Added ABI decoding of return values to callAsync
This commit is contained in:
@@ -19,6 +19,7 @@ import { constants as stakingConstants } from './utils/constants';
|
||||
import { StakingWrapper } from './utils/staking_wrapper';
|
||||
|
||||
import { ERC20Wrapper, ERC20ProxyContract } from '@0x/contracts-asset-proxy';
|
||||
import { StakingContract } from '../src';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@@ -48,7 +49,8 @@ describe('Staking Core', () => {
|
||||
// create accounts
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
owner = accounts[0];
|
||||
stakers = accounts.slice(1);
|
||||
stakers = accounts.slice(1, 5);
|
||||
makers = accounts.slice(6, 10);
|
||||
// deploy erc20 proxy
|
||||
erc20Wrapper = new ERC20Wrapper(provider, stakers, owner);
|
||||
erc20ProxyContract = await erc20Wrapper.deployProxyAsync();
|
||||
@@ -232,7 +234,27 @@ describe('Staking Core', () => {
|
||||
const expectedNextPoolId = "0x0000000000000000000000000000000200000000000000000000000000000000";
|
||||
const nextPoolId = await stakingWrapper.getNextPoolIdAsync();
|
||||
expect(nextPoolId).to.be.equal(expectedNextPoolId);
|
||||
//
|
||||
// add maker to pool
|
||||
const makerAddress = makers[0];
|
||||
const makerSignature = "0x";
|
||||
await stakingWrapper.addMakerToPoolAsync(poolId, makerAddress, makerSignature, operatorAddress);
|
||||
// check the pool id of the maker
|
||||
const poolIdOfMaker = await stakingWrapper.getMakerPoolId(makerAddress);
|
||||
expect(poolIdOfMaker).to.be.equal(poolId);
|
||||
// check the list of makers for the pool
|
||||
const makerAddressesForPool = await stakingWrapper.getMakerAddressesForPool(poolId);
|
||||
expect(makerAddressesForPool).to.be.deep.equal([makerAddress]);
|
||||
// try to add the same maker address again
|
||||
//await stakingWrapper.addMakerToPoolAsync(poolId, makerAddress, makerSignature, operatorAddress);
|
||||
// try to add a new maker address from an address other than the pool operator
|
||||
|
||||
// try to remove the maker address from an address other than the operator
|
||||
|
||||
// remove maker from pool
|
||||
|
||||
// check that maker was removed
|
||||
|
||||
// try to add
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -146,20 +146,26 @@ export class StakingWrapper {
|
||||
const poolId = (createPoolLog as any).args.poolId;
|
||||
return poolId;
|
||||
}
|
||||
/*
|
||||
public async addMakerToPoolAsync(poolId: string, makerAddress: string, makerSignature: string): Promise<void> {
|
||||
|
||||
public async addMakerToPoolAsync(poolId: string, makerAddress: string, makerSignature: string, operatorAddress: string): Promise<void> {
|
||||
const calldata = this.getStakingContract().addMakerToPool.getABIEncodedTransactionData(poolId, makerAddress, makerSignature);
|
||||
await this._executeTransactionAsync(calldata, operatorAddress);
|
||||
}
|
||||
/*
|
||||
public async removeMakerFromPoolAsync(poolId: string, makerAddress: string): Promise<void> {
|
||||
|
||||
}
|
||||
public async getMakerPoolId(makerAddress: string): Promise<string> {
|
||||
|
||||
}
|
||||
public async getMakersForPool(poolId: string): Promise<string[]> {
|
||||
|
||||
}
|
||||
*/
|
||||
public async getMakerPoolId(makerAddress: string): Promise<string> {
|
||||
const calldata = this.getStakingContract().getMakerPoolId.getABIEncodedTransactionData(makerAddress);
|
||||
const poolId = await this._callAsync(calldata);
|
||||
return poolId;
|
||||
}
|
||||
public async getMakerAddressesForPool(poolId: string): Promise<string[]> {
|
||||
const calldata = this.getStakingContract().getMakerAddressesForPool.getABIEncodedTransactionData(poolId);
|
||||
const returndata = await this._callAsync(calldata);
|
||||
const makerAddresses = this.getStakingContract().getMakerAddressesForPool.getABIDecodedReturnData(returndata);
|
||||
return makerAddresses;
|
||||
}
|
||||
public async getZrxVaultBalance(holder: string): Promise<BigNumber> {
|
||||
const balance = await this.getZrxVaultContract().balanceOf.callAsync(holder);
|
||||
return balance;
|
||||
|
||||
Reference in New Issue
Block a user