aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/util/order.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-02-07 20:41:30 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-02-07 20:41:30 +0800
commit568e4d33f29db2f5c0195585438e18ab4b2aea18 (patch)
tree4f2372dc040f4354d51cfb2229391cfd7c033264 /packages/contracts/util/order.ts
parentfd004032cb23998184a78ac4a0a486ef1bd04c25 (diff)
downloaddexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar
dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar.gz
dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar.bz2
dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar.lz
dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar.xz
dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar.zst
dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.zip
Use Order and SignedOrder type from 0x.js
Diffstat (limited to 'packages/contracts/util/order.ts')
-rw-r--r--packages/contracts/util/order.ts47
1 files changed, 0 insertions, 47 deletions
diff --git a/packages/contracts/util/order.ts b/packages/contracts/util/order.ts
deleted file mode 100644
index 6d412e2af..000000000
--- a/packages/contracts/util/order.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import { BigNumber } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
-import ethUtil = require('ethereumjs-util');
-import * as _ from 'lodash';
-
-import { crypto } from './crypto';
-import { SignedOrder } from './signed_order';
-import { OrderParams } from './types';
-
-export class Order {
- public params: OrderParams;
- private _web3Wrapper: Web3Wrapper;
- constructor(web3Wrapper: Web3Wrapper, params: OrderParams) {
- this.params = params;
- this._web3Wrapper = web3Wrapper;
- }
- public async signAsync(): Promise<SignedOrder> {
- const orderHash = this.getOrderHashHex();
- const signature = await this._web3Wrapper.signTransactionAsync(this.params.maker, orderHash);
- const { v, r, s } = ethUtil.fromRpcSig(signature);
- const signedOrderParams = _.assign(this.params, {
- v,
- r: ethUtil.bufferToHex(r),
- s: ethUtil.bufferToHex(s),
- });
- const signedOrder = new SignedOrder(this._web3Wrapper, signedOrderParams);
- return signedOrder;
- }
- public getOrderHashHex(): string {
- const orderHash = crypto.solSHA3([
- this.params.exchangeContractAddress,
- this.params.maker,
- this.params.taker,
- this.params.makerToken,
- this.params.takerToken,
- this.params.feeRecipient,
- this.params.makerTokenAmount,
- this.params.takerTokenAmount,
- this.params.makerFee,
- this.params.takerFee,
- this.params.expirationTimestampInSec,
- this.params.salt,
- ]);
- const orderHashHex = ethUtil.bufferToHex(orderHash);
- return orderHashHex;
- }
-}