aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/contracts/package.json1
-rw-r--r--packages/contracts/src/utils/constants.ts1
-rw-r--r--packages/contracts/test/ether_token.ts53
-rw-r--r--packages/contracts/test/unlimited_allowance_token.ts62
-rw-r--r--packages/contracts/test/zrx_token.ts72
-rw-r--r--packages/website/ts/components/portal/portal.tsx2
-rw-r--r--packages/website/ts/components/wallet/wallet.tsx36
7 files changed, 109 insertions, 118 deletions
diff --git a/packages/contracts/package.json b/packages/contracts/package.json
index 180b8058a..037cb7a04 100644
--- a/packages/contracts/package.json
+++ b/packages/contracts/package.json
@@ -67,7 +67,6 @@
},
"dependencies": {
"@0xproject/base-contract": "^0.3.2",
- "@0xproject/contract-wrappers": "^0.0.2",
"@0xproject/order-utils": "^0.0.5",
"@0xproject/sol-compiler": "^0.5.0",
"@0xproject/types": "^0.7.0",
diff --git a/packages/contracts/src/utils/constants.ts b/packages/contracts/src/utils/constants.ts
index 483340186..7a0e26a48 100644
--- a/packages/contracts/src/utils/constants.ts
+++ b/packages/contracts/src/utils/constants.ts
@@ -32,6 +32,7 @@ export const constants = {
NUM_DUMMY_ERC721_TO_DEPLOY: 1,
NUM_ERC721_TOKENS_TO_MINT: 2,
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
+ UNLIMITED_ALLOWANCE_IN_BASE_UNITS: new BigNumber(2).pow(256).minus(1),
TESTRPC_PRIVATE_KEYS: _.map(TESTRPC_PRIVATE_KEYS_STRINGS, privateKeyString => ethUtil.toBuffer(privateKeyString)),
INITIAL_ERC20_BALANCE: Web3Wrapper.toBaseUnitAmount(new BigNumber(10000), 18),
INITIAL_ERC20_ALLOWANCE: Web3Wrapper.toBaseUnitAmount(new BigNumber(10000), 18),
diff --git a/packages/contracts/test/ether_token.ts b/packages/contracts/test/ether_token.ts
index 5c8a5e199..10dd635fe 100644
--- a/packages/contracts/test/ether_token.ts
+++ b/packages/contracts/test/ether_token.ts
@@ -1,4 +1,3 @@
-import { ContractWrappers, ContractWrappersError } from '@0xproject/contract-wrappers';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber, promisify } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
@@ -18,8 +17,7 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('EtherToken', () => {
let account: string;
const gasPrice = Web3Wrapper.toBaseUnitAmount(new BigNumber(20), 9);
- let contractWrappers: ContractWrappers;
- let etherTokenAddress: string;
+ let etherToken: WETH9Contract;
before(async () => {
await blockchainLifecycle.startAsync();
@@ -31,11 +29,9 @@ describe('EtherToken', () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
account = accounts[0];
- const etherToken = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.EtherToken, provider, txDefaults);
- etherTokenAddress = etherToken.address;
- contractWrappers = new ContractWrappers(provider, {
+ etherToken = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.EtherToken, provider, {
gasPrice,
- networkId: constants.TESTRPC_NETWORK_ID,
+ ...txDefaults,
});
});
beforeEach(async () => {
@@ -49,18 +45,18 @@ describe('EtherToken', () => {
const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
const ethToDeposit = initEthBalance.plus(1);
- return expect(
- contractWrappers.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account),
- ).to.be.rejectedWith(ContractWrappersError.InsufficientEthBalanceForDeposit);
+ return expect(etherToken.deposit.sendTransactionAsync({ value: ethToDeposit })).to.be.rejectedWith(
+ "ender doesn't have enough funds to send tx.",
+ );
});
it('should convert deposited Ether to wrapped Ether tokens', async () => {
const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
- const initEthTokenBalance = await contractWrappers.token.getBalanceAsync(etherTokenAddress, account);
+ const initEthTokenBalance = await etherToken.balanceOf.callAsync(account);
const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1)));
- const txHash = await contractWrappers.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account);
+ const txHash = await etherToken.deposit.sendTransactionAsync({ value: ethToDeposit });
const receipt = await web3Wrapper.awaitTransactionSuccessAsync(
txHash,
constants.AWAIT_TRANSACTION_MINED_MS,
@@ -68,7 +64,7 @@ describe('EtherToken', () => {
const ethSpentOnGas = gasPrice.times(receipt.gasUsed);
const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
- const finalEthTokenBalance = await contractWrappers.token.getBalanceAsync(etherTokenAddress, account);
+ const finalEthTokenBalance = await etherToken.balanceOf.callAsync(account);
expect(finalEthBalance).to.be.bignumber.equal(initEthBalance.minus(ethToDeposit.plus(ethSpentOnGas)));
expect(finalEthTokenBalance).to.be.bignumber.equal(initEthTokenBalance.plus(ethToDeposit));
@@ -77,29 +73,24 @@ describe('EtherToken', () => {
describe('withdraw', () => {
it('should throw if caller attempts to withdraw greater than caller balance', async () => {
- const initEthTokenBalance = await contractWrappers.token.getBalanceAsync(etherTokenAddress, account);
+ const initEthTokenBalance = await etherToken.balanceOf.callAsync(account);
const ethTokensToWithdraw = initEthTokenBalance.plus(1);
- return expect(
- contractWrappers.etherToken.withdrawAsync(etherTokenAddress, ethTokensToWithdraw, account),
- ).to.be.rejectedWith(ContractWrappersError.InsufficientWEthBalanceForWithdrawal);
+ return expect(etherToken.withdraw.sendTransactionAsync(ethTokensToWithdraw)).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
it('should convert ether tokens to ether with sufficient balance', async () => {
const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1)));
- await contractWrappers.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account);
- const initEthTokenBalance = await contractWrappers.token.getBalanceAsync(etherTokenAddress, account);
+ await etherToken.deposit.sendTransactionAsync({ value: ethToDeposit });
+ const initEthTokenBalance = await etherToken.balanceOf.callAsync(account);
const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
const ethTokensToWithdraw = initEthTokenBalance;
expect(ethTokensToWithdraw).to.not.be.bignumber.equal(0);
- const txHash = await contractWrappers.etherToken.withdrawAsync(
- etherTokenAddress,
- ethTokensToWithdraw,
- account,
- {
- gasLimit: constants.MAX_ETHERTOKEN_WITHDRAW_GAS,
- },
- );
+ const txHash = await etherToken.withdraw.sendTransactionAsync(ethTokensToWithdraw, {
+ gas: constants.MAX_ETHERTOKEN_WITHDRAW_GAS,
+ });
const receipt = await web3Wrapper.awaitTransactionSuccessAsync(
txHash,
constants.AWAIT_TRANSACTION_MINED_MS,
@@ -107,7 +98,7 @@ describe('EtherToken', () => {
const ethSpentOnGas = gasPrice.times(receipt.gasUsed);
const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
- const finalEthTokenBalance = await contractWrappers.token.getBalanceAsync(etherTokenAddress, account);
+ const finalEthTokenBalance = await etherToken.balanceOf.callAsync(account);
expect(finalEthBalance).to.be.bignumber.equal(
initEthBalance.plus(ethTokensToWithdraw.minus(ethSpentOnGas)),
@@ -119,13 +110,13 @@ describe('EtherToken', () => {
describe('fallback', () => {
it('should convert sent ether to ether tokens', async () => {
const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
- const initEthTokenBalance = await contractWrappers.token.getBalanceAsync(etherTokenAddress, account);
+ const initEthTokenBalance = await etherToken.balanceOf.callAsync(account);
const ethToDeposit = Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18);
const txHash = await web3Wrapper.sendTransactionAsync({
from: account,
- to: etherTokenAddress,
+ to: etherToken.address,
value: ethToDeposit,
gasPrice,
});
@@ -137,7 +128,7 @@ describe('EtherToken', () => {
const ethSpentOnGas = gasPrice.times(receipt.gasUsed);
const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
- const finalEthTokenBalance = await contractWrappers.token.getBalanceAsync(etherTokenAddress, account);
+ const finalEthTokenBalance = await etherToken.balanceOf.callAsync(account);
expect(finalEthBalance).to.be.bignumber.equal(initEthBalance.minus(ethToDeposit.plus(ethSpentOnGas)));
expect(finalEthTokenBalance).to.be.bignumber.equal(initEthTokenBalance.plus(ethToDeposit));
diff --git a/packages/contracts/test/unlimited_allowance_token.ts b/packages/contracts/test/unlimited_allowance_token.ts
index e3e3bd485..c68d8bdcf 100644
--- a/packages/contracts/test/unlimited_allowance_token.ts
+++ b/packages/contracts/test/unlimited_allowance_token.ts
@@ -1,4 +1,3 @@
-import { ContractWrappers } from '@0xproject/contract-wrappers';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
@@ -19,12 +18,7 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('UnlimitedAllowanceToken', () => {
let owner: string;
let spender: string;
- const contractWrappers = new ContractWrappers(provider, {
- networkId: constants.TESTRPC_NETWORK_ID,
- });
-
const MAX_MINT_VALUE = new BigNumber(100000000000000000000);
- let tokenAddress: string;
let token: DummyERC20TokenContract;
before(async () => {
@@ -50,7 +44,6 @@ describe('UnlimitedAllowanceToken', () => {
await token.mint.sendTransactionAsync(MAX_MINT_VALUE, { from: owner }),
constants.AWAIT_TRANSACTION_MINED_MS,
);
- tokenAddress = token.address;
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
@@ -60,7 +53,7 @@ describe('UnlimitedAllowanceToken', () => {
});
describe('transfer', () => {
it('should throw if owner has insufficient balance', async () => {
- const ownerBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, owner);
+ const ownerBalance = await token.balanceOf.callAsync(owner);
const amountToTransfer = ownerBalance.plus(1);
return expect(token.transfer.callAsync(spender, amountToTransfer, { from: owner })).to.be.rejectedWith(
constants.REVERT,
@@ -69,11 +62,11 @@ describe('UnlimitedAllowanceToken', () => {
it('should transfer balance from sender to receiver', async () => {
const receiver = spender;
- const initOwnerBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, owner);
+ const initOwnerBalance = await token.balanceOf.callAsync(owner);
const amountToTransfer = new BigNumber(1);
- await contractWrappers.token.transferAsync(tokenAddress, owner, receiver, amountToTransfer);
- const finalOwnerBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, owner);
- const finalReceiverBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, receiver);
+ await token.transfer.sendTransactionAsync(receiver, amountToTransfer, { from: owner });
+ const finalOwnerBalance = await token.balanceOf.callAsync(owner);
+ const finalReceiverBalance = await token.balanceOf.callAsync(receiver);
const expectedFinalOwnerBalance = initOwnerBalance.minus(amountToTransfer);
const expectedFinalReceiverBalance = amountToTransfer;
@@ -91,9 +84,9 @@ describe('UnlimitedAllowanceToken', () => {
describe('transferFrom', () => {
it('should throw if owner has insufficient balance', async () => {
- const ownerBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, owner);
+ const ownerBalance = await token.balanceOf.callAsync(owner);
const amountToTransfer = ownerBalance.plus(1);
- await contractWrappers.token.setAllowanceAsync(tokenAddress, owner, spender, amountToTransfer);
+ await token.approve.sendTransactionAsync(spender, amountToTransfer, { from: owner });
return expect(
token.transferFrom.callAsync(owner, spender, amountToTransfer, {
from: spender,
@@ -102,10 +95,10 @@ describe('UnlimitedAllowanceToken', () => {
});
it('should throw if spender has insufficient allowance', async () => {
- const ownerBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, owner);
+ const ownerBalance = await token.balanceOf.callAsync(owner);
const amountToTransfer = ownerBalance;
- const spenderAllowance = await contractWrappers.token.getAllowanceAsync(tokenAddress, owner, spender);
+ const spenderAllowance = await token.allowance.callAsync(owner, spender);
const isSpenderAllowanceInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
expect(isSpenderAllowanceInsufficient).to.be.true();
@@ -125,44 +118,47 @@ describe('UnlimitedAllowanceToken', () => {
});
it('should not modify spender allowance if spender allowance is 2^256 - 1', async () => {
- const initOwnerBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, owner);
+ const initOwnerBalance = await token.balanceOf.callAsync(owner);
const amountToTransfer = initOwnerBalance;
- const initSpenderAllowance = contractWrappers.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
- await contractWrappers.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
- await contractWrappers.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, {
- gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
+ const initSpenderAllowance = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
+ await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner });
+ await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, {
+ from: spender,
+ gas: constants.MAX_TOKEN_TRANSFERFROM_GAS,
});
- const newSpenderAllowance = await contractWrappers.token.getAllowanceAsync(tokenAddress, owner, spender);
+ const newSpenderAllowance = await token.allowance.callAsync(owner, spender);
expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance);
});
it('should transfer the correct balances if spender has sufficient allowance', async () => {
- const initOwnerBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, owner);
+ const initOwnerBalance = await token.balanceOf.callAsync(owner);
const amountToTransfer = initOwnerBalance;
const initSpenderAllowance = initOwnerBalance;
- await contractWrappers.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
- await contractWrappers.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, {
- gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
+ await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner });
+ await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, {
+ from: spender,
+ gas: constants.MAX_TOKEN_TRANSFERFROM_GAS,
});
- const newOwnerBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, owner);
- const newSpenderBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, spender);
+ const newOwnerBalance = await token.balanceOf.callAsync(owner);
+ const newSpenderBalance = await token.balanceOf.callAsync(spender);
expect(newOwnerBalance).to.be.bignumber.equal(0);
expect(newSpenderBalance).to.be.bignumber.equal(initOwnerBalance);
});
it('should modify allowance if spender has sufficient allowance less than 2^256 - 1', async () => {
- const initOwnerBalance = await contractWrappers.token.getBalanceAsync(tokenAddress, owner);
+ const initOwnerBalance = await token.balanceOf.callAsync(owner);
const amountToTransfer = initOwnerBalance;
const initSpenderAllowance = initOwnerBalance;
- await contractWrappers.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
- await contractWrappers.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, {
- gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
+ await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner });
+ await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, {
+ from: spender,
+ gas: constants.MAX_TOKEN_TRANSFERFROM_GAS,
});
- const newSpenderAllowance = await contractWrappers.token.getAllowanceAsync(tokenAddress, owner, spender);
+ const newSpenderAllowance = await token.allowance.callAsync(owner, spender);
expect(newSpenderAllowance).to.be.bignumber.equal(0);
});
});
diff --git a/packages/contracts/test/zrx_token.ts b/packages/contracts/test/zrx_token.ts
index e632364ef..fe37e802b 100644
--- a/packages/contracts/test/zrx_token.ts
+++ b/packages/contracts/test/zrx_token.ts
@@ -1,4 +1,3 @@
-import { ContractWrappers } from '@0xproject/contract-wrappers';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
@@ -19,12 +18,8 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('ZRXToken', () => {
let owner: string;
let spender: string;
- let contractWrappers: ContractWrappers;
-
let MAX_UINT: BigNumber;
-
let zrxToken: ZRXTokenContract;
- let zrxAddress: string;
before(async () => {
await blockchainLifecycle.startAsync();
@@ -36,12 +31,8 @@ describe('ZRXToken', () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
owner = accounts[0];
spender = accounts[1];
- contractWrappers = new ContractWrappers(provider, {
- networkId: constants.TESTRPC_NETWORK_ID,
- });
zrxToken = await ZRXTokenContract.deployFrom0xArtifactAsync(artifacts.ZRX, provider, txDefaults);
- zrxAddress = zrxToken.address;
- MAX_UINT = contractWrappers.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
+ MAX_UINT = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
@@ -77,7 +68,7 @@ describe('ZRXToken', () => {
describe('constructor', () => {
it('should initialize owner balance to totalSupply', async () => {
- const ownerBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, owner);
+ const ownerBalance = await zrxToken.balanceOf.callAsync(owner);
const totalSupply = new BigNumber(await zrxToken.totalSupply.callAsync());
expect(totalSupply).to.be.bignumber.equal(ownerBalance);
});
@@ -86,11 +77,11 @@ describe('ZRXToken', () => {
describe('transfer', () => {
it('should transfer balance from sender to receiver', async () => {
const receiver = spender;
- const initOwnerBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, owner);
+ const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner);
const amountToTransfer = new BigNumber(1);
- await contractWrappers.token.transferAsync(zrxAddress, owner, receiver, amountToTransfer);
- const finalOwnerBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, owner);
- const finalReceiverBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, receiver);
+ await zrxToken.transfer.sendTransactionAsync(receiver, amountToTransfer, { from: owner });
+ const finalOwnerBalance = await zrxToken.balanceOf.callAsync(owner);
+ const finalReceiverBalance = await zrxToken.balanceOf.callAsync(receiver);
const expectedFinalOwnerBalance = initOwnerBalance.minus(amountToTransfer);
const expectedFinalReceiverBalance = amountToTransfer;
@@ -108,10 +99,11 @@ describe('ZRXToken', () => {
describe('transferFrom', () => {
it('should return false if owner has insufficient balance', async () => {
- const ownerBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, owner);
+ const ownerBalance = await zrxToken.balanceOf.callAsync(owner);
const amountToTransfer = ownerBalance.plus(1);
- await contractWrappers.token.setAllowanceAsync(zrxAddress, owner, spender, amountToTransfer, {
- gasLimit: constants.MAX_TOKEN_APPROVE_GAS,
+ await zrxToken.approve.sendTransactionAsync(spender, amountToTransfer, {
+ from: owner,
+ gas: constants.MAX_TOKEN_APPROVE_GAS,
});
const didReturnTrue = await zrxToken.transferFrom.callAsync(owner, spender, amountToTransfer, {
from: spender,
@@ -120,10 +112,10 @@ describe('ZRXToken', () => {
});
it('should return false if spender has insufficient allowance', async () => {
- const ownerBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, owner);
+ const ownerBalance = await zrxToken.balanceOf.callAsync(owner);
const amountToTransfer = ownerBalance;
- const spenderAllowance = await contractWrappers.token.getAllowanceAsync(zrxAddress, owner, spender);
+ const spenderAllowance = await zrxToken.allowance.callAsync(owner, spender);
const isSpenderAllowanceInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
expect(isSpenderAllowanceInsufficient).to.be.true();
@@ -142,46 +134,50 @@ describe('ZRXToken', () => {
});
it('should not modify spender allowance if spender allowance is 2^256 - 1', async () => {
- const initOwnerBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, owner);
+ const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner);
const amountToTransfer = initOwnerBalance;
const initSpenderAllowance = MAX_UINT;
- await contractWrappers.token.setAllowanceAsync(zrxAddress, owner, spender, initSpenderAllowance, {
- gasLimit: constants.MAX_TOKEN_APPROVE_GAS,
+ await zrxToken.approve.sendTransactionAsync(spender, initSpenderAllowance, {
+ from: owner,
+ gas: constants.MAX_TOKEN_APPROVE_GAS,
});
- await contractWrappers.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer, {
- gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
+ await zrxToken.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, {
+ from: spender,
+ gas: constants.MAX_TOKEN_TRANSFERFROM_GAS,
});
- const newSpenderAllowance = await contractWrappers.token.getAllowanceAsync(zrxAddress, owner, spender);
+ const newSpenderAllowance = await zrxToken.allowance.callAsync(owner, spender);
expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance);
});
it('should transfer the correct balances if spender has sufficient allowance', async () => {
- const initOwnerBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, owner);
- const initSpenderBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, spender);
+ const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner);
+ const initSpenderBalance = await zrxToken.balanceOf.callAsync(spender);
const amountToTransfer = initOwnerBalance;
const initSpenderAllowance = initOwnerBalance;
- await contractWrappers.token.setAllowanceAsync(zrxAddress, owner, spender, initSpenderAllowance);
- await contractWrappers.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer, {
- gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
+ await zrxToken.approve.sendTransactionAsync(spender, initSpenderAllowance);
+ await zrxToken.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, {
+ from: spender,
+ gas: constants.MAX_TOKEN_TRANSFERFROM_GAS,
});
- const newOwnerBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, owner);
- const newSpenderBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, spender);
+ const newOwnerBalance = await zrxToken.balanceOf.callAsync(owner);
+ const newSpenderBalance = await zrxToken.balanceOf.callAsync(spender);
expect(newOwnerBalance).to.be.bignumber.equal(0);
expect(newSpenderBalance).to.be.bignumber.equal(initSpenderBalance.plus(initOwnerBalance));
});
it('should modify allowance if spender has sufficient allowance less than 2^256 - 1', async () => {
- const initOwnerBalance = await contractWrappers.token.getBalanceAsync(zrxAddress, owner);
+ const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner);
const amountToTransfer = initOwnerBalance;
- await contractWrappers.token.setAllowanceAsync(zrxAddress, owner, spender, amountToTransfer);
- await contractWrappers.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer, {
- gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS,
+ await zrxToken.approve.sendTransactionAsync(spender, amountToTransfer);
+ await zrxToken.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, {
+ from: spender,
+ gas: constants.MAX_TOKEN_TRANSFERFROM_GAS,
});
- const newSpenderAllowance = await contractWrappers.token.getAllowanceAsync(zrxAddress, owner, spender);
+ const newSpenderAllowance = await zrxToken.allowance.callAsync(owner, spender);
expect(newSpenderAllowance).to.be.bignumber.equal(0);
});
});
diff --git a/packages/website/ts/components/portal/portal.tsx b/packages/website/ts/components/portal/portal.tsx
index a03731ec0..0e1506e17 100644
--- a/packages/website/ts/components/portal/portal.tsx
+++ b/packages/website/ts/components/portal/portal.tsx
@@ -296,6 +296,8 @@ export class Portal extends React.Component<PortalProps, PortalState> {
lastForceTokenStateRefetch={this.props.lastForceTokenStateRefetch}
injectedProviderName={this.props.injectedProviderName}
providerType={this.props.providerType}
+ screenWidth={this.props.screenWidth}
+ location={this.props.location}
onToggleLedgerDialog={this._onToggleLedgerDialog.bind(this)}
onAddToken={this._onAddToken.bind(this)}
onRemoveToken={this._onRemoveToken.bind(this)}
diff --git a/packages/website/ts/components/wallet/wallet.tsx b/packages/website/ts/components/wallet/wallet.tsx
index 39e591bac..10ee31619 100644
--- a/packages/website/ts/components/wallet/wallet.tsx
+++ b/packages/website/ts/components/wallet/wallet.tsx
@@ -35,6 +35,7 @@ import {
BlockchainErrs,
ItemByAddress,
ProviderType,
+ ScreenWidths,
Side,
Token,
TokenByAddress,
@@ -61,6 +62,8 @@ export interface WalletProps {
lastForceTokenStateRefetch: number;
injectedProviderName: string;
providerType: ProviderType;
+ screenWidth: ScreenWidths;
+ location: Location;
onToggleLedgerDialog: () => void;
onAddToken: () => void;
onRemoveToken: () => void;
@@ -116,8 +119,6 @@ const styles: Styles = {
paddingBottom: 8,
},
bodyInnerDiv: {
- // TODO: make this completely responsive
- maxHeight: 475,
overflow: 'auto',
WebkitOverflowScrolling: 'touch',
},
@@ -140,6 +141,7 @@ const DISCONNECTED_ITEM_KEY = 'DISCONNECTED';
const ETHER_ITEM_KEY = 'ETHER';
const USD_DECIMAL_PLACES = 2;
const NO_ALLOWANCE_TOGGLE_SPACE_WIDTH = 56;
+const ACCOUNT_PATH = `${WebsitePaths.Portal}/account`;
export class Wallet extends React.Component<WalletProps, WalletState> {
private _isUnmounted: boolean;
@@ -226,7 +228,7 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
const userAddress = this.props.userAddress;
const primaryText = utils.getAddressBeginAndEnd(userAddress);
return (
- <Link key={HEADER_ITEM_KEY} to={`${WebsitePaths.Portal}/account`} style={{ textDecoration: 'none' }}>
+ <Link key={HEADER_ITEM_KEY} to={ACCOUNT_PATH} style={{ textDecoration: 'none' }}>
<ListItem
primaryText={primaryText}
leftIcon={<Identicon address={userAddress} diameter={ICON_DIMENSION} />}
@@ -240,6 +242,8 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
const bodyStyle: React.CSSProperties = {
...styles.bodyInnerDiv,
overflow: this.state.isHoveringSidebar ? 'auto' : 'hidden',
+ // TODO: make this completely responsive
+ maxHeight: this.props.screenWidth !== ScreenWidths.Sm ? 475 : undefined,
};
return (
<div
@@ -296,18 +300,20 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
innerDivStyle={styles.footerItemInnerDiv}
style={styles.borderedItem}
/>
- <Link to={`${WebsitePaths.Portal}/account`} style={{ textDecoration: 'none' }}>
- <ListItem
- primaryText={
- <div className="flex right" style={styles.manageYourWalletText}>
- {'manage your wallet'}
- </div>
- // https://github.com/palantir/tslint-react/issues/140
- // tslint:disable-next-line:jsx-curly-spacing
- }
- style={{ ...styles.paddedItem, ...styles.borderedItem }}
- />
- </Link>
+ {this.props.location.pathname !== ACCOUNT_PATH && (
+ <Link to={ACCOUNT_PATH} style={{ textDecoration: 'none' }}>
+ <ListItem
+ primaryText={
+ <div className="flex right" style={styles.manageYourWalletText}>
+ {'manage your wallet'}
+ </div>
+ // https://github.com/palantir/tslint-react/issues/140
+ // tslint:disable-next-line:jsx-curly-spacing
+ }
+ style={{ ...styles.paddedItem, ...styles.borderedItem }}
+ />
+ </Link>
+ )}
</div>
);
}