ethers-providers
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -8,6 +8,8 @@ 'use strict'; | ||
var utils = (function() { | ||
var convert = require('ethers-utils/convert'); | ||
return { | ||
defineProperty: require('ethers-utils/properties').defineProperty, | ||
hexlify: require('ethers-utils/convert').hexlify, | ||
hexlify: convert.hexlify, | ||
isHexString: convert.isHexString, | ||
} | ||
@@ -27,7 +29,22 @@ })(); | ||
function stripHexZeros(value) { | ||
while (value.length > 3 && value.substring(0, 3) === '0x0') { | ||
value = '0x' + value.substring(3); | ||
} | ||
return value; | ||
} | ||
function getTransaction(transaction) { | ||
var result = {}; | ||
for (var key in transaction) { | ||
result[key] = utils.hexlify(transaction[key]); | ||
} | ||
// Some nodes (INFURA ropsten; INFURA mainnet is fine) don't like extra zeros. | ||
['gasLimit', 'gasPrice', 'nonce', 'value'].forEach(function(key) { | ||
if (!result[key]) { return; } | ||
result[key] = stripHexZeros(result[key]); | ||
}); | ||
return result; | ||
@@ -66,12 +83,22 @@ } | ||
case 'getBalance': | ||
return this.send('eth_getBalance', [params.address, params.blockTag]); | ||
var blockTag = params.blockTag; | ||
if (utils.isHexString(blockTag)) { blockTag = stripHexZeros(blockTag); } | ||
return this.send('eth_getBalance', [params.address, blockTag]); | ||
case 'getTransactionCount': | ||
return this.send('eth_getTransactionCount', [params.address, params.blockTag]); | ||
var blockTag = params.blockTag; | ||
if (utils.isHexString(blockTag)) { blockTag = stripHexZeros(blockTag); } | ||
return this.send('eth_getTransactionCount', [params.address, blockTag]); | ||
case 'getCode': | ||
return this.send('eth_getCode', [params.address, params.blockTag]); | ||
var blockTag = params.blockTag; | ||
if (utils.isHexString(blockTag)) { blockTag = stripHexZeros(blockTag); } | ||
return this.send('eth_getCode', [params.address, blockTag]); | ||
case 'getStorageAt': | ||
return this.send('eth_getStorageAt', [params.address, params.position, params.blockTag]); | ||
var position = params.position; | ||
if (utils.isHexString(position)) { position = stripHexZeros(position); } | ||
var blockTag = params.blockTag; | ||
if (utils.isHexString(blockTag)) { blockTag = stripHexZeros(blockTag); } | ||
return this.send('eth_getStorageAt', [params.address, position, blockTag]); | ||
@@ -83,3 +110,5 @@ case 'sendTransaction': | ||
if (params.blockTag) { | ||
return this.send('eth_getBlockByNumber', [params.blockTag, false]); | ||
var blockTag = params.blockTag; | ||
if (utils.isHexString(blockTag)) { blockTag = stripHexZeros(blockTag); } | ||
return this.send('eth_getBlockByNumber', [blockTag, false]); | ||
} else if (params.blockHash) { | ||
@@ -86,0 +115,0 @@ return this.send('eth_getBlockByHash', [params.blockHash, false]); |
{ | ||
"name": "ethers-providers", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Service provider for Ethereum wallet library.", | ||
@@ -14,3 +14,3 @@ "bugs": { | ||
"dependencies": { | ||
"ethers-utils": "^2.0.0", | ||
"ethers-utils": "^2.1.0", | ||
"inherits": "2.0.1", | ||
@@ -17,0 +17,0 @@ "xmlhttprequest": "1.8.0" |
@@ -109,21 +109,12 @@ 'use strict'; | ||
if (typeof(blockTag) === 'number') { | ||
blockTag = utils.hexlify(blockTag); | ||
} | ||
if (utils.isHexString(blockTag)) { | ||
// HACK: This seems to be a weird requirement some nodes have | ||
// (e.g. INFURA on ropsten; INFURA on homestead is fine) | ||
// Remove leading 0's from the hex blockTag | ||
while (blockTag.length > 3 && blockTag.substring(0, 3) === '0x0') { | ||
blockTag = '0x' + blockTag.substring(3); | ||
} | ||
if (blockTag === 'latest' || blockTag === 'pending') { | ||
return blockTag; | ||
} | ||
if (blockTag === 'latest' || blockTag === 'pending') { | ||
return blockTag; | ||
if (typeof(blockTag) === 'number') { | ||
return utils.hexlify(blockTag); | ||
} | ||
if (utils.isHexString(blockTag)) { return blockTag; } | ||
throw new Error('invalid blockTag'); | ||
@@ -130,0 +121,0 @@ } |
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
46066
1177
Updatedethers-utils@^2.1.0