Change contract templates
This commit is contained in:
		
				
					committed by
					
						
						Amir Bandeali
					
				
			
			
				
	
			
			
			
						parent
						
							600a2b40af
						
					
				
				
					commit
					eea8b15180
				
			@@ -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']);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,15 +1,10 @@
 | 
			
		||||
public {{this.name}} = {
 | 
			
		||||
    async callAsync(
 | 
			
		||||
    {{> typed_params inputs=inputs}}
 | 
			
		||||
public async {{this.name}}(
 | 
			
		||||
{{> typed_params inputs=inputs}}
 | 
			
		||||
    defaultBlock?: Web3.BlockParam,
 | 
			
		||||
    ): Promise<{{> return_type outputs=outputs}}> {
 | 
			
		||||
): 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,
 | 
			
		||||
        )(
 | 
			
		||||
    const result = await self._web3ContractInstance.{{this.name}}.call(
 | 
			
		||||
        {{> params inputs=inputs}}
 | 
			
		||||
    );
 | 
			
		||||
    return result;
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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}}
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user