35 lines
1.4 KiB
Handlebars
35 lines
1.4 KiB
Handlebars
async callAsync(
|
|
{{> typed_params inputs=inputs}}
|
|
callData: Partial<CallData> = {},
|
|
defaultBlock?: BlockParam,
|
|
): Promise<{{> return_type outputs=outputs}}> {
|
|
{{#each inputs}}
|
|
{{#assertionType name type}}{{/assertionType}}
|
|
{{/each}}
|
|
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
|
|
schemas.addressSchema,
|
|
schemas.numberSchema,
|
|
schemas.jsNumber,
|
|
]);
|
|
if (defaultBlock !== undefined) {
|
|
assert.isBlockParam('defaultBlock', defaultBlock);
|
|
}
|
|
const self = this as any as {{contractName}}Contract;
|
|
const encodedData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> params inputs=inputs}}]);
|
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
|
{
|
|
to: self.address,
|
|
...callData,
|
|
data: encodedData,
|
|
},
|
|
self._web3Wrapper.getContractDefaults(),
|
|
);
|
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
|
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;
|
|
},
|