Comparing version 0.1.0-alpha.4 to 0.1.0-alpha.5
@@ -0,1 +1,2 @@ | ||
export * from "./abi"; | ||
export * from "./address"; | ||
@@ -2,0 +3,0 @@ export * from "./bn"; |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./abi")); | ||
__export(require("./address")); | ||
@@ -8,0 +9,0 @@ __export(require("./bn")); |
{ | ||
"name": "eth-utils", | ||
"version": "0.1.0-alpha.4", | ||
"version": "0.1.0-alpha.5", | ||
"description": "Collection of ethereum utils", | ||
@@ -5,0 +5,0 @@ "author": { |
/// <reference types="node" /> | ||
export declare function buildPersonalMessage(...types: string[]): (...args: any[]) => Buffer; | ||
export declare function hashPersonalMessage(message: Buffer | string): Buffer; | ||
@@ -4,0 +3,0 @@ export declare function signPersonalMessage(message: Buffer | string, privateKey: Buffer): Buffer; |
@@ -7,50 +7,2 @@ "use strict"; | ||
const crypto_1 = require("../crypto"); | ||
function buildPersonalMessage(...types) { | ||
return (...args) => { | ||
if (types.length !== args.length) { | ||
return null; | ||
} | ||
const buffers = []; | ||
for (const index in types) { | ||
if (typeof args[index] !== "undefined") { | ||
const type = types[index]; | ||
const arg = args[index]; | ||
switch (type) { | ||
case "bool": | ||
buffers.push(buffer_1.anyToBuffer(!!arg)); | ||
break; | ||
case "address": | ||
buffers.push(buffer_1.anyToBuffer(arg, { | ||
size: 20, | ||
})); | ||
break; | ||
case "bytes": | ||
case "string": | ||
buffers.push(buffer_1.anyToBuffer(arg)); | ||
break; | ||
default: | ||
const matched = type.match(/\d+/g); | ||
let size = Array.isArray(matched) && matched.length | ||
? parseInt(matched[0], 10) | ||
: 0; | ||
if (size && | ||
size % 8 === 0) { | ||
size = parseInt(matched[0], 10) / 8; | ||
buffers.push(buffer_1.anyToBuffer(arg, { | ||
size, | ||
})); | ||
} | ||
else { | ||
return null; | ||
} | ||
} | ||
} | ||
else { | ||
return null; | ||
} | ||
} | ||
return Buffer.concat(buffers); | ||
}; | ||
} | ||
exports.buildPersonalMessage = buildPersonalMessage; | ||
function hashPersonalMessage(message) { | ||
@@ -57,0 +9,0 @@ return crypto_1.sha3(buffer_1.anyToBuffer("\x19Ethereum Signed Message:\n32"), crypto_1.sha3(message)); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
28548
68
825
0