diff options
author | Fabio Berger <me@fabioberger.com> | 2018-01-25 23:42:58 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-01-25 23:42:58 +0800 |
commit | 71d68f975cd7bc089f0cbef4e5888a73eab4ee42 (patch) | |
tree | 9482602fc23d2baec3fff1fb97750ad45adc6eca /packages/contracts/util/order.ts | |
parent | ec3d8a034fe763d8255935985b1fb97aff6c177b (diff) | |
parent | f58f0ddb67555c3f0c7252ea3e003824984c48ad (diff) | |
download | dexon-0x-contracts-71d68f975cd7bc089f0cbef4e5888a73eab4ee42.tar.gz dexon-0x-contracts-71d68f975cd7bc089f0cbef4e5888a73eab4ee42.tar.zst dexon-0x-contracts-71d68f975cd7bc089f0cbef4e5888a73eab4ee42.zip |
Merge branch 'development' into feature/portal-ledger-support
* development: (437 commits)
Publish
Update yarn.lock
Update the CHANGELOG
Fix the bug making it impossible to specify the custom ZRX address
Fix fill/cancel order by looking for NoError instead of empty blockchainErr given the BlockchainErrs type refactor
Add a comment about a yarn bug
Add our mainnet and kovan nodes as backups for Portal requests
Fix bug hiding the user info from topBar
Add dev-utils package to top level README
Prettier newline
Prettier
Allow Token symbols to be alphanumeric
Update CHANGELOG, rebase on development
Should not -> cannot
Reject negative amounts in isValidBaseUnitAmount
Re-add changelog for 0x.js
Fix prettier
Update yarn.lock
Move tests to a separate folder
Change file layout
...
# Conflicts:
# packages/website/README.md
Diffstat (limited to 'packages/contracts/util/order.ts')
-rw-r--r-- | packages/contracts/util/order.ts | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/packages/contracts/util/order.ts b/packages/contracts/util/order.ts index ec5362b66..e202d485b 100644 --- a/packages/contracts/util/order.ts +++ b/packages/contracts/util/order.ts @@ -1,11 +1,10 @@ -import {promisify} from '@0xproject/utils'; -import {BigNumber} from 'bignumber.js'; +import { BigNumber, promisify } from '@0xproject/utils'; import ethUtil = require('ethereumjs-util'); import * as _ from 'lodash'; import Web3 = require('web3'); -import {crypto} from './crypto'; -import {OrderParams} from './types'; +import { crypto } from './crypto'; +import { OrderParams } from './types'; // In order to benefit from type-safety, we re-assign the global web3 instance injected by Truffle // with type `any` to a variable of type `Web3`. @@ -17,11 +16,11 @@ export class Order { this.params = params; } public isValidSignature() { - const {v, r, s} = this.params; + const { v, r, s } = this.params; if (_.isUndefined(v) || _.isUndefined(r) || _.isUndefined(s)) { throw new Error('Cannot call isValidSignature on unsigned order'); } - const orderHash = this.getOrderHash(); + const orderHash = this._getOrderHash(); const msgHash = ethUtil.hashPersonalMessage(ethUtil.toBuffer(orderHash)); try { const pubKey = ethUtil.ecrecover(msgHash, v, ethUtil.toBuffer(r), ethUtil.toBuffer(s)); @@ -32,9 +31,9 @@ export class Order { } } public async signAsync() { - const orderHash = this.getOrderHash(); + const orderHash = this._getOrderHash(); const signature = await promisify<string>(web3.eth.sign)(this.params.maker, orderHash); - const {v, r, s} = ethUtil.fromRpcSig(signature); + const { v, r, s } = ethUtil.fromRpcSig(signature); this.params = _.assign(this.params, { orderHashHex: orderHash, v, @@ -88,7 +87,7 @@ export class Order { }; return cancel; } - private getOrderHash(): string { + private _getOrderHash(): string { const orderHash = crypto.solSHA3([ this.params.exchangeContractAddress, this.params.maker, |