aboutsummaryrefslogtreecommitdiffstats
path: root/contracts/core/test/utils/asset_proxy_owner_wrapper.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-11-23 23:16:15 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-12-03 19:09:28 +0800
commit91c89d90a5266354b14fe81517424396b0ca18b0 (patch)
tree458a1cbecdfed78f7276df0450e7a3cfbd38f2cb /contracts/core/test/utils/asset_proxy_owner_wrapper.ts
parent980e3cb82f73036f124313d641f63b2b50e98251 (diff)
downloaddexon-sol-tools-91c89d90a5266354b14fe81517424396b0ca18b0.tar
dexon-sol-tools-91c89d90a5266354b14fe81517424396b0ca18b0.tar.gz
dexon-sol-tools-91c89d90a5266354b14fe81517424396b0ca18b0.tar.bz2
dexon-sol-tools-91c89d90a5266354b14fe81517424396b0ca18b0.tar.lz
dexon-sol-tools-91c89d90a5266354b14fe81517424396b0ca18b0.tar.xz
dexon-sol-tools-91c89d90a5266354b14fe81517424396b0ca18b0.tar.zst
dexon-sol-tools-91c89d90a5266354b14fe81517424396b0ca18b0.zip
Use assetProxyOwner instead of the multisig in the core contracts tests
Diffstat (limited to 'contracts/core/test/utils/asset_proxy_owner_wrapper.ts')
-rw-r--r--contracts/core/test/utils/asset_proxy_owner_wrapper.ts69
1 files changed, 69 insertions, 0 deletions
diff --git a/contracts/core/test/utils/asset_proxy_owner_wrapper.ts b/contracts/core/test/utils/asset_proxy_owner_wrapper.ts
new file mode 100644
index 000000000..d5aaaf519
--- /dev/null
+++ b/contracts/core/test/utils/asset_proxy_owner_wrapper.ts
@@ -0,0 +1,69 @@
+import { LogDecoder } from '@0x/contracts-test-utils';
+import { BigNumber } from '@0x/utils';
+import { Web3Wrapper } from '@0x/web3-wrapper';
+import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
+import * as _ from 'lodash';
+
+import { AssetProxyOwnerContract } from '../../generated-wrappers/asset_proxy_owner';
+import { artifacts } from '../../src/artifacts';
+
+export class AssetProxyOwnerWrapper {
+ private readonly _assetProxyOwner: AssetProxyOwnerContract;
+ private readonly _web3Wrapper: Web3Wrapper;
+ private readonly _logDecoder: LogDecoder;
+ constructor(assetproxyOwnerContract: AssetProxyOwnerContract, provider: Provider) {
+ this._assetProxyOwner = assetproxyOwnerContract;
+ this._web3Wrapper = new Web3Wrapper(provider);
+ this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts);
+ }
+ public async submitTransactionAsync(
+ destination: string,
+ data: string,
+ from: string,
+ opts: { value?: BigNumber } = {},
+ ): Promise<TransactionReceiptWithDecodedLogs> {
+ const value = _.isUndefined(opts.value) ? 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 AssetProxyOwnerContract).executeRemoveAuthorizedAddressAtIndex.sendTransactionAsync(
+ txId,
+ {
+ from,
+ },
+ );
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
+ return tx;
+ }
+}