@parity/api
Version:
The Parity Promise-based API library for interfacing with Ethereum over RPC
504 lines (503 loc) • 20.2 kB
JavaScript
"use strict";
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var _a = require('../../format/input'), inAddress = _a.inAddress, inAddresses = _a.inAddresses, inBlockNumber = _a.inBlockNumber, inData = _a.inData, inDeriveHash = _a.inDeriveHash, inDeriveIndex = _a.inDeriveIndex, inHex = _a.inHex, inNumber16 = _a.inNumber16, inOptions = _a.inOptions;
var _b = require('../../format/output'), outAccountInfo = _b.outAccountInfo, outAddress = _b.outAddress, outAddresses = _b.outAddresses, outBlock = _b.outBlock, outBlockReceipts = _b.outBlockReceipts, outChainStatus = _b.outChainStatus, outHistogram = _b.outHistogram, outHwAccountInfo = _b.outHwAccountInfo, outNodeKind = _b.outNodeKind, outNumber = _b.outNumber, outPeers = _b.outPeers, outRecentDapps = _b.outRecentDapps, outTransaction = _b.outTransaction, outVaultMeta = _b.outVaultMeta;
var Parity = /** @class */ (function () {
function Parity(provider) {
this._provider = provider;
}
Parity.prototype.acceptNonReservedPeers = function () {
return this._provider
.send('parity_acceptNonReservedPeers');
};
Parity.prototype.accountsInfo = function () {
return this._provider
.send('parity_accountsInfo')
.then(outAccountInfo);
};
Parity.prototype.allAccountsInfo = function () {
return this._provider
.send('parity_allAccountsInfo')
.then(outAccountInfo);
};
Parity.prototype.addReservedPeer = function (enode) {
return this._provider
.send('parity_addReservedPeer', enode);
};
Parity.prototype.call = function (requests, blockNumber) {
if (blockNumber === void 0) { blockNumber = 'latest'; }
return this._provider
.send('parity_call', requests.map(function (options) { return inOptions(options); }), inBlockNumber(blockNumber));
};
Parity.prototype.chain = function () {
return this._provider
.send('parity_chain');
};
Parity.prototype.chainId = function () {
return this._provider
.send('parity_chainId');
};
Parity.prototype.chainStatus = function () {
return this._provider
.send('parity_chainStatus')
.then(outChainStatus);
};
Parity.prototype.changePassword = function (account, password, newPassword) {
return this._provider
.send('parity_changePassword', inAddress(account), password, newPassword);
};
Parity.prototype.changeVault = function (account, vaultName) {
return this._provider
.send('parity_changeVault', inAddress(account), vaultName);
};
Parity.prototype.changeVaultPassword = function (vaultName, password) {
return this._provider
.send('parity_changeVaultPassword', vaultName, password);
};
Parity.prototype.checkRequest = function (requestId) {
return this._provider
.send('parity_checkRequest', inNumber16(requestId));
};
Parity.prototype.cidV0 = function (data) {
return this._provider
.send('parity_cidV0', inData(data));
};
Parity.prototype.closeVault = function (vaultName) {
return this._provider
.send('parity_closeVault', vaultName);
};
Parity.prototype.composeTransaction = function (options) {
return this._provider
.send('parity_composeTransaction', inOptions(options));
};
Parity.prototype.consensusCapability = function () {
return this._provider
.send('parity_consensusCapability');
};
Parity.prototype.dappsList = function () {
return this._provider
.send('parity_dappsList');
};
Parity.prototype.dappsRefresh = function () {
return this._provider
.send('parity_dappsRefresh');
};
Parity.prototype.dappsUrl = function () {
return this._provider
.send('parity_dappsUrl');
};
Parity.prototype.decryptMessage = function (address, data) {
return this._provider
.send('parity_decryptMessage', inAddress(address), inHex(data));
};
Parity.prototype.defaultAccount = function () {
return this._provider
.send('parity_defaultAccount')
.then(outAddress);
};
Parity.prototype.defaultExtraData = function () {
return this._provider
.send('parity_defaultExtraData');
};
Parity.prototype.devLogs = function () {
return this._provider
.send('parity_devLogs');
};
Parity.prototype.devLogsLevels = function () {
return this._provider
.send('parity_devLogsLevels');
};
Parity.prototype.deriveAddressHash = function (address, password, hash, shouldSave) {
return this._provider
.send('parity_deriveAddressHash', inAddress(address), password, inDeriveHash(hash), !!shouldSave)
.then(outAddress);
};
Parity.prototype.deriveAddressIndex = function (address, password, index, shouldSave) {
return this._provider
.send('parity_deriveAddressIndex', inAddress(address), password, inDeriveIndex(index), !!shouldSave)
.then(outAddress);
};
Parity.prototype.dropNonReservedPeers = function () {
return this._provider
.send('parity_dropNonReservedPeers');
};
Parity.prototype.enode = function () {
return this._provider
.send('parity_enode');
};
Parity.prototype.encryptMessage = function (pubkey, data) {
return this._provider
.send('parity_encryptMessage', inHex(pubkey), inHex(data));
};
Parity.prototype.executeUpgrade = function () {
return this._provider
.send('parity_executeUpgrade');
};
Parity.prototype.exportAccount = function (address, password) {
return this._provider
.send('parity_exportAccount', inAddress(address), password);
};
Parity.prototype.extraData = function () {
return this._provider
.send('parity_extraData');
};
Parity.prototype.futureTransactions = function () {
return this._provider
.send('parity_futureTransactions');
};
Parity.prototype.gasCeilTarget = function () {
return this._provider
.send('parity_gasCeilTarget')
.then(outNumber);
};
Parity.prototype.gasFloorTarget = function () {
return this._provider
.send('parity_gasFloorTarget')
.then(outNumber);
};
Parity.prototype.gasPriceHistogram = function () {
return this._provider
.send('parity_gasPriceHistogram')
.then(outHistogram);
};
Parity.prototype.generateSecretPhrase = function () {
return this._provider
.send('parity_generateSecretPhrase');
};
Parity.prototype.getBlockHeaderByNumber = function (blockNumber) {
if (blockNumber === void 0) { blockNumber = 'latest'; }
return this._provider
.send('parity_getBlockHeaderByNumber', inBlockNumber(blockNumber))
.then(outBlock);
};
Parity.prototype.getBlockReceipts = function (blockNumber) {
if (blockNumber === void 0) { blockNumber = 'latest'; }
return this._provider
.send('parity_getBlockReceipts', inBlockNumber(blockNumber))
.then(outBlockReceipts);
};
Parity.prototype.getDappAddresses = function (dappId) {
return this._provider
.send('parity_getDappAddresses', dappId)
.then(outAddresses);
};
Parity.prototype.getDappDefaultAddress = function (dappId) {
return this._provider
.send('parity_getDappDefaultAddress', dappId)
.then(outAddress);
};
Parity.prototype.getNewDappsAddresses = function () {
return this._provider
.send('parity_getNewDappsAddresses')
.then(function (addresses) { return addresses ? addresses.map(outAddress) : null; });
};
Parity.prototype.getNewDappsDefaultAddress = function () {
return this._provider
.send('parity_getNewDappsDefaultAddress')
.then(outAddress);
};
Parity.prototype.getVaultMeta = function (vaultName) {
return this._provider
.send('parity_getVaultMeta', vaultName)
.then(outVaultMeta);
};
Parity.prototype.hardwareAccountsInfo = function () {
return this._provider
.send('parity_hardwareAccountsInfo')
.then(outHwAccountInfo);
};
Parity.prototype.lockedHardwareAccountsInfo = function () {
return this._provider
.send('parity_lockedHardwareAccountsInfo');
};
Parity.prototype.hardwarePinMatrixAck = function (path, pin) {
return this._provider
.send('parity_hardwarePinMatrixAck', path, pin);
};
Parity.prototype.hashContent = function (url) {
return this._provider
.send('parity_hashContent', url);
};
Parity.prototype.importGethAccounts = function (accounts) {
return this._provider
.send('parity_importGethAccounts', inAddresses(accounts))
.then(outAddresses);
};
Parity.prototype.killAccount = function (account, password) {
return this._provider
.send('parity_killAccount', inAddress(account), password);
};
Parity.prototype.listAccounts = function (count, offset, blockNumber) {
if (offset === void 0) { offset = null; }
if (blockNumber === void 0) { blockNumber = 'latest'; }
return this._provider
.send('parity_listAccounts', count, inAddress(offset), inBlockNumber(blockNumber))
.then(function (accounts) { return (accounts || []).map(outAddress); });
};
Parity.prototype.listOpenedVaults = function () {
return this._provider
.send('parity_listOpenedVaults');
};
Parity.prototype.listVaults = function () {
return this._provider
.send('parity_listVaults');
};
Parity.prototype.listRecentDapps = function () {
return this._provider
.send('parity_listRecentDapps')
.then(outRecentDapps);
};
Parity.prototype.listStorageKeys = function (address, count, hash, blockNumber) {
if (hash === void 0) { hash = null; }
if (blockNumber === void 0) { blockNumber = 'latest'; }
return this._provider
.send('parity_listStorageKeys', inAddress(address), count, inHex(hash), inBlockNumber(blockNumber));
};
Parity.prototype.removeAddress = function (address) {
return this._provider
.send('parity_removeAddress', inAddress(address));
};
Parity.prototype.listGethAccounts = function () {
return this._provider
.send('parity_listGethAccounts')
.then(outAddresses);
};
Parity.prototype.localTransactions = function () {
return this._provider
.send('parity_localTransactions')
.then(function (transactions) {
Object.values(transactions)
.filter(function (tx) { return tx.transaction; })
.map(function (tx) {
tx.transaction = outTransaction(tx.transaction);
});
return transactions;
});
};
Parity.prototype.minGasPrice = function () {
return this._provider
.send('parity_minGasPrice')
.then(outNumber);
};
Parity.prototype.mode = function () {
return this._provider
.send('parity_mode');
};
// DEPRECATED - use chain instead.
Parity.prototype.netChain = function () {
return this._provider
.send('parity_chain');
};
Parity.prototype.nodeHealth = function () {
return this._provider
.send('parity_nodeHealth');
};
Parity.prototype.nodeKind = function () {
return this._provider
.send('parity_nodeKind')
.then(outNodeKind);
};
Parity.prototype.netPeers = function () {
return this._provider
.send('parity_netPeers')
.then(outPeers);
};
Parity.prototype.netMaxPeers = function () {
return this._provider
.send('parity_netMaxPeers')
.then(outNumber);
};
Parity.prototype.netPort = function () {
return this._provider
.send('parity_netPort')
.then(outNumber);
};
Parity.prototype.newAccountFromPhrase = function (phrase, password) {
return this._provider
.send('parity_newAccountFromPhrase', phrase, password)
.then(outAddress);
};
Parity.prototype.newAccountFromSecret = function (secret, password) {
return this._provider
.send('parity_newAccountFromSecret', inHex(secret), password)
.then(outAddress);
};
Parity.prototype.newAccountFromWallet = function (json, password) {
return this._provider
.send('parity_newAccountFromWallet', json, password)
.then(outAddress);
};
Parity.prototype.newVault = function (vaultName, password) {
return this._provider
.send('parity_newVault', vaultName, password);
};
Parity.prototype.nextNonce = function (account) {
return this._provider
.send('parity_nextNonce', inAddress(account))
.then(outNumber);
};
Parity.prototype.nodeName = function () {
return this._provider
.send('parity_nodeName');
};
Parity.prototype.openVault = function (vaultName, password) {
return this._provider
.send('parity_openVault', vaultName, password);
};
Parity.prototype.pendingTransactions = function () {
return this._provider
.send('parity_pendingTransactions')
.then(function (data) { return data.map(outTransaction); });
};
Parity.prototype.pendingTransactionsStats = function () {
return this._provider
.send('parity_pendingTransactionsStats');
};
Parity.prototype.phraseToAddress = function (phrase) {
return this._provider
.send('parity_phraseToAddress', phrase)
.then(outAddress);
};
Parity.prototype.postSign = function (address, hash) {
return this._provider
.send('parity_postSign', inAddress(address), inHex(hash));
};
Parity.prototype.postTransaction = function (options) {
if (options === void 0) { options = {}; }
return this._provider
.send('parity_postTransaction', inOptions(options));
};
Parity.prototype.registryAddress = function () {
return this._provider
.send('parity_registryAddress')
.then(outAddress);
};
Parity.prototype.releasesInfo = function () {
return this._provider
.send('parity_releasesInfo');
};
Parity.prototype.removeReservedPeer = function (enode) {
return this._provider
.send('parity_removeReservedPeer', enode);
};
Parity.prototype.removeTransaction = function (hash) {
return this._provider
.send('parity_removeTransaction', inHex(hash))
.then(outTransaction);
};
Parity.prototype.rpcSettings = function () {
return this._provider
.send('parity_rpcSettings');
};
Parity.prototype.setAccountName = function (address, name) {
return this._provider
.send('parity_setAccountName', inAddress(address), name);
};
Parity.prototype.setAccountMeta = function (address, meta) {
return this._provider
.send('parity_setAccountMeta', inAddress(address), JSON.stringify(meta));
};
Parity.prototype.setAuthor = function (address) {
return this._provider
.send('parity_setAuthor', inAddress(address));
};
Parity.prototype.setDappAddresses = function (dappId, addresses) {
return this._provider
.send('parity_setDappAddresses', dappId, inAddresses(addresses));
};
Parity.prototype.setDappDefaultAddress = function (dappId, address) {
return this._provider
.send('parity_setDappDefaultAddress', dappId, address ? inAddress(address) : null);
};
Parity.prototype.setEngineSigner = function (address, password) {
return this._provider
.send('parity_setEngineSigner', inAddress(address), password);
};
Parity.prototype.setExtraData = function (data) {
return this._provider
.send('parity_setExtraData', inData(data));
};
Parity.prototype.setGasCeilTarget = function (quantity) {
return this._provider
.send('parity_setGasCeilTarget', inNumber16(quantity));
};
Parity.prototype.setGasFloorTarget = function (quantity) {
return this._provider
.send('parity_setGasFloorTarget', inNumber16(quantity));
};
Parity.prototype.setMaxTransactionGas = function (quantity) {
return this._provider
.send('parity_setMaxTransactionGas', inNumber16(quantity));
};
Parity.prototype.setMinGasPrice = function (quantity) {
return this._provider
.send('parity_setMinGasPrice', inNumber16(quantity));
};
Parity.prototype.setMode = function (mode) {
return this._provider
.send('parity_setMode', mode);
};
Parity.prototype.setChain = function (specName) {
return this._provider
.send('parity_setChain', specName);
};
Parity.prototype.setNewDappsAddresses = function (addresses) {
return this._provider
.send('parity_setNewDappsAddresses', addresses ? inAddresses(addresses) : null);
};
Parity.prototype.setNewDappsDefaultAddress = function (address) {
return this._provider
.send('parity_setNewDappsDefaultAddress', inAddress(address));
};
Parity.prototype.setTransactionsLimit = function (quantity) {
return this._provider
.send('parity_setTransactionsLimit', inNumber16(quantity));
};
Parity.prototype.setVaultMeta = function (vaultName, meta) {
return this._provider
.send('parity_setVaultMeta', vaultName, JSON.stringify(meta));
};
Parity.prototype.signMessage = function (address, password, messageHash) {
return this._provider
.send('parity_signMessage', inAddress(address), password, inHex(messageHash));
};
Parity.prototype.testPassword = function (account, password) {
return this._provider
.send('parity_testPassword', inAddress(account), password);
};
Parity.prototype.transactionsLimit = function () {
return this._provider
.send('parity_transactionsLimit')
.then(outNumber);
};
Parity.prototype.unsignedTransactionsCount = function () {
return this._provider
.send('parity_unsignedTransactionsCount')
.then(outNumber);
};
Parity.prototype.upgradeReady = function () {
return this._provider
.send('parity_upgradeReady');
};
Parity.prototype.versionInfo = function () {
return this._provider
.send('parity_versionInfo');
};
Parity.prototype.wsUrl = function () {
return this._provider
.send('parity_wsUrl');
};
return Parity;
}());
module.exports = Parity;