update abi-gen with new method interfaces (#2325)

* update abi-gen with new method interfaces

* wip: get all packages to build

* wip: get all packages to build

* Fix two contract wrapper calls

* Export necessary types part of the contract wrapper public interfaces

* Revive and fix wrapper_unit_tests

* Remove duplicate type

* Fix lib_exchange_rich_error_decoder tests

* Fix remaining test failures in contracts-* packages

* Prettier fixes

* remove transactionHelper

* lint and update changelogs

* Fix prettier

* Revert changes to reference docs

* Add back changelog already published and add revert changelog entry

* Add missing CHANGELOG entries

* Add missing comma

* Update mesh-rpc-client dep

* Update Mesh RPC logic in @0x/orderbook to v6.0.1-beta

* Align package versions
This commit is contained in:
Xianny
2019-11-14 11:22:29 -05:00
committed by GitHub
parent 9d4d9ce978
commit f0d7d10fe7
198 changed files with 30021 additions and 38850 deletions

View File

@@ -45,7 +45,7 @@ blockchainTests('Protocol Fees unit tests', env => {
exchangeAddress,
);
minimumStake = (await testContract.getParams.callAsync())[2];
minimumStake = (await testContract.getParams().callAsync())[2];
});
interface CreateTestPoolOpts {
@@ -63,12 +63,14 @@ blockchainTests('Protocol Fees unit tests', env => {
makers: _.times(2, () => randomAddress()),
...opts,
};
await testContract.createTestPool.awaitTransactionSuccessAsync(
_opts.poolId,
new BigNumber(_opts.operatorStake),
new BigNumber(_opts.membersStake),
_opts.makers,
);
await testContract
.createTestPool(
_opts.poolId,
new BigNumber(_opts.operatorStake),
new BigNumber(_opts.membersStake),
_opts.makers,
)
.awaitTransactionSuccessAsync();
return _opts;
}
@@ -80,23 +82,17 @@ blockchainTests('Protocol Fees unit tests', env => {
describe('forbidden actions', () => {
it('should revert if called by a non-exchange', async () => {
const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress,
payerAddress,
DEFAULT_PROTOCOL_FEE_PAID,
{ from: notExchangeAddress },
);
const tx = testContract
.payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID)
.awaitTransactionSuccessAsync({ from: notExchangeAddress });
const expectedError = new StakingRevertErrors.OnlyCallableByExchangeError(notExchangeAddress);
return expect(tx).to.revertWith(expectedError);
});
it('should revert if `protocolFee` is zero with non-zero value sent', async () => {
const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress,
payerAddress,
ZERO_AMOUNT,
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID },
);
const tx = testContract
.payProtocolFee(makerAddress, payerAddress, ZERO_AMOUNT)
.awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID });
const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError(
ZERO_AMOUNT,
DEFAULT_PROTOCOL_FEE_PAID,
@@ -105,12 +101,9 @@ blockchainTests('Protocol Fees unit tests', env => {
});
it('should revert if `protocolFee` is < than the provided message value', async () => {
const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress,
payerAddress,
DEFAULT_PROTOCOL_FEE_PAID,
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID.minus(1) },
);
const tx = testContract
.payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID)
.awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID.minus(1) });
const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError(
DEFAULT_PROTOCOL_FEE_PAID,
DEFAULT_PROTOCOL_FEE_PAID.minus(1),
@@ -119,12 +112,9 @@ blockchainTests('Protocol Fees unit tests', env => {
});
it('should revert if `protocolFee` is > than the provided message value', async () => {
const tx = testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress,
payerAddress,
DEFAULT_PROTOCOL_FEE_PAID,
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID.plus(1) },
);
const tx = testContract
.payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID)
.awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID.plus(1) });
const expectedError = new StakingRevertErrors.InvalidProtocolFeePaymentError(
DEFAULT_PROTOCOL_FEE_PAID,
DEFAULT_PROTOCOL_FEE_PAID.plus(1),
@@ -134,7 +124,7 @@ blockchainTests('Protocol Fees unit tests', env => {
});
async function getProtocolFeesAsync(poolId: string): Promise<BigNumber> {
return (await testContract.getStakingPoolStatsThisEpoch.callAsync(poolId)).feesCollected;
return (await testContract.getStakingPoolStatsThisEpoch(poolId).callAsync()).feesCollected;
}
describe('ETH fees', () => {
@@ -148,23 +138,17 @@ blockchainTests('Protocol Fees unit tests', env => {
it('should not transfer WETH if value is sent', async () => {
await createTestPoolAsync({ operatorStake: minimumStake });
const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress,
payerAddress,
DEFAULT_PROTOCOL_FEE_PAID,
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID },
);
const receipt = await testContract
.payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID)
.awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID });
assertNoWETHTransferLogs(receipt.logs);
});
it('should credit pool if the maker is in a pool', async () => {
const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake, makers: [makerAddress] });
const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress,
payerAddress,
DEFAULT_PROTOCOL_FEE_PAID,
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID },
);
const receipt = await testContract
.payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID)
.awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID });
assertNoWETHTransferLogs(receipt.logs);
const poolFees = await getProtocolFeesAsync(poolId);
@@ -173,12 +157,9 @@ blockchainTests('Protocol Fees unit tests', env => {
it('should not credit the pool if maker is not in a pool', async () => {
const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake });
const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress,
payerAddress,
DEFAULT_PROTOCOL_FEE_PAID,
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID },
);
const receipt = await testContract
.payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID)
.awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID });
assertNoWETHTransferLogs(receipt.logs);
const poolFees = await getProtocolFeesAsync(poolId);
expect(poolFees).to.bignumber.eq(ZERO_AMOUNT);
@@ -187,12 +168,9 @@ blockchainTests('Protocol Fees unit tests', env => {
it('fees paid to the same maker should go to the same pool', async () => {
const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake, makers: [makerAddress] });
const payAsync = async () => {
const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress,
payerAddress,
DEFAULT_PROTOCOL_FEE_PAID,
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID },
);
const receipt = await testContract
.payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID)
.awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID });
assertNoWETHTransferLogs(receipt.logs);
};
await payAsync();
@@ -219,23 +197,17 @@ blockchainTests('Protocol Fees unit tests', env => {
it('should transfer WETH if no value is sent and the maker is not in a pool', async () => {
await createTestPoolAsync({ operatorStake: minimumStake });
const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress,
payerAddress,
DEFAULT_PROTOCOL_FEE_PAID,
{ from: exchangeAddress, value: ZERO_AMOUNT },
);
const receipt = await testContract
.payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID)
.awaitTransactionSuccessAsync({ from: exchangeAddress, value: ZERO_AMOUNT });
assertWETHTransferLogs(receipt.logs, payerAddress, DEFAULT_PROTOCOL_FEE_PAID);
});
it('should update `protocolFeesThisEpochByPool` if the maker is in a pool', async () => {
const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake, makers: [makerAddress] });
const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress,
payerAddress,
DEFAULT_PROTOCOL_FEE_PAID,
{ from: exchangeAddress, value: ZERO_AMOUNT },
);
const receipt = await testContract
.payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID)
.awaitTransactionSuccessAsync({ from: exchangeAddress, value: ZERO_AMOUNT });
assertWETHTransferLogs(receipt.logs, payerAddress, DEFAULT_PROTOCOL_FEE_PAID);
const poolFees = await getProtocolFeesAsync(poolId);
expect(poolFees).to.bignumber.eq(DEFAULT_PROTOCOL_FEE_PAID);
@@ -243,12 +215,9 @@ blockchainTests('Protocol Fees unit tests', env => {
it('should not update `protocolFeesThisEpochByPool` if maker is not in a pool', async () => {
const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake });
const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress,
payerAddress,
DEFAULT_PROTOCOL_FEE_PAID,
{ from: exchangeAddress, value: ZERO_AMOUNT },
);
const receipt = await testContract
.payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID)
.awaitTransactionSuccessAsync({ from: exchangeAddress, value: ZERO_AMOUNT });
assertWETHTransferLogs(receipt.logs, payerAddress, DEFAULT_PROTOCOL_FEE_PAID);
const poolFees = await getProtocolFeesAsync(poolId);
expect(poolFees).to.bignumber.eq(ZERO_AMOUNT);
@@ -257,12 +226,9 @@ blockchainTests('Protocol Fees unit tests', env => {
it('fees paid to the same maker should go to the same pool', async () => {
const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake, makers: [makerAddress] });
const payAsync = async () => {
const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress,
payerAddress,
DEFAULT_PROTOCOL_FEE_PAID,
{ from: exchangeAddress, value: ZERO_AMOUNT },
);
const receipt = await testContract
.payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID)
.awaitTransactionSuccessAsync({ from: exchangeAddress, value: ZERO_AMOUNT });
assertWETHTransferLogs(receipt.logs, payerAddress, DEFAULT_PROTOCOL_FEE_PAID);
};
await payAsync();
@@ -275,15 +241,12 @@ blockchainTests('Protocol Fees unit tests', env => {
it('fees paid to the same maker in WETH then ETH should go to the same pool', async () => {
const { poolId } = await createTestPoolAsync({ operatorStake: minimumStake, makers: [makerAddress] });
const payAsync = async (inWETH: boolean) => {
await testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress,
payerAddress,
DEFAULT_PROTOCOL_FEE_PAID,
{
await testContract
.payProtocolFee(makerAddress, payerAddress, DEFAULT_PROTOCOL_FEE_PAID)
.awaitTransactionSuccessAsync({
from: exchangeAddress,
value: inWETH ? ZERO_AMOUNT : DEFAULT_PROTOCOL_FEE_PAID,
},
);
});
};
await payAsync(true);
await payAsync(false);
@@ -300,12 +263,9 @@ blockchainTests('Protocol Fees unit tests', env => {
membersStake: 0,
makers: [makerAddress],
});
await testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress,
constants.NULL_ADDRESS,
DEFAULT_PROTOCOL_FEE_PAID,
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID },
);
await testContract
.payProtocolFee(makerAddress, constants.NULL_ADDRESS, DEFAULT_PROTOCOL_FEE_PAID)
.awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID });
const feesCredited = await getProtocolFeesAsync(poolId);
expect(feesCredited).to.bignumber.eq(DEFAULT_PROTOCOL_FEE_PAID);
});
@@ -316,12 +276,9 @@ blockchainTests('Protocol Fees unit tests', env => {
membersStake: 0,
makers: [makerAddress],
});
await testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress,
constants.NULL_ADDRESS,
DEFAULT_PROTOCOL_FEE_PAID,
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID },
);
await testContract
.payProtocolFee(makerAddress, constants.NULL_ADDRESS, DEFAULT_PROTOCOL_FEE_PAID)
.awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID });
const feesCredited = await getProtocolFeesAsync(poolId);
expect(feesCredited).to.bignumber.eq(DEFAULT_PROTOCOL_FEE_PAID);
});
@@ -332,12 +289,9 @@ blockchainTests('Protocol Fees unit tests', env => {
membersStake: 0,
makers: [makerAddress],
});
await testContract.payProtocolFee.awaitTransactionSuccessAsync(
makerAddress,
constants.NULL_ADDRESS,
DEFAULT_PROTOCOL_FEE_PAID,
{ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID },
);
await testContract
.payProtocolFee(makerAddress, constants.NULL_ADDRESS, DEFAULT_PROTOCOL_FEE_PAID)
.awaitTransactionSuccessAsync({ from: exchangeAddress, value: DEFAULT_PROTOCOL_FEE_PAID });
const feesCredited = await getProtocolFeesAsync(poolId);
expect(feesCredited).to.bignumber.eq(0);
});
@@ -347,7 +301,7 @@ blockchainTests('Protocol Fees unit tests', env => {
let membersStakeWeight: number;
before(async () => {
membersStakeWeight = (await testContract.getParams.callAsync())[1];
membersStakeWeight = (await testContract.getParams().callAsync())[1];
});
interface FinalizationState {
@@ -357,7 +311,7 @@ blockchainTests('Protocol Fees unit tests', env => {
}
async function getFinalizationStateAsync(): Promise<FinalizationState> {
const aggregatedStats = await testContract.getAggregatedStatsForCurrentEpoch.callAsync();
const aggregatedStats = await testContract.getAggregatedStatsForCurrentEpoch().callAsync();
return {
numPoolsToFinalize: aggregatedStats.numPoolsToFinalize,
totalFeesCollected: aggregatedStats.totalFeesCollected,
@@ -372,12 +326,9 @@ blockchainTests('Protocol Fees unit tests', env => {
async function payToMakerAsync(poolMaker: string, fee?: Numberish): Promise<PayToMakerResult> {
const _fee = fee === undefined ? getRandomInteger(1, '1e18') : fee;
const receipt = await testContract.payProtocolFee.awaitTransactionSuccessAsync(
poolMaker,
payerAddress,
new BigNumber(_fee),
{ from: exchangeAddress, value: _fee },
);
const receipt = await testContract
.payProtocolFee(poolMaker, payerAddress, new BigNumber(_fee))
.awaitTransactionSuccessAsync({ from: exchangeAddress, value: _fee });
const events = filterLogsToArguments<IStakingEventsStakingPoolEarnedRewardsInEpochEventArgs>(
receipt.logs,
IStakingEventsEvents.StakingPoolEarnedRewardsInEpoch,
@@ -404,7 +355,7 @@ blockchainTests('Protocol Fees unit tests', env => {
it('pool is not registered to start', async () => {
const { poolId } = await createTestPoolAsync();
const pool = await testContract.getStakingPoolStatsThisEpoch.callAsync(poolId);
const pool = await testContract.getStakingPoolStatsThisEpoch(poolId).callAsync();
expect(pool.feesCollected).to.bignumber.eq(0);
expect(pool.membersStake).to.bignumber.eq(0);
expect(pool.weightedStake).to.bignumber.eq(0);
@@ -419,7 +370,7 @@ blockchainTests('Protocol Fees unit tests', env => {
const { fee, poolEarnedRewardsEvents } = await payToMakerAsync(poolMaker);
expect(poolEarnedRewardsEvents.length).to.eq(1);
expect(poolEarnedRewardsEvents[0].poolId).to.eq(poolId);
const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch.callAsync(poolId);
const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch(poolId).callAsync();
const expectedWeightedStake = toWeightedStake(pool.operatorStake, pool.membersStake);
expect(actualPoolStats.feesCollected).to.bignumber.eq(fee);
expect(actualPoolStats.membersStake).to.bignumber.eq(pool.membersStake);
@@ -439,7 +390,7 @@ blockchainTests('Protocol Fees unit tests', env => {
const { fee: fee1 } = await payToMakerAsync(poolMaker);
const { fee: fee2, poolEarnedRewardsEvents } = await payToMakerAsync(poolMaker);
expect(poolEarnedRewardsEvents).to.deep.eq([]);
const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch.callAsync(poolId);
const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch(poolId).callAsync();
const expectedWeightedStake = toWeightedStake(pool.operatorStake, pool.membersStake);
const fees = BigNumber.sum(fee1, fee2);
expect(actualPoolStats.feesCollected).to.bignumber.eq(fees);
@@ -463,7 +414,7 @@ blockchainTests('Protocol Fees unit tests', env => {
const { fee, poolEarnedRewardsEvents } = await payToMakerAsync(poolMaker);
expect(poolEarnedRewardsEvents.length).to.eq(1);
expect(poolEarnedRewardsEvents[0].poolId).to.eq(poolId);
const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch.callAsync(poolId);
const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch(poolId).callAsync();
const expectedWeightedStake = toWeightedStake(pool.operatorStake, pool.membersStake);
expect(actualPoolStats.feesCollected).to.bignumber.eq(fee);
expect(actualPoolStats.membersStake).to.bignumber.eq(pool.membersStake);
@@ -484,8 +435,8 @@ blockchainTests('Protocol Fees unit tests', env => {
makers: [poolMaker],
} = pool;
await payToMakerAsync(poolMaker);
await testContract.advanceEpoch.awaitTransactionSuccessAsync();
const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch.callAsync(poolId);
await testContract.advanceEpoch().awaitTransactionSuccessAsync();
const actualPoolStats = await testContract.getStakingPoolStatsThisEpoch(poolId).callAsync();
expect(actualPoolStats.feesCollected).to.bignumber.eq(0);
expect(actualPoolStats.membersStake).to.bignumber.eq(0);
expect(actualPoolStats.weightedStake).to.bignumber.eq(0);