Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@metamask/ethjs-query

Package Overview
Dependencies
Maintainers
12
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask/ethjs-query - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

251

CHANGELOG.md

@@ -1,120 +0,189 @@

# 0.5.0 -- change to error reporting
# Changelog
All notable changes to this project will be documented in this file.
1. Removed logic that was catching too broadly and applying an erroneous "formatting error" error.
2. Removed logic that was rethrowing newly constructed Error objects that stripped stack traces relevant to the actual error.
3. Changes to lint configuration
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
# 0.4.0 -- maintenance update
## [Unreleased]
1. Renamed to @metamask/ethjs-query
2. Fixed and removed broken devDependencies
3. Require minimum nodejs v8.17, npm v6
4. Repository location changed
5. `npm prepublish` is now `npm prepare`
## [0.6.0]
### Changed
- **BREAKING**: `@babel/runtime@^7.0.0` is now a peerDependency ([#10](https://github.com/MetaMask/ethjs-query/pull/10))
- Update from `ethjs-rpc@0.2.0` to `@metamask/ethjs-rpc@^0.3.0` ([#22](https://github.com/MetaMask/ethjs-query/pull/22))
# 0.3.8 -- performCall change
### Removed
- Remove implicit peerDependency `babel-runtime` ([#10](https://github.com/MetaMask/ethjs-query/pull/10))
1. Replace babel transforms with dependency babel-runtime
2. performCall behaves differently
## [0.5.0]
### Changed
- change to error reporting
- Removed logic that was catching too broadly and applying an erroneous "formatting error" error.
- Removed logic that was rethrowing newly constructed Error objects that stripped stack traces relevant to the actual error.
- Changes to lint configuration
## [0.4.0]
### Changed
- maintenance update
- Renamed to `@metamask/ethjs-query`
- Fixed and removed broken devDependencies
- Require minimum nodejs v8.17, npm v6
- Repository location changed
- `npm prepublish` is now `npm prepare`
# 0.3.7 -- various fixes
1. Async and promise handling changes
2. ethjs-rpc bump to 0.2.0
3. Replaced ethereum-tesrpc with ganache-core
## [0.3.8]
### Changed
- performCall change
- Replace babel transforms with dependency babel-runtime
- performCall behaves differently
# 0.3.6 -- ethjs-format bump to 0.2.7
## [0.3.7]
### Changed
- various fixes
- Async and promise handling changes
- ethjs-rpc bump to 0.2.0
- Replaced ethereum-testrpc with ganache-core
# 0.3.5 -- new eth filter ID changes
## [0.3.6]
### Changed
- ethjs-format bump to 0.2.7
1. Adds padded quantities
2. Fixed problem where number ID 1 for filter ID encodes to 0x1, when it should be 0x01 (with padding)
3. Methods affected: `eth.getFilterChanges` `eth.uninstallFilter` `eth.getFilterLogs`
## [0.3.5]
### Changed
- new eth filter ID changes
- Adds padded quantities
- Fixed problem where number ID 1 for filter ID encodes to 0x1, when it should be 0x01 (with padding)
- Methods affected: `eth.getFilterChanges` `eth.uninstallFilter` `eth.getFilterLogs`
# 0.3.4 -- added new ethjs-format
## [0.3.4]
### Changed
- added new ethjs-format
- Unhandled promise rejection fixed, and is no longer being swolloed.
- ethjs-rpc bump to 0.1.9
1. Unhandled promise rejection fixed, and is no longer being swolloed.
2. ethjs-rpc bump to 0.1.9
## [0.2.6]
### Changed
- added new ethjs-format
- no longer padds quantity hex values, as per standard.
# 0.2.6 -- added new ethjs-format
## [0.2.4]
### Changed
- personal sign and ecrecover
1. no longer padds quantity hex values, as per standard.
## [0.2.3]
### Changed
- package updates
- Update ethjs-rpc, handle 405 errors better
# 0.2.4 -- personal sign and ecrecover
## [0.2.1]
### Changed
- handle non RPC errors better
- Handle non rpc errors better
# 0.2.3 -- package updates
## [0.2.0]
### Changed
- handle 500 errors better
- Handles 500/404/303 errors
1. Update ethjs-rpc, handle 405 errors better
## [0.1.8]
### Changed
- bn formatting update
- Bignumber formatting update
# 0.2.1 -- handle non RPC errors better
## [0.1.7]
### Changed
- Better RPC error handling
- Better RPC error handling
1. Handle non rpc errors better
## [0.1.6]
### Changed
- Strinigy RPC error
- Added JSON.strinify for RPC error handling
# 0.2.0 -- handle 500 errors better
## [0.1.5]
### Changed
- format update
- Tigher formatting enforcement
- Small schema update
1. Handles 500/404/303 errors
## [0.1.4]
### Changed
- less dependencies
- Better formatting
- Less dependencies
- ID generation done in house
- 25kb less file size
- More docs
# 0.1.8 -- bn formatting update
## [0.1.2]
### Changed
- config fixes
- webpack config updates
- build config updates
1. Bignumber formatting update
## [0.1.1]
### Changed
- new packages
- new ethjs-format
- more docs
# 0.1.7 -- Better RPC error handling
## [0.0.5]
### Changed
- refactor
- code cleanup
- more coverage
- better error handling
- less dependencies
1. Better RPC error handling
## [0.0.4]
### Changed
- promises, louder errors, more tests
- added promises
- louder errors
- more test coverage
# 0.1.6 -- Strinigy RPC error
## [0.0.3]
### Changed
- options with debug logging and other features
- added low level complete logging `new Eth(provider, { debug: false, logger: console, jsonSpace: 0 })`
- more tests
1. Added JSON.strinify for RPC error handling
## [0.0.2]
### Changed
- handle `eth_getFilterChanges` during Block and Pending Tx filter
- handle `getFilterChanges` during BlockFilter and PendingTxFilter.
# 0.1.5 -- format update
## [0.0.1]
### Changed
- `ethjs-query`
- Basic testing
- Basic docs
- License
- linting
- basic exports
1. Tigher formatting enforcement
2. Small schema update
# 0.1.4 -- less dependencies
1. Better formatting
2. Less dependencies
3. ID generation done in house
4. 25kb less file size
5. More docs
# 0.1.2 -- config fixes
1. webpack config updates
2. build config updates
# 0.1.1 -- new packages
1. new ethjs-format
2. more docs
# 0.0.5 -- refactor
1. code cleanup
2. more coverage
3. better error handling
4. less dependencies
# 0.0.4 -- promises, louder errors, more tests
1. added promises
2. louder errors
3. more test coverage
# 0.0.3 -- options with debug logging and other features
1. added low level complete logging `new Eth(provider, { debug: false, logger: console, jsonSpace: 0 })`
2. more tests
# 0.0.2 -- handle eth_getFilterChanges during Block and Pending Tx filter
1. handle getFilterChanges during BlockFilter and PendingTxFilter.
# 0.0.1 -- ethjs-query
1. Basic testing
2. Basic docs
3. License
4. linting
5. basic exports
[Unreleased]: https://github.com/MetaMask/ethjs-query/compare/v0.6.0...HEAD
[0.6.0]: https://github.com/MetaMask/ethjs-query/compare/v0.5.0...v0.6.0
[0.5.0]: https://github.com/MetaMask/ethjs-query/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/MetaMask/ethjs-query/compare/v0.3.8...v0.4.0
[0.3.8]: https://github.com/MetaMask/ethjs-query/compare/v0.3.7...v0.3.8
[0.3.7]: https://github.com/MetaMask/ethjs-query/compare/v0.3.6...v0.3.7
[0.3.6]: https://github.com/MetaMask/ethjs-query/compare/v0.3.5...v0.3.6
[0.3.5]: https://github.com/MetaMask/ethjs-query/compare/v0.3.4...v0.3.5
[0.3.4]: https://github.com/MetaMask/ethjs-query/compare/v0.2.6...v0.3.4
[0.2.6]: https://github.com/MetaMask/ethjs-query/compare/v0.2.4...v0.2.6
[0.2.4]: https://github.com/MetaMask/ethjs-query/compare/v0.2.3...v0.2.4
[0.2.3]: https://github.com/MetaMask/ethjs-query/compare/v0.2.1...v0.2.3
[0.2.1]: https://github.com/MetaMask/ethjs-query/compare/v0.2.0...v0.2.1
[0.2.0]: https://github.com/MetaMask/ethjs-query/compare/v0.1.8...v0.2.0
[0.1.8]: https://github.com/MetaMask/ethjs-query/compare/v0.1.7...v0.1.8
[0.1.7]: https://github.com/MetaMask/ethjs-query/compare/v0.1.6...v0.1.7
[0.1.6]: https://github.com/MetaMask/ethjs-query/compare/v0.1.5...v0.1.6
[0.1.5]: https://github.com/MetaMask/ethjs-query/compare/v0.1.4...v0.1.5
[0.1.4]: https://github.com/MetaMask/ethjs-query/compare/v0.1.2...v0.1.4
[0.1.2]: https://github.com/MetaMask/ethjs-query/compare/v0.1.1...v0.1.2
[0.1.1]: https://github.com/MetaMask/ethjs-query/compare/v0.0.5...v0.1.1
[0.0.5]: https://github.com/MetaMask/ethjs-query/compare/v0.0.4...v0.0.5
[0.0.4]: https://github.com/MetaMask/ethjs-query/compare/v0.0.3...v0.0.4
[0.0.3]: https://github.com/MetaMask/ethjs-query/compare/v0.0.2...v0.0.3
[0.0.2]: https://github.com/MetaMask/ethjs-query/compare/v0.0.1...v0.0.2
[0.0.1]: https://github.com/MetaMask/ethjs-query/releases/tag/v0.0.1

@@ -1,2 +0,3 @@

var webpack = require('webpack'); // eslint-disable-line
const path = require('path');
const webpack = require('webpack');

@@ -16,3 +17,3 @@ var env = process.env.NODE_ENV; // eslint-disable-line

test: /\.json$/,
loader: 'json',
loader: 'json-loader',
},

@@ -23,3 +24,3 @@ ],

output: {
path: 'dist',
path: path.resolve(path.join(__dirname, '../../dist')),
filename: filename + '.js', // eslint-disable-line

@@ -57,5 +58,4 @@ library: library, // eslint-disable-line

}));
config.plugins.push(new webpack.optimize.DedupePlugin());
}
module.exports = config;

@@ -1,13 +0,10 @@

'use strict';
"use strict";
var format = require('ethjs-format');
var EthRPC = require('ethjs-rpc');
var EthRPC = require('@metamask/ethjs-rpc');
var promiseToCallback = require('promise-to-callback');
module.exports = Eth;
function Eth(provider, options) {
var self = this;
var optionsObject = options || {};
if (!(this instanceof Eth)) {

@@ -17,5 +14,4 @@ throw new Error('[ethjs-query] the Eth object requires the "new" flag in order to function normally (i.e. `const eth = new Eth(provider);`).');

if (typeof provider !== 'object') {
throw new Error('[ethjs-query] the Eth object requires that the first input \'provider\' must be an object, got \'' + typeof provider + '\' (i.e. \'const eth = new Eth(provider);\')');
throw new Error("[ethjs-query] the Eth object requires that the first input 'provider' must be an object, got '" + typeof provider + "' (i.e. 'const eth = new Eth(provider);')");
}
self.options = Object.assign({

@@ -29,8 +25,6 @@ debug: optionsObject.debug || false,

}
Eth.prototype.log = function log(message) {
var self = this;
if (self.options.debug) self.options.logger.log('[ethjs-query log] ' + message);
if (self.options.debug) self.options.logger.log("[ethjs-query log] " + message);
};
Object.keys(format.schema.methods).forEach(function (rpcMethodName) {

@@ -42,3 +36,2 @@ Object.defineProperty(Eth.prototype, rpcMethodName.replace('eth_', ''), {

});
function generateFnFor(rpcMethodName, methodObject) {

@@ -56,3 +49,2 @@ return function outputMethod() {

}
var promise = performCall.call(this);

@@ -67,14 +59,12 @@

return promise;
function performCall() {
var _this = this;
return new Promise(function (resolve, reject) {
// validate arg length
if (args.length < methodObject[2]) {
reject(new Error('[ethjs-query] method \'' + protoMethodName + '\' requires at least ' + methodObject[2] + ' input (format type ' + methodObject[0][0] + '), ' + args.length + ' provided. For more information visit: https://github.com/ethereum/wiki/wiki/JSON-RPC#' + rpcMethodName.toLowerCase()));
reject(new Error("[ethjs-query] method '" + protoMethodName + "' requires at least " + methodObject[2] + " input (format type " + methodObject[0][0] + "), " + args.length + " provided. For more information visit: https://github.com/ethereum/wiki/wiki/JSON-RPC#" + rpcMethodName.toLowerCase()));
return;
}
if (args.length > methodObject[0].length) {
reject(new Error('[ethjs-query] method \'' + protoMethodName + '\' requires at most ' + methodObject[0].length + ' params, ' + args.length + ' provided \'' + JSON.stringify(args, null, self.options.jsonSpace) + '\'. For more information visit: https://github.com/ethereum/wiki/wiki/JSON-RPC#' + rpcMethodName.toLowerCase()));
reject(new Error("[ethjs-query] method '" + protoMethodName + "' requires at most " + methodObject[0].length + " params, " + args.length + " provided '" + JSON.stringify(args, null, self.options.jsonSpace) + "'. For more information visit: https://github.com/ethereum/wiki/wiki/JSON-RPC#" + rpcMethodName.toLowerCase()));
return;

@@ -89,8 +79,8 @@ }

// format inputs
_this.log('attempting method formatting for \'' + protoMethodName + '\' with inputs ' + JSON.stringify(args, null, _this.options.jsonSpace));
_this.log("attempting method formatting for '" + protoMethodName + "' with inputs " + JSON.stringify(args, null, _this.options.jsonSpace));
try {
inputs = format.formatInputs(rpcMethodName, args);
_this.log('method formatting success for \'' + protoMethodName + '\' with formatted result: ' + JSON.stringify(inputs, null, _this.options.jsonSpace));
_this.log("method formatting success for '" + protoMethodName + "' with formatted result: " + JSON.stringify(inputs, null, _this.options.jsonSpace));
} catch (formattingError) {
reject(new Error('[ethjs-query] while formatting inputs \'' + JSON.stringify(args, null, _this.options.jsonSpace) + '\' for method \'' + protoMethodName + '\' error: ' + formattingError));
reject(new Error("[ethjs-query] while formatting inputs '" + JSON.stringify(args, null, _this.options.jsonSpace) + "' for method '" + protoMethodName + "' error: " + formattingError));
return;

@@ -100,10 +90,13 @@ }

// perform rpc call
_this.rpc.sendAsync({ method: rpcMethodName, params: inputs }).then(function (result) {
_this.rpc.sendAsync({
method: rpcMethodName,
params: inputs
}).then(function (result) {
// format result
_this.log('attempting method formatting for \'' + protoMethodName + '\' with raw outputs: ' + JSON.stringify(result, null, _this.options.jsonSpace));
_this.log("attempting method formatting for '" + protoMethodName + "' with raw outputs: " + JSON.stringify(result, null, _this.options.jsonSpace));
var methodOutputs = format.formatOutputs(rpcMethodName, result);
_this.log('method formatting success for \'' + protoMethodName + '\' formatted result: ' + JSON.stringify(methodOutputs, null, _this.options.jsonSpace));
_this.log("method formatting success for '" + protoMethodName + "' formatted result: " + JSON.stringify(methodOutputs, null, _this.options.jsonSpace));
resolve(methodOutputs);
return;
})['catch'](function (error) {
})["catch"](function (error) {
reject(error);

@@ -110,0 +103,0 @@ });

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -11,14 +11,10 @@ require('hard-rejection')();

var abi = require('ethjs-abi');
describe('ethjs-query', function () {
var provider = void 0;
var provider;
beforeEach(function () {
provider = Ganache.provider();
});
describe('construction', function () {
it('should construct normally', function () {
var eth = new Eth(provider);
assert.equal(typeof eth, 'object');

@@ -32,6 +28,4 @@ assert.equal(typeof eth.accounts, 'function');

});
it('should construct normally with non Eth name', function () {
var eth = new Eth2(provider);
assert.equal(typeof eth, 'object');

@@ -43,3 +37,2 @@ assert.equal(typeof eth.accounts, 'function');

});
it('should fail when provider is not valid', function (done) {

@@ -53,3 +46,2 @@ try {

});
it('should fail when provider is not valid', function (done) {

@@ -63,7 +55,11 @@ try {

});
it('debugger should function', function (done) {
var eth = new Eth(provider, { debug: true, logger: { log: function log(message) {
var eth = new Eth(provider, {
debug: true,
logger: {
log: function log(message) {
assert.equal(typeof message, 'string');
} } }); // eslint-disable-line
}
}
}); // eslint-disable-line

@@ -76,7 +72,8 @@ eth.accounts(function (err, result) {

});
it('should fail with response error payload', function (done) {
var eth = new Eth({
sendAsync: function sendAsync(opts, cb) {
cb(false, { error: 'bad data..' });
cb(false, {
error: 'bad data..'
});
}

@@ -91,3 +88,2 @@ }); // eslint-disable-line

});
it('should handle empty getTransactionReceipt', function (done) {

@@ -102,7 +98,8 @@ var eth = new Eth(provider); // eslint-disable-line

});
it('should fail with invalid payload response (formatting error)', function (done) {
var eth = new Eth({
sendAsync: function sendAsync(opts, cb) {
cb(false, { result: [38274978, 983428943] });
cb(false, {
result: [38274978, 983428943]
});
}

@@ -117,3 +114,2 @@ }); // eslint-disable-line

});
it('should fail with invalid method input (formatting error)', function (done) {

@@ -128,3 +124,2 @@ var eth = new Eth(provider); // eslint-disable-line

});
it('should fail when no new flag is present', function (done) {

@@ -138,3 +133,2 @@ try {

});
it('should fail nicely when too little params on getBalance', function (done) {

@@ -146,7 +140,5 @@ var eth = new Eth(provider); // eslint-disable-line

assert.equal(result, null);
done();
});
});
it('should fail nicely when too many paramsEncoded on getBalance', function (done) {

@@ -158,21 +150,15 @@ var eth = new Eth(provider); // eslint-disable-line

assert.equal(result, null);
done();
});
});
it('should check if the rpc is eth_syncing', function (done) {
var eth = new Eth(provider);
eth.syncing(function (err, result) {
assert.equal(err, null);
assert.equal(typeof result, 'boolean');
done();
});
});
it('should function while eth_coinbase', function (done) {
var eth = new Eth(provider);
eth.coinbase(function (err, result) {

@@ -182,36 +168,27 @@ assert.equal(err, null);

assert.equal(util.getBinarySize(result), 42);
done();
});
});
it('should function while eth_coinbase using promise', function (done) {
var eth = new Eth(provider);
eth.coinbase().then(function (result) {
assert.equal(typeof result, 'string');
assert.equal(util.getBinarySize(result), 42);
done();
})['catch'](function (err) {
})["catch"](function (err) {
assert.equal(err, null);
});
});
it('should get acconts with promise', function (done) {
var eth = new Eth(provider);
eth.accounts().then(function (result) {
assert.equal(typeof result, 'object');
assert.equal(result.length > 0, true);
done();
})['catch'](function (err) {
})["catch"](function (err) {
assert.equal(err, null);
});
});
it('should reject bad getBalance call with an error', function (done) {
var eth = new Eth(provider);
eth.accounts(function (accountsError, accounts) {

@@ -224,3 +201,3 @@ eth.sendTransaction({

data: '0x'
})['catch'](function (err) {
})["catch"](function (err) {
assert.equal(typeof err, 'object');

@@ -231,25 +208,19 @@ done();

});
it('should function while eth_getBalance using promise', function (done) {
var eth = new Eth(provider);
eth.coinbase().then(function (result) {
assert.equal(typeof result, 'string');
assert.equal(util.getBinarySize(result), 42);
eth.getBalance(result).then(function (balance) {
assert.equal(typeof balance, 'object');
done();
})['catch'](function (err) {
})["catch"](function (err) {
assert.equal(err, null);
});
})['catch'](function (err) {
})["catch"](function (err) {
assert.equal(err, null);
});
});
it('should function while eth_getBalance, optional and non optional latest', function (done) {
var eth = new Eth(provider);
eth.coinbase(function (err, coinbase) {

@@ -259,7 +230,5 @@ assert.equal(err, null);

assert.equal(util.getBinarySize(coinbase), 42);
eth.getBalance(coinbase, function (balanceError, balance) {
assert.equal(balanceError, null);
assert.equal(typeof balance, 'object');
eth.getBalance(coinbase, 'latest', function (balanceLatestError, balanceLatest) {

@@ -269,3 +238,2 @@ assert.equal(balanceLatestError, null);

assert.equal(balance.toString(10), balanceLatest.toString(10));
done();

@@ -276,6 +244,4 @@ });

});
it('should function while get_accounts', function (done) {
var eth = new Eth(provider);
eth.accounts(function (err, result) {

@@ -288,10 +254,7 @@ assert.equal(err, null);

assert.equal(util.getBinarySize(result[0]), 42);
done();
});
});
it('should function while eth_blockNumber', function (done) {
var eth = new Eth(provider);
eth.blockNumber(function (err, result) {

@@ -304,3 +267,2 @@ assert.equal(err, null);

});
it('should function while eth_estimateGas', function (done) {

@@ -311,3 +273,2 @@ var eth = new Eth(provider);

assert.equal(typeof accounts, 'object');
var testTransactionObject = {

@@ -320,3 +281,2 @@ from: accounts[0],

};
eth.estimateGas(testTransactionObject, function (err, result) {

@@ -331,6 +291,4 @@ assert.equal(err, null);

});
it('should function while eth_gasPrice', function (done) {
var eth = new Eth(provider);
eth.gasPrice(function (err, result) {

@@ -343,10 +301,7 @@ assert.equal(err, null);

});
it('should function while eth_getBalance', function (done) {
var eth = new Eth(provider);
eth.accounts(function (accountsError, accounts) {
assert.equal(accountsError, null);
assert.equal(typeof accounts, 'object');
eth.getBalance(accounts[0], function (err, result) {

@@ -356,3 +311,2 @@ assert.equal(err, null);

assert.equal(result.gt(0), true);
eth.getBalance(accounts[0], 'latest', function (err2, result2) {

@@ -367,7 +321,5 @@ assert.equal(err2, null);

});
it('should function while eth_getBlockByNumber', function (done) {
// eslint-disable-line
var eth = new Eth(provider);
eth.getBlockByNumber(0, true, function (blockError, result) {

@@ -385,10 +337,7 @@ assert.equal(blockError, null);

});
it('should function while eth_getBlockByHash', function (done) {
var eth = new Eth(provider);
eth.getBlockByNumber(0, true, function (blockError, block) {
assert.equal(blockError, null);
assert.equal(typeof block, 'object');
eth.getBlockByHash(block.hash, true, function (error, result) {

@@ -407,3 +356,2 @@ assert.equal(error, null);

});
it('should function while eth_getCode', function (done) {

@@ -413,3 +361,2 @@ var eth = new Eth(provider); // eslint-disable-line

});
it('should function while eth_hashrate', function (done) {

@@ -422,7 +369,5 @@ var eth = new Eth(provider); // eslint-disable-line

assert.equal(result.toNumber(10) >= 0, true);
done();
});
});
it('should function while eth_mining', function (done) {

@@ -434,7 +379,5 @@ var eth = new Eth(provider); // eslint-disable-line

assert.equal(typeof result, 'boolean');
done();
});
});
it('should function while eth_getTransactionCount', function (done) {

@@ -446,3 +389,2 @@ var eth = new Eth(provider); // eslint-disable-line

assert.equal(typeof accounts, 'object');
eth.getTransactionCount(accounts[0], function (error, result) {

@@ -452,3 +394,2 @@ assert.equal(error, null);

assert.equal(result.toNumber(10) >= 0, true);
done();

@@ -458,3 +399,2 @@ });

});
it('should function while eth_getTransactionByBlockHashAndIndex', function (done) {

@@ -466,3 +406,2 @@ var eth = new Eth(provider); // eslint-disable-line

assert.equal(typeof accounts, 'object');
var testTransaction = {

@@ -474,3 +413,2 @@ from: accounts[0],

};
eth.sendTransaction(testTransaction, function (error, result) {

@@ -480,7 +418,5 @@ assert.equal(error, null);

assert.equal(util.getBinarySize(result), 66);
eth.getTransactionReceipt(result, function (receiptError, receipt) {
assert.equal(receiptError, null);
assert.equal(typeof receipt, 'object');
eth.getTransactionByBlockHashAndIndex(receipt.blockHash, 0, function (blockError, block) {

@@ -494,3 +430,2 @@ assert.equal(blockError, null);

assert.equal(block.blockNumber.toNumber(10) >= 0, true);
done();

@@ -502,3 +437,2 @@ });

});
it('should function while eth_getTransactionByBlockNumberAndIndex', function (done) {

@@ -510,3 +444,2 @@ var eth = new Eth(provider); // eslint-disable-line

assert.equal(typeof accounts, 'object');
var testTransaction = {

@@ -518,3 +451,2 @@ from: accounts[0],

};
eth.sendTransaction(testTransaction, function (error, result) {

@@ -524,7 +456,5 @@ assert.equal(error, null);

assert.equal(util.getBinarySize(result), 66);
eth.getTransactionReceipt(result, function (receiptError, receipt) {
assert.equal(receiptError, null);
assert.equal(typeof receipt, 'object');
eth.getTransactionByBlockNumberAndIndex(1, 0, function (blockError, block) {

@@ -538,3 +468,2 @@ assert.equal(blockError, null);

assert.equal(block.blockNumber.toNumber(10) >= 0, true);
done();

@@ -546,3 +475,2 @@ });

});
it('should function while eth_sendTransaction', function (done) {

@@ -554,3 +482,2 @@ var eth = new Eth(provider); // eslint-disable-line

assert.equal(typeof accounts, 'object');
var testTransaction = {

@@ -562,3 +489,2 @@ from: accounts[0],

};
eth.sendTransaction(testTransaction, function (error, result) {

@@ -568,3 +494,2 @@ assert.equal(error, null);

assert.equal(util.getBinarySize(result), 66);
done();

@@ -574,3 +499,2 @@ });

});
it('should function while eth_sendTransaction with contract', function (done) {

@@ -582,3 +506,2 @@ var eth = new Eth(provider); // eslint-disable-line

assert.equal(typeof accounts, 'object');
var testTransaction = {

@@ -589,3 +512,2 @@ from: accounts[0],

};
eth.sendTransaction(testTransaction, function (error, result) {

@@ -595,3 +517,2 @@ assert.equal(error, null);

assert.equal(util.getBinarySize(result), 66);
done();

@@ -601,3 +522,2 @@ });

});
it('should function while eth_sign', function (done) {

@@ -609,5 +529,3 @@ var eth = new Eth(provider); // eslint-disable-line

assert.equal(typeof accounts, 'object');
var testTxData = '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470';
eth.sign(accounts[0], testTxData, function (error, result) {

@@ -617,3 +535,2 @@ assert.equal(error, null);

assert.equal(util.getBinarySize(result) > 0, true);
done();

@@ -623,3 +540,2 @@ });

});
it('should function while eth_getTransactionReceipt', function (done) {

@@ -631,3 +547,2 @@ var eth = new Eth(provider); // eslint-disable-line

assert.equal(typeof accounts, 'object');
var testTransaction = {

@@ -639,3 +554,2 @@ from: accounts[0],

};
eth.sendTransaction(testTransaction, function (error, result) {

@@ -645,3 +559,2 @@ assert.equal(error, null);

assert.equal(util.getBinarySize(result), 66);
setTimeout(function () {

@@ -651,3 +564,2 @@ eth.getTransactionReceipt(result, function (receiptError, receipt) {

assert.equal(typeof receipt, 'object');
assert.equal(util.getBinarySize(receipt.transactionHash), 66);

@@ -659,3 +571,2 @@ assert.equal(receipt.transactionIndex.toNumber(10) >= 0, true);

assert.equal(Array.isArray(receipt.logs), true);
done();

@@ -667,3 +578,2 @@ });

});
it('should function while deploy, use contract via eth_call, eth_getCode', function (done) {

@@ -675,3 +585,2 @@ var eth = new Eth(provider); // eslint-disable-line

assert.equal(typeof accounts, 'object');
var testContractTransaction = {

@@ -682,5 +591,53 @@ from: accounts[0],

};
var contractABI = [{
'constant': false,
'inputs': [],
'name': 'setcompeltereturn',
'outputs': [{
'name': '_newValue',
'type': 'uint256'
}, {
'name': '_sender',
'type': 'address'
}],
'payable': false,
'type': 'function'
}, {
'constant': false,
'inputs': [{
'name': '_value',
'type': 'uint256'
}],
'name': 'set',
'outputs': [{
'name': '',
'type': 'bool'
}],
'payable': false,
'type': 'function'
}, {
'constant': false,
'inputs': [],
'name': 'get',
'outputs': [{
'name': 'storeValue',
'type': 'uint256'
}],
'payable': false,
'type': 'function'
}, {
'anonymous': false,
'inputs': [{
'indexed': false,
'name': '_newValue',
'type': 'uint256'
}, {
'indexed': false,
'name': '_sender',
'type': 'address'
}],
'name': 'SetComplete',
'type': 'event'
}]; // eslint-disable-line
var contractABI = [{ 'constant': false, 'inputs': [], 'name': 'setcompeltereturn', 'outputs': [{ 'name': '_newValue', 'type': 'uint256' }, { 'name': '_sender', 'type': 'address' }], 'payable': false, 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': '_value', 'type': 'uint256' }], 'name': 'set', 'outputs': [{ 'name': '', 'type': 'bool' }], 'payable': false, 'type': 'function' }, { 'constant': false, 'inputs': [], 'name': 'get', 'outputs': [{ 'name': 'storeValue', 'type': 'uint256' }], 'payable': false, 'type': 'function' }, { 'anonymous': false, 'inputs': [{ 'indexed': false, 'name': '_newValue', 'type': 'uint256' }, { 'indexed': false, 'name': '_sender', 'type': 'address' }], 'name': 'SetComplete', 'type': 'event' }]; // eslint-disable-line
eth.sendTransaction(testContractTransaction, function (error, result) {

@@ -690,3 +647,2 @@ assert.equal(error, null);

assert.equal(util.getBinarySize(result), 66);
setTimeout(function () {

@@ -696,3 +652,2 @@ eth.getTransactionReceipt(result, function (receiptError, receipt) {

assert.equal(typeof receipt, 'object');
assert.equal(util.getBinarySize(receipt.transactionHash), 66);

@@ -705,3 +660,2 @@ assert.equal(receipt.transactionIndex.toNumber(10) >= 0, true);

assert.equal(typeof receipt.contractAddress, 'string');
var uintValue = 350000;

@@ -714,3 +668,2 @@ var setMethodTransaction = {

};
eth.sendTransaction(setMethodTransaction, function (setMethodError, setMethodTx) {

@@ -720,3 +673,2 @@ assert.equal(setMethodError, null);

assert.equal(util.getBinarySize(setMethodTx), 66);
setTimeout(function () {

@@ -727,3 +679,2 @@ var callMethodTransaction = {

};
eth.call(callMethodTransaction, function (callError, callResult) {

@@ -733,9 +684,6 @@ // eslint-disable-line

var decodedUint = abi.decodeMethod(contractABI[2], callResult);
assert.equal(decodedUint[0].toNumber(10), uintValue);
eth.getCode(receipt.contractAddress, 'latest', function (codeError, codeResult) {
assert.equal(codeError, null);
assert.equal(typeof codeResult, 'string');
done();

@@ -751,5 +699,10 @@ });

});
it('should function while deploy, use contract via eth_call, eth_getCode with debug, logger', function (done) {
var eth = new Eth(provider, { debug: true, logger: { log: function log() {} }, jsonSpace: 2 }); // eslint-disable-line
var eth = new Eth(provider, {
debug: true,
logger: {
log: function log() {}
},
jsonSpace: 2
}); // eslint-disable-line

@@ -759,3 +712,2 @@ eth.accounts(function (accountsError, accounts) {

assert.equal(typeof accounts, 'object');
var testContractTransaction = {

@@ -766,5 +718,53 @@ from: accounts[0],

};
var contractABI = [{
'constant': false,
'inputs': [],
'name': 'setcompeltereturn',
'outputs': [{
'name': '_newValue',
'type': 'uint256'
}, {
'name': '_sender',
'type': 'address'
}],
'payable': false,
'type': 'function'
}, {
'constant': false,
'inputs': [{
'name': '_value',
'type': 'uint256'
}],
'name': 'set',
'outputs': [{
'name': '',
'type': 'bool'
}],
'payable': false,
'type': 'function'
}, {
'constant': false,
'inputs': [],
'name': 'get',
'outputs': [{
'name': 'storeValue',
'type': 'uint256'
}],
'payable': false,
'type': 'function'
}, {
'anonymous': false,
'inputs': [{
'indexed': false,
'name': '_newValue',
'type': 'uint256'
}, {
'indexed': false,
'name': '_sender',
'type': 'address'
}],
'name': 'SetComplete',
'type': 'event'
}]; // eslint-disable-line
var contractABI = [{ 'constant': false, 'inputs': [], 'name': 'setcompeltereturn', 'outputs': [{ 'name': '_newValue', 'type': 'uint256' }, { 'name': '_sender', 'type': 'address' }], 'payable': false, 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': '_value', 'type': 'uint256' }], 'name': 'set', 'outputs': [{ 'name': '', 'type': 'bool' }], 'payable': false, 'type': 'function' }, { 'constant': false, 'inputs': [], 'name': 'get', 'outputs': [{ 'name': 'storeValue', 'type': 'uint256' }], 'payable': false, 'type': 'function' }, { 'anonymous': false, 'inputs': [{ 'indexed': false, 'name': '_newValue', 'type': 'uint256' }, { 'indexed': false, 'name': '_sender', 'type': 'address' }], 'name': 'SetComplete', 'type': 'event' }]; // eslint-disable-line
eth.sendTransaction(testContractTransaction, function (error, result) {

@@ -774,3 +774,2 @@ assert.equal(error, null);

assert.equal(util.getBinarySize(result), 66);
setTimeout(function () {

@@ -780,3 +779,2 @@ eth.getTransactionReceipt(result, function (receiptError, receipt) {

assert.equal(typeof receipt, 'object');
assert.equal(util.getBinarySize(receipt.transactionHash), 66);

@@ -789,3 +787,2 @@ assert.equal(receipt.transactionIndex.toNumber(10) >= 0, true);

assert.equal(typeof receipt.contractAddress, 'string');
var uintValue = 350000;

@@ -798,3 +795,2 @@ var setMethodTransaction = {

};
eth.sendTransaction(setMethodTransaction, function (setMethodError, setMethodTx) {

@@ -804,3 +800,2 @@ assert.equal(setMethodError, null);

assert.equal(util.getBinarySize(setMethodTx), 66);
setTimeout(function () {

@@ -811,3 +806,2 @@ var callMethodTransaction = {

};
eth.call(callMethodTransaction, function (callError, callResult) {

@@ -817,9 +811,6 @@ // eslint-disable-line

var decodedUint = abi.decodeMethod(contractABI[2], callResult);
assert.equal(decodedUint[0].toNumber(10), uintValue);
eth.getCode(receipt.contractAddress, 'latest', function (codeError, codeResult) {
assert.equal(codeError, null);
assert.equal(typeof codeResult, 'string');
done();

@@ -826,0 +817,0 @@ });

{
"name": "@metamask/ethjs-query",
"version": "0.5.0",
"version": "0.6.0",
"description": "A simple query layer for the Ethereum RPC.",

@@ -59,3 +59,3 @@ "main": "lib/index.js",

[
"transform-es2015-template-literals",
"@babel/plugin-transform-template-literals",
{

@@ -65,8 +65,8 @@ "loose": true

],
"transform-es2015-literals",
"transform-es2015-function-name",
"transform-es2015-arrow-functions",
"transform-es2015-block-scoped-functions",
"@babel/plugin-transform-literals",
"@babel/plugin-transform-function-name",
"@babel/plugin-transform-arrow-functions",
"@babel/plugin-transform-block-scoped-functions",
[
"transform-es2015-classes",
"@babel/plugin-transform-classes",
{

@@ -76,6 +76,6 @@ "loose": true

],
"transform-es2015-object-super",
"transform-es2015-shorthand-properties",
"@babel/plugin-transform-object-super",
"@babel/plugin-transform-shorthand-properties",
[
"transform-es2015-computed-properties",
"@babel/plugin-transform-computed-properties",
{

@@ -86,3 +86,3 @@ "loose": true

[
"transform-es2015-for-of",
"@babel/plugin-transform-for-of",
{

@@ -92,7 +92,6 @@ "loose": true

],
"transform-es2015-sticky-regex",
"transform-es2015-unicode-regex",
"check-es2015-constants",
"@babel/plugin-transform-sticky-regex",
"@babel/plugin-transform-unicode-regex",
[
"transform-es2015-spread",
"@babel/plugin-transform-spread",
{

@@ -102,5 +101,5 @@ "loose": true

],
"transform-es2015-parameters",
"@babel/plugin-transform-parameters",
[
"transform-es2015-destructuring",
"@babel/plugin-transform-destructuring",
{

@@ -110,6 +109,6 @@ "loose": true

],
"transform-es2015-block-scoping",
"transform-object-rest-spread",
"transform-es3-member-expression-literals",
"transform-es3-property-literals"
"@babel/plugin-transform-block-scoping",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-transform-member-expression-literals",
"@babel/plugin-transform-property-literals"
],

@@ -120,3 +119,3 @@ "env": {

[
"transform-es2015-modules-commonjs",
"@babel/plugin-transform-modules-commonjs",
{

@@ -131,34 +130,32 @@ "loose": true

"dependencies": {
"babel-runtime": "^6.26.0",
"@metamask/ethjs-rpc": "^0.3.0",
"ethjs-format": "0.2.7",
"ethjs-rpc": "0.2.0",
"promise-to-callback": "^1.0.0"
},
"devDependencies": {
"babel-cli": "6.18.0",
"babel-core": "6.18.2",
"babel-eslint": "7.2.2",
"babel-loader": "6.2.8",
"babel-plugin-check-es2015-constants": "6.8.0",
"babel-plugin-transform-es2015-arrow-functions": "6.8.0",
"babel-plugin-transform-es2015-block-scoped-functions": "6.8.0",
"babel-plugin-transform-es2015-block-scoping": "6.18.0",
"babel-plugin-transform-es2015-classes": "6.18.0",
"babel-plugin-transform-es2015-computed-properties": "6.8.0",
"babel-plugin-transform-es2015-destructuring": "6.19.0",
"babel-plugin-transform-es2015-for-of": "6.18.0",
"babel-plugin-transform-es2015-function-name": "6.9.0",
"babel-plugin-transform-es2015-literals": "6.8.0",
"babel-plugin-transform-es2015-modules-commonjs": "6.18.0",
"babel-plugin-transform-es2015-object-super": "6.8.0",
"babel-plugin-transform-es2015-parameters": "6.18.0",
"babel-plugin-transform-es2015-shorthand-properties": "6.18.0",
"babel-plugin-transform-es2015-spread": "6.8.0",
"babel-plugin-transform-es2015-sticky-regex": "6.8.0",
"babel-plugin-transform-es2015-template-literals": "6.8.0",
"babel-plugin-transform-es2015-unicode-regex": "6.11.0",
"babel-plugin-transform-es3-member-expression-literals": "6.5.0",
"babel-plugin-transform-es3-property-literals": "6.5.0",
"babel-plugin-transform-object-rest-spread": "6.19.0",
"babel-register": "6.18.0",
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/eslint-parser": "7.11.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-transform-arrow-functions": "^7.0.0",
"@babel/plugin-transform-block-scoped-functions": "^7.0.0",
"@babel/plugin-transform-block-scoping": "^7.0.0",
"@babel/plugin-transform-classes": "^7.0.0",
"@babel/plugin-transform-computed-properties": "^7.0.0",
"@babel/plugin-transform-destructuring": "^7.0.0",
"@babel/plugin-transform-for-of": "^7.0.0",
"@babel/plugin-transform-function-name": "^7.0.0",
"@babel/plugin-transform-literals": "^7.0.0",
"@babel/plugin-transform-member-expression-literals": "^7.0.0",
"@babel/plugin-transform-modules-commonjs": "^7.0.0",
"@babel/plugin-transform-object-super": "^7.0.0",
"@babel/plugin-transform-parameters": "^7.0.0",
"@babel/plugin-transform-property-literals": "^7.0.0",
"@babel/plugin-transform-shorthand-properties": "^7.0.0",
"@babel/plugin-transform-spread": "^7.0.0",
"@babel/plugin-transform-sticky-regex": "^7.0.0",
"@babel/plugin-transform-template-literals": "^7.0.0",
"@babel/plugin-transform-unicode-regex": "^7.0.0",
"@babel/register": "^7.0.0",
"babel-loader": "^8.0.0",
"bignumber.js": "3.0.1",

@@ -182,4 +179,7 @@ "chai": "3.5.0",

"rimraf": "2.3.4",
"webpack": "2.1.0-beta.15"
"webpack": "3.12.0"
},
"peerDependencies": {
"@babel/runtime": "^7.0.0"
},
"lint-staged": {

@@ -189,3 +189,3 @@ "lint:eslint": "*.js"

"eslintConfig": {
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"extends": "airbnb",

@@ -199,2 +199,3 @@ "env": {

"ecmaVersion": 6,
"requireConfigFile": false,
"sourceType": "module"

@@ -201,0 +202,0 @@ },

const format = require('ethjs-format');
const EthRPC = require('ethjs-rpc');
const EthRPC = require('@metamask/ethjs-rpc');
const promiseToCallback = require('promise-to-callback');

@@ -4,0 +4,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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc