@findeth/abi
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -7,5 +7,4 @@ "use strict"; | ||
exports.toNumber = exports.toBuffer = exports.concat = void 0; | ||
const BUFFER_WIDTH = 32; | ||
var _bigintBuffer = require("bigint-buffer"); | ||
const concat = (target, value, position) => { | ||
@@ -18,3 +17,4 @@ return Buffer.concat([target.subarray(0, position !== null && position !== void 0 ? position : target.length), value, target.subarray(position !== null && position !== void 0 ? position : target.length)]); | ||
const toBuffer = value => { | ||
return (0, _bigintBuffer.toBufferBE)(BigInt(value), 32); | ||
const hex = value.toString(16); | ||
return Buffer.from(hex.padStart(BUFFER_WIDTH * 2, '0').slice(0, BUFFER_WIDTH * 2), 'hex'); | ||
}; | ||
@@ -25,3 +25,9 @@ | ||
const toNumber = buffer => { | ||
return (0, _bigintBuffer.toBigIntBE)(buffer); | ||
const hex = buffer.toString('hex'); | ||
if (hex.length === 0) { | ||
return BigInt(0); | ||
} | ||
return BigInt(`0x${hex}`); | ||
}; | ||
@@ -28,0 +34,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { toBigIntBE, toBufferBE } from 'bigint-buffer'; | ||
const BUFFER_WIDTH = 32; | ||
export const concat = (target, value, position) => { | ||
@@ -6,7 +6,14 @@ return Buffer.concat([target.subarray(0, position !== null && position !== void 0 ? position : target.length), value, target.subarray(position !== null && position !== void 0 ? position : target.length)]); | ||
export const toBuffer = value => { | ||
return toBufferBE(BigInt(value), 32); | ||
const hex = value.toString(16); | ||
return Buffer.from(hex.padStart(BUFFER_WIDTH * 2, '0').slice(0, BUFFER_WIDTH * 2), 'hex'); | ||
}; | ||
export const toNumber = buffer => { | ||
return toBigIntBE(buffer); | ||
const hex = buffer.toString('hex'); | ||
if (hex.length === 0) { | ||
return BigInt(0); | ||
} | ||
return BigInt(`0x${hex}`); | ||
}; | ||
//# sourceMappingURL=buffer.js.map |
{ | ||
"name": "@findeth/abi", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "A tiny Solidity ABI encoder and decoder", | ||
@@ -55,3 +55,2 @@ "author": "Maarten Zuidhoorn <maarten@zuidhoorn.com>", | ||
"dependencies": { | ||
"bigint-buffer": "^1.1.5", | ||
"keccak": "^3.0.0" | ||
@@ -58,0 +57,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
import { toBigIntBE, toBufferBE } from 'bigint-buffer'; | ||
const BUFFER_WIDTH = 32; | ||
@@ -12,7 +12,13 @@ export const concat = (target: Buffer, value: Buffer, position?: number): Buffer => { | ||
export const toBuffer = (value: number | bigint): Buffer => { | ||
return toBufferBE(BigInt(value), 32); | ||
const hex = value.toString(16); | ||
return Buffer.from(hex.padStart(BUFFER_WIDTH * 2, '0').slice(0, BUFFER_WIDTH * 2), 'hex'); | ||
}; | ||
export const toNumber = (buffer: Buffer): bigint => { | ||
return toBigIntBE(buffer); | ||
const hex = buffer.toString('hex'); | ||
if (hex.length === 0) { | ||
return BigInt(0); | ||
} | ||
return BigInt(`0x${hex}`); | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
101039
1
1578
- Removedbigint-buffer@^1.1.5
- Removedbigint-buffer@1.1.5(transitive)
- Removedbindings@1.5.0(transitive)
- Removedfile-uri-to-path@1.0.0(transitive)