@@ -65,14 +65,15 @@ class Commands {
65
65
*
66
66
* @param {string } template - template directory
67
67
* @param {string[] } files - input files
68
- * @param {string } contractInput the contract data
69
- * @param {string } stateInput the contract state
70
- * @param {string } currentTime the definition of 'now'
71
- * @param {string[] } requestsInput the requests
72
- * @param {boolean } warnings whether to print warnings
68
+ * @param {string } contractInput - the contract data
69
+ * @param {string } stateInput - the contract state
70
+ * @param {string } [currentTime] - the definition of 'now', defaults to current time
71
+ * @param {number } [utcOffset] - UTC Offset for this execution, defaults to local offset
72
+ * @param {string[] } requestsInput - the requests
73
+ * @param {boolean } warnings - whether to print warnings
73
74
* @returns {object } Promise to the result of execution
74
75
*/
75
- static async trigger ( template , files , contractInput , stateInput , currentTime , requestsInput , warnings ) {
76
+ static async trigger ( template , files , contractInput , stateInput , currentTime , utcOffset , requestsInput , warnings ) {
76
77
try {
77
78
const logicManager = await loadTemplate ( template , files ) ;
78
79
const contractJson = getJson ( contractInput ) ;
@@ -83,15 +84,15 @@ class Commands {
83
84
const engine = new Engine ( ) ;
84
85
let initResponse ;
85
86
if ( stateInput === null ) {
86
- initResponse = engine . compileAndInit ( logicManager , contractJson , { } , currentTime , null ) ;
87
+ initResponse = engine . compileAndInit ( logicManager , contractJson , { } , currentTime , utcOffset ) ;
87
88
} else {
88
89
const stateJson = getJson ( stateInput ) ;
89
90
initResponse = Promise . resolve ( { state : stateJson } ) ;
90
91
}
91
92
// Get all the other requests and chain execution through Promise.reduce()
92
93
return requestsJson . reduce ( ( promise , requestJson ) => {
93
94
return promise . then ( ( result ) => {
94
- return engine . compileAndTrigger ( logicManager , contractJson , requestJson , result . state , currentTime , null ) ;
95
+ return engine . compileAndTrigger ( logicManager , contractJson , requestJson , result . state , currentTime , utcOffset ) ;
95
96
} ) ;
96
97
} , initResponse ) ;
97
98
} catch ( err ) {
@@ -104,22 +105,23 @@ class Commands {
104
105
*
105
106
* @param {string } template - template directory
106
107
* @param {string[] } files - input files
107
- * @param {string } clauseName the name of the clause to invoke
108
- * @param {string } contractInput the contract data
109
- * @param {string } stateInput the contract state
110
- * @param {string } currentTime the definition of 'now'
111
- * @param {object } paramsInput the parameters for the clause
112
- * @param {boolean } warnings whether to print warnings
108
+ * @param {string } clauseName - the name of the clause to invoke
109
+ * @param {string } contractInput - the contract data
110
+ * @param {string } stateInput - the contract state
111
+ * @param {string } [currentTime] - the definition of 'now', defaults to current time
112
+ * @param {number } [utcOffset] - UTC Offset for this execution, defaults to local offset
113
+ * @param {object } paramsInput - the parameters for the clause
114
+ * @param {boolean } warnings - whether to print warnings
113
115
* @returns {object } Promise to the result of invocation
114
116
*/
115
- static async invoke ( template , files , clauseName , contractInput , stateInput , currentTime , paramsInput , warnings ) {
117
+ static async invoke ( template , files , clauseName , contractInput , stateInput , currentTime , utcOffset , paramsInput , warnings ) {
116
118
try {
117
119
const logicManager = await loadTemplate ( template , files ) ;
118
120
const contractJson = getJson ( contractInput ) ;
119
121
const clauseParams = getJson ( paramsInput ) ;
120
122
const stateJson = getJson ( stateInput ) ;
121
123
const engine = new Engine ( ) ;
122
- return engine . compileAndInvoke ( logicManager , clauseName , contractJson , clauseParams , stateJson , currentTime , null ) ;
124
+ return engine . compileAndInvoke ( logicManager , clauseName , contractJson , clauseParams , stateJson , currentTime , utcOffset ) ;
123
125
} catch ( err ) {
124
126
return Promise . reject ( err ) ;
125
127
}
@@ -130,19 +132,20 @@ class Commands {
130
132
*
131
133
* @param {string } template - template directory
132
134
* @param {string[] } files - input files
133
- * @param {string } contractInput the contract data
134
- * @param {string } currentTime the definition of 'now'
135
- * @param {object } paramsInput the parameters for the clause
136
- * @param {boolean } warnings whether to print warnings
135
+ * @param {string } contractInput - the contract data
136
+ * @param {string } [currentTime] - the definition of 'now', defaults to current time
137
+ * @param {number } [utcOffset] - UTC Offset for this execution, defaults to local offset
138
+ * @param {object } paramsInput - the parameters for the clause
139
+ * @param {boolean } warnings - whether to print warnings
137
140
* @returns {object } Promise to the result of execution
138
141
*/
139
- static async initialize ( template , files , contractInput , currentTime , paramsInput , warnings ) {
142
+ static async initialize ( template , files , contractInput , currentTime , utcOffset , paramsInput , warnings ) {
140
143
try {
141
144
const logicManager = await loadTemplate ( template , files ) ;
142
145
const contractJson = getJson ( contractInput ) ;
143
146
const clauseParams = getJson ( paramsInput ) ;
144
147
const engine = new Engine ( ) ;
145
- return engine . compileAndInit ( logicManager , contractJson , clauseParams , currentTime , null ) ;
148
+ return engine . compileAndInit ( logicManager , contractJson , clauseParams , currentTime , utcOffset ) ;
146
149
} catch ( err ) {
147
150
return Promise . reject ( err ) ;
148
151
}
0 commit comments