diff options
author | Jacob Evans <dekz@dekz.net> | 2018-08-14 07:36:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-14 07:36:11 +0800 |
commit | e51deb93eef2e59a3577195becfb6d602df3892a (patch) | |
tree | a74ca989588877d3552f28144d40b015f1f5b67e /packages/order-utils/src/order_factory.ts | |
parent | 0025c6640b3a5840bacfb4ab5f6e937fc9af8eff (diff) | |
parent | a3517574936aa6a4911003dbff06302926b04cb4 (diff) | |
download | dexon-sol-tools-e51deb93eef2e59a3577195becfb6d602df3892a.tar dexon-sol-tools-e51deb93eef2e59a3577195becfb6d602df3892a.tar.gz dexon-sol-tools-e51deb93eef2e59a3577195becfb6d602df3892a.tar.bz2 dexon-sol-tools-e51deb93eef2e59a3577195becfb6d602df3892a.tar.lz dexon-sol-tools-e51deb93eef2e59a3577195becfb6d602df3892a.tar.xz dexon-sol-tools-e51deb93eef2e59a3577195becfb6d602df3892a.tar.zst dexon-sol-tools-e51deb93eef2e59a3577195becfb6d602df3892a.zip |
Merge pull request #914 from 0xProject/feature/0x.js/ec-signature-string
0x.js Return signature as a hex encoded string
Diffstat (limited to 'packages/order-utils/src/order_factory.ts')
-rw-r--r-- | packages/order-utils/src/order_factory.ts | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/packages/order-utils/src/order_factory.ts b/packages/order-utils/src/order_factory.ts index 14727fd97..4a6f3924b 100644 --- a/packages/order-utils/src/order_factory.ts +++ b/packages/order-utils/src/order_factory.ts @@ -1,14 +1,13 @@ -import { ECSignature, Order, SignedOrder } from '@0xproject/types'; +import { Order, SignedOrder, SignerType } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Provider } from 'ethereum-types'; -import * as ethUtil from 'ethereumjs-util'; import * as _ from 'lodash'; import { constants } from './constants'; import { orderHashUtils } from './order_hash'; import { generatePseudoRandomSalt } from './salt'; import { ecSignOrderHashAsync } from './signature_utils'; -import { CreateOrderOpts, MessagePrefixType } from './types'; +import { CreateOrderOpts } from './types'; export const orderFactory = { createOrder( @@ -59,12 +58,7 @@ export const orderFactory = { createOrderOpts, ); const orderHash = orderHashUtils.getOrderHashHex(order); - const messagePrefixOpts = { - prefixType: MessagePrefixType.EthSign, - shouldAddPrefixBeforeCallingEthSign: false, - }; - const ecSignature = await ecSignOrderHashAsync(provider, orderHash, makerAddress, messagePrefixOpts); - const signature = getVRSHexString(ecSignature); + const signature = await ecSignOrderHashAsync(provider, orderHash, makerAddress, SignerType.Default); const signedOrder: SignedOrder = _.assign(order, { signature }); return signedOrder; }, @@ -89,16 +83,3 @@ function generateDefaultCreateOrderOpts(): { expirationTimeSeconds: constants.INFINITE_TIMESTAMP_SEC, }; } - -function getVRSHexString(ecSignature: ECSignature): string { - const ETH_SIGN_SIGNATURE_TYPE = '03'; - const vrs = `${intToHex(ecSignature.v)}${ethUtil.stripHexPrefix(ecSignature.r)}${ethUtil.stripHexPrefix( - ecSignature.s, - )}${ETH_SIGN_SIGNATURE_TYPE}`; - return vrs; -} - -function intToHex(i: number): string { - const hex = ethUtil.bufferToHex(ethUtil.toBuffer(i)); - return hex; -} |