aboutsummaryrefslogtreecommitdiffstats
path: root/src/ts/0x.js.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-05-27 00:54:56 +0800
committerGitHub <noreply@github.com>2017-05-27 00:54:56 +0800
commitb897bdab79fe566ffc8c19c6ec9f1bb7260fa95e (patch)
tree65abedae4adfa1694db877a8e041e57c29a547f9 /src/ts/0x.js.ts
parentf338c68f126cba0f1b49c2928f276158b64d8ee7 (diff)
parent5d4c2dcb2950747c7cb2d95df340c23c981d70d3 (diff)
downloaddexon-sol-tools-b897bdab79fe566ffc8c19c6ec9f1bb7260fa95e.tar
dexon-sol-tools-b897bdab79fe566ffc8c19c6ec9f1bb7260fa95e.tar.gz
dexon-sol-tools-b897bdab79fe566ffc8c19c6ec9f1bb7260fa95e.tar.bz2
dexon-sol-tools-b897bdab79fe566ffc8c19c6ec9f1bb7260fa95e.tar.lz
dexon-sol-tools-b897bdab79fe566ffc8c19c6ec9f1bb7260fa95e.tar.xz
dexon-sol-tools-b897bdab79fe566ffc8c19c6ec9f1bb7260fa95e.tar.zst
dexon-sol-tools-b897bdab79fe566ffc8c19c6ec9f1bb7260fa95e.zip
Merge pull request #14 from 0xProject/implementFirstExchangeMethod
Implement first exchange method
Diffstat (limited to 'src/ts/0x.js.ts')
-rw-r--r--src/ts/0x.js.ts27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/ts/0x.js.ts b/src/ts/0x.js.ts
index ba922d3db..bd4978c96 100644
--- a/src/ts/0x.js.ts
+++ b/src/ts/0x.js.ts
@@ -1,25 +1,22 @@
+import * as _ from 'lodash';
import * as BigNumber from 'bignumber.js';
import * as BN from 'bn.js';
import * as ethUtil from 'ethereumjs-util';
+import contract = require('truffle-contract');
+import * as Web3 from 'web3';
import * as ethABI from 'ethereumjs-abi';
-import * as _ from 'lodash';
+import {Web3Wrapper} from './web3_wrapper';
import {constants} from './utils/constants';
import {assert} from './utils/assert';
+import {ExchangeWrapper} from './contract_wrappers/exchange_wrapper';
import {ECSignatureSchema} from './schemas/ec_signature_schema';
-import {SolidityTypes} from './types';
-
-/**
- * Elliptic Curve signature
- */
-export interface ECSignature {
- v: number;
- r: string;
- s: string;
-}
+import {SolidityTypes, ECSignature} from './types';
const MAX_DIGITS_IN_UNSIGNED_256_INT = 78;
export class ZeroEx {
+ public web3Wrapper: Web3Wrapper;
+ public exchange: ExchangeWrapper;
/**
* Computes the orderHash given the order parameters and returns it as a hex encoded string.
*/
@@ -74,7 +71,8 @@ export class ZeroEx {
const dataBuff = ethUtil.toBuffer(dataHex);
const msgHashBuff = ethUtil.hashPersonalMessage(dataBuff);
try {
- const pubKey = ethUtil.ecrecover(msgHashBuff,
+ const pubKey = ethUtil.ecrecover(
+ msgHashBuff,
signature.v,
ethUtil.toBuffer(signature.r),
ethUtil.toBuffer(signature.s));
@@ -129,7 +127,6 @@ export class ZeroEx {
const baseUnitAmount = amount.times(unit);
return baseUnitAmount;
}
-
/**
* Converts BigNumber instance to BN
* The only we convert to BN is to remain compatible with `ethABI. soliditySHA3 ` that
@@ -139,4 +136,8 @@ export class ZeroEx {
private static bigNumberToBN(value: BigNumber.BigNumber) {
return new BN(value.toString(), 10);
}
+ constructor(web3: Web3) {
+ this.web3Wrapper = new Web3Wrapper(web3);
+ this.exchange = new ExchangeWrapper(this.web3Wrapper);
+ }
}