diff options
author | fragosti <francesco.agosti93@gmail.com> | 2019-01-25 04:05:44 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2019-01-25 04:05:44 +0800 |
commit | 5b06595a6b6d459d53840d066fb204c0a9e3ed02 (patch) | |
tree | a5e9ed5c805cd69bd2f78525ac5b02cb9cdebdbf /contracts/multisig/test/utils | |
parent | 44aafe4d78059267c9279fdf747fd51e6c3b26e1 (diff) | |
parent | 92cbff67d196abc7755e82087dbb1831485485d1 (diff) | |
download | dexon-0x-contracts-5b06595a6b6d459d53840d066fb204c0a9e3ed02.tar dexon-0x-contracts-5b06595a6b6d459d53840d066fb204c0a9e3ed02.tar.gz dexon-0x-contracts-5b06595a6b6d459d53840d066fb204c0a9e3ed02.tar.bz2 dexon-0x-contracts-5b06595a6b6d459d53840d066fb204c0a9e3ed02.tar.lz dexon-0x-contracts-5b06595a6b6d459d53840d066fb204c0a9e3ed02.tar.xz dexon-0x-contracts-5b06595a6b6d459d53840d066fb204c0a9e3ed02.tar.zst dexon-0x-contracts-5b06595a6b6d459d53840d066fb204c0a9e3ed02.zip |
Merge branch 'development' of https://github.com/0xProject/0x-monorepo into development
Diffstat (limited to 'contracts/multisig/test/utils')
-rw-r--r-- | contracts/multisig/test/utils/asset_proxy_owner_wrapper.ts | 71 | ||||
-rw-r--r-- | contracts/multisig/test/utils/index.ts | 2 |
2 files changed, 73 insertions, 0 deletions
diff --git a/contracts/multisig/test/utils/asset_proxy_owner_wrapper.ts b/contracts/multisig/test/utils/asset_proxy_owner_wrapper.ts new file mode 100644 index 000000000..b6040d8e3 --- /dev/null +++ b/contracts/multisig/test/utils/asset_proxy_owner_wrapper.ts @@ -0,0 +1,71 @@ +import { artifacts as proxyArtifacts } from '@0x/contracts-asset-proxy'; +import { artifacts as erc20Artifacts } from '@0x/contracts-erc20'; +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, ...erc20Artifacts, ...proxyArtifacts }); + } + 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; + } +} diff --git a/contracts/multisig/test/utils/index.ts b/contracts/multisig/test/utils/index.ts new file mode 100644 index 000000000..382fd92e5 --- /dev/null +++ b/contracts/multisig/test/utils/index.ts @@ -0,0 +1,2 @@ +export * from './asset_proxy_owner_wrapper'; +export * from './multi_sig_wrapper'; |