aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-09-05 19:43:46 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-09-05 19:43:46 +0800
commit9f12ef61b0cc8bb295b4a2bbfdf24b41c1584da2 (patch)
tree1bcb6a3c80c15ea7bfe6755a97ac9fb8760da953 /src/contract_wrappers
parente05dfab1fca9eb108848c98da9dbf671a59d17f3 (diff)
downloaddexon-sol-tools-9f12ef61b0cc8bb295b4a2bbfdf24b41c1584da2.tar
dexon-sol-tools-9f12ef61b0cc8bb295b4a2bbfdf24b41c1584da2.tar.gz
dexon-sol-tools-9f12ef61b0cc8bb295b4a2bbfdf24b41c1584da2.tar.bz2
dexon-sol-tools-9f12ef61b0cc8bb295b4a2bbfdf24b41c1584da2.tar.lz
dexon-sol-tools-9f12ef61b0cc8bb295b4a2bbfdf24b41c1584da2.tar.xz
dexon-sol-tools-9f12ef61b0cc8bb295b4a2bbfdf24b41c1584da2.tar.zst
dexon-sol-tools-9f12ef61b0cc8bb295b4a2bbfdf24b41c1584da2.zip
Rename x.call -> x.callAsync x() -> x.sendTransactionAsync() x.estimateGas() -> x.estimateGasAsync()
Diffstat (limited to 'src/contract_wrappers')
-rw-r--r--src/contract_wrappers/ether_token_wrapper.ts4
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts42
-rw-r--r--src/contract_wrappers/token_registry_wrapper.ts12
-rw-r--r--src/contract_wrappers/token_transfer_proxy_wrapper.ts4
-rw-r--r--src/contract_wrappers/token_wrapper.ts17
5 files changed, 41 insertions, 38 deletions
diff --git a/src/contract_wrappers/ether_token_wrapper.ts b/src/contract_wrappers/ether_token_wrapper.ts
index 4c19b3caa..d31069b22 100644
--- a/src/contract_wrappers/ether_token_wrapper.ts
+++ b/src/contract_wrappers/ether_token_wrapper.ts
@@ -33,7 +33,7 @@ export class EtherTokenWrapper extends ContractWrapper {
assert.assert(ethBalanceInWei.gte(amountInWei), ZeroExError.InsufficientEthBalanceForDeposit);
const wethContract = await this._getEtherTokenContractAsync();
- const txHash = await wethContract.deposit({
+ const txHash = await wethContract.deposit.sendTransactionAsync({
from: depositor,
value: amountInWei,
});
@@ -55,7 +55,7 @@ export class EtherTokenWrapper extends ContractWrapper {
assert.assert(WETHBalanceInBaseUnits.gte(amountInWei), ZeroExError.InsufficientWEthBalanceForWithdrawal);
const wethContract = await this._getEtherTokenContractAsync();
- const txHash = await wethContract.withdraw(amountInWei, {
+ const txHash = await wethContract.withdraw.sendTransactionAsync(amountInWei, {
from: withdrawer,
});
return txHash;
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index 324c92062..fbb2c710f 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -90,7 +90,7 @@ export class ExchangeWrapper extends ContractWrapper {
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
const exchangeContract = await this._getExchangeContractAsync();
- let unavailableTakerTokenAmount = await exchangeContract.getUnavailableTakerTokenAmount.call(orderHash);
+ let unavailableTakerTokenAmount = await exchangeContract.getUnavailableTakerTokenAmount.callAsync(orderHash);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
unavailableTakerTokenAmount = new BigNumber(unavailableTakerTokenAmount);
return unavailableTakerTokenAmount;
@@ -104,7 +104,7 @@ export class ExchangeWrapper extends ContractWrapper {
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
const exchangeContract = await this._getExchangeContractAsync();
- let fillAmountInBaseUnits = await exchangeContract.filled.call(orderHash);
+ let fillAmountInBaseUnits = await exchangeContract.filled.callAsync(orderHash);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
fillAmountInBaseUnits = new BigNumber(fillAmountInBaseUnits);
return fillAmountInBaseUnits;
@@ -119,7 +119,7 @@ export class ExchangeWrapper extends ContractWrapper {
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
const exchangeContract = await this._getExchangeContractAsync();
- let cancelledAmountInBaseUnits = await exchangeContract.cancelled.call(orderHash);
+ let cancelledAmountInBaseUnits = await exchangeContract.cancelled.callAsync(orderHash);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
cancelledAmountInBaseUnits = new BigNumber(cancelledAmountInBaseUnits);
return cancelledAmountInBaseUnits;
@@ -156,7 +156,7 @@ export class ExchangeWrapper extends ContractWrapper {
const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(signedOrder);
- const gas = await exchangeInstance.fillOrder.estimateGas(
+ const gas = await exchangeInstance.fillOrder.estimateGasAsync(
orderAddresses,
orderValues,
fillTakerTokenAmount,
@@ -168,7 +168,7 @@ export class ExchangeWrapper extends ContractWrapper {
from: takerAddress,
},
);
- const txHash: string = await exchangeInstance.fillOrder(
+ const txHash: string = await exchangeInstance.fillOrder.sendTransactionAsync(
orderAddresses,
orderValues,
fillTakerTokenAmount,
@@ -235,7 +235,7 @@ export class ExchangeWrapper extends ContractWrapper {
);
const exchangeInstance = await this._getExchangeContractAsync();
- const gas = await exchangeInstance.fillOrdersUpTo.estimateGas(
+ const gas = await exchangeInstance.fillOrdersUpTo.estimateGasAsync(
orderAddressesArray,
orderValuesArray,
fillTakerTokenAmount,
@@ -247,7 +247,7 @@ export class ExchangeWrapper extends ContractWrapper {
from: takerAddress,
},
);
- const txHash = await exchangeInstance.fillOrdersUpTo(
+ const txHash = await exchangeInstance.fillOrdersUpTo.sendTransactionAsync(
orderAddressesArray,
orderValuesArray,
fillTakerTokenAmount,
@@ -316,7 +316,7 @@ export class ExchangeWrapper extends ContractWrapper {
);
const exchangeInstance = await this._getExchangeContractAsync();
- const gas = await exchangeInstance.batchFillOrders.estimateGas(
+ const gas = await exchangeInstance.batchFillOrders.estimateGasAsync(
orderAddressesArray,
orderValuesArray,
fillTakerTokenAmounts,
@@ -328,7 +328,7 @@ export class ExchangeWrapper extends ContractWrapper {
from: takerAddress,
},
);
- const txHash = await exchangeInstance.batchFillOrders(
+ const txHash = await exchangeInstance.batchFillOrders.sendTransactionAsync(
orderAddressesArray,
orderValuesArray,
fillTakerTokenAmounts,
@@ -366,7 +366,7 @@ export class ExchangeWrapper extends ContractWrapper {
const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(signedOrder);
- const gas = await exchangeInstance.fillOrKillOrder.estimateGas(
+ const gas = await exchangeInstance.fillOrKillOrder.estimateGasAsync(
orderAddresses,
orderValues,
fillTakerTokenAmount,
@@ -377,7 +377,7 @@ export class ExchangeWrapper extends ContractWrapper {
from: takerAddress,
},
);
- const txHash = await exchangeInstance.fillOrKillOrder(
+ const txHash = await exchangeInstance.fillOrKillOrder.sendTransactionAsync(
orderAddresses,
orderValues,
fillTakerTokenAmount,
@@ -434,7 +434,7 @@ export class ExchangeWrapper extends ContractWrapper {
const [orderAddresses, orderValues, fillTakerTokenAmounts, vParams, rParams, sParams] =
_.unzip<any>(orderAddressesValuesAndTakerTokenFillAmounts);
- const gas = await exchangeInstance.batchFillOrKillOrders.estimateGas(
+ const gas = await exchangeInstance.batchFillOrKillOrders.estimateGasAsync(
orderAddresses,
orderValues,
fillTakerTokenAmounts,
@@ -445,7 +445,7 @@ export class ExchangeWrapper extends ContractWrapper {
from: takerAddress,
},
);
- const txHash = await exchangeInstance.batchFillOrKillOrders(
+ const txHash = await exchangeInstance.batchFillOrKillOrders.sendTransactionAsync(
orderAddresses,
orderValues,
fillTakerTokenAmounts,
@@ -477,7 +477,7 @@ export class ExchangeWrapper extends ContractWrapper {
await this.validateCancelOrderThrowIfInvalidAsync(order, cancelTakerTokenAmount);
const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(order);
- const gas = await exchangeInstance.cancelOrder.estimateGas(
+ const gas = await exchangeInstance.cancelOrder.estimateGasAsync(
orderAddresses,
orderValues,
cancelTakerTokenAmount,
@@ -485,7 +485,7 @@ export class ExchangeWrapper extends ContractWrapper {
from: order.maker,
},
);
- const txHash = await exchangeInstance.cancelOrder(
+ const txHash = await exchangeInstance.cancelOrder.sendTransactionAsync(
orderAddresses,
orderValues,
cancelTakerTokenAmount,
@@ -535,7 +535,7 @@ export class ExchangeWrapper extends ContractWrapper {
// We use _.unzip<any> because _.unzip doesn't type check if values have different types :'(
const [orderAddresses, orderValues, cancelTakerTokenAmounts] =
_.unzip<any>(orderAddressesValuesAndTakerTokenCancelAmounts);
- const gas = await exchangeInstance.batchCancelOrders.estimateGas(
+ const gas = await exchangeInstance.batchCancelOrders.estimateGasAsync(
orderAddresses,
orderValues,
cancelTakerTokenAmounts,
@@ -543,7 +543,7 @@ export class ExchangeWrapper extends ContractWrapper {
from: maker,
},
);
- const txHash = await exchangeInstance.batchCancelOrders(
+ const txHash = await exchangeInstance.batchCancelOrders.sendTransactionAsync(
orderAddresses,
orderValues,
cancelTakerTokenAmounts,
@@ -677,7 +677,7 @@ export class ExchangeWrapper extends ContractWrapper {
assert.isBigNumber('takerTokenAmount', takerTokenAmount);
assert.isBigNumber('makerTokenAmount', makerTokenAmount);
const exchangeInstance = await this._getExchangeContractAsync();
- const isRoundingError = await exchangeInstance.isRoundingError.call(
+ const isRoundingError = await exchangeInstance.isRoundingError.callAsync(
fillTakerTokenAmount, takerTokenAmount, makerTokenAmount,
);
return isRoundingError;
@@ -694,7 +694,7 @@ export class ExchangeWrapper extends ContractWrapper {
const exchangeInstance = await this._getExchangeContractAsync();
- const isValidSignature = await exchangeInstance.isValidSignature.call(
+ const isValidSignature = await exchangeInstance.isValidSignature.callAsync(
signerAddressHex,
dataHex,
ecSignature.v,
@@ -706,7 +706,7 @@ export class ExchangeWrapper extends ContractWrapper {
private async _getOrderHashHexUsingContractCallAsync(order: Order|SignedOrder): Promise<string> {
const exchangeInstance = await this._getExchangeContractAsync();
const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(order);
- const orderHashHex = await exchangeInstance.getOrderHash.call(orderAddresses, orderValues);
+ const orderHashHex = await exchangeInstance.getOrderHash.callAsync(orderAddresses, orderValues);
return orderHashHex;
}
private _throwErrorLogsAsErrors(logs: ContractEvent[]): void {
@@ -729,7 +729,7 @@ export class ExchangeWrapper extends ContractWrapper {
}
private async _getZRXTokenAddressAsync(): Promise<string> {
const exchangeInstance = await this._getExchangeContractAsync();
- const ZRXtokenAddress = await exchangeInstance.ZRX_TOKEN_CONTRACT.call();
+ const ZRXtokenAddress = await exchangeInstance.ZRX_TOKEN_CONTRACT.callAsync();
return ZRXtokenAddress;
}
}
diff --git a/src/contract_wrappers/token_registry_wrapper.ts b/src/contract_wrappers/token_registry_wrapper.ts
index 57c9ca93d..79eb516fe 100644
--- a/src/contract_wrappers/token_registry_wrapper.ts
+++ b/src/contract_wrappers/token_registry_wrapper.ts
@@ -35,7 +35,7 @@ export class TokenRegistryWrapper extends ContractWrapper {
*/
public async getTokenAddressesAsync(): Promise<string[]> {
const tokenRegistryContract = await this._getTokenRegistryContractAsync();
- const addresses = await tokenRegistryContract.getTokenAddresses.call();
+ const addresses = await tokenRegistryContract.getTokenAddresses.callAsync();
return addresses;
}
/**
@@ -46,14 +46,14 @@ export class TokenRegistryWrapper extends ContractWrapper {
assert.isETHAddressHex('address', address);
const tokenRegistryContract = await this._getTokenRegistryContractAsync();
- const metadata = await tokenRegistryContract.getTokenMetaData.call(address);
+ const metadata = await tokenRegistryContract.getTokenMetaData.callAsync(address);
const token = this._createTokenFromMetadata(metadata);
return token;
}
public async getTokenAddressBySymbolIfExistsAsync(symbol: string): Promise<string|undefined> {
assert.isString('symbol', symbol);
const tokenRegistryContract = await this._getTokenRegistryContractAsync();
- const addressIfExists = await tokenRegistryContract.getTokenAddressBySymbol.call(symbol);
+ const addressIfExists = await tokenRegistryContract.getTokenAddressBySymbol.callAsync(symbol);
if (addressIfExists === constants.NULL_ADDRESS) {
return undefined;
}
@@ -62,7 +62,7 @@ export class TokenRegistryWrapper extends ContractWrapper {
public async getTokenAddressByNameIfExistsAsync(name: string): Promise<string|undefined> {
assert.isString('name', name);
const tokenRegistryContract = await this._getTokenRegistryContractAsync();
- const addressIfExists = await tokenRegistryContract.getTokenAddressByName.call(name);
+ const addressIfExists = await tokenRegistryContract.getTokenAddressByName.callAsync(name);
if (addressIfExists === constants.NULL_ADDRESS) {
return undefined;
}
@@ -71,14 +71,14 @@ export class TokenRegistryWrapper extends ContractWrapper {
public async getTokenBySymbolIfExistsAsync(symbol: string): Promise<Token|undefined> {
assert.isString('symbol', symbol);
const tokenRegistryContract = await this._getTokenRegistryContractAsync();
- const metadata = await tokenRegistryContract.getTokenBySymbol.call(symbol);
+ const metadata = await tokenRegistryContract.getTokenBySymbol.callAsync(symbol);
const token = this._createTokenFromMetadata(metadata);
return token;
}
public async getTokenByNameIfExistsAsync(name: string): Promise<Token|undefined> {
assert.isString('name', name);
const tokenRegistryContract = await this._getTokenRegistryContractAsync();
- const metadata = await tokenRegistryContract.getTokenByName.call(name);
+ const metadata = await tokenRegistryContract.getTokenByName.callAsync(name);
const token = this._createTokenFromMetadata(metadata);
return token;
}
diff --git a/src/contract_wrappers/token_transfer_proxy_wrapper.ts b/src/contract_wrappers/token_transfer_proxy_wrapper.ts
index 2b4b32961..2ed198be6 100644
--- a/src/contract_wrappers/token_transfer_proxy_wrapper.ts
+++ b/src/contract_wrappers/token_transfer_proxy_wrapper.ts
@@ -15,7 +15,7 @@ export class TokenTransferProxyWrapper extends ContractWrapper {
*/
public async isAuthorizedAsync(exchangeContractAddress: string): Promise<boolean> {
const tokenTransferProxyContractInstance = await this._getTokenTransferProxyContractAsync();
- const isAuthorized = await tokenTransferProxyContractInstance.authorized.call(exchangeContractAddress);
+ const isAuthorized = await tokenTransferProxyContractInstance.authorized.callAsync(exchangeContractAddress);
return isAuthorized;
}
/**
@@ -24,7 +24,7 @@ export class TokenTransferProxyWrapper extends ContractWrapper {
*/
public async getAuthorizedAddressesAsync(): Promise<string[]> {
const tokenTransferProxyContractInstance = await this._getTokenTransferProxyContractAsync();
- const authorizedAddresses = await tokenTransferProxyContractInstance.getAuthorizedAddresses.call();
+ const authorizedAddresses = await tokenTransferProxyContractInstance.getAuthorizedAddresses.callAsync();
return authorizedAddresses;
}
/**
diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts
index 944f0fb42..db1ce22b2 100644
--- a/src/contract_wrappers/token_wrapper.ts
+++ b/src/contract_wrappers/token_wrapper.ts
@@ -47,7 +47,7 @@ export class TokenWrapper extends ContractWrapper {
assert.isETHAddressHex('tokenAddress', tokenAddress);
const tokenContract = await this._getTokenContractAsync(tokenAddress);
- let balance = await tokenContract.balanceOf.call(ownerAddress);
+ let balance = await tokenContract.balanceOf.callAsync(ownerAddress);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
balance = new BigNumber(balance);
return balance;
@@ -75,7 +75,7 @@ export class TokenWrapper extends ContractWrapper {
// TODO: Debug issue in testrpc and submit a PR, then remove this hack
const networkIdIfExists = await this._web3Wrapper.getNetworkIdIfExistsAsync();
const gas = networkIdIfExists === constants.TESTRPC_NETWORK_ID ? ALLOWANCE_TO_ZERO_GAS_AMOUNT : undefined;
- const txHash = await tokenContract.approve(spenderAddress, amountInBaseUnits, {
+ const txHash = await tokenContract.approve.sendTransactionAsync(spenderAddress, amountInBaseUnits, {
from: ownerAddress,
gas,
});
@@ -112,7 +112,7 @@ export class TokenWrapper extends ContractWrapper {
assert.isETHAddressHex('tokenAddress', tokenAddress);
const tokenContract = await this._getTokenContractAsync(tokenAddress);
- let allowanceInBaseUnits = await tokenContract.allowance.call(ownerAddress, spenderAddress);
+ let allowanceInBaseUnits = await tokenContract.allowance.callAsync(ownerAddress, spenderAddress);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
allowanceInBaseUnits = new BigNumber(allowanceInBaseUnits);
return allowanceInBaseUnits;
@@ -187,7 +187,7 @@ export class TokenWrapper extends ContractWrapper {
throw new Error(ZeroExError.InsufficientBalanceForTransfer);
}
- const txHash = await tokenContract.transfer(toAddress, amountInBaseUnits, {
+ const txHash = await tokenContract.transfer.sendTransactionAsync(toAddress, amountInBaseUnits, {
from: fromAddress,
});
return txHash;
@@ -226,9 +226,12 @@ export class TokenWrapper extends ContractWrapper {
throw new Error(ZeroExError.InsufficientBalanceForTransfer);
}
- const txHash = await tokenContract.transferFrom(fromAddress, toAddress, amountInBaseUnits, {
- from: senderAddress,
- });
+ const txHash = await tokenContract.transferFrom.sendTransactionAsync(
+ fromAddress, toAddress, amountInBaseUnits,
+ {
+ from: senderAddress,
+ },
+ );
return txHash;
}
/**