aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-02-27 09:04:19 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-02-28 04:07:06 +0800
commitef40cb96876cb77e897be441ceff1ca1521dc682 (patch)
tree8f9588a1e615c7c6289c0a433b9c17d82e10f57b
parent758604fc1ab1fecf1303eef9dfb81192957e495e (diff)
downloaddexon-sol-tools-ef40cb96876cb77e897be441ceff1ca1521dc682.tar
dexon-sol-tools-ef40cb96876cb77e897be441ceff1ca1521dc682.tar.gz
dexon-sol-tools-ef40cb96876cb77e897be441ceff1ca1521dc682.tar.bz2
dexon-sol-tools-ef40cb96876cb77e897be441ceff1ca1521dc682.tar.lz
dexon-sol-tools-ef40cb96876cb77e897be441ceff1ca1521dc682.tar.xz
dexon-sol-tools-ef40cb96876cb77e897be441ceff1ca1521dc682.tar.zst
dexon-sol-tools-ef40cb96876cb77e897be441ceff1ca1521dc682.zip
Add txData to async calls
-rw-r--r--packages/0x.js/src/contract_wrappers/exchange_wrapper.ts8
-rw-r--r--packages/0x.js/src/contract_wrappers/token_wrapper.ts5
-rw-r--r--packages/contract_templates/partials/callAsync.handlebars3
-rw-r--r--packages/web3-wrapper/src/index.ts4
4 files changed, 14 insertions, 6 deletions
diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
index e0f6bd539..20b46c6bc 100644
--- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
@@ -108,8 +108,10 @@ export class ExchangeWrapper extends ContractWrapper {
const exchangeContract = await this._getExchangeContractAsync();
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
+ const txData = {};
let unavailableTakerTokenAmount = await exchangeContract.getUnavailableTakerTokenAmount.callAsync(
orderHash,
+ txData,
defaultBlock,
);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
@@ -127,7 +129,8 @@ export class ExchangeWrapper extends ContractWrapper {
const exchangeContract = await this._getExchangeContractAsync();
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
- let fillAmountInBaseUnits = await exchangeContract.filled.callAsync(orderHash, defaultBlock);
+ const txData = {};
+ let fillAmountInBaseUnits = await exchangeContract.filled.callAsync(orderHash, txData, defaultBlock);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
fillAmountInBaseUnits = new BigNumber(fillAmountInBaseUnits);
return fillAmountInBaseUnits;
@@ -144,7 +147,8 @@ export class ExchangeWrapper extends ContractWrapper {
const exchangeContract = await this._getExchangeContractAsync();
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
- let cancelledAmountInBaseUnits = await exchangeContract.cancelled.callAsync(orderHash, defaultBlock);
+ const txData = {};
+ let cancelledAmountInBaseUnits = await exchangeContract.cancelled.callAsync(orderHash, txData, defaultBlock);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
cancelledAmountInBaseUnits = new BigNumber(cancelledAmountInBaseUnits);
return cancelledAmountInBaseUnits;
diff --git a/packages/0x.js/src/contract_wrappers/token_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_wrapper.ts
index 0ec9ad707..0f688cb71 100644
--- a/packages/0x.js/src/contract_wrappers/token_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/token_wrapper.ts
@@ -51,7 +51,8 @@ export class TokenWrapper extends ContractWrapper {
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
- let balance = await tokenContract.balanceOf.callAsync(normalizedOwnerAddress, defaultBlock);
+ const txData = {};
+ let balance = await tokenContract.balanceOf.callAsync(normalizedOwnerAddress, txData, defaultBlock);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
balance = new BigNumber(balance);
return balance;
@@ -146,9 +147,11 @@ export class TokenWrapper extends ContractWrapper {
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
+ const txData = {};
let allowanceInBaseUnits = await tokenContract.allowance.callAsync(
normalizedOwnerAddress,
normalizedSpenderAddress,
+ txData,
defaultBlock,
);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
diff --git a/packages/contract_templates/partials/callAsync.handlebars b/packages/contract_templates/partials/callAsync.handlebars
index 88cc49ffa..93d347145 100644
--- a/packages/contract_templates/partials/callAsync.handlebars
+++ b/packages/contract_templates/partials/callAsync.handlebars
@@ -7,6 +7,7 @@ async callAsync(
{{^this.payable}}
txData: TxData = {},
{{/this.payable}}
+ defaultBlock?: Web3.BlockParam,
): Promise<{{> return_type outputs=outputs}}> {
const self = this as {{contractName}}Contract;
const inputAbi = _.find(this.abi, {name: '{{this.name}}'}).inputs;
@@ -19,7 +20,7 @@ async callAsync(
data: encodedData,
}
)
- const rawCallResult = await self._web3Wrapper.callAsync(callData);
+ const rawCallResult = await self._web3Wrapper.callAsync(callData, defaultBlock);
const outputAbi = _.find(this.abi, {name: '{{this.name}}'}).outputs as Web3.DataItem[];
const outputParamsTypes = _.map(outputAbi, 'type');
let resultArray = ethersContracts.Interface.decodeParams(outputParamsTypes, rawCallResult) as any;
diff --git a/packages/web3-wrapper/src/index.ts b/packages/web3-wrapper/src/index.ts
index e7c875430..a07805344 100644
--- a/packages/web3-wrapper/src/index.ts
+++ b/packages/web3-wrapper/src/index.ts
@@ -132,8 +132,8 @@ export class Web3Wrapper {
const gas = await promisify<number>(this._web3.eth.estimateGas)(txData);
return gas;
}
- public async callAsync(callData: Web3.CallData): Promise<string> {
- const rawCalllResult = await promisify<string>(this._web3.eth.call)(callData);
+ public async callAsync(callData: Web3.CallData, defaultBlock?: Web3.BlockParam): Promise<string> {
+ const rawCalllResult = await promisify<string>(this._web3.eth.call)(callData, defaultBlock);
return rawCalllResult;
}
public async sendTransactionAsync(txData: Web3.TxData): Promise<string> {