ethjs-format
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -75,4 +75,9 @@ 'use strict'; | ||
// format double padded zeros. | ||
if (output === '0x00') { | ||
output = '0x0'; | ||
} | ||
// throw if bytelength is not correct | ||
if (typeof byteLength === 'number' && value !== null && output !== '0x' && output !== '0x00' // support empty values | ||
if (typeof byteLength === 'number' && value !== null && output !== '0x' && output !== '0x0' // support empty values | ||
&& (!/^[0-9A-Fa-f]+$/.test(stripHexPrefix(output)) || outputByteLength !== 2 + byteLength * 2)) { | ||
@@ -79,0 +84,0 @@ throw new Error('[ethjs-format] hex string \'' + output + '\' must be an alphanumeric ' + (2 + byteLength * 2) + ' utf8 byte hex (chars: a-fA-F) string, is ' + outputByteLength + ' bytes'); |
@@ -257,2 +257,19 @@ 'use strict'; | ||
assert.equal(decodedObject.input, '0x603880600c6000396000f300603880600c6000396000f3603880600c6000396000f360'); | ||
var encodedTransactionObjectWithEmptyAddress = { | ||
hash: '0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b', | ||
nonce: '0x', | ||
blockHash: '0xbeab0aa2411b7ab17f30a99d3cb9c6ef2fc5426d6ad6fd9e2a26a6aed1d1055b', | ||
blockNumber: '0x15df', // 5599 | ||
transactionIndex: '0x1', // 1 | ||
from: '0x0', | ||
to: '0x85e43d8a49eeb85d32cf465507dd71d507100c12', | ||
value: '0x7f110', // 520464 | ||
gas: '0x7f110', // 520464 | ||
gasPrice: '0x9184e72a000', | ||
input: '0x603880600c6000396000f300603880600c6000396000f3603880600c6000396000f360' | ||
}; | ||
var decodedObject2 = format.formatObject('Transaction', encodedTransactionObjectWithEmptyAddress, false); | ||
assert.equal(decodedObject2.from, '0x0'); | ||
}); | ||
@@ -259,0 +276,0 @@ |
{ | ||
"name": "ethjs-format", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "A payload formatter for the Ethereum RPC layer.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -71,4 +71,7 @@ const schema = require('ethjs-schema'); | ||
// format double padded zeros. | ||
if (output === '0x00') { output = '0x0'; } | ||
// throw if bytelength is not correct | ||
if (typeof byteLength === 'number' && value !== null && output !== '0x' && output !== '0x00' // support empty values | ||
if (typeof byteLength === 'number' && value !== null && output !== '0x' && output !== '0x0' // support empty values | ||
&& (!/^[0-9A-Fa-f]+$/.test(stripHexPrefix(output)) || outputByteLength !== 2 + byteLength * 2)) { | ||
@@ -75,0 +78,0 @@ throw new Error(`[ethjs-format] hex string '${output}' must be an alphanumeric ${2 + byteLength * 2} utf8 byte hex (chars: a-fA-F) string, is ${outputByteLength} bytes`); |
@@ -255,2 +255,19 @@ /* eslint-disable */ | ||
assert.equal(decodedObject.input, '0x603880600c6000396000f300603880600c6000396000f3603880600c6000396000f360'); | ||
const encodedTransactionObjectWithEmptyAddress = { | ||
hash: '0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b', | ||
nonce: '0x', | ||
blockHash: '0xbeab0aa2411b7ab17f30a99d3cb9c6ef2fc5426d6ad6fd9e2a26a6aed1d1055b', | ||
blockNumber: '0x15df', // 5599 | ||
transactionIndex: '0x1', // 1 | ||
from: '0x0', | ||
to: '0x85e43d8a49eeb85d32cf465507dd71d507100c12', | ||
value: '0x7f110', // 520464 | ||
gas: '0x7f110', // 520464 | ||
gasPrice: '0x9184e72a000', | ||
input: '0x603880600c6000396000f300603880600c6000396000f3603880600c6000396000f360', | ||
}; | ||
const decodedObject2 = format.formatObject('Transaction', encodedTransactionObjectWithEmptyAddress, false); | ||
assert.equal(decodedObject2.from, '0x0'); | ||
}); | ||
@@ -257,0 +274,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
586357
8136