aboutsummaryrefslogtreecommitdiffstats
path: root/packages/abi-gen-templates
diff options
context:
space:
mode:
Diffstat (limited to 'packages/abi-gen-templates')
-rw-r--r--packages/abi-gen-templates/contract.handlebars2
-rw-r--r--packages/abi-gen-templates/partials/callAsync.handlebars17
-rw-r--r--packages/abi-gen-templates/partials/tx.handlebars13
3 files changed, 10 insertions, 22 deletions
diff --git a/packages/abi-gen-templates/contract.handlebars b/packages/abi-gen-templates/contract.handlebars
index 9b2a2b336..7e7171c70 100644
--- a/packages/abi-gen-templates/contract.handlebars
+++ b/packages/abi-gen-templates/contract.handlebars
@@ -85,7 +85,7 @@ export class {{contractName}}Contract extends BaseContract {
}
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
super('{{contractName}}', abi, address, provider, txDefaults);
- classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
+ classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
}
} // tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method
diff --git a/packages/abi-gen-templates/partials/callAsync.handlebars b/packages/abi-gen-templates/partials/callAsync.handlebars
index ddbbe7508..ab9f2c21c 100644
--- a/packages/abi-gen-templates/partials/callAsync.handlebars
+++ b/packages/abi-gen-templates/partials/callAsync.handlebars
@@ -4,12 +4,7 @@ async callAsync(
defaultBlock?: BlockParam,
): Promise<{{> return_type outputs=outputs}}> {
const self = this as any as {{contractName}}Contract;
- const functionSignature = '{{this.functionSignature}}';
- const inputAbi = self._lookupAbi(functionSignature).inputs;
- [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
- BaseContract.strictArgumentEncodingCheck(inputAbi, [{{> params inputs=inputs}}]);
- const ethersFunction = self._lookupEthersInterface(functionSignature).functions.{{this.name}};
- const encodedData = ethersFunction.encode([{{> params inputs=inputs}}]);
+ const encodedData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> params inputs=inputs}}]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{
to: self.address,
@@ -20,9 +15,9 @@ async callAsync(
);
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
- let resultArray = ethersFunction.decode(rawCallResult);
- const outputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).outputs;
- resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
- resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
- return resultArray{{#singleReturnValue}}[0]{{/singleReturnValue}};
+ const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}');
+ // tslint:disable boolean-naming
+ const result = abiEncoder.strictDecodeReturnValue<{{> return_type outputs=outputs}}>(rawCallResult);
+ // tslint:enable boolean-naming
+ return result;
},
diff --git a/packages/abi-gen-templates/partials/tx.handlebars b/packages/abi-gen-templates/partials/tx.handlebars
index b39156583..0f1027fae 100644
--- a/packages/abi-gen-templates/partials/tx.handlebars
+++ b/packages/abi-gen-templates/partials/tx.handlebars
@@ -9,10 +9,7 @@ public {{this.tsName}} = {
{{/this.payable}}
): Promise<string> {
const self = this as any as {{contractName}}Contract;
- const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs;
- [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
- BaseContract.strictArgumentEncodingCheck(inputAbi, [{{> params inputs=inputs}}]);
- const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}.encode([{{> params inputs=inputs}}]);
+ const encodedData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> params inputs=inputs}}]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{
to: self.address,
@@ -33,9 +30,7 @@ public {{this.tsName}} = {
txData: Partial<TxData> = {},
): Promise<number> {
const self = this as any as {{contractName}}Contract;
- const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs;
- [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString);
- const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}.encode([{{> params inputs=inputs}}]);
+ const encodedData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> params inputs=inputs}}]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{
to: self.address,
@@ -51,9 +46,7 @@ public {{this.tsName}} = {
{{> typed_params inputs=inputs}}
): string {
const self = this as any as {{contractName}}Contract;
- const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs;
- [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString);
- const abiEncodedTransactionData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}.encode([{{> params inputs=inputs}}]);
+ const abiEncodedTransactionData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> params inputs=inputs}}]);
return abiEncodedTransactionData;
},
{{> callAsync}}