Remove HexString type

This commit is contained in:
Leonid Logvinov 2017-05-25 12:28:28 +02:00
parent 5be5debdf1
commit 00a16b37e0
No known key found for this signature in database
GPG Key ID: 0DD294BFDE8C95D4
2 changed files with 6 additions and 7 deletions

View File

@ -19,12 +19,12 @@ export class ZeroEx {
* Verifies that the elliptic curve signature `signature` was generated * Verifies that the elliptic curve signature `signature` was generated
* by signing `data` with the private key corresponding to the `signer` address. * by signing `data` with the private key corresponding to the `signer` address.
*/ */
public static isValidSignature(data: HexString, signature: ECSignature, signer: ETHAddressHex): boolean { public static isValidSignature(dataHex: string, signature: ECSignature, signer: ETHAddressHex): boolean {
assert.isString('data', data); assert.isHexString('dataHex', dataHex);
assert.isObject('signature', signature); assert.isObject('signature', signature);
assert.isETHAddressHex('signer', signer); assert.isETHAddressHex('signer', signer);
const dataBuff = ethUtil.toBuffer(data); const dataBuff = ethUtil.toBuffer(dataHex);
const msgHashBuff = ethUtil.hashPersonalMessage(dataBuff); const msgHashBuff = ethUtil.hashPersonalMessage(dataBuff);
try { try {
const pubKey = ethUtil.ecrecover(msgHashBuff, const pubKey = ethUtil.ecrecover(msgHashBuff,
@ -51,7 +51,7 @@ export class ZeroEx {
return salt; return salt;
} }
/** Checks if order hash is valid */ /** Checks if order hash is valid */
public static isValidOrderHash(orderHash: HexString): boolean { public static isValidOrderHash(orderHash: string): boolean {
assert.isHexString('orderHash', orderHash); assert.isHexString('orderHash', orderHash);
return orderHash.length === ORDER_HASH_LENGTH; return orderHash.length === ORDER_HASH_LENGTH;
} }

5
src/ts/globals.d.ts vendored
View File

@ -1,12 +1,11 @@
declare type ETHPublicKey = string; declare type ETHPublicKey = string;
declare type ETHAddressHex = string; declare type ETHAddressHex = string;
declare type HexString = string;
declare type ETHAddressBuff = Buffer; declare type ETHAddressBuff = Buffer;
declare module 'ethereumjs-util' { declare module 'ethereumjs-util' {
const toBuffer: (data: HexString) => Buffer; const toBuffer: (dataHex: string) => Buffer;
const hashPersonalMessage: (msg: Buffer) => Buffer; const hashPersonalMessage: (msg: Buffer) => Buffer;
const bufferToHex: (buff: Buffer) => HexString; const bufferToHex: (buff: Buffer) => string;
const ecrecover: (msgHashBuff: Buffer, v: number, r: Buffer, s: Buffer) => ETHPublicKey; const ecrecover: (msgHashBuff: Buffer, v: number, r: Buffer, s: Buffer) => ETHPublicKey;
const pubToAddress: (pubKey: ETHPublicKey) => ETHAddressBuff; const pubToAddress: (pubKey: ETHPublicKey) => ETHAddressBuff;
} }