From bc8fc534332b5ea82f881bdd3a75773384714f4d Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 25 May 2017 19:47:11 +0200 Subject: Add initial exchange contract function, set up web3Wrapper, added types and utils --- src/ts/0x.js.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/ts/0x.js.ts') diff --git a/src/ts/0x.js.ts b/src/ts/0x.js.ts index ead1f56df..7025f8804 100644 --- a/src/ts/0x.js.ts +++ b/src/ts/0x.js.ts @@ -1,21 +1,21 @@ import * as BigNumber from 'bignumber.js'; import * as ethUtil from 'ethereumjs-util'; import * as _ from 'lodash'; +import Web3 from 'web3'; import {assert} from './utils/assert'; +import {utils} from './utils/utils'; +import {ZeroExError} from './types'; +import {Web3Wrapper} from './web3_wrapper'; +import {ExchangeWrapper} from './contract_wrappers/exchange_wrapper'; +import contract = require('truffle-contract'); import {ECSignatureSchema} from './schemas/ec_signature_schema'; - -/** - * Elliptic Curve signature - */ -export interface ECSignature { - v: number; - r: string; - s: string; -} +import {ECSignature} from './types'; const MAX_DIGITS_IN_UNSIGNED_256_INT = 78; export class ZeroEx { + public web3Wrapper: Web3Wrapper; + public exchange: ContractInstance; /** * Verifies that the elliptic curve signature `signature` was generated * by signing `data` with the private key corresponding to the `signerAddressHex` address. @@ -83,4 +83,8 @@ export class ZeroEx { const baseUnitAmount = amount.times(unit); return baseUnitAmount; } + constructor(web3: Web3) { + this.web3Wrapper = new Web3Wrapper(web3); + this.exchange = new ExchangeWrapper(this.web3Wrapper); + } } -- cgit v1.2.3 From b9892c0d49076e4a32fdf33d5dc94e1d22cd2725 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 25 May 2017 20:11:48 +0200 Subject: Remove unused imports --- src/ts/0x.js.ts | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/ts/0x.js.ts') diff --git a/src/ts/0x.js.ts b/src/ts/0x.js.ts index 7025f8804..6d682fc4c 100644 --- a/src/ts/0x.js.ts +++ b/src/ts/0x.js.ts @@ -1,10 +1,7 @@ import * as BigNumber from 'bignumber.js'; import * as ethUtil from 'ethereumjs-util'; -import * as _ from 'lodash'; import Web3 from 'web3'; import {assert} from './utils/assert'; -import {utils} from './utils/utils'; -import {ZeroExError} from './types'; import {Web3Wrapper} from './web3_wrapper'; import {ExchangeWrapper} from './contract_wrappers/exchange_wrapper'; import contract = require('truffle-contract'); -- cgit v1.2.3 From 8e35923d6e2c6ed5347a34e7147067906f8c2fe5 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 25 May 2017 20:12:13 +0200 Subject: Fix exchange type --- src/ts/0x.js.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ts/0x.js.ts') diff --git a/src/ts/0x.js.ts b/src/ts/0x.js.ts index 6d682fc4c..7ea32b87a 100644 --- a/src/ts/0x.js.ts +++ b/src/ts/0x.js.ts @@ -12,7 +12,7 @@ const MAX_DIGITS_IN_UNSIGNED_256_INT = 78; export class ZeroEx { public web3Wrapper: Web3Wrapper; - public exchange: ContractInstance; + public exchange: ExchangeWrapper; /** * Verifies that the elliptic curve signature `signature` was generated * by signing `data` with the private key corresponding to the `signerAddressHex` address. -- cgit v1.2.3 From 8c61af28db02129fb1d79930b32cea0ab8b55954 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 26 May 2017 12:57:37 +0200 Subject: Fix web3 imports --- src/ts/0x.js.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ts/0x.js.ts') diff --git a/src/ts/0x.js.ts b/src/ts/0x.js.ts index 7ea32b87a..78abff681 100644 --- a/src/ts/0x.js.ts +++ b/src/ts/0x.js.ts @@ -1,6 +1,6 @@ import * as BigNumber from 'bignumber.js'; import * as ethUtil from 'ethereumjs-util'; -import Web3 from 'web3'; +import Web3 = require('web3'); import {assert} from './utils/assert'; import {Web3Wrapper} from './web3_wrapper'; import {ExchangeWrapper} from './contract_wrappers/exchange_wrapper'; -- cgit v1.2.3 From e1e50bba3d08a96d4cb5a9314c255e5d5c19d51a Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 26 May 2017 13:24:05 +0200 Subject: Fix web3 imports again --- src/ts/0x.js.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ts/0x.js.ts') diff --git a/src/ts/0x.js.ts b/src/ts/0x.js.ts index 78abff681..cc3c43e79 100644 --- a/src/ts/0x.js.ts +++ b/src/ts/0x.js.ts @@ -1,6 +1,6 @@ import * as BigNumber from 'bignumber.js'; import * as ethUtil from 'ethereumjs-util'; -import Web3 = require('web3'); +import * as Web3 from 'web3'; import {assert} from './utils/assert'; import {Web3Wrapper} from './web3_wrapper'; import {ExchangeWrapper} from './contract_wrappers/exchange_wrapper'; -- cgit v1.2.3 From e545ade857501fae7ccc9ad27da6ab3803a5ffd8 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 26 May 2017 17:09:34 +0200 Subject: Spacing and import re-order --- src/ts/0x.js.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/ts/0x.js.ts') diff --git a/src/ts/0x.js.ts b/src/ts/0x.js.ts index 7c6557b5b..8496a0989 100644 --- a/src/ts/0x.js.ts +++ b/src/ts/0x.js.ts @@ -1,14 +1,14 @@ 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 {Web3Wrapper} from './web3_wrapper'; import * as ethABI from 'ethereumjs-abi'; import * as _ from 'lodash'; import {constants} from './utils/constants'; import {assert} from './utils/assert'; -import {Web3Wrapper} from './web3_wrapper'; import {ExchangeWrapper} from './contract_wrappers/exchange_wrapper'; -import contract = require('truffle-contract'); import {ECSignatureSchema} from './schemas/ec_signature_schema'; import {SolidityTypes, ECSignature} from './types'; @@ -71,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)); -- cgit v1.2.3 From 57b820c7467102b299e602aaa94e043ee0bd4690 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 26 May 2017 17:40:23 +0200 Subject: import re-order --- src/ts/0x.js.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ts/0x.js.ts') diff --git a/src/ts/0x.js.ts b/src/ts/0x.js.ts index 8496a0989..bd4978c96 100644 --- a/src/ts/0x.js.ts +++ b/src/ts/0x.js.ts @@ -1,11 +1,11 @@ +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 {Web3Wrapper} from './web3_wrapper'; 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'; -- cgit v1.2.3