UNPKG

orbit-db

Version:

Distributed p2p database on IPFS

1,144 lines (1,091 loc) 3.25 MB
var OrbitDB; /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ "./node_modules/@ethersproject/abstract-provider/lib.esm/_version.js": /*!***************************************************************************!*\ !*** ./node_modules/@ethersproject/abstract-provider/lib.esm/_version.js ***! \***************************************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "version": () => (/* binding */ version) /* harmony export */ }); const version = "abstract-provider/5.7.0"; //# sourceMappingURL=_version.js.map /***/ }), /***/ "./node_modules/@ethersproject/abstract-provider/lib.esm/index.js": /*!************************************************************************!*\ !*** ./node_modules/@ethersproject/abstract-provider/lib.esm/index.js ***! \************************************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "BlockForkEvent": () => (/* binding */ BlockForkEvent), /* harmony export */ "ForkEvent": () => (/* binding */ ForkEvent), /* harmony export */ "Provider": () => (/* binding */ Provider), /* harmony export */ "TransactionForkEvent": () => (/* binding */ TransactionForkEvent), /* harmony export */ "TransactionOrderForkEvent": () => (/* binding */ TransactionOrderForkEvent) /* harmony export */ }); /* harmony import */ var _ethersproject_bignumber__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @ethersproject/bignumber */ "./node_modules/@ethersproject/bignumber/lib.esm/bignumber.js"); /* harmony import */ var _ethersproject_bytes__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @ethersproject/bytes */ "./node_modules/@ethersproject/bytes/lib.esm/index.js"); /* harmony import */ var _ethersproject_properties__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @ethersproject/properties */ "./node_modules/@ethersproject/properties/lib.esm/index.js"); /* harmony import */ var _ethersproject_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @ethersproject/logger */ "./node_modules/@ethersproject/logger/lib.esm/index.js"); /* harmony import */ var _version__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./_version */ "./node_modules/@ethersproject/abstract-provider/lib.esm/_version.js"); var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; const logger = new _ethersproject_logger__WEBPACK_IMPORTED_MODULE_0__.Logger(_version__WEBPACK_IMPORTED_MODULE_1__.version); ; ; //export type CallTransactionable = { // call(transaction: TransactionRequest): Promise<TransactionResponse>; //}; class ForkEvent extends _ethersproject_properties__WEBPACK_IMPORTED_MODULE_2__.Description { static isForkEvent(value) { return !!(value && value._isForkEvent); } } class BlockForkEvent extends ForkEvent { constructor(blockHash, expiry) { if (!(0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_3__.isHexString)(blockHash, 32)) { logger.throwArgumentError("invalid blockHash", "blockHash", blockHash); } super({ _isForkEvent: true, _isBlockForkEvent: true, expiry: (expiry || 0), blockHash: blockHash }); } } class TransactionForkEvent extends ForkEvent { constructor(hash, expiry) { if (!(0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_3__.isHexString)(hash, 32)) { logger.throwArgumentError("invalid transaction hash", "hash", hash); } super({ _isForkEvent: true, _isTransactionForkEvent: true, expiry: (expiry || 0), hash: hash }); } } class TransactionOrderForkEvent extends ForkEvent { constructor(beforeHash, afterHash, expiry) { if (!(0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_3__.isHexString)(beforeHash, 32)) { logger.throwArgumentError("invalid transaction hash", "beforeHash", beforeHash); } if (!(0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_3__.isHexString)(afterHash, 32)) { logger.throwArgumentError("invalid transaction hash", "afterHash", afterHash); } super({ _isForkEvent: true, _isTransactionOrderForkEvent: true, expiry: (expiry || 0), beforeHash: beforeHash, afterHash: afterHash }); } } /////////////////////////////// // Exported Abstracts class Provider { constructor() { logger.checkAbstract(new.target, Provider); (0,_ethersproject_properties__WEBPACK_IMPORTED_MODULE_2__.defineReadOnly)(this, "_isProvider", true); } getFeeData() { return __awaiter(this, void 0, void 0, function* () { const { block, gasPrice } = yield (0,_ethersproject_properties__WEBPACK_IMPORTED_MODULE_2__.resolveProperties)({ block: this.getBlock("latest"), gasPrice: this.getGasPrice().catch((error) => { // @TODO: Why is this now failing on Calaveras? //console.log(error); return null; }) }); let lastBaseFeePerGas = null, maxFeePerGas = null, maxPriorityFeePerGas = null; if (block && block.baseFeePerGas) { // We may want to compute this more accurately in the future, // using the formula "check if the base fee is correct". // See: https://eips.ethereum.org/EIPS/eip-1559 lastBaseFeePerGas = block.baseFeePerGas; maxPriorityFeePerGas = _ethersproject_bignumber__WEBPACK_IMPORTED_MODULE_4__.BigNumber.from("1500000000"); maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas); } return { lastBaseFeePerGas, maxFeePerGas, maxPriorityFeePerGas, gasPrice }; }); } // Alias for "on" addListener(eventName, listener) { return this.on(eventName, listener); } // Alias for "off" removeListener(eventName, listener) { return this.off(eventName, listener); } static isProvider(value) { return !!(value && value._isProvider); } } //# sourceMappingURL=index.js.map /***/ }), /***/ "./node_modules/@ethersproject/abstract-signer/lib.esm/_version.js": /*!*************************************************************************!*\ !*** ./node_modules/@ethersproject/abstract-signer/lib.esm/_version.js ***! \*************************************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "version": () => (/* binding */ version) /* harmony export */ }); const version = "abstract-signer/5.7.0"; //# sourceMappingURL=_version.js.map /***/ }), /***/ "./node_modules/@ethersproject/abstract-signer/lib.esm/index.js": /*!**********************************************************************!*\ !*** ./node_modules/@ethersproject/abstract-signer/lib.esm/index.js ***! \**********************************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "Signer": () => (/* binding */ Signer), /* harmony export */ "VoidSigner": () => (/* binding */ VoidSigner) /* harmony export */ }); /* harmony import */ var _ethersproject_properties__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @ethersproject/properties */ "./node_modules/@ethersproject/properties/lib.esm/index.js"); /* harmony import */ var _ethersproject_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @ethersproject/logger */ "./node_modules/@ethersproject/logger/lib.esm/index.js"); /* harmony import */ var _version__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./_version */ "./node_modules/@ethersproject/abstract-signer/lib.esm/_version.js"); var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; const logger = new _ethersproject_logger__WEBPACK_IMPORTED_MODULE_0__.Logger(_version__WEBPACK_IMPORTED_MODULE_1__.version); const allowedTransactionKeys = [ "accessList", "ccipReadEnabled", "chainId", "customData", "data", "from", "gasLimit", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "to", "type", "value" ]; const forwardErrors = [ _ethersproject_logger__WEBPACK_IMPORTED_MODULE_0__.Logger.errors.INSUFFICIENT_FUNDS, _ethersproject_logger__WEBPACK_IMPORTED_MODULE_0__.Logger.errors.NONCE_EXPIRED, _ethersproject_logger__WEBPACK_IMPORTED_MODULE_0__.Logger.errors.REPLACEMENT_UNDERPRICED, ]; ; ; class Signer { /////////////////// // Sub-classes MUST call super constructor() { logger.checkAbstract(new.target, Signer); (0,_ethersproject_properties__WEBPACK_IMPORTED_MODULE_2__.defineReadOnly)(this, "_isSigner", true); } /////////////////// // Sub-classes MAY override these getBalance(blockTag) { return __awaiter(this, void 0, void 0, function* () { this._checkProvider("getBalance"); return yield this.provider.getBalance(this.getAddress(), blockTag); }); } getTransactionCount(blockTag) { return __awaiter(this, void 0, void 0, function* () { this._checkProvider("getTransactionCount"); return yield this.provider.getTransactionCount(this.getAddress(), blockTag); }); } // Populates "from" if unspecified, and estimates the gas for the transaction estimateGas(transaction) { return __awaiter(this, void 0, void 0, function* () { this._checkProvider("estimateGas"); const tx = yield (0,_ethersproject_properties__WEBPACK_IMPORTED_MODULE_2__.resolveProperties)(this.checkTransaction(transaction)); return yield this.provider.estimateGas(tx); }); } // Populates "from" if unspecified, and calls with the transaction call(transaction, blockTag) { return __awaiter(this, void 0, void 0, function* () { this._checkProvider("call"); const tx = yield (0,_ethersproject_properties__WEBPACK_IMPORTED_MODULE_2__.resolveProperties)(this.checkTransaction(transaction)); return yield this.provider.call(tx, blockTag); }); } // Populates all fields in a transaction, signs it and sends it to the network sendTransaction(transaction) { return __awaiter(this, void 0, void 0, function* () { this._checkProvider("sendTransaction"); const tx = yield this.populateTransaction(transaction); const signedTx = yield this.signTransaction(tx); return yield this.provider.sendTransaction(signedTx); }); } getChainId() { return __awaiter(this, void 0, void 0, function* () { this._checkProvider("getChainId"); const network = yield this.provider.getNetwork(); return network.chainId; }); } getGasPrice() { return __awaiter(this, void 0, void 0, function* () { this._checkProvider("getGasPrice"); return yield this.provider.getGasPrice(); }); } getFeeData() { return __awaiter(this, void 0, void 0, function* () { this._checkProvider("getFeeData"); return yield this.provider.getFeeData(); }); } resolveName(name) { return __awaiter(this, void 0, void 0, function* () { this._checkProvider("resolveName"); return yield this.provider.resolveName(name); }); } // Checks a transaction does not contain invalid keys and if // no "from" is provided, populates it. // - does NOT require a provider // - adds "from" is not present // - returns a COPY (safe to mutate the result) // By default called from: (overriding these prevents it) // - call // - estimateGas // - populateTransaction (and therefor sendTransaction) checkTransaction(transaction) { for (const key in transaction) { if (allowedTransactionKeys.indexOf(key) === -1) { logger.throwArgumentError("invalid transaction key: " + key, "transaction", transaction); } } const tx = (0,_ethersproject_properties__WEBPACK_IMPORTED_MODULE_2__.shallowCopy)(transaction); if (tx.from == null) { tx.from = this.getAddress(); } else { // Make sure any provided address matches this signer tx.from = Promise.all([ Promise.resolve(tx.from), this.getAddress() ]).then((result) => { if (result[0].toLowerCase() !== result[1].toLowerCase()) { logger.throwArgumentError("from address mismatch", "transaction", transaction); } return result[0]; }); } return tx; } // Populates ALL keys for a transaction and checks that "from" matches // this Signer. Should be used by sendTransaction but NOT by signTransaction. // By default called from: (overriding these prevents it) // - sendTransaction // // Notes: // - We allow gasPrice for EIP-1559 as long as it matches maxFeePerGas populateTransaction(transaction) { return __awaiter(this, void 0, void 0, function* () { const tx = yield (0,_ethersproject_properties__WEBPACK_IMPORTED_MODULE_2__.resolveProperties)(this.checkTransaction(transaction)); if (tx.to != null) { tx.to = Promise.resolve(tx.to).then((to) => __awaiter(this, void 0, void 0, function* () { if (to == null) { return null; } const address = yield this.resolveName(to); if (address == null) { logger.throwArgumentError("provided ENS name resolves to null", "tx.to", to); } return address; })); // Prevent this error from causing an UnhandledPromiseException tx.to.catch((error) => { }); } // Do not allow mixing pre-eip-1559 and eip-1559 properties const hasEip1559 = (tx.maxFeePerGas != null || tx.maxPriorityFeePerGas != null); if (tx.gasPrice != null && (tx.type === 2 || hasEip1559)) { logger.throwArgumentError("eip-1559 transaction do not support gasPrice", "transaction", transaction); } else if ((tx.type === 0 || tx.type === 1) && hasEip1559) { logger.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas", "transaction", transaction); } if ((tx.type === 2 || tx.type == null) && (tx.maxFeePerGas != null && tx.maxPriorityFeePerGas != null)) { // Fully-formed EIP-1559 transaction (skip getFeeData) tx.type = 2; } else if (tx.type === 0 || tx.type === 1) { // Explicit Legacy or EIP-2930 transaction // Populate missing gasPrice if (tx.gasPrice == null) { tx.gasPrice = this.getGasPrice(); } } else { // We need to get fee data to determine things const feeData = yield this.getFeeData(); if (tx.type == null) { // We need to auto-detect the intended type of this transaction... if (feeData.maxFeePerGas != null && feeData.maxPriorityFeePerGas != null) { // The network supports EIP-1559! // Upgrade transaction from null to eip-1559 tx.type = 2; if (tx.gasPrice != null) { // Using legacy gasPrice property on an eip-1559 network, // so use gasPrice as both fee properties const gasPrice = tx.gasPrice; delete tx.gasPrice; tx.maxFeePerGas = gasPrice; tx.maxPriorityFeePerGas = gasPrice; } else { // Populate missing fee data if (tx.maxFeePerGas == null) { tx.maxFeePerGas = feeData.maxFeePerGas; } if (tx.maxPriorityFeePerGas == null) { tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas; } } } else if (feeData.gasPrice != null) { // Network doesn't support EIP-1559... // ...but they are trying to use EIP-1559 properties if (hasEip1559) { logger.throwError("network does not support EIP-1559", _ethersproject_logger__WEBPACK_IMPORTED_MODULE_0__.Logger.errors.UNSUPPORTED_OPERATION, { operation: "populateTransaction" }); } // Populate missing fee data if (tx.gasPrice == null) { tx.gasPrice = feeData.gasPrice; } // Explicitly set untyped transaction to legacy tx.type = 0; } else { // getFeeData has failed us. logger.throwError("failed to get consistent fee data", _ethersproject_logger__WEBPACK_IMPORTED_MODULE_0__.Logger.errors.UNSUPPORTED_OPERATION, { operation: "signer.getFeeData" }); } } else if (tx.type === 2) { // Explicitly using EIP-1559 // Populate missing fee data if (tx.maxFeePerGas == null) { tx.maxFeePerGas = feeData.maxFeePerGas; } if (tx.maxPriorityFeePerGas == null) { tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas; } } } if (tx.nonce == null) { tx.nonce = this.getTransactionCount("pending"); } if (tx.gasLimit == null) { tx.gasLimit = this.estimateGas(tx).catch((error) => { if (forwardErrors.indexOf(error.code) >= 0) { throw error; } return logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", _ethersproject_logger__WEBPACK_IMPORTED_MODULE_0__.Logger.errors.UNPREDICTABLE_GAS_LIMIT, { error: error, tx: tx }); }); } if (tx.chainId == null) { tx.chainId = this.getChainId(); } else { tx.chainId = Promise.all([ Promise.resolve(tx.chainId), this.getChainId() ]).then((results) => { if (results[1] !== 0 && results[0] !== results[1]) { logger.throwArgumentError("chainId address mismatch", "transaction", transaction); } return results[0]; }); } return yield (0,_ethersproject_properties__WEBPACK_IMPORTED_MODULE_2__.resolveProperties)(tx); }); } /////////////////// // Sub-classes SHOULD leave these alone _checkProvider(operation) { if (!this.provider) { logger.throwError("missing provider", _ethersproject_logger__WEBPACK_IMPORTED_MODULE_0__.Logger.errors.UNSUPPORTED_OPERATION, { operation: (operation || "_checkProvider") }); } } static isSigner(value) { return !!(value && value._isSigner); } } class VoidSigner extends Signer { constructor(address, provider) { super(); (0,_ethersproject_properties__WEBPACK_IMPORTED_MODULE_2__.defineReadOnly)(this, "address", address); (0,_ethersproject_properties__WEBPACK_IMPORTED_MODULE_2__.defineReadOnly)(this, "provider", provider || null); } getAddress() { return Promise.resolve(this.address); } _fail(message, operation) { return Promise.resolve().then(() => { logger.throwError(message, _ethersproject_logger__WEBPACK_IMPORTED_MODULE_0__.Logger.errors.UNSUPPORTED_OPERATION, { operation: operation }); }); } signMessage(message) { return this._fail("VoidSigner cannot sign messages", "signMessage"); } signTransaction(transaction) { return this._fail("VoidSigner cannot sign transactions", "signTransaction"); } _signTypedData(domain, types, value) { return this._fail("VoidSigner cannot sign typed data", "signTypedData"); } connect(provider) { return new VoidSigner(this.address, provider); } } //# sourceMappingURL=index.js.map /***/ }), /***/ "./node_modules/@ethersproject/address/lib.esm/_version.js": /*!*****************************************************************!*\ !*** ./node_modules/@ethersproject/address/lib.esm/_version.js ***! \*****************************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "version": () => (/* binding */ version) /* harmony export */ }); const version = "address/5.7.0"; //# sourceMappingURL=_version.js.map /***/ }), /***/ "./node_modules/@ethersproject/address/lib.esm/index.js": /*!**************************************************************!*\ !*** ./node_modules/@ethersproject/address/lib.esm/index.js ***! \**************************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "getAddress": () => (/* binding */ getAddress), /* harmony export */ "getContractAddress": () => (/* binding */ getContractAddress), /* harmony export */ "getCreate2Address": () => (/* binding */ getCreate2Address), /* harmony export */ "getIcapAddress": () => (/* binding */ getIcapAddress), /* harmony export */ "isAddress": () => (/* binding */ isAddress) /* harmony export */ }); /* harmony import */ var _ethersproject_bytes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @ethersproject/bytes */ "./node_modules/@ethersproject/bytes/lib.esm/index.js"); /* harmony import */ var _ethersproject_bignumber__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @ethersproject/bignumber */ "./node_modules/@ethersproject/bignumber/lib.esm/bignumber.js"); /* harmony import */ var _ethersproject_keccak256__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @ethersproject/keccak256 */ "./node_modules/@ethersproject/keccak256/lib.esm/index.js"); /* harmony import */ var _ethersproject_rlp__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @ethersproject/rlp */ "./node_modules/@ethersproject/rlp/lib.esm/index.js"); /* harmony import */ var _ethersproject_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @ethersproject/logger */ "./node_modules/@ethersproject/logger/lib.esm/index.js"); /* harmony import */ var _version__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./_version */ "./node_modules/@ethersproject/address/lib.esm/_version.js"); const logger = new _ethersproject_logger__WEBPACK_IMPORTED_MODULE_0__.Logger(_version__WEBPACK_IMPORTED_MODULE_1__.version); function getChecksumAddress(address) { if (!(0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_2__.isHexString)(address, 20)) { logger.throwArgumentError("invalid address", "address", address); } address = address.toLowerCase(); const chars = address.substring(2).split(""); const expanded = new Uint8Array(40); for (let i = 0; i < 40; i++) { expanded[i] = chars[i].charCodeAt(0); } const hashed = (0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_2__.arrayify)((0,_ethersproject_keccak256__WEBPACK_IMPORTED_MODULE_3__.keccak256)(expanded)); for (let i = 0; i < 40; i += 2) { if ((hashed[i >> 1] >> 4) >= 8) { chars[i] = chars[i].toUpperCase(); } if ((hashed[i >> 1] & 0x0f) >= 8) { chars[i + 1] = chars[i + 1].toUpperCase(); } } return "0x" + chars.join(""); } // Shims for environments that are missing some required constants and functions const MAX_SAFE_INTEGER = 0x1fffffffffffff; function log10(x) { if (Math.log10) { return Math.log10(x); } return Math.log(x) / Math.LN10; } // See: https://en.wikipedia.org/wiki/International_Bank_Account_Number // Create lookup table const ibanLookup = {}; for (let i = 0; i < 10; i++) { ibanLookup[String(i)] = String(i); } for (let i = 0; i < 26; i++) { ibanLookup[String.fromCharCode(65 + i)] = String(10 + i); } // How many decimal digits can we process? (for 64-bit float, this is 15) const safeDigits = Math.floor(log10(MAX_SAFE_INTEGER)); function ibanChecksum(address) { address = address.toUpperCase(); address = address.substring(4) + address.substring(0, 2) + "00"; let expanded = address.split("").map((c) => { return ibanLookup[c]; }).join(""); // Javascript can handle integers safely up to 15 (decimal) digits while (expanded.length >= safeDigits) { let block = expanded.substring(0, safeDigits); expanded = parseInt(block, 10) % 97 + expanded.substring(block.length); } let checksum = String(98 - (parseInt(expanded, 10) % 97)); while (checksum.length < 2) { checksum = "0" + checksum; } return checksum; } ; function getAddress(address) { let result = null; if (typeof (address) !== "string") { logger.throwArgumentError("invalid address", "address", address); } if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) { // Missing the 0x prefix if (address.substring(0, 2) !== "0x") { address = "0x" + address; } result = getChecksumAddress(address); // It is a checksummed address with a bad checksum if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) { logger.throwArgumentError("bad address checksum", "address", address); } // Maybe ICAP? (we only support direct mode) } else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { // It is an ICAP address with a bad checksum if (address.substring(2, 4) !== ibanChecksum(address)) { logger.throwArgumentError("bad icap checksum", "address", address); } result = (0,_ethersproject_bignumber__WEBPACK_IMPORTED_MODULE_4__._base36To16)(address.substring(4)); while (result.length < 40) { result = "0" + result; } result = getChecksumAddress("0x" + result); } else { logger.throwArgumentError("invalid address", "address", address); } return result; } function isAddress(address) { try { getAddress(address); return true; } catch (error) { } return false; } function getIcapAddress(address) { let base36 = (0,_ethersproject_bignumber__WEBPACK_IMPORTED_MODULE_4__._base16To36)(getAddress(address).substring(2)).toUpperCase(); while (base36.length < 30) { base36 = "0" + base36; } return "XE" + ibanChecksum("XE00" + base36) + base36; } // http://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed function getContractAddress(transaction) { let from = null; try { from = getAddress(transaction.from); } catch (error) { logger.throwArgumentError("missing from address", "transaction", transaction); } const nonce = (0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_2__.stripZeros)((0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_2__.arrayify)(_ethersproject_bignumber__WEBPACK_IMPORTED_MODULE_4__.BigNumber.from(transaction.nonce).toHexString())); return getAddress((0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_2__.hexDataSlice)((0,_ethersproject_keccak256__WEBPACK_IMPORTED_MODULE_3__.keccak256)((0,_ethersproject_rlp__WEBPACK_IMPORTED_MODULE_5__.encode)([from, nonce])), 12)); } function getCreate2Address(from, salt, initCodeHash) { if ((0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_2__.hexDataLength)(salt) !== 32) { logger.throwArgumentError("salt must be 32 bytes", "salt", salt); } if ((0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_2__.hexDataLength)(initCodeHash) !== 32) { logger.throwArgumentError("initCodeHash must be 32 bytes", "initCodeHash", initCodeHash); } return getAddress((0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_2__.hexDataSlice)((0,_ethersproject_keccak256__WEBPACK_IMPORTED_MODULE_3__.keccak256)((0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_2__.concat)(["0xff", getAddress(from), salt, initCodeHash])), 12)); } //# sourceMappingURL=index.js.map /***/ }), /***/ "./node_modules/@ethersproject/basex/lib.esm/index.js": /*!************************************************************!*\ !*** ./node_modules/@ethersproject/basex/lib.esm/index.js ***! \************************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "Base32": () => (/* binding */ Base32), /* harmony export */ "Base58": () => (/* binding */ Base58), /* harmony export */ "BaseX": () => (/* binding */ BaseX) /* harmony export */ }); /* harmony import */ var _ethersproject_bytes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @ethersproject/bytes */ "./node_modules/@ethersproject/bytes/lib.esm/index.js"); /* harmony import */ var _ethersproject_properties__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @ethersproject/properties */ "./node_modules/@ethersproject/properties/lib.esm/index.js"); /** * var basex = require("base-x"); * * This implementation is heavily based on base-x. The main reason to * deviate was to prevent the dependency of Buffer. * * Contributors: * * base-x encoding * Forked from https://github.com/cryptocoinjs/bs58 * Originally written by Mike Hearn for BitcoinJ * Copyright (c) 2011 Google Inc * Ported to JavaScript by Stefan Thomas * Merged Buffer refactorings from base58-native by Stephen Pair * Copyright (c) 2013 BitPay Inc * * The MIT License (MIT) * * Copyright base-x contributors (c) 2016 * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. * */ class BaseX { constructor(alphabet) { (0,_ethersproject_properties__WEBPACK_IMPORTED_MODULE_0__.defineReadOnly)(this, "alphabet", alphabet); (0,_ethersproject_properties__WEBPACK_IMPORTED_MODULE_0__.defineReadOnly)(this, "base", alphabet.length); (0,_ethersproject_properties__WEBPACK_IMPORTED_MODULE_0__.defineReadOnly)(this, "_alphabetMap", {}); (0,_ethersproject_properties__WEBPACK_IMPORTED_MODULE_0__.defineReadOnly)(this, "_leader", alphabet.charAt(0)); // pre-compute lookup table for (let i = 0; i < alphabet.length; i++) { this._alphabetMap[alphabet.charAt(i)] = i; } } encode(value) { let source = (0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_1__.arrayify)(value); if (source.length === 0) { return ""; } let digits = [0]; for (let i = 0; i < source.length; ++i) { let carry = source[i]; for (let j = 0; j < digits.length; ++j) { carry += digits[j] << 8; digits[j] = carry % this.base; carry = (carry / this.base) | 0; } while (carry > 0) { digits.push(carry % this.base); carry = (carry / this.base) | 0; } } let string = ""; // deal with leading zeros for (let k = 0; source[k] === 0 && k < source.length - 1; ++k) { string += this._leader; } // convert digits to a string for (let q = digits.length - 1; q >= 0; --q) { string += this.alphabet[digits[q]]; } return string; } decode(value) { if (typeof (value) !== "string") { throw new TypeError("Expected String"); } let bytes = []; if (value.length === 0) { return new Uint8Array(bytes); } bytes.push(0); for (let i = 0; i < value.length; i++) { let byte = this._alphabetMap[value[i]]; if (byte === undefined) { throw new Error("Non-base" + this.base + " character"); } let carry = byte; for (let j = 0; j < bytes.length; ++j) { carry += bytes[j] * this.base; bytes[j] = carry & 0xff; carry >>= 8; } while (carry > 0) { bytes.push(carry & 0xff); carry >>= 8; } } // deal with leading zeros for (let k = 0; value[k] === this._leader && k < value.length - 1; ++k) { bytes.push(0); } return (0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_1__.arrayify)(new Uint8Array(bytes.reverse())); } } const Base32 = new BaseX("abcdefghijklmnopqrstuvwxyz234567"); const Base58 = new BaseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"); //console.log(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj")) //console.log(Base58.encode(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj"))) //# sourceMappingURL=index.js.map /***/ }), /***/ "./node_modules/@ethersproject/bignumber/lib.esm/_version.js": /*!*******************************************************************!*\ !*** ./node_modules/@ethersproject/bignumber/lib.esm/_version.js ***! \*******************************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "version": () => (/* binding */ version) /* harmony export */ }); const version = "bignumber/5.7.0"; //# sourceMappingURL=_version.js.map /***/ }), /***/ "./node_modules/@ethersproject/bignumber/lib.esm/bignumber.js": /*!********************************************************************!*\ !*** ./node_modules/@ethersproject/bignumber/lib.esm/bignumber.js ***! \********************************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "BigNumber": () => (/* binding */ BigNumber), /* harmony export */ "_base16To36": () => (/* binding */ _base16To36), /* harmony export */ "_base36To16": () => (/* binding */ _base36To16), /* harmony export */ "isBigNumberish": () => (/* binding */ isBigNumberish) /* harmony export */ }); /* harmony import */ var bn_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! bn.js */ "./node_modules/bn.js/lib/bn.js"); /* harmony import */ var bn_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(bn_js__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _ethersproject_bytes__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @ethersproject/bytes */ "./node_modules/@ethersproject/bytes/lib.esm/index.js"); /* harmony import */ var _ethersproject_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @ethersproject/logger */ "./node_modules/@ethersproject/logger/lib.esm/index.js"); /* harmony import */ var _version__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./_version */ "./node_modules/@ethersproject/bignumber/lib.esm/_version.js"); /** * BigNumber * * A wrapper around the BN.js object. We use the BN.js library * because it is used by elliptic, so it is required regardless. * */ var BN = (bn_js__WEBPACK_IMPORTED_MODULE_0___default().BN); const logger = new _ethersproject_logger__WEBPACK_IMPORTED_MODULE_1__.Logger(_version__WEBPACK_IMPORTED_MODULE_2__.version); const _constructorGuard = {}; const MAX_SAFE = 0x1fffffffffffff; function isBigNumberish(value) { return (value != null) && (BigNumber.isBigNumber(value) || (typeof (value) === "number" && (value % 1) === 0) || (typeof (value) === "string" && !!value.match(/^-?[0-9]+$/)) || (0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_3__.isHexString)(value) || (typeof (value) === "bigint") || (0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_3__.isBytes)(value)); } // Only warn about passing 10 into radix once let _warnedToStringRadix = false; class BigNumber { constructor(constructorGuard, hex) { if (constructorGuard !== _constructorGuard) { logger.throwError("cannot call constructor directly; use BigNumber.from", _ethersproject_logger__WEBPACK_IMPORTED_MODULE_1__.Logger.errors.UNSUPPORTED_OPERATION, { operation: "new (BigNumber)" }); } this._hex = hex; this._isBigNumber = true; Object.freeze(this); } fromTwos(value) { return toBigNumber(toBN(this).fromTwos(value)); } toTwos(value) { return toBigNumber(toBN(this).toTwos(value)); } abs() { if (this._hex[0] === "-") { return BigNumber.from(this._hex.substring(1)); } return this; } add(other) { return toBigNumber(toBN(this).add(toBN(other))); } sub(other) { return toBigNumber(toBN(this).sub(toBN(other))); } div(other) { const o = BigNumber.from(other); if (o.isZero()) { throwFault("division-by-zero", "div"); } return toBigNumber(toBN(this).div(toBN(other))); } mul(other) { return toBigNumber(toBN(this).mul(toBN(other))); } mod(other) { const value = toBN(other); if (value.isNeg()) { throwFault("division-by-zero", "mod"); } return toBigNumber(toBN(this).umod(value)); } pow(other) { const value = toBN(other); if (value.isNeg()) { throwFault("negative-power", "pow"); } return toBigNumber(toBN(this).pow(value)); } and(other) { const value = toBN(other); if (this.isNegative() || value.isNeg()) { throwFault("unbound-bitwise-result", "and"); } return toBigNumber(toBN(this).and(value)); } or(other) { const value = toBN(other); if (this.isNegative() || value.isNeg()) { throwFault("unbound-bitwise-result", "or"); } return toBigNumber(toBN(this).or(value)); } xor(other) { const value = toBN(other); if (this.isNegative() || value.isNeg()) { throwFault("unbound-bitwise-result", "xor"); } return toBigNumber(toBN(this).xor(value)); } mask(value) { if (this.isNegative() || value < 0) { throwFault("negative-width", "mask"); } return toBigNumber(toBN(this).maskn(value)); } shl(value) { if (this.isNegative() || value < 0) { throwFault("negative-width", "shl"); } return toBigNumber(toBN(this).shln(value)); } shr(value) { if (this.isNegative() || value < 0) { throwFault("negative-width", "shr"); } return toBigNumber(toBN(this).shrn(value)); } eq(other) { return toBN(this).eq(toBN(other)); } lt(other) { return toBN(this).lt(toBN(other)); } lte(other) { return toBN(this).lte(toBN(other)); } gt(other) { return toBN(this).gt(toBN(other)); } gte(other) { return toBN(this).gte(toBN(other)); } isNegative() { return (this._hex[0] === "-"); } isZero() { return toBN(this).isZero(); } toNumber() { try { return toBN(this).toNumber(); } catch (error) { throwFault("overflow", "toNumber", this.toString()); } return null; } toBigInt() { try { return BigInt(this.toString()); } catch (e) { } return logger.throwError("this platform does not support BigInt", _ethersproject_logger__WEBPACK_IMPORTED_MODULE_1__.Logger.errors.UNSUPPORTED_OPERATION, { value: this.toString() }); } toString() { // Lots of people expect this, which we do not support, so check (See: #889) if (arguments.length > 0) { if (arguments[0] === 10) { if (!_warnedToStringRadix) { _warnedToStringRadix = true; logger.warn("BigNumber.toString does not accept any parameters; base-10 is assumed"); } } else if (arguments[0] === 16) { logger.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", _ethersproject_logger__WEBPACK_IMPORTED_MODULE_1__.Logger.errors.UNEXPECTED_ARGUMENT, {}); } else { logger.throwError("BigNumber.toString does not accept parameters", _ethersproject_logger__WEBPACK_IMPORTED_MODULE_1__.Logger.errors.UNEXPECTED_ARGUMENT, {}); } } return toBN(this).toString(10); } toHexString() { return this._hex; } toJSON(key) { return { type: "BigNumber", hex: this.toHexString() }; } static from(value) { if (value instanceof BigNumber) { return value; } if (typeof (value) === "string") { if (value.match(/^-?0x[0-9a-f]+$/i)) { return new BigNumber(_constructorGuard, toHex(value)); } if (value.match(/^-?[0-9]+$/)) { return new BigNumber(_constructorGuard, toHex(new BN(value))); } return logger.throwArgumentError("invalid BigNumber string", "value", value); } if (typeof (value) === "number") { if (value % 1) { throwFault("underflow", "BigNumber.from", value); } if (value >= MAX_SAFE || value <= -MAX_SAFE) { throwFault("overflow", "BigNumber.from", value); } return BigNumber.from(String(value)); } const anyValue = value; if (typeof (anyValue) === "bigint") { return BigNumber.from(anyValue.toString()); } if ((0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_3__.isBytes)(anyValue)) { return BigNumber.from((0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_3__.hexlify)(anyValue)); } if (anyValue) { // Hexable interface (takes priority) if (anyValue.toHexString) { const hex = anyValue.toHexString(); if (typeof (hex) === "string") { return BigNumber.from(hex); } } else { // For now, handle legacy JSON-ified values (goes away in v6) let hex = anyValue._hex; // New-form JSON if (hex == null && anyValue.type === "BigNumber") { hex = anyValue.hex; } if (typeof (hex) === "string") { if ((0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_3__.isHexString)(hex) || (hex[0] === "-" && (0,_ethersproject_bytes__WEBPACK_IMPORTED_MODULE_3__.isHexString)(hex.substring(1)))) { return BigNumber.from(hex); } } } } return logger.throwArgumentError("invalid BigNumber value", "value", value); } static isBigNumber(value) { return !!(value && value._isBigNumber); } } // Normalize the hex string function toHex(value) { // For BN, call on the hex string if (typeof (value) !== "string") { return toHex(value.toString(16)); } // If negative, prepend the negative sign to the normalized positive value if (value[0] === "-") { // Strip off the negative sign value = value.substring(1); // Cannot have multiple negative signs (e.g. "--0x04") if (value[0] === "-") { logger.throwArgumentError("invalid hex", "value", value); } // Call toHex on the positive component value = toHex(value); // Do not allow "-0x00" if (value === "0x00") { return value; } // Negate the value return "-" + value; } // Add a "0x" prefix if missing if (value.substring(0, 2) !== "0x") { value = "0x" + value; } // Normalize zero if (value === "0x") { return "0x00"; } // Make the string even length if (value.length % 2) { value = "0x0" + value.substring(2); } // Trim to smallest even-length string while (value.length > 4 && value.substring(0, 4) === "0x00") { value = "0x" + value.substring(4); } return value; } function toBigNumber(value) { return BigNumber.from(toHex(value)); } function toBN(value) { const hex = BigNumber.from(value).toHexString(); if (hex[0] === "-") { return (new BN("-" + hex.substring(3), 16)); } return new BN(hex.substring(2), 16); } function throwFault(fault, operation, value) { const params = { fault: fault, operation: operation }; if (value != null) { params.value = value; } return logger.throwError(fault, _ethersproject_logger__WEBPACK_IMPORTED_MODULE_1__.Logger.errors.NUMERIC_FAULT, params); } // value should have no prefix function _base36To16(value) { return (new BN(value, 36)).toString(16); } // value should have no prefix function _base16To36(value) { return (new BN(value, 16)).toString(36); } //# sourceMappingURL=bignumber.js.map /***/