aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-02-06 23:37:42 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-02-07 09:27:47 +0800
commiteea8b15180d3e6616a908a8eb4c537df7d87a6ab (patch)
treeb257751abc8cb16f84133493b043616c7d801fa8 /packages/contracts
parent600a2b40af0430d4037f86f6ffe21d6edf3fb166 (diff)
downloaddexon-0x-contracts-eea8b15180d3e6616a908a8eb4c537df7d87a6ab.tar
dexon-0x-contracts-eea8b15180d3e6616a908a8eb4c537df7d87a6ab.tar.gz
dexon-0x-contracts-eea8b15180d3e6616a908a8eb4c537df7d87a6ab.tar.bz2
dexon-0x-contracts-eea8b15180d3e6616a908a8eb4c537df7d87a6ab.tar.lz
dexon-0x-contracts-eea8b15180d3e6616a908a8eb4c537df7d87a6ab.tar.xz
dexon-0x-contracts-eea8b15180d3e6616a908a8eb4c537df7d87a6ab.tar.zst
dexon-0x-contracts-eea8b15180d3e6616a908a8eb4c537df7d87a6ab.zip
Change contract templates
Diffstat (limited to 'packages/contracts')
-rw-r--r--packages/contracts/contract_templates/contract.handlebars3
-rw-r--r--packages/contracts/contract_templates/partials/call.handlebars25
-rw-r--r--packages/contracts/contract_templates/partials/return_type.handlebars4
-rw-r--r--packages/contracts/contract_templates/partials/tx.handlebars39
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;
},
};