Change contract templates
This commit is contained in:
parent
600a2b40af
commit
eea8b15180
@ -2,6 +2,7 @@
|
|||||||
* This file is auto-generated using abi-gen. Don't edit directly.
|
* 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.
|
* 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
|
// tslint:disable-next-line:no-unused-variable
|
||||||
import { TxData, TxDataPayable } from '@0xproject/types';
|
import { TxData, TxDataPayable } from '@0xproject/types';
|
||||||
import { BigNumber, classUtils, promisify } from '@0xproject/utils';
|
import { BigNumber, classUtils, promisify } from '@0xproject/utils';
|
||||||
@ -18,7 +19,7 @@ export class {{contractName}}Contract extends BaseContract {
|
|||||||
{{> tx contractName=../contractName}}
|
{{> tx contractName=../contractName}}
|
||||||
{{/this.constant}}
|
{{/this.constant}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) {
|
constructor(web3ContractInstance: Web3.ContractInstance, defaults?: Partial<TxData>) {
|
||||||
super(web3ContractInstance, defaults);
|
super(web3ContractInstance, defaults);
|
||||||
classUtils.bindAll(this, ['_web3ContractInstance', '_defaults']);
|
classUtils.bindAll(this, ['_web3ContractInstance', '_defaults']);
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,10 @@
|
|||||||
public {{this.name}} = {
|
public async {{this.name}}(
|
||||||
async callAsync(
|
{{> typed_params inputs=inputs}}
|
||||||
{{> typed_params inputs=inputs}}
|
defaultBlock?: Web3.BlockParam,
|
||||||
defaultBlock?: Web3.BlockParam,
|
): Promise<{{> return_type outputs=outputs}}> {
|
||||||
): Promise<{{> return_type outputs=outputs}}> {
|
const self = this as {{contractName}}Contract;
|
||||||
const self = this as {{contractName}}Contract;
|
const result = await self._web3ContractInstance.{{this.name}}.call(
|
||||||
const result = await promisify<{{> return_type outputs=outputs}}>(
|
{{> params inputs=inputs}}
|
||||||
self._web3ContractInstance.{{this.name}}.call,
|
);
|
||||||
self._web3ContractInstance,
|
return result;
|
||||||
)(
|
}
|
||||||
{{> params inputs=inputs}}
|
|
||||||
);
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
|
{{#if outputs.length}}
|
||||||
{{#singleReturnValue}}
|
{{#singleReturnValue}}
|
||||||
{{#returnType outputs.0.type}}{{/returnType}}
|
{{#returnType outputs.0.type}}{{/returnType}}
|
||||||
{{/singleReturnValue}}
|
{{/singleReturnValue}}
|
||||||
{{^singleReturnValue}}
|
{{^singleReturnValue}}
|
||||||
[{{#each outputs}}{{#returnType type}}{{/returnType}}{{#unless @last}}, {{/unless}}{{/each}}]
|
[{{#each outputs}}{{#returnType type}}{{/returnType}}{{#unless @last}}, {{/unless}}{{/each}}]
|
||||||
{{/singleReturnValue}}
|
{{/singleReturnValue}}
|
||||||
|
{{else}}
|
||||||
|
void
|
||||||
|
{{/if}}
|
||||||
|
@ -9,43 +9,28 @@ public {{this.name}} = {
|
|||||||
{{/this.payable}}
|
{{/this.payable}}
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const self = this as {{contractName}}Contract;
|
const self = this as {{contractName}}Contract;
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(txData);
|
||||||
txData,
|
const txHash = await self._web3ContractInstance.{{this.name}}(
|
||||||
self.{{this.name}}.estimateGasAsync.bind(
|
|
||||||
self,
|
|
||||||
{{> params inputs=inputs}}
|
|
||||||
),
|
|
||||||
);
|
|
||||||
const txHash = await promisify<string>(
|
|
||||||
self._web3ContractInstance.{{this.name}}, self._web3ContractInstance,
|
|
||||||
)(
|
|
||||||
{{> params inputs=inputs}}
|
{{> params inputs=inputs}}
|
||||||
txDataWithDefaults,
|
txDataWithDefaults,
|
||||||
);
|
);
|
||||||
return txHash;
|
return txHash;
|
||||||
},
|
},
|
||||||
async estimateGasAsync(
|
async callAsync(
|
||||||
{{> typed_params inputs=inputs}}
|
{{> typed_params inputs=inputs}}
|
||||||
|
{{#this.payable}}
|
||||||
|
txData: TxDataPayable = {},
|
||||||
|
{{/this.payable}}
|
||||||
|
{{^this.payable}}
|
||||||
txData: TxData = {},
|
txData: TxData = {},
|
||||||
): Promise<number> {
|
{{/this.payable}}
|
||||||
|
): Promise<{{> return_type outputs=outputs}}> {
|
||||||
const self = this as {{contractName}}Contract;
|
const self = this as {{contractName}}Contract;
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(txData);
|
||||||
txData,
|
const returnValue = await self._web3ContractInstance.{{this.name}}.call(
|
||||||
);
|
|
||||||
const gas = await promisify<number>(
|
|
||||||
self._web3ContractInstance.{{this.name}}.estimateGas, self._web3ContractInstance,
|
|
||||||
)(
|
|
||||||
{{> params inputs=inputs}}
|
{{> params inputs=inputs}}
|
||||||
txDataWithDefaults,
|
txDataWithDefaults,
|
||||||
);
|
);
|
||||||
return gas;
|
return returnValue;
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(
|
|
||||||
{{> typed_params inputs=inputs}}
|
|
||||||
txData: TxData = {},
|
|
||||||
): string {
|
|
||||||
const self = this as {{contractName}}Contract;
|
|
||||||
const abiEncodedTransactionData = self._web3ContractInstance.{{this.name}}.getData();
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user