Skip to content

Commit

Permalink
Handles edge case on parsing base-10 number string inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-miller-0 committed May 9, 2021
1 parent f9cf6aa commit afb1c95
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gridplus-sdk",
"version": "0.7.13",
"version": "0.7.14",
"description": "SDK to interact with GridPlus Lattice1 device",
"scripts": {
"commit": "git-cz",
Expand Down
3 changes: 2 additions & 1 deletion src/ethereum.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ function ensureHexBuffer(x) {
// For null values, return a 0-sized buffer
if (x === null || x === 0) return Buffer.alloc(0);
// Otherwise try to get this converted to a hex string
if (typeof x === 'number') {
if (typeof x === 'number' || new BN(x).toString() === String(x)) {
// If this is a number or a base-10 number string, convert it to hex
x = `${new BN(x).toString(16)}`;
} else if (typeof x === 'string' && x.slice(0, 2) === '0x') {
x = x.slice(2);
Expand Down

0 comments on commit afb1c95

Please sign in to comment.