diff options
Diffstat (limited to 'packages/contracts/contract_templates/partials/tx.handlebars')
-rw-r--r-- | packages/contracts/contract_templates/partials/tx.handlebars | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/packages/contracts/contract_templates/partials/tx.handlebars b/packages/contracts/contract_templates/partials/tx.handlebars new file mode 100644 index 000000000..69ae982d6 --- /dev/null +++ b/packages/contracts/contract_templates/partials/tx.handlebars @@ -0,0 +1,36 @@ +public {{this.name}} = { + async sendTransactionAsync( + {{> typed_params inputs=inputs}} + {{#this.payable}} + txData: TxDataPayable = {}, + {{/this.payable}} + {{^this.payable}} + txData: TxData = {}, + {{/this.payable}} + ): Promise<string> { + const self = this as {{contractName}}Contract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(txData); + const txHash = await self._web3ContractInstance.{{this.name}}( + {{> params inputs=inputs}} + txDataWithDefaults, + ); + return txHash; + }, + async callAsync( + {{> typed_params inputs=inputs}} + {{#this.payable}} + txData: TxDataPayable = {}, + {{/this.payable}} + {{^this.payable}} + txData: TxData = {}, + {{/this.payable}} + ): Promise<{{> return_type outputs=outputs}}> { + const self = this as {{contractName}}Contract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(txData); + const returnValue = await self._web3ContractInstance.{{this.name}}.call( + {{> params inputs=inputs}} + txDataWithDefaults, + ); + return returnValue; + }, +}; |