diff options
author | Olaf Tomalka <olaf@tomalka.me> | 2018-01-31 21:24:20 +0800 |
---|---|---|
committer | Olaf Tomalka <olaf@tomalka.me> | 2018-01-31 21:24:20 +0800 |
commit | eaeb715e56bbb3243268ee5fd863cfd1f1211c39 (patch) | |
tree | f3a833bf8fc2cf1467bfc6c2a8bc02da87b87e2a /packages/0x.js/contract_templates/partials/tx.handlebars | |
parent | fa35768fc9647c475f8132c6b431102a30b4efe1 (diff) | |
download | dexon-0x-contracts-eaeb715e56bbb3243268ee5fd863cfd1f1211c39.tar dexon-0x-contracts-eaeb715e56bbb3243268ee5fd863cfd1f1211c39.tar.gz dexon-0x-contracts-eaeb715e56bbb3243268ee5fd863cfd1f1211c39.tar.bz2 dexon-0x-contracts-eaeb715e56bbb3243268ee5fd863cfd1f1211c39.tar.lz dexon-0x-contracts-eaeb715e56bbb3243268ee5fd863cfd1f1211c39.tar.xz dexon-0x-contracts-eaeb715e56bbb3243268ee5fd863cfd1f1211c39.tar.zst dexon-0x-contracts-eaeb715e56bbb3243268ee5fd863cfd1f1211c39.zip |
Updated contract generation in 0x to new abi-gen CLI
Diffstat (limited to 'packages/0x.js/contract_templates/partials/tx.handlebars')
-rw-r--r-- | packages/0x.js/contract_templates/partials/tx.handlebars | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/packages/0x.js/contract_templates/partials/tx.handlebars b/packages/0x.js/contract_templates/partials/tx.handlebars new file mode 100644 index 000000000..8a43e5319 --- /dev/null +++ b/packages/0x.js/contract_templates/partials/tx.handlebars @@ -0,0 +1,51 @@ +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, + self.{{this.name}}.estimateGasAsync.bind( + self, + {{> params inputs=inputs}} + ), + ); + const txHash = await promisify<string>( + self.web3ContractInstance.{{this.name}}, self.web3ContractInstance, + )( + {{> params inputs=inputs}} + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + {{> typed_params inputs=inputs}} + txData: TxData = {}, + ): Promise<number> { + const self = this as {{contractName}}Contract; + const txDataWithDefaults = await self.applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self.web3ContractInstance.{{this.name}}.estimateGas, self.web3ContractInstance, + )( + {{> params inputs=inputs}} + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + {{> typed_params inputs=inputs}} + txData: TxData = {}, + ): string { + const self = this as {{contractName}}Contract; + const abiEncodedTransactionData = self.web3ContractInstance.{{this.name}}.getData(); + return abiEncodedTransactionData; + }, +}; |