Remove type aliases

This commit is contained in:
Leonid Logvinov 2017-05-25 13:00:56 +02:00
parent dc1ca23e30
commit 74a80c28d3
No known key found for this signature in database
GPG Key ID: 0DD294BFDE8C95D4
3 changed files with 7 additions and 8 deletions

View File

@ -20,10 +20,10 @@ export class ZeroEx {
* Verifies that the elliptic curve signature `signature` was generated
* by signing `data` with the private key corresponding to the `signer` address.
*/
public static isValidSignature(dataHex: string, signature: ECSignature, signer: ETHAddressHex): boolean {
public static isValidSignature(dataHex: string, signature: ECSignature, signerAddress: string): boolean {
assert.isHexString('dataHex', dataHex);
assert.doesConformToSchema('signature', signature, ECSignatureSchema);
assert.isETHAddressHex('signer', signer);
assert.isETHAddressHex('signerAddress', signerAddress);
const dataBuff = ethUtil.toBuffer(dataHex);
const msgHashBuff = ethUtil.hashPersonalMessage(dataBuff);
@ -33,7 +33,7 @@ export class ZeroEx {
ethUtil.toBuffer(signature.r),
ethUtil.toBuffer(signature.s));
const retrievedAddress = ethUtil.bufferToHex(ethUtil.pubToAddress(pubKey));
return retrievedAddress === signer;
return retrievedAddress === signerAddress;
} catch (err) {
return false;
}

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

@ -1,5 +1,3 @@
declare type ETHPublicKey = string;
declare type ETHAddressHex = string;
declare type ETHAddressBuff = Buffer;
declare interface Schema {
@ -10,6 +8,7 @@ declare module 'ethereumjs-util' {
const toBuffer: (dataHex: string) => Buffer;
const hashPersonalMessage: (msg: Buffer) => Buffer;
const bufferToHex: (buff: Buffer) => string;
const ecrecover: (msgHashBuff: Buffer, v: number, r: Buffer, s: Buffer) => ETHPublicKey;
const pubToAddress: (pubKey: ETHPublicKey) => ETHAddressBuff;
const ecrecover: (msgHashBuff: Buffer, v: number, r: Buffer, s: Buffer) => string;
const pubToAddress: (pubKey: string) => ETHAddressBuff;
const isValidAddress: (address: string) => boolean;
}

View File

@ -17,7 +17,7 @@ export const assert = {
this.assert(_.isString(value) && HEX_REGEX.test(value),
this.typeAssertionMessage(variableName, 'HexString', value));
},
isETHAddressHex(variableName: string, value: ETHAddressHex) {
isETHAddressHex(variableName: string, value: string) {
const web3 = new Web3();
this.assert(web3.isAddress(value), this.typeAssertionMessage(variableName, 'ETHAddressHex', value));
},