@simbachain/libsimba-js
Version:
libsimba-js is a library simplifying the use of SIMBAChain APIs. We aim to abstract away the various blockchain concepts, reducing the necessary time needed to get to working code.
1,391 lines (1,265 loc) • 1.02 MB
JavaScript
/*!
* @simbachain/libsimba-js
* libsimba-js is a library simplifying the use of SIMBAChain APIs. We aim to abstract away the various blockchain concepts, reducing the necessary time needed to get to working code.
*
* @version v0.5.8
* @author Kieran David Evans <kieran.evans@simbachain.com>
* @homepage
* @repository git+https://github.com/simbachain/libsimba-js.git
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["libsimba"] = factory();
else
root["libsimba"] = factory();
})((typeof self !== 'undefined' ? self : this), function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 297);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
// EXTERNAL MODULE: ./node_modules/@ethersproject/logger/lib.esm/index.js + 1 modules
var lib_esm = __webpack_require__(4);
// CONCATENATED MODULE: ./node_modules/@ethersproject/bytes/lib.esm/_version.js
const version = "bytes/5.0.0-beta.132";
// CONCATENATED MODULE: ./node_modules/@ethersproject/bytes/lib.esm/index.js
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isBytesLike", function() { return isBytesLike; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isBytes", function() { return isBytes; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "arrayify", function() { return arrayify; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "concat", function() { return concat; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stripZeros", function() { return stripZeros; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "zeroPad", function() { return zeroPad; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isHexString", function() { return isHexString; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hexlify", function() { return hexlify; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hexDataLength", function() { return hexDataLength; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hexDataSlice", function() { return hexDataSlice; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hexConcat", function() { return hexConcat; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hexValue", function() { return hexValue; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hexStripZeros", function() { return hexStripZeros; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hexZeroPad", function() { return hexZeroPad; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "splitSignature", function() { return splitSignature; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "joinSignature", function() { return joinSignature; });
const logger = new lib_esm["Logger"](version);
///////////////////////////////
function isHexable(value) {
return !!(value.toHexString);
}
function addSlice(array) {
if (array.slice) {
return array;
}
array.slice = function () {
let args = Array.prototype.slice.call(arguments);
return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args)));
};
return array;
}
function isBytesLike(value) {
return ((isHexString(value) && !(value.length % 2)) || isBytes(value));
}
function isBytes(value) {
if (value == null) {
return false;
}
if (value.constructor === Uint8Array) {
return true;
}
if (typeof (value) === "string") {
return false;
}
if (value.length == null) {
return false;
}
for (let i = 0; i < value.length; i++) {
let v = value[i];
if (v < 0 || v >= 256 || (v % 1)) {
return false;
}
}
return true;
}
function arrayify(value, options) {
if (!options) {
options = {};
}
if (typeof (value) === "number") {
logger.checkSafeUint53(value, "invalid arrayify value");
let result = [];
while (value) {
result.unshift(value & 0xff);
value /= 256;
}
if (result.length === 0) {
result.push(0);
}
return addSlice(new Uint8Array(result));
}
if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
value = "0x" + value;
}
if (isHexable(value)) {
value = value.toHexString();
}
if (isHexString(value)) {
let hex = value.substring(2);
if (hex.length % 2) {
if (options.hexPad === "left") {
hex = "0x0" + hex.substring(2);
}
else if (options.hexPad === "right") {
hex += "0";
}
else {
logger.throwArgumentError("hex data is odd-length", "value", value);
}
}
let result = [];
for (let i = 0; i < hex.length; i += 2) {
result.push(parseInt(hex.substring(i, i + 2), 16));
}
return addSlice(new Uint8Array(result));
}
if (isBytes(value)) {
return addSlice(new Uint8Array(value));
}
return logger.throwArgumentError("invalid arrayify value", "value", value);
}
function concat(items) {
let objects = items.map(item => arrayify(item));
let length = objects.reduce((accum, item) => (accum + item.length), 0);
let result = new Uint8Array(length);
objects.reduce((offset, object) => {
result.set(object, offset);
return offset + object.length;
}, 0);
return addSlice(result);
}
function stripZeros(value) {
let result = arrayify(value);
if (result.length === 0) {
return result;
}
// Find the first non-zero entry
let start = 0;
while (start < result.length && result[start] === 0) {
start++;
}
// If we started with zeros, strip them
if (start) {
result = result.slice(start);
}
return result;
}
function zeroPad(value, length) {
value = arrayify(value);
if (value.length > length) {
logger.throwArgumentError("value out of range", "value", arguments[0]);
}
let result = new Uint8Array(length);
result.set(value, length - value.length);
return addSlice(result);
}
function isHexString(value, length) {
if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
return false;
}
if (length && value.length !== 2 + 2 * length) {
return false;
}
return true;
}
const HexCharacters = "0123456789abcdef";
function hexlify(value, options) {
if (!options) {
options = {};
}
if (typeof (value) === "number") {
logger.checkSafeUint53(value, "invalid hexlify value");
let hex = "";
while (value) {
hex = HexCharacters[value & 0x0f] + hex;
value = Math.floor(value / 16);
}
if (hex.length) {
if (hex.length % 2) {
hex = "0" + hex;
}
return "0x" + hex;
}
return "0x00";
}
if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
value = "0x" + value;
}
if (isHexable(value)) {
return value.toHexString();
}
if (isHexString(value)) {
if (value.length % 2) {
if (options.hexPad === "left") {
value = "0x0" + value.substring(2);
}
else if (options.hexPad === "right") {
value += "0";
}
else {
logger.throwArgumentError("hex data is odd-length", "value", value);
}
}
return value.toLowerCase();
}
if (isBytes(value)) {
let result = "0x";
for (let i = 0; i < value.length; i++) {
let v = value[i];
result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f];
}
return result;
}
return logger.throwArgumentError("invalid hexlify value", "value", value);
}
/*
function unoddify(value: BytesLike | Hexable | number): BytesLike | Hexable | number {
if (typeof(value) === "string" && value.length % 2 && value.substring(0, 2) === "0x") {
return "0x0" + value.substring(2);
}
return value;
}
*/
function hexDataLength(data) {
if (typeof (data) !== "string") {
data = hexlify(data);
}
else if (!isHexString(data) || (data.length % 2)) {
return null;
}
return (data.length - 2) / 2;
}
function hexDataSlice(data, offset, endOffset) {
if (typeof (data) !== "string") {
data = hexlify(data);
}
else if (!isHexString(data) || (data.length % 2)) {
logger.throwArgumentError("invalid hexData", "value", data);
}
offset = 2 + 2 * offset;
if (endOffset != null) {
return "0x" + data.substring(offset, 2 + 2 * endOffset);
}
return "0x" + data.substring(offset);
}
function hexConcat(items) {
let result = "0x";
items.forEach((item) => {
result += hexlify(item).substring(2);
});
return result;
}
function hexValue(value) {
let trimmed = hexStripZeros(hexlify(value, { hexPad: "left" }));
if (trimmed === "0x") {
return "0x0";
}
return trimmed;
}
function hexStripZeros(value) {
if (typeof (value) !== "string") {
value = hexlify(value);
}
if (!isHexString(value)) {
logger.throwArgumentError("invalid hex string", "value", value);
}
value = value.substring(2);
let offset = 0;
while (offset < value.length && value[offset] === "0") {
offset++;
}
return "0x" + value.substring(offset);
}
function hexZeroPad(value, length) {
if (typeof (value) !== "string") {
value = hexlify(value);
}
else if (!isHexString(value)) {
logger.throwArgumentError("invalid hex string", "value", value);
}
if (value.length > 2 * length + 2) {
logger.throwArgumentError("value out of range", "value", arguments[1]);
}
while (value.length < 2 * length + 2) {
value = "0x0" + value.substring(2);
}
return value;
}
function splitSignature(signature) {
let result = {
r: "0x",
s: "0x",
_vs: "0x",
recoveryParam: 0,
v: 0
};
if (isBytesLike(signature)) {
let bytes = arrayify(signature);
if (bytes.length !== 65) {
logger.throwArgumentError("invalid signature string; must be 65 bytes", "signature", signature);
}
// Get the r and s
result.r = hexlify(bytes.slice(0, 32));
result.s = hexlify(bytes.slice(32, 64));
// Reduce v to the canonical 27 or 28
result.v = bytes[64];
if (result.v !== 27 && result.v !== 28) {
result.v = 27 + (result.v % 2);
}
// Compute recoveryParam from v
result.recoveryParam = (result.v - 27);
// Compute _vs from recoveryParam and s
if (result.recoveryParam) {
bytes[32] |= 0x80;
}
result._vs = hexlify(bytes.slice(32, 64));
}
else {
result.r = signature.r;
result.s = signature.s;
result.v = signature.v;
result.recoveryParam = signature.recoveryParam;
result._vs = signature._vs;
// Normalize v into a canonical 27 or 28
if (result.v != null && !(result.v == 27 || result.v == 28)) {
result.v = 27 + (result.v % 2);
}
// Populate a missing v or recoveryParam if possible
if (result.recoveryParam == null && result.v != null) {
result.recoveryParam = 1 - (result.v % 2);
}
else if (result.recoveryParam != null && result.v == null) {
result.v = 27 + result.recoveryParam;
}
else if (result.recoveryParam != null && result.v != null) {
if (result.v !== 27 + result.recoveryParam) {
logger.throwArgumentError("signature v mismatch recoveryParam", "signature", signature);
}
}
// Make sure r and s are padded properly
if (result.r != null) {
result.r = hexZeroPad(result.r, 32);
}
if (result.s != null) {
result.s = hexZeroPad(result.s, 32);
}
// If the _vs is available, use it to populate missing s, v and recoveryParam
// and verify non-missing s, v and recoveryParam
if (result._vs != null) {
result._vs = hexZeroPad(result._vs, 32);
if (result._vs.length > 66) {
logger.throwArgumentError("signature _vs overflow", "signature", signature);
}
let vs = arrayify(result._vs);
let recoveryParam = ((vs[0] >= 128) ? 1 : 0);
let v = 27 + result.recoveryParam;
// Use _vs to compute s
vs[0] &= 0x7f;
let s = hexlify(vs);
// Check _vs aggress with other parameters
if (result.s == null) {
result.s = s;
}
else if (result.s !== s) {
logger.throwArgumentError("signature v mismatch _vs", "signature", signature);
}
if (result.v == null) {
result.v = v;
}
else if (result.v !== v) {
logger.throwArgumentError("signature v mismatch _vs", "signature", signature);
}
if (recoveryParam == null) {
result.recoveryParam = recoveryParam;
}
else if (result.recoveryParam !== recoveryParam) {
logger.throwArgumentError("signature recoveryParam mismatch _vs", "signature", signature);
}
}
// After all populating, both v and recoveryParam are still missing...
if (result.v == null && result.recoveryParam == null) {
logger.throwArgumentError("signature requires at least one of recoveryParam, v or _vs", "signature", signature);
}
// Check for canonical v
if (result.v !== 27 && result.v !== 28) {
logger.throwArgumentError("signature v not canonical", "signature", signature);
}
// Check that r and s are in range
if (result.r.length > 66 || result.s.length > 66) {
logger.throwArgumentError("signature overflow r or s", "signature", signature);
}
if (result._vs == null) {
let vs = arrayify(result.s);
if (vs[0] >= 128) {
logger.throwArgumentError("signature s out of range", "signature", signature);
}
if (result.recoveryParam) {
vs[0] |= 0x80;
}
result._vs = hexlify(vs);
}
}
return result;
}
function joinSignature(signature) {
signature = splitSignature(signature);
return hexlify(concat([
signature.r,
signature.s,
(signature.recoveryParam ? "0x1c" : "0x1b")
]));
}
/***/ }),
/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export BaseException */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return NotImplementedException; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return MissingMetadataException; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return BadMetadataException; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return MethodCallValidationMetadataException; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return GenerateTransactionException; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return SubmitTransactionException; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return GetRequestException; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return PostRequestException; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return GetTransactionsException; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return TransactionStatusCheckException; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return SigningException; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return NotInBrowserException; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return UserRejectedSigningException; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return WalletNotFoundException; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return WalletLockedException; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return RetriesExceededException; });
/* harmony import */ var core_js_modules_es_array_concat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(55);
/* harmony import */ var core_js_modules_es_array_concat__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_concat__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var core_js_modules_es_function_name__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(126);
/* harmony import */ var core_js_modules_es_function_name__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_function_name__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(165);
/* harmony import */ var _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(10);
/* harmony import */ var _babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _babel_runtime_helpers_wrapNativeSuper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(166);
/* harmony import */ var _babel_runtime_helpers_wrapNativeSuper__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_wrapNativeSuper__WEBPACK_IMPORTED_MODULE_4__);
/**
* Base exception that all libsimba Exceptions extend
*/
var BaseException =
/*#__PURE__*/
function (_Error) {
_babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3___default()(BaseException, _Error);
/**
* Base exception that all libsimba Exceptions extend
* @param {string} message - the error message
* @param {Error|string} [cause] - (Optional) wrap an existing error
*/
function BaseException(message, cause) {
var _this;
_this = _Error.call(this) || this;
_this.name = 'BaseException';
if ('response' in message) {
_this.message = message.response.data;
_this.cause = cause || message;
} else {
_this.message = message;
_this.cause = cause;
} // Maintains proper stack trace for where our error was thrown (only available on V8)
if (Error.captureStackTrace) {
Error.captureStackTrace(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_2___default()(_this), _this.constructor);
}
return _this;
}
return BaseException;
}(_babel_runtime_helpers_wrapNativeSuper__WEBPACK_IMPORTED_MODULE_4___default()(Error));
/**
* Thrown when a method that should be implemented is not
*/
var NotImplementedException =
/*#__PURE__*/
function (_BaseException) {
_babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3___default()(NotImplementedException, _BaseException);
function NotImplementedException() {
var _this2;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this2 = _BaseException.call.apply(_BaseException, [this].concat(args)) || this;
_this2.name = 'NotImplementedException';
return _this2;
}
return NotImplementedException;
}(BaseException);
/**
* Thrown when a method on a class inheriting [SimbaBase]{@link SimbaBase} is called before
* metadata is retrieved.
*/
var MissingMetadataException =
/*#__PURE__*/
function (_BaseException2) {
_babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3___default()(MissingMetadataException, _BaseException2);
function MissingMetadataException() {
var _this3;
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
_this3 = _BaseException2.call.apply(_BaseException2, [this].concat(args)) || this;
_this3.name = 'MissingMetadataException';
return _this3;
}
return MissingMetadataException;
}(BaseException);
/**
* Thrown when metadata doesn't have something it should have
*/
var BadMetadataException =
/*#__PURE__*/
function (_BaseException3) {
_babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3___default()(BadMetadataException, _BaseException3);
function BadMetadataException() {
var _this4;
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
_this4 = _BaseException3.call.apply(_BaseException3, [this].concat(args)) || this;
_this4.name = 'BadMetadataException';
return _this4;
}
return BadMetadataException;
}(BaseException);
/**
* Thrown when a method call isn't valid
*/
var MethodCallValidationMetadataException =
/*#__PURE__*/
function (_BaseException4) {
_babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3___default()(MethodCallValidationMetadataException, _BaseException4);
function MethodCallValidationMetadataException() {
var _this5;
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
}
_this5 = _BaseException4.call.apply(_BaseException4, [this].concat(args)) || this;
_this5.name = 'MethodCallValidationMetadataException';
return _this5;
}
return MethodCallValidationMetadataException;
}(BaseException);
/**
* Thrown when the server fails to generate the transaction for signing
*/
var GenerateTransactionException =
/*#__PURE__*/
function (_BaseException5) {
_babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3___default()(GenerateTransactionException, _BaseException5);
function GenerateTransactionException() {
var _this6;
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
args[_key5] = arguments[_key5];
}
_this6 = _BaseException5.call.apply(_BaseException5, [this].concat(args)) || this;
_this6.name = 'GenerateTransactionException';
return _this6;
}
return GenerateTransactionException;
}(BaseException);
/**
* Thrown when the server returns an error after submitting a signed transaction
*/
var SubmitTransactionException =
/*#__PURE__*/
function (_BaseException6) {
_babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3___default()(SubmitTransactionException, _BaseException6);
function SubmitTransactionException() {
var _this7;
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
args[_key6] = arguments[_key6];
}
_this7 = _BaseException6.call.apply(_BaseException6, [this].concat(args)) || this;
_this7.name = 'SubmitTransactionException';
return _this7;
}
return SubmitTransactionException;
}(BaseException);
/**
* Thrown when the server returns an error when querying transactions
*/
var GetRequestException =
/*#__PURE__*/
function (_BaseException7) {
_babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3___default()(GetRequestException, _BaseException7);
function GetRequestException() {
var _this8;
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
args[_key7] = arguments[_key7];
}
_this8 = _BaseException7.call.apply(_BaseException7, [this].concat(args)) || this;
_this8.name = 'GetRequestException';
return _this8;
}
return GetRequestException;
}(BaseException);
/**
* Thrown when the server returns an error when querying transactions
*/
var PostRequestException =
/*#__PURE__*/
function (_BaseException8) {
_babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3___default()(PostRequestException, _BaseException8);
function PostRequestException() {
var _this9;
for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
args[_key8] = arguments[_key8];
}
_this9 = _BaseException8.call.apply(_BaseException8, [this].concat(args)) || this;
_this9.name = 'PostRequestException';
return _this9;
}
return PostRequestException;
}(BaseException);
/**
* Thrown when the server returns an error when querying transactions
*/
var GetTransactionsException =
/*#__PURE__*/
function (_GetRequestException) {
_babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3___default()(GetTransactionsException, _GetRequestException);
function GetTransactionsException() {
var _this10;
for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
args[_key9] = arguments[_key9];
}
_this10 = _GetRequestException.call.apply(_GetRequestException, [this].concat(args)) || this;
_this10.name = 'GetTransactionsException';
return _this10;
}
return GetTransactionsException;
}(GetRequestException);
/**
* Thrown when an error occurs checking a transactions status
*/
var TransactionStatusCheckException =
/*#__PURE__*/
function (_BaseException9) {
_babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3___default()(TransactionStatusCheckException, _BaseException9);
function TransactionStatusCheckException() {
var _this11;
for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
args[_key10] = arguments[_key10];
}
_this11 = _BaseException9.call.apply(_BaseException9, [this].concat(args)) || this;
_this11.name = 'TransactionStatusCheckException';
return _this11;
}
return TransactionStatusCheckException;
}(BaseException);
/**
* Thrown when there's an error signing a transaction
*/
var SigningException =
/*#__PURE__*/
function (_BaseException10) {
_babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3___default()(SigningException, _BaseException10);
function SigningException() {
var _this12;
for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
args[_key11] = arguments[_key11];
}
_this12 = _BaseException10.call.apply(_BaseException10, [this].concat(args)) || this;
_this12.name = 'SigningException';
return _this12;
}
return SigningException;
}(BaseException);
/**
* Thrown when a LocalWallet is created in a non browser environment
*/
var NotInBrowserException =
/*#__PURE__*/
function (_BaseException11) {
_babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3___default()(NotInBrowserException, _BaseException11);
function NotInBrowserException() {
var _this13;
for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
args[_key12] = arguments[_key12];
}
_this13 = _BaseException11.call.apply(_BaseException11, [this].concat(args)) || this;
_this13.name = 'NotInBrowserException';
return _this13;
}
return NotInBrowserException;
}(BaseException);
/**
* Thrown when the user rejects the request to sign
*/
var UserRejectedSigningException =
/*#__PURE__*/
function (_SigningException) {
_babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3___default()(UserRejectedSigningException, _SigningException);
function UserRejectedSigningException() {
var _this14;
for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
args[_key13] = arguments[_key13];
}
_this14 = _SigningException.call.apply(_SigningException, [this].concat(args)) || this;
_this14.name = 'UserRejectedSigningException';
return _this14;
}
return UserRejectedSigningException;
}(SigningException);
/**
* Thrown when a method on a class inheriting [SimbaBase]{@link SimbaBase} is called that requires
* a [Wallet]{@link Wallet} to be set, and it isn't.
*/
var WalletNotFoundException =
/*#__PURE__*/
function (_SigningException2) {
_babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3___default()(WalletNotFoundException, _SigningException2);
function WalletNotFoundException() {
var _this15;
for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
args[_key14] = arguments[_key14];
}
_this15 = _SigningException2.call.apply(_SigningException2, [this].concat(args)) || this;
_this15.name = 'WalletNotFoundException';
return _this15;
}
return WalletNotFoundException;
}(SigningException);
/**
* Thrown when a method on a class inheriting [SimbaBase]{@link SimbaBase} is called that requires
* a [Wallet]{@link Wallet} to be unlocked, and it isn't.
*/
var WalletLockedException =
/*#__PURE__*/
function (_SigningException3) {
_babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3___default()(WalletLockedException, _SigningException3);
function WalletLockedException() {
var _this16;
for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) {
args[_key15] = arguments[_key15];
}
_this16 = _SigningException3.call.apply(_SigningException3, [this].concat(args)) || this;
_this16.name = 'WalletLockedException';
return _this16;
}
return WalletLockedException;
}(SigningException);
/**
* Thrown when a method call exceeds the max retries
*/
var RetriesExceededException =
/*#__PURE__*/
function (_SigningException4) {
_babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_3___default()(RetriesExceededException, _SigningException4);
function RetriesExceededException() {
var _this17;
for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) {
args[_key16] = arguments[_key16];
}
_this17 = _SigningException4.call.apply(_SigningException4, [this].concat(args)) || this;
_this17.name = 'RetriesExceededException';
return _this17;
}
return RetriesExceededException;
}(SigningException);
/***/ }),
/* 2 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
// EXTERNAL MODULE: ./node_modules/@ethersproject/logger/lib.esm/index.js + 1 modules
var lib_esm = __webpack_require__(4);
// CONCATENATED MODULE: ./node_modules/@ethersproject/properties/lib.esm/_version.js
const version = "properties/5.0.0-beta.133";
// CONCATENATED MODULE: ./node_modules/@ethersproject/properties/lib.esm/index.js
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defineReadOnly", function() { return defineReadOnly; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getStatic", function() { return getStatic; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "resolveProperties", function() { return resolveProperties; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "checkProperties", function() { return checkProperties; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shallowCopy", function() { return shallowCopy; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "deepCopy", function() { return deepCopy; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Description", function() { return Description; });
const logger = new lib_esm["Logger"](version);
function defineReadOnly(object, name, value) {
Object.defineProperty(object, name, {
enumerable: true,
value: value,
writable: false,
});
}
// Crawl up the constructor chain to find a static method
function getStatic(ctor, key) {
for (let i = 0; i < 32; i++) {
if (ctor[key]) {
return ctor[key];
}
if (!ctor.prototype || typeof (ctor.prototype) !== "object") {
break;
}
ctor = Object.getPrototypeOf(ctor.prototype).constructor;
}
return null;
}
function resolveProperties(object) {
let promises = Object.keys(object).map((key) => {
let value = object[key];
if (!(value instanceof Promise)) {
return Promise.resolve({ key: key, value: value });
}
return value.then((value) => {
return { key: key, value: value };
});
});
return Promise.all(promises).then((results) => {
let result = {};
return results.reduce((accum, result) => {
accum[result.key] = result.value;
return accum;
}, result);
});
}
function checkProperties(object, properties) {
if (!object || typeof (object) !== "object") {
logger.throwArgumentError("invalid object", "object", object);
}
Object.keys(object).forEach((key) => {
if (!properties[key]) {
logger.throwArgumentError("invalid object key - " + key, "transaction:" + key, object);
}
});
}
function shallowCopy(object) {
let result = {};
for (let key in object) {
result[key] = object[key];
}
return result;
}
let opaque = { bigint: true, boolean: true, number: true, string: true };
// Returns a new copy of object, such that no properties may be replaced.
// New properties may be added only to objects.
function deepCopy(object) {
// Opaque objects are not mutable, so safe to copy by assignment
if (object === undefined || object === null || opaque[typeof (object)]) {
return object;
}
// Arrays are mutable, so we need to create a copy
if (Array.isArray(object)) {
return Object.freeze(object.map((item) => deepCopy(item)));
}
if (typeof (object) === "object") {
// Immutable objects are safe to just use
if (Object.isFrozen(object)) {
return object;
}
let result = {};
for (let key in object) {
let value = object[key];
if (value === undefined) {
continue;
}
defineReadOnly(result, key, deepCopy(value));
}
return result;
}
// The function type is also immutable, so safe to copy by assignment
if (typeof (object) === "function") {
return object;
}
throw new Error("Cannot deepCopy " + typeof (object));
}
class Description {
constructor(info) {
for (let key in info) {
this[key] = deepCopy(info[key]);
}
Object.freeze(this);
}
}
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(54);
/***/ }),
/* 4 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
// CONCATENATED MODULE: ./node_modules/@ethersproject/logger/lib.esm/_version.js
const version = "logger/5.0.0-beta.131";
// CONCATENATED MODULE: ./node_modules/@ethersproject/logger/lib.esm/index.js
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return lib_esm_Logger; });
let _permanentCensorErrors = false;
let _censorErrors = false;
const LogLevels = { debug: 1, "default": 2, info: 2, warn: 3, error: 4, off: 5 };
let LogLevel = LogLevels["default"];
let _globalLogger = null;
function _checkNormalize() {
try {
let missing = [];
// Make sure all forms of normalization are supported
["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => {
try {
if ("test".normalize(form) !== "test") {
throw new Error("bad normalize");
}
;
}
catch (error) {
missing.push(form);
}
});
if (missing.length) {
throw new Error("missing " + missing.join(", "));
}
if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) {
throw new Error("broken implementation");
}
}
catch (error) {
return error.message;
}
return null;
}
let _normalizeError = _checkNormalize();
class lib_esm_Logger {
constructor(version) {
Object.defineProperty(this, "version", {
enumerable: true,
value: version,
writable: false
});
}
setLogLevel(logLevel) {
let level = LogLevels[logLevel];
if (level == null) {
this.warn("invliad log level - " + logLevel);
return;
}
LogLevel = level;
}
_log(logLevel, args) {
if (LogLevel > LogLevels[logLevel]) {
return;
}
console.log.apply(console, args);
}
debug(...args) {
this._log(lib_esm_Logger.levels.DEBUG, args);
}
info(...args) {
this._log(lib_esm_Logger.levels.INFO, args);
}
warn(...args) {
this._log(lib_esm_Logger.levels.WARNING, args);
}
makeError(message, code, params) {
if (_censorErrors) {
return new Error("unknown error");
}
if (!code) {
code = lib_esm_Logger.errors.UNKNOWN_ERROR;
}
if (!params) {
params = {};
}
let messageDetails = [];
Object.keys(params).forEach((key) => {
try {
messageDetails.push(key + "=" + JSON.stringify(params[key]));
}
catch (error) {
messageDetails.push(key + "=" + JSON.stringify(params[key].toString()));
}
});
messageDetails.push("version=" + this.version);
let reason = message;
if (messageDetails.length) {
message += " (" + messageDetails.join(", ") + ")";
}
// @TODO: Any??
let error = new Error(message);
error.reason = reason;
error.code = code;
Object.keys(params).forEach(function (key) {
error[key] = params[key];
});
return error;
}
throwError(message, code, params) {
throw this.makeError(message, code, params);
}
throwArgumentError(message, name, value) {
return this.throwError(message, lib_esm_Logger.errors.INVALID_ARGUMENT, {
argument: name,
value: value
});
}
checkNormalize(message) {
if (message == null) {
message = "platform missing String.prototype.normalize";
}
if (_normalizeError) {
this.throwError("platform missing String.prototype.normalize", lib_esm_Logger.errors.UNSUPPORTED_OPERATION, {
operation: "String.prototype.normalize", form: _normalizeError
});
}
}
checkSafeUint53(value, message) {
if (typeof (value) !== "number") {
return;
}
if (message == null) {
message = "value not safe";
}
if (value < 0 || value >= 0x1fffffffffffff) {
this.throwError(message, lib_esm_Logger.errors.NUMERIC_FAULT, {
operation: "checkSafeInteger",
fault: "out-of-safe-range",
value: value
});
}
if (value % 1) {
this.throwError(message, lib_esm_Logger.errors.NUMERIC_FAULT, {
operation: "checkSafeInteger",
fault: "non-integer",
value: value
});
}
}
checkArgumentCount(count, expectedCount, message) {
if (message) {
message = ": " + message;
}
else {
message = "";
}
if (count < expectedCount) {
this.throwError("missing argument" + message, lib_esm_Logger.errors.MISSING_ARGUMENT, {
count: count,
expectedCount: expectedCount
});
}
if (count > expectedCount) {
this.throwError("too many arguments" + message, lib_esm_Logger.errors.UNEXPECTED_ARGUMENT, {
count: count,
expectedCount: expectedCount
});
}
}
checkNew(target, kind) {
if (target === Object || target == null) {
this.throwError("missing new", lib_esm_Logger.errors.MISSING_NEW, { name: kind.name });
}
}
checkAbstract(target, kind) {
if (target === kind) {
this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", lib_esm_Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" });
}
else if (target === Object || target == null) {
this.throwError("missing new", lib_esm_Logger.errors.MISSING_NEW, { name: kind.name });
}
}
static globalLogger() {
if (!_globalLogger) {
_globalLogger = new lib_esm_Logger(version);
}
return _globalLogger;
}
static setCensorship(censorship, permanent) {
if (_permanentCensorErrors) {
if (!censorship) {
return;
}
this.globalLogger().throwError("error censorship permanent", lib_esm_Logger.errors.UNSUPPORTED_OPERATION, {
operation: "setCensorship"
});
}
_censorErrors = !!censorship;
_permanentCensorErrors = !!permanent;
}
}
lib_esm_Logger.errors = {
///////////////////
// Generic Errors
// Unknown Error
UNKNOWN_ERROR: "UNKNOWN_ERROR",
// Not Implemented
NOT_IMPLEMENTED: "NOT_IMPLEMENTED",
// Unsupported Operation
// - operation
UNSUPPORTED_OPERATION: "UNSUPPORTED_OPERATION",
// Network Error (i.e. Ethereum Network, such as an invalid chain ID)
NETWORK_ERROR: "NETWORK_ERROR",
// Some sort of bad response from the server
SERVER_ERROR: "SERVER_ERROR",
// Timeout
TIMEOUT: "TIMEOUT",
///////////////////
// Operational Errors
// Buffer Overrun
BUFFER_OVERRUN: "BUFFER_OVERRUN",
// Numeric Fault
// - operation: the operation being executed
// - fault: the reason this faulted
NUMERIC_FAULT: "NUMERIC_FAULT",
///////////////////
// Argument Errors
// Missing new operator to an object
// - name: The name of the class
MISSING_NEW: "MISSING_NEW",
// Invalid argument (e.g. value is incompatible with type) to a function:
// - argument: The argument name that was invalid
// - value: The value of the argument
INVALID_ARGUMENT: "INVALID_ARGUMENT",
// Missing argument to a function:
// - count: The number of arguments received
// - expectedCount: The number of arguments expected
MISSING_ARGUMENT: "MISSING_ARGUMENT",
// Too many arguments
// - count: The number of arguments received
// - expectedCount: The number of arguments expected
UNEXPECTED_ARGUMENT: "UNEXPECTED_ARGUMENT",
///////////////////
// Blockchain Errors
// Call exception
// - transaction: the transaction
// - address?: the contract address
// - args?: The arguments passed into the function
// - method?: The Solidity method signature
// - errorSignature?: The EIP848 error signature
// - errorArgs?: The EIP848 error parameters
// - reason: The reason (only for EIP848 "Error(string)")
CALL_EXCEPTION: "CALL_EXCEPTION",
// Insufficien funds (< value + gasLimit * gasPrice)
// - transaction: the transaction attempted
INSUFFICIENT_FUNDS: "INSUFFICIENT_FUNDS",
// Nonce has already been used
// - transaction: the transaction attempted
NONCE_EXPIRED: "NONCE_EXPIRED",
// The replacement fee for the transaction is too low
// - transaction: the transaction attempted
REPLACEMENT_UNDERPRICED: "REPLACEMENT_UNDERPRICED",
// The gas limit could not be estimated
// - transaction: the transaction passed to estimateGas
UNPREDICTABLE_GAS_LIMIT: "UNPREDICTABLE_GAS_LIMIT",
};
lib_esm_Logger.levels = {
DEBUG: "DEBUG",
INFO: "INFO",
WARNING: "WARNING",
ERROR: "ERROR",
OFF: "OFF"
};
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(global) {var O = 'object';
var check = function (it) {
return it && it.Math == Math && it;
};
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
module.exports =
// eslint-disable-next-line no-undef
check(typeof globalThis == O && globalThis) ||
check(typeof window == O && window) ||
check(typeof self == O && self) ||
check(typeof global == O && global) ||
// eslint-disable-next-line no-new-func
Function('return this')();
/* WEBPACK VAR INJECTION */}.call(this, __webpack_requir