@zilliqa-js/core
Advanced tools
Comparing version 0.8.1-alpha.2 to 0.8.1
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
// This file is part of Zilliqa-Javascript-Library. | ||
@@ -16,3 +16,3 @@ // | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
// this constant is used to indicate the number of times to poll the | ||
@@ -24,2 +24,2 @@ // blockchain for a transaction confirmation. this number has been selected by | ||
exports.GET_TX_ATTEMPTS = 33; | ||
//# sourceMappingURL=constants.js.map | ||
//# sourceMappingURL=constants.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
// This file is part of Zilliqa-Javascript-Library. | ||
@@ -16,5 +16,5 @@ // | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var sign_1 = require("./sign"); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var sign_1 = require('./sign'); | ||
exports.sign = sign_1.sign; | ||
//# sourceMappingURL=index.js.map | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
// This file is part of Zilliqa-Javascript-Library. | ||
@@ -16,4 +16,4 @@ // | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var tslib_1 = require('tslib'); | ||
/** | ||
@@ -30,27 +30,34 @@ * sign | ||
*/ | ||
exports.sign = function (target, key, descriptor) { | ||
var original = descriptor.value; | ||
function interceptor(arg) { | ||
var args = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
args[_i - 1] = arguments[_i]; | ||
exports.sign = function(target, key, descriptor) { | ||
var original = descriptor.value; | ||
function interceptor(arg) { | ||
var args = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
args[_i - 1] = arguments[_i]; | ||
} | ||
return tslib_1.__awaiter(this, void 0, void 0, function() { | ||
var signed; | ||
return tslib_1.__generator(this, function(_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!(original && arg.bytes)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.signer.sign(arg)]; | ||
case 1: | ||
signed = _a.sent(); | ||
return [ | ||
2 /*return*/, | ||
original.call.apply( | ||
original, | ||
tslib_1.__spread([this, signed], args), | ||
), | ||
]; | ||
case 2: | ||
return [2 /*return*/]; | ||
} | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var signed; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!(original && arg.bytes)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.signer.sign(arg)]; | ||
case 1: | ||
signed = _a.sent(); | ||
return [2 /*return*/, original.call.apply(original, tslib_1.__spread([this, signed], args))]; | ||
case 2: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
descriptor.value = interceptor; | ||
return descriptor; | ||
}); | ||
}); | ||
} | ||
descriptor.value = interceptor; | ||
return descriptor; | ||
}; | ||
//# sourceMappingURL=sign.js.map | ||
//# sourceMappingURL=sign.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
// This file is part of Zilliqa-Javascript-Library. | ||
@@ -16,49 +16,49 @@ // | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var tslib_1 = require('tslib'); | ||
var Errors; | ||
(function (Errors) { | ||
// Unknown Error | ||
Errors["UNKNOWN_ERROR"] = "UNKNOWN_ERROR"; | ||
// Not implemented | ||
Errors["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED"; | ||
// Missing new operator to an object | ||
// - name: The name of the class | ||
Errors["MISSING_NEW"] = "MISSING_NEW"; | ||
// Call exception | ||
// - transaction: the transaction | ||
// - address?: the contract address | ||
// - args?: The arguments passed into the function | ||
// - method?: The Solidity method signature | ||
Errors["CALL_EXCEPTION"] = "CALL_EXCEPTION"; | ||
Errors["TIMED_OUT"] = "TIMED_OUT"; | ||
// Invalid argument (e.g. value is incompatible with type) to a function: | ||
// - arg: The argument name that was invalid | ||
// - value: The value of the argument | ||
Errors["INVALID_ARGUMENT"] = "INVALID_ARGUMENT"; | ||
// Missing argument to a function: | ||
// - count: The number of arguments received | ||
// - expectedCount: The number of arguments expected | ||
Errors["MISSING_ARGUMENT"] = "MISSING_ARGUMENT"; | ||
// Too many arguments | ||
// - count: The number of arguments received | ||
// - expectedCount: The number of arguments expected | ||
Errors["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT"; | ||
// Numeric Fault | ||
// - operation: the operation being executed | ||
// - fault: the reason this faulted | ||
Errors["NUMERIC_FAULT"] = "NUMERIC_FAULT"; | ||
// Insufficien funds (< value + gasLimit * gasPrice) | ||
// - transaction: the transaction attempted | ||
Errors["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS"; | ||
// Nonce has already been used | ||
// - transaction: the transaction attempted | ||
Errors["NONCE_EXPIRED"] = "NONCE_EXPIRED"; | ||
// The replacement fee for the transaction is too low | ||
// - transaction: the transaction attempted | ||
Errors["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED"; | ||
// Unsupported operation | ||
// - operation | ||
Errors["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION"; | ||
})(Errors = exports.Errors || (exports.Errors = {})); | ||
(function(Errors) { | ||
// Unknown Error | ||
Errors['UNKNOWN_ERROR'] = 'UNKNOWN_ERROR'; | ||
// Not implemented | ||
Errors['NOT_IMPLEMENTED'] = 'NOT_IMPLEMENTED'; | ||
// Missing new operator to an object | ||
// - name: The name of the class | ||
Errors['MISSING_NEW'] = 'MISSING_NEW'; | ||
// Call exception | ||
// - transaction: the transaction | ||
// - address?: the contract address | ||
// - args?: The arguments passed into the function | ||
// - method?: The Solidity method signature | ||
Errors['CALL_EXCEPTION'] = 'CALL_EXCEPTION'; | ||
Errors['TIMED_OUT'] = 'TIMED_OUT'; | ||
// Invalid argument (e.g. value is incompatible with type) to a function: | ||
// - arg: The argument name that was invalid | ||
// - value: The value of the argument | ||
Errors['INVALID_ARGUMENT'] = 'INVALID_ARGUMENT'; | ||
// Missing argument to a function: | ||
// - count: The number of arguments received | ||
// - expectedCount: The number of arguments expected | ||
Errors['MISSING_ARGUMENT'] = 'MISSING_ARGUMENT'; | ||
// Too many arguments | ||
// - count: The number of arguments received | ||
// - expectedCount: The number of arguments expected | ||
Errors['UNEXPECTED_ARGUMENT'] = 'UNEXPECTED_ARGUMENT'; | ||
// Numeric Fault | ||
// - operation: the operation being executed | ||
// - fault: the reason this faulted | ||
Errors['NUMERIC_FAULT'] = 'NUMERIC_FAULT'; | ||
// Insufficien funds (< value + gasLimit * gasPrice) | ||
// - transaction: the transaction attempted | ||
Errors['INSUFFICIENT_FUNDS'] = 'INSUFFICIENT_FUNDS'; | ||
// Nonce has already been used | ||
// - transaction: the transaction attempted | ||
Errors['NONCE_EXPIRED'] = 'NONCE_EXPIRED'; | ||
// The replacement fee for the transaction is too low | ||
// - transaction: the transaction attempted | ||
Errors['REPLACEMENT_UNDERPRICED'] = 'REPLACEMENT_UNDERPRICED'; | ||
// Unsupported operation | ||
// - operation | ||
Errors['UNSUPPORTED_OPERATION'] = 'UNSUPPORTED_OPERATION'; | ||
})((Errors = exports.Errors || (exports.Errors = {}))); | ||
/** | ||
@@ -71,15 +71,17 @@ * ZjsError | ||
*/ | ||
var ZjsError = /** @class */ (function (_super) { | ||
tslib_1.__extends(ZjsError, _super); | ||
function ZjsError(message, reason, code, params) { | ||
if (params === void 0) { params = {}; } | ||
var _this = _super.call(this, message) || this; | ||
_this.reason = ''; | ||
_this.reason = reason; | ||
_this.code = code; | ||
_this.params = params; | ||
return _this; | ||
var ZjsError = /** @class */ (function(_super) { | ||
tslib_1.__extends(ZjsError, _super); | ||
function ZjsError(message, reason, code, params) { | ||
if (params === void 0) { | ||
params = {}; | ||
} | ||
return ZjsError; | ||
}(Error)); | ||
var _this = _super.call(this, message) || this; | ||
_this.reason = ''; | ||
_this.reason = reason; | ||
_this.code = code; | ||
_this.params = params; | ||
return _this; | ||
} | ||
return ZjsError; | ||
})(Error); | ||
exports.ZjsError = ZjsError; | ||
@@ -99,16 +101,19 @@ /** | ||
*/ | ||
exports.createError = function (reason, code, params) { | ||
if (code === void 0) { code = "UNKNOWN_ERROR" /* UNKNOWN_ERROR */; } | ||
if (params === void 0) { params = {}; } | ||
var details = Object.keys(params).map(function (key) { | ||
try { | ||
return key + "=" + JSON.stringify(params[key]); | ||
} | ||
catch (error) { | ||
return key + "=" + JSON.stringify(params[key].toString()); | ||
} | ||
}); | ||
var message = reason + " (" + details.join(', ') + ")"; | ||
return new ZjsError(message, reason, code, params); | ||
exports.createError = function(reason, code, params) { | ||
if (code === void 0) { | ||
code = 'UNKNOWN_ERROR' /* UNKNOWN_ERROR */; | ||
} | ||
if (params === void 0) { | ||
params = {}; | ||
} | ||
var details = Object.keys(params).map(function(key) { | ||
try { | ||
return key + '=' + JSON.stringify(params[key]); | ||
} catch (error) { | ||
return key + '=' + JSON.stringify(params[key].toString()); | ||
} | ||
}); | ||
var message = reason + ' (' + details.join(', ') + ')'; | ||
return new ZjsError(message, reason, code, params); | ||
}; | ||
//# sourceMappingURL=errors.js.map | ||
//# sourceMappingURL=errors.js.map |
@@ -1,71 +0,70 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var mitt_1 = tslib_1.__importDefault(require("mitt")); | ||
var EventEmitter = /** @class */ (function () { | ||
function EventEmitter() { | ||
var _this = this; | ||
this.handlers = {}; | ||
this.emitter = new mitt_1.default(this.handlers); | ||
this.off = this.emitter.off.bind(this); | ||
this.emit = this.emitter.emit.bind(this); | ||
// tslint:disable-next-line: no-empty | ||
this.promise = new Promise(function (resolve, reject) { | ||
_this.resolve = resolve; | ||
_this.reject = reject; | ||
}); | ||
this.then = this.promise.then.bind(this.promise); | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var tslib_1 = require('tslib'); | ||
var mitt_1 = tslib_1.__importDefault(require('mitt')); | ||
var EventEmitter = /** @class */ (function() { | ||
function EventEmitter() { | ||
var _this = this; | ||
this.handlers = {}; | ||
this.emitter = new mitt_1.default(this.handlers); | ||
this.off = this.emitter.off.bind(this); | ||
this.emit = this.emitter.emit.bind(this); | ||
// tslint:disable-next-line: no-empty | ||
this.promise = new Promise(function(resolve, reject) { | ||
_this.resolve = resolve; | ||
_this.reject = reject; | ||
}); | ||
this.then = this.promise.then.bind(this.promise); | ||
} | ||
EventEmitter.prototype.resetHandlers = function() { | ||
// tslint:disable-next-line: forin | ||
for (var i in this.handlers) { | ||
delete this.handlers[i]; | ||
} | ||
EventEmitter.prototype.resetHandlers = function () { | ||
// tslint:disable-next-line: forin | ||
for (var i in this.handlers) { | ||
delete this.handlers[i]; | ||
} | ||
}; | ||
EventEmitter.prototype.on = function (type, handler) { | ||
this.emitter.on(type, handler); | ||
return this; | ||
}; | ||
EventEmitter.prototype.once = function (type, handler) { | ||
var _this = this; | ||
this.emitter.on(type, function (e) { | ||
handler(e); | ||
_this.removeEventListener(type); | ||
}); | ||
}; | ||
EventEmitter.prototype.addEventListener = function (type, handler) { | ||
this.emitter.on(type, handler); | ||
}; | ||
EventEmitter.prototype.removeEventListener = function (type, handler) { | ||
if (!type) { | ||
this.handlers = {}; | ||
return; | ||
} | ||
if (!handler) { | ||
delete this.handlers[type]; | ||
} | ||
else { | ||
return this.emitter.off(type, handler); | ||
} | ||
}; | ||
EventEmitter.prototype.onError = function (error) { | ||
this.emitter.on('error', error); | ||
this.removeEventListener('*'); | ||
}; | ||
EventEmitter.prototype.onData = function (data) { | ||
this.emitter.on('data', data); | ||
this.removeEventListener('*'); | ||
}; | ||
EventEmitter.prototype.listenerCount = function (listenKey) { | ||
var count = 0; | ||
Object.keys(this.handlers).forEach(function (val) { | ||
if (listenKey === val) { | ||
count += 1; | ||
} | ||
}); | ||
return count; | ||
}; | ||
return EventEmitter; | ||
}()); | ||
}; | ||
EventEmitter.prototype.on = function(type, handler) { | ||
this.emitter.on(type, handler); | ||
return this; | ||
}; | ||
EventEmitter.prototype.once = function(type, handler) { | ||
var _this = this; | ||
this.emitter.on(type, function(e) { | ||
handler(e); | ||
_this.removeEventListener(type); | ||
}); | ||
}; | ||
EventEmitter.prototype.addEventListener = function(type, handler) { | ||
this.emitter.on(type, handler); | ||
}; | ||
EventEmitter.prototype.removeEventListener = function(type, handler) { | ||
if (!type) { | ||
this.handlers = {}; | ||
return; | ||
} | ||
if (!handler) { | ||
delete this.handlers[type]; | ||
} else { | ||
return this.emitter.off(type, handler); | ||
} | ||
}; | ||
EventEmitter.prototype.onError = function(error) { | ||
this.emitter.on('error', error); | ||
this.removeEventListener('*'); | ||
}; | ||
EventEmitter.prototype.onData = function(data) { | ||
this.emitter.on('data', data); | ||
this.removeEventListener('*'); | ||
}; | ||
EventEmitter.prototype.listenerCount = function(listenKey) { | ||
var count = 0; | ||
Object.keys(this.handlers).forEach(function(val) { | ||
if (listenKey === val) { | ||
count += 1; | ||
} | ||
}); | ||
return count; | ||
}; | ||
return EventEmitter; | ||
})(); | ||
exports.EventEmitter = EventEmitter; | ||
//# sourceMappingURL=eventEmitter.js.map | ||
//# sourceMappingURL=eventEmitter.js.map |
@@ -242,2 +242,3 @@ import fetch from 'cross-fetch'; | ||
RPCMethod["GetSmartContractState"] = "GetSmartContractState"; | ||
RPCMethod["GetSmartContractSubState"] = "GetSmartContractSubState"; | ||
RPCMethod["GetContractAddressFromTransactionID"] = "GetContractAddressFromTransactionID"; | ||
@@ -244,0 +245,0 @@ // Account-related methods |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
// This file is part of Zilliqa-Javascript-Library. | ||
@@ -16,11 +16,11 @@ // | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./types"), exports); | ||
tslib_1.__exportStar(require("./decorators"), exports); | ||
tslib_1.__exportStar(require("./net"), exports); | ||
tslib_1.__exportStar(require("./util"), exports); | ||
tslib_1.__exportStar(require("./providers/http"), exports); | ||
tslib_1.__exportStar(require("./constants"), exports); | ||
tslib_1.__exportStar(require("./eventEmitter"), exports); | ||
//# sourceMappingURL=index.js.map | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var tslib_1 = require('tslib'); | ||
tslib_1.__exportStar(require('./types'), exports); | ||
tslib_1.__exportStar(require('./decorators'), exports); | ||
tslib_1.__exportStar(require('./net'), exports); | ||
tslib_1.__exportStar(require('./util'), exports); | ||
tslib_1.__exportStar(require('./providers/http'), exports); | ||
tslib_1.__exportStar(require('./constants'), exports); | ||
tslib_1.__exportStar(require('./eventEmitter'), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -243,2 +243,3 @@ (function (global, factory) { | ||
RPCMethod["GetSmartContractState"] = "GetSmartContractState"; | ||
RPCMethod["GetSmartContractSubState"] = "GetSmartContractSubState"; | ||
RPCMethod["GetContractAddressFromTransactionID"] = "GetContractAddressFromTransactionID"; | ||
@@ -245,0 +246,0 @@ // Account-related methods |
@@ -36,2 +36,3 @@ import { WithRequest } from './util'; | ||
GetSmartContractState = "GetSmartContractState", | ||
GetSmartContractSubState = "GetSmartContractSubState", | ||
GetContractAddressFromTransactionID = "GetContractAddressFromTransactionID", | ||
@@ -38,0 +39,0 @@ GetBalance = "GetBalance" |
220
dist/net.js
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
// This file is part of Zilliqa-Javascript-Library. | ||
@@ -16,5 +16,5 @@ // | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var cross_fetch_1 = tslib_1.__importDefault(require("cross-fetch")); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var tslib_1 = require('tslib'); | ||
var cross_fetch_1 = tslib_1.__importDefault(require('cross-fetch')); | ||
/** | ||
@@ -24,98 +24,124 @@ * blockchain-side. | ||
var RPCMethod; | ||
(function (RPCMethod) { | ||
// Network-related methods | ||
RPCMethod["GetNetworkId"] = "GetNetworkId"; | ||
// Blockchain-related methods | ||
RPCMethod["GetBlockchainInfo"] = "GetBlockchainInfo"; | ||
RPCMethod["GetShardingStructure"] = "GetShardingStructure"; | ||
RPCMethod["GetDSBlock"] = "GetDsBlock"; | ||
RPCMethod["GetLatestDSBlock"] = "GetLatestDsBlock"; | ||
RPCMethod["GetNumDSBlocks"] = "GetNumDSBlocks"; | ||
RPCMethod["GetDSBlockRate"] = "GetDSBlockRate"; | ||
RPCMethod["DSBlockListing"] = "DSBlockListing"; | ||
RPCMethod["GetTxBlock"] = "GetTxBlock"; | ||
RPCMethod["GetLatestTxBlock"] = "GetLatestTxBlock"; | ||
RPCMethod["GetNumTxBlocks"] = "GetNumTxBlocks"; | ||
RPCMethod["GetTxBlockRate"] = "GetTxBlockRate"; | ||
RPCMethod["TxBlockListing"] = "TxBlockListing"; | ||
RPCMethod["GetNumTransactions"] = "GetNumTransactions"; | ||
RPCMethod["GetTransactionRate"] = "GetTransactionRate"; | ||
RPCMethod["GetCurrentMiniEpoch"] = "GetCurrentMiniEpoch"; | ||
RPCMethod["GetCurrentDSEpoch"] = "GetCurrentDSEpoch"; | ||
RPCMethod["GetPrevDifficulty"] = "GetPrevDifficulty"; | ||
RPCMethod["GetPrevDSDifficulty"] = "GetPrevDSDifficulty"; | ||
// Transaction-related methods | ||
RPCMethod["CreateTransaction"] = "CreateTransaction"; | ||
RPCMethod["GetTransaction"] = "GetTransaction"; | ||
RPCMethod["GetRecentTransactions"] = "GetRecentTransactions"; | ||
RPCMethod["GetTransactionsForTxBlock"] = "GetTransactionsForTxBlock"; | ||
RPCMethod["GetNumTxnsTxEpoch"] = "GetNumTxnsTxEpoch"; | ||
RPCMethod["GetNumTxnsDSEpoch"] = "GetNumTxnsDSEpoch"; | ||
RPCMethod["GetMinimumGasPrice"] = "GetMinimumGasPrice"; | ||
// Contract-related methods | ||
RPCMethod["GetSmartContracts"] = "GetSmartContracts"; | ||
RPCMethod["GetSmartContractCode"] = "GetSmartContractCode"; | ||
RPCMethod["GetSmartContractInit"] = "GetSmartContractInit"; | ||
RPCMethod["GetSmartContractState"] = "GetSmartContractState"; | ||
RPCMethod["GetContractAddressFromTransactionID"] = "GetContractAddressFromTransactionID"; | ||
// Account-related methods | ||
RPCMethod["GetBalance"] = "GetBalance"; | ||
})(RPCMethod = exports.RPCMethod || (exports.RPCMethod = {})); | ||
(function(RPCMethod) { | ||
// Network-related methods | ||
RPCMethod['GetNetworkId'] = 'GetNetworkId'; | ||
// Blockchain-related methods | ||
RPCMethod['GetBlockchainInfo'] = 'GetBlockchainInfo'; | ||
RPCMethod['GetShardingStructure'] = 'GetShardingStructure'; | ||
RPCMethod['GetDSBlock'] = 'GetDsBlock'; | ||
RPCMethod['GetLatestDSBlock'] = 'GetLatestDsBlock'; | ||
RPCMethod['GetNumDSBlocks'] = 'GetNumDSBlocks'; | ||
RPCMethod['GetDSBlockRate'] = 'GetDSBlockRate'; | ||
RPCMethod['DSBlockListing'] = 'DSBlockListing'; | ||
RPCMethod['GetTxBlock'] = 'GetTxBlock'; | ||
RPCMethod['GetLatestTxBlock'] = 'GetLatestTxBlock'; | ||
RPCMethod['GetNumTxBlocks'] = 'GetNumTxBlocks'; | ||
RPCMethod['GetTxBlockRate'] = 'GetTxBlockRate'; | ||
RPCMethod['TxBlockListing'] = 'TxBlockListing'; | ||
RPCMethod['GetNumTransactions'] = 'GetNumTransactions'; | ||
RPCMethod['GetTransactionRate'] = 'GetTransactionRate'; | ||
RPCMethod['GetCurrentMiniEpoch'] = 'GetCurrentMiniEpoch'; | ||
RPCMethod['GetCurrentDSEpoch'] = 'GetCurrentDSEpoch'; | ||
RPCMethod['GetPrevDifficulty'] = 'GetPrevDifficulty'; | ||
RPCMethod['GetPrevDSDifficulty'] = 'GetPrevDSDifficulty'; | ||
// Transaction-related methods | ||
RPCMethod['CreateTransaction'] = 'CreateTransaction'; | ||
RPCMethod['GetTransaction'] = 'GetTransaction'; | ||
RPCMethod['GetRecentTransactions'] = 'GetRecentTransactions'; | ||
RPCMethod['GetTransactionsForTxBlock'] = 'GetTransactionsForTxBlock'; | ||
RPCMethod['GetNumTxnsTxEpoch'] = 'GetNumTxnsTxEpoch'; | ||
RPCMethod['GetNumTxnsDSEpoch'] = 'GetNumTxnsDSEpoch'; | ||
RPCMethod['GetMinimumGasPrice'] = 'GetMinimumGasPrice'; | ||
// Contract-related methods | ||
RPCMethod['GetSmartContracts'] = 'GetSmartContracts'; | ||
RPCMethod['GetSmartContractCode'] = 'GetSmartContractCode'; | ||
RPCMethod['GetSmartContractInit'] = 'GetSmartContractInit'; | ||
RPCMethod['GetSmartContractState'] = 'GetSmartContractState'; | ||
RPCMethod['GetSmartContractSubState'] = 'GetSmartContractSubState'; | ||
RPCMethod['GetContractAddressFromTransactionID'] = | ||
'GetContractAddressFromTransactionID'; | ||
// Account-related methods | ||
RPCMethod['GetBalance'] = 'GetBalance'; | ||
})((RPCMethod = exports.RPCMethod || (exports.RPCMethod = {}))); | ||
var RPCErrorCode; | ||
(function (RPCErrorCode) { | ||
// Standard JSON-RPC 2.0 errors | ||
// RPC_INVALID_REQUEST is internally mapped to HTTP_BAD_REQUEST (400). | ||
// It should not be used for application-layer errors. | ||
RPCErrorCode[RPCErrorCode["RPC_INVALID_REQUEST"] = -32600] = "RPC_INVALID_REQUEST"; | ||
// RPC_METHOD_NOT_FOUND is internally mapped to HTTP_NOT_FOUND (404). | ||
// It should not be used for application-layer errors. | ||
RPCErrorCode[RPCErrorCode["RPC_METHOD_NOT_FOUND"] = -32601] = "RPC_METHOD_NOT_FOUND"; | ||
RPCErrorCode[RPCErrorCode["RPC_INVALID_PARAMS"] = -32602] = "RPC_INVALID_PARAMS"; | ||
// RPC_INTERNAL_ERROR should only be used for genuine errors in bitcoind | ||
// (for example datadir corruption). | ||
RPCErrorCode[RPCErrorCode["RPC_INTERNAL_ERROR"] = -32603] = "RPC_INTERNAL_ERROR"; | ||
RPCErrorCode[RPCErrorCode["RPC_PARSE_ERROR"] = -32700] = "RPC_PARSE_ERROR"; | ||
// General application defined errors | ||
RPCErrorCode[RPCErrorCode["RPC_MISC_ERROR"] = -1] = "RPC_MISC_ERROR"; | ||
RPCErrorCode[RPCErrorCode["RPC_TYPE_ERROR"] = -3] = "RPC_TYPE_ERROR"; | ||
RPCErrorCode[RPCErrorCode["RPC_INVALID_ADDRESS_OR_KEY"] = -5] = "RPC_INVALID_ADDRESS_OR_KEY"; | ||
RPCErrorCode[RPCErrorCode["RPC_INVALID_PARAMETER"] = -8] = "RPC_INVALID_PARAMETER"; | ||
RPCErrorCode[RPCErrorCode["RPC_DATABASE_ERROR"] = -20] = "RPC_DATABASE_ERROR"; | ||
RPCErrorCode[RPCErrorCode["RPC_DESERIALIZATION_ERROR"] = -22] = "RPC_DESERIALIZATION_ERROR"; | ||
RPCErrorCode[RPCErrorCode["RPC_VERIFY_ERROR"] = -25] = "RPC_VERIFY_ERROR"; | ||
RPCErrorCode[RPCErrorCode["RPC_VERIFY_REJECTED"] = -26] = "RPC_VERIFY_REJECTED"; | ||
RPCErrorCode[RPCErrorCode["RPC_IN_WARMUP"] = -28] = "RPC_IN_WARMUP"; | ||
RPCErrorCode[RPCErrorCode["RPC_METHOD_DEPRECATED"] = -32] = "RPC_METHOD_DEPRECATED"; | ||
})(RPCErrorCode = exports.RPCErrorCode || (exports.RPCErrorCode = {})); | ||
(function(RPCErrorCode) { | ||
// Standard JSON-RPC 2.0 errors | ||
// RPC_INVALID_REQUEST is internally mapped to HTTP_BAD_REQUEST (400). | ||
// It should not be used for application-layer errors. | ||
RPCErrorCode[(RPCErrorCode['RPC_INVALID_REQUEST'] = -32600)] = | ||
'RPC_INVALID_REQUEST'; | ||
// RPC_METHOD_NOT_FOUND is internally mapped to HTTP_NOT_FOUND (404). | ||
// It should not be used for application-layer errors. | ||
RPCErrorCode[(RPCErrorCode['RPC_METHOD_NOT_FOUND'] = -32601)] = | ||
'RPC_METHOD_NOT_FOUND'; | ||
RPCErrorCode[(RPCErrorCode['RPC_INVALID_PARAMS'] = -32602)] = | ||
'RPC_INVALID_PARAMS'; | ||
// RPC_INTERNAL_ERROR should only be used for genuine errors in bitcoind | ||
// (for example datadir corruption). | ||
RPCErrorCode[(RPCErrorCode['RPC_INTERNAL_ERROR'] = -32603)] = | ||
'RPC_INTERNAL_ERROR'; | ||
RPCErrorCode[(RPCErrorCode['RPC_PARSE_ERROR'] = -32700)] = 'RPC_PARSE_ERROR'; | ||
// General application defined errors | ||
RPCErrorCode[(RPCErrorCode['RPC_MISC_ERROR'] = -1)] = 'RPC_MISC_ERROR'; | ||
RPCErrorCode[(RPCErrorCode['RPC_TYPE_ERROR'] = -3)] = 'RPC_TYPE_ERROR'; | ||
RPCErrorCode[(RPCErrorCode['RPC_INVALID_ADDRESS_OR_KEY'] = -5)] = | ||
'RPC_INVALID_ADDRESS_OR_KEY'; | ||
RPCErrorCode[(RPCErrorCode['RPC_INVALID_PARAMETER'] = -8)] = | ||
'RPC_INVALID_PARAMETER'; | ||
RPCErrorCode[(RPCErrorCode['RPC_DATABASE_ERROR'] = -20)] = | ||
'RPC_DATABASE_ERROR'; | ||
RPCErrorCode[(RPCErrorCode['RPC_DESERIALIZATION_ERROR'] = -22)] = | ||
'RPC_DESERIALIZATION_ERROR'; | ||
RPCErrorCode[(RPCErrorCode['RPC_VERIFY_ERROR'] = -25)] = 'RPC_VERIFY_ERROR'; | ||
RPCErrorCode[(RPCErrorCode['RPC_VERIFY_REJECTED'] = -26)] = | ||
'RPC_VERIFY_REJECTED'; | ||
RPCErrorCode[(RPCErrorCode['RPC_IN_WARMUP'] = -28)] = 'RPC_IN_WARMUP'; | ||
RPCErrorCode[(RPCErrorCode['RPC_METHOD_DEPRECATED'] = -32)] = | ||
'RPC_METHOD_DEPRECATED'; | ||
})((RPCErrorCode = exports.RPCErrorCode || (exports.RPCErrorCode = {}))); | ||
var DEFAULT_HEADERS = { 'Content-Type': 'application/json' }; | ||
exports.performRPC = function (request, handler) { return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
exports.performRPC = function(request, handler) { | ||
return tslib_1.__awaiter(void 0, void 0, void 0, function() { | ||
var response, err_1; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, cross_fetch_1.default(request.url, { | ||
method: 'POST', | ||
cache: 'no-cache', | ||
mode: 'cors', | ||
redirect: 'follow', | ||
referrer: 'no-referrer', | ||
body: JSON.stringify(request.payload), | ||
headers: tslib_1.__assign(tslib_1.__assign({}, DEFAULT_HEADERS), ((request.options && request.options.headers) || {})), | ||
})]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response | ||
.json() | ||
.then(function (body) { | ||
return tslib_1.__assign(tslib_1.__assign({}, body), { req: request }); | ||
}) | ||
.then(handler)]; | ||
case 2: | ||
err_1 = _a.sent(); | ||
throw err_1; | ||
case 3: return [2 /*return*/]; | ||
} | ||
return tslib_1.__generator(this, function(_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [ | ||
4 /*yield*/, | ||
cross_fetch_1.default(request.url, { | ||
method: 'POST', | ||
cache: 'no-cache', | ||
mode: 'cors', | ||
redirect: 'follow', | ||
referrer: 'no-referrer', | ||
body: JSON.stringify(request.payload), | ||
headers: tslib_1.__assign( | ||
tslib_1.__assign({}, DEFAULT_HEADERS), | ||
(request.options && request.options.headers) || {}, | ||
), | ||
}), | ||
]; | ||
case 1: | ||
response = _a.sent(); | ||
return [ | ||
2 /*return*/, | ||
response | ||
.json() | ||
.then(function(body) { | ||
return tslib_1.__assign(tslib_1.__assign({}, body), { | ||
req: request, | ||
}); | ||
}) | ||
.then(handler), | ||
]; | ||
case 2: | ||
err_1 = _a.sent(); | ||
throw err_1; | ||
case 3: | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
//# sourceMappingURL=net.js.map | ||
}); | ||
}; | ||
//# sourceMappingURL=net.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
// This file is part of Zilliqa-Javascript-Library. | ||
@@ -16,116 +16,137 @@ // | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var tslib_1 = require('tslib'); | ||
var MiddlewareType; | ||
(function (MiddlewareType) { | ||
MiddlewareType[MiddlewareType["REQ"] = 0] = "REQ"; | ||
MiddlewareType[MiddlewareType["RES"] = 1] = "RES"; | ||
(function(MiddlewareType) { | ||
MiddlewareType[(MiddlewareType['REQ'] = 0)] = 'REQ'; | ||
MiddlewareType[(MiddlewareType['RES'] = 1)] = 'RES'; | ||
})(MiddlewareType || (MiddlewareType = {})); | ||
var BaseProvider = /** @class */ (function () { | ||
function BaseProvider(nodeURL, reqMiddleware, resMiddleware) { | ||
var _this = this; | ||
if (reqMiddleware === void 0) { reqMiddleware = new Map(); } | ||
if (resMiddleware === void 0) { resMiddleware = new Map(); } | ||
this.middleware = { | ||
request: { | ||
use: function (fn, match) { | ||
if (match === void 0) { match = '*'; } | ||
_this.pushMiddleware(fn, 0 /* REQ */, match); | ||
}, | ||
}, | ||
response: { | ||
use: function (fn, match) { | ||
if (match === void 0) { match = '*'; } | ||
_this.pushMiddleware(fn, 1 /* RES */, match); | ||
}, | ||
}, | ||
}; | ||
this.nodeURL = nodeURL; | ||
this.reqMiddleware = reqMiddleware; | ||
this.resMiddleware = resMiddleware; | ||
var BaseProvider = /** @class */ (function() { | ||
function BaseProvider(nodeURL, reqMiddleware, resMiddleware) { | ||
var _this = this; | ||
if (reqMiddleware === void 0) { | ||
reqMiddleware = new Map(); | ||
} | ||
/** | ||
* pushMiddleware | ||
* | ||
* Adds the middleware to the appropriate middleware map. | ||
* | ||
* @param {ResMiddlewareFn} | ||
* @param {T} type | ||
* @param {Matcher} match | ||
* @returns {void} | ||
*/ | ||
BaseProvider.prototype.pushMiddleware = function (fn, type, match) { | ||
if (type !== 0 /* REQ */ && type !== 1 /* RES */) { | ||
throw new Error('Please specify the type of middleware being added'); | ||
if (resMiddleware === void 0) { | ||
resMiddleware = new Map(); | ||
} | ||
this.middleware = { | ||
request: { | ||
use: function(fn, match) { | ||
if (match === void 0) { | ||
match = '*'; | ||
} | ||
_this.pushMiddleware(fn, 0 /* REQ */, match); | ||
}, | ||
}, | ||
response: { | ||
use: function(fn, match) { | ||
if (match === void 0) { | ||
match = '*'; | ||
} | ||
_this.pushMiddleware(fn, 1 /* RES */, match); | ||
}, | ||
}, | ||
}; | ||
this.nodeURL = nodeURL; | ||
this.reqMiddleware = reqMiddleware; | ||
this.resMiddleware = resMiddleware; | ||
} | ||
/** | ||
* pushMiddleware | ||
* | ||
* Adds the middleware to the appropriate middleware map. | ||
* | ||
* @param {ResMiddlewareFn} | ||
* @param {T} type | ||
* @param {Matcher} match | ||
* @returns {void} | ||
*/ | ||
BaseProvider.prototype.pushMiddleware = function(fn, type, match) { | ||
if (type !== 0 /* REQ */ && type !== 1 /* RES */) { | ||
throw new Error('Please specify the type of middleware being added'); | ||
} | ||
if (type === 0 /* REQ */) { | ||
var current = this.reqMiddleware.get(match) || []; | ||
this.reqMiddleware.set(match, tslib_1.__spread(current, [fn])); | ||
} else { | ||
var current = this.resMiddleware.get(match) || []; | ||
this.resMiddleware.set(match, tslib_1.__spread(current, [fn])); | ||
} | ||
}; | ||
/** | ||
* getMiddleware | ||
* | ||
* Returns the middleware that matches the matcher provided. Note that | ||
* middleware are called in order of specificity: string -> regexp -> | ||
* wildcard. | ||
* | ||
* @param {Matcher} match | ||
* @returns {[ReqMiddlewareFn[], ResMiddlewareFn[]]} | ||
*/ | ||
BaseProvider.prototype.getMiddleware = function(method) { | ||
var e_1, _a, e_2, _b; | ||
var reqFns = []; | ||
var resFns = []; | ||
try { | ||
for ( | ||
var _c = tslib_1.__values(this.reqMiddleware.entries()), _d = _c.next(); | ||
!_d.done; | ||
_d = _c.next() | ||
) { | ||
var _e = tslib_1.__read(_d.value, 2), | ||
key = _e[0], | ||
transformers = _e[1]; | ||
if (typeof key === 'string' && key !== '*' && key === method) { | ||
reqFns.push.apply(reqFns, tslib_1.__spread(transformers)); | ||
} | ||
if (type === 0 /* REQ */) { | ||
var current = this.reqMiddleware.get(match) || []; | ||
this.reqMiddleware.set(match, tslib_1.__spread(current, [fn])); | ||
if (key instanceof RegExp && key.test(method)) { | ||
reqFns.push.apply(reqFns, tslib_1.__spread(transformers)); | ||
} | ||
else { | ||
var current = this.resMiddleware.get(match) || []; | ||
this.resMiddleware.set(match, tslib_1.__spread(current, [fn])); | ||
if (key === '*') { | ||
reqFns.push.apply(reqFns, tslib_1.__spread(transformers)); | ||
} | ||
}; | ||
/** | ||
* getMiddleware | ||
* | ||
* Returns the middleware that matches the matcher provided. Note that | ||
* middleware are called in order of specificity: string -> regexp -> | ||
* wildcard. | ||
* | ||
* @param {Matcher} match | ||
* @returns {[ReqMiddlewareFn[], ResMiddlewareFn[]]} | ||
*/ | ||
BaseProvider.prototype.getMiddleware = function (method) { | ||
var e_1, _a, e_2, _b; | ||
var reqFns = []; | ||
var resFns = []; | ||
try { | ||
for (var _c = tslib_1.__values(this.reqMiddleware.entries()), _d = _c.next(); !_d.done; _d = _c.next()) { | ||
var _e = tslib_1.__read(_d.value, 2), key = _e[0], transformers = _e[1]; | ||
if (typeof key === 'string' && key !== '*' && key === method) { | ||
reqFns.push.apply(reqFns, tslib_1.__spread(transformers)); | ||
} | ||
if (key instanceof RegExp && key.test(method)) { | ||
reqFns.push.apply(reqFns, tslib_1.__spread(transformers)); | ||
} | ||
if (key === '*') { | ||
reqFns.push.apply(reqFns, tslib_1.__spread(transformers)); | ||
} | ||
} | ||
} | ||
} catch (e_1_1) { | ||
e_1 = { error: e_1_1 }; | ||
} finally { | ||
try { | ||
if (_d && !_d.done && (_a = _c.return)) _a.call(_c); | ||
} finally { | ||
if (e_1) throw e_1.error; | ||
} | ||
} | ||
try { | ||
for ( | ||
var _f = tslib_1.__values(this.resMiddleware.entries()), _g = _f.next(); | ||
!_g.done; | ||
_g = _f.next() | ||
) { | ||
var _h = tslib_1.__read(_g.value, 2), | ||
key = _h[0], | ||
transformers = _h[1]; | ||
if (typeof key === 'string' && key !== '*' && key === method) { | ||
resFns.push.apply(resFns, tslib_1.__spread(transformers)); | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_d && !_d.done && (_a = _c.return)) _a.call(_c); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
if (key instanceof RegExp && key.test(method)) { | ||
resFns.push.apply(resFns, tslib_1.__spread(transformers)); | ||
} | ||
try { | ||
for (var _f = tslib_1.__values(this.resMiddleware.entries()), _g = _f.next(); !_g.done; _g = _f.next()) { | ||
var _h = tslib_1.__read(_g.value, 2), key = _h[0], transformers = _h[1]; | ||
if (typeof key === 'string' && key !== '*' && key === method) { | ||
resFns.push.apply(resFns, tslib_1.__spread(transformers)); | ||
} | ||
if (key instanceof RegExp && key.test(method)) { | ||
resFns.push.apply(resFns, tslib_1.__spread(transformers)); | ||
} | ||
if (key === '*') { | ||
resFns.push.apply(resFns, tslib_1.__spread(transformers)); | ||
} | ||
} | ||
if (key === '*') { | ||
resFns.push.apply(resFns, tslib_1.__spread(transformers)); | ||
} | ||
catch (e_2_1) { e_2 = { error: e_2_1 }; } | ||
finally { | ||
try { | ||
if (_g && !_g.done && (_b = _f.return)) _b.call(_f); | ||
} | ||
finally { if (e_2) throw e_2.error; } | ||
} | ||
return [reqFns, resFns]; | ||
}; | ||
return BaseProvider; | ||
}()); | ||
} | ||
} catch (e_2_1) { | ||
e_2 = { error: e_2_1 }; | ||
} finally { | ||
try { | ||
if (_g && !_g.done && (_b = _f.return)) _b.call(_f); | ||
} finally { | ||
if (e_2) throw e_2.error; | ||
} | ||
} | ||
return [reqFns, resFns]; | ||
}; | ||
return BaseProvider; | ||
})(); | ||
exports.BaseProvider = BaseProvider; | ||
//# sourceMappingURL=base.js.map | ||
//# sourceMappingURL=base.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
// This file is part of Zilliqa-Javascript-Library. | ||
@@ -16,38 +16,46 @@ // | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var base_1 = require("./base"); | ||
var net_1 = require("../net"); | ||
var util_1 = require("../util"); | ||
var HTTPProvider = /** @class */ (function (_super) { | ||
tslib_1.__extends(HTTPProvider, _super); | ||
function HTTPProvider() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var tslib_1 = require('tslib'); | ||
var base_1 = require('./base'); | ||
var net_1 = require('../net'); | ||
var util_1 = require('../util'); | ||
var HTTPProvider = /** @class */ (function(_super) { | ||
tslib_1.__extends(HTTPProvider, _super); | ||
function HTTPProvider() { | ||
return (_super !== null && _super.apply(this, arguments)) || this; | ||
} | ||
HTTPProvider.prototype.buildPayload = function(method, params) { | ||
return { | ||
url: this.nodeURL, | ||
payload: { id: 1, jsonrpc: '2.0', method: method, params: params }, | ||
}; | ||
}; | ||
HTTPProvider.prototype.send = function(method) { | ||
var params = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
params[_i - 1] = arguments[_i]; | ||
} | ||
HTTPProvider.prototype.buildPayload = function (method, params) { | ||
return { | ||
url: this.nodeURL, | ||
payload: { id: 1, jsonrpc: '2.0', method: method, params: params }, | ||
}; | ||
}; | ||
HTTPProvider.prototype.send = function (method) { | ||
var params = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
params[_i - 1] = arguments[_i]; | ||
} | ||
var _a = tslib_1.__read(this.getMiddleware(method), 2), tReq = _a[0], tRes = _a[1]; | ||
var reqMiddleware = util_1.composeMiddleware.apply(void 0, tslib_1.__spread(tReq)); | ||
var resMiddleware = util_1.composeMiddleware.apply(void 0, tslib_1.__spread(tRes)); | ||
var req = reqMiddleware(this.buildPayload(method, params)); | ||
return net_1.performRPC(req, resMiddleware); | ||
}; | ||
HTTPProvider.prototype.subscribe = function (event, subscriber) { | ||
throw new Error('HTTPProvider does not support subscriptions.'); | ||
}; | ||
HTTPProvider.prototype.unsubscribe = function (token) { | ||
throw new Error('HTTPProvider does not support subscriptions.'); | ||
}; | ||
return HTTPProvider; | ||
}(base_1.BaseProvider)); | ||
var _a = tslib_1.__read(this.getMiddleware(method), 2), | ||
tReq = _a[0], | ||
tRes = _a[1]; | ||
var reqMiddleware = util_1.composeMiddleware.apply( | ||
void 0, | ||
tslib_1.__spread(tReq), | ||
); | ||
var resMiddleware = util_1.composeMiddleware.apply( | ||
void 0, | ||
tslib_1.__spread(tRes), | ||
); | ||
var req = reqMiddleware(this.buildPayload(method, params)); | ||
return net_1.performRPC(req, resMiddleware); | ||
}; | ||
HTTPProvider.prototype.subscribe = function(event, subscriber) { | ||
throw new Error('HTTPProvider does not support subscriptions.'); | ||
}; | ||
HTTPProvider.prototype.unsubscribe = function(token) { | ||
throw new Error('HTTPProvider does not support subscriptions.'); | ||
}; | ||
return HTTPProvider; | ||
})(base_1.BaseProvider); | ||
exports.HTTPProvider = HTTPProvider; | ||
//# sourceMappingURL=http.js.map | ||
//# sourceMappingURL=http.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
// This file is part of Zilliqa-Javascript-Library. | ||
@@ -16,37 +16,56 @@ // | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Signer = /** @class */ (function () { | ||
function Signer() { | ||
} | ||
return Signer; | ||
}()); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var Signer = /** @class */ (function() { | ||
function Signer() {} | ||
return Signer; | ||
})(); | ||
exports.Signer = Signer; | ||
var TxBlockType; | ||
(function (TxBlockType) { | ||
TxBlockType[TxBlockType["MICRO"] = 0] = "MICRO"; | ||
TxBlockType[TxBlockType["FINAL"] = 1] = "FINAL"; | ||
(function(TxBlockType) { | ||
TxBlockType[(TxBlockType['MICRO'] = 0)] = 'MICRO'; | ||
TxBlockType[(TxBlockType['FINAL'] = 1)] = 'FINAL'; | ||
})(TxBlockType || (TxBlockType = {})); | ||
var TransactionError; | ||
(function (TransactionError) { | ||
TransactionError[TransactionError["CHECKER_FAILED"] = 0] = "CHECKER_FAILED"; | ||
TransactionError[TransactionError["RUNNER_FAILED"] = 1] = "RUNNER_FAILED"; | ||
TransactionError[TransactionError["BALANCE_TRANSFER_FAILED"] = 2] = "BALANCE_TRANSFER_FAILED"; | ||
TransactionError[TransactionError["EXECUTE_CMD_FAILED"] = 3] = "EXECUTE_CMD_FAILED"; | ||
TransactionError[TransactionError["EXECUTE_CMD_TIMEOUT"] = 4] = "EXECUTE_CMD_TIMEOUT"; | ||
TransactionError[TransactionError["NO_GAS_REMAINING_FOUND"] = 5] = "NO_GAS_REMAINING_FOUND"; | ||
TransactionError[TransactionError["NO_ACCEPTED_FOUND"] = 6] = "NO_ACCEPTED_FOUND"; | ||
TransactionError[TransactionError["CALL_CONTRACT_FAILED"] = 7] = "CALL_CONTRACT_FAILED"; | ||
TransactionError[TransactionError["CREATE_CONTRACT_FAILED"] = 8] = "CREATE_CONTRACT_FAILED"; | ||
TransactionError[TransactionError["JSON_OUTPUT_CORRUPTED"] = 9] = "JSON_OUTPUT_CORRUPTED"; | ||
TransactionError[TransactionError["CONTRACT_NOT_EXIST"] = 10] = "CONTRACT_NOT_EXIST"; | ||
TransactionError[TransactionError["STATE_CORRUPTED"] = 11] = "STATE_CORRUPTED"; | ||
TransactionError[TransactionError["LOG_ENTRY_INSTALL_FAILED"] = 12] = "LOG_ENTRY_INSTALL_FAILED"; | ||
TransactionError[TransactionError["MESSAGE_CORRUPTED"] = 13] = "MESSAGE_CORRUPTED"; | ||
TransactionError[TransactionError["RECEIPT_IS_NULL"] = 14] = "RECEIPT_IS_NULL"; | ||
TransactionError[TransactionError["MAX_DEPTH_REACHED"] = 15] = "MAX_DEPTH_REACHED"; | ||
TransactionError[TransactionError["CHAIN_CALL_DIFF_SHARD"] = 16] = "CHAIN_CALL_DIFF_SHARD"; | ||
TransactionError[TransactionError["PREPARATION_FAILED"] = 17] = "PREPARATION_FAILED"; | ||
TransactionError[TransactionError["NO_OUTPUT"] = 18] = "NO_OUTPUT"; | ||
TransactionError[TransactionError["OUTPUT_ILLEGAL"] = 19] = "OUTPUT_ILLEGAL"; | ||
})(TransactionError = exports.TransactionError || (exports.TransactionError = {})); | ||
//# sourceMappingURL=types.js.map | ||
(function(TransactionError) { | ||
TransactionError[(TransactionError['CHECKER_FAILED'] = 0)] = 'CHECKER_FAILED'; | ||
TransactionError[(TransactionError['RUNNER_FAILED'] = 1)] = 'RUNNER_FAILED'; | ||
TransactionError[(TransactionError['BALANCE_TRANSFER_FAILED'] = 2)] = | ||
'BALANCE_TRANSFER_FAILED'; | ||
TransactionError[(TransactionError['EXECUTE_CMD_FAILED'] = 3)] = | ||
'EXECUTE_CMD_FAILED'; | ||
TransactionError[(TransactionError['EXECUTE_CMD_TIMEOUT'] = 4)] = | ||
'EXECUTE_CMD_TIMEOUT'; | ||
TransactionError[(TransactionError['NO_GAS_REMAINING_FOUND'] = 5)] = | ||
'NO_GAS_REMAINING_FOUND'; | ||
TransactionError[(TransactionError['NO_ACCEPTED_FOUND'] = 6)] = | ||
'NO_ACCEPTED_FOUND'; | ||
TransactionError[(TransactionError['CALL_CONTRACT_FAILED'] = 7)] = | ||
'CALL_CONTRACT_FAILED'; | ||
TransactionError[(TransactionError['CREATE_CONTRACT_FAILED'] = 8)] = | ||
'CREATE_CONTRACT_FAILED'; | ||
TransactionError[(TransactionError['JSON_OUTPUT_CORRUPTED'] = 9)] = | ||
'JSON_OUTPUT_CORRUPTED'; | ||
TransactionError[(TransactionError['CONTRACT_NOT_EXIST'] = 10)] = | ||
'CONTRACT_NOT_EXIST'; | ||
TransactionError[(TransactionError['STATE_CORRUPTED'] = 11)] = | ||
'STATE_CORRUPTED'; | ||
TransactionError[(TransactionError['LOG_ENTRY_INSTALL_FAILED'] = 12)] = | ||
'LOG_ENTRY_INSTALL_FAILED'; | ||
TransactionError[(TransactionError['MESSAGE_CORRUPTED'] = 13)] = | ||
'MESSAGE_CORRUPTED'; | ||
TransactionError[(TransactionError['RECEIPT_IS_NULL'] = 14)] = | ||
'RECEIPT_IS_NULL'; | ||
TransactionError[(TransactionError['MAX_DEPTH_REACHED'] = 15)] = | ||
'MAX_DEPTH_REACHED'; | ||
TransactionError[(TransactionError['CHAIN_CALL_DIFF_SHARD'] = 16)] = | ||
'CHAIN_CALL_DIFF_SHARD'; | ||
TransactionError[(TransactionError['PREPARATION_FAILED'] = 17)] = | ||
'PREPARATION_FAILED'; | ||
TransactionError[(TransactionError['NO_OUTPUT'] = 18)] = 'NO_OUTPUT'; | ||
TransactionError[(TransactionError['OUTPUT_ILLEGAL'] = 19)] = | ||
'OUTPUT_ILLEGAL'; | ||
})( | ||
(TransactionError = | ||
exports.TransactionError || (exports.TransactionError = {})), | ||
); | ||
//# sourceMappingURL=types.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
// This file is part of Zilliqa-Javascript-Library. | ||
@@ -16,26 +16,34 @@ // | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function isValidResponse(response) { | ||
if (response.jsonrpc === '2.0' && | ||
(response.id === '1' || response.id === 1) && | ||
(response.error || response.result)) { | ||
return true; | ||
} | ||
return false; | ||
if ( | ||
response.jsonrpc === '2.0' && | ||
(response.id === '1' || response.id === 1) && | ||
(response.error || response.result) | ||
) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
exports.isValidResponse = isValidResponse; | ||
function composeMiddleware() { | ||
var fns = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
fns[_i] = arguments[_i]; | ||
} | ||
if (fns.length === 0) { | ||
return function (arg) { return arg; }; | ||
} | ||
if (fns.length === 1) { | ||
return fns[0]; | ||
} | ||
return fns.reduce(function (a, b) { return function (arg) { return a(b(arg)); }; }); | ||
var fns = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
fns[_i] = arguments[_i]; | ||
} | ||
if (fns.length === 0) { | ||
return function(arg) { | ||
return arg; | ||
}; | ||
} | ||
if (fns.length === 1) { | ||
return fns[0]; | ||
} | ||
return fns.reduce(function(a, b) { | ||
return function(arg) { | ||
return a(b(arg)); | ||
}; | ||
}); | ||
} | ||
exports.composeMiddleware = composeMiddleware; | ||
//# sourceMappingURL=util.js.map | ||
//# sourceMappingURL=util.js.map |
{ | ||
"name": "@zilliqa-js/core", | ||
"version": "0.8.1-alpha.2", | ||
"version": "0.8.1", | ||
"description": "Core abstractions that power the zilliqa JS client.", | ||
@@ -36,3 +36,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "870c1c1a1d49877e1d23f64fa993702d744580e8" | ||
"gitHead": "b62c7e42ebf43c80a1d4581344c47be4464f1c6c" | ||
} |
@@ -40,2 +40,4 @@ # @zilliqa-js/core | ||
GetSmartContractState = 'GetSmartContractState', | ||
GetSmartContractSubState = 'GetSmartContractSubState', | ||
GetContractAddressFromTransactionID = 'GetContractAddressFromTransactionID', | ||
@@ -42,0 +44,0 @@ |
@@ -61,2 +61,3 @@ // This file is part of Zilliqa-Javascript-Library. | ||
GetSmartContractState = 'GetSmartContractState', | ||
GetSmartContractSubState = 'GetSmartContractSubState', | ||
GetContractAddressFromTransactionID = 'GetContractAddressFromTransactionID', | ||
@@ -63,0 +64,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3350
200
367451