Socket
Socket
Sign inDemoInstall

web3-core-method

Package Overview
Dependencies
4
Maintainers
2
Versions
137
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0-beta.48 to 1.0.0-beta.49

LICENSE

1158

dist/web3-core-method.esm.js
import EventEmitter from 'eventemitter3';
import { NewHeadsSubscription } from 'web3-core-subscriptions';
import isString from 'lodash/isString';
import cloneDeep from 'lodash/cloneDeep';
import { PromiEvent } from 'web3-core-promievent';
import { SubscriptionsFactory } from 'web3-core-subscriptions';
import { formatters } from 'web3-core-helpers';
import * as Utils from 'web3-utils';
import { Observable } from 'rxjs';
import isFunction from 'lodash/isFunction';
class TransactionConfirmationWorkflow {
constructor(transactionReceiptValidator, newHeadsWatcher, getTransactionReceiptMethod) {
this.transactionReceiptValidator = transactionReceiptValidator;
this.newHeadsWatcher = newHeadsWatcher;
this.timeoutCounter = 0;
this.confirmationsCounter = 0;
this.getTransactionReceiptMethod = getTransactionReceiptMethod;
}
execute(method, moduleInstance, transactionHash, promiEvent) {
this.getTransactionReceiptMethod.parameters = [transactionHash];
this.getTransactionReceiptMethod.execute(moduleInstance).then(receipt => {
if (receipt && receipt.blockHash) {
const validationResult = this.transactionReceiptValidator.validate(receipt, method);
if (validationResult === true) {
this.handleSuccessState(receipt, method, promiEvent);
return;
}
this.handleErrorState(validationResult, method, promiEvent);
return;
}
this.newHeadsWatcher.watch(moduleInstance).on('newHead', () => {
this.timeoutCounter++;
if (!this.isTimeoutTimeExceeded(moduleInstance, this.newHeadsWatcher.isPolling)) {
this.getTransactionReceiptMethod.execute(moduleInstance).then(receipt => {
if (receipt && receipt.blockHash) {
const validationResult = this.transactionReceiptValidator.validate(receipt, method);
if (validationResult === true) {
this.confirmationsCounter++;
promiEvent.emit('confirmation', this.confirmationsCounter, receipt);
if (this.isConfirmed(moduleInstance)) {
this.handleSuccessState(receipt, method, promiEvent);
}
return;
}
this.handleErrorState(validationResult, method, promiEvent);
}
});
return;
}
let error = new Error(`Transaction was not mined within ${moduleInstance.transactionBlockTimeout} blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!`);
if (this.newHeadsWatcher.isPolling) {
error = new Error(`Transaction was not mined within ${moduleInstance.transactionPollingTimeout} seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!`);
}
this.handleErrorState(error, method, promiEvent);
});
class PromiEvent {
constructor() {
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
this.eventEmitter = new EventEmitter();
return new Proxy(this, {
get: this.proxyHandler
});
}
isConfirmed(moduleInstance) {
return this.confirmationsCounter === moduleInstance.transactionConfirmationBlocks;
}
isTimeoutTimeExceeded(moduleInstance, watcherIsPolling) {
let timeout = moduleInstance.transactionBlockTimeout;
if (watcherIsPolling) {
timeout = moduleInstance.transactionPollingTimeout;
proxyHandler(target, name) {
if (name === 'resolve' || name === 'reject') {
return target[name];
}
return this.timeoutCounter > timeout;
}
handleSuccessState(receipt, method, promiEvent) {
this.timeoutCounter = 0;
this.confirmationsCounter = 0;
this.newHeadsWatcher.stop();
if (method.constructor.name === 'ContractDeployMethod') {
if (method.callback) {
method.callback(false, receipt);
}
promiEvent.resolve(method.afterExecution(receipt));
promiEvent.emit('receipt', receipt);
promiEvent.removeAllListeners();
return;
if (name === 'then') {
return target.promise.then.bind(target.promise);
}
const mappedReceipt = method.afterExecution(receipt);
if (method.callback) {
method.callback(false, mappedReceipt);
if (name === 'catch') {
return target.promise.catch.bind(target.promise);
}
promiEvent.resolve(mappedReceipt);
promiEvent.emit('receipt', mappedReceipt);
promiEvent.removeAllListeners();
}
handleErrorState(error, method, promiEvent) {
this.timeoutCounter = 0;
this.confirmationsCounter = 0;
this.newHeadsWatcher.stop();
if (method.callback) {
method.callback(error, null);
if (target.eventEmitter[name]) {
return target.eventEmitter[name];
}
promiEvent.reject(error);
promiEvent.emit('error', error);
promiEvent.removeAllListeners();
}
}
class TransactionReceiptValidator {
validate(receipt, method) {
const receiptJSON = JSON.stringify(receipt, null, 2);
if (!this.isValidGasUsage(receipt, method)) {
return new Error(`Transaction ran out of gas. Please provide more gas:\n${receiptJSON}`);
}
if (!this.isValidReceiptStatus(receipt)) {
return new Error(`Transaction has been reverted by the EVM:\n${receiptJSON}`);
}
return true;
}
isValidReceiptStatus(receipt) {
return receipt.status === true || typeof receipt.status === 'undefined' || receipt.status === null;
}
isValidGasUsage(receipt, method) {
return !receipt.outOfGas && method.utils.hexToNumber(method.parameters[0].gas) !== receipt.gasUsed;
}
}
class NewHeadsWatcher extends EventEmitter {
constructor(subscriptionsFactory) {
super();
this.subscriptionsFactory = subscriptionsFactory;
this.confirmationInterval = null;
this.confirmationSubscription = null;
this.isPolling = false;
}
watch(moduleInstance) {
if (moduleInstance.currentProvider.constructor.name !== 'HttpProvider') {
this.confirmationSubscription = this.subscriptionsFactory.createNewHeadsSubscription(moduleInstance).subscribe(() => {
this.emit('newHead');
});
return this;
}
this.isPolling = true;
this.confirmationInterval = setInterval(() => {
this.emit('newHead');
}, 1000);
return this;
}
stop() {
if (this.confirmationSubscription) {
this.confirmationSubscription.unsubscribe();
}
if (this.confirmationInterval) {
clearInterval(this.confirmationInterval);
}
this.removeAllListeners('newHead');
}
}
class MethodProxy {
constructor(target, methodFactory) {
return new Proxy(target, {
get: (target, name) => {
if (methodFactory.hasMethod(name)) {
if (typeof target[name] !== 'undefined') {
throw new TypeError(`Duplicated method ${name}. This method is defined as RPC call and as Object method.`);
}
const method = methodFactory.createMethod(name);
function anonymousFunction() {
method.arguments = arguments;
if (method.Type === 'CALL') {
return method.execute(target);
}
return method.execute(target, new PromiEvent());
}
anonymousFunction.method = method;
anonymousFunction.request = function () {
method.arguments = arguments;
return method;
};
return anonymousFunction;
}
return target[name];
}
});
}
}
class AbstractMethod {
constructor(rpcMethod, parametersAmount, utils, formatters$$1) {
constructor(rpcMethod, parametersAmount, utils, formatters, moduleInstance) {
this.utils = utils;
this.formatters = formatters$$1;
this.promiEvent = new PromiEvent();
this.formatters = formatters;
this.moduleInstance = moduleInstance;
this._arguments = {

@@ -196,3 +50,23 @@ parameters: []

}
execute(moduleInstance) {}
async execute() {
this.beforeExecution(this.moduleInstance);
if (this.parameters.length !== this.parametersAmount) {
throw new Error(`Invalid Arguments length: expected: ${this.parametersAmount}, given: ${this.parameters.length}`);
}
try {
let response = await this.moduleInstance.currentProvider.send(this.rpcMethod, this.parameters);
if (response) {
response = this.afterExecution(response);
}
if (this.callback) {
this.callback(false, response);
}
return response;
} catch (error) {
if (this.callback) {
this.callback(error, null);
}
throw error;
}
}
set rpcMethod(value) {

@@ -222,3 +96,3 @@ this._rpcMethod = value;

}
set arguments(args) {
setArguments(args) {
let parameters = cloneDeep([...args]);

@@ -237,44 +111,38 @@ let callback = null;

}
get arguments() {
getArguments() {
return this._arguments;
}
isHash(parameter) {
return isString(parameter) && parameter.indexOf('0x') === 0;
return isString(parameter) && parameter.startsWith('0x');
}
}
class AbstractCallMethod extends AbstractMethod {
constructor(rpcMethod, parametersAmount, utils, formatters$$1) {
super(rpcMethod, parametersAmount, utils, formatters$$1);
class AbstractGetBlockMethod extends AbstractMethod {
constructor(rpcMethod, utils, formatters, moduleInstance) {
super(rpcMethod, 2, utils, formatters, moduleInstance);
}
static get Type() {
return 'CALL';
}
async execute(moduleInstance) {
this.beforeExecution(moduleInstance);
if (this.parameters.length !== this.parametersAmount) {
throw new Error(`Invalid Arguments length: expected: ${this.parametersAmount}, given: ${this.parameters.length}`);
beforeExecution(moduleInstance) {
this.parameters[0] = this.formatters.inputBlockNumberFormatter(this.parameters[0]);
if (isFunction(this.parameters[1])) {
this.callback = this.parameters[1];
this.parameters[1] = false;
} else {
this.parameters[1] = !!this.parameters[1];
}
try {
let response = await moduleInstance.currentProvider.send(this.rpcMethod, this.parameters);
if (response) {
response = this.afterExecution(response);
}
if (this.callback) {
this.callback(false, response);
}
return response;
} catch (error) {
if (this.callback) {
this.callback(error, null);
}
throw error;
}
}
afterExecution(response) {
return this.formatters.outputBlockFormatter(response);
}
}
class GetTransactionReceiptMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_getTransactionReceipt', 1, utils, formatters$$1);
class GetBlockByNumberMethod extends AbstractGetBlockMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_getBlockByNumber', utils, formatters, moduleInstance);
}
}
class GetTransactionReceiptMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_getTransactionReceipt', 1, utils, formatters, moduleInstance);
}
afterExecution(response) {

@@ -288,93 +156,141 @@ if (response !== null) {

class AbstractSendMethod extends AbstractMethod {
constructor(rpcMethod, parametersAmount, utils, formatters$$1, transactionConfirmationWorkflow) {
super(rpcMethod, parametersAmount, utils, formatters$$1);
this.transactionConfirmationWorkflow = transactionConfirmationWorkflow;
class TransactionObserver {
constructor(provider, timeout, blockConfirmations, getTransactionReceiptMethod, getBlockByNumberMethod, newHeadsSubscription) {
this.provider = provider;
this.timeout = timeout;
this.blockConfirmations = blockConfirmations;
this.getTransactionReceiptMethod = getTransactionReceiptMethod;
this.getBlockByNumberMethod = getBlockByNumberMethod;
this.newHeadsSubscription = newHeadsSubscription;
this.blockNumbers = [];
this.lastBlock = false;
this.confirmations = 0;
this.confirmationChecks = 0;
this.interval = false;
}
static get Type() {
return 'SEND';
observe(transactionHash) {
return Observable.create(observer => {
if (this.isSocketBasedProvider()) {
this.startSocketObserver(transactionHash, observer);
} else {
this.startHttpObserver(transactionHash, observer);
}
});
}
execute(moduleInstance, promiEvent) {
this.beforeExecution(moduleInstance);
if (this.parameters.length !== this.parametersAmount) {
throw new Error(`Invalid Arguments length: expected: ${this.parametersAmount}, given: ${this.parameters.length}`);
}
moduleInstance.currentProvider.send(this.rpcMethod, this.parameters).then(response => {
this.transactionConfirmationWorkflow.execute(this, moduleInstance, response, promiEvent);
if (this.callback) {
this.callback(false, response);
startSocketObserver(transactionHash, observer) {
this.newHeadsSubscription.subscribe(async (error, newHead) => {
try {
if (observer.closed) {
await this.newHeadsSubscription.unsubscribe();
return;
}
if (error) {
throw error;
}
this.getTransactionReceiptMethod.parameters = [transactionHash];
const receipt = await this.getTransactionReceiptMethod.execute();
if (!this.blockNumbers.includes(newHead.number)) {
if (receipt) {
this.confirmations++;
this.emitNext(receipt, observer);
if (this.isConfirmed()) {
await this.newHeadsSubscription.unsubscribe();
observer.complete();
}
}
this.blockNumbers.push(newHead.number);
this.confirmationChecks++;
if (this.isTimeoutTimeExceeded()) {
await this.newHeadsSubscription.unsubscribe();
this.emitError(new Error('Timeout exceeded during the transaction confirmation process. Be aware the transaction could still get confirmed!'), receipt, observer);
}
}
} catch (error2) {
this.emitError(error2, false, observer);
}
promiEvent.emit('transactionHash', response);
}).catch(error => {
if (this.callback) {
this.callback(error, null);
}
promiEvent.reject(error);
promiEvent.emit('error', error);
promiEvent.removeAllListeners();
});
return promiEvent;
}
}
class SendRawTransactionMethod extends AbstractSendMethod {
constructor(utils, formatters$$1, transactionConfirmationWorkflow) {
super('eth_sendRawTransaction', 1, utils, formatters$$1, transactionConfirmationWorkflow);
startHttpObserver(transactionHash, observer) {
const interval = setInterval(async () => {
try {
if (observer.closed) {
clearInterval(interval);
return;
}
this.getTransactionReceiptMethod.parameters = [transactionHash];
const receipt = await this.getTransactionReceiptMethod.execute();
if (receipt) {
if (this.lastBlock) {
const block = await this.getBlockByNumber(this.increaseBlockNumber(this.lastBlock.number));
if (block && this.isValidConfirmation(block)) {
this.lastBlock = block;
this.confirmations++;
this.emitNext(receipt, observer);
}
} else {
this.lastBlock = await this.getBlockByNumber(receipt.blockNumber);
this.confirmations++;
this.emitNext(receipt, observer);
}
if (this.isConfirmed()) {
clearInterval(interval);
observer.complete();
}
}
this.confirmationChecks++;
if (this.isTimeoutTimeExceeded()) {
clearInterval(interval);
this.emitError(new Error('Timeout exceeded during the transaction confirmation process. Be aware the transaction could still get confirmed!'), receipt, observer);
}
} catch (error) {
clearInterval(interval);
this.emitError(error, false, observer);
}
}, 1000);
}
}
class ModuleFactory {
constructor(subscriptionsFactory, utils, formatters$$1) {
this.subscriptionsFactory = subscriptionsFactory;
this.formatters = formatters$$1;
this.utils = utils;
emitNext(receipt, observer) {
observer.next({
receipt,
confirmations: this.confirmations
});
}
createMethodProxy(target, methodFactory) {
return new MethodProxy(target, methodFactory);
emitError(error, receipt, observer) {
observer.error({
error,
receipt,
confirmations: this.confirmations,
confirmationChecks: this.confirmationChecks
});
}
createTransactionConfirmationWorkflow() {
return new TransactionConfirmationWorkflow(this.createTransactionReceiptValidator(), this.createNewHeadsWatcher(), new GetTransactionReceiptMethod(this.utils, this.formatters));
getBlockByNumber(blockHash) {
this.getBlockByNumberMethod.parameters = [blockHash];
return this.getBlockByNumberMethod.execute();
}
createTransactionReceiptValidator() {
return new TransactionReceiptValidator();
isConfirmed() {
return this.confirmations === this.blockConfirmations;
}
createNewHeadsWatcher() {
return new NewHeadsWatcher(this.subscriptionsFactory);
isValidConfirmation(block) {
return this.lastBlock.hash === block.parentHash && this.lastBlock.number !== block.number;
}
createSendRawTransactionMethod() {
return new SendRawTransactionMethod(this.utils, this.formatters, this.createTransactionConfirmationWorkflow());
isTimeoutTimeExceeded() {
return this.confirmationChecks === this.timeout;
}
}
class GetTransactionCountMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_getTransactionCount', 2, utils, formatters$$1);
}
beforeExecution(moduleInstance) {
this.parameters[0] = this.formatters.inputAddressFormatter(this.parameters[0]);
if (isFunction(this.parameters[1])) {
this.callback = this.parameters[1];
this.parameters[1] = moduleInstance.defaultBlock;
isSocketBasedProvider() {
switch (this.provider.constructor.name) {
case 'CustomProvider':
case 'HttpProvider':
return false;
default:
return true;
}
this.parameters[1] = this.formatters.inputDefaultBlockNumberFormatter(this.parameters[1], moduleInstance);
}
afterExecution(response) {
return this.utils.hexToNumber(response);
increaseBlockNumber(blockNumber) {
return '0x' + (parseInt(blockNumber, 16) + 1).toString(16);
}
}
class ChainIdMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_chainId', 0, utils, formatters$$1);
}
afterExecution(response) {
return this.utils.hexToNumber(response);
}
}
class AbstractMethodFactory {
constructor(methodModuleFactory, utils, formatters$$1) {
this.methodModuleFactory = methodModuleFactory;
constructor(utils, formatters) {
this.utils = utils;
this.formatters = formatters$$1;
this.formatters = formatters;
this._methods = null;

@@ -394,27 +310,52 @@ }

}
createMethod(name) {
createMethod(name, moduleInstance) {
const method = this.methods[name];
switch (method.Type) {
case 'CALL':
return new method(this.utils, this.formatters);
case 'SEND':
if (method.name === 'SendTransactionMethod') {
const transactionConfirmationWorkflow = this.methodModuleFactory.createTransactionConfirmationWorkflow();
return new method(this.utils, this.formatters, transactionConfirmationWorkflow, new SendRawTransactionMethod(this.utils, this.formatters, transactionConfirmationWorkflow), new ChainIdMethod(this.utils, this.formatters), new GetTransactionCountMethod(this.utils, this.formatters));
}
return new method(this.utils, this.formatters, this.methodModuleFactory.createTransactionConfirmationWorkflow());
if (method.Type === 'observed-transaction-method') {
let timeout = moduleInstance.transactionBlockTimeout;
const providerName = moduleInstance.currentProvider.constructor.name;
if (providerName === 'HttpProvider' || providerName === 'CustomProvider') {
timeout = moduleInstance.transactionPollingTimeout;
}
return new method(this.utils, this.formatters, moduleInstance, new TransactionObserver(moduleInstance.currentProvider, timeout, moduleInstance.transactionConfirmationBlocks, new GetTransactionReceiptMethod(this.utils, this.formatters, moduleInstance), new GetBlockByNumberMethod(this.utils, this.formatters, moduleInstance), new NewHeadsSubscription(this.utils, this.formatters, moduleInstance)));
}
return new method(this.utils, this.formatters, moduleInstance);
}
}
class GetProtocolVersionMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_protocolVersion', 0, utils, formatters$$1);
class MethodProxy {
constructor(target, methodFactory) {
return new Proxy(target, {
get: (target, name) => {
if (methodFactory.hasMethod(name)) {
if (typeof target[name] !== 'undefined') {
throw new TypeError(`Duplicated method ${name}. This method is defined as RPC call and as Object method.`);
}
const method = methodFactory.createMethod(name, target);
function anonymousFunction() {
method.setArguments(arguments);
return method.execute();
}
anonymousFunction.method = method;
anonymousFunction.request = function () {
method.setArguments(arguments);
return method;
};
return anonymousFunction;
}
return target[name];
}
});
}
}
class VersionMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('net_version', 0, utils, formatters$$1);
class GetProtocolVersionMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_protocolVersion', 0, utils, formatters, moduleInstance);
}
}
class VersionMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('net_version', 0, utils, formatters, moduleInstance);
}
afterExecution(response) {

@@ -425,11 +366,11 @@ return this.utils.hexToNumber(response);

class ListeningMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('net_listening', 0, utils, formatters$$1);
class ListeningMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('net_listening', 0, utils, formatters, moduleInstance);
}
}
class PeerCountMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('net_peerCount', 0, utils, formatters$$1);
class PeerCountMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('net_peerCount', 0, utils, formatters, moduleInstance);
}

@@ -441,24 +382,33 @@ afterExecution(response) {

class GetNodeInfoMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('web3_clientVersion', 0, utils, formatters$$1);
class ChainIdMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_chainId', 0, utils, formatters, moduleInstance);
}
afterExecution(response) {
return this.utils.hexToNumber(response);
}
}
class GetCoinbaseMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_coinbase', 0, utils, formatters$$1);
class GetNodeInfoMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('web3_clientVersion', 0, utils, formatters, moduleInstance);
}
}
class IsMiningMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_mining', 0, utils, formatters$$1);
class GetCoinbaseMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_coinbase', 0, utils, formatters, moduleInstance);
}
}
class GetHashrateMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_hashrate', 0, utils, formatters$$1);
class IsMiningMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_mining', 0, utils, formatters, moduleInstance);
}
}
class GetHashrateMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_hashrate', 0, utils, formatters, moduleInstance);
}
afterExecution(response) {

@@ -469,5 +419,5 @@ return this.utils.hexToNumber(response);

class IsSyncingMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_syncing', 0, utils, formatters$$1);
class IsSyncingMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_syncing', 0, utils, formatters, moduleInstance);
}

@@ -482,5 +432,5 @@ afterExecution(response) {

class GetGasPriceMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_gasPrice', 0, utils, formatters$$1);
class GetGasPriceMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_gasPrice', 0, utils, formatters, moduleInstance);
}

@@ -492,17 +442,17 @@ afterExecution(response) {

class SubmitWorkMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_submitWork', 3, utils, formatters$$1);
class SubmitWorkMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_submitWork', 3, utils, formatters, moduleInstance);
}
}
class GetWorkMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_getWork', 0, utils, formatters$$1);
class GetWorkMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_getWork', 0, utils, formatters, moduleInstance);
}
}
class GetAccountsMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_accounts', 0, utils, formatters$$1);
class GetAccountsMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_accounts', 0, utils, formatters, moduleInstance);
}

@@ -516,5 +466,5 @@ afterExecution(response) {

class GetBalanceMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_getBalance', 2, utils, formatters$$1);
class GetBalanceMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_getBalance', 2, utils, formatters, moduleInstance);
}

@@ -534,11 +484,13 @@ beforeExecution(moduleInstance) {

class RequestAccountsMethod extends AbstractCallMethod {
constructor() {
super('eth_requestAccounts', 0, null, null);
class GetTransactionCountMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_getTransactionCount', 2, utils, formatters, moduleInstance);
}
}
class GetBlockNumberMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_blockNumber', 0, utils, formatters$$1);
beforeExecution(moduleInstance) {
this.parameters[0] = this.formatters.inputAddressFormatter(this.parameters[0]);
if (isFunction(this.parameters[1])) {
this.callback = this.parameters[1];
this.parameters[1] = moduleInstance.defaultBlock;
}
this.parameters[1] = this.formatters.inputDefaultBlockNumberFormatter(this.parameters[1], moduleInstance);
}

@@ -550,17 +502,15 @@ afterExecution(response) {

class GetBlockMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_getBlockByNumber', 2, utils, formatters$$1);
class RequestAccountsMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_requestAccounts', 0, utils, formatters, moduleInstance);
}
}
class AbstractGetUncleMethod extends AbstractMethod {
constructor(rpcMethod, utils, formatters, moduleInstance) {
super(rpcMethod, 2, utils, formatters, moduleInstance);
}
beforeExecution(moduleInstance) {
if (this.isHash(this.parameters[0])) {
this.rpcMethod = 'eth_getBlockByHash';
}
this.parameters[0] = this.formatters.inputBlockNumberFormatter(this.parameters[0]);
if (isFunction(this.parameters[1])) {
this.callback = this.parameters[1];
this.parameters[1] = false;
} else {
this.parameters[1] = !!this.parameters[1];
}
this.parameters[1] = this.utils.numberToHex(this.parameters[1]);
}

@@ -572,26 +522,19 @@ afterExecution(response) {

class GetUncleMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_getUncleByBlockNumberAndIndex', 2, utils, formatters$$1);
class AbstractGetBlockTransactionCountMethod extends AbstractMethod {
constructor(rpcMethod, utils, formatters, moduleInstance) {
super(rpcMethod, 1, utils, formatters, moduleInstance);
}
beforeExecution(moduleInstance) {
if (this.isHash(this.parameters[0])) {
this.rpcMethod = 'eth_getUncleByBlockHashAndIndex';
}
this.parameters[0] = this.formatters.inputBlockNumberFormatter(this.parameters[0]);
this.parameters[1] = this.utils.numberToHex(this.parameters[1]);
}
afterExecution(response) {
return this.formatters.outputBlockFormatter(response);
return this.utils.hexToNumber(response);
}
}
class GetBlockTransactionCountMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_getBlockTransactionCountByNumber', 1, utils, formatters$$1);
class AbstractGetBlockUncleCountMethod extends AbstractMethod {
constructor(rpcMethod, utils, formatters, moduleInstance) {
super(rpcMethod, 1, utils, formatters, moduleInstance);
}
beforeExecution(moduleInstance) {
if (this.isHash(this.parameters[0])) {
this.rpcMethod = 'eth_getBlockTransactionCountByHash';
}
this.parameters[0] = this.formatters.inputBlockNumberFormatter(this.parameters[0]);

@@ -604,11 +547,11 @@ }

class GetBlockUncleCountMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_getUncleCountByBlockNumber', 1, utils, formatters$$1);
class GetBlockByHashMethod extends AbstractGetBlockMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_getBlockByHash', utils, formatters, moduleInstance);
}
beforeExecution(moduleInstance) {
if (this.isHash(this.parameters[0])) {
this.rpcMethod = 'eth_getUncleCountByBlockHash';
}
this.parameters[0] = this.formatters.inputBlockNumberFormatter(this.parameters[0]);
}
class GetBlockNumberMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_blockNumber', 0, utils, formatters, moduleInstance);
}

@@ -620,19 +563,43 @@ afterExecution(response) {

class GetTransactionMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_getTransactionByHash', 1, utils, formatters$$1);
class GetBlockTransactionCountByHashMethod extends AbstractGetBlockTransactionCountMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_getBlockTransactionCountByHash', utils, formatters, moduleInstance);
}
afterExecution(response) {
return this.formatters.outputTransactionFormatter(response);
}
class GetBlockTransactionCountByNumberMethod extends AbstractGetBlockTransactionCountMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_getBlockTransactionCountByNumber', utils, formatters, moduleInstance);
}
}
class GetTransactionFromBlockMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_getTransactionByBlockNumberAndIndex', 2, utils, formatters$$1);
class GetBlockUncleCountByBlockHashMethod extends AbstractGetBlockUncleCountMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_getUncleCountByBlockHash', utils, formatters, moduleInstance);
}
}
class GetBlockUncleCountByBlockNumberMethod extends AbstractGetBlockUncleCountMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_getUncleCountByBlockNumber', utils, formatters, moduleInstance);
}
}
class GetUncleByBlockHashAndIndexMethod extends AbstractGetUncleMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_getUncleByBlockHashAndIndex', utils, formatters, moduleInstance);
}
}
class GetUncleByBlockNumberAndIndexMethod extends AbstractGetUncleMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_getUncleByBlockNumberAndIndex', utils, formatters, moduleInstance);
}
}
class AbstractGetTransactionFromBlockMethod extends AbstractMethod {
constructor(rpcMethod, utils, formatters, moduleInstance) {
super(rpcMethod, 2, utils, formatters, moduleInstance);
}
beforeExecution(moduleInstance) {
if (this.isHash(this.parameters[0])) {
this.rpcMethod = 'eth_getTransactionByBlockHashAndIndex';
}
this.parameters[0] = this.formatters.inputBlockNumberFormatter(this.parameters[0]);

@@ -646,6 +613,70 @@ this.parameters[1] = this.utils.numberToHex(this.parameters[1]);

class SignTransactionMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_signTransaction', 1, utils, formatters$$1);
class AbstractObservedTransactionMethod extends AbstractMethod {
constructor(rpcMethod, parametersAmount, utils, formatters, moduleInstance, transactionObserver) {
super(rpcMethod, parametersAmount, utils, formatters, moduleInstance);
this.transactionObserver = transactionObserver;
this.promiEvent = new PromiEvent();
}
static get Type() {
return 'observed-transaction-method';
}
execute() {
this.beforeExecution(this.moduleInstance);
this.moduleInstance.currentProvider.send(this.rpcMethod, this.parameters).then(transactionHash => {
let confirmations, receipt;
if (this.callback) {
this.callback(false, transactionHash);
return;
}
this.promiEvent.emit('transactionHash', transactionHash);
const transactionConfirmationSubscription = this.transactionObserver.observe(transactionHash).subscribe(transactionConfirmation => {
confirmations = transactionConfirmation.confirmations;
receipt = transactionConfirmation.receipt;
if (this.hasRevertReceiptStatus(receipt)) {
if (this.parameters[0].gas === receipt.gasUsed) {
this.handleError(new Error(`Transaction ran out of gas. Please provide more gas:\n${JSON.stringify(receipt, null, 2)}`), receipt, confirmations);
transactionConfirmationSubscription.unsubscribe();
return;
}
this.handleError(new Error(`Transaction has been reverted by the EVM:\n${JSON.stringify(receipt, null, 2)}`), receipt, confirmations);
transactionConfirmationSubscription.unsubscribe();
return;
}
this.promiEvent.emit('confirmation', confirmations, this.afterExecution(receipt));
}, error => {
this.handleError(error, receipt, confirmations);
}, () => {
if (this.promiEvent.listenerCount('receipt') > 0) {
this.promiEvent.emit('receipt', this.afterExecution(receipt));
this.promiEvent.removeAllListeners();
return;
}
this.promiEvent.resolve(this.afterExecution(receipt));
});
}).catch(error => {
if (this.callback) {
this.callback(error, null);
return;
}
this.handleError(error, false, 0);
});
return this.promiEvent;
}
handleError(error, receipt, confirmations) {
if (this.promiEvent.listenerCount('error') > 0) {
this.promiEvent.emit('error', error, receipt, confirmations);
this.promiEvent.removeAllListeners();
return;
}
this.promiEvent.reject(error);
}
hasRevertReceiptStatus(receipt) {
return Boolean(parseInt(receipt.status)) === false && receipt.status !== undefined && receipt.status !== null;
}
}
class SendTransactionMethod extends AbstractObservedTransactionMethod {
constructor(utils, formatters, moduleInstance, transactionObserver) {
super('eth_sendTransaction', 1, utils, formatters, moduleInstance, transactionObserver);
}
beforeExecution(moduleInstance) {

@@ -656,82 +687,107 @@ this.parameters[0] = this.formatters.inputTransactionFormatter(this.parameters[0], moduleInstance);

class SendTransactionMethod extends AbstractSendMethod {
constructor(utils, formatters$$1, transactionConfirmationWorkflow, sendRawTransactionMethod, chainIdMethod, getTransactionCountMethod) {
super('eth_sendTransaction', 1, utils, formatters$$1, transactionConfirmationWorkflow);
this.sendRawTransactionMethod = sendRawTransactionMethod;
class EthSendTransactionMethod extends SendTransactionMethod {
constructor(utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod, sendRawTransactionMethod) {
super(utils, formatters, moduleInstance, transactionObserver);
this.chainIdMethod = chainIdMethod;
this.getTransactionCountMethod = getTransactionCountMethod;
this.sendRawTransactionMethod = sendRawTransactionMethod;
}
beforeExecution(moduleInstance) {
this.parameters[0] = this.formatters.inputTransactionFormatter(this.parameters[0], moduleInstance);
}
execute(moduleInstance, promiEvent) {
if (!this.parameters[0].gas && moduleInstance.defaultGas) {
this.parameters[0]['gas'] = moduleInstance.defaultGas;
execute() {
if (!this.parameters[0].gas && this.moduleInstance.defaultGas) {
this.parameters[0]['gas'] = this.moduleInstance.defaultGas;
}
if (!this.parameters[0].gasPrice) {
if (!moduleInstance.defaultGasPrice) {
moduleInstance.currentProvider.send('eth_gasPrice', []).then(gasPrice => {
if (!this.moduleInstance.defaultGasPrice) {
this.moduleInstance.currentProvider.send('eth_gasPrice', []).then(gasPrice => {
this.parameters[0].gasPrice = gasPrice;
this.execute(moduleInstance, promiEvent);
this.execute();
}).catch(error => {
this.handleError(error, false, 0);
});
return promiEvent;
return this.promiEvent;
}
this.parameters[0]['gasPrice'] = moduleInstance.defaultGasPrice;
this.parameters[0]['gasPrice'] = this.moduleInstance.defaultGasPrice;
}
if (this.hasAccounts(moduleInstance) && this.isDefaultSigner(moduleInstance)) {
if (moduleInstance.accounts.wallet[this.parameters[0].from]) {
this.sendRawTransaction(moduleInstance.accounts.wallet[this.parameters[0].from].privateKey, promiEvent, moduleInstance).catch(error => {
if (this.callback) {
this.callback(error, null);
}
promiEvent.reject(error);
promiEvent.emit('error', error);
promiEvent.removeAllListeners();
if (this.hasAccounts() && this.isDefaultSigner()) {
if (this.moduleInstance.accounts.wallet[this.parameters[0].from]) {
this.sendRawTransaction(this.moduleInstance.accounts.wallet[this.parameters[0].from].privateKey).catch(error => {
this.handleError(error, false, 0);
});
return promiEvent;
return this.promiEvent;
}
}
if (this.hasCustomSigner(moduleInstance)) {
this.sendRawTransaction(null, promiEvent, moduleInstance).catch(error => {
if (this.callback) {
this.callback(error, null);
}
promiEvent.reject(error);
promiEvent.emit('error', error);
promiEvent.removeAllListeners();
if (this.hasCustomSigner()) {
this.sendRawTransaction().catch(error => {
this.handleError(error, false, 0);
});
return promiEvent;
return this.promiEvent;
}
super.execute(moduleInstance, promiEvent);
return promiEvent;
return super.execute();
}
async sendRawTransaction(privateKey, promiEvent, moduleInstance) {
async sendRawTransaction(privateKey = null) {
if (!this.parameters[0].chainId) {
this.parameters[0].chainId = await this.chainIdMethod.execute(moduleInstance);
this.parameters[0].chainId = await this.chainIdMethod.execute();
}
if (!this.parameters[0].nonce && this.parameters[0].nonce !== 0) {
this.getTransactionCountMethod.parameters = [this.parameters[0].from];
this.parameters[0].nonce = await this.getTransactionCountMethod.execute(moduleInstance);
this.parameters[0].nonce = await this.getTransactionCountMethod.execute();
}
const response = await moduleInstance.transactionSigner.sign(this.parameters[0], privateKey);
const response = await this.moduleInstance.transactionSigner.sign(this.parameters[0], privateKey);
this.sendRawTransactionMethod.parameters = [response.rawTransaction];
this.sendRawTransactionMethod.callback = this.callback;
this.sendRawTransactionMethod.execute(moduleInstance, promiEvent);
this.sendRawTransactionMethod.promiEvent = this.promiEvent;
return this.sendRawTransactionMethod.execute();
}
isDefaultSigner(moduleInstance) {
return moduleInstance.transactionSigner.constructor.name === 'TransactionSigner';
isDefaultSigner() {
return this.moduleInstance.transactionSigner.constructor.name === 'TransactionSigner';
}
hasAccounts(moduleInstance) {
return moduleInstance.accounts && moduleInstance.accounts.accountsIndex > 0;
hasAccounts() {
return this.moduleInstance.accounts && this.moduleInstance.accounts.accountsIndex > 0;
}
hasCustomSigner(moduleInstance) {
return moduleInstance.transactionSigner.constructor.name !== 'TransactionSigner';
hasCustomSigner() {
return this.moduleInstance.transactionSigner.constructor.name !== 'TransactionSigner';
}
}
class GetCodeMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_getCode', 2, utils, formatters$$1);
class GetTransactionMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_getTransactionByHash', 1, utils, formatters, moduleInstance);
}
afterExecution(response) {
return this.formatters.outputTransactionFormatter(response);
}
}
class GetTransactionByBlockHashAndIndexMethod extends AbstractGetTransactionFromBlockMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_getTransactionByBlockHashAndIndex', utils, formatters, moduleInstance);
}
}
class GetTransactionByBlockNumberAndIndexMethod extends AbstractGetTransactionFromBlockMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_getTransactionByBlockNumberAndIndex', utils, formatters, moduleInstance);
}
}
class SendRawTransactionMethod extends AbstractObservedTransactionMethod {
constructor(utils, formatters, moduleInstance, transactionObserver) {
super('eth_sendRawTransaction', 1, utils, formatters, moduleInstance, transactionObserver);
}
}
class SignTransactionMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_signTransaction', 1, utils, formatters, moduleInstance);
}
beforeExecution(moduleInstance) {
this.parameters[0] = this.formatters.inputTransactionFormatter(this.parameters[0], moduleInstance);
}
}
class GetCodeMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_getCode', 2, utils, formatters, moduleInstance);
}
beforeExecution(moduleInstance) {
this.parameters[0] = this.formatters.inputAddressFormatter(this.parameters[0]);

@@ -746,27 +802,6 @@ if (isFunction(this.parameters[1])) {

class SignMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_sign', 2, utils, formatters$$1);
class SignMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_sign', 2, utils, formatters, moduleInstance);
}
execute(moduleInstance) {
if (this.hasAccount(moduleInstance)) {
return this.signLocally(moduleInstance);
}
return super.execute(moduleInstance);
}
async signLocally(moduleInstance) {
try {
this.beforeExecution(moduleInstance);
let signedMessage = moduleInstance.accounts.sign(this.parameters[0], moduleInstance.accounts.wallet[this.parameters[1]].address);
if (this.callback) {
this.callback(false, signedMessage);
}
return signedMessage;
} catch (error) {
if (this.callback) {
this.callback(error, null);
}
throw error;
}
}
beforeExecution(moduleInstance) {

@@ -776,10 +811,7 @@ this.parameters[0] = this.formatters.inputSignFormatter(this.parameters[0]);

}
hasAccount(moduleInstance) {
return moduleInstance.accounts && moduleInstance.accounts.accountsIndex > 0 && moduleInstance.accounts.wallet[this.parameters[1]];
}
}
class CallMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_call', 2, utils, formatters$$1);
class CallMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_call', 2, utils, formatters, moduleInstance);
}

@@ -796,5 +828,5 @@ beforeExecution(moduleInstance) {

class GetStorageAtMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_getStorageAt', 3, utils, formatters$$1);
class GetStorageAtMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_getStorageAt', 3, utils, formatters, moduleInstance);
}

@@ -812,5 +844,5 @@ beforeExecution(moduleInstance) {

class EstimateGasMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_estimateGas', 1, utils, formatters$$1);
class EstimateGasMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_estimateGas', 1, utils, formatters, moduleInstance);
}

@@ -825,5 +857,5 @@ beforeExecution(moduleInstance) {

class GetPastLogsMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('eth_getLogs', 1, utils, formatters$$1);
class GetPastLogsMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('eth_getLogs', 1, utils, formatters, moduleInstance);
}

@@ -840,5 +872,5 @@ beforeExecution(moduleInstance) {

class EcRecoverMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('personal_ecRecover', 3, utils, formatters$$1);
class EcRecoverMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('personal_ecRecover', 3, utils, formatters, moduleInstance);
}

@@ -850,11 +882,11 @@ beforeExecution(moduleInstance) {

class ImportRawKeyMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('personal_importRawKey', 2, utils, formatters$$1);
class ImportRawKeyMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('personal_importRawKey', 2, utils, formatters, moduleInstance);
}
}
class ListAccountsMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('personal_listAccounts', 0, utils, formatters$$1);
class ListAccountsMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('personal_listAccounts', 0, utils, formatters, moduleInstance);
}

@@ -868,5 +900,5 @@ afterExecution(response) {

class LockAccountMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('personal_lockAccount', 1, utils, formatters$$1);
class LockAccountMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('personal_lockAccount', 1, utils, formatters, moduleInstance);
}

@@ -878,5 +910,5 @@ beforeExecution(moduleInstance) {

class NewAccountMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('personal_newAccount', 1, utils, formatters$$1);
class NewAccountMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('personal_newAccount', 1, utils, formatters, moduleInstance);
}

@@ -888,5 +920,5 @@ afterExecution(response) {

class PersonalSendTransactionMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('personal_sendTransaction', 2, utils, formatters$$1);
class PersonalSendTransactionMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('personal_sendTransaction', 2, utils, formatters, moduleInstance);
}

@@ -898,5 +930,5 @@ beforeExecution(moduleInstance) {

class PersonalSignMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('personal_sign', 3, utils, formatters$$1);
class PersonalSignMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('personal_sign', 3, utils, formatters, moduleInstance);
}

@@ -909,5 +941,5 @@ beforeExecution(moduleInstance) {

class PersonalSignTransactionMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('personal_signTransaction', 2, utils, formatters$$1);
class PersonalSignTransactionMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('personal_signTransaction', 2, utils, formatters, moduleInstance);
}

@@ -919,5 +951,5 @@ beforeExecution(moduleInstance) {

class UnlockAccountMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('personal_unlockAccount', 3, utils, formatters$$1);
class UnlockAccountMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('personal_unlockAccount', 3, utils, formatters, moduleInstance);
}

@@ -929,132 +961,128 @@ beforeExecution(moduleInstance) {

class AddPrivateKeyMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_addPrivateKey', 1, utils, formatters$$1);
class AddPrivateKeyMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_addPrivateKey', 1, utils, formatters, moduleInstance);
}
}
class AddSymKeyMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_addSymKey', 1, utils, formatters$$1);
class AddSymKeyMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_addSymKey', 1, utils, formatters, moduleInstance);
}
}
class DeleteKeyPairMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_deleteKeyPair', 1, utils, formatters$$1);
class DeleteKeyPairMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_deleteKeyPair', 1, utils, formatters, moduleInstance);
}
}
class DeleteMessageFilterMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_deleteMessageFilter', 1, utils, formatters$$1);
class DeleteMessageFilterMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_deleteMessageFilter', 1, utils, formatters, moduleInstance);
}
}
class DeleteSymKeyMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_deleteSymKey', 1, utils, formatters$$1);
class DeleteSymKeyMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_deleteSymKey', 1, utils, formatters, moduleInstance);
}
}
class GenerateSymKeyFromPasswordMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_generateSymKeyFromPassword', 1, utils, formatters$$1);
class GenerateSymKeyFromPasswordMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_generateSymKeyFromPassword', 1, utils, formatters, moduleInstance);
}
}
class GetFilterMessagesMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_getFilterMessages', 1, utils, formatters$$1);
class GetFilterMessagesMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_getFilterMessages', 1, utils, formatters, moduleInstance);
}
}
class GetInfoMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_info', 0, utils, formatters$$1);
class GetInfoMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_info', 0, utils, formatters, moduleInstance);
}
}
class GetPrivateKeyMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_getPrivateKey', 1, utils, formatters$$1);
class GetPrivateKeyMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_getPrivateKey', 1, utils, formatters, moduleInstance);
}
}
class GetPublicKeyMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_getPublicKey', 1, utils, formatters$$1);
class GetPublicKeyMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_getPublicKey', 1, utils, formatters, moduleInstance);
}
}
class GetSymKeyMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_getSymKey', 1, utils, formatters$$1);
class GetSymKeyMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_getSymKey', 1, utils, formatters, moduleInstance);
}
}
class HasKeyPairMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_hasKeyPair', 1, utils, formatters$$1);
class HasKeyPairMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_hasKeyPair', 1, utils, formatters, moduleInstance);
}
}
class HasSymKeyMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_hasSymKey', 1, utils, formatters$$1);
class HasSymKeyMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_hasSymKey', 1, utils, formatters, moduleInstance);
}
}
class MarkTrustedPeerMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_markTrustedPeer', 1, utils, formatters$$1);
class MarkTrustedPeerMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_markTrustedPeer', 1, utils, formatters, moduleInstance);
}
}
class NewKeyPairMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_newKeyPair', 1, utils, formatters$$1);
class NewKeyPairMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_newKeyPair', 0, utils, formatters, moduleInstance);
}
}
class NewMessageFilterMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_newMessageFilter', 1, utils, formatters$$1);
class NewMessageFilterMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_newMessageFilter', 1, utils, formatters, moduleInstance);
}
}
class NewSymKeyMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_newSymKey', 0, utils, formatters$$1);
class NewSymKeyMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_newSymKey', 0, utils, formatters, moduleInstance);
}
}
class PostMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_post', 1, utils, formatters$$1);
class PostMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_post', 1, utils, formatters, moduleInstance);
}
}
class SetMaxMessageSizeMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_setMaxMessageSize', 1, utils, formatters$$1);
class SetMaxMessageSizeMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_setMaxMessageSize', 1, utils, formatters, moduleInstance);
}
}
class SetMinPoWMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_setMinPoW', 1, utils, formatters$$1);
class SetMinPoWMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_setMinPoW', 1, utils, formatters, moduleInstance);
}
}
class ShhVersionMethod extends AbstractCallMethod {
constructor(utils, formatters$$1) {
super('shh_version', 0, utils, formatters$$1);
class ShhVersionMethod extends AbstractMethod {
constructor(utils, formatters, moduleInstance) {
super('shh_version', 0, utils, formatters, moduleInstance);
}
}
const MethodModuleFactory = () => {
return new ModuleFactory(new SubscriptionsFactory(), Utils, formatters);
};
export { MethodModuleFactory, AbstractMethod, AbstractMethodFactory, GetProtocolVersionMethod, VersionMethod, ListeningMethod, PeerCountMethod, ChainIdMethod, GetNodeInfoMethod, GetCoinbaseMethod, IsMiningMethod, GetHashrateMethod, IsSyncingMethod, GetGasPriceMethod, SubmitWorkMethod, GetWorkMethod, GetAccountsMethod, GetBalanceMethod, GetTransactionCountMethod, RequestAccountsMethod, GetBlockNumberMethod, GetBlockMethod, GetUncleMethod, GetBlockTransactionCountMethod, GetBlockUncleCountMethod, GetTransactionMethod, GetTransactionFromBlockMethod, GetTransactionReceiptMethod as GetTransactionReceipt, SendRawTransactionMethod, SignTransactionMethod, SendTransactionMethod, GetCodeMethod, SignMethod, CallMethod, GetStorageAtMethod, EstimateGasMethod, GetPastLogsMethod, EcRecoverMethod, ImportRawKeyMethod, ListAccountsMethod, LockAccountMethod, NewAccountMethod, PersonalSendTransactionMethod, PersonalSignMethod, PersonalSignTransactionMethod, UnlockAccountMethod, AddPrivateKeyMethod, AddSymKeyMethod, DeleteKeyPairMethod, DeleteMessageFilterMethod, DeleteSymKeyMethod, GenerateSymKeyFromPasswordMethod, GetFilterMessagesMethod, GetInfoMethod, GetPrivateKeyMethod, GetPublicKeyMethod, GetSymKeyMethod, HasKeyPairMethod, HasSymKeyMethod, MarkTrustedPeerMethod, NewKeyPairMethod, NewMessageFilterMethod, NewSymKeyMethod, PostMethod, SetMaxMessageSizeMethod, SetMinPoWMethod, ShhVersionMethod };
export { PromiEvent, AbstractMethodFactory, AbstractMethod, MethodProxy, TransactionObserver, GetProtocolVersionMethod, VersionMethod, ListeningMethod, PeerCountMethod, ChainIdMethod, GetNodeInfoMethod, GetCoinbaseMethod, IsMiningMethod, GetHashrateMethod, IsSyncingMethod, GetGasPriceMethod, SubmitWorkMethod, GetWorkMethod, GetAccountsMethod, GetBalanceMethod, GetTransactionCountMethod, RequestAccountsMethod, AbstractGetBlockMethod, AbstractGetUncleMethod, AbstractGetBlockTransactionCountMethod, AbstractGetBlockUncleCountMethod, GetBlockByHashMethod, GetBlockByNumberMethod, GetBlockNumberMethod, GetBlockTransactionCountByHashMethod, GetBlockTransactionCountByNumberMethod, GetBlockUncleCountByBlockHashMethod, GetBlockUncleCountByBlockNumberMethod, GetUncleByBlockHashAndIndexMethod, GetUncleByBlockNumberAndIndexMethod, AbstractGetTransactionFromBlockMethod, AbstractObservedTransactionMethod, EthSendTransactionMethod, GetTransactionMethod, GetTransactionByBlockHashAndIndexMethod, GetTransactionByBlockNumberAndIndexMethod, GetTransactionReceiptMethod, SendRawTransactionMethod, SignTransactionMethod, SendTransactionMethod, GetCodeMethod, SignMethod, CallMethod, GetStorageAtMethod, EstimateGasMethod, GetPastLogsMethod, EcRecoverMethod, ImportRawKeyMethod, ListAccountsMethod, LockAccountMethod, NewAccountMethod, PersonalSendTransactionMethod, PersonalSignMethod, PersonalSignTransactionMethod, UnlockAccountMethod, AddPrivateKeyMethod, AddSymKeyMethod, DeleteKeyPairMethod, DeleteMessageFilterMethod, DeleteSymKeyMethod, GenerateSymKeyFromPasswordMethod, GetFilterMessagesMethod, GetInfoMethod, GetPrivateKeyMethod, GetPublicKeyMethod, GetSymKeyMethod, HasKeyPairMethod, HasSymKeyMethod, MarkTrustedPeerMethod, NewKeyPairMethod, NewMessageFilterMethod, NewSymKeyMethod, PostMethod, SetMaxMessageSizeMethod, SetMinPoWMethod, ShhVersionMethod };
{
"name": "web3-core-method",
"namespace": "ethereum",
"version": "1.0.0-beta.48",
"description": "Handles the JSON-RPC methods. This package is internally used by web3.",
"version": "1.0.0-beta.49",
"description": "Handles the JSON-RPC methods. This package is also internally used by web3.",
"repository": "https://github.com/ethereum/web3.js/tree/1.0/packages/web3-core-method",

@@ -22,12 +22,13 @@ "license": "LGPL-3.0",

"eventemitter3": "3.1.0",
"lodash": "^4.17.11",
"web3-core": "1.0.0-beta.48",
"web3-core-helpers": "1.0.0-beta.48",
"web3-core-promievent": "1.0.0-beta.48",
"web3-core-subscriptions": "1.0.0-beta.48",
"web3-utils": "1.0.0-beta.48"
"lodash": "^4.17.11"
},
"devDependencies": {
"dtslint": "^0.4.2",
"web3-providers": "1.0.0-beta.48"
"definitelytyped-header-parser": "^1.0.1",
"dtslint": "0.4.2",
"rxjs": "^6.4.0",
"web3-core": "1.0.0-beta.49",
"web3-core-helpers": "1.0.0-beta.49",
"web3-core-subscriptions": "1.0.0-beta.49",
"web3-providers": "1.0.0-beta.49",
"web3-utils": "1.0.0-beta.49"
},

@@ -37,3 +38,4 @@ "files": [

"types/index.d.ts"
]
],
"gitHead": "eb1452cdd1591e0f26ff0f66df68ee0feb3f8c47"
}

@@ -13,93 +13,2 @@ # web3-core-method

## Exported classes
``` js
MethodModuleFactory
AbstractMethod
AbstractMethodFactory
/**
* Methods
*/
// Network
GetProtocolVersionMethod
VersionMethod
ListeningMethod
PeerCountMethod
// Node
GetNodeInfoMethod
GetCoinbaseMethod
IsMiningMethod
GetHashrateMethod
IsSyncingMethod
GetGasPriceMethod
SubmitWorkMethod
GetWorkMethod
// Account
GetAccountsMethod
GetBalanceMethod
GetTransactionCountMethod
RequestAccountsMethod
// Block
GetBlockNumberMethod
GetBlockMethod
GetUncleMethod
GetBlockTransactionCountMethod
GetBlockUncleCountMethod
// Transaction
GetTransactionMethod
GetTransactionFromBlockMethod
GetTransactionReceipt
SendRawTransactionMethod
SignTransactionMethod
SendTransactionMethod
// Global
GetCodeMethod
SignMethod
CallMethod
GetStorageAtMethod
EstimateGasMethod
GetPastLogsMethod
// Personal
EcRecoverMethod
ImportRawKeyMethod
ListAccountsMethod
LockAccountMethod
NewAccountMethod
PersonalSendTransactionMethod
PersonalSignMethod
PersonalSignTransactionMethod
UnlockAccountMethod
// SHH
AddPrivateKeyMethod
AddSymKeyMethod
DeleteKeyPairMethod
DeleteMessageFilterMethod
DeleteSymKeyMethod
GenerateSymKeyFromPasswordMethod
GetFilterMessagesMethod
GetInfoMethod
GetPrivateKeyMethod
GetPublicKeyMethod
GetSymKeyMethod
HasKeyPairMethod
HasSymKeyMethod
MarkTrustedPeerMethod
NewKeyPairMethod
NewMessageFilterMethod
NewSymKeyMethod
PostMethod
SetMaxMessageSizeMethod
SetMinPoWMethod
ShhVersionMethod
```
## Types

@@ -106,0 +15,0 @@

@@ -25,3 +25,9 @@ /*

export class AbstractMethod {
constructor(rpcMethod: string, parametersAmount: number, utils: Utils, formatters: formatters);
constructor(
rpcMethod: string,
parametersAmount: number,
utils: Utils,
formatters: formatters,
moduleInstance: AbstractWeb3Module
);

@@ -34,4 +40,9 @@ utils: Utils;

parameters: any[];
arguments: object;
getArguments(): any;
setArguments(args: any[]): void;
isHash(parameter: string): boolean;
hasWallets(): boolean;

@@ -45,3 +56,3 @@

execute(moduleInstance: AbstractWeb3Module): Promise<object|string>|PromiEvent<any>|string;
execute(): Promise<any> | PromiEvent<any> | string;

@@ -51,2 +62,9 @@ clearSubscriptions(unsubscribeMethod: string): Promise<boolean | Error>;

export class MethodModuleFactory { } // TODO: Define methods
export class AbstractMethodFactory {
constructor(utils: Utils, formatters: formatters);
methods: null | object;
hasMethod: boolean;
createMethod(name: string, moduleInstance: AbstractWeb3Module): AbstractMethod;
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc