aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers/ether_token_wrapper.ts
diff options
context:
space:
mode:
authorLeonid <logvinov.leon@gmail.com>2017-09-06 16:35:19 +0800
committerGitHub <noreply@github.com>2017-09-06 16:35:19 +0800
commit35c133caeda613121d7d90f3f1347ebdc8087d66 (patch)
tree6156865472010078a9f27b905bcaec7782f6521c /src/contract_wrappers/ether_token_wrapper.ts
parent18a52a1ea758ee5640680f1097eba1ce9a9e81fc (diff)
parentf0a5ad2d2063fe8ba4682147ec2f73e2763b0275 (diff)
downloaddexon-0x-contracts-35c133caeda613121d7d90f3f1347ebdc8087d66.tar
dexon-0x-contracts-35c133caeda613121d7d90f3f1347ebdc8087d66.tar.gz
dexon-0x-contracts-35c133caeda613121d7d90f3f1347ebdc8087d66.tar.bz2
dexon-0x-contracts-35c133caeda613121d7d90f3f1347ebdc8087d66.tar.lz
dexon-0x-contracts-35c133caeda613121d7d90f3f1347ebdc8087d66.tar.xz
dexon-0x-contracts-35c133caeda613121d7d90f3f1347ebdc8087d66.tar.zst
dexon-0x-contracts-35c133caeda613121d7d90f3f1347ebdc8087d66.zip
Merge branch 'development' into fix/signature-verification
Diffstat (limited to 'src/contract_wrappers/ether_token_wrapper.ts')
-rw-r--r--src/contract_wrappers/ether_token_wrapper.ts22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/contract_wrappers/ether_token_wrapper.ts b/src/contract_wrappers/ether_token_wrapper.ts
index 3c282510f..b86309f90 100644
--- a/src/contract_wrappers/ether_token_wrapper.ts
+++ b/src/contract_wrappers/ether_token_wrapper.ts
@@ -4,7 +4,7 @@ import {ContractWrapper} from './contract_wrapper';
import {TokenWrapper} from './token_wrapper';
import {EtherTokenContract, ZeroExError} from '../types';
import {assert} from '../utils/assert';
-import * as EtherTokenArtifacts from '../artifacts/EtherToken.json';
+import {artifacts} from '../artifacts';
/**
* This class includes all the functionality related to interacting with a wrapped Ether ERC20 token contract.
@@ -13,8 +13,8 @@ import * as EtherTokenArtifacts from '../artifacts/EtherToken.json';
export class EtherTokenWrapper extends ContractWrapper {
private _etherTokenContractIfExists?: EtherTokenContract;
private _tokenWrapper: TokenWrapper;
- constructor(web3Wrapper: Web3Wrapper, tokenWrapper: TokenWrapper, gasPrice?: BigNumber.BigNumber) {
- super(web3Wrapper, gasPrice);
+ constructor(web3Wrapper: Web3Wrapper, tokenWrapper: TokenWrapper) {
+ super(web3Wrapper);
this._tokenWrapper = tokenWrapper;
}
/**
@@ -23,8 +23,9 @@ export class EtherTokenWrapper extends ContractWrapper {
* for ETH.
* @param amountInWei Amount of ETH in Wei the caller wishes to deposit.
* @param depositor The hex encoded user Ethereum address that would like to make the deposit.
+ * @return Transaction hash.
*/
- public async depositAsync(amountInWei: BigNumber.BigNumber, depositor: string): Promise<void> {
+ public async depositAsync(amountInWei: BigNumber.BigNumber, depositor: string): Promise<string> {
assert.isBigNumber('amountInWei', amountInWei);
await assert.isSenderAddressAsync('depositor', depositor, this._web3Wrapper);
@@ -32,18 +33,20 @@ export class EtherTokenWrapper extends ContractWrapper {
assert.assert(ethBalanceInWei.gte(amountInWei), ZeroExError.InsufficientEthBalanceForDeposit);
const wethContract = await this._getEtherTokenContractAsync();
- await wethContract.deposit({
+ const txHash = await wethContract.deposit.sendTransactionAsync({
from: depositor,
value: amountInWei,
});
+ return txHash;
}
/**
* Withdraw ETH to the withdrawer's address from the wrapped ETH smart contract in exchange for the
* equivalent number of wrapped ETH tokens.
* @param amountInWei Amount of ETH in Wei the caller wishes to withdraw.
* @param withdrawer The hex encoded user Ethereum address that would like to make the withdrawl.
+ * @return Transaction hash.
*/
- public async withdrawAsync(amountInWei: BigNumber.BigNumber, withdrawer: string): Promise<void> {
+ public async withdrawAsync(amountInWei: BigNumber.BigNumber, withdrawer: string): Promise<string> {
assert.isBigNumber('amountInWei', amountInWei);
await assert.isSenderAddressAsync('withdrawer', withdrawer, this._web3Wrapper);
@@ -52,9 +55,10 @@ export class EtherTokenWrapper extends ContractWrapper {
assert.assert(WETHBalanceInBaseUnits.gte(amountInWei), ZeroExError.InsufficientWEthBalanceForWithdrawal);
const wethContract = await this._getEtherTokenContractAsync();
- await wethContract.withdraw(amountInWei, {
+ const txHash = await wethContract.withdraw.sendTransactionAsync(amountInWei, {
from: withdrawer,
});
+ return txHash;
}
/**
* Retrieves the Wrapped Ether token contract address
@@ -71,7 +75,9 @@ export class EtherTokenWrapper extends ContractWrapper {
if (!_.isUndefined(this._etherTokenContractIfExists)) {
return this._etherTokenContractIfExists;
}
- const contractInstance = await this._instantiateContractIfExistsAsync((EtherTokenArtifacts as any));
+ const contractInstance = await this._instantiateContractIfExistsAsync<EtherTokenContract>(
+ artifacts.EtherTokenArtifact,
+ );
this._etherTokenContractIfExists = contractInstance as EtherTokenContract;
return this._etherTokenContractIfExists;
}