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:
@@ -126,9 +126,9 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
});
|
||||
it('should confirm transaction for caller but not reset the confirmation time if tx is already fully confirmed', async () => {
|
||||
await multiSigWrapper.confirmTransactionAsync(txId, owners[1]);
|
||||
const confirmationTimeBefore = await multiSig.confirmationTimes.callAsync(txId);
|
||||
const confirmationTimeBefore = await multiSig.confirmationTimes(txId).callAsync();
|
||||
const txReceipt = await multiSigWrapper.confirmTransactionAsync(txId, owners[2]);
|
||||
const confirmationTimeAfter = await multiSig.confirmationTimes.callAsync(txId);
|
||||
const confirmationTimeAfter = await multiSig.confirmationTimes(txId).callAsync();
|
||||
expect(confirmationTimeBefore).to.bignumber.equal(confirmationTimeAfter);
|
||||
expect(txReceipt.logs.length).to.equal(1);
|
||||
const log = txReceipt.logs[0] as LogWithDecodedArgs<MultiSigWalletWithTimeLockConfirmationEventArgs>;
|
||||
@@ -256,25 +256,25 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
|
||||
it('should revert when not called by wallet', async () => {
|
||||
return expectTransactionFailedWithoutReasonAsync(
|
||||
multiSig.changeTimeLock.sendTransactionAsync(SECONDS_TIME_LOCKED, { from: owners[0] }),
|
||||
multiSig.changeTimeLock(SECONDS_TIME_LOCKED).sendTransactionAsync({ from: owners[0] }),
|
||||
);
|
||||
});
|
||||
|
||||
it('should revert without enough confirmations', async () => {
|
||||
const destination = multiSig.address;
|
||||
const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(SECONDS_TIME_LOCKED);
|
||||
const changeTimeLockData = multiSig.changeTimeLock(SECONDS_TIME_LOCKED).getABIEncodedTransactionData();
|
||||
const res = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]);
|
||||
const log = res.logs[0] as LogWithDecodedArgs<MultiSigWalletWithTimeLockSubmissionEventArgs>;
|
||||
const txId = log.args.transactionId;
|
||||
return expectTransactionFailedAsync(
|
||||
multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }),
|
||||
multiSig.executeTransaction(txId).sendTransactionAsync({ from: owners[0] }),
|
||||
RevertReason.TxNotFullyConfirmed,
|
||||
);
|
||||
});
|
||||
|
||||
it('should set confirmation time with enough confirmations', async () => {
|
||||
const destination = multiSig.address;
|
||||
const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(SECONDS_TIME_LOCKED);
|
||||
const changeTimeLockData = multiSig.changeTimeLock(SECONDS_TIME_LOCKED).getABIEncodedTransactionData();
|
||||
const subRes = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]);
|
||||
const subLog = subRes.logs[0] as LogWithDecodedArgs<MultiSigWalletWithTimeLockSubmissionEventArgs>;
|
||||
const txId = subLog.args.transactionId;
|
||||
@@ -288,14 +288,14 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
throw new Error(`Unexpectedly failed to fetch block at #${blockNum}`);
|
||||
}
|
||||
const timestamp = new BigNumber(blockInfo.timestamp);
|
||||
const confirmationTimeBigNum = new BigNumber(await multiSig.confirmationTimes.callAsync(txId));
|
||||
const confirmationTimeBigNum = new BigNumber(await multiSig.confirmationTimes(txId).callAsync());
|
||||
|
||||
expect(timestamp).to.be.bignumber.equal(confirmationTimeBigNum);
|
||||
});
|
||||
|
||||
it('should be executable with enough confirmations and secondsTimeLocked of 0', async () => {
|
||||
const destination = multiSig.address;
|
||||
const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(SECONDS_TIME_LOCKED);
|
||||
const changeTimeLockData = multiSig.changeTimeLock(SECONDS_TIME_LOCKED).getABIEncodedTransactionData();
|
||||
const subRes = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]);
|
||||
const subLog = subRes.logs[0] as LogWithDecodedArgs<MultiSigWalletWithTimeLockSubmissionEventArgs>;
|
||||
const txId = subLog.args.transactionId;
|
||||
@@ -303,7 +303,7 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
await multiSigWrapper.confirmTransactionAsync(txId, owners[1]);
|
||||
await multiSigWrapper.executeTransactionAsync(txId, owners[1]);
|
||||
|
||||
const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.callAsync());
|
||||
const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked().callAsync());
|
||||
expect(secondsTimeLocked).to.be.bignumber.equal(SECONDS_TIME_LOCKED);
|
||||
});
|
||||
});
|
||||
@@ -328,7 +328,7 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
);
|
||||
multiSigWrapper = new MultiSigWrapper(multiSig, provider);
|
||||
|
||||
const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(newSecondsTimeLocked);
|
||||
const changeTimeLockData = multiSig.changeTimeLock(newSecondsTimeLocked).getABIEncodedTransactionData();
|
||||
const res = await multiSigWrapper.submitTransactionAsync(
|
||||
multiSig.address,
|
||||
changeTimeLockData,
|
||||
@@ -341,19 +341,21 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
|
||||
it('should revert if it has enough confirmations but is not past the time lock', async () => {
|
||||
return expectTransactionFailedAsync(
|
||||
multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }),
|
||||
multiSig.executeTransaction(txId).sendTransactionAsync({ from: owners[0] }),
|
||||
RevertReason.TimeLockIncomplete,
|
||||
);
|
||||
});
|
||||
|
||||
it('should execute if it has enough confirmations and is past the time lock', async () => {
|
||||
await increaseTimeAndMineBlockAsync(SECONDS_TIME_LOCKED.toNumber());
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }),
|
||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||
);
|
||||
await multiSig
|
||||
.executeTransaction(txId)
|
||||
.awaitTransactionSuccessAsync(
|
||||
{ from: owners[0] },
|
||||
{ pollingIntervalMs: constants.AWAIT_TRANSACTION_MINED_MS },
|
||||
);
|
||||
|
||||
const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.callAsync());
|
||||
const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked().callAsync());
|
||||
expect(secondsTimeLocked).to.be.bignumber.equal(newSecondsTimeLocked);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -25,19 +25,19 @@ export class MultiSigWrapper {
|
||||
opts: { value?: BigNumber } = {},
|
||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const value = opts.value === undefined ? new BigNumber(0) : opts.value;
|
||||
const txHash = await this._multiSig.submitTransaction.sendTransactionAsync(destination, value, data, {
|
||||
const txHash = await this._multiSig.submitTransaction(destination, value, data).sendTransactionAsync({
|
||||
from,
|
||||
});
|
||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
||||
return tx;
|
||||
}
|
||||
public async confirmTransactionAsync(txId: BigNumber, from: string): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const txHash = await this._multiSig.confirmTransaction.sendTransactionAsync(txId, { from });
|
||||
const txHash = await this._multiSig.confirmTransaction(txId).sendTransactionAsync({ from });
|
||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
||||
return tx;
|
||||
}
|
||||
public async revokeConfirmationAsync(txId: BigNumber, from: string): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const txHash = await this._multiSig.revokeConfirmation.sendTransactionAsync(txId, { from });
|
||||
const txHash = await this._multiSig.revokeConfirmation(txId).sendTransactionAsync({ from });
|
||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
||||
return tx;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ export class MultiSigWrapper {
|
||||
from: string,
|
||||
opts: { gas?: number } = {},
|
||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const txHash = await this._multiSig.executeTransaction.sendTransactionAsync(txId, {
|
||||
const txHash = await this._multiSig.executeTransaction(txId).sendTransactionAsync({
|
||||
from,
|
||||
gas: opts.gas,
|
||||
});
|
||||
|
||||
@@ -20,12 +20,13 @@ export class ZeroExGovernorWrapper {
|
||||
const values = opts.values === undefined ? data.map(() => constants.ZERO_AMOUNT) : opts.values;
|
||||
const batchTransactionEncoder = AbiEncoder.create('(bytes[],address[],uint256[])');
|
||||
const batchTransactionData = batchTransactionEncoder.encode([data, destinations, values]);
|
||||
const txReceipt = await this._governor.submitTransaction.awaitTransactionSuccessAsync(
|
||||
hexRandom(20), // submitTransaction will fail if this is a null address
|
||||
constants.ZERO_AMOUNT,
|
||||
batchTransactionData,
|
||||
{ from },
|
||||
);
|
||||
const txReceipt = await this._governor
|
||||
.submitTransaction(
|
||||
hexRandom(20), // submitTransaction will fail if this is a null address
|
||||
constants.ZERO_AMOUNT,
|
||||
batchTransactionData,
|
||||
)
|
||||
.awaitTransactionSuccessAsync({ from });
|
||||
const txId = (txReceipt.logs[0] as LogWithDecodedArgs<ZeroExGovernorSubmissionEventArgs>).args.transactionId;
|
||||
return { txReceipt, txId };
|
||||
}
|
||||
@@ -39,15 +40,16 @@ export class ZeroExGovernorWrapper {
|
||||
const submitResults = await this.submitTransactionAsync(data, destinations, signerAddresses[0], opts);
|
||||
const requiredSignatures = opts.requiredSignatures === undefined ? 2 : opts.requiredSignatures;
|
||||
for (const index of _.range(1, requiredSignatures)) {
|
||||
await this._governor.confirmTransaction.awaitTransactionSuccessAsync(submitResults.txId, {
|
||||
await this._governor.confirmTransaction(submitResults.txId).awaitTransactionSuccessAsync({
|
||||
from: signerAddresses[index],
|
||||
});
|
||||
}
|
||||
await increaseTimeAndMineBlockAsync(increaseTimeSeconds);
|
||||
const executionTxReceipt = await this._governor.executeTransaction.awaitTransactionSuccessAsync(
|
||||
submitResults.txId,
|
||||
{ from: opts.executeFromAddress === undefined ? signerAddresses[0] : opts.executeFromAddress },
|
||||
);
|
||||
const executionTxReceipt = await this._governor
|
||||
.executeTransaction(submitResults.txId)
|
||||
.awaitTransactionSuccessAsync({
|
||||
from: opts.executeFromAddress === undefined ? signerAddresses[0] : opts.executeFromAddress,
|
||||
});
|
||||
return { executionTxReceipt, txId: submitResults.txId };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,10 +158,9 @@ blockchainTests.resets('ZeroExGovernor', env => {
|
||||
new BigNumber(REQUIRED_SIGNERS),
|
||||
new BigNumber(DEFAULT_TIME_LOCK),
|
||||
);
|
||||
const timelock = await governorContract.functionCallTimeLocks.callAsync(
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
);
|
||||
const timelock = await governorContract
|
||||
.functionCallTimeLocks(reg.functionSelectors[0], reg.destinations[0])
|
||||
.callAsync();
|
||||
expect(timelock[0]).to.equal(true);
|
||||
expect(timelock[1]).to.bignumber.equal(reg.functionCallTimeLockSeconds[0]);
|
||||
});
|
||||
@@ -180,10 +179,9 @@ blockchainTests.resets('ZeroExGovernor', env => {
|
||||
new BigNumber(DEFAULT_TIME_LOCK),
|
||||
);
|
||||
for (const [index, selector] of reg.functionSelectors.entries()) {
|
||||
const timelock = await governorContract.functionCallTimeLocks.callAsync(
|
||||
selector,
|
||||
reg.destinations[index],
|
||||
);
|
||||
const timelock = await governorContract
|
||||
.functionCallTimeLocks(selector, reg.destinations[index])
|
||||
.callAsync();
|
||||
expect(timelock[0]).to.equal(true);
|
||||
expect(timelock[1]).to.bignumber.equal(reg.functionCallTimeLockSeconds[index]);
|
||||
}
|
||||
@@ -193,23 +191,26 @@ blockchainTests.resets('ZeroExGovernor', env => {
|
||||
blockchainTests.resets('registerFunctionCall', () => {
|
||||
it('should revert if not called by wallet', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
const tx = governor.registerFunctionCall.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
{ from: signerAddresses[0] },
|
||||
);
|
||||
const tx = governor
|
||||
.registerFunctionCall(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
)
|
||||
.awaitTransactionSuccessAsync({ from: signerAddresses[0] });
|
||||
expect(tx).to.revertWith(RevertReason.OnlyCallableByWallet);
|
||||
});
|
||||
it('should register a function call', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
const txReceipt = await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
);
|
||||
const txReceipt = await governor
|
||||
.registerFunctionCallBypassWallet(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
)
|
||||
.awaitTransactionSuccessAsync();
|
||||
expect(txReceipt.logs.length).to.eq(1);
|
||||
const logArgs = (txReceipt.logs[0] as LogWithDecodedArgs<
|
||||
ZeroExGovernorFunctionCallTimeLockRegistrationEventArgs
|
||||
@@ -218,53 +219,53 @@ blockchainTests.resets('ZeroExGovernor', env => {
|
||||
expect(logArgs.destination).to.eq(reg.destinations[0]);
|
||||
expect(logArgs.hasCustomTimeLock).to.eq(true);
|
||||
expect(logArgs.newSecondsTimeLocked).to.bignumber.eq(reg.functionCallTimeLockSeconds[0]);
|
||||
const timelock = await governor.functionCallTimeLocks.callAsync(
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
);
|
||||
const timelock = await governor
|
||||
.functionCallTimeLocks(reg.functionSelectors[0], reg.destinations[0])
|
||||
.callAsync();
|
||||
expect(timelock[0]).to.equal(true);
|
||||
expect(timelock[1]).to.bignumber.equal(reg.functionCallTimeLockSeconds[0]);
|
||||
});
|
||||
it('should be able to overwrite existing function calls', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
);
|
||||
await governor
|
||||
.registerFunctionCallBypassWallet(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
)
|
||||
.awaitTransactionSuccessAsync();
|
||||
const newTimeLock = reg.functionCallTimeLockSeconds[0].plus(1000);
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
newTimeLock,
|
||||
);
|
||||
const timelock = await governor.functionCallTimeLocks.callAsync(
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
);
|
||||
await governor
|
||||
.registerFunctionCallBypassWallet(true, reg.functionSelectors[0], reg.destinations[0], newTimeLock)
|
||||
.awaitTransactionSuccessAsync();
|
||||
const timelock = await governor
|
||||
.functionCallTimeLocks(reg.functionSelectors[0], reg.destinations[0])
|
||||
.callAsync();
|
||||
expect(timelock[0]).to.equal(true);
|
||||
expect(timelock[1]).to.bignumber.equal(newTimeLock);
|
||||
});
|
||||
it('should clear the function timelock if hasCustomTimeLock is set to false', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
);
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
false,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
);
|
||||
const timelock = await governor.functionCallTimeLocks.callAsync(
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
);
|
||||
await governor
|
||||
.registerFunctionCallBypassWallet(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
)
|
||||
.awaitTransactionSuccessAsync();
|
||||
await governor
|
||||
.registerFunctionCallBypassWallet(
|
||||
false,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
)
|
||||
.awaitTransactionSuccessAsync();
|
||||
const timelock = await governor
|
||||
.functionCallTimeLocks(reg.functionSelectors[0], reg.destinations[0])
|
||||
.callAsync();
|
||||
expect(timelock[0]).to.equal(false);
|
||||
expect(timelock[1]).to.bignumber.equal(constants.ZERO_AMOUNT);
|
||||
});
|
||||
@@ -272,11 +273,9 @@ blockchainTests.resets('ZeroExGovernor', env => {
|
||||
|
||||
describe('assertValidFunctionCall', () => {
|
||||
it('should revert if the data is less than 4 bytes long', async () => {
|
||||
const result = governor.assertValidFunctionCall.callAsync(
|
||||
constants.ZERO_AMOUNT,
|
||||
constants.NULL_BYTES,
|
||||
constants.NULL_ADDRESS,
|
||||
);
|
||||
const result = governor
|
||||
.assertValidFunctionCall(constants.ZERO_AMOUNT, constants.NULL_BYTES, constants.NULL_ADDRESS)
|
||||
.callAsync();
|
||||
const expectedError = new LibBytesRevertErrors.InvalidByteOperationError(
|
||||
LibBytesRevertErrors.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsFourRequired,
|
||||
constants.ZERO_AMOUNT,
|
||||
@@ -288,91 +287,87 @@ blockchainTests.resets('ZeroExGovernor', env => {
|
||||
const latestTimestamp = await getLatestBlockTimestampAsync();
|
||||
const transactionConfirmationTime = new BigNumber(latestTimestamp);
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
const result = governor.assertValidFunctionCall.callAsync(
|
||||
transactionConfirmationTime,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
);
|
||||
const result = governor
|
||||
.assertValidFunctionCall(transactionConfirmationTime, reg.functionSelectors[0], reg.destinations[0])
|
||||
.callAsync();
|
||||
expect(result).to.revertWith(RevertReason.DefaultTimeLockIncomplete);
|
||||
});
|
||||
it('should revert if a registered function is called before the custom timelock', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
);
|
||||
await governor
|
||||
.registerFunctionCallBypassWallet(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
)
|
||||
.awaitTransactionSuccessAsync();
|
||||
const latestTimestamp = await getLatestBlockTimestampAsync();
|
||||
const transactionConfirmationTime = new BigNumber(latestTimestamp);
|
||||
const result = governor.assertValidFunctionCall.callAsync(
|
||||
transactionConfirmationTime,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
);
|
||||
const result = governor
|
||||
.assertValidFunctionCall(transactionConfirmationTime, reg.functionSelectors[0], reg.destinations[0])
|
||||
.callAsync();
|
||||
expect(result).to.revertWith(RevertReason.CustomTimeLockIncomplete);
|
||||
});
|
||||
it('should revert if a registered function is called before the custom timelock and after the default timelock', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
new BigNumber(DEFAULT_TIME_LOCK).times(2),
|
||||
);
|
||||
await governor
|
||||
.registerFunctionCallBypassWallet(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
new BigNumber(DEFAULT_TIME_LOCK).times(2),
|
||||
)
|
||||
.awaitTransactionSuccessAsync();
|
||||
const latestTimestamp = await getLatestBlockTimestampAsync();
|
||||
const transactionConfirmationTime = new BigNumber(latestTimestamp).minus(DEFAULT_TIME_LOCK);
|
||||
const result = governor.assertValidFunctionCall.callAsync(
|
||||
transactionConfirmationTime,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
);
|
||||
const result = governor
|
||||
.assertValidFunctionCall(transactionConfirmationTime, reg.functionSelectors[0], reg.destinations[0])
|
||||
.callAsync();
|
||||
expect(result).to.revertWith(RevertReason.CustomTimeLockIncomplete);
|
||||
});
|
||||
it('should be successful if an unregistered function is called after the default timelock', async () => {
|
||||
const latestTimestamp = await getLatestBlockTimestampAsync();
|
||||
const transactionConfirmationTime = new BigNumber(latestTimestamp).minus(DEFAULT_TIME_LOCK);
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
const result = governor.assertValidFunctionCall.callAsync(
|
||||
transactionConfirmationTime,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
);
|
||||
const result = governor
|
||||
.assertValidFunctionCall(transactionConfirmationTime, reg.functionSelectors[0], reg.destinations[0])
|
||||
.callAsync();
|
||||
expect(result).to.be.fulfilled('');
|
||||
});
|
||||
it('should be successful if a registered function is called after the custom timelock', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
);
|
||||
await governor
|
||||
.registerFunctionCallBypassWallet(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
)
|
||||
.awaitTransactionSuccessAsync();
|
||||
const latestTimestamp = await getLatestBlockTimestampAsync();
|
||||
const transactionConfirmationTime = new BigNumber(latestTimestamp).minus(
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
);
|
||||
const result = governor.assertValidFunctionCall.callAsync(
|
||||
transactionConfirmationTime,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
);
|
||||
const result = governor
|
||||
.assertValidFunctionCall(transactionConfirmationTime, reg.functionSelectors[0], reg.destinations[0])
|
||||
.callAsync();
|
||||
expect(result).to.be.fulfilled('');
|
||||
});
|
||||
it('should allow a custom timelock to be set to 0', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
constants.ZERO_AMOUNT,
|
||||
);
|
||||
await governor
|
||||
.registerFunctionCallBypassWallet(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
constants.ZERO_AMOUNT,
|
||||
)
|
||||
.awaitTransactionSuccessAsync();
|
||||
const latestTimestamp = await getLatestBlockTimestampAsync();
|
||||
const result = governor.assertValidFunctionCall.callAsync(
|
||||
new BigNumber(latestTimestamp),
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
);
|
||||
const result = governor
|
||||
.assertValidFunctionCall(new BigNumber(latestTimestamp), reg.functionSelectors[0], reg.destinations[0])
|
||||
.callAsync();
|
||||
expect(result).to.be.fulfilled('');
|
||||
});
|
||||
});
|
||||
@@ -402,7 +397,7 @@ blockchainTests.resets('ZeroExGovernor', env => {
|
||||
const data = [hexRandom()];
|
||||
const destinations = [receiver.address];
|
||||
const results = await governorWrapper.submitTransactionAsync(data, destinations, signerAddresses[0]);
|
||||
const tx = governor.executeTransaction.awaitTransactionSuccessAsync(results.txId, {
|
||||
const tx = governor.executeTransaction(results.txId).awaitTransactionSuccessAsync({
|
||||
from: signerAddresses[1],
|
||||
});
|
||||
expect(tx).to.revertWith(RevertReason.TxNotFullyConfirmed);
|
||||
@@ -411,7 +406,7 @@ blockchainTests.resets('ZeroExGovernor', env => {
|
||||
const data = [hexRandom()];
|
||||
const destinations = [receiver.address];
|
||||
const results = await governorWrapper.submitTransactionAsync(data, destinations, signerAddresses[0]);
|
||||
const tx = governor.executeTransaction.awaitTransactionSuccessAsync(results.txId, {
|
||||
const tx = governor.executeTransaction(results.txId).awaitTransactionSuccessAsync({
|
||||
from: signerAddresses[0],
|
||||
});
|
||||
expect(tx).to.revertWith(RevertReason.TxNotFullyConfirmed);
|
||||
@@ -444,12 +439,9 @@ blockchainTests.resets('ZeroExGovernor', env => {
|
||||
const data = [hexRandom()];
|
||||
const destinations = [receiver.address];
|
||||
const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2);
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
data[0].slice(0, 10),
|
||||
receiver.address,
|
||||
newTimeLock,
|
||||
);
|
||||
await governor
|
||||
.registerFunctionCallBypassWallet(true, data[0].slice(0, 10), receiver.address, newTimeLock)
|
||||
.awaitTransactionSuccessAsync();
|
||||
const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
@@ -462,12 +454,9 @@ blockchainTests.resets('ZeroExGovernor', env => {
|
||||
const data = [hexRandom()];
|
||||
const destinations = [receiver.address];
|
||||
const newTimeLock = constants.ZERO_AMOUNT;
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
data[0].slice(0, 10),
|
||||
receiver.address,
|
||||
newTimeLock,
|
||||
);
|
||||
await governor
|
||||
.registerFunctionCallBypassWallet(true, data[0].slice(0, 10), receiver.address, newTimeLock)
|
||||
.awaitTransactionSuccessAsync();
|
||||
const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
@@ -480,12 +469,9 @@ blockchainTests.resets('ZeroExGovernor', env => {
|
||||
const data = [hexRandom()];
|
||||
const destinations = [receiver.address];
|
||||
const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2);
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
data[0].slice(0, 10),
|
||||
receiver.address,
|
||||
newTimeLock,
|
||||
);
|
||||
await governor
|
||||
.registerFunctionCallBypassWallet(true, data[0].slice(0, 10), receiver.address, newTimeLock)
|
||||
.awaitTransactionSuccessAsync();
|
||||
const values = [INITIAL_BALANCE];
|
||||
const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
@@ -530,12 +516,9 @@ blockchainTests.resets('ZeroExGovernor', env => {
|
||||
const data = [hexRandom(), hexRandom()];
|
||||
const destinations = [receiver.address, receiver.address];
|
||||
const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2);
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
data[0].slice(0, 10),
|
||||
receiver.address,
|
||||
newTimeLock,
|
||||
);
|
||||
await governor
|
||||
.registerFunctionCallBypassWallet(true, data[0].slice(0, 10), receiver.address, newTimeLock)
|
||||
.awaitTransactionSuccessAsync();
|
||||
const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
@@ -548,12 +531,9 @@ blockchainTests.resets('ZeroExGovernor', env => {
|
||||
const data = [hexRandom(), hexRandom()];
|
||||
const destinations = [receiver.address, receiver.address];
|
||||
const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2);
|
||||
await governor.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
|
||||
true,
|
||||
data[0].slice(0, 10),
|
||||
receiver.address,
|
||||
newTimeLock,
|
||||
);
|
||||
await governor
|
||||
.registerFunctionCallBypassWallet(true, data[0].slice(0, 10), receiver.address, newTimeLock)
|
||||
.awaitTransactionSuccessAsync();
|
||||
const tx = governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
data,
|
||||
destinations,
|
||||
@@ -630,7 +610,7 @@ blockchainTests.resets('ZeroExGovernor', env => {
|
||||
signerAddresses,
|
||||
DEFAULT_TIME_LOCK,
|
||||
);
|
||||
const tx = governor.executeTransaction.awaitTransactionSuccessAsync(results.txId);
|
||||
const tx = governor.executeTransaction(results.txId).awaitTransactionSuccessAsync();
|
||||
expect(tx).to.revertWith(RevertReason.TxAlreadyExecuted);
|
||||
});
|
||||
it('should revert if the only call is unsuccessful', async () => {
|
||||
@@ -660,12 +640,14 @@ blockchainTests.resets('ZeroExGovernor', env => {
|
||||
it('should be able to call registerFunctionCall after the default timelock', async () => {
|
||||
const reg = createFunctionRegistration(1, 1, 1);
|
||||
const data = [
|
||||
governor.registerFunctionCall.getABIEncodedTransactionData(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
),
|
||||
governor
|
||||
.registerFunctionCall(
|
||||
true,
|
||||
reg.functionSelectors[0],
|
||||
reg.destinations[0],
|
||||
reg.functionCallTimeLockSeconds[0],
|
||||
)
|
||||
.getABIEncodedTransactionData(),
|
||||
];
|
||||
const destinations = [governor.address];
|
||||
const results = await governorWrapper.submitConfirmAndExecuteTransactionAsync(
|
||||
|
||||
Reference in New Issue
Block a user