aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract_templates/partials/tx.handlebars
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-03-27 21:19:23 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-03-27 23:56:21 +0800
commitd72b7299c66ea6d63eb14595b06456c02b2ad99b (patch)
treee026f0af7f779c0c94ddc1261f630dd8ca923af5 /packages/contract_templates/partials/tx.handlebars
parent066d13f5b7260d28b13195c4f9aed48b4ae96cc3 (diff)
downloaddexon-sol-tools-d72b7299c66ea6d63eb14595b06456c02b2ad99b.tar
dexon-sol-tools-d72b7299c66ea6d63eb14595b06456c02b2ad99b.tar.gz
dexon-sol-tools-d72b7299c66ea6d63eb14595b06456c02b2ad99b.tar.bz2
dexon-sol-tools-d72b7299c66ea6d63eb14595b06456c02b2ad99b.tar.lz
dexon-sol-tools-d72b7299c66ea6d63eb14595b06456c02b2ad99b.tar.xz
dexon-sol-tools-d72b7299c66ea6d63eb14595b06456c02b2ad99b.tar.zst
dexon-sol-tools-d72b7299c66ea6d63eb14595b06456c02b2ad99b.zip
Move common types out of web3 types
Diffstat (limited to 'packages/contract_templates/partials/tx.handlebars')
-rw-r--r--packages/contract_templates/partials/tx.handlebars27
1 files changed, 13 insertions, 14 deletions
diff --git a/packages/contract_templates/partials/tx.handlebars b/packages/contract_templates/partials/tx.handlebars
index d517a9f7f..f76de3a70 100644
--- a/packages/contract_templates/partials/tx.handlebars
+++ b/packages/contract_templates/partials/tx.handlebars
@@ -2,16 +2,16 @@ public {{this.name}} = {
async sendTransactionAsync(
{{> typed_params inputs=inputs}}
{{#this.payable}}
- txData: TxDataPayable = {},
+ txData: Partial<TxDataPayable> = {},
{{/this.payable}}
{{^this.payable}}
- txData: TxData = {},
+ txData: Partial<TxData> = {},
{{/this.payable}}
): Promise<string> {
const self = this as {{contractName}}Contract;
- const inputAbi = _.find(this.abi, {name: '{{this.name}}'}).inputs;
- [{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(this));
- const encodedData = this._ethersInterface.functions.{{this.name}}(
+ const inputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).inputs;
+ [{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
+ const encodedData = self._ethersInterface.functions.{{this.name}}(
{{> params inputs=inputs}}
).data
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
@@ -24,17 +24,17 @@ public {{this.name}} = {
{{> params inputs=inputs}}
),
);
- const txHash = await this._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
+ const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
return txHash;
},
async estimateGasAsync(
{{> typed_params inputs=inputs}}
- txData: TxData = {},
+ txData: Partial<TxData> = {},
): Promise<number> {
const self = this as {{contractName}}Contract;
- const inputAbi = _.find(this.abi, {name: '{{this.name}}'}).inputs;
+ const inputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).inputs;
[{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(this));
- const encodedData = this._ethersInterface.functions.{{this.name}}(
+ const encodedData = self._ethersInterface.functions.{{this.name}}(
{{> params inputs=inputs}}
).data
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
@@ -43,17 +43,16 @@ public {{this.name}} = {
data: encodedData,
}
);
- const gas = await this._web3Wrapper.estimateGasAsync(txDataWithDefaults);
+ const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
return gas;
},
getABIEncodedTransactionData(
{{> typed_params inputs=inputs}}
- txData: TxData = {},
): string {
const self = this as {{contractName}}Contract;
- const inputAbi = _.find(this.abi, {name: '{{this.name}}'}).inputs;
- [{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(this));
- const abiEncodedTransactionData = this._ethersInterface.functions.{{this.name}}(
+ const inputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).inputs;
+ [{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
+ const abiEncodedTransactionData = self._ethersInterface.functions.{{this.name}}(
{{> params inputs=inputs}}
).data
return abiEncodedTransactionData;