Remove type aliases
This commit is contained in:
parent
dc1ca23e30
commit
74a80c28d3
@ -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
7
src/ts/globals.d.ts
vendored
@ -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;
|
||||
}
|
||||
|
@ -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));
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user