Update AssetProxyOwner tests

This commit is contained in:
Amir Bandeali 2019-09-13 12:45:57 -04:00
parent eb784a4a7c
commit f47feabb4a
9 changed files with 595 additions and 616 deletions

View File

@ -34,7 +34,7 @@
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
},
"config": {
"abis": "./generated-artifacts/@(AssetProxyOwner|MultiSigWallet|MultiSigWalletWithTimeLock|TestAssetProxyOwner|TestRejectEther).json",
"abis": "./generated-artifacts/@(AssetProxyOwner|ContractCallReceiver|MultiSigWallet|MultiSigWalletWithTimeLock|TestAssetProxyOwner|TestRejectEther).json",
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
},
"repository": {
@ -72,7 +72,7 @@
"@0x/base-contract": "^5.3.1",
"@0x/contracts-asset-proxy": "^2.2.5",
"@0x/contracts-erc20": "^2.2.11",
"@0x/contracts-utils": "2.0.1",
"@0x/contracts-utils": "^3.2.1",
"@0x/types": "^2.4.1",
"@0x/typescript-typings": "^4.2.4",
"@0x/utils": "^4.5.0",

View File

@ -6,6 +6,7 @@
import { ContractArtifact } from 'ethereum-types';
import * as AssetProxyOwner from '../generated-artifacts/AssetProxyOwner.json';
import * as ContractCallReceiver from '../generated-artifacts/ContractCallReceiver.json';
import * as MultiSigWallet from '../generated-artifacts/MultiSigWallet.json';
import * as MultiSigWalletWithTimeLock from '../generated-artifacts/MultiSigWalletWithTimeLock.json';
import * as TestAssetProxyOwner from '../generated-artifacts/TestAssetProxyOwner.json';
@ -14,6 +15,7 @@ export const artifacts = {
AssetProxyOwner: AssetProxyOwner as ContractArtifact,
MultiSigWallet: MultiSigWallet as ContractArtifact,
MultiSigWalletWithTimeLock: MultiSigWalletWithTimeLock as ContractArtifact,
ContractCallReceiver: ContractCallReceiver as ContractArtifact,
TestAssetProxyOwner: TestAssetProxyOwner as ContractArtifact,
TestRejectEther: TestRejectEther as ContractArtifact,
};

View File

@ -4,6 +4,7 @@
* -----------------------------------------------------------------------------
*/
export * from '../generated-wrappers/asset_proxy_owner';
export * from '../generated-wrappers/contract_call_receiver';
export * from '../generated-wrappers/multi_sig_wallet';
export * from '../generated-wrappers/multi_sig_wallet_with_time_lock';
export * from '../generated-wrappers/test_asset_proxy_owner';

File diff suppressed because it is too large Load Diff

View File

@ -1,72 +1,48 @@
import { artifacts as proxyArtifacts } from '@0x/contracts-asset-proxy';
import { LogDecoder, Web3ProviderEngine } from '@0x/contracts-test-utils';
import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import { constants, hexRandom, increaseTimeAndMineBlockAsync } from '@0x/contracts-test-utils';
import { AbiEncoder, BigNumber } from '@0x/utils';
import { LogWithDecodedArgs, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import { AssetProxyOwnerContract, TestAssetProxyOwnerContract } from '../../src';
import { artifacts } from '../../src/artifacts';
import { AssetProxyOwnerContract, AssetProxyOwnerSubmissionEventArgs, TestAssetProxyOwnerContract } from '../../src';
export class AssetProxyOwnerWrapper {
private readonly _assetProxyOwner: AssetProxyOwnerContract | TestAssetProxyOwnerContract;
private readonly _web3Wrapper: Web3Wrapper;
private readonly _logDecoder: LogDecoder;
constructor(
assetproxyOwnerContract: AssetProxyOwnerContract | TestAssetProxyOwnerContract,
provider: Web3ProviderEngine,
) {
constructor(assetproxyOwnerContract: AssetProxyOwnerContract | TestAssetProxyOwnerContract) {
this._assetProxyOwner = assetproxyOwnerContract;
this._web3Wrapper = new Web3Wrapper(provider);
this._logDecoder = new LogDecoder(this._web3Wrapper, { ...artifacts, ...proxyArtifacts });
}
public async submitTransactionAsync(
destination: string,
data: string,
data: string[],
destinations: string[],
from: string,
opts: { value?: BigNumber } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
const value = opts.value === undefined ? new BigNumber(0) : opts.value;
const txHash = await this._assetProxyOwner.submitTransaction.sendTransactionAsync(destination, value, data, {
from,
});
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async confirmTransactionAsync(txId: BigNumber, from: string): Promise<TransactionReceiptWithDecodedLogs> {
const txHash = await this._assetProxyOwner.confirmTransaction.sendTransactionAsync(txId, { from });
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async revokeConfirmationAsync(txId: BigNumber, from: string): Promise<TransactionReceiptWithDecodedLogs> {
const txHash = await this._assetProxyOwner.revokeConfirmation.sendTransactionAsync(txId, { from });
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async executeTransactionAsync(
txId: BigNumber,
from: string,
opts: { gas?: number } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
const txHash = await this._assetProxyOwner.executeTransaction.sendTransactionAsync(txId, {
from,
gas: opts.gas,
});
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async executeRemoveAuthorizedAddressAtIndexAsync(
txId: BigNumber,
from: string,
): Promise<TransactionReceiptWithDecodedLogs> {
// tslint:disable-next-line:no-unnecessary-type-assertion
const txHash = await (this
._assetProxyOwner as TestAssetProxyOwnerContract).executeRemoveAuthorizedAddressAtIndex.sendTransactionAsync(
txId,
{
from,
},
opts: { values?: BigNumber[] } = {},
): Promise<{ txReceipt: TransactionReceiptWithDecodedLogs; txId: BigNumber }> {
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._assetProxyOwner.submitTransaction.awaitTransactionSuccessAsync(
hexRandom(20), // submitTransaction will fail if this is a null address
constants.ZERO_AMOUNT,
batchTransactionData,
{ from },
);
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
const txId = (txReceipt.logs[0] as LogWithDecodedArgs<AssetProxyOwnerSubmissionEventArgs>).args.transactionId;
return { txReceipt, txId };
}
public async submitConfirmAndExecuteTransactionAsync(
data: string[],
destinations: string[],
signerAddresses: string[],
increaseTimeSeconds: number,
opts: { values?: BigNumber[]; executeFromAddress?: string } = {},
): Promise<{ executionTxReceipt: TransactionReceiptWithDecodedLogs; txId: BigNumber }> {
const submitResults = await this.submitTransactionAsync(data, destinations, signerAddresses[0], opts);
await this._assetProxyOwner.confirmTransaction.awaitTransactionSuccessAsync(submitResults.txId, {
from: signerAddresses[1],
});
await increaseTimeAndMineBlockAsync(increaseTimeSeconds);
const executionTxReceipt = await this._assetProxyOwner.executeTransaction.awaitTransactionSuccessAsync(
submitResults.txId,
{ from: opts.executeFromAddress === undefined ? signerAddresses[0] : opts.executeFromAddress },
);
return { executionTxReceipt, txId: submitResults.txId };
}
}

View File

@ -1,2 +1,2 @@
export * from './asset_proxy_owner_wrapper';
export * from './multi_sig_wrapper';
export * from './asset_proxy_owner_wrapper';

View File

@ -4,6 +4,7 @@
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
"files": [
"generated-artifacts/AssetProxyOwner.json",
"generated-artifacts/ContractCallReceiver.json",
"generated-artifacts/MultiSigWallet.json",
"generated-artifacts/MultiSigWalletWithTimeLock.json",
"generated-artifacts/TestAssetProxyOwner.json",

View File

@ -53,8 +53,8 @@ export const constants = {
NUM_DUMMY_ERC1155_CONTRACTS_TO_DEPLOY: 2,
NUM_ERC1155_FUNGIBLE_TOKENS_MINT: 4,
NUM_ERC1155_NONFUNGIBLE_TOKENS_MINT: 4,
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
NULL_BYTES4: '0x00000000',
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
NULL_BYTES32: '0x0000000000000000000000000000000000000000000000000000000000000000',
UNLIMITED_ALLOWANCE_IN_BASE_UNITS: MAX_UINT256,
MAX_UINT256,

View File

@ -643,12 +643,6 @@
npmlog "^4.1.2"
write-file-atomic "^2.3.0"
"@0x/abi-gen-wrappers@^3.0.1":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@0x/abi-gen-wrappers/-/abi-gen-wrappers-3.0.3.tgz#a30fdb3c520ce45fb327590281d000e086ff9609"
dependencies:
"@0x/base-contract" "^4.0.3"
"@0x/asset-buyer@6.1.8":
version "6.1.8"
resolved "https://registry.yarnpkg.com/@0x/asset-buyer/-/asset-buyer-6.1.8.tgz#71f6abb366e89e62457c256644edb37e12113e94"
@ -666,27 +660,6 @@
ethereum-types "^2.1.3"
lodash "^4.17.11"
"@0x/base-contract@^4.0.1", "@0x/base-contract@^4.0.3":
version "4.0.3"
resolved "https://registry.yarnpkg.com/@0x/base-contract/-/base-contract-4.0.3.tgz#ea5e3640824ee096813350e55546d98455a57805"
dependencies:
"@0x/typescript-typings" "^4.0.0"
"@0x/utils" "^4.1.0"
"@0x/web3-wrapper" "^5.0.0"
ethereum-types "^2.0.0"
ethers "~4.0.4"
lodash "^4.17.11"
"@0x/contract-addresses@^2.2.1":
version "2.3.3"
resolved "https://registry.yarnpkg.com/@0x/contract-addresses/-/contract-addresses-2.3.3.tgz#8cf009e7668c2fccca416177c85f3f6612c724c6"
dependencies:
lodash "^4.17.11"
"@0x/contract-artifacts@^1.3.0":
version "1.5.1"
resolved "https://registry.npmjs.org/@0x/contract-artifacts/-/contract-artifacts-1.5.1.tgz#6fba56a1d3e2d5d897a75fcfa432e49e2ebb17a7"
"@0x/contract-wrappers@^9.1.6", "@0x/contract-wrappers@^9.1.7":
version "9.1.8"
resolved "https://registry.yarnpkg.com/@0x/contract-wrappers/-/contract-wrappers-9.1.8.tgz#5923d35af3e4b442a57d02f74e02620b2d5b1356"
@ -711,21 +684,6 @@
lodash "^4.17.11"
uuid "^3.3.2"
"@0x/contracts-utils@2.0.1":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@0x/contracts-utils/-/contracts-utils-2.0.1.tgz#32e298ab5e6edb045c37294063ff928b629db0a4"
dependencies:
"@0x/base-contract" "^4.0.1"
"@0x/order-utils" "^5.0.0"
"@0x/types" "^2.0.1"
"@0x/typescript-typings" "^4.0.0"
"@0x/utils" "^4.0.2"
"@0x/web3-wrapper" "^4.0.1"
bn.js "^4.11.8"
ethereum-types "^2.0.0"
ethereumjs-util "^5.1.1"
lodash "^4.17.5"
"@0x/coordinator-server@^0.1.3":
version "0.1.3"
resolved "https://registry.yarnpkg.com/@0x/coordinator-server/-/coordinator-server-0.1.3.tgz#5fbb7c11bb641aa5386797769cab9a68a7d15b79"
@ -755,28 +713,6 @@
typeorm "0.2.7"
websocket "^1.0.25"
"@0x/order-utils@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@0x/order-utils/-/order-utils-5.0.0.tgz#7f43e0310ace31738895881501c8dda9c3a3aefa"
dependencies:
"@0x/abi-gen-wrappers" "^3.0.1"
"@0x/assert" "^2.0.1"
"@0x/base-contract" "^4.0.1"
"@0x/contract-addresses" "^2.2.1"
"@0x/contract-artifacts" "^1.3.0"
"@0x/json-schemas" "^3.0.1"
"@0x/types" "^2.0.1"
"@0x/typescript-typings" "^4.0.0"
"@0x/utils" "^4.0.2"
"@0x/web3-wrapper" "^4.0.1"
"@types/node" "*"
bn.js "^4.11.8"
ethereum-types "^2.0.0"
ethereumjs-abi "0.6.5"
ethereumjs-util "^5.1.1"
ethers "~4.0.4"
lodash "^4.17.11"
"@0x/subproviders@^4.1.1":
version "4.1.2"
resolved "https://registry.yarnpkg.com/@0x/subproviders/-/subproviders-4.1.2.tgz#ab7bb0f482b11ccb4615fb5dd8ca85199cd0ae23"
@ -806,32 +742,6 @@
optionalDependencies:
"@ledgerhq/hw-transport-node-hid" "^4.3.0"
"@0x/web3-wrapper@^4.0.1":
version "4.0.2"
resolved "https://registry.yarnpkg.com/@0x/web3-wrapper/-/web3-wrapper-4.0.2.tgz#d4e0a4fa1217155e1aed4cd91086654fd99f2959"
dependencies:
"@0x/assert" "^2.0.2"
"@0x/json-schemas" "^3.0.2"
"@0x/typescript-typings" "^4.0.0"
"@0x/utils" "^4.0.3"
ethereum-types "^2.0.0"
ethereumjs-util "^5.1.1"
ethers "~4.0.4"
lodash "^4.17.11"
"@0x/web3-wrapper@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@0x/web3-wrapper/-/web3-wrapper-5.0.0.tgz#a9b4baf0dca125181885b31c4dd5a3fbf6b87260"
dependencies:
"@0x/assert" "^2.0.3"
"@0x/json-schemas" "^3.0.3"
"@0x/typescript-typings" "^4.0.0"
"@0x/utils" "^4.1.0"
ethereum-types "^2.0.0"
ethereumjs-util "^5.1.1"
ethers "~4.0.4"
lodash "^4.17.11"
"@0xproject/npm-cli-login@^0.0.11":
version "0.0.11"
resolved "https://registry.yarnpkg.com/@0xproject/npm-cli-login/-/npm-cli-login-0.0.11.tgz#3f1ec06112ce62aad300ff0575358f68aeecde2e"