diff options
author | Fabio Berger <me@fabioberger.com> | 2018-07-02 17:12:01 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-07-02 17:12:01 +0800 |
commit | de9f0732a09893f035ce8a7e8e01fa1141882a3a (patch) | |
tree | 63d1f0bbc6f9d65576e5d12b379378700eb88567 /packages/contracts/test/utils/multi_sig_wrapper.ts | |
parent | 20acdbf6c3ba6a62e87a9a496021cb6482c0c03a (diff) | |
parent | b9b00e10d39c3c84bc72892ef37f1313e904414d (diff) | |
download | dexon-sol-tools-de9f0732a09893f035ce8a7e8e01fa1141882a3a.tar.gz dexon-sol-tools-de9f0732a09893f035ce8a7e8e01fa1141882a3a.tar.zst dexon-sol-tools-de9f0732a09893f035ce8a7e8e01fa1141882a3a.zip |
Merge branch 'v2-prototype' into fix/five_decimal_scenario
* v2-prototype: (75 commits)
Update relayer grid tiles to use Text
Fix build
Update file structure
Update 2.0.0 artifacts
Move ledgerhq module declarations to typescript-typings
Export LedgerEthereumClient type in subproviders
Update artifacts
Add logging and updated artifacts
Fix migrations
Run prettier
Add Kovan artifacts
Use ledger subprovider
Add Kovan migrations
Remove state variable from Link component in Portal
Make registerAssetProxy append only
Update staging api link
Change getTransactionReceipt to awaitTransactionMined
Move /docs route to the end
Remove extra call to scrollIntoView for wallet in onboarding
Update expectRevertReasonOrAlwaysFailingTransactionAsync to check status codes
...
Diffstat (limited to 'packages/contracts/test/utils/multi_sig_wrapper.ts')
-rw-r--r-- | packages/contracts/test/utils/multi_sig_wrapper.ts | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/packages/contracts/test/utils/multi_sig_wrapper.ts b/packages/contracts/test/utils/multi_sig_wrapper.ts new file mode 100644 index 000000000..6e7746dfc --- /dev/null +++ b/packages/contracts/test/utils/multi_sig_wrapper.ts @@ -0,0 +1,55 @@ +import { BigNumber } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; +import * as _ from 'lodash'; + +import { AssetProxyOwnerContract } from '../../generated_contract_wrappers/asset_proxy_owner'; +import { MultiSigWalletContract } from '../../generated_contract_wrappers/multi_sig_wallet'; + +import { LogDecoder } from './log_decoder'; + +export class MultiSigWrapper { + private _multiSig: MultiSigWalletContract; + private _web3Wrapper: Web3Wrapper; + private _logDecoder: LogDecoder; + constructor(multiSigContract: MultiSigWalletContract, provider: Provider) { + this._multiSig = multiSigContract; + this._web3Wrapper = new Web3Wrapper(provider); + this._logDecoder = new LogDecoder(this._web3Wrapper, this._multiSig.address); + } + 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._multiSig.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._multiSig.confirmTransaction.sendTransactionAsync(txId, { from }); + const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash); + return tx; + } + public async executeTransactionAsync(txId: BigNumber, from: string): Promise<TransactionReceiptWithDecodedLogs> { + const txHash = await this._multiSig.executeTransaction.sendTransactionAsync(txId, { from }); + 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 + ._multiSig as AssetProxyOwnerContract).executeRemoveAuthorizedAddressAtIndex.sendTransactionAsync(txId, { + from, + }); + const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash); + return tx; + } +} |