aboutsummaryrefslogtreecommitdiffstats
path: root/packages/abi-gen-templates
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2019-01-15 22:13:24 +0800
committerFabio Berger <me@fabioberger.com>2019-01-15 22:13:24 +0800
commit7c37d10d1f93791db75b1622efa775a361965c49 (patch)
tree7017104bea27120661f71701552214dc5efba909 /packages/abi-gen-templates
parentaffd6170540034c31593a4f36ce1dbacb91b6b3e (diff)
parent18084588ea9fa724d6e32c9a49c79d49f189ba7c (diff)
downloaddexon-sol-tools-7c37d10d1f93791db75b1622efa775a361965c49.tar
dexon-sol-tools-7c37d10d1f93791db75b1622efa775a361965c49.tar.gz
dexon-sol-tools-7c37d10d1f93791db75b1622efa775a361965c49.tar.bz2
dexon-sol-tools-7c37d10d1f93791db75b1622efa775a361965c49.tar.lz
dexon-sol-tools-7c37d10d1f93791db75b1622efa775a361965c49.tar.xz
dexon-sol-tools-7c37d10d1f93791db75b1622efa775a361965c49.tar.zst
dexon-sol-tools-7c37d10d1f93791db75b1622efa775a361965c49.zip
Merge branch 'development' into feature/monorepo-scripts/publishToDockerHub
* development: (87 commits) Update packages/sol-tracing-utils/src/trace_collection_subprovider.ts Make mapping namings direct Remove unused tslint disable Revert "Remove logAsyncErrors hack" Remove logAsyncErrors hack Refactor logAsyncErrors to follow our conventions Export Sources and SourceCodes out of tracing utils Replace console.log with logUtils.log (#1515) strict decoding of return values using generics makerAssetFillAmount -> takerAssetFillAmount Ran prettier Linter Fix build after rebase Style cleanup for Compressed Calldata in Contract Wrappers PR Use simpler `_.find` to locate fillOrderBai Updated dutch auction wrapper Added back abi-gen-wrappers Renamed signatureParser.ts to signature_parser.ts Renamed decode rule `structsAsObjects` to `shouldConvertStructsToObjects` circle build failed. New commit to resubmit job. ...
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}}