aboutsummaryrefslogtreecommitdiffstats
path: root/contracts/multisig/test/utils/multi_sig_wrapper.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-11-23 21:03:48 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-12-03 19:09:28 +0800
commit0faa8b3231ddfc15723a4bdda0b6ed7aeb742bd4 (patch)
tree1d1f4ec74287ff12e305a18fee459772345c2ff1 /contracts/multisig/test/utils/multi_sig_wrapper.ts
parent450c72035f13b02cb3cbd24f68a9fcb743aceb26 (diff)
downloaddexon-0x-contracts-0faa8b3231ddfc15723a4bdda0b6ed7aeb742bd4.tar
dexon-0x-contracts-0faa8b3231ddfc15723a4bdda0b6ed7aeb742bd4.tar.gz
dexon-0x-contracts-0faa8b3231ddfc15723a4bdda0b6ed7aeb742bd4.tar.bz2
dexon-0x-contracts-0faa8b3231ddfc15723a4bdda0b6ed7aeb742bd4.tar.lz
dexon-0x-contracts-0faa8b3231ddfc15723a4bdda0b6ed7aeb742bd4.tar.xz
dexon-0x-contracts-0faa8b3231ddfc15723a4bdda0b6ed7aeb742bd4.tar.zst
dexon-0x-contracts-0faa8b3231ddfc15723a4bdda0b6ed7aeb742bd4.zip
Refactor contracts-core into contracts-multisig, contracts-core and contracts-test-utils
Diffstat (limited to 'contracts/multisig/test/utils/multi_sig_wrapper.ts')
-rw-r--r--contracts/multisig/test/utils/multi_sig_wrapper.ts54
1 files changed, 54 insertions, 0 deletions
diff --git a/contracts/multisig/test/utils/multi_sig_wrapper.ts b/contracts/multisig/test/utils/multi_sig_wrapper.ts
new file mode 100644
index 000000000..086143613
--- /dev/null
+++ b/contracts/multisig/test/utils/multi_sig_wrapper.ts
@@ -0,0 +1,54 @@
+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 { MultiSigWalletContract } from '../../generated-wrappers/multi_sig_wallet';
+import { artifacts } from '../../src/artifacts';
+
+export class MultiSigWrapper {
+ private readonly _multiSig: MultiSigWalletContract;
+ private readonly _web3Wrapper: Web3Wrapper;
+ private readonly _logDecoder: LogDecoder;
+ constructor(multiSigContract: MultiSigWalletContract, provider: Provider) {
+ this._multiSig = multiSigContract;
+ 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._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 revokeConfirmationAsync(txId: BigNumber, from: string): Promise<TransactionReceiptWithDecodedLogs> {
+ const txHash = await this._multiSig.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._multiSig.executeTransaction.sendTransactionAsync(txId, {
+ from,
+ gas: opts.gas,
+ });
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
+ return tx;
+ }
+}