diff options
author | Fabio Berger <me@fabioberger.com> | 2017-07-08 05:21:47 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2017-07-08 05:21:47 +0800 |
commit | 68120ad1da1ee72ee11e1286698abc699c80e2cf (patch) | |
tree | 0734f15b21c1b318a8587a27a0c769542811b33b /src | |
parent | bdfbfb829b66b57ecb26a053a2b23665c9fd1549 (diff) | |
download | dexon-sol-tools-68120ad1da1ee72ee11e1286698abc699c80e2cf.tar.gz dexon-sol-tools-68120ad1da1ee72ee11e1286698abc699c80e2cf.tar.zst dexon-sol-tools-68120ad1da1ee72ee11e1286698abc699c80e2cf.zip |
Move private helper methods into signatureUtils so that they don't show up in the ZeroEx classes auto-complete list
Diffstat (limited to 'src')
-rw-r--r-- | src/0x.ts | 25 | ||||
-rw-r--r-- | src/utils/signature_utils.ts | 29 |
2 files changed, 30 insertions, 24 deletions
@@ -9,6 +9,7 @@ import compareVersions = require('compare-versions'); import {Web3Wrapper} from './web3_wrapper'; import {constants} from './utils/constants'; import {utils} from './utils/utils'; +import {signatureUtils} from './utils/signature_utils'; import {assert} from './utils/assert'; import {ExchangeWrapper} from './contract_wrappers/exchange_wrapper'; import {TokenRegistryWrapper} from './contract_wrappers/token_registry_wrapper'; @@ -282,28 +283,4 @@ export class ZeroEx { } return proxyAuthorizedExchangeContractAddresses; } - private parseSignatureHexAsVRS(signatureHex: string): ECSignature { - const signatureBuffer = ethUtil.toBuffer(signatureHex); - let v = signatureBuffer[0]; - if (v < 27) { - v += 27; - } - const r = signatureBuffer.slice(1, 33); - const s = signatureBuffer.slice(33, 65); - const ecSignature: ECSignature = { - v, - r: ethUtil.bufferToHex(r), - s: ethUtil.bufferToHex(s), - }; - return ecSignature; - } - private parseSignatureHexAsRSV(signatureHex: string): ECSignature { - const {v, r, s} = ethUtil.fromRpcSig(signatureHex); - const ecSignature: ECSignature = { - v, - r: ethUtil.bufferToHex(r), - s: ethUtil.bufferToHex(s), - }; - return ecSignature; - } } diff --git a/src/utils/signature_utils.ts b/src/utils/signature_utils.ts new file mode 100644 index 000000000..b312b5554 --- /dev/null +++ b/src/utils/signature_utils.ts @@ -0,0 +1,29 @@ +import * as ethUtil from 'ethereumjs-util'; +import {ECSignature} from '../types'; + +export const signatureUtils = { + parseSignatureHexAsVRS(signatureHex: string): ECSignature { + const signatureBuffer = ethUtil.toBuffer(signatureHex); + let v = signatureBuffer[0]; + if (v < 27) { + v += 27; + } + const r = signatureBuffer.slice(1, 33); + const s = signatureBuffer.slice(33, 65); + const ecSignature: ECSignature = { + v, + r: ethUtil.bufferToHex(r), + s: ethUtil.bufferToHex(s), + }; + return ecSignature; + }, + parseSignatureHexAsRSV(signatureHex: string): ECSignature { + const {v, r, s} = ethUtil.fromRpcSig(signatureHex); + const ecSignature: ECSignature = { + v, + r: ethUtil.bufferToHex(r), + s: ethUtil.bufferToHex(s), + }; + return ecSignature; + }, +}; |