diff options
Diffstat (limited to 'packages')
4 files changed, 28 insertions, 43 deletions
diff --git a/packages/contracts/contract_templates/contract.handlebars b/packages/contracts/contract_templates/contract.handlebars index d3fe1b8cc..f9ffb730c 100644 --- a/packages/contracts/contract_templates/contract.handlebars +++ b/packages/contracts/contract_templates/contract.handlebars @@ -2,6 +2,7 @@ * This file is auto-generated using abi-gen. Don't edit directly. * Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates. */ +// tslint:disable:async-suffix member-ordering // tslint:disable-next-line:no-unused-variable import { TxData, TxDataPayable } from '@0xproject/types'; import { BigNumber, classUtils, promisify } from '@0xproject/utils'; @@ -18,7 +19,7 @@ export class {{contractName}}Contract extends BaseContract { {{> tx contractName=../contractName}} {{/this.constant}} {{/each}} - constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) { + constructor(web3ContractInstance: Web3.ContractInstance, defaults?: Partial<TxData>) { super(web3ContractInstance, defaults); classUtils.bindAll(this, ['_web3ContractInstance', '_defaults']); } diff --git a/packages/contracts/contract_templates/partials/call.handlebars b/packages/contracts/contract_templates/partials/call.handlebars index 0475136f0..82a45b40e 100644 --- a/packages/contracts/contract_templates/partials/call.handlebars +++ b/packages/contracts/contract_templates/partials/call.handlebars @@ -1,15 +1,10 @@ -public {{this.name}} = { - async callAsync( - {{> typed_params inputs=inputs}} - defaultBlock?: Web3.BlockParam, - ): Promise<{{> return_type outputs=outputs}}> { - const self = this as {{contractName}}Contract; - const result = await promisify<{{> return_type outputs=outputs}}>( - self._web3ContractInstance.{{this.name}}.call, - self._web3ContractInstance, - )( - {{> params inputs=inputs}} - ); - return result; - }, -}; +public async {{this.name}}( +{{> typed_params inputs=inputs}} + defaultBlock?: Web3.BlockParam, +): Promise<{{> return_type outputs=outputs}}> { + const self = this as {{contractName}}Contract; + const result = await self._web3ContractInstance.{{this.name}}.call( + {{> params inputs=inputs}} + ); + return result; +} diff --git a/packages/contracts/contract_templates/partials/return_type.handlebars b/packages/contracts/contract_templates/partials/return_type.handlebars index 383961a40..40a5dd8b0 100644 --- a/packages/contracts/contract_templates/partials/return_type.handlebars +++ b/packages/contracts/contract_templates/partials/return_type.handlebars @@ -1,6 +1,10 @@ +{{#if outputs.length}} {{#singleReturnValue}} {{#returnType outputs.0.type}}{{/returnType}} {{/singleReturnValue}} {{^singleReturnValue}} [{{#each outputs}}{{#returnType type}}{{/returnType}}{{#unless @last}}, {{/unless}}{{/each}}] {{/singleReturnValue}} +{{else}} +void +{{/if}} diff --git a/packages/contracts/contract_templates/partials/tx.handlebars b/packages/contracts/contract_templates/partials/tx.handlebars index 9df83266a..69ae982d6 100644 --- a/packages/contracts/contract_templates/partials/tx.handlebars +++ b/packages/contracts/contract_templates/partials/tx.handlebars @@ -9,43 +9,28 @@ public {{this.name}} = { {{/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, - )( + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(txData); + const txHash = await self._web3ContractInstance.{{this.name}}( {{> params inputs=inputs}} txDataWithDefaults, ); return txHash; }, - async estimateGasAsync( + async callAsync( {{> typed_params inputs=inputs}} + {{#this.payable}} + txData: TxDataPayable = {}, + {{/this.payable}} + {{^this.payable}} txData: TxData = {}, - ): Promise<number> { + {{/this.payable}} + ): Promise<{{> return_type outputs=outputs}}> { const self = this as {{contractName}}Contract; - const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( - txData, - ); - const gas = await promisify<number>( - self._web3ContractInstance.{{this.name}}.estimateGas, self._web3ContractInstance, - )( + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(txData); + const returnValue = await self._web3ContractInstance.{{this.name}}.call( {{> 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; + return returnValue; }, }; |