Fix linting errors

This commit is contained in:
Amir Bandeali
2019-09-13 15:12:24 -05:00
parent f47feabb4a
commit 057aee8ad2
4 changed files with 37 additions and 14 deletions

View File

@@ -123,6 +123,7 @@ contract AssetProxyOwner is
// Decode batch transaction data from transaction.data
// `destination` and `value` fields of transaction are ignored
// Note that `destination` must be non-0, or the transaction cannot be submitted
// solhint-disable
(
bytes[] memory data,
address[] memory destinations,
@@ -131,6 +132,7 @@ contract AssetProxyOwner is
transaction.data,
(bytes[], address[], uint256[])
);
// solhint-enable
// Ensure lengths of array properties are equal
uint256 length = data.length;
@@ -148,6 +150,7 @@ contract AssetProxyOwner is
destinations[i]
);
// Call each function
// solhint-disable-next-line avoid-call-value
(bool didSucceed,) = destinations[i].call.value(values[i])(data[i]);
// Ensure that function call was successful
require(
@@ -200,6 +203,7 @@ contract AssetProxyOwner is
{
bytes4 functionSelector = data.readBytes4(0);
TimeLock storage timeLock = functionCallTimeLocks[functionSelector][destination];
// solhint-disable not-rely-on-time
if (timeLock.hasCustomTimeLock) {
require(
block.timestamp >= transactionConfirmationTime.safeAdd(timeLock.secondsTimeLocked),
@@ -211,5 +215,6 @@ contract AssetProxyOwner is
"DEFAULT_TIME_LOCK_INCOMPLETE"
);
}
// solhint-enable not-rely-on-time
}
}

View File

@@ -45,7 +45,7 @@ contract TestAssetProxyOwner is
)
{}
function registerFunctionCallBypassWalet(
function registerFunctionCallBypassWallet(
bool hasCustomTimeLock,
bytes4 functionSelector,
address destination,

View File

@@ -14,6 +14,7 @@ import {
TestAssetProxyOwnerContract,
} from '../src';
// tslint:disable: no-unnecessary-type-assertion
blockchainTests.resets('AssetProxyOwner', env => {
let assetProxyOwner: TestAssetProxyOwnerContract;
let assetProxyOwnerWrapper: AssetProxyOwnerWrapper;
@@ -182,7 +183,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
});
it('should register a function call', async () => {
const reg = createFunctionRegistration(1, 1, 1);
const txReceipt = await assetProxyOwner.registerFunctionCallBypassWalet.awaitTransactionSuccessAsync(
const txReceipt = await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
true,
reg.functionSelectors[0],
reg.destinations[0],
@@ -205,14 +206,14 @@ blockchainTests.resets('AssetProxyOwner', env => {
});
it('should be able to overwrite existing function calls', async () => {
const reg = createFunctionRegistration(1, 1, 1);
await assetProxyOwner.registerFunctionCallBypassWalet.awaitTransactionSuccessAsync(
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
true,
reg.functionSelectors[0],
reg.destinations[0],
reg.functionCallTimeLockSeconds[0],
);
const newTimeLock = reg.functionCallTimeLockSeconds[0].plus(1000);
await assetProxyOwner.registerFunctionCallBypassWalet.awaitTransactionSuccessAsync(
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
true,
reg.functionSelectors[0],
reg.destinations[0],
@@ -227,13 +228,13 @@ blockchainTests.resets('AssetProxyOwner', env => {
});
it('should clear the function timelock if hasCustomTimeLock is set to false', async () => {
const reg = createFunctionRegistration(1, 1, 1);
await assetProxyOwner.registerFunctionCallBypassWalet.awaitTransactionSuccessAsync(
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
true,
reg.functionSelectors[0],
reg.destinations[0],
reg.functionCallTimeLockSeconds[0],
);
await assetProxyOwner.registerFunctionCallBypassWalet.awaitTransactionSuccessAsync(
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
false,
reg.functionSelectors[0],
reg.destinations[0],
@@ -275,7 +276,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
});
it('should revert if a registered function is called before the custom timelock', async () => {
const reg = createFunctionRegistration(1, 1, 1);
await assetProxyOwner.registerFunctionCallBypassWalet.awaitTransactionSuccessAsync(
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
true,
reg.functionSelectors[0],
reg.destinations[0],
@@ -303,7 +304,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
});
it('should be successful if a registered function is called after the custom timelock', async () => {
const reg = createFunctionRegistration(1, 1, 1);
await assetProxyOwner.registerFunctionCallBypassWalet.awaitTransactionSuccessAsync(
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
true,
reg.functionSelectors[0],
reg.destinations[0],
@@ -320,7 +321,22 @@ blockchainTests.resets('AssetProxyOwner', env => {
);
expect(result).to.be.fulfilled('');
});
it('should allow a custom timelock to be set to 0', async () => {});
it('should allow a custom timelock to be set to 0', async () => {
const reg = createFunctionRegistration(1, 1, 1);
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
true,
reg.functionSelectors[0],
reg.destinations[0],
constants.ZERO_AMOUNT,
);
const latestTimestamp = await getLatestBlockTimestampAsync();
const result = assetProxyOwner.assertValidFunctionCall.callAsync(
new BigNumber(latestTimestamp),
reg.functionSelectors[0],
reg.destinations[0],
);
expect(result).to.be.fulfilled('');
});
});
blockchainTests.resets('executeTransaction', () => {
@@ -381,7 +397,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
const data = [hexRandom()];
const destinations = [receiver.address];
const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2);
await assetProxyOwner.registerFunctionCallBypassWalet.awaitTransactionSuccessAsync(
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
true,
data[0].slice(0, 10),
receiver.address,
@@ -399,7 +415,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
const data = [hexRandom()];
const destinations = [receiver.address];
const newTimeLock = constants.ZERO_AMOUNT;
await assetProxyOwner.registerFunctionCallBypassWalet.awaitTransactionSuccessAsync(
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
true,
data[0].slice(0, 10),
receiver.address,
@@ -417,7 +433,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
const data = [hexRandom()];
const destinations = [receiver.address];
const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2);
await assetProxyOwner.registerFunctionCallBypassWalet.awaitTransactionSuccessAsync(
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
true,
data[0].slice(0, 10),
receiver.address,
@@ -467,7 +483,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
const data = [hexRandom(), hexRandom()];
const destinations = [receiver.address, receiver.address];
const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2);
await assetProxyOwner.registerFunctionCallBypassWalet.awaitTransactionSuccessAsync(
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
true,
data[0].slice(0, 10),
receiver.address,
@@ -485,7 +501,7 @@ blockchainTests.resets('AssetProxyOwner', env => {
const data = [hexRandom(), hexRandom()];
const destinations = [receiver.address, receiver.address];
const newTimeLock = new BigNumber(DEFAULT_TIME_LOCK).dividedToIntegerBy(2);
await assetProxyOwner.registerFunctionCallBypassWalet.awaitTransactionSuccessAsync(
await assetProxyOwner.registerFunctionCallBypassWallet.awaitTransactionSuccessAsync(
true,
data[0].slice(0, 10),
receiver.address,
@@ -598,3 +614,4 @@ blockchainTests.resets('AssetProxyOwner', env => {
});
});
});
// tslint:disable: max-file-line-count

View File

@@ -4,6 +4,7 @@ import { LogWithDecodedArgs, TransactionReceiptWithDecodedLogs } from 'ethereum-
import { AssetProxyOwnerContract, AssetProxyOwnerSubmissionEventArgs, TestAssetProxyOwnerContract } from '../../src';
// tslint:disable: no-unnecessary-type-assertion
export class AssetProxyOwnerWrapper {
private readonly _assetProxyOwner: AssetProxyOwnerContract | TestAssetProxyOwnerContract;
constructor(assetproxyOwnerContract: AssetProxyOwnerContract | TestAssetProxyOwnerContract) {