@@ -65,14 +65,15 @@ class Commands {
6565 *
6666 * @param {string } template - template directory
6767 * @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
7374 * @returns {object } Promise to the result of execution
7475 */
75- static async trigger ( template , files , contractInput , stateInput , currentTime , requestsInput , warnings ) {
76+ static async trigger ( template , files , contractInput , stateInput , currentTime , utcOffset , requestsInput , warnings ) {
7677 try {
7778 const logicManager = await loadTemplate ( template , files ) ;
7879 const contractJson = getJson ( contractInput ) ;
@@ -83,15 +84,15 @@ class Commands {
8384 const engine = new Engine ( ) ;
8485 let initResponse ;
8586 if ( stateInput === null ) {
86- initResponse = engine . compileAndInit ( logicManager , contractJson , { } , currentTime , null ) ;
87+ initResponse = engine . compileAndInit ( logicManager , contractJson , { } , currentTime , utcOffset ) ;
8788 } else {
8889 const stateJson = getJson ( stateInput ) ;
8990 initResponse = Promise . resolve ( { state : stateJson } ) ;
9091 }
9192 // Get all the other requests and chain execution through Promise.reduce()
9293 return requestsJson . reduce ( ( promise , requestJson ) => {
9394 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 ) ;
9596 } ) ;
9697 } , initResponse ) ;
9798 } catch ( err ) {
@@ -104,22 +105,23 @@ class Commands {
104105 *
105106 * @param {string } template - template directory
106107 * @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
113115 * @returns {object } Promise to the result of invocation
114116 */
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 ) {
116118 try {
117119 const logicManager = await loadTemplate ( template , files ) ;
118120 const contractJson = getJson ( contractInput ) ;
119121 const clauseParams = getJson ( paramsInput ) ;
120122 const stateJson = getJson ( stateInput ) ;
121123 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 ) ;
123125 } catch ( err ) {
124126 return Promise . reject ( err ) ;
125127 }
@@ -130,19 +132,20 @@ class Commands {
130132 *
131133 * @param {string } template - template directory
132134 * @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
137140 * @returns {object } Promise to the result of execution
138141 */
139- static async initialize ( template , files , contractInput , currentTime , paramsInput , warnings ) {
142+ static async initialize ( template , files , contractInput , currentTime , utcOffset , paramsInput , warnings ) {
140143 try {
141144 const logicManager = await loadTemplate ( template , files ) ;
142145 const contractJson = getJson ( contractInput ) ;
143146 const clauseParams = getJson ( paramsInput ) ;
144147 const engine = new Engine ( ) ;
145- return engine . compileAndInit ( logicManager , contractJson , clauseParams , currentTime , null ) ;
148+ return engine . compileAndInit ( logicManager , contractJson , clauseParams , currentTime , utcOffset ) ;
146149 } catch ( err ) {
147150 return Promise . reject ( err ) ;
148151 }
0 commit comments