From b8ebf21cb4893d38cd9ccbcf2329e647097dc5a5 Mon Sep 17 00:00:00 2001 From: tornadocontrib Date: Sun, 17 Nov 2024 00:42:59 +0000 Subject: [PATCH] Add APY command --- dist/cli.js | 8489 +++++++++++++++++++++++++++------ dist/services/nodeEvents.d.ts | 26 +- package.json | 5 +- src/program.ts | 166 +- src/services/nodeEvents.ts | 152 +- yarn.lock | 171 +- 6 files changed, 7448 insertions(+), 1561 deletions(-) diff --git a/dist/cli.js b/dist/cli.js index 3ee6ba0..6bb7096 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -896,6 +896,391 @@ module.exports = { }; +/***/ }), + +/***/ 15795: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +/* + ISC License + + Copyright (c) 2019, Pierre-Louis Despaigne + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +const CID = __webpack_require__(26613); + +// Label's max length in DNS (https://tools.ietf.org/html/rfc1034#page-7) +const dnsLabelMaxLength = 63; + +/** + * Take any ipfsHash and convert it to DNS-compatible CID + * @param {string} ipfsHash a regular ipfs hash either a cid v0 or v1 + * @return {string} the resulting ipfs hash as a cid v1 + */ +const cidForWeb = (ipfsHash) => { + let cid = new CID(ipfsHash); + if (cid.version === 0) { + cid = cid.toV1(); + } + let dnsLabel = cid.toString('base32'); + if (dnsLabel.length > dnsLabelMaxLength) { + const b36 = cid.toString('base36'); + if (b36.length <= dnsLabelMaxLength) { + return b36; + } + throw new TypeError ('CID is longer than DNS limit of 63 characters and is not compatible with public gateways'); + } + return dnsLabel; +} + +exports.cidForWeb = cidForWeb; + + +/** + * Take any ipfsHash and convert it to a CID v1 encoded in base32. + * @param {string} ipfsHash a regular ipfs hash either a cid v0 or v1 (v1 will remain unchanged) + * @return {string} the resulting ipfs hash as a cid v1 + */ +const cidV0ToV1Base32 = (ipfsHash) => { + let cid = new CID(ipfsHash); + if (cid.version === 0) { + cid = cid.toV1(); + } + return cid.toString('base32'); +} + +exports.cidV0ToV1Base32 = cidV0ToV1Base32; + + +/***/ }), + +/***/ 81810: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +/* + ISC License + + Copyright (c) 2019, Pierre-Louis Despaigne + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +const multiC = __webpack_require__(52021); +const multiH = __webpack_require__(14243); + +const { hexStringToBuffer, profiles } = __webpack_require__(55262); +const { cidForWeb, cidV0ToV1Base32 } = __webpack_require__(15795); + +module.exports = { + + //export some helpers functions + helpers: { + cidForWeb, + cidV0ToV1Base32, + }, + + /** + * Decode a Content Hash. + * @param {string} hash an hex string containing a content hash + * @return {string} the decoded content + */ + decode: function (contentHash) { + const buffer = hexStringToBuffer(contentHash); + const codec = multiC.getCodec(buffer); + const value = multiC.rmPrefix(buffer); + let profile = profiles[codec]; + if (!profile) profile = profiles['default']; + return profile.decode(value); + }, + + /** + * Encode an IPFS address into a content hash + * @param {string} ipfsHash string containing an IPFS address + * @return {string} the resulting content hash + */ + fromIpfs: function (ipfsHash) { + return this.encode('ipfs-ns', ipfsHash); + }, + + /** + * Encode a Skylink into a content hash + * @param {string} skylink string containing a Skylink + * @return {string} the resulting content hash + */ + fromSkylink: function (skylink) { + return this.encode('skynet-ns', skylink); + }, + + /** + * Encode a Swarm address into a content hash + * @param {string} swarmHash string containing a Swarm address + * @return {string} the resulting content hash + */ + fromSwarm: function (swarmHash) { + return this.encode('swarm-ns', swarmHash); + }, + + /** + * Encode a arweave address into a content hash + * @param {string} swarmHash string containing a arweave address + * @return {string} the resulting content hash + */ + fromArweave: function(arweave) { + return this.encode('arweave-ns', arweave); + }, + + /** + * General purpose encoding function + * @param {string} codec + * @param {string} value + */ + encode: function (codec, value) { + let profile = profiles[codec]; + if (!profile) profile = profiles['default']; + const encodedValue = profile.encode(value); + return multiH.toHexString(multiC.addPrefix(codec, encodedValue)) + }, + + /** + * Extract the codec of a content hash + * @param {string} hash hex string containing a content hash + * @return {string} the extracted codec + */ + getCodec: function (hash) { + let buffer = hexStringToBuffer(hash); + return multiC.getCodec(buffer); + }, +} + + +/***/ }), + +/***/ 55262: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +/* + ISC License + + Copyright (c) 2019, Pierre-Louis Despaigne + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +const CID = __webpack_require__(26613); +const multiH = __webpack_require__(14243); +const base64 = __webpack_require__(8127) + +/** + * Convert an hexadecimal string to a Buffer, the string can start with or without '0x' + * @param {string} hex an hexadecimal value + * @return {Buffer} the resulting Buffer + */ +const hexStringToBuffer = (hex) => { + let prefix = hex.slice(0, 2); + let value = hex.slice(2); + let res = ''; + if (prefix === '0x') res = value; + else res = hex; + return multiH.fromHexString(res); +} + +/** + * Validates IPNS identifier to safeguard against insecure names. + * @param {CID} name ised in ipns-ns + * @return {bool} + */ +const isCryptographicIPNS = (cid) => { + try { + const { multihash } = cid + // Additional check for identifiers shorter + // than what inlined ED25519 pubkey would be + // https://github.com/ensdomains/ens-app/issues/849#issuecomment-777088950 + if (multihash.length < 38) { + const mh = multiH.decode(multihash) + // ED25519 pubkeys are inlined using identity hash function + // and we should not see anything shorter than that + if (mh.name === 'identity' && mh.length < 36) { + // One can read inlined string value via: + // console.log('ipns-ns id:', String(multiH.decode(new CID(value).multihash).digest)) + return false + } + } + // ok, CID looks fine + return true + } catch (_) { return false } +} + +/** +* list of known encoding, +* encoding should be a function that takes a `string` input, +* and return a `Buffer` result +*/ +const encodes = { + /** + * @param {string} value + * @return {Buffer} + */ + skynet: (value) => { + return base64.toUint8Array(value) + }, + /** + * @param {string} value + * @return {Buffer} + */ + swarm: (value) => { + const multihash = multiH.encode(hexStringToBuffer(value), 'keccak-256'); + return new CID(1, 'swarm-manifest', multihash).bytes; + }, + /** + * @param {string} value + * @return {Buffer} + */ + ipfs: (value) => { + return new CID(value).toV1().bytes; + }, + /** + * @param {string} value + * @return {Buffer} + */ + ipns: (value) => { + const cid = new CID(value) + if (!isCryptographicIPNS(cid)) { + throw Error('ipns-ns allows only valid cryptographic libp2p-key identifiers, try using ED25519 pubkey instead') + } + // Represent IPNS name as a CID with libp2p-key codec + // https://github.com/libp2p/specs/blob/master/RFC/0001-text-peerid-cid.md + return new CID(1, 'libp2p-key', cid.multihash).bytes + }, + /** + * @param {string} value + * @return {Buffer} + */ + utf8: (value) => { + return Buffer.from(value, 'utf8'); + }, + /** + * @param {string} value + * @return {Buffer} + */ + arweave: (value) => { + return base64.toUint8Array(value) + }, +}; + +/** +* list of known decoding, +* decoding should be a function that takes a `Buffer` input, +* and return a `string` result +*/ +const decodes = { + /** + * @param {Buffer} value + */ + hexMultiHash: (value) => { + const cid = new CID(value); + return multiH.decode(cid.multihash).digest.toString('hex'); + }, + /** + * @param {Buffer} value + */ + ipfs: (value) => { + const cid = new CID(value).toV1(); + return cid.toString(cid.codec === 'libp2p-key' ? 'base36' : 'base32') + }, + /** + * @param {Buffer} value + */ + ipns: (value) => { + const cid = new CID(value).toV1() + if (!isCryptographicIPNS(cid)) { + // Value is not a libp2p-key, return original string + console.warn('[ensdomains/content-hash] use of non-cryptographic identifiers in ipns-ns is deprecated and will be removed, migrate to ED25519 libp2p-key') + return String(multiH.decode(new CID(value).multihash).digest) + // TODO: start throwing an error (after some deprecation period) + // throw Error('ipns-ns allows only valid cryptographic libp2p-key identifiers, try using ED25519 pubkey instead') + } + return cid.toString('base36') + }, + /** + * @param {Buffer} value + */ + utf8: (value) => { + return value.toString('utf8'); + }, + base64: (value) => { + // `true` option makes it URL safe (replaces / and + with - and _ ) + return base64.fromUint8Array(value, true) + } +}; + +/** +* list of known encoding/decoding for a given codec, +* `encode` should be chosen among the `encodes` functions +* `decode` should be chosen among the `decodes` functions +*/ +const profiles = { + 'skynet-ns': { + encode: encodes.skynet, + decode: decodes.base64, + }, + 'swarm-ns': { + encode: encodes.swarm, + decode: decodes.hexMultiHash, + }, + 'ipfs-ns': { + encode: encodes.ipfs, + decode: decodes.ipfs, + }, + 'ipns-ns': { + encode: encodes.ipns, + decode: decodes.ipns, + }, + 'arweave-ns': { + encode: encodes.arweave, + decode: decodes.base64, + }, + 'default': { + encode: encodes.utf8, + decode: decodes.utf8, + }, +}; + +exports.hexStringToBuffer = hexStringToBuffer; +exports.profiles = profiles; + + /***/ }), /***/ 66289: @@ -6435,6 +6820,139 @@ function randomBytes(bytesLength = 32) { } //# sourceMappingURL=utils.js.map +/***/ }), + +/***/ 25084: +/***/ ((module) => { + +"use strict"; + +// base-x encoding / decoding +// Copyright (c) 2018 base-x contributors +// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp) +// Distributed under the MIT software license, see the accompanying +// file LICENSE or http://www.opensource.org/licenses/mit-license.php. +function base (ALPHABET) { + if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') } + var BASE_MAP = new Uint8Array(256) + for (var j = 0; j < BASE_MAP.length; j++) { + BASE_MAP[j] = 255 + } + for (var i = 0; i < ALPHABET.length; i++) { + var x = ALPHABET.charAt(i) + var xc = x.charCodeAt(0) + if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') } + BASE_MAP[xc] = i + } + var BASE = ALPHABET.length + var LEADER = ALPHABET.charAt(0) + var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up + var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up + function encode (source) { + if (source instanceof Uint8Array) { + } else if (ArrayBuffer.isView(source)) { + source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength) + } else if (Array.isArray(source)) { + source = Uint8Array.from(source) + } + if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') } + if (source.length === 0) { return '' } + // Skip & count leading zeroes. + var zeroes = 0 + var length = 0 + var pbegin = 0 + var pend = source.length + while (pbegin !== pend && source[pbegin] === 0) { + pbegin++ + zeroes++ + } + // Allocate enough space in big-endian base58 representation. + var size = ((pend - pbegin) * iFACTOR + 1) >>> 0 + var b58 = new Uint8Array(size) + // Process the bytes. + while (pbegin !== pend) { + var carry = source[pbegin] + // Apply "b58 = b58 * 256 + ch". + var i = 0 + for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) { + carry += (256 * b58[it1]) >>> 0 + b58[it1] = (carry % BASE) >>> 0 + carry = (carry / BASE) >>> 0 + } + if (carry !== 0) { throw new Error('Non-zero carry') } + length = i + pbegin++ + } + // Skip leading zeroes in base58 result. + var it2 = size - length + while (it2 !== size && b58[it2] === 0) { + it2++ + } + // Translate the result into a string. + var str = LEADER.repeat(zeroes) + for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) } + return str + } + function decodeUnsafe (source) { + if (typeof source !== 'string') { throw new TypeError('Expected String') } + if (source.length === 0) { return new Uint8Array() } + var psz = 0 + // Skip leading spaces. + if (source[psz] === ' ') { return } + // Skip and count leading '1's. + var zeroes = 0 + var length = 0 + while (source[psz] === LEADER) { + zeroes++ + psz++ + } + // Allocate enough space in big-endian base256 representation. + var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. + var b256 = new Uint8Array(size) + // Process the characters. + while (source[psz]) { + // Decode character + var carry = BASE_MAP[source.charCodeAt(psz)] + // Invalid character + if (carry === 255) { return } + var i = 0 + for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) { + carry += (BASE * b256[it3]) >>> 0 + b256[it3] = (carry % 256) >>> 0 + carry = (carry / 256) >>> 0 + } + if (carry !== 0) { throw new Error('Non-zero carry') } + length = i + psz++ + } + // Skip trailing spaces. + if (source[psz] === ' ') { return } + // Skip leading zeroes in b256. + var it4 = size - length + while (it4 !== size && b256[it4] === 0) { + it4++ + } + var vch = new Uint8Array(zeroes + (size - it4)) + var j = zeroes + while (it4 !== size) { + vch[j++] = b256[it4++] + } + return vch + } + function decode (string) { + var buffer = decodeUnsafe(string) + if (buffer) { return buffer } + throw new Error('Non-base' + BASE + ' character') + } + return { + encode: encode, + decodeUnsafe: decodeUnsafe, + decode: decode + } +} +module.exports = base + + /***/ }), /***/ 73562: @@ -20182,6 +20700,133 @@ module.exports = { } +/***/ }), + +/***/ 95364: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + +// base-x encoding / decoding +// Copyright (c) 2018 base-x contributors +// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp) +// Distributed under the MIT software license, see the accompanying +// file LICENSE or http://www.opensource.org/licenses/mit-license.php. +// @ts-ignore +var _Buffer = (__webpack_require__(92861).Buffer) +function base (ALPHABET) { + if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') } + var BASE_MAP = new Uint8Array(256) + for (var j = 0; j < BASE_MAP.length; j++) { + BASE_MAP[j] = 255 + } + for (var i = 0; i < ALPHABET.length; i++) { + var x = ALPHABET.charAt(i) + var xc = x.charCodeAt(0) + if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') } + BASE_MAP[xc] = i + } + var BASE = ALPHABET.length + var LEADER = ALPHABET.charAt(0) + var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up + var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up + function encode (source) { + if (Array.isArray(source) || source instanceof Uint8Array) { source = _Buffer.from(source) } + if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') } + if (source.length === 0) { return '' } + // Skip & count leading zeroes. + var zeroes = 0 + var length = 0 + var pbegin = 0 + var pend = source.length + while (pbegin !== pend && source[pbegin] === 0) { + pbegin++ + zeroes++ + } + // Allocate enough space in big-endian base58 representation. + var size = ((pend - pbegin) * iFACTOR + 1) >>> 0 + var b58 = new Uint8Array(size) + // Process the bytes. + while (pbegin !== pend) { + var carry = source[pbegin] + // Apply "b58 = b58 * 256 + ch". + var i = 0 + for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) { + carry += (256 * b58[it1]) >>> 0 + b58[it1] = (carry % BASE) >>> 0 + carry = (carry / BASE) >>> 0 + } + if (carry !== 0) { throw new Error('Non-zero carry') } + length = i + pbegin++ + } + // Skip leading zeroes in base58 result. + var it2 = size - length + while (it2 !== size && b58[it2] === 0) { + it2++ + } + // Translate the result into a string. + var str = LEADER.repeat(zeroes) + for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) } + return str + } + function decodeUnsafe (source) { + if (typeof source !== 'string') { throw new TypeError('Expected String') } + if (source.length === 0) { return _Buffer.alloc(0) } + var psz = 0 + // Skip and count leading '1's. + var zeroes = 0 + var length = 0 + while (source[psz] === LEADER) { + zeroes++ + psz++ + } + // Allocate enough space in big-endian base256 representation. + var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. + var b256 = new Uint8Array(size) + // Process the characters. + while (psz < source.length) { + // Decode character + var carry = BASE_MAP[source.charCodeAt(psz)] + // Invalid character + if (carry === 255) { return } + var i = 0 + for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) { + carry += (BASE * b256[it3]) >>> 0 + b256[it3] = (carry % 256) >>> 0 + carry = (carry / 256) >>> 0 + } + if (carry !== 0) { throw new Error('Non-zero carry') } + length = i + psz++ + } + // Skip leading zeroes in b256. + var it4 = size - length + while (it4 !== size && b256[it4] === 0) { + it4++ + } + var vch = _Buffer.allocUnsafe(zeroes + (size - it4)) + vch.fill(0x00, 0, zeroes) + var j = zeroes + while (it4 !== size) { + vch[j++] = b256[it4++] + } + return vch + } + function decode (string) { + var buffer = decodeUnsafe(string) + if (buffer) { return buffer } + throw new Error('Non-base' + BASE + ' character') + } + return { + encode: encode, + decodeUnsafe: decodeUnsafe, + decode: decode + } +} +module.exports = base + + /***/ }), /***/ 92096: @@ -26535,6 +27180,1073 @@ module.exports = one_at_a_time_hash; })( false || module, this); +/***/ }), + +/***/ 90297: +/***/ ((module) => { + +"use strict"; +/* eslint quote-props: off */ + + +/** + * Names for all available hashes + * + * @typedef { "identity" | "sha1" | "sha2-256" | "sha2-512" | "sha3-512" | "sha3-384" | "sha3-256" | "sha3-224" | "shake-128" | "shake-256" | "keccak-224" | "keccak-256" | "keccak-384" | "keccak-512" | "blake3" | "murmur3-128" | "murmur3-32" | "dbl-sha2-256" | "md4" | "md5" | "bmt" | "sha2-256-trunc254-padded" | "ripemd-128" | "ripemd-160" | "ripemd-256" | "ripemd-320" | "x11" | "kangarootwelve" | "sm3-256" | "blake2b-8" | "blake2b-16" | "blake2b-24" | "blake2b-32" | "blake2b-40" | "blake2b-48" | "blake2b-56" | "blake2b-64" | "blake2b-72" | "blake2b-80" | "blake2b-88" | "blake2b-96" | "blake2b-104" | "blake2b-112" | "blake2b-120" | "blake2b-128" | "blake2b-136" | "blake2b-144" | "blake2b-152" | "blake2b-160" | "blake2b-168" | "blake2b-176" | "blake2b-184" | "blake2b-192" | "blake2b-200" | "blake2b-208" | "blake2b-216" | "blake2b-224" | "blake2b-232" | "blake2b-240" | "blake2b-248" | "blake2b-256" | "blake2b-264" | "blake2b-272" | "blake2b-280" | "blake2b-288" | "blake2b-296" | "blake2b-304" | "blake2b-312" | "blake2b-320" | "blake2b-328" | "blake2b-336" | "blake2b-344" | "blake2b-352" | "blake2b-360" | "blake2b-368" | "blake2b-376" | "blake2b-384" | "blake2b-392" | "blake2b-400" | "blake2b-408" | "blake2b-416" | "blake2b-424" | "blake2b-432" | "blake2b-440" | "blake2b-448" | "blake2b-456" | "blake2b-464" | "blake2b-472" | "blake2b-480" | "blake2b-488" | "blake2b-496" | "blake2b-504" | "blake2b-512" | "blake2s-8" | "blake2s-16" | "blake2s-24" | "blake2s-32" | "blake2s-40" | "blake2s-48" | "blake2s-56" | "blake2s-64" | "blake2s-72" | "blake2s-80" | "blake2s-88" | "blake2s-96" | "blake2s-104" | "blake2s-112" | "blake2s-120" | "blake2s-128" | "blake2s-136" | "blake2s-144" | "blake2s-152" | "blake2s-160" | "blake2s-168" | "blake2s-176" | "blake2s-184" | "blake2s-192" | "blake2s-200" | "blake2s-208" | "blake2s-216" | "blake2s-224" | "blake2s-232" | "blake2s-240" | "blake2s-248" | "blake2s-256" | "skein256-8" | "skein256-16" | "skein256-24" | "skein256-32" | "skein256-40" | "skein256-48" | "skein256-56" | "skein256-64" | "skein256-72" | "skein256-80" | "skein256-88" | "skein256-96" | "skein256-104" | "skein256-112" | "skein256-120" | "skein256-128" | "skein256-136" | "skein256-144" | "skein256-152" | "skein256-160" | "skein256-168" | "skein256-176" | "skein256-184" | "skein256-192" | "skein256-200" | "skein256-208" | "skein256-216" | "skein256-224" | "skein256-232" | "skein256-240" | "skein256-248" | "skein256-256" | "skein512-8" | "skein512-16" | "skein512-24" | "skein512-32" | "skein512-40" | "skein512-48" | "skein512-56" | "skein512-64" | "skein512-72" | "skein512-80" | "skein512-88" | "skein512-96" | "skein512-104" | "skein512-112" | "skein512-120" | "skein512-128" | "skein512-136" | "skein512-144" | "skein512-152" | "skein512-160" | "skein512-168" | "skein512-176" | "skein512-184" | "skein512-192" | "skein512-200" | "skein512-208" | "skein512-216" | "skein512-224" | "skein512-232" | "skein512-240" | "skein512-248" | "skein512-256" | "skein512-264" | "skein512-272" | "skein512-280" | "skein512-288" | "skein512-296" | "skein512-304" | "skein512-312" | "skein512-320" | "skein512-328" | "skein512-336" | "skein512-344" | "skein512-352" | "skein512-360" | "skein512-368" | "skein512-376" | "skein512-384" | "skein512-392" | "skein512-400" | "skein512-408" | "skein512-416" | "skein512-424" | "skein512-432" | "skein512-440" | "skein512-448" | "skein512-456" | "skein512-464" | "skein512-472" | "skein512-480" | "skein512-488" | "skein512-496" | "skein512-504" | "skein512-512" | "skein1024-8" | "skein1024-16" | "skein1024-24" | "skein1024-32" | "skein1024-40" | "skein1024-48" | "skein1024-56" | "skein1024-64" | "skein1024-72" | "skein1024-80" | "skein1024-88" | "skein1024-96" | "skein1024-104" | "skein1024-112" | "skein1024-120" | "skein1024-128" | "skein1024-136" | "skein1024-144" | "skein1024-152" | "skein1024-160" | "skein1024-168" | "skein1024-176" | "skein1024-184" | "skein1024-192" | "skein1024-200" | "skein1024-208" | "skein1024-216" | "skein1024-224" | "skein1024-232" | "skein1024-240" | "skein1024-248" | "skein1024-256" | "skein1024-264" | "skein1024-272" | "skein1024-280" | "skein1024-288" | "skein1024-296" | "skein1024-304" | "skein1024-312" | "skein1024-320" | "skein1024-328" | "skein1024-336" | "skein1024-344" | "skein1024-352" | "skein1024-360" | "skein1024-368" | "skein1024-376" | "skein1024-384" | "skein1024-392" | "skein1024-400" | "skein1024-408" | "skein1024-416" | "skein1024-424" | "skein1024-432" | "skein1024-440" | "skein1024-448" | "skein1024-456" | "skein1024-464" | "skein1024-472" | "skein1024-480" | "skein1024-488" | "skein1024-496" | "skein1024-504" | "skein1024-512" | "skein1024-520" | "skein1024-528" | "skein1024-536" | "skein1024-544" | "skein1024-552" | "skein1024-560" | "skein1024-568" | "skein1024-576" | "skein1024-584" | "skein1024-592" | "skein1024-600" | "skein1024-608" | "skein1024-616" | "skein1024-624" | "skein1024-632" | "skein1024-640" | "skein1024-648" | "skein1024-656" | "skein1024-664" | "skein1024-672" | "skein1024-680" | "skein1024-688" | "skein1024-696" | "skein1024-704" | "skein1024-712" | "skein1024-720" | "skein1024-728" | "skein1024-736" | "skein1024-744" | "skein1024-752" | "skein1024-760" | "skein1024-768" | "skein1024-776" | "skein1024-784" | "skein1024-792" | "skein1024-800" | "skein1024-808" | "skein1024-816" | "skein1024-824" | "skein1024-832" | "skein1024-840" | "skein1024-848" | "skein1024-856" | "skein1024-864" | "skein1024-872" | "skein1024-880" | "skein1024-888" | "skein1024-896" | "skein1024-904" | "skein1024-912" | "skein1024-920" | "skein1024-928" | "skein1024-936" | "skein1024-944" | "skein1024-952" | "skein1024-960" | "skein1024-968" | "skein1024-976" | "skein1024-984" | "skein1024-992" | "skein1024-1000" | "skein1024-1008" | "skein1024-1016" | "skein1024-1024" | "poseidon-bls12_381-a2-fc1" | "poseidon-bls12_381-a2-fc1-sc" } HashName + */ +/** + * Codes for all available hashes + * + * @typedef { 0x00 | 0x11 | 0x12 | 0x13 | 0x14 | 0x15 | 0x16 | 0x17 | 0x18 | 0x19 | 0x1a | 0x1b | 0x1c | 0x1d | 0x1e | 0x22 | 0x23 | 0x56 | 0xd4 | 0xd5 | 0xd6 | 0x1012 | 0x1052 | 0x1053 | 0x1054 | 0x1055 | 0x1100 | 0x1d01 | 0x534d | 0xb201 | 0xb202 | 0xb203 | 0xb204 | 0xb205 | 0xb206 | 0xb207 | 0xb208 | 0xb209 | 0xb20a | 0xb20b | 0xb20c | 0xb20d | 0xb20e | 0xb20f | 0xb210 | 0xb211 | 0xb212 | 0xb213 | 0xb214 | 0xb215 | 0xb216 | 0xb217 | 0xb218 | 0xb219 | 0xb21a | 0xb21b | 0xb21c | 0xb21d | 0xb21e | 0xb21f | 0xb220 | 0xb221 | 0xb222 | 0xb223 | 0xb224 | 0xb225 | 0xb226 | 0xb227 | 0xb228 | 0xb229 | 0xb22a | 0xb22b | 0xb22c | 0xb22d | 0xb22e | 0xb22f | 0xb230 | 0xb231 | 0xb232 | 0xb233 | 0xb234 | 0xb235 | 0xb236 | 0xb237 | 0xb238 | 0xb239 | 0xb23a | 0xb23b | 0xb23c | 0xb23d | 0xb23e | 0xb23f | 0xb240 | 0xb241 | 0xb242 | 0xb243 | 0xb244 | 0xb245 | 0xb246 | 0xb247 | 0xb248 | 0xb249 | 0xb24a | 0xb24b | 0xb24c | 0xb24d | 0xb24e | 0xb24f | 0xb250 | 0xb251 | 0xb252 | 0xb253 | 0xb254 | 0xb255 | 0xb256 | 0xb257 | 0xb258 | 0xb259 | 0xb25a | 0xb25b | 0xb25c | 0xb25d | 0xb25e | 0xb25f | 0xb260 | 0xb301 | 0xb302 | 0xb303 | 0xb304 | 0xb305 | 0xb306 | 0xb307 | 0xb308 | 0xb309 | 0xb30a | 0xb30b | 0xb30c | 0xb30d | 0xb30e | 0xb30f | 0xb310 | 0xb311 | 0xb312 | 0xb313 | 0xb314 | 0xb315 | 0xb316 | 0xb317 | 0xb318 | 0xb319 | 0xb31a | 0xb31b | 0xb31c | 0xb31d | 0xb31e | 0xb31f | 0xb320 | 0xb321 | 0xb322 | 0xb323 | 0xb324 | 0xb325 | 0xb326 | 0xb327 | 0xb328 | 0xb329 | 0xb32a | 0xb32b | 0xb32c | 0xb32d | 0xb32e | 0xb32f | 0xb330 | 0xb331 | 0xb332 | 0xb333 | 0xb334 | 0xb335 | 0xb336 | 0xb337 | 0xb338 | 0xb339 | 0xb33a | 0xb33b | 0xb33c | 0xb33d | 0xb33e | 0xb33f | 0xb340 | 0xb341 | 0xb342 | 0xb343 | 0xb344 | 0xb345 | 0xb346 | 0xb347 | 0xb348 | 0xb349 | 0xb34a | 0xb34b | 0xb34c | 0xb34d | 0xb34e | 0xb34f | 0xb350 | 0xb351 | 0xb352 | 0xb353 | 0xb354 | 0xb355 | 0xb356 | 0xb357 | 0xb358 | 0xb359 | 0xb35a | 0xb35b | 0xb35c | 0xb35d | 0xb35e | 0xb35f | 0xb360 | 0xb361 | 0xb362 | 0xb363 | 0xb364 | 0xb365 | 0xb366 | 0xb367 | 0xb368 | 0xb369 | 0xb36a | 0xb36b | 0xb36c | 0xb36d | 0xb36e | 0xb36f | 0xb370 | 0xb371 | 0xb372 | 0xb373 | 0xb374 | 0xb375 | 0xb376 | 0xb377 | 0xb378 | 0xb379 | 0xb37a | 0xb37b | 0xb37c | 0xb37d | 0xb37e | 0xb37f | 0xb380 | 0xb381 | 0xb382 | 0xb383 | 0xb384 | 0xb385 | 0xb386 | 0xb387 | 0xb388 | 0xb389 | 0xb38a | 0xb38b | 0xb38c | 0xb38d | 0xb38e | 0xb38f | 0xb390 | 0xb391 | 0xb392 | 0xb393 | 0xb394 | 0xb395 | 0xb396 | 0xb397 | 0xb398 | 0xb399 | 0xb39a | 0xb39b | 0xb39c | 0xb39d | 0xb39e | 0xb39f | 0xb3a0 | 0xb3a1 | 0xb3a2 | 0xb3a3 | 0xb3a4 | 0xb3a5 | 0xb3a6 | 0xb3a7 | 0xb3a8 | 0xb3a9 | 0xb3aa | 0xb3ab | 0xb3ac | 0xb3ad | 0xb3ae | 0xb3af | 0xb3b0 | 0xb3b1 | 0xb3b2 | 0xb3b3 | 0xb3b4 | 0xb3b5 | 0xb3b6 | 0xb3b7 | 0xb3b8 | 0xb3b9 | 0xb3ba | 0xb3bb | 0xb3bc | 0xb3bd | 0xb3be | 0xb3bf | 0xb3c0 | 0xb3c1 | 0xb3c2 | 0xb3c3 | 0xb3c4 | 0xb3c5 | 0xb3c6 | 0xb3c7 | 0xb3c8 | 0xb3c9 | 0xb3ca | 0xb3cb | 0xb3cc | 0xb3cd | 0xb3ce | 0xb3cf | 0xb3d0 | 0xb3d1 | 0xb3d2 | 0xb3d3 | 0xb3d4 | 0xb3d5 | 0xb3d6 | 0xb3d7 | 0xb3d8 | 0xb3d9 | 0xb3da | 0xb3db | 0xb3dc | 0xb3dd | 0xb3de | 0xb3df | 0xb3e0 | 0xb401 | 0xb402 } HashCode + */ + +/** + * @type { Record } + */ +const names = Object.freeze({ + 'identity': 0x00, + 'sha1': 0x11, + 'sha2-256': 0x12, + 'sha2-512': 0x13, + 'sha3-512': 0x14, + 'sha3-384': 0x15, + 'sha3-256': 0x16, + 'sha3-224': 0x17, + 'shake-128': 0x18, + 'shake-256': 0x19, + 'keccak-224': 0x1a, + 'keccak-256': 0x1b, + 'keccak-384': 0x1c, + 'keccak-512': 0x1d, + 'blake3': 0x1e, + 'murmur3-128': 0x22, + 'murmur3-32': 0x23, + 'dbl-sha2-256': 0x56, + 'md4': 0xd4, + 'md5': 0xd5, + 'bmt': 0xd6, + 'sha2-256-trunc254-padded': 0x1012, + 'ripemd-128': 0x1052, + 'ripemd-160': 0x1053, + 'ripemd-256': 0x1054, + 'ripemd-320': 0x1055, + 'x11': 0x1100, + 'kangarootwelve': 0x1d01, + 'sm3-256': 0x534d, + 'blake2b-8': 0xb201, + 'blake2b-16': 0xb202, + 'blake2b-24': 0xb203, + 'blake2b-32': 0xb204, + 'blake2b-40': 0xb205, + 'blake2b-48': 0xb206, + 'blake2b-56': 0xb207, + 'blake2b-64': 0xb208, + 'blake2b-72': 0xb209, + 'blake2b-80': 0xb20a, + 'blake2b-88': 0xb20b, + 'blake2b-96': 0xb20c, + 'blake2b-104': 0xb20d, + 'blake2b-112': 0xb20e, + 'blake2b-120': 0xb20f, + 'blake2b-128': 0xb210, + 'blake2b-136': 0xb211, + 'blake2b-144': 0xb212, + 'blake2b-152': 0xb213, + 'blake2b-160': 0xb214, + 'blake2b-168': 0xb215, + 'blake2b-176': 0xb216, + 'blake2b-184': 0xb217, + 'blake2b-192': 0xb218, + 'blake2b-200': 0xb219, + 'blake2b-208': 0xb21a, + 'blake2b-216': 0xb21b, + 'blake2b-224': 0xb21c, + 'blake2b-232': 0xb21d, + 'blake2b-240': 0xb21e, + 'blake2b-248': 0xb21f, + 'blake2b-256': 0xb220, + 'blake2b-264': 0xb221, + 'blake2b-272': 0xb222, + 'blake2b-280': 0xb223, + 'blake2b-288': 0xb224, + 'blake2b-296': 0xb225, + 'blake2b-304': 0xb226, + 'blake2b-312': 0xb227, + 'blake2b-320': 0xb228, + 'blake2b-328': 0xb229, + 'blake2b-336': 0xb22a, + 'blake2b-344': 0xb22b, + 'blake2b-352': 0xb22c, + 'blake2b-360': 0xb22d, + 'blake2b-368': 0xb22e, + 'blake2b-376': 0xb22f, + 'blake2b-384': 0xb230, + 'blake2b-392': 0xb231, + 'blake2b-400': 0xb232, + 'blake2b-408': 0xb233, + 'blake2b-416': 0xb234, + 'blake2b-424': 0xb235, + 'blake2b-432': 0xb236, + 'blake2b-440': 0xb237, + 'blake2b-448': 0xb238, + 'blake2b-456': 0xb239, + 'blake2b-464': 0xb23a, + 'blake2b-472': 0xb23b, + 'blake2b-480': 0xb23c, + 'blake2b-488': 0xb23d, + 'blake2b-496': 0xb23e, + 'blake2b-504': 0xb23f, + 'blake2b-512': 0xb240, + 'blake2s-8': 0xb241, + 'blake2s-16': 0xb242, + 'blake2s-24': 0xb243, + 'blake2s-32': 0xb244, + 'blake2s-40': 0xb245, + 'blake2s-48': 0xb246, + 'blake2s-56': 0xb247, + 'blake2s-64': 0xb248, + 'blake2s-72': 0xb249, + 'blake2s-80': 0xb24a, + 'blake2s-88': 0xb24b, + 'blake2s-96': 0xb24c, + 'blake2s-104': 0xb24d, + 'blake2s-112': 0xb24e, + 'blake2s-120': 0xb24f, + 'blake2s-128': 0xb250, + 'blake2s-136': 0xb251, + 'blake2s-144': 0xb252, + 'blake2s-152': 0xb253, + 'blake2s-160': 0xb254, + 'blake2s-168': 0xb255, + 'blake2s-176': 0xb256, + 'blake2s-184': 0xb257, + 'blake2s-192': 0xb258, + 'blake2s-200': 0xb259, + 'blake2s-208': 0xb25a, + 'blake2s-216': 0xb25b, + 'blake2s-224': 0xb25c, + 'blake2s-232': 0xb25d, + 'blake2s-240': 0xb25e, + 'blake2s-248': 0xb25f, + 'blake2s-256': 0xb260, + 'skein256-8': 0xb301, + 'skein256-16': 0xb302, + 'skein256-24': 0xb303, + 'skein256-32': 0xb304, + 'skein256-40': 0xb305, + 'skein256-48': 0xb306, + 'skein256-56': 0xb307, + 'skein256-64': 0xb308, + 'skein256-72': 0xb309, + 'skein256-80': 0xb30a, + 'skein256-88': 0xb30b, + 'skein256-96': 0xb30c, + 'skein256-104': 0xb30d, + 'skein256-112': 0xb30e, + 'skein256-120': 0xb30f, + 'skein256-128': 0xb310, + 'skein256-136': 0xb311, + 'skein256-144': 0xb312, + 'skein256-152': 0xb313, + 'skein256-160': 0xb314, + 'skein256-168': 0xb315, + 'skein256-176': 0xb316, + 'skein256-184': 0xb317, + 'skein256-192': 0xb318, + 'skein256-200': 0xb319, + 'skein256-208': 0xb31a, + 'skein256-216': 0xb31b, + 'skein256-224': 0xb31c, + 'skein256-232': 0xb31d, + 'skein256-240': 0xb31e, + 'skein256-248': 0xb31f, + 'skein256-256': 0xb320, + 'skein512-8': 0xb321, + 'skein512-16': 0xb322, + 'skein512-24': 0xb323, + 'skein512-32': 0xb324, + 'skein512-40': 0xb325, + 'skein512-48': 0xb326, + 'skein512-56': 0xb327, + 'skein512-64': 0xb328, + 'skein512-72': 0xb329, + 'skein512-80': 0xb32a, + 'skein512-88': 0xb32b, + 'skein512-96': 0xb32c, + 'skein512-104': 0xb32d, + 'skein512-112': 0xb32e, + 'skein512-120': 0xb32f, + 'skein512-128': 0xb330, + 'skein512-136': 0xb331, + 'skein512-144': 0xb332, + 'skein512-152': 0xb333, + 'skein512-160': 0xb334, + 'skein512-168': 0xb335, + 'skein512-176': 0xb336, + 'skein512-184': 0xb337, + 'skein512-192': 0xb338, + 'skein512-200': 0xb339, + 'skein512-208': 0xb33a, + 'skein512-216': 0xb33b, + 'skein512-224': 0xb33c, + 'skein512-232': 0xb33d, + 'skein512-240': 0xb33e, + 'skein512-248': 0xb33f, + 'skein512-256': 0xb340, + 'skein512-264': 0xb341, + 'skein512-272': 0xb342, + 'skein512-280': 0xb343, + 'skein512-288': 0xb344, + 'skein512-296': 0xb345, + 'skein512-304': 0xb346, + 'skein512-312': 0xb347, + 'skein512-320': 0xb348, + 'skein512-328': 0xb349, + 'skein512-336': 0xb34a, + 'skein512-344': 0xb34b, + 'skein512-352': 0xb34c, + 'skein512-360': 0xb34d, + 'skein512-368': 0xb34e, + 'skein512-376': 0xb34f, + 'skein512-384': 0xb350, + 'skein512-392': 0xb351, + 'skein512-400': 0xb352, + 'skein512-408': 0xb353, + 'skein512-416': 0xb354, + 'skein512-424': 0xb355, + 'skein512-432': 0xb356, + 'skein512-440': 0xb357, + 'skein512-448': 0xb358, + 'skein512-456': 0xb359, + 'skein512-464': 0xb35a, + 'skein512-472': 0xb35b, + 'skein512-480': 0xb35c, + 'skein512-488': 0xb35d, + 'skein512-496': 0xb35e, + 'skein512-504': 0xb35f, + 'skein512-512': 0xb360, + 'skein1024-8': 0xb361, + 'skein1024-16': 0xb362, + 'skein1024-24': 0xb363, + 'skein1024-32': 0xb364, + 'skein1024-40': 0xb365, + 'skein1024-48': 0xb366, + 'skein1024-56': 0xb367, + 'skein1024-64': 0xb368, + 'skein1024-72': 0xb369, + 'skein1024-80': 0xb36a, + 'skein1024-88': 0xb36b, + 'skein1024-96': 0xb36c, + 'skein1024-104': 0xb36d, + 'skein1024-112': 0xb36e, + 'skein1024-120': 0xb36f, + 'skein1024-128': 0xb370, + 'skein1024-136': 0xb371, + 'skein1024-144': 0xb372, + 'skein1024-152': 0xb373, + 'skein1024-160': 0xb374, + 'skein1024-168': 0xb375, + 'skein1024-176': 0xb376, + 'skein1024-184': 0xb377, + 'skein1024-192': 0xb378, + 'skein1024-200': 0xb379, + 'skein1024-208': 0xb37a, + 'skein1024-216': 0xb37b, + 'skein1024-224': 0xb37c, + 'skein1024-232': 0xb37d, + 'skein1024-240': 0xb37e, + 'skein1024-248': 0xb37f, + 'skein1024-256': 0xb380, + 'skein1024-264': 0xb381, + 'skein1024-272': 0xb382, + 'skein1024-280': 0xb383, + 'skein1024-288': 0xb384, + 'skein1024-296': 0xb385, + 'skein1024-304': 0xb386, + 'skein1024-312': 0xb387, + 'skein1024-320': 0xb388, + 'skein1024-328': 0xb389, + 'skein1024-336': 0xb38a, + 'skein1024-344': 0xb38b, + 'skein1024-352': 0xb38c, + 'skein1024-360': 0xb38d, + 'skein1024-368': 0xb38e, + 'skein1024-376': 0xb38f, + 'skein1024-384': 0xb390, + 'skein1024-392': 0xb391, + 'skein1024-400': 0xb392, + 'skein1024-408': 0xb393, + 'skein1024-416': 0xb394, + 'skein1024-424': 0xb395, + 'skein1024-432': 0xb396, + 'skein1024-440': 0xb397, + 'skein1024-448': 0xb398, + 'skein1024-456': 0xb399, + 'skein1024-464': 0xb39a, + 'skein1024-472': 0xb39b, + 'skein1024-480': 0xb39c, + 'skein1024-488': 0xb39d, + 'skein1024-496': 0xb39e, + 'skein1024-504': 0xb39f, + 'skein1024-512': 0xb3a0, + 'skein1024-520': 0xb3a1, + 'skein1024-528': 0xb3a2, + 'skein1024-536': 0xb3a3, + 'skein1024-544': 0xb3a4, + 'skein1024-552': 0xb3a5, + 'skein1024-560': 0xb3a6, + 'skein1024-568': 0xb3a7, + 'skein1024-576': 0xb3a8, + 'skein1024-584': 0xb3a9, + 'skein1024-592': 0xb3aa, + 'skein1024-600': 0xb3ab, + 'skein1024-608': 0xb3ac, + 'skein1024-616': 0xb3ad, + 'skein1024-624': 0xb3ae, + 'skein1024-632': 0xb3af, + 'skein1024-640': 0xb3b0, + 'skein1024-648': 0xb3b1, + 'skein1024-656': 0xb3b2, + 'skein1024-664': 0xb3b3, + 'skein1024-672': 0xb3b4, + 'skein1024-680': 0xb3b5, + 'skein1024-688': 0xb3b6, + 'skein1024-696': 0xb3b7, + 'skein1024-704': 0xb3b8, + 'skein1024-712': 0xb3b9, + 'skein1024-720': 0xb3ba, + 'skein1024-728': 0xb3bb, + 'skein1024-736': 0xb3bc, + 'skein1024-744': 0xb3bd, + 'skein1024-752': 0xb3be, + 'skein1024-760': 0xb3bf, + 'skein1024-768': 0xb3c0, + 'skein1024-776': 0xb3c1, + 'skein1024-784': 0xb3c2, + 'skein1024-792': 0xb3c3, + 'skein1024-800': 0xb3c4, + 'skein1024-808': 0xb3c5, + 'skein1024-816': 0xb3c6, + 'skein1024-824': 0xb3c7, + 'skein1024-832': 0xb3c8, + 'skein1024-840': 0xb3c9, + 'skein1024-848': 0xb3ca, + 'skein1024-856': 0xb3cb, + 'skein1024-864': 0xb3cc, + 'skein1024-872': 0xb3cd, + 'skein1024-880': 0xb3ce, + 'skein1024-888': 0xb3cf, + 'skein1024-896': 0xb3d0, + 'skein1024-904': 0xb3d1, + 'skein1024-912': 0xb3d2, + 'skein1024-920': 0xb3d3, + 'skein1024-928': 0xb3d4, + 'skein1024-936': 0xb3d5, + 'skein1024-944': 0xb3d6, + 'skein1024-952': 0xb3d7, + 'skein1024-960': 0xb3d8, + 'skein1024-968': 0xb3d9, + 'skein1024-976': 0xb3da, + 'skein1024-984': 0xb3db, + 'skein1024-992': 0xb3dc, + 'skein1024-1000': 0xb3dd, + 'skein1024-1008': 0xb3de, + 'skein1024-1016': 0xb3df, + 'skein1024-1024': 0xb3e0, + 'poseidon-bls12_381-a2-fc1': 0xb401, + 'poseidon-bls12_381-a2-fc1-sc': 0xb402 +}) + +module.exports = { names } + + +/***/ }), + +/***/ 17684: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; +/** + * Multihash implementation in JavaScript. + */ + + +const multibase = __webpack_require__(91466) +const varint = __webpack_require__(61203) +const { names } = __webpack_require__(90297) +const { toString: uint8ArrayToString } = __webpack_require__(9804) +const { fromString: uint8ArrayFromString } = __webpack_require__(35195) +const { concat: uint8ArrayConcat } = __webpack_require__(61045) + +const codes = /** @type {import('./types').CodeNameMap} */({}) + +// eslint-disable-next-line guard-for-in +for (const key in names) { + const name = /** @type {HashName} */(key) + codes[names[name]] = name +} +Object.freeze(codes) + +/** + * Convert the given multihash to a hex encoded string. + * + * @param {Uint8Array} hash + * @returns {string} + */ +function toHexString (hash) { + if (!(hash instanceof Uint8Array)) { + throw new Error('must be passed a Uint8Array') + } + + return uint8ArrayToString(hash, 'base16') +} + +/** + * Convert the given hex encoded string to a multihash. + * + * @param {string} hash + * @returns {Uint8Array} + */ +function fromHexString (hash) { + return uint8ArrayFromString(hash, 'base16') +} + +/** + * Convert the given multihash to a base58 encoded string. + * + * @param {Uint8Array} hash + * @returns {string} + */ +function toB58String (hash) { + if (!(hash instanceof Uint8Array)) { + throw new Error('must be passed a Uint8Array') + } + + return uint8ArrayToString(multibase.encode('base58btc', hash)).slice(1) +} + +/** + * Convert the given base58 encoded string to a multihash. + * + * @param {string|Uint8Array} hash + * @returns {Uint8Array} + */ +function fromB58String (hash) { + const encoded = hash instanceof Uint8Array + ? uint8ArrayToString(hash) + : hash + + return multibase.decode('z' + encoded) +} + +/** + * Decode a hash from the given multihash. + * + * @param {Uint8Array} bytes + * @returns {{code: HashCode, name: HashName, length: number, digest: Uint8Array}} result + */ +function decode (bytes) { + if (!(bytes instanceof Uint8Array)) { + throw new Error('multihash must be a Uint8Array') + } + + if (bytes.length < 2) { + throw new Error('multihash too short. must be > 2 bytes.') + } + + const code = /** @type {HashCode} */(varint.decode(bytes)) + if (!isValidCode(code)) { + throw new Error(`multihash unknown function code: 0x${code.toString(16)}`) + } + bytes = bytes.slice(varint.decode.bytes) + + const len = varint.decode(bytes) + if (len < 0) { + throw new Error(`multihash invalid length: ${len}`) + } + bytes = bytes.slice(varint.decode.bytes) + + if (bytes.length !== len) { + throw new Error(`multihash length inconsistent: 0x${uint8ArrayToString(bytes, 'base16')}`) + } + + return { + code, + name: codes[code], + length: len, + digest: bytes + } +} + +/** + * Encode a hash digest along with the specified function code. + * + * > **Note:** the length is derived from the length of the digest itself. + * + * @param {Uint8Array} digest + * @param {HashName | HashCode} code + * @param {number} [length] + * @returns {Uint8Array} + */ +function encode (digest, code, length) { + if (!digest || code === undefined) { + throw new Error('multihash encode requires at least two args: digest, code') + } + + // ensure it's a hashfunction code. + const hashfn = coerceCode(code) + + if (!(digest instanceof Uint8Array)) { + throw new Error('digest should be a Uint8Array') + } + + if (length == null) { + length = digest.length + } + + if (length && digest.length !== length) { + throw new Error('digest length should be equal to specified length.') + } + + const hash = varint.encode(hashfn) + const len = varint.encode(length) + return uint8ArrayConcat([hash, len, digest], hash.length + len.length + digest.length) +} + +/** + * Converts a hash function name into the matching code. + * If passed a number it will return the number if it's a valid code. + * + * @param {HashName | number} name + * @returns {number} + */ +function coerceCode (name) { + let code = name + + if (typeof name === 'string') { + if (names[name] === undefined) { + throw new Error(`Unrecognized hash function named: ${name}`) + } + code = names[name] + } + + if (typeof code !== 'number') { + throw new Error(`Hash function code should be a number. Got: ${code}`) + } + + // @ts-ignore + if (codes[code] === undefined && !isAppCode(code)) { + throw new Error(`Unrecognized function code: ${code}`) + } + + return code +} + +/** + * Checks if a code is part of the app range + * + * @param {number} code + * @returns {boolean} + */ +function isAppCode (code) { + return code > 0 && code < 0x10 +} + +/** + * Checks whether a multihash code is valid. + * + * @param {HashCode} code + * @returns {boolean} + */ +function isValidCode (code) { + if (isAppCode(code)) { + return true + } + + if (codes[code]) { + return true + } + + return false +} + +/** + * Check if the given buffer is a valid multihash. Throws an error if it is not valid. + * + * @param {Uint8Array} multihash + * @returns {void} + * @throws {Error} + */ +function validate (multihash) { + decode(multihash) // throws if bad. +} + +/** + * Returns a prefix from a valid multihash. Throws an error if it is not valid. + * + * @param {Uint8Array} multihash + * @returns {Uint8Array} + * @throws {Error} + */ +function prefix (multihash) { + validate(multihash) + + return multihash.subarray(0, 2) +} + +module.exports = { + names, + codes, + toHexString, + fromHexString, + toB58String, + fromB58String, + decode, + encode, + coerceCode, + isAppCode, + validate, + prefix, + isValidCode +} + +/** + * @typedef { import("./constants").HashCode } HashCode + * @typedef { import("./constants").HashName } HashName + */ + + +/***/ }), + +/***/ 64378: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +const mh = __webpack_require__(17684) + +const CIDUtil = { + /** + * Test if the given input is a valid CID object. + * Returns an error message if it is not. + * Returns undefined if it is a valid CID. + * + * @param {any} other + * @returns {string|undefined} + */ + checkCIDComponents: function (other) { + if (other == null) { + return 'null values are not valid CIDs' + } + + if (!(other.version === 0 || other.version === 1)) { + return 'Invalid version, must be a number equal to 1 or 0' + } + + if (typeof other.codec !== 'string') { + return 'codec must be string' + } + + if (other.version === 0) { + if (other.codec !== 'dag-pb') { + return "codec must be 'dag-pb' for CIDv0" + } + if (other.multibaseName !== 'base58btc') { + return "multibaseName must be 'base58btc' for CIDv0" + } + } + + if (!(other.multihash instanceof Uint8Array)) { + return 'multihash must be a Uint8Array' + } + + try { + mh.validate(other.multihash) + } catch (err) { + let errorMsg = err.message + if (!errorMsg) { // Just in case mh.validate() throws an error with empty error message + errorMsg = 'Multihash validation failed' + } + return errorMsg + } + } +} + +module.exports = CIDUtil + + +/***/ }), + +/***/ 26613: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +const mh = __webpack_require__(17684) +const multibase = __webpack_require__(91466) +const multicodec = __webpack_require__(52021) +const CIDUtil = __webpack_require__(64378) +const { concat: uint8ArrayConcat } = __webpack_require__(61045) +const { toString: uint8ArrayToString } = __webpack_require__(9804) +const { equals: uint8ArrayEquals } = __webpack_require__(27980) + +const codecs = multicodec.nameToCode +const codecInts = /** @type {CodecName[]} */(Object.keys(codecs)).reduce((p, name) => { + p[codecs[name]] = name + return p +}, /** @type {Record} */({})) + +const symbol = Symbol.for('@ipld/js-cid/CID') + +/** + * @typedef {Object} SerializedCID + * @property {string} codec + * @property {number} version + * @property {Uint8Array} hash + */ +/** + * @typedef {0|1} CIDVersion + * @typedef {import('multibase').BaseNameOrCode} BaseNameOrCode + * @typedef {import('multicodec').CodecName} CodecName + * @typedef {import('multicodec').CodecCode} CodecCode + */ + +/** + * Class representing a CID `` + * , as defined in [ipld/cid](https://github.com/multiformats/cid). + * + * @class CID + */ +class CID { + /** + * Create a new CID. + * + * The algorithm for argument input is roughly: + * ``` + * if (cid) + * -> create a copy + * else if (str) + * if (1st char is on multibase table) -> CID String + * else -> bs58 encoded multihash + * else if (Uint8Array) + * if (1st byte is 0 or 1) -> CID + * else -> multihash + * else if (Number) + * -> construct CID by parts + * ``` + * + * @param {CIDVersion | string | Uint8Array | CID} version + * @param {string|number} [codec] + * @param {Uint8Array} [multihash] + * @param {string} [multibaseName] + * + * @example + * new CID(, , , ) + * new CID() + * new CID() + * new CID() + * new CID() + * new CID() + */ + constructor (version, codec, multihash, multibaseName) { + // We have below three blank field accessors only because + // otherwise TS will not pick them up if done after assignemnts + + /** + * The version of the CID. + * + * @type {CIDVersion} + */ + // eslint-disable-next-line no-unused-expressions + this.version + + /** + * The codec of the CID. + * + * @deprecated + * @type {CodecName} + */ + // eslint-disable-next-line no-unused-expressions + this.codec + + /** + * The multihash of the CID. + * + * @type {Uint8Array} + */ + // eslint-disable-next-line no-unused-expressions + this.multihash + + Object.defineProperty(this, symbol, { value: true }) + if (CID.isCID(version)) { + // version is an exising CID instance + const cid = /** @type {CID} */(version) + this.version = cid.version + this.codec = cid.codec + this.multihash = cid.multihash + // Default guard for when a CID < 0.7 is passed with no multibaseName + // @ts-ignore + this.multibaseName = cid.multibaseName || (cid.version === 0 ? 'base58btc' : 'base32') + return + } + + if (typeof version === 'string') { + // e.g. 'base32' or false + const baseName = multibase.isEncoded(version) + if (baseName) { + // version is a CID String encoded with multibase, so v1 + const cid = multibase.decode(version) + this.version = /** @type {CIDVersion} */(parseInt(cid[0].toString(), 16)) + this.codec = multicodec.getCodec(cid.slice(1)) + this.multihash = multicodec.rmPrefix(cid.slice(1)) + this.multibaseName = baseName + } else { + // version is a base58btc string multihash, so v0 + this.version = 0 + this.codec = 'dag-pb' + this.multihash = mh.fromB58String(version) + this.multibaseName = 'base58btc' + } + CID.validateCID(this) + Object.defineProperty(this, 'string', { value: version }) + return + } + + if (version instanceof Uint8Array) { + const v = parseInt(version[0].toString(), 16) + if (v === 1) { + // version is a CID Uint8Array + const cid = version + this.version = v + this.codec = multicodec.getCodec(cid.slice(1)) + this.multihash = multicodec.rmPrefix(cid.slice(1)) + this.multibaseName = 'base32' + } else { + // version is a raw multihash Uint8Array, so v0 + this.version = 0 + this.codec = 'dag-pb' + this.multihash = version + this.multibaseName = 'base58btc' + } + CID.validateCID(this) + return + } + + // otherwise, assemble the CID from the parameters + + this.version = version + + if (typeof codec === 'number') { + // @ts-ignore + codec = codecInts[codec] + } + + this.codec = /** @type {CodecName} */ (codec) + + this.multihash = /** @type {Uint8Array} */ (multihash) + + /** + * Multibase name as string. + * + * @deprecated + * @type {string} + */ + this.multibaseName = multibaseName || (version === 0 ? 'base58btc' : 'base32') + + CID.validateCID(this) + } + + /** + * The CID as a `Uint8Array` + * + * @returns {Uint8Array} + * + */ + get bytes () { + // @ts-ignore + let bytes = this._bytes + + if (!bytes) { + if (this.version === 0) { + bytes = this.multihash + } else if (this.version === 1) { + const codec = multicodec.getCodeVarint(this.codec) + bytes = uint8ArrayConcat([ + [1], codec, this.multihash + ], 1 + codec.byteLength + this.multihash.byteLength) + } else { + throw new Error('unsupported version') + } + + // Cache this Uint8Array so it doesn't have to be recreated + Object.defineProperty(this, '_bytes', { value: bytes }) + } + + return bytes + } + + /** + * The prefix of the CID. + * + * @returns {Uint8Array} + */ + get prefix () { + const codec = multicodec.getCodeVarint(this.codec) + const multihash = mh.prefix(this.multihash) + const prefix = uint8ArrayConcat([ + [this.version], codec, multihash + ], 1 + codec.byteLength + multihash.byteLength) + + return prefix + } + + /** + * The codec of the CID in its number form. + * + * @returns {CodecCode} + */ + get code () { + return codecs[this.codec] + } + + /** + * Convert to a CID of version `0`. + * + * @returns {CID} + */ + toV0 () { + if (this.codec !== 'dag-pb') { + throw new Error('Cannot convert a non dag-pb CID to CIDv0') + } + + const { name, length } = mh.decode(this.multihash) + + if (name !== 'sha2-256') { + throw new Error('Cannot convert non sha2-256 multihash CID to CIDv0') + } + + if (length !== 32) { + throw new Error('Cannot convert non 32 byte multihash CID to CIDv0') + } + + return new CID(0, this.codec, this.multihash) + } + + /** + * Convert to a CID of version `1`. + * + * @returns {CID} + */ + toV1 () { + return new CID(1, this.codec, this.multihash, this.multibaseName) + } + + /** + * Encode the CID into a string. + * + * @param {BaseNameOrCode} [base=this.multibaseName] - Base encoding to use. + * @returns {string} + */ + toBaseEncodedString (base = this.multibaseName) { + // @ts-ignore non enumerable cache property + if (this.string && this.string.length !== 0 && base === this.multibaseName) { + // @ts-ignore non enumerable cache property + return this.string + } + let str + if (this.version === 0) { + if (base !== 'base58btc') { + throw new Error('not supported with CIDv0, to support different bases, please migrate the instance do CIDv1, you can do that through cid.toV1()') + } + str = mh.toB58String(this.multihash) + } else if (this.version === 1) { + str = uint8ArrayToString(multibase.encode(base, this.bytes)) + } else { + throw new Error('unsupported version') + } + if (base === this.multibaseName) { + // cache the string value + Object.defineProperty(this, 'string', { value: str }) + } + return str + } + + /** + * CID(QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n) + * + * @returns {string} + */ + [Symbol.for('nodejs.util.inspect.custom')] () { + return 'CID(' + this.toString() + ')' + } + + /** + * Encode the CID into a string. + * + * @param {BaseNameOrCode} [base=this.multibaseName] - Base encoding to use. + * @returns {string} + */ + toString (base) { + return this.toBaseEncodedString(base) + } + + /** + * Serialize to a plain object. + * + * @returns {SerializedCID} + */ + toJSON () { + return { + codec: this.codec, + version: this.version, + hash: this.multihash + } + } + + /** + * Compare equality with another CID. + * + * @param {CID} other + * @returns {boolean} + */ + equals (other) { + return this.codec === other.codec && + this.version === other.version && + uint8ArrayEquals(this.multihash, other.multihash) + } + + /** + * Test if the given input is a valid CID object. + * Throws if it is not. + * + * @param {any} other - The other CID. + * @returns {void} + */ + static validateCID (other) { + const errorMsg = CIDUtil.checkCIDComponents(other) + if (errorMsg) { + throw new Error(errorMsg) + } + } + + /** + * Check if object is a CID instance + * + * @param {any} value + * @returns {value is CID} + */ + static isCID (value) { + return value instanceof CID || Boolean(value && value[symbol]) + } +} + +CID.codecs = codecs + +module.exports = CID + + /***/ }), /***/ 62586: @@ -43502,6 +45214,312 @@ if (typeof Object.create === 'function') { } +/***/ }), + +/***/ 8127: +/***/ (function(module) { + +// +// THIS FILE IS AUTOMATICALLY GENERATED! DO NOT EDIT BY HAND! +// +; +(function (global, factory) { + true + ? module.exports = factory() + : 0; +}((typeof self !== 'undefined' ? self + : typeof window !== 'undefined' ? window + : typeof global !== 'undefined' ? global + : this), function () { + 'use strict'; + /** + * base64.ts + * + * Licensed under the BSD 3-Clause License. + * http://opensource.org/licenses/BSD-3-Clause + * + * References: + * http://en.wikipedia.org/wiki/Base64 + * + * @author Dan Kogai (https://github.com/dankogai) + */ + var version = '3.7.7'; + /** + * @deprecated use lowercase `version`. + */ + var VERSION = version; + var _hasBuffer = typeof Buffer === 'function'; + var _TD = typeof TextDecoder === 'function' ? new TextDecoder() : undefined; + var _TE = typeof TextEncoder === 'function' ? new TextEncoder() : undefined; + var b64ch = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + var b64chs = Array.prototype.slice.call(b64ch); + var b64tab = (function (a) { + var tab = {}; + a.forEach(function (c, i) { return tab[c] = i; }); + return tab; + })(b64chs); + var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/; + var _fromCC = String.fromCharCode.bind(String); + var _U8Afrom = typeof Uint8Array.from === 'function' + ? Uint8Array.from.bind(Uint8Array) + : function (it) { return new Uint8Array(Array.prototype.slice.call(it, 0)); }; + var _mkUriSafe = function (src) { return src + .replace(/=/g, '').replace(/[+\/]/g, function (m0) { return m0 == '+' ? '-' : '_'; }); }; + var _tidyB64 = function (s) { return s.replace(/[^A-Za-z0-9\+\/]/g, ''); }; + /** + * polyfill version of `btoa` + */ + var btoaPolyfill = function (bin) { + // console.log('polyfilled'); + var u32, c0, c1, c2, asc = ''; + var pad = bin.length % 3; + for (var i = 0; i < bin.length;) { + if ((c0 = bin.charCodeAt(i++)) > 255 || + (c1 = bin.charCodeAt(i++)) > 255 || + (c2 = bin.charCodeAt(i++)) > 255) + throw new TypeError('invalid character found'); + u32 = (c0 << 16) | (c1 << 8) | c2; + asc += b64chs[u32 >> 18 & 63] + + b64chs[u32 >> 12 & 63] + + b64chs[u32 >> 6 & 63] + + b64chs[u32 & 63]; + } + return pad ? asc.slice(0, pad - 3) + "===".substring(pad) : asc; + }; + /** + * does what `window.btoa` of web browsers do. + * @param {String} bin binary string + * @returns {string} Base64-encoded string + */ + var _btoa = typeof btoa === 'function' ? function (bin) { return btoa(bin); } + : _hasBuffer ? function (bin) { return Buffer.from(bin, 'binary').toString('base64'); } + : btoaPolyfill; + var _fromUint8Array = _hasBuffer + ? function (u8a) { return Buffer.from(u8a).toString('base64'); } + : function (u8a) { + // cf. https://stackoverflow.com/questions/12710001/how-to-convert-uint8-array-to-base64-encoded-string/12713326#12713326 + var maxargs = 0x1000; + var strs = []; + for (var i = 0, l = u8a.length; i < l; i += maxargs) { + strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs))); + } + return _btoa(strs.join('')); + }; + /** + * converts a Uint8Array to a Base64 string. + * @param {boolean} [urlsafe] URL-and-filename-safe a la RFC4648 §5 + * @returns {string} Base64 string + */ + var fromUint8Array = function (u8a, urlsafe) { + if (urlsafe === void 0) { urlsafe = false; } + return urlsafe ? _mkUriSafe(_fromUint8Array(u8a)) : _fromUint8Array(u8a); + }; + // This trick is found broken https://github.com/dankogai/js-base64/issues/130 + // const utob = (src: string) => unescape(encodeURIComponent(src)); + // reverting good old fationed regexp + var cb_utob = function (c) { + if (c.length < 2) { + var cc = c.charCodeAt(0); + return cc < 0x80 ? c + : cc < 0x800 ? (_fromCC(0xc0 | (cc >>> 6)) + + _fromCC(0x80 | (cc & 0x3f))) + : (_fromCC(0xe0 | ((cc >>> 12) & 0x0f)) + + _fromCC(0x80 | ((cc >>> 6) & 0x3f)) + + _fromCC(0x80 | (cc & 0x3f))); + } + else { + var cc = 0x10000 + + (c.charCodeAt(0) - 0xD800) * 0x400 + + (c.charCodeAt(1) - 0xDC00); + return (_fromCC(0xf0 | ((cc >>> 18) & 0x07)) + + _fromCC(0x80 | ((cc >>> 12) & 0x3f)) + + _fromCC(0x80 | ((cc >>> 6) & 0x3f)) + + _fromCC(0x80 | (cc & 0x3f))); + } + }; + var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g; + /** + * @deprecated should have been internal use only. + * @param {string} src UTF-8 string + * @returns {string} UTF-16 string + */ + var utob = function (u) { return u.replace(re_utob, cb_utob); }; + // + var _encode = _hasBuffer + ? function (s) { return Buffer.from(s, 'utf8').toString('base64'); } + : _TE + ? function (s) { return _fromUint8Array(_TE.encode(s)); } + : function (s) { return _btoa(utob(s)); }; + /** + * converts a UTF-8-encoded string to a Base64 string. + * @param {boolean} [urlsafe] if `true` make the result URL-safe + * @returns {string} Base64 string + */ + var encode = function (src, urlsafe) { + if (urlsafe === void 0) { urlsafe = false; } + return urlsafe + ? _mkUriSafe(_encode(src)) + : _encode(src); + }; + /** + * converts a UTF-8-encoded string to URL-safe Base64 RFC4648 §5. + * @returns {string} Base64 string + */ + var encodeURI = function (src) { return encode(src, true); }; + // This trick is found broken https://github.com/dankogai/js-base64/issues/130 + // const btou = (src: string) => decodeURIComponent(escape(src)); + // reverting good old fationed regexp + var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g; + var cb_btou = function (cccc) { + switch (cccc.length) { + case 4: + var cp = ((0x07 & cccc.charCodeAt(0)) << 18) + | ((0x3f & cccc.charCodeAt(1)) << 12) + | ((0x3f & cccc.charCodeAt(2)) << 6) + | (0x3f & cccc.charCodeAt(3)), offset = cp - 0x10000; + return (_fromCC((offset >>> 10) + 0xD800) + + _fromCC((offset & 0x3FF) + 0xDC00)); + case 3: + return _fromCC(((0x0f & cccc.charCodeAt(0)) << 12) + | ((0x3f & cccc.charCodeAt(1)) << 6) + | (0x3f & cccc.charCodeAt(2))); + default: + return _fromCC(((0x1f & cccc.charCodeAt(0)) << 6) + | (0x3f & cccc.charCodeAt(1))); + } + }; + /** + * @deprecated should have been internal use only. + * @param {string} src UTF-16 string + * @returns {string} UTF-8 string + */ + var btou = function (b) { return b.replace(re_btou, cb_btou); }; + /** + * polyfill version of `atob` + */ + var atobPolyfill = function (asc) { + // console.log('polyfilled'); + asc = asc.replace(/\s+/g, ''); + if (!b64re.test(asc)) + throw new TypeError('malformed base64.'); + asc += '=='.slice(2 - (asc.length & 3)); + var u24, bin = '', r1, r2; + for (var i = 0; i < asc.length;) { + u24 = b64tab[asc.charAt(i++)] << 18 + | b64tab[asc.charAt(i++)] << 12 + | (r1 = b64tab[asc.charAt(i++)]) << 6 + | (r2 = b64tab[asc.charAt(i++)]); + bin += r1 === 64 ? _fromCC(u24 >> 16 & 255) + : r2 === 64 ? _fromCC(u24 >> 16 & 255, u24 >> 8 & 255) + : _fromCC(u24 >> 16 & 255, u24 >> 8 & 255, u24 & 255); + } + return bin; + }; + /** + * does what `window.atob` of web browsers do. + * @param {String} asc Base64-encoded string + * @returns {string} binary string + */ + var _atob = typeof atob === 'function' ? function (asc) { return atob(_tidyB64(asc)); } + : _hasBuffer ? function (asc) { return Buffer.from(asc, 'base64').toString('binary'); } + : atobPolyfill; + // + var _toUint8Array = _hasBuffer + ? function (a) { return _U8Afrom(Buffer.from(a, 'base64')); } + : function (a) { return _U8Afrom(_atob(a).split('').map(function (c) { return c.charCodeAt(0); })); }; + /** + * converts a Base64 string to a Uint8Array. + */ + var toUint8Array = function (a) { return _toUint8Array(_unURI(a)); }; + // + var _decode = _hasBuffer + ? function (a) { return Buffer.from(a, 'base64').toString('utf8'); } + : _TD + ? function (a) { return _TD.decode(_toUint8Array(a)); } + : function (a) { return btou(_atob(a)); }; + var _unURI = function (a) { return _tidyB64(a.replace(/[-_]/g, function (m0) { return m0 == '-' ? '+' : '/'; })); }; + /** + * converts a Base64 string to a UTF-8 string. + * @param {String} src Base64 string. Both normal and URL-safe are supported + * @returns {string} UTF-8 string + */ + var decode = function (src) { return _decode(_unURI(src)); }; + /** + * check if a value is a valid Base64 string + * @param {String} src a value to check + */ + var isValid = function (src) { + if (typeof src !== 'string') + return false; + var s = src.replace(/\s+/g, '').replace(/={0,2}$/, ''); + return !/[^\s0-9a-zA-Z\+/]/.test(s) || !/[^\s0-9a-zA-Z\-_]/.test(s); + }; + // + var _noEnum = function (v) { + return { + value: v, enumerable: false, writable: true, configurable: true + }; + }; + /** + * extend String.prototype with relevant methods + */ + var extendString = function () { + var _add = function (name, body) { return Object.defineProperty(String.prototype, name, _noEnum(body)); }; + _add('fromBase64', function () { return decode(this); }); + _add('toBase64', function (urlsafe) { return encode(this, urlsafe); }); + _add('toBase64URI', function () { return encode(this, true); }); + _add('toBase64URL', function () { return encode(this, true); }); + _add('toUint8Array', function () { return toUint8Array(this); }); + }; + /** + * extend Uint8Array.prototype with relevant methods + */ + var extendUint8Array = function () { + var _add = function (name, body) { return Object.defineProperty(Uint8Array.prototype, name, _noEnum(body)); }; + _add('toBase64', function (urlsafe) { return fromUint8Array(this, urlsafe); }); + _add('toBase64URI', function () { return fromUint8Array(this, true); }); + _add('toBase64URL', function () { return fromUint8Array(this, true); }); + }; + /** + * extend Builtin prototypes with relevant methods + */ + var extendBuiltins = function () { + extendString(); + extendUint8Array(); + }; + var gBase64 = { + version: version, + VERSION: VERSION, + atob: _atob, + atobPolyfill: atobPolyfill, + btoa: _btoa, + btoaPolyfill: btoaPolyfill, + fromBase64: decode, + toBase64: encode, + encode: encode, + encodeURI: encodeURI, + encodeURL: encodeURI, + utob: utob, + btou: btou, + decode: decode, + isValid: isValid, + fromUint8Array: fromUint8Array, + toUint8Array: toUint8Array, + extendString: extendString, + extendUint8Array: extendUint8Array, + extendBuiltins: extendBuiltins + }; + // + // export Base64 to the namespace + // + // ES5 is yet to have Object.assign() that may make transpilers unhappy. + // gBase64.Base64 = Object.assign({}, gBase64); + gBase64.Base64 = {}; + Object.keys(gBase64).forEach(function (k) { return gBase64.Base64[k] = gBase64[k]; }); + return gBase64; +})); + + /***/ }), /***/ 31176: @@ -66015,6 +68033,3875 @@ function plural(ms, msAbs, n, name) { } +/***/ }), + +/***/ 18633: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +const { encodeText } = __webpack_require__(24084) + +/** @typedef {import('./types').CodecFactory} CodecFactory */ +/** @typedef {import("./types").BaseName} BaseName */ +/** @typedef {import("./types").BaseCode} BaseCode */ + +/** + * Class to encode/decode in the supported Bases + * + */ +class Base { + /** + * @param {BaseName} name + * @param {BaseCode} code + * @param {CodecFactory} factory + * @param {string} alphabet + */ + constructor (name, code, factory, alphabet) { + this.name = name + this.code = code + this.codeBuf = encodeText(this.code) + this.alphabet = alphabet + this.codec = factory(alphabet) + } + + /** + * @param {Uint8Array} buf + * @returns {string} + */ + encode (buf) { + return this.codec.encode(buf) + } + + /** + * @param {string} string + * @returns {Uint8Array} + */ + decode (string) { + for (const char of string) { + if (this.alphabet && this.alphabet.indexOf(char) < 0) { + throw new Error(`invalid character '${char}' in '${string}'`) + } + } + return this.codec.decode(string) + } +} + +module.exports = Base + + +/***/ }), + +/***/ 67579: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +const baseX = __webpack_require__(25084) +const Base = __webpack_require__(18633) +const { rfc4648 } = __webpack_require__(99417) +const { decodeText, encodeText } = __webpack_require__(24084) + +/** @typedef {import('./types').CodecFactory} CodecFactory */ +/** @typedef {import('./types').Codec} Codec */ +/** @typedef {import('./types').BaseName} BaseName */ +/** @typedef {import('./types').BaseCode} BaseCode */ + +/** @type {CodecFactory} */ +const identity = () => { + return { + encode: decodeText, + decode: encodeText + } +} + +/** + * + * name, code, implementation, alphabet + * + * @type {Array<[BaseName, BaseCode, CodecFactory, string]>} + */ +const constants = [ + ['identity', '\x00', identity, ''], + ['base2', '0', rfc4648(1), '01'], + ['base8', '7', rfc4648(3), '01234567'], + ['base10', '9', baseX, '0123456789'], + ['base16', 'f', rfc4648(4), '0123456789abcdef'], + ['base16upper', 'F', rfc4648(4), '0123456789ABCDEF'], + ['base32hex', 'v', rfc4648(5), '0123456789abcdefghijklmnopqrstuv'], + ['base32hexupper', 'V', rfc4648(5), '0123456789ABCDEFGHIJKLMNOPQRSTUV'], + ['base32hexpad', 't', rfc4648(5), '0123456789abcdefghijklmnopqrstuv='], + ['base32hexpadupper', 'T', rfc4648(5), '0123456789ABCDEFGHIJKLMNOPQRSTUV='], + ['base32', 'b', rfc4648(5), 'abcdefghijklmnopqrstuvwxyz234567'], + ['base32upper', 'B', rfc4648(5), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'], + ['base32pad', 'c', rfc4648(5), 'abcdefghijklmnopqrstuvwxyz234567='], + ['base32padupper', 'C', rfc4648(5), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567='], + ['base32z', 'h', rfc4648(5), 'ybndrfg8ejkmcpqxot1uwisza345h769'], + ['base36', 'k', baseX, '0123456789abcdefghijklmnopqrstuvwxyz'], + ['base36upper', 'K', baseX, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'], + ['base58btc', 'z', baseX, '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'], + ['base58flickr', 'Z', baseX, '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'], + ['base64', 'm', rfc4648(6), 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'], + ['base64pad', 'M', rfc4648(6), 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='], + ['base64url', 'u', rfc4648(6), 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'], + ['base64urlpad', 'U', rfc4648(6), 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_='] +] + +/** @type {Record} */ +const names = constants.reduce((prev, tupple) => { + prev[tupple[0]] = new Base(tupple[0], tupple[1], tupple[2], tupple[3]) + return prev +}, /** @type {Record} */({})) + +/** @type {Record} */ +const codes = constants.reduce((prev, tupple) => { + prev[tupple[1]] = names[tupple[0]] + return prev +}, /** @type {Record} */({})) + +module.exports = { + names, + codes +} + + +/***/ }), + +/***/ 91466: +/***/ ((module, exports, __webpack_require__) => { + +"use strict"; +/** + * Implementation of the [multibase](https://github.com/multiformats/multibase) specification. + * + */ + + +const constants = __webpack_require__(67579) +const { encodeText, decodeText, concat } = __webpack_require__(24084) + +/** @typedef {import('./base')} Base */ +/** @typedef {import("./types").BaseNameOrCode} BaseNameOrCode */ +/** @typedef {import("./types").BaseCode} BaseCode */ +/** @typedef {import("./types").BaseName} BaseName */ + +/** + * Create a new Uint8Array with the multibase varint+code. + * + * @param {BaseNameOrCode} nameOrCode - The multibase name or code number. + * @param {Uint8Array} buf - The data to be prefixed with multibase. + * @returns {Uint8Array} + * @throws {Error} Will throw if the encoding is not supported + */ +function multibase (nameOrCode, buf) { + if (!buf) { + throw new Error('requires an encoded Uint8Array') + } + const { name, codeBuf } = encoding(nameOrCode) + validEncode(name, buf) + + return concat([codeBuf, buf], codeBuf.length + buf.length) +} + +/** + * Encode data with the specified base and add the multibase prefix. + * + * @param {BaseNameOrCode} nameOrCode - The multibase name or code number. + * @param {Uint8Array} buf - The data to be encoded. + * @returns {Uint8Array} + * @throws {Error} Will throw if the encoding is not supported + * + */ +function encode (nameOrCode, buf) { + const enc = encoding(nameOrCode) + const data = encodeText(enc.encode(buf)) + + return concat([enc.codeBuf, data], enc.codeBuf.length + data.length) +} + +/** + * Takes a Uint8Array or string encoded with multibase header, decodes it and + * returns the decoded buffer + * + * @param {Uint8Array|string} data + * @returns {Uint8Array} + * @throws {Error} Will throw if the encoding is not supported + * + */ +function decode (data) { + if (data instanceof Uint8Array) { + data = decodeText(data) + } + const prefix = data[0] + + // Make all encodings case-insensitive except the ones that include upper and lower chars in the alphabet + if (['f', 'F', 'v', 'V', 't', 'T', 'b', 'B', 'c', 'C', 'h', 'k', 'K'].includes(prefix)) { + data = data.toLowerCase() + } + const enc = encoding(/** @type {BaseCode} */(data[0])) + return enc.decode(data.substring(1)) +} + +/** + * Is the given data multibase encoded? + * + * @param {Uint8Array|string} data + */ +function isEncoded (data) { + if (data instanceof Uint8Array) { + data = decodeText(data) + } + + // Ensure bufOrString is a string + if (Object.prototype.toString.call(data) !== '[object String]') { + return false + } + + try { + const enc = encoding(/** @type {BaseCode} */(data[0])) + return enc.name + } catch (err) { + return false + } +} + +/** + * Validate encoded data + * + * @param {BaseNameOrCode} name + * @param {Uint8Array} buf + * @returns {void} + * @throws {Error} Will throw if the encoding is not supported + */ +function validEncode (name, buf) { + const enc = encoding(name) + enc.decode(decodeText(buf)) +} + +/** + * Get the encoding by name or code + * + * @param {BaseNameOrCode} nameOrCode + * @returns {Base} + * @throws {Error} Will throw if the encoding is not supported + */ +function encoding (nameOrCode) { + if (Object.prototype.hasOwnProperty.call(constants.names, /** @type {BaseName} */(nameOrCode))) { + return constants.names[/** @type {BaseName} */(nameOrCode)] + } else if (Object.prototype.hasOwnProperty.call(constants.codes, /** @type {BaseCode} */(nameOrCode))) { + return constants.codes[/** @type {BaseCode} */(nameOrCode)] + } else { + throw new Error(`Unsupported encoding: ${nameOrCode}`) + } +} + +/** + * Get encoding from data + * + * @param {string|Uint8Array} data + * @returns {Base} + * @throws {Error} Will throw if the encoding is not supported + */ +function encodingFromData (data) { + if (data instanceof Uint8Array) { + data = decodeText(data) + } + + return encoding(/** @type {BaseCode} */(data[0])) +} + +exports = module.exports = multibase +exports.encode = encode +exports.decode = decode +exports.isEncoded = isEncoded +exports.encoding = encoding +exports.encodingFromData = encodingFromData +const names = Object.freeze(constants.names) +const codes = Object.freeze(constants.codes) +exports.names = names +exports.codes = codes + + +/***/ }), + +/***/ 99417: +/***/ ((module) => { + +"use strict"; + + +/** @typedef {import('./types').CodecFactory} CodecFactory */ + +/** + * @param {string} string + * @param {string} alphabet + * @param {number} bitsPerChar + * @returns {Uint8Array} + */ +const decode = (string, alphabet, bitsPerChar) => { + // Build the character lookup table: + /** @type {Record} */ + const codes = {} + for (let i = 0; i < alphabet.length; ++i) { + codes[alphabet[i]] = i + } + + // Count the padding bytes: + let end = string.length + while (string[end - 1] === '=') { + --end + } + + // Allocate the output: + const out = new Uint8Array((end * bitsPerChar / 8) | 0) + + // Parse the data: + let bits = 0 // Number of bits currently in the buffer + let buffer = 0 // Bits waiting to be written out, MSB first + let written = 0 // Next byte to write + for (let i = 0; i < end; ++i) { + // Read one character from the string: + const value = codes[string[i]] + if (value === undefined) { + throw new SyntaxError('Invalid character ' + string[i]) + } + + // Append the bits to the buffer: + buffer = (buffer << bitsPerChar) | value + bits += bitsPerChar + + // Write out some bits if the buffer has a byte's worth: + if (bits >= 8) { + bits -= 8 + out[written++] = 0xff & (buffer >> bits) + } + } + + // Verify that we have received just enough bits: + if (bits >= bitsPerChar || 0xff & (buffer << (8 - bits))) { + throw new SyntaxError('Unexpected end of data') + } + + return out +} + +/** + * @param {Uint8Array} data + * @param {string} alphabet + * @param {number} bitsPerChar + * @returns {string} + */ +const encode = (data, alphabet, bitsPerChar) => { + const pad = alphabet[alphabet.length - 1] === '=' + const mask = (1 << bitsPerChar) - 1 + let out = '' + + let bits = 0 // Number of bits currently in the buffer + let buffer = 0 // Bits waiting to be written out, MSB first + for (let i = 0; i < data.length; ++i) { + // Slurp data into the buffer: + buffer = (buffer << 8) | data[i] + bits += 8 + + // Write out as much as we can: + while (bits > bitsPerChar) { + bits -= bitsPerChar + out += alphabet[mask & (buffer >> bits)] + } + } + + // Partial character: + if (bits) { + out += alphabet[mask & (buffer << (bitsPerChar - bits))] + } + + // Add padding characters until we hit a byte boundary: + if (pad) { + while ((out.length * bitsPerChar) & 7) { + out += '=' + } + } + + return out +} + +/** + * RFC4648 Factory + * + * @param {number} bitsPerChar + * @returns {CodecFactory} + */ +const rfc4648 = (bitsPerChar) => (alphabet) => { + return { + /** + * @param {Uint8Array} input + * @returns {string} + */ + encode (input) { + return encode(input, alphabet, bitsPerChar) + }, + /** + * @param {string} input + * @returns {Uint8Array} + */ + decode (input) { + return decode(input, alphabet, bitsPerChar) + } + } +} + +module.exports = { rfc4648 } + + +/***/ }), + +/***/ 24084: +/***/ ((module) => { + +"use strict"; + + +const textDecoder = new TextDecoder() +/** + * @param {ArrayBufferView|ArrayBuffer} bytes + * @returns {string} + */ +const decodeText = (bytes) => textDecoder.decode(bytes) + +const textEncoder = new TextEncoder() +/** + * @param {string} text + * @returns {Uint8Array} + */ +const encodeText = (text) => textEncoder.encode(text) + +/** + * Returns a new Uint8Array created by concatenating the passed Arrays + * + * @param {Array>} arrs + * @param {number} length + * @returns {Uint8Array} + */ +function concat (arrs, length) { + const output = new Uint8Array(length) + let offset = 0 + + for (const arr of arrs) { + output.set(arr, offset) + offset += arr.length + } + + return output +} + +module.exports = { decodeText, encodeText, concat } + + +/***/ }), + +/***/ 35194: +/***/ ((module) => { + +module.exports = read + +var MSB = 0x80 + , REST = 0x7F + +function read(buf, offset) { + var res = 0 + , offset = offset || 0 + , shift = 0 + , counter = offset + , b + , l = buf.length + + do { + if (counter >= l || shift > 49) { + read.bytes = 0 + throw new RangeError('Could not decode varint') + } + b = buf[counter++] + res += shift < 28 + ? (b & REST) << shift + : (b & REST) * Math.pow(2, shift) + shift += 7 + } while (b >= MSB) + + read.bytes = counter - offset + + return res +} + + +/***/ }), + +/***/ 25134: +/***/ ((module) => { + +module.exports = encode + +var MSB = 0x80 + , REST = 0x7F + , MSBALL = ~REST + , INT = Math.pow(2, 31) + +function encode(num, out, offset) { + if (Number.MAX_SAFE_INTEGER && num > Number.MAX_SAFE_INTEGER) { + encode.bytes = 0 + throw new RangeError('Could not encode varint') + } + out = out || [] + offset = offset || 0 + var oldOffset = offset + + while(num >= INT) { + out[offset++] = (num & 0xFF) | MSB + num /= 128 + } + while(num & MSBALL) { + out[offset++] = (num & 0xFF) | MSB + num >>>= 7 + } + out[offset] = num | 0 + + encode.bytes = offset - oldOffset + 1 + + return out +} + + +/***/ }), + +/***/ 20038: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +module.exports = { + encode: __webpack_require__(25134) + , decode: __webpack_require__(35194) + , encodingLength: __webpack_require__(36516) +} + + +/***/ }), + +/***/ 36516: +/***/ ((module) => { + + +var N1 = Math.pow(2, 7) +var N2 = Math.pow(2, 14) +var N3 = Math.pow(2, 21) +var N4 = Math.pow(2, 28) +var N5 = Math.pow(2, 35) +var N6 = Math.pow(2, 42) +var N7 = Math.pow(2, 49) +var N8 = Math.pow(2, 56) +var N9 = Math.pow(2, 63) + +module.exports = function (value) { + return ( + value < N1 ? 1 + : value < N2 ? 2 + : value < N3 ? 3 + : value < N4 ? 4 + : value < N5 ? 5 + : value < N6 ? 6 + : value < N7 ? 7 + : value < N8 ? 8 + : value < N9 ? 9 + : 10 + ) +} + + +/***/ }), + +/***/ 15661: +/***/ ((module) => { + +"use strict"; +// DO NOT CHANGE THIS FILE. IT IS GENERATED BY tools/update-table.js +/* eslint quote-props: off */ + + +/** + * @type {import('./generated-types').NameCodeMap} + */ +const baseTable = Object.freeze({ + 'identity': 0x00, + 'cidv1': 0x01, + 'cidv2': 0x02, + 'cidv3': 0x03, + 'ip4': 0x04, + 'tcp': 0x06, + 'sha1': 0x11, + 'sha2-256': 0x12, + 'sha2-512': 0x13, + 'sha3-512': 0x14, + 'sha3-384': 0x15, + 'sha3-256': 0x16, + 'sha3-224': 0x17, + 'shake-128': 0x18, + 'shake-256': 0x19, + 'keccak-224': 0x1a, + 'keccak-256': 0x1b, + 'keccak-384': 0x1c, + 'keccak-512': 0x1d, + 'blake3': 0x1e, + 'dccp': 0x21, + 'murmur3-128': 0x22, + 'murmur3-32': 0x23, + 'ip6': 0x29, + 'ip6zone': 0x2a, + 'path': 0x2f, + 'multicodec': 0x30, + 'multihash': 0x31, + 'multiaddr': 0x32, + 'multibase': 0x33, + 'dns': 0x35, + 'dns4': 0x36, + 'dns6': 0x37, + 'dnsaddr': 0x38, + 'protobuf': 0x50, + 'cbor': 0x51, + 'raw': 0x55, + 'dbl-sha2-256': 0x56, + 'rlp': 0x60, + 'bencode': 0x63, + 'dag-pb': 0x70, + 'dag-cbor': 0x71, + 'libp2p-key': 0x72, + 'git-raw': 0x78, + 'torrent-info': 0x7b, + 'torrent-file': 0x7c, + 'leofcoin-block': 0x81, + 'leofcoin-tx': 0x82, + 'leofcoin-pr': 0x83, + 'sctp': 0x84, + 'dag-jose': 0x85, + 'dag-cose': 0x86, + 'eth-block': 0x90, + 'eth-block-list': 0x91, + 'eth-tx-trie': 0x92, + 'eth-tx': 0x93, + 'eth-tx-receipt-trie': 0x94, + 'eth-tx-receipt': 0x95, + 'eth-state-trie': 0x96, + 'eth-account-snapshot': 0x97, + 'eth-storage-trie': 0x98, + 'eth-receipt-log-trie': 0x99, + 'eth-reciept-log': 0x9a, + 'bitcoin-block': 0xb0, + 'bitcoin-tx': 0xb1, + 'bitcoin-witness-commitment': 0xb2, + 'zcash-block': 0xc0, + 'zcash-tx': 0xc1, + 'caip-50': 0xca, + 'streamid': 0xce, + 'stellar-block': 0xd0, + 'stellar-tx': 0xd1, + 'md4': 0xd4, + 'md5': 0xd5, + 'bmt': 0xd6, + 'decred-block': 0xe0, + 'decred-tx': 0xe1, + 'ipld-ns': 0xe2, + 'ipfs-ns': 0xe3, + 'swarm-ns': 0xe4, + 'ipns-ns': 0xe5, + 'zeronet': 0xe6, + 'secp256k1-pub': 0xe7, + 'bls12_381-g1-pub': 0xea, + 'bls12_381-g2-pub': 0xeb, + 'x25519-pub': 0xec, + 'ed25519-pub': 0xed, + 'bls12_381-g1g2-pub': 0xee, + 'dash-block': 0xf0, + 'dash-tx': 0xf1, + 'swarm-manifest': 0xfa, + 'swarm-feed': 0xfb, + 'udp': 0x0111, + 'p2p-webrtc-star': 0x0113, + 'p2p-webrtc-direct': 0x0114, + 'p2p-stardust': 0x0115, + 'p2p-circuit': 0x0122, + 'dag-json': 0x0129, + 'udt': 0x012d, + 'utp': 0x012e, + 'unix': 0x0190, + 'thread': 0x0196, + 'p2p': 0x01a5, + 'ipfs': 0x01a5, + 'https': 0x01bb, + 'onion': 0x01bc, + 'onion3': 0x01bd, + 'garlic64': 0x01be, + 'garlic32': 0x01bf, + 'tls': 0x01c0, + 'noise': 0x01c6, + 'quic': 0x01cc, + 'ws': 0x01dd, + 'wss': 0x01de, + 'p2p-websocket-star': 0x01df, + 'http': 0x01e0, + 'swhid-1-snp': 0x01f0, + 'json': 0x0200, + 'messagepack': 0x0201, + 'libp2p-peer-record': 0x0301, + 'libp2p-relay-rsvp': 0x0302, + 'car-index-sorted': 0x0400, + 'sha2-256-trunc254-padded': 0x1012, + 'ripemd-128': 0x1052, + 'ripemd-160': 0x1053, + 'ripemd-256': 0x1054, + 'ripemd-320': 0x1055, + 'x11': 0x1100, + 'p256-pub': 0x1200, + 'p384-pub': 0x1201, + 'p521-pub': 0x1202, + 'ed448-pub': 0x1203, + 'x448-pub': 0x1204, + 'ed25519-priv': 0x1300, + 'secp256k1-priv': 0x1301, + 'x25519-priv': 0x1302, + 'kangarootwelve': 0x1d01, + 'sm3-256': 0x534d, + 'blake2b-8': 0xb201, + 'blake2b-16': 0xb202, + 'blake2b-24': 0xb203, + 'blake2b-32': 0xb204, + 'blake2b-40': 0xb205, + 'blake2b-48': 0xb206, + 'blake2b-56': 0xb207, + 'blake2b-64': 0xb208, + 'blake2b-72': 0xb209, + 'blake2b-80': 0xb20a, + 'blake2b-88': 0xb20b, + 'blake2b-96': 0xb20c, + 'blake2b-104': 0xb20d, + 'blake2b-112': 0xb20e, + 'blake2b-120': 0xb20f, + 'blake2b-128': 0xb210, + 'blake2b-136': 0xb211, + 'blake2b-144': 0xb212, + 'blake2b-152': 0xb213, + 'blake2b-160': 0xb214, + 'blake2b-168': 0xb215, + 'blake2b-176': 0xb216, + 'blake2b-184': 0xb217, + 'blake2b-192': 0xb218, + 'blake2b-200': 0xb219, + 'blake2b-208': 0xb21a, + 'blake2b-216': 0xb21b, + 'blake2b-224': 0xb21c, + 'blake2b-232': 0xb21d, + 'blake2b-240': 0xb21e, + 'blake2b-248': 0xb21f, + 'blake2b-256': 0xb220, + 'blake2b-264': 0xb221, + 'blake2b-272': 0xb222, + 'blake2b-280': 0xb223, + 'blake2b-288': 0xb224, + 'blake2b-296': 0xb225, + 'blake2b-304': 0xb226, + 'blake2b-312': 0xb227, + 'blake2b-320': 0xb228, + 'blake2b-328': 0xb229, + 'blake2b-336': 0xb22a, + 'blake2b-344': 0xb22b, + 'blake2b-352': 0xb22c, + 'blake2b-360': 0xb22d, + 'blake2b-368': 0xb22e, + 'blake2b-376': 0xb22f, + 'blake2b-384': 0xb230, + 'blake2b-392': 0xb231, + 'blake2b-400': 0xb232, + 'blake2b-408': 0xb233, + 'blake2b-416': 0xb234, + 'blake2b-424': 0xb235, + 'blake2b-432': 0xb236, + 'blake2b-440': 0xb237, + 'blake2b-448': 0xb238, + 'blake2b-456': 0xb239, + 'blake2b-464': 0xb23a, + 'blake2b-472': 0xb23b, + 'blake2b-480': 0xb23c, + 'blake2b-488': 0xb23d, + 'blake2b-496': 0xb23e, + 'blake2b-504': 0xb23f, + 'blake2b-512': 0xb240, + 'blake2s-8': 0xb241, + 'blake2s-16': 0xb242, + 'blake2s-24': 0xb243, + 'blake2s-32': 0xb244, + 'blake2s-40': 0xb245, + 'blake2s-48': 0xb246, + 'blake2s-56': 0xb247, + 'blake2s-64': 0xb248, + 'blake2s-72': 0xb249, + 'blake2s-80': 0xb24a, + 'blake2s-88': 0xb24b, + 'blake2s-96': 0xb24c, + 'blake2s-104': 0xb24d, + 'blake2s-112': 0xb24e, + 'blake2s-120': 0xb24f, + 'blake2s-128': 0xb250, + 'blake2s-136': 0xb251, + 'blake2s-144': 0xb252, + 'blake2s-152': 0xb253, + 'blake2s-160': 0xb254, + 'blake2s-168': 0xb255, + 'blake2s-176': 0xb256, + 'blake2s-184': 0xb257, + 'blake2s-192': 0xb258, + 'blake2s-200': 0xb259, + 'blake2s-208': 0xb25a, + 'blake2s-216': 0xb25b, + 'blake2s-224': 0xb25c, + 'blake2s-232': 0xb25d, + 'blake2s-240': 0xb25e, + 'blake2s-248': 0xb25f, + 'blake2s-256': 0xb260, + 'skein256-8': 0xb301, + 'skein256-16': 0xb302, + 'skein256-24': 0xb303, + 'skein256-32': 0xb304, + 'skein256-40': 0xb305, + 'skein256-48': 0xb306, + 'skein256-56': 0xb307, + 'skein256-64': 0xb308, + 'skein256-72': 0xb309, + 'skein256-80': 0xb30a, + 'skein256-88': 0xb30b, + 'skein256-96': 0xb30c, + 'skein256-104': 0xb30d, + 'skein256-112': 0xb30e, + 'skein256-120': 0xb30f, + 'skein256-128': 0xb310, + 'skein256-136': 0xb311, + 'skein256-144': 0xb312, + 'skein256-152': 0xb313, + 'skein256-160': 0xb314, + 'skein256-168': 0xb315, + 'skein256-176': 0xb316, + 'skein256-184': 0xb317, + 'skein256-192': 0xb318, + 'skein256-200': 0xb319, + 'skein256-208': 0xb31a, + 'skein256-216': 0xb31b, + 'skein256-224': 0xb31c, + 'skein256-232': 0xb31d, + 'skein256-240': 0xb31e, + 'skein256-248': 0xb31f, + 'skein256-256': 0xb320, + 'skein512-8': 0xb321, + 'skein512-16': 0xb322, + 'skein512-24': 0xb323, + 'skein512-32': 0xb324, + 'skein512-40': 0xb325, + 'skein512-48': 0xb326, + 'skein512-56': 0xb327, + 'skein512-64': 0xb328, + 'skein512-72': 0xb329, + 'skein512-80': 0xb32a, + 'skein512-88': 0xb32b, + 'skein512-96': 0xb32c, + 'skein512-104': 0xb32d, + 'skein512-112': 0xb32e, + 'skein512-120': 0xb32f, + 'skein512-128': 0xb330, + 'skein512-136': 0xb331, + 'skein512-144': 0xb332, + 'skein512-152': 0xb333, + 'skein512-160': 0xb334, + 'skein512-168': 0xb335, + 'skein512-176': 0xb336, + 'skein512-184': 0xb337, + 'skein512-192': 0xb338, + 'skein512-200': 0xb339, + 'skein512-208': 0xb33a, + 'skein512-216': 0xb33b, + 'skein512-224': 0xb33c, + 'skein512-232': 0xb33d, + 'skein512-240': 0xb33e, + 'skein512-248': 0xb33f, + 'skein512-256': 0xb340, + 'skein512-264': 0xb341, + 'skein512-272': 0xb342, + 'skein512-280': 0xb343, + 'skein512-288': 0xb344, + 'skein512-296': 0xb345, + 'skein512-304': 0xb346, + 'skein512-312': 0xb347, + 'skein512-320': 0xb348, + 'skein512-328': 0xb349, + 'skein512-336': 0xb34a, + 'skein512-344': 0xb34b, + 'skein512-352': 0xb34c, + 'skein512-360': 0xb34d, + 'skein512-368': 0xb34e, + 'skein512-376': 0xb34f, + 'skein512-384': 0xb350, + 'skein512-392': 0xb351, + 'skein512-400': 0xb352, + 'skein512-408': 0xb353, + 'skein512-416': 0xb354, + 'skein512-424': 0xb355, + 'skein512-432': 0xb356, + 'skein512-440': 0xb357, + 'skein512-448': 0xb358, + 'skein512-456': 0xb359, + 'skein512-464': 0xb35a, + 'skein512-472': 0xb35b, + 'skein512-480': 0xb35c, + 'skein512-488': 0xb35d, + 'skein512-496': 0xb35e, + 'skein512-504': 0xb35f, + 'skein512-512': 0xb360, + 'skein1024-8': 0xb361, + 'skein1024-16': 0xb362, + 'skein1024-24': 0xb363, + 'skein1024-32': 0xb364, + 'skein1024-40': 0xb365, + 'skein1024-48': 0xb366, + 'skein1024-56': 0xb367, + 'skein1024-64': 0xb368, + 'skein1024-72': 0xb369, + 'skein1024-80': 0xb36a, + 'skein1024-88': 0xb36b, + 'skein1024-96': 0xb36c, + 'skein1024-104': 0xb36d, + 'skein1024-112': 0xb36e, + 'skein1024-120': 0xb36f, + 'skein1024-128': 0xb370, + 'skein1024-136': 0xb371, + 'skein1024-144': 0xb372, + 'skein1024-152': 0xb373, + 'skein1024-160': 0xb374, + 'skein1024-168': 0xb375, + 'skein1024-176': 0xb376, + 'skein1024-184': 0xb377, + 'skein1024-192': 0xb378, + 'skein1024-200': 0xb379, + 'skein1024-208': 0xb37a, + 'skein1024-216': 0xb37b, + 'skein1024-224': 0xb37c, + 'skein1024-232': 0xb37d, + 'skein1024-240': 0xb37e, + 'skein1024-248': 0xb37f, + 'skein1024-256': 0xb380, + 'skein1024-264': 0xb381, + 'skein1024-272': 0xb382, + 'skein1024-280': 0xb383, + 'skein1024-288': 0xb384, + 'skein1024-296': 0xb385, + 'skein1024-304': 0xb386, + 'skein1024-312': 0xb387, + 'skein1024-320': 0xb388, + 'skein1024-328': 0xb389, + 'skein1024-336': 0xb38a, + 'skein1024-344': 0xb38b, + 'skein1024-352': 0xb38c, + 'skein1024-360': 0xb38d, + 'skein1024-368': 0xb38e, + 'skein1024-376': 0xb38f, + 'skein1024-384': 0xb390, + 'skein1024-392': 0xb391, + 'skein1024-400': 0xb392, + 'skein1024-408': 0xb393, + 'skein1024-416': 0xb394, + 'skein1024-424': 0xb395, + 'skein1024-432': 0xb396, + 'skein1024-440': 0xb397, + 'skein1024-448': 0xb398, + 'skein1024-456': 0xb399, + 'skein1024-464': 0xb39a, + 'skein1024-472': 0xb39b, + 'skein1024-480': 0xb39c, + 'skein1024-488': 0xb39d, + 'skein1024-496': 0xb39e, + 'skein1024-504': 0xb39f, + 'skein1024-512': 0xb3a0, + 'skein1024-520': 0xb3a1, + 'skein1024-528': 0xb3a2, + 'skein1024-536': 0xb3a3, + 'skein1024-544': 0xb3a4, + 'skein1024-552': 0xb3a5, + 'skein1024-560': 0xb3a6, + 'skein1024-568': 0xb3a7, + 'skein1024-576': 0xb3a8, + 'skein1024-584': 0xb3a9, + 'skein1024-592': 0xb3aa, + 'skein1024-600': 0xb3ab, + 'skein1024-608': 0xb3ac, + 'skein1024-616': 0xb3ad, + 'skein1024-624': 0xb3ae, + 'skein1024-632': 0xb3af, + 'skein1024-640': 0xb3b0, + 'skein1024-648': 0xb3b1, + 'skein1024-656': 0xb3b2, + 'skein1024-664': 0xb3b3, + 'skein1024-672': 0xb3b4, + 'skein1024-680': 0xb3b5, + 'skein1024-688': 0xb3b6, + 'skein1024-696': 0xb3b7, + 'skein1024-704': 0xb3b8, + 'skein1024-712': 0xb3b9, + 'skein1024-720': 0xb3ba, + 'skein1024-728': 0xb3bb, + 'skein1024-736': 0xb3bc, + 'skein1024-744': 0xb3bd, + 'skein1024-752': 0xb3be, + 'skein1024-760': 0xb3bf, + 'skein1024-768': 0xb3c0, + 'skein1024-776': 0xb3c1, + 'skein1024-784': 0xb3c2, + 'skein1024-792': 0xb3c3, + 'skein1024-800': 0xb3c4, + 'skein1024-808': 0xb3c5, + 'skein1024-816': 0xb3c6, + 'skein1024-824': 0xb3c7, + 'skein1024-832': 0xb3c8, + 'skein1024-840': 0xb3c9, + 'skein1024-848': 0xb3ca, + 'skein1024-856': 0xb3cb, + 'skein1024-864': 0xb3cc, + 'skein1024-872': 0xb3cd, + 'skein1024-880': 0xb3ce, + 'skein1024-888': 0xb3cf, + 'skein1024-896': 0xb3d0, + 'skein1024-904': 0xb3d1, + 'skein1024-912': 0xb3d2, + 'skein1024-920': 0xb3d3, + 'skein1024-928': 0xb3d4, + 'skein1024-936': 0xb3d5, + 'skein1024-944': 0xb3d6, + 'skein1024-952': 0xb3d7, + 'skein1024-960': 0xb3d8, + 'skein1024-968': 0xb3d9, + 'skein1024-976': 0xb3da, + 'skein1024-984': 0xb3db, + 'skein1024-992': 0xb3dc, + 'skein1024-1000': 0xb3dd, + 'skein1024-1008': 0xb3de, + 'skein1024-1016': 0xb3df, + 'skein1024-1024': 0xb3e0, + 'poseidon-bls12_381-a2-fc1': 0xb401, + 'poseidon-bls12_381-a2-fc1-sc': 0xb402, + 'zeroxcert-imprint-256': 0xce11, + 'fil-commitment-unsealed': 0xf101, + 'fil-commitment-sealed': 0xf102, + 'holochain-adr-v0': 0x807124, + 'holochain-adr-v1': 0x817124, + 'holochain-key-v0': 0x947124, + 'holochain-key-v1': 0x957124, + 'holochain-sig-v0': 0xa27124, + 'holochain-sig-v1': 0xa37124, + 'skynet-ns': 0xb19910, + 'arweave-ns': 0xb29910 +}) + +module.exports = { baseTable } + + +/***/ }), + +/***/ 52021: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; +/** + * Implementation of the multicodec specification. + * + * @module multicodec + * @example + * const multicodec = require('multicodec') + * + * const prefixedProtobuf = multicodec.addPrefix('protobuf', protobufBuffer) + * // prefixedProtobuf 0x50... + * + */ + + +/** @typedef {import('./generated-types').CodecName} CodecName */ +/** @typedef {import('./generated-types').CodecCode} CodecCode */ + +const varint = __webpack_require__(20038) +const { concat: uint8ArrayConcat } = __webpack_require__(61045) +const util = __webpack_require__(82693) +const { nameToVarint, constantToCode, nameToCode, codeToName } = __webpack_require__(90482) + +/** + * Prefix a buffer with a multicodec-packed. + * + * @param {CodecName|Uint8Array} multicodecStrOrCode + * @param {Uint8Array} data + * @returns {Uint8Array} + */ +function addPrefix (multicodecStrOrCode, data) { + let prefix + + if (multicodecStrOrCode instanceof Uint8Array) { + prefix = util.varintUint8ArrayEncode(multicodecStrOrCode) + } else { + if (nameToVarint[multicodecStrOrCode]) { + prefix = nameToVarint[multicodecStrOrCode] + } else { + throw new Error('multicodec not recognized') + } + } + + return uint8ArrayConcat([prefix, data], prefix.length + data.length) +} + +/** + * Decapsulate the multicodec-packed prefix from the data. + * + * @param {Uint8Array} data + * @returns {Uint8Array} + */ +function rmPrefix (data) { + varint.decode(/** @type {Buffer} */(data)) + return data.slice(varint.decode.bytes) +} + +/** + * Get the codec name of the prefixed data. + * + * @param {Uint8Array} prefixedData + * @returns {CodecName} + */ +function getNameFromData (prefixedData) { + const code = /** @type {CodecCode} */(varint.decode(/** @type {Buffer} */(prefixedData))) + const name = codeToName[code] + if (name === undefined) { + throw new Error(`Code "${code}" not found`) + } + return name +} + +/** + * Get the codec name from a code. + * + * @param {CodecCode} codec + * @returns {CodecName} + */ +function getNameFromCode (codec) { + return codeToName[codec] +} + +/** + * Get the code of the codec + * + * @param {CodecName} name + * @returns {CodecCode} + */ +function getCodeFromName (name) { + const code = nameToCode[name] + if (code === undefined) { + throw new Error(`Codec "${name}" not found`) + } + return code +} + +/** + * Get the code of the prefixed data. + * + * @param {Uint8Array} prefixedData + * @returns {CodecCode} + */ +function getCodeFromData (prefixedData) { + return /** @type {CodecCode} */(varint.decode(/** @type {Buffer} */(prefixedData))) +} + +/** + * Get the code as varint of a codec name. + * + * @param {CodecName} name + * @returns {Uint8Array} + */ +function getVarintFromName (name) { + const code = nameToVarint[name] + if (code === undefined) { + throw new Error(`Codec "${name}" not found`) + } + return code +} + +/** + * Get the varint of a code. + * + * @param {CodecCode} code + * @returns {Uint8Array} + */ +function getVarintFromCode (code) { + return util.varintEncode(code) +} + +/** + * Get the codec name of the prefixed data. + * + * @deprecated use getNameFromData instead. + * @param {Uint8Array} prefixedData + * @returns {CodecName} + */ +function getCodec (prefixedData) { + return getNameFromData(prefixedData) +} + +/** + * Get the codec name from a code. + * + * @deprecated use getNameFromCode instead. + * @param {CodecCode} codec + * @returns {CodecName} + */ +function getName (codec) { + return getNameFromCode(codec) +} + +/** + * Get the code of the codec + * + * @deprecated use getCodeFromName instead. + * @param {CodecName} name + * @returns {CodecCode} + */ +function getNumber (name) { + return getCodeFromName(name) +} + +/** + * Get the code of the prefixed data. + * + * @deprecated use getCodeFromData instead. + * @param {Uint8Array} prefixedData + * @returns {CodecCode} + */ +function getCode (prefixedData) { + return getCodeFromData(prefixedData) +} + +/** + * Get the code as varint of a codec name. + * + * @deprecated use getVarintFromName instead. + * @param {CodecName} name + * @returns {Uint8Array} + */ +function getCodeVarint (name) { + return getVarintFromName(name) +} + +/** + * Get the varint of a code. + * + * @deprecated use getVarintFromCode instead. + * @param {CodecCode} code + * @returns {Array.} + */ +function getVarint (code) { + return Array.from(getVarintFromCode(code)) +} + +module.exports = { + addPrefix, + rmPrefix, + getNameFromData, + getNameFromCode, + getCodeFromName, + getCodeFromData, + getVarintFromName, + getVarintFromCode, + // Deprecated + getCodec, + getName, + getNumber, + getCode, + getCodeVarint, + getVarint, + // Make the constants top-level constants + ...constantToCode, + // Export the maps + nameToVarint, + nameToCode, + codeToName +} + + +/***/ }), + +/***/ 90482: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +/** @typedef {import('./generated-types').ConstantCodeMap} ConstantCodeMap */ +/** @typedef {import('./generated-types').NameUint8ArrayMap} NameUint8ArrayMap */ +/** @typedef {import('./generated-types').CodeNameMap} CodeNameMap */ +/** @typedef {import('./generated-types').CodecName} CodecName */ +/** @typedef {import('./generated-types').CodecConstant} CodecConstant */ + +const { baseTable } = __webpack_require__(15661) +const varintEncode = (__webpack_require__(82693).varintEncode) + +const nameToVarint = /** @type {NameUint8ArrayMap} */ ({}) +const constantToCode = /** @type {ConstantCodeMap} */({}) +const codeToName = /** @type {CodeNameMap} */({}) + +// eslint-disable-next-line guard-for-in +for (const name in baseTable) { + const codecName = /** @type {CodecName} */(name) + const code = baseTable[codecName] + nameToVarint[codecName] = varintEncode(code) + + const constant = /** @type {CodecConstant} */(codecName.toUpperCase().replace(/-/g, '_')) + constantToCode[constant] = code + + if (!codeToName[code]) { + codeToName[code] = codecName + } +} + +Object.freeze(nameToVarint) +Object.freeze(constantToCode) +Object.freeze(codeToName) +const nameToCode = Object.freeze(baseTable) +module.exports = { + nameToVarint, + constantToCode, + nameToCode, + codeToName +} + + +/***/ }), + +/***/ 82693: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +const varint = __webpack_require__(20038) +const { toString: uint8ArrayToString } = __webpack_require__(9804) +const { fromString: uint8ArrayFromString } = __webpack_require__(35195) + +module.exports = { + numberToUint8Array, + uint8ArrayToNumber, + varintUint8ArrayEncode, + varintEncode +} + +/** + * @param {Uint8Array} buf + */ +function uint8ArrayToNumber (buf) { + return parseInt(uint8ArrayToString(buf, 'base16'), 16) +} + +/** + * @param {number} num + */ +function numberToUint8Array (num) { + let hexString = num.toString(16) + if (hexString.length % 2 === 1) { + hexString = '0' + hexString + } + return uint8ArrayFromString(hexString, 'base16') +} + +/** + * @param {Uint8Array} input + */ +function varintUint8ArrayEncode (input) { + return Uint8Array.from(varint.encode(uint8ArrayToNumber(input))) +} + +/** + * @param {number} num + */ +function varintEncode (num) { + return Uint8Array.from(varint.encode(num)) +} + + +/***/ }), + +/***/ 11222: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var baseX$1 = __webpack_require__(89816); +var bytes = __webpack_require__(13913); + +class Encoder { + constructor(name, prefix, baseEncode) { + this.name = name; + this.prefix = prefix; + this.baseEncode = baseEncode; + } + encode(bytes) { + if (bytes instanceof Uint8Array) { + return `${ this.prefix }${ this.baseEncode(bytes) }`; + } else { + throw Error('Unknown type, must be binary type'); + } + } +} +class Decoder { + constructor(name, prefix, baseDecode) { + this.name = name; + this.prefix = prefix; + if (prefix.codePointAt(0) === undefined) { + throw new Error('Invalid prefix character'); + } + this.prefixCodePoint = prefix.codePointAt(0); + this.baseDecode = baseDecode; + } + decode(text) { + if (typeof text === 'string') { + if (text.codePointAt(0) !== this.prefixCodePoint) { + throw Error(`Unable to decode multibase string ${ JSON.stringify(text) }, ${ this.name } decoder only supports inputs prefixed with ${ this.prefix }`); + } + return this.baseDecode(text.slice(this.prefix.length)); + } else { + throw Error('Can only multibase decode strings'); + } + } + or(decoder) { + return or(this, decoder); + } +} +class ComposedDecoder { + constructor(decoders) { + this.decoders = decoders; + } + or(decoder) { + return or(this, decoder); + } + decode(input) { + const prefix = input[0]; + const decoder = this.decoders[prefix]; + if (decoder) { + return decoder.decode(input); + } else { + throw RangeError(`Unable to decode multibase string ${ JSON.stringify(input) }, only inputs prefixed with ${ Object.keys(this.decoders) } are supported`); + } + } +} +const or = (left, right) => new ComposedDecoder({ + ...left.decoders || { [left.prefix]: left }, + ...right.decoders || { [right.prefix]: right } +}); +class Codec { + constructor(name, prefix, baseEncode, baseDecode) { + this.name = name; + this.prefix = prefix; + this.baseEncode = baseEncode; + this.baseDecode = baseDecode; + this.encoder = new Encoder(name, prefix, baseEncode); + this.decoder = new Decoder(name, prefix, baseDecode); + } + encode(input) { + return this.encoder.encode(input); + } + decode(input) { + return this.decoder.decode(input); + } +} +const from = ({name, prefix, encode, decode}) => new Codec(name, prefix, encode, decode); +const baseX = ({prefix, name, alphabet}) => { + const {encode, decode} = baseX$1(alphabet, name); + return from({ + prefix, + name, + encode, + decode: text => bytes.coerce(decode(text)) + }); +}; +const decode = (string, alphabet, bitsPerChar, name) => { + const codes = {}; + for (let i = 0; i < alphabet.length; ++i) { + codes[alphabet[i]] = i; + } + let end = string.length; + while (string[end - 1] === '=') { + --end; + } + const out = new Uint8Array(end * bitsPerChar / 8 | 0); + let bits = 0; + let buffer = 0; + let written = 0; + for (let i = 0; i < end; ++i) { + const value = codes[string[i]]; + if (value === undefined) { + throw new SyntaxError(`Non-${ name } character`); + } + buffer = buffer << bitsPerChar | value; + bits += bitsPerChar; + if (bits >= 8) { + bits -= 8; + out[written++] = 255 & buffer >> bits; + } + } + if (bits >= bitsPerChar || 255 & buffer << 8 - bits) { + throw new SyntaxError('Unexpected end of data'); + } + return out; +}; +const encode = (data, alphabet, bitsPerChar) => { + const pad = alphabet[alphabet.length - 1] === '='; + const mask = (1 << bitsPerChar) - 1; + let out = ''; + let bits = 0; + let buffer = 0; + for (let i = 0; i < data.length; ++i) { + buffer = buffer << 8 | data[i]; + bits += 8; + while (bits > bitsPerChar) { + bits -= bitsPerChar; + out += alphabet[mask & buffer >> bits]; + } + } + if (bits) { + out += alphabet[mask & buffer << bitsPerChar - bits]; + } + if (pad) { + while (out.length * bitsPerChar & 7) { + out += '='; + } + } + return out; +}; +const rfc4648 = ({name, prefix, bitsPerChar, alphabet}) => { + return from({ + prefix, + name, + encode(input) { + return encode(input, alphabet, bitsPerChar); + }, + decode(input) { + return decode(input, alphabet, bitsPerChar, name); + } + }); +}; + +exports.Codec = Codec; +exports.baseX = baseX; +exports.from = from; +exports.or = or; +exports.rfc4648 = rfc4648; + + +/***/ }), + +/***/ 67339: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var base = __webpack_require__(11222); + +const base10 = base.baseX({ + prefix: '9', + name: 'base10', + alphabet: '0123456789' +}); + +exports.base10 = base10; + + +/***/ }), + +/***/ 49265: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var base = __webpack_require__(11222); + +const base16 = base.rfc4648({ + prefix: 'f', + name: 'base16', + alphabet: '0123456789abcdef', + bitsPerChar: 4 +}); +const base16upper = base.rfc4648({ + prefix: 'F', + name: 'base16upper', + alphabet: '0123456789ABCDEF', + bitsPerChar: 4 +}); + +exports.base16 = base16; +exports.base16upper = base16upper; + + +/***/ }), + +/***/ 59998: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var base = __webpack_require__(11222); + +const base2 = base.rfc4648({ + prefix: '0', + name: 'base2', + alphabet: '01', + bitsPerChar: 1 +}); + +exports.base2 = base2; + + +/***/ }), + +/***/ 24347: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var base = __webpack_require__(11222); + +const alphabet = Array.from('\uD83D\uDE80\uD83E\uDE90\u2604\uD83D\uDEF0\uD83C\uDF0C\uD83C\uDF11\uD83C\uDF12\uD83C\uDF13\uD83C\uDF14\uD83C\uDF15\uD83C\uDF16\uD83C\uDF17\uD83C\uDF18\uD83C\uDF0D\uD83C\uDF0F\uD83C\uDF0E\uD83D\uDC09\u2600\uD83D\uDCBB\uD83D\uDDA5\uD83D\uDCBE\uD83D\uDCBF\uD83D\uDE02\u2764\uD83D\uDE0D\uD83E\uDD23\uD83D\uDE0A\uD83D\uDE4F\uD83D\uDC95\uD83D\uDE2D\uD83D\uDE18\uD83D\uDC4D\uD83D\uDE05\uD83D\uDC4F\uD83D\uDE01\uD83D\uDD25\uD83E\uDD70\uD83D\uDC94\uD83D\uDC96\uD83D\uDC99\uD83D\uDE22\uD83E\uDD14\uD83D\uDE06\uD83D\uDE44\uD83D\uDCAA\uD83D\uDE09\u263A\uD83D\uDC4C\uD83E\uDD17\uD83D\uDC9C\uD83D\uDE14\uD83D\uDE0E\uD83D\uDE07\uD83C\uDF39\uD83E\uDD26\uD83C\uDF89\uD83D\uDC9E\u270C\u2728\uD83E\uDD37\uD83D\uDE31\uD83D\uDE0C\uD83C\uDF38\uD83D\uDE4C\uD83D\uDE0B\uD83D\uDC97\uD83D\uDC9A\uD83D\uDE0F\uD83D\uDC9B\uD83D\uDE42\uD83D\uDC93\uD83E\uDD29\uD83D\uDE04\uD83D\uDE00\uD83D\uDDA4\uD83D\uDE03\uD83D\uDCAF\uD83D\uDE48\uD83D\uDC47\uD83C\uDFB6\uD83D\uDE12\uD83E\uDD2D\u2763\uD83D\uDE1C\uD83D\uDC8B\uD83D\uDC40\uD83D\uDE2A\uD83D\uDE11\uD83D\uDCA5\uD83D\uDE4B\uD83D\uDE1E\uD83D\uDE29\uD83D\uDE21\uD83E\uDD2A\uD83D\uDC4A\uD83E\uDD73\uD83D\uDE25\uD83E\uDD24\uD83D\uDC49\uD83D\uDC83\uD83D\uDE33\u270B\uD83D\uDE1A\uD83D\uDE1D\uD83D\uDE34\uD83C\uDF1F\uD83D\uDE2C\uD83D\uDE43\uD83C\uDF40\uD83C\uDF37\uD83D\uDE3B\uD83D\uDE13\u2B50\u2705\uD83E\uDD7A\uD83C\uDF08\uD83D\uDE08\uD83E\uDD18\uD83D\uDCA6\u2714\uD83D\uDE23\uD83C\uDFC3\uD83D\uDC90\u2639\uD83C\uDF8A\uD83D\uDC98\uD83D\uDE20\u261D\uD83D\uDE15\uD83C\uDF3A\uD83C\uDF82\uD83C\uDF3B\uD83D\uDE10\uD83D\uDD95\uD83D\uDC9D\uD83D\uDE4A\uD83D\uDE39\uD83D\uDDE3\uD83D\uDCAB\uD83D\uDC80\uD83D\uDC51\uD83C\uDFB5\uD83E\uDD1E\uD83D\uDE1B\uD83D\uDD34\uD83D\uDE24\uD83C\uDF3C\uD83D\uDE2B\u26BD\uD83E\uDD19\u2615\uD83C\uDFC6\uD83E\uDD2B\uD83D\uDC48\uD83D\uDE2E\uD83D\uDE46\uD83C\uDF7B\uD83C\uDF43\uD83D\uDC36\uD83D\uDC81\uD83D\uDE32\uD83C\uDF3F\uD83E\uDDE1\uD83C\uDF81\u26A1\uD83C\uDF1E\uD83C\uDF88\u274C\u270A\uD83D\uDC4B\uD83D\uDE30\uD83E\uDD28\uD83D\uDE36\uD83E\uDD1D\uD83D\uDEB6\uD83D\uDCB0\uD83C\uDF53\uD83D\uDCA2\uD83E\uDD1F\uD83D\uDE41\uD83D\uDEA8\uD83D\uDCA8\uD83E\uDD2C\u2708\uD83C\uDF80\uD83C\uDF7A\uD83E\uDD13\uD83D\uDE19\uD83D\uDC9F\uD83C\uDF31\uD83D\uDE16\uD83D\uDC76\uD83E\uDD74\u25B6\u27A1\u2753\uD83D\uDC8E\uD83D\uDCB8\u2B07\uD83D\uDE28\uD83C\uDF1A\uD83E\uDD8B\uD83D\uDE37\uD83D\uDD7A\u26A0\uD83D\uDE45\uD83D\uDE1F\uD83D\uDE35\uD83D\uDC4E\uD83E\uDD32\uD83E\uDD20\uD83E\uDD27\uD83D\uDCCC\uD83D\uDD35\uD83D\uDC85\uD83E\uDDD0\uD83D\uDC3E\uD83C\uDF52\uD83D\uDE17\uD83E\uDD11\uD83C\uDF0A\uD83E\uDD2F\uD83D\uDC37\u260E\uD83D\uDCA7\uD83D\uDE2F\uD83D\uDC86\uD83D\uDC46\uD83C\uDFA4\uD83D\uDE47\uD83C\uDF51\u2744\uD83C\uDF34\uD83D\uDCA3\uD83D\uDC38\uD83D\uDC8C\uD83D\uDCCD\uD83E\uDD40\uD83E\uDD22\uD83D\uDC45\uD83D\uDCA1\uD83D\uDCA9\uD83D\uDC50\uD83D\uDCF8\uD83D\uDC7B\uD83E\uDD10\uD83E\uDD2E\uD83C\uDFBC\uD83E\uDD75\uD83D\uDEA9\uD83C\uDF4E\uD83C\uDF4A\uD83D\uDC7C\uD83D\uDC8D\uD83D\uDCE3\uD83E\uDD42'); +const alphabetBytesToChars = alphabet.reduce((p, c, i) => { + p[i] = c; + return p; +}, []); +const alphabetCharsToBytes = alphabet.reduce((p, c, i) => { + p[c.codePointAt(0)] = i; + return p; +}, []); +function encode(data) { + return data.reduce((p, c) => { + p += alphabetBytesToChars[c]; + return p; + }, ''); +} +function decode(str) { + const byts = []; + for (const char of str) { + const byt = alphabetCharsToBytes[char.codePointAt(0)]; + if (byt === undefined) { + throw new Error(`Non-base256emoji character: ${ char }`); + } + byts.push(byt); + } + return new Uint8Array(byts); +} +const base256emoji = base.from({ + prefix: '\uD83D\uDE80', + name: 'base256emoji', + encode, + decode +}); + +exports.base256emoji = base256emoji; + + +/***/ }), + +/***/ 78607: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var base = __webpack_require__(11222); + +const base32 = base.rfc4648({ + prefix: 'b', + name: 'base32', + alphabet: 'abcdefghijklmnopqrstuvwxyz234567', + bitsPerChar: 5 +}); +const base32upper = base.rfc4648({ + prefix: 'B', + name: 'base32upper', + alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', + bitsPerChar: 5 +}); +const base32pad = base.rfc4648({ + prefix: 'c', + name: 'base32pad', + alphabet: 'abcdefghijklmnopqrstuvwxyz234567=', + bitsPerChar: 5 +}); +const base32padupper = base.rfc4648({ + prefix: 'C', + name: 'base32padupper', + alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=', + bitsPerChar: 5 +}); +const base32hex = base.rfc4648({ + prefix: 'v', + name: 'base32hex', + alphabet: '0123456789abcdefghijklmnopqrstuv', + bitsPerChar: 5 +}); +const base32hexupper = base.rfc4648({ + prefix: 'V', + name: 'base32hexupper', + alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV', + bitsPerChar: 5 +}); +const base32hexpad = base.rfc4648({ + prefix: 't', + name: 'base32hexpad', + alphabet: '0123456789abcdefghijklmnopqrstuv=', + bitsPerChar: 5 +}); +const base32hexpadupper = base.rfc4648({ + prefix: 'T', + name: 'base32hexpadupper', + alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV=', + bitsPerChar: 5 +}); +const base32z = base.rfc4648({ + prefix: 'h', + name: 'base32z', + alphabet: 'ybndrfg8ejkmcpqxot1uwisza345h769', + bitsPerChar: 5 +}); + +exports.base32 = base32; +exports.base32hex = base32hex; +exports.base32hexpad = base32hexpad; +exports.base32hexpadupper = base32hexpadupper; +exports.base32hexupper = base32hexupper; +exports.base32pad = base32pad; +exports.base32padupper = base32padupper; +exports.base32upper = base32upper; +exports.base32z = base32z; + + +/***/ }), + +/***/ 31499: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var base = __webpack_require__(11222); + +const base36 = base.baseX({ + prefix: 'k', + name: 'base36', + alphabet: '0123456789abcdefghijklmnopqrstuvwxyz' +}); +const base36upper = base.baseX({ + prefix: 'K', + name: 'base36upper', + alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' +}); + +exports.base36 = base36; +exports.base36upper = base36upper; + + +/***/ }), + +/***/ 73455: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var base = __webpack_require__(11222); + +const base58btc = base.baseX({ + name: 'base58btc', + prefix: 'z', + alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' +}); +const base58flickr = base.baseX({ + name: 'base58flickr', + prefix: 'Z', + alphabet: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ' +}); + +exports.base58btc = base58btc; +exports.base58flickr = base58flickr; + + +/***/ }), + +/***/ 89412: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var base = __webpack_require__(11222); + +const base64 = base.rfc4648({ + prefix: 'm', + name: 'base64', + alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', + bitsPerChar: 6 +}); +const base64pad = base.rfc4648({ + prefix: 'M', + name: 'base64pad', + alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', + bitsPerChar: 6 +}); +const base64url = base.rfc4648({ + prefix: 'u', + name: 'base64url', + alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_', + bitsPerChar: 6 +}); +const base64urlpad = base.rfc4648({ + prefix: 'U', + name: 'base64urlpad', + alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=', + bitsPerChar: 6 +}); + +exports.base64 = base64; +exports.base64pad = base64pad; +exports.base64url = base64url; +exports.base64urlpad = base64urlpad; + + +/***/ }), + +/***/ 68588: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var base = __webpack_require__(11222); + +const base8 = base.rfc4648({ + prefix: '7', + name: 'base8', + alphabet: '01234567', + bitsPerChar: 3 +}); + +exports.base8 = base8; + + +/***/ }), + +/***/ 50357: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var base = __webpack_require__(11222); +var bytes = __webpack_require__(13913); + +const identity = base.from({ + prefix: '\0', + name: 'identity', + encode: buf => bytes.toString(buf), + decode: str => bytes.fromString(str) +}); + +exports.identity = identity; + + +/***/ }), + +/***/ 62399: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var identity = __webpack_require__(50357); +var base2 = __webpack_require__(59998); +var base8 = __webpack_require__(68588); +var base10 = __webpack_require__(67339); +var base16 = __webpack_require__(49265); +var base32 = __webpack_require__(78607); +var base36 = __webpack_require__(31499); +var base58 = __webpack_require__(73455); +var base64 = __webpack_require__(89412); +var base256emoji = __webpack_require__(24347); +var sha2 = __webpack_require__(87383); +var identity$1 = __webpack_require__(441); +var raw = __webpack_require__(13522); +var json = __webpack_require__(15824); +__webpack_require__(2386); +var cid = __webpack_require__(48286); +var hasher = __webpack_require__(35384); +var digest = __webpack_require__(42523); +var varint = __webpack_require__(29258); +var bytes = __webpack_require__(13913); + +const bases = { + ...identity, + ...base2, + ...base8, + ...base10, + ...base16, + ...base32, + ...base36, + ...base58, + ...base64, + ...base256emoji +}; +const hashes = { + ...sha2, + ...identity$1 +}; +const codecs = { + raw, + json +}; + +exports.CID = cid.CID; +exports.hasher = hasher; +exports.digest = digest; +exports.varint = varint; +exports.bytes = bytes; +exports.bases = bases; +exports.codecs = codecs; +exports.hashes = hashes; + + +/***/ }), + +/***/ 13913: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +const empty = new Uint8Array(0); +const toHex = d => d.reduce((hex, byte) => hex + byte.toString(16).padStart(2, '0'), ''); +const fromHex = hex => { + const hexes = hex.match(/../g); + return hexes ? new Uint8Array(hexes.map(b => parseInt(b, 16))) : empty; +}; +const equals = (aa, bb) => { + if (aa === bb) + return true; + if (aa.byteLength !== bb.byteLength) { + return false; + } + for (let ii = 0; ii < aa.byteLength; ii++) { + if (aa[ii] !== bb[ii]) { + return false; + } + } + return true; +}; +const coerce = o => { + if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array') + return o; + if (o instanceof ArrayBuffer) + return new Uint8Array(o); + if (ArrayBuffer.isView(o)) { + return new Uint8Array(o.buffer, o.byteOffset, o.byteLength); + } + throw new Error('Unknown type, must be binary type'); +}; +const isBinary = o => o instanceof ArrayBuffer || ArrayBuffer.isView(o); +const fromString = str => new TextEncoder().encode(str); +const toString = b => new TextDecoder().decode(b); + +exports.coerce = coerce; +exports.empty = empty; +exports.equals = equals; +exports.fromHex = fromHex; +exports.fromString = fromString; +exports.isBinary = isBinary; +exports.toHex = toHex; +exports.toString = toString; + + +/***/ }), + +/***/ 48286: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var varint = __webpack_require__(29258); +var digest = __webpack_require__(42523); +var base58 = __webpack_require__(73455); +var base32 = __webpack_require__(78607); +var bytes = __webpack_require__(13913); + +class CID { + constructor(version, code, multihash, bytes) { + this.code = code; + this.version = version; + this.multihash = multihash; + this.bytes = bytes; + this.byteOffset = bytes.byteOffset; + this.byteLength = bytes.byteLength; + this.asCID = this; + this._baseCache = new Map(); + Object.defineProperties(this, { + byteOffset: hidden, + byteLength: hidden, + code: readonly, + version: readonly, + multihash: readonly, + bytes: readonly, + _baseCache: hidden, + asCID: hidden + }); + } + toV0() { + switch (this.version) { + case 0: { + return this; + } + default: { + const {code, multihash} = this; + if (code !== DAG_PB_CODE) { + throw new Error('Cannot convert a non dag-pb CID to CIDv0'); + } + if (multihash.code !== SHA_256_CODE) { + throw new Error('Cannot convert non sha2-256 multihash CID to CIDv0'); + } + return CID.createV0(multihash); + } + } + } + toV1() { + switch (this.version) { + case 0: { + const {code, digest: digest$1} = this.multihash; + const multihash = digest.create(code, digest$1); + return CID.createV1(this.code, multihash); + } + case 1: { + return this; + } + default: { + throw Error(`Can not convert CID version ${ this.version } to version 0. This is a bug please report`); + } + } + } + equals(other) { + return other && this.code === other.code && this.version === other.version && digest.equals(this.multihash, other.multihash); + } + toString(base) { + const {bytes, version, _baseCache} = this; + switch (version) { + case 0: + return toStringV0(bytes, _baseCache, base || base58.base58btc.encoder); + default: + return toStringV1(bytes, _baseCache, base || base32.base32.encoder); + } + } + toJSON() { + return { + code: this.code, + version: this.version, + hash: this.multihash.bytes + }; + } + get [Symbol.toStringTag]() { + return 'CID'; + } + [Symbol.for('nodejs.util.inspect.custom')]() { + return 'CID(' + this.toString() + ')'; + } + static isCID(value) { + deprecate(/^0\.0/, IS_CID_DEPRECATION); + return !!(value && (value[cidSymbol] || value.asCID === value)); + } + get toBaseEncodedString() { + throw new Error('Deprecated, use .toString()'); + } + get codec() { + throw new Error('"codec" property is deprecated, use integer "code" property instead'); + } + get buffer() { + throw new Error('Deprecated .buffer property, use .bytes to get Uint8Array instead'); + } + get multibaseName() { + throw new Error('"multibaseName" property is deprecated'); + } + get prefix() { + throw new Error('"prefix" property is deprecated'); + } + static asCID(value) { + if (value instanceof CID) { + return value; + } else if (value != null && value.asCID === value) { + const {version, code, multihash, bytes} = value; + return new CID(version, code, multihash, bytes || encodeCID(version, code, multihash.bytes)); + } else if (value != null && value[cidSymbol] === true) { + const {version, multihash, code} = value; + const digest$1 = digest.decode(multihash); + return CID.create(version, code, digest$1); + } else { + return null; + } + } + static create(version, code, digest) { + if (typeof code !== 'number') { + throw new Error('String codecs are no longer supported'); + } + switch (version) { + case 0: { + if (code !== DAG_PB_CODE) { + throw new Error(`Version 0 CID must use dag-pb (code: ${ DAG_PB_CODE }) block encoding`); + } else { + return new CID(version, code, digest, digest.bytes); + } + } + case 1: { + const bytes = encodeCID(version, code, digest.bytes); + return new CID(version, code, digest, bytes); + } + default: { + throw new Error('Invalid version'); + } + } + } + static createV0(digest) { + return CID.create(0, DAG_PB_CODE, digest); + } + static createV1(code, digest) { + return CID.create(1, code, digest); + } + static decode(bytes) { + const [cid, remainder] = CID.decodeFirst(bytes); + if (remainder.length) { + throw new Error('Incorrect length'); + } + return cid; + } + static decodeFirst(bytes$1) { + const specs = CID.inspectBytes(bytes$1); + const prefixSize = specs.size - specs.multihashSize; + const multihashBytes = bytes.coerce(bytes$1.subarray(prefixSize, prefixSize + specs.multihashSize)); + if (multihashBytes.byteLength !== specs.multihashSize) { + throw new Error('Incorrect length'); + } + const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize); + const digest$1 = new digest.Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes); + const cid = specs.version === 0 ? CID.createV0(digest$1) : CID.createV1(specs.codec, digest$1); + return [ + cid, + bytes$1.subarray(specs.size) + ]; + } + static inspectBytes(initialBytes) { + let offset = 0; + const next = () => { + const [i, length] = varint.decode(initialBytes.subarray(offset)); + offset += length; + return i; + }; + let version = next(); + let codec = DAG_PB_CODE; + if (version === 18) { + version = 0; + offset = 0; + } else if (version === 1) { + codec = next(); + } + if (version !== 0 && version !== 1) { + throw new RangeError(`Invalid CID version ${ version }`); + } + const prefixSize = offset; + const multihashCode = next(); + const digestSize = next(); + const size = offset + digestSize; + const multihashSize = size - prefixSize; + return { + version, + codec, + multihashCode, + digestSize, + multihashSize, + size + }; + } + static parse(source, base) { + const [prefix, bytes] = parseCIDtoBytes(source, base); + const cid = CID.decode(bytes); + cid._baseCache.set(prefix, source); + return cid; + } +} +const parseCIDtoBytes = (source, base) => { + switch (source[0]) { + case 'Q': { + const decoder = base || base58.base58btc; + return [ + base58.base58btc.prefix, + decoder.decode(`${ base58.base58btc.prefix }${ source }`) + ]; + } + case base58.base58btc.prefix: { + const decoder = base || base58.base58btc; + return [ + base58.base58btc.prefix, + decoder.decode(source) + ]; + } + case base32.base32.prefix: { + const decoder = base || base32.base32; + return [ + base32.base32.prefix, + decoder.decode(source) + ]; + } + default: { + if (base == null) { + throw Error('To parse non base32 or base58btc encoded CID multibase decoder must be provided'); + } + return [ + source[0], + base.decode(source) + ]; + } + } +}; +const toStringV0 = (bytes, cache, base) => { + const {prefix} = base; + if (prefix !== base58.base58btc.prefix) { + throw Error(`Cannot string encode V0 in ${ base.name } encoding`); + } + const cid = cache.get(prefix); + if (cid == null) { + const cid = base.encode(bytes).slice(1); + cache.set(prefix, cid); + return cid; + } else { + return cid; + } +}; +const toStringV1 = (bytes, cache, base) => { + const {prefix} = base; + const cid = cache.get(prefix); + if (cid == null) { + const cid = base.encode(bytes); + cache.set(prefix, cid); + return cid; + } else { + return cid; + } +}; +const DAG_PB_CODE = 112; +const SHA_256_CODE = 18; +const encodeCID = (version, code, multihash) => { + const codeOffset = varint.encodingLength(version); + const hashOffset = codeOffset + varint.encodingLength(code); + const bytes = new Uint8Array(hashOffset + multihash.byteLength); + varint.encodeTo(version, bytes, 0); + varint.encodeTo(code, bytes, codeOffset); + bytes.set(multihash, hashOffset); + return bytes; +}; +const cidSymbol = Symbol.for('@ipld/js-cid/CID'); +const readonly = { + writable: false, + configurable: false, + enumerable: true +}; +const hidden = { + writable: false, + enumerable: false, + configurable: false +}; +const version = '0.0.0-dev'; +const deprecate = (range, message) => { + if (range.test(version)) { + console.warn(message); + } else { + throw new Error(message); + } +}; +const IS_CID_DEPRECATION = `CID.isCID(v) is deprecated and will be removed in the next major release. +Following code pattern: + +if (CID.isCID(value)) { + doSomethingWithCID(value) +} + +Is replaced with: + +const cid = CID.asCID(value) +if (cid) { + // Make sure to use cid instead of value + doSomethingWithCID(cid) +} +`; + +exports.CID = CID; + + +/***/ }), + +/***/ 15824: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +const textEncoder = new TextEncoder(); +const textDecoder = new TextDecoder(); +const name = 'json'; +const code = 512; +const encode = node => textEncoder.encode(JSON.stringify(node)); +const decode = data => JSON.parse(textDecoder.decode(data)); + +exports.code = code; +exports.decode = decode; +exports.encode = encode; +exports.name = name; + + +/***/ }), + +/***/ 13522: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var bytes = __webpack_require__(13913); + +const name = 'raw'; +const code = 85; +const encode = node => bytes.coerce(node); +const decode = data => bytes.coerce(data); + +exports.code = code; +exports.decode = decode; +exports.encode = encode; +exports.name = name; + + +/***/ }), + +/***/ 42523: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var bytes = __webpack_require__(13913); +var varint = __webpack_require__(29258); + +const create = (code, digest) => { + const size = digest.byteLength; + const sizeOffset = varint.encodingLength(code); + const digestOffset = sizeOffset + varint.encodingLength(size); + const bytes = new Uint8Array(digestOffset + size); + varint.encodeTo(code, bytes, 0); + varint.encodeTo(size, bytes, sizeOffset); + bytes.set(digest, digestOffset); + return new Digest(code, size, digest, bytes); +}; +const decode = multihash => { + const bytes$1 = bytes.coerce(multihash); + const [code, sizeOffset] = varint.decode(bytes$1); + const [size, digestOffset] = varint.decode(bytes$1.subarray(sizeOffset)); + const digest = bytes$1.subarray(sizeOffset + digestOffset); + if (digest.byteLength !== size) { + throw new Error('Incorrect length'); + } + return new Digest(code, size, digest, bytes$1); +}; +const equals = (a, b) => { + if (a === b) { + return true; + } else { + return a.code === b.code && a.size === b.size && bytes.equals(a.bytes, b.bytes); + } +}; +class Digest { + constructor(code, size, digest, bytes) { + this.code = code; + this.size = size; + this.digest = digest; + this.bytes = bytes; + } +} + +exports.Digest = Digest; +exports.create = create; +exports.decode = decode; +exports.equals = equals; + + +/***/ }), + +/***/ 35384: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var digest = __webpack_require__(42523); + +const from = ({name, code, encode}) => new Hasher(name, code, encode); +class Hasher { + constructor(name, code, encode) { + this.name = name; + this.code = code; + this.encode = encode; + } + digest(input) { + if (input instanceof Uint8Array) { + const result = this.encode(input); + return result instanceof Uint8Array ? digest.create(this.code, result) : result.then(digest$1 => digest.create(this.code, digest$1)); + } else { + throw Error('Unknown type, must be binary type'); + } + } +} + +exports.Hasher = Hasher; +exports.from = from; + + +/***/ }), + +/***/ 441: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var bytes = __webpack_require__(13913); +var digest$1 = __webpack_require__(42523); + +const code = 0; +const name = 'identity'; +const encode = bytes.coerce; +const digest = input => digest$1.create(code, encode(input)); +const identity = { + code, + name, + encode, + digest +}; + +exports.identity = identity; + + +/***/ }), + +/***/ 87383: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var crypto = __webpack_require__(76982); +var hasher = __webpack_require__(35384); +var bytes = __webpack_require__(13913); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto); + +const sha256 = hasher.from({ + name: 'sha2-256', + code: 18, + encode: input => bytes.coerce(crypto__default["default"].createHash('sha256').update(input).digest()) +}); +const sha512 = hasher.from({ + name: 'sha2-512', + code: 19, + encode: input => bytes.coerce(crypto__default["default"].createHash('sha512').update(input).digest()) +}); + +exports.sha256 = sha256; +exports.sha512 = sha512; + + +/***/ }), + +/***/ 2386: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var cid = __webpack_require__(48286); +var varint = __webpack_require__(29258); +var bytes = __webpack_require__(13913); +var hasher = __webpack_require__(35384); +var digest = __webpack_require__(42523); + + + +exports.CID = cid.CID; +exports.varint = varint; +exports.bytes = bytes; +exports.hasher = hasher; +exports.digest = digest; + + +/***/ }), + +/***/ 29258: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var varint$1 = __webpack_require__(46682); + +const decode = (data, offset = 0) => { + const code = varint$1.decode(data, offset); + return [ + code, + varint$1.decode.bytes + ]; +}; +const encodeTo = (int, target, offset = 0) => { + varint$1.encode(int, target, offset); + return target; +}; +const encodingLength = int => { + return varint$1.encodingLength(int); +}; + +exports.decode = decode; +exports.encodeTo = encodeTo; +exports.encodingLength = encodingLength; + + +/***/ }), + +/***/ 89816: +/***/ ((module) => { + +"use strict"; + + +function base(ALPHABET, name) { + if (ALPHABET.length >= 255) { + throw new TypeError('Alphabet too long'); + } + var BASE_MAP = new Uint8Array(256); + for (var j = 0; j < BASE_MAP.length; j++) { + BASE_MAP[j] = 255; + } + for (var i = 0; i < ALPHABET.length; i++) { + var x = ALPHABET.charAt(i); + var xc = x.charCodeAt(0); + if (BASE_MAP[xc] !== 255) { + throw new TypeError(x + ' is ambiguous'); + } + BASE_MAP[xc] = i; + } + var BASE = ALPHABET.length; + var LEADER = ALPHABET.charAt(0); + var FACTOR = Math.log(BASE) / Math.log(256); + var iFACTOR = Math.log(256) / Math.log(BASE); + function encode(source) { + if (source instanceof Uint8Array); + else if (ArrayBuffer.isView(source)) { + source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength); + } else if (Array.isArray(source)) { + source = Uint8Array.from(source); + } + if (!(source instanceof Uint8Array)) { + throw new TypeError('Expected Uint8Array'); + } + if (source.length === 0) { + return ''; + } + var zeroes = 0; + var length = 0; + var pbegin = 0; + var pend = source.length; + while (pbegin !== pend && source[pbegin] === 0) { + pbegin++; + zeroes++; + } + var size = (pend - pbegin) * iFACTOR + 1 >>> 0; + var b58 = new Uint8Array(size); + while (pbegin !== pend) { + var carry = source[pbegin]; + var i = 0; + for (var it1 = size - 1; (carry !== 0 || i < length) && it1 !== -1; it1--, i++) { + carry += 256 * b58[it1] >>> 0; + b58[it1] = carry % BASE >>> 0; + carry = carry / BASE >>> 0; + } + if (carry !== 0) { + throw new Error('Non-zero carry'); + } + length = i; + pbegin++; + } + var it2 = size - length; + while (it2 !== size && b58[it2] === 0) { + it2++; + } + var str = LEADER.repeat(zeroes); + for (; it2 < size; ++it2) { + str += ALPHABET.charAt(b58[it2]); + } + return str; + } + function decodeUnsafe(source) { + if (typeof source !== 'string') { + throw new TypeError('Expected String'); + } + if (source.length === 0) { + return new Uint8Array(); + } + var psz = 0; + if (source[psz] === ' ') { + return; + } + var zeroes = 0; + var length = 0; + while (source[psz] === LEADER) { + zeroes++; + psz++; + } + var size = (source.length - psz) * FACTOR + 1 >>> 0; + var b256 = new Uint8Array(size); + while (source[psz]) { + var carry = BASE_MAP[source.charCodeAt(psz)]; + if (carry === 255) { + return; + } + var i = 0; + for (var it3 = size - 1; (carry !== 0 || i < length) && it3 !== -1; it3--, i++) { + carry += BASE * b256[it3] >>> 0; + b256[it3] = carry % 256 >>> 0; + carry = carry / 256 >>> 0; + } + if (carry !== 0) { + throw new Error('Non-zero carry'); + } + length = i; + psz++; + } + if (source[psz] === ' ') { + return; + } + var it4 = size - length; + while (it4 !== size && b256[it4] === 0) { + it4++; + } + var vch = new Uint8Array(zeroes + (size - it4)); + var j = zeroes; + while (it4 !== size) { + vch[j++] = b256[it4++]; + } + return vch; + } + function decode(string) { + var buffer = decodeUnsafe(string); + if (buffer) { + return buffer; + } + throw new Error(`Non-${ name } character`); + } + return { + encode: encode, + decodeUnsafe: decodeUnsafe, + decode: decode + }; +} +var src = base; +var _brrp__multiformats_scope_baseX = src; + +module.exports = _brrp__multiformats_scope_baseX; + + +/***/ }), + +/***/ 46682: +/***/ ((module) => { + +"use strict"; + + +var encode_1 = encode; +var MSB = 128, REST = 127, MSBALL = ~REST, INT = Math.pow(2, 31); +function encode(num, out, offset) { + out = out || []; + offset = offset || 0; + var oldOffset = offset; + while (num >= INT) { + out[offset++] = num & 255 | MSB; + num /= 128; + } + while (num & MSBALL) { + out[offset++] = num & 255 | MSB; + num >>>= 7; + } + out[offset] = num | 0; + encode.bytes = offset - oldOffset + 1; + return out; +} +var decode = read; +var MSB$1 = 128, REST$1 = 127; +function read(buf, offset) { + var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length; + do { + if (counter >= l) { + read.bytes = 0; + throw new RangeError('Could not decode varint'); + } + b = buf[counter++]; + res += shift < 28 ? (b & REST$1) << shift : (b & REST$1) * Math.pow(2, shift); + shift += 7; + } while (b >= MSB$1); + read.bytes = counter - offset; + return res; +} +var N1 = Math.pow(2, 7); +var N2 = Math.pow(2, 14); +var N3 = Math.pow(2, 21); +var N4 = Math.pow(2, 28); +var N5 = Math.pow(2, 35); +var N6 = Math.pow(2, 42); +var N7 = Math.pow(2, 49); +var N8 = Math.pow(2, 56); +var N9 = Math.pow(2, 63); +var length = function (value) { + return value < N1 ? 1 : value < N2 ? 2 : value < N3 ? 3 : value < N4 ? 4 : value < N5 ? 5 : value < N6 ? 6 : value < N7 ? 7 : value < N8 ? 8 : value < N9 ? 9 : 10; +}; +var varint = { + encode: encode_1, + decode: decode, + encodingLength: length +}; +var _brrp_varint = varint; +var varint$1 = _brrp_varint; + +module.exports = varint$1; + + +/***/ }), + +/***/ 76994: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; +// @ts-check + +const { Buffer } = __webpack_require__(20181) + +/** + * @typedef {Object} Codec + * @property {function(Uint8Array):string} encode + * @property {function(string):Uint8Array} decode + * + * @typedef {function(string):Codec} CodecFactory + */ + +class Base { + /** + * @param {string} name + * @param {string} code + * @param {CodecFactory} implementation + * @param {string} alphabet + */ + constructor (name, code, implementation, alphabet) { + this.name = name + this.code = code + this.codeBuf = Buffer.from(this.code) + this.alphabet = alphabet + this.engine = implementation(alphabet) + } + + /** + * @param {Uint8Array} buf + * @returns {string} + */ + encode (buf) { + return this.engine.encode(buf) + } + + /** + * @param {string} string + * @returns {Uint8Array} + */ + decode (string) { + for (const char of string) { + if (this.alphabet && this.alphabet.indexOf(char) < 0) { + throw new Error(`invalid character '${char}' in '${string}'`) + } + } + return this.engine.decode(string) + } +} + +module.exports = Base + + +/***/ }), + +/***/ 46082: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; +// @ts-check + + +const baseX = __webpack_require__(95364) +const Base = __webpack_require__(76994) +const rfc4648 = __webpack_require__(15920) +const { decodeText, encodeText } = __webpack_require__(40639) + +const identity = () => { + return { + encode: decodeText, + decode: encodeText + } +} + +/** + * @typedef {import('./base').CodecFactory} CodecFactory + * + * name, code, implementation, alphabet + * @type {Array<[string, string, CodecFactory, string]>} + */ +const constants = [ + ['identity', '\x00', identity, ''], + ['base2', '0', rfc4648(1), '01'], + ['base8', '7', rfc4648(3), '01234567'], + ['base10', '9', baseX, '0123456789'], + ['base16', 'f', rfc4648(4), '0123456789abcdef'], + ['base16upper', 'F', rfc4648(4), '0123456789ABCDEF'], + ['base32hex', 'v', rfc4648(5), '0123456789abcdefghijklmnopqrstuv'], + ['base32hexupper', 'V', rfc4648(5), '0123456789ABCDEFGHIJKLMNOPQRSTUV'], + ['base32hexpad', 't', rfc4648(5), '0123456789abcdefghijklmnopqrstuv='], + ['base32hexpadupper', 'T', rfc4648(5), '0123456789ABCDEFGHIJKLMNOPQRSTUV='], + ['base32', 'b', rfc4648(5), 'abcdefghijklmnopqrstuvwxyz234567'], + ['base32upper', 'B', rfc4648(5), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'], + ['base32pad', 'c', rfc4648(5), 'abcdefghijklmnopqrstuvwxyz234567='], + ['base32padupper', 'C', rfc4648(5), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567='], + ['base32z', 'h', rfc4648(5), 'ybndrfg8ejkmcpqxot1uwisza345h769'], + ['base36', 'k', baseX, '0123456789abcdefghijklmnopqrstuvwxyz'], + ['base36upper', 'K', baseX, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'], + ['base58btc', 'z', baseX, '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'], + ['base58flickr', 'Z', baseX, '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'], + ['base64', 'm', rfc4648(6), 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'], + ['base64pad', 'M', rfc4648(6), 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='], + ['base64url', 'u', rfc4648(6), 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'], + ['base64urlpad', 'U', rfc4648(6), 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_='] +] + +const names = constants.reduce((prev, tupple) => { + prev[tupple[0]] = new Base(tupple[0], tupple[1], tupple[2], tupple[3]) + return prev +}, {}) + +const codes = constants.reduce((prev, tupple) => { + prev[tupple[1]] = names[tupple[0]] + return prev +}, {}) + +module.exports = { + names, + codes +} + + +/***/ }), + +/***/ 42879: +/***/ ((module, exports, __webpack_require__) => { + +"use strict"; +// @ts-check +/** + * Implementation of the [multibase](https://github.com/multiformats/multibase) specification. + * + * @module Multibase + */ + + +const { Buffer } = __webpack_require__(20181) +const constants = __webpack_require__(46082) +const { decodeText, asBuffer } = __webpack_require__(40639) + +/** @typedef {import("./base")} Base */ + +/** + * Create a new buffer with the multibase varint+code. + * + * @param {string|number} nameOrCode - The multibase name or code number. + * @param {Uint8Array} buf - The data to be prefixed with multibase. + * @returns {Buffer} + * @throws {Error} Will throw if the encoding is not supported + */ +function multibase (nameOrCode, buf) { + if (!buf) { + throw new Error('requires an encoded buffer') + } + const { name, codeBuf } = encoding(nameOrCode) + validEncode(name, buf) + + const buffer = Buffer.alloc(codeBuf.length + buf.length) + buffer.set(codeBuf, 0) + buffer.set(buf, codeBuf.length) + + return buffer +} + +/** + * Encode data with the specified base and add the multibase prefix. + * + * @param {string|number} nameOrCode - The multibase name or code number. + * @param {Uint8Array} buf - The data to be encoded. + * @returns {Buffer} + * @throws {Error} Will throw if the encoding is not supported + * + */ +function encode (nameOrCode, buf) { + const enc = encoding(nameOrCode) + + return Buffer.concat([enc.codeBuf, Buffer.from(enc.encode(buf))]) +} + +/** + * Takes a Uint8Array or string encoded with multibase header, decodes it and + * returns the decoded buffer + * + * @param {Uint8Array|string} data + * @returns {Buffer} + * @throws {Error} Will throw if the encoding is not supported + * + */ +function decode (data) { + if (ArrayBuffer.isView(data)) { + data = decodeText(data) + } + const prefix = data[0] + + // Make all encodings case-insensitive except the ones that include upper and lower chars in the alphabet + if (['f', 'F', 'v', 'V', 't', 'T', 'b', 'B', 'c', 'C', 'h', 'k', 'K'].includes(prefix)) { + data = data.toLowerCase() + } + const enc = encoding(data[0]) + return asBuffer(enc.decode(data.substring(1))) +} + +/** + * Is the given data multibase encoded? + * + * @param {Uint8Array|string} data + * @returns {false|string} + */ +function isEncoded (data) { + if (data instanceof Uint8Array) { + data = decodeText(data) + } + + // Ensure bufOrString is a string + if (Object.prototype.toString.call(data) !== '[object String]') { + return false + } + + try { + const enc = encoding(data[0]) + return enc.name + } catch (err) { + return false + } +} + +/** + * Validate encoded data + * + * @param {string} name + * @param {Uint8Array} buf + * @returns {void} + * @throws {Error} Will throw if the encoding is not supported + */ +function validEncode (name, buf) { + const enc = encoding(name) + enc.decode(decodeText(buf)) +} + +/** + * Get the encoding by name or code + * + * @param {string|number} nameOrCode + * @returns {Base} + * @throws {Error} Will throw if the encoding is not supported + */ +function encoding (nameOrCode) { + if (constants.names[nameOrCode]) { + return constants.names[nameOrCode] + } else if (constants.codes[nameOrCode]) { + return constants.codes[nameOrCode] + } else { + throw new Error(`Unsupported encoding: ${nameOrCode}`) + } +} + +/** + * Get encoding from data + * + * @param {string|Uint8Array} data + * @returns {Base} + * @throws {Error} Will throw if the encoding is not supported + */ +function encodingFromData (data) { + if (data instanceof Uint8Array) { + data = decodeText(data) + } + + return encoding(data[0]) +} + +exports = module.exports = multibase +exports.encode = encode +exports.decode = decode +exports.isEncoded = isEncoded +exports.encoding = encoding +exports.encodingFromData = encodingFromData +exports.names = Object.freeze(constants.names) +exports.codes = Object.freeze(constants.codes) + + +/***/ }), + +/***/ 15920: +/***/ ((module) => { + +"use strict"; +// @ts-check + + +/** @typedef {import('./base').CodecFactory} CodecFactory */ + +/** + * @param {string} string + * @param {string} alphabet + * @param {number} bitsPerChar + * @returns {Uint8Array} + */ +const decode = (string, alphabet, bitsPerChar) => { + // Build the character lookup table: + const codes = {} + for (let i = 0; i < alphabet.length; ++i) { + codes[alphabet[i]] = i + } + + // Count the padding bytes: + let end = string.length + while (string[end - 1] === '=') { + --end + } + + // Allocate the output: + const out = new Uint8Array((end * bitsPerChar / 8) | 0) + + // Parse the data: + let bits = 0 // Number of bits currently in the buffer + let buffer = 0 // Bits waiting to be written out, MSB first + let written = 0 // Next byte to write + for (let i = 0; i < end; ++i) { + // Read one character from the string: + const value = codes[string[i]] + if (value === undefined) { + throw new SyntaxError('Invalid character ' + string[i]) + } + + // Append the bits to the buffer: + buffer = (buffer << bitsPerChar) | value + bits += bitsPerChar + + // Write out some bits if the buffer has a byte's worth: + if (bits >= 8) { + bits -= 8 + out[written++] = 0xff & (buffer >> bits) + } + } + + // Verify that we have received just enough bits: + if (bits >= bitsPerChar || 0xff & (buffer << (8 - bits))) { + throw new SyntaxError('Unexpected end of data') + } + + return out +} + +/** + * @param {Uint8Array} data + * @param {string} alphabet + * @param {number} bitsPerChar + * @returns {string} + */ +const encode = (data, alphabet, bitsPerChar) => { + const pad = alphabet[alphabet.length - 1] === '=' + const mask = (1 << bitsPerChar) - 1 + let out = '' + + let bits = 0 // Number of bits currently in the buffer + let buffer = 0 // Bits waiting to be written out, MSB first + for (let i = 0; i < data.length; ++i) { + // Slurp data into the buffer: + buffer = (buffer << 8) | data[i] + bits += 8 + + // Write out as much as we can: + while (bits > bitsPerChar) { + bits -= bitsPerChar + out += alphabet[mask & (buffer >> bits)] + } + } + + // Partial character: + if (bits) { + out += alphabet[mask & (buffer << (bitsPerChar - bits))] + } + + // Add padding characters until we hit a byte boundary: + if (pad) { + while ((out.length * bitsPerChar) & 7) { + out += '=' + } + } + + return out +} + +/** + * @param {number} bitsPerChar + * @returns {CodecFactory} + */ +module.exports = (bitsPerChar) => (alphabet) => { + return { + /** + * @param {Uint8Array} input + * @returns {string} + */ + encode (input) { + return encode(input, alphabet, bitsPerChar) + }, + /** + * @param {string} input + * @returns {Uint8Array} + */ + decode (input) { + return decode(input, alphabet, bitsPerChar) + } + } +} + + +/***/ }), + +/***/ 40639: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; +// @ts-check + + +const { Buffer } = __webpack_require__(20181) +const { TextEncoder, TextDecoder } = __webpack_require__(67019) + +const textDecoder = new TextDecoder() +/** + * @param {ArrayBufferView|ArrayBuffer} bytes + * @returns {string} + */ +const decodeText = (bytes) => textDecoder.decode(bytes) + +const textEncoder = new TextEncoder() +/** + * @param {string} text + * @returns {Uint8Array} + */ +const encodeText = (text) => textEncoder.encode(text) + +/** + * @param {ArrayBufferView} bytes + * @returns {Buffer} + */ +const asBuffer = ({ buffer, byteLength, byteOffset }) => + Buffer.from(buffer, byteOffset, byteLength) + +module.exports = { decodeText, encodeText, asBuffer } + + +/***/ }), + +/***/ 53702: +/***/ ((module) => { + +"use strict"; +/* eslint quote-props: off */ + + +const names = Object.freeze({ + 'identity': 0x00, + 'sha1': 0x11, + 'sha2-256': 0x12, + 'sha2-512': 0x13, + 'sha3-512': 0x14, + 'sha3-384': 0x15, + 'sha3-256': 0x16, + 'sha3-224': 0x17, + 'shake-128': 0x18, + 'shake-256': 0x19, + 'keccak-224': 0x1a, + 'keccak-256': 0x1b, + 'keccak-384': 0x1c, + 'keccak-512': 0x1d, + 'blake3': 0x1e, + 'murmur3-128': 0x22, + 'murmur3-32': 0x23, + 'dbl-sha2-256': 0x56, + 'md4': 0xd4, + 'md5': 0xd5, + 'bmt': 0xd6, + 'sha2-256-trunc254-padded': 0x1012, + 'ripemd-128': 0x1052, + 'ripemd-160': 0x1053, + 'ripemd-256': 0x1054, + 'ripemd-320': 0x1055, + 'x11': 0x1100, + 'sm3-256': 0x534d, + 'blake2b-8': 0xb201, + 'blake2b-16': 0xb202, + 'blake2b-24': 0xb203, + 'blake2b-32': 0xb204, + 'blake2b-40': 0xb205, + 'blake2b-48': 0xb206, + 'blake2b-56': 0xb207, + 'blake2b-64': 0xb208, + 'blake2b-72': 0xb209, + 'blake2b-80': 0xb20a, + 'blake2b-88': 0xb20b, + 'blake2b-96': 0xb20c, + 'blake2b-104': 0xb20d, + 'blake2b-112': 0xb20e, + 'blake2b-120': 0xb20f, + 'blake2b-128': 0xb210, + 'blake2b-136': 0xb211, + 'blake2b-144': 0xb212, + 'blake2b-152': 0xb213, + 'blake2b-160': 0xb214, + 'blake2b-168': 0xb215, + 'blake2b-176': 0xb216, + 'blake2b-184': 0xb217, + 'blake2b-192': 0xb218, + 'blake2b-200': 0xb219, + 'blake2b-208': 0xb21a, + 'blake2b-216': 0xb21b, + 'blake2b-224': 0xb21c, + 'blake2b-232': 0xb21d, + 'blake2b-240': 0xb21e, + 'blake2b-248': 0xb21f, + 'blake2b-256': 0xb220, + 'blake2b-264': 0xb221, + 'blake2b-272': 0xb222, + 'blake2b-280': 0xb223, + 'blake2b-288': 0xb224, + 'blake2b-296': 0xb225, + 'blake2b-304': 0xb226, + 'blake2b-312': 0xb227, + 'blake2b-320': 0xb228, + 'blake2b-328': 0xb229, + 'blake2b-336': 0xb22a, + 'blake2b-344': 0xb22b, + 'blake2b-352': 0xb22c, + 'blake2b-360': 0xb22d, + 'blake2b-368': 0xb22e, + 'blake2b-376': 0xb22f, + 'blake2b-384': 0xb230, + 'blake2b-392': 0xb231, + 'blake2b-400': 0xb232, + 'blake2b-408': 0xb233, + 'blake2b-416': 0xb234, + 'blake2b-424': 0xb235, + 'blake2b-432': 0xb236, + 'blake2b-440': 0xb237, + 'blake2b-448': 0xb238, + 'blake2b-456': 0xb239, + 'blake2b-464': 0xb23a, + 'blake2b-472': 0xb23b, + 'blake2b-480': 0xb23c, + 'blake2b-488': 0xb23d, + 'blake2b-496': 0xb23e, + 'blake2b-504': 0xb23f, + 'blake2b-512': 0xb240, + 'blake2s-8': 0xb241, + 'blake2s-16': 0xb242, + 'blake2s-24': 0xb243, + 'blake2s-32': 0xb244, + 'blake2s-40': 0xb245, + 'blake2s-48': 0xb246, + 'blake2s-56': 0xb247, + 'blake2s-64': 0xb248, + 'blake2s-72': 0xb249, + 'blake2s-80': 0xb24a, + 'blake2s-88': 0xb24b, + 'blake2s-96': 0xb24c, + 'blake2s-104': 0xb24d, + 'blake2s-112': 0xb24e, + 'blake2s-120': 0xb24f, + 'blake2s-128': 0xb250, + 'blake2s-136': 0xb251, + 'blake2s-144': 0xb252, + 'blake2s-152': 0xb253, + 'blake2s-160': 0xb254, + 'blake2s-168': 0xb255, + 'blake2s-176': 0xb256, + 'blake2s-184': 0xb257, + 'blake2s-192': 0xb258, + 'blake2s-200': 0xb259, + 'blake2s-208': 0xb25a, + 'blake2s-216': 0xb25b, + 'blake2s-224': 0xb25c, + 'blake2s-232': 0xb25d, + 'blake2s-240': 0xb25e, + 'blake2s-248': 0xb25f, + 'blake2s-256': 0xb260, + 'skein256-8': 0xb301, + 'skein256-16': 0xb302, + 'skein256-24': 0xb303, + 'skein256-32': 0xb304, + 'skein256-40': 0xb305, + 'skein256-48': 0xb306, + 'skein256-56': 0xb307, + 'skein256-64': 0xb308, + 'skein256-72': 0xb309, + 'skein256-80': 0xb30a, + 'skein256-88': 0xb30b, + 'skein256-96': 0xb30c, + 'skein256-104': 0xb30d, + 'skein256-112': 0xb30e, + 'skein256-120': 0xb30f, + 'skein256-128': 0xb310, + 'skein256-136': 0xb311, + 'skein256-144': 0xb312, + 'skein256-152': 0xb313, + 'skein256-160': 0xb314, + 'skein256-168': 0xb315, + 'skein256-176': 0xb316, + 'skein256-184': 0xb317, + 'skein256-192': 0xb318, + 'skein256-200': 0xb319, + 'skein256-208': 0xb31a, + 'skein256-216': 0xb31b, + 'skein256-224': 0xb31c, + 'skein256-232': 0xb31d, + 'skein256-240': 0xb31e, + 'skein256-248': 0xb31f, + 'skein256-256': 0xb320, + 'skein512-8': 0xb321, + 'skein512-16': 0xb322, + 'skein512-24': 0xb323, + 'skein512-32': 0xb324, + 'skein512-40': 0xb325, + 'skein512-48': 0xb326, + 'skein512-56': 0xb327, + 'skein512-64': 0xb328, + 'skein512-72': 0xb329, + 'skein512-80': 0xb32a, + 'skein512-88': 0xb32b, + 'skein512-96': 0xb32c, + 'skein512-104': 0xb32d, + 'skein512-112': 0xb32e, + 'skein512-120': 0xb32f, + 'skein512-128': 0xb330, + 'skein512-136': 0xb331, + 'skein512-144': 0xb332, + 'skein512-152': 0xb333, + 'skein512-160': 0xb334, + 'skein512-168': 0xb335, + 'skein512-176': 0xb336, + 'skein512-184': 0xb337, + 'skein512-192': 0xb338, + 'skein512-200': 0xb339, + 'skein512-208': 0xb33a, + 'skein512-216': 0xb33b, + 'skein512-224': 0xb33c, + 'skein512-232': 0xb33d, + 'skein512-240': 0xb33e, + 'skein512-248': 0xb33f, + 'skein512-256': 0xb340, + 'skein512-264': 0xb341, + 'skein512-272': 0xb342, + 'skein512-280': 0xb343, + 'skein512-288': 0xb344, + 'skein512-296': 0xb345, + 'skein512-304': 0xb346, + 'skein512-312': 0xb347, + 'skein512-320': 0xb348, + 'skein512-328': 0xb349, + 'skein512-336': 0xb34a, + 'skein512-344': 0xb34b, + 'skein512-352': 0xb34c, + 'skein512-360': 0xb34d, + 'skein512-368': 0xb34e, + 'skein512-376': 0xb34f, + 'skein512-384': 0xb350, + 'skein512-392': 0xb351, + 'skein512-400': 0xb352, + 'skein512-408': 0xb353, + 'skein512-416': 0xb354, + 'skein512-424': 0xb355, + 'skein512-432': 0xb356, + 'skein512-440': 0xb357, + 'skein512-448': 0xb358, + 'skein512-456': 0xb359, + 'skein512-464': 0xb35a, + 'skein512-472': 0xb35b, + 'skein512-480': 0xb35c, + 'skein512-488': 0xb35d, + 'skein512-496': 0xb35e, + 'skein512-504': 0xb35f, + 'skein512-512': 0xb360, + 'skein1024-8': 0xb361, + 'skein1024-16': 0xb362, + 'skein1024-24': 0xb363, + 'skein1024-32': 0xb364, + 'skein1024-40': 0xb365, + 'skein1024-48': 0xb366, + 'skein1024-56': 0xb367, + 'skein1024-64': 0xb368, + 'skein1024-72': 0xb369, + 'skein1024-80': 0xb36a, + 'skein1024-88': 0xb36b, + 'skein1024-96': 0xb36c, + 'skein1024-104': 0xb36d, + 'skein1024-112': 0xb36e, + 'skein1024-120': 0xb36f, + 'skein1024-128': 0xb370, + 'skein1024-136': 0xb371, + 'skein1024-144': 0xb372, + 'skein1024-152': 0xb373, + 'skein1024-160': 0xb374, + 'skein1024-168': 0xb375, + 'skein1024-176': 0xb376, + 'skein1024-184': 0xb377, + 'skein1024-192': 0xb378, + 'skein1024-200': 0xb379, + 'skein1024-208': 0xb37a, + 'skein1024-216': 0xb37b, + 'skein1024-224': 0xb37c, + 'skein1024-232': 0xb37d, + 'skein1024-240': 0xb37e, + 'skein1024-248': 0xb37f, + 'skein1024-256': 0xb380, + 'skein1024-264': 0xb381, + 'skein1024-272': 0xb382, + 'skein1024-280': 0xb383, + 'skein1024-288': 0xb384, + 'skein1024-296': 0xb385, + 'skein1024-304': 0xb386, + 'skein1024-312': 0xb387, + 'skein1024-320': 0xb388, + 'skein1024-328': 0xb389, + 'skein1024-336': 0xb38a, + 'skein1024-344': 0xb38b, + 'skein1024-352': 0xb38c, + 'skein1024-360': 0xb38d, + 'skein1024-368': 0xb38e, + 'skein1024-376': 0xb38f, + 'skein1024-384': 0xb390, + 'skein1024-392': 0xb391, + 'skein1024-400': 0xb392, + 'skein1024-408': 0xb393, + 'skein1024-416': 0xb394, + 'skein1024-424': 0xb395, + 'skein1024-432': 0xb396, + 'skein1024-440': 0xb397, + 'skein1024-448': 0xb398, + 'skein1024-456': 0xb399, + 'skein1024-464': 0xb39a, + 'skein1024-472': 0xb39b, + 'skein1024-480': 0xb39c, + 'skein1024-488': 0xb39d, + 'skein1024-496': 0xb39e, + 'skein1024-504': 0xb39f, + 'skein1024-512': 0xb3a0, + 'skein1024-520': 0xb3a1, + 'skein1024-528': 0xb3a2, + 'skein1024-536': 0xb3a3, + 'skein1024-544': 0xb3a4, + 'skein1024-552': 0xb3a5, + 'skein1024-560': 0xb3a6, + 'skein1024-568': 0xb3a7, + 'skein1024-576': 0xb3a8, + 'skein1024-584': 0xb3a9, + 'skein1024-592': 0xb3aa, + 'skein1024-600': 0xb3ab, + 'skein1024-608': 0xb3ac, + 'skein1024-616': 0xb3ad, + 'skein1024-624': 0xb3ae, + 'skein1024-632': 0xb3af, + 'skein1024-640': 0xb3b0, + 'skein1024-648': 0xb3b1, + 'skein1024-656': 0xb3b2, + 'skein1024-664': 0xb3b3, + 'skein1024-672': 0xb3b4, + 'skein1024-680': 0xb3b5, + 'skein1024-688': 0xb3b6, + 'skein1024-696': 0xb3b7, + 'skein1024-704': 0xb3b8, + 'skein1024-712': 0xb3b9, + 'skein1024-720': 0xb3ba, + 'skein1024-728': 0xb3bb, + 'skein1024-736': 0xb3bc, + 'skein1024-744': 0xb3bd, + 'skein1024-752': 0xb3be, + 'skein1024-760': 0xb3bf, + 'skein1024-768': 0xb3c0, + 'skein1024-776': 0xb3c1, + 'skein1024-784': 0xb3c2, + 'skein1024-792': 0xb3c3, + 'skein1024-800': 0xb3c4, + 'skein1024-808': 0xb3c5, + 'skein1024-816': 0xb3c6, + 'skein1024-824': 0xb3c7, + 'skein1024-832': 0xb3c8, + 'skein1024-840': 0xb3c9, + 'skein1024-848': 0xb3ca, + 'skein1024-856': 0xb3cb, + 'skein1024-864': 0xb3cc, + 'skein1024-872': 0xb3cd, + 'skein1024-880': 0xb3ce, + 'skein1024-888': 0xb3cf, + 'skein1024-896': 0xb3d0, + 'skein1024-904': 0xb3d1, + 'skein1024-912': 0xb3d2, + 'skein1024-920': 0xb3d3, + 'skein1024-928': 0xb3d4, + 'skein1024-936': 0xb3d5, + 'skein1024-944': 0xb3d6, + 'skein1024-952': 0xb3d7, + 'skein1024-960': 0xb3d8, + 'skein1024-968': 0xb3d9, + 'skein1024-976': 0xb3da, + 'skein1024-984': 0xb3db, + 'skein1024-992': 0xb3dc, + 'skein1024-1000': 0xb3dd, + 'skein1024-1008': 0xb3de, + 'skein1024-1016': 0xb3df, + 'skein1024-1024': 0xb3e0, + 'poseidon-bls12_381-a2-fc1': 0xb401, + 'poseidon-bls12_381-a2-fc1-sc': 0xb402 +}) + +module.exports = { names } + + +/***/ }), + +/***/ 14243: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; +// @ts-check +/* eslint-disable guard-for-in */ +/** + * Multihash implementation in JavaScript. + * + * @module multihash + */ + + +const { Buffer } = __webpack_require__(20181) +const multibase = __webpack_require__(42879) +const varint = __webpack_require__(61203) +const { names } = __webpack_require__(53702) +const { TextDecoder } = __webpack_require__(67019) + +const textDecoder = new TextDecoder() +const codes = {} + +for (const key in names) { + codes[names[key]] = key +} +exports.names = names +exports.codes = Object.freeze(codes) + +/** + * Convert the given multihash to a hex encoded string. + * + * @param {Uint8Array} hash + * @returns {string} + */ +exports.toHexString = function toHexString (hash) { + if (!(hash instanceof Uint8Array)) { + throw new Error('must be passed a Uint8Array') + } + + const buffer = Buffer.isBuffer(hash) + ? hash + : Buffer.from(hash.buffer, hash.byteOffset, hash.byteLength) + + return buffer.toString('hex') +} + +/** + * Convert the given hex encoded string to a multihash. + * + * @param {string} hash + * @returns {Buffer} + */ +exports.fromHexString = function fromHexString (hash) { + return Buffer.from(hash, 'hex') +} + +/** + * Convert the given multihash to a base58 encoded string. + * + * @param {Uint8Array} hash + * @returns {string} + */ +exports.toB58String = function toB58String (hash) { + if (!(hash instanceof Uint8Array)) { + throw new Error('must be passed a Uint8Array') + } + + return textDecoder.decode(multibase.encode('base58btc', hash)).slice(1) +} + +/** + * Convert the given base58 encoded string to a multihash. + * + * @param {string|Uint8Array} hash + * @returns {Buffer} + */ +exports.fromB58String = function fromB58String (hash) { + const encoded = hash instanceof Uint8Array + ? textDecoder.decode(hash) + : hash + + return multibase.decode('z' + encoded) +} + +/** + * Decode a hash from the given multihash. + * + * @param {Uint8Array} bytes + * @returns {{code: number, name: string, length: number, digest: Buffer}} result + */ +exports.decode = function decode (bytes) { + if (!(bytes instanceof Uint8Array)) { + throw new Error('multihash must be a Uint8Array') + } + let buf = Buffer.isBuffer(bytes) + ? bytes + : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength) + + if (buf.length < 2) { + throw new Error('multihash too short. must be > 2 bytes.') + } + + const code = varint.decode(buf) + if (!exports.isValidCode(code)) { + throw new Error(`multihash unknown function code: 0x${code.toString(16)}`) + } + buf = buf.slice(varint.decode.bytes) + + const len = varint.decode(buf) + if (len < 0) { + throw new Error(`multihash invalid length: ${len}`) + } + buf = buf.slice(varint.decode.bytes) + + if (buf.length !== len) { + throw new Error(`multihash length inconsistent: 0x${buf.toString('hex')}`) + } + + return { + code, + name: codes[code], + length: len, + digest: buf + } +} + +/** + * Encode a hash digest along with the specified function code. + * + * > **Note:** the length is derived from the length of the digest itself. + * + * @param {Uint8Array} digest + * @param {string|number} code + * @param {number} [length] + * @returns {Buffer} + */ +exports.encode = function encode (digest, code, length) { + if (!digest || code === undefined) { + throw new Error('multihash encode requires at least two args: digest, code') + } + + // ensure it's a hashfunction code. + const hashfn = exports.coerceCode(code) + + if (!(digest instanceof Uint8Array)) { + throw new Error('digest should be a Uint8Array') + } + + if (length == null) { + length = digest.length + } + + if (length && digest.length !== length) { + throw new Error('digest length should be equal to specified length.') + } + + const hash = varint.encode(hashfn) + const len = varint.encode(length) + const buffer = Buffer.alloc(hash.length + len.length + digest.length) + buffer.set(hash, 0) + buffer.set(len, hash.length) + buffer.set(digest, hash.length + len.length) + return buffer +} + +/** + * Converts a hash function name into the matching code. + * If passed a number it will return the number if it's a valid code. + * @param {string|number} name + * @returns {number} + */ +exports.coerceCode = function coerceCode (name) { + let code = name + + if (typeof name === 'string') { + if (names[name] === undefined) { + throw new Error(`Unrecognized hash function named: ${name}`) + } + code = names[name] + } + + if (typeof code !== 'number') { + throw new Error(`Hash function code should be a number. Got: ${code}`) + } + + if (codes[code] === undefined && !exports.isAppCode(code)) { + throw new Error(`Unrecognized function code: ${code}`) + } + + return code +} + +/** + * Checks wether a code is part of the app range + * + * @param {number} code + * @returns {boolean} + */ +exports.isAppCode = function appCode (code) { + return code > 0 && code < 0x10 +} + +/** + * Checks whether a multihash code is valid. + * + * @param {number} code + * @returns {boolean} + */ +exports.isValidCode = function validCode (code) { + if (exports.isAppCode(code)) { + return true + } + + if (codes[code]) { + return true + } + + return false +} + +/** + * Check if the given buffer is a valid multihash. Throws an error if it is not valid. + * + * @param {Uint8Array} multihash + * @returns {void} + * @throws {Error} + */ +function validate (multihash) { + exports.decode(multihash) // throws if bad. +} +exports.validate = validate + +/** + * Returns a prefix from a valid multihash. Throws an error if it is not valid. + * + * @param {Uint8Array} multihash + * @returns {Buffer} + * @throws {Error} + */ +exports.prefix = function prefix (multihash) { + validate(multihash) + + return Buffer.from(multihash.buffer, multihash.byteOffset, 2) +} + + /***/ }), /***/ 86889: @@ -75121,6 +81008,222 @@ nacl.setPRNG = function(fn) { })( true && module.exports ? module.exports : (self.nacl = self.nacl || {})); +/***/ }), + +/***/ 74240: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var asUint8array = __webpack_require__(25900); + +function alloc(size = 0) { + if (globalThis.Buffer != null && globalThis.Buffer.alloc != null) { + return asUint8array.asUint8Array(globalThis.Buffer.alloc(size)); + } + return new Uint8Array(size); +} +function allocUnsafe(size = 0) { + if (globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null) { + return asUint8array.asUint8Array(globalThis.Buffer.allocUnsafe(size)); + } + return new Uint8Array(size); +} + +exports.alloc = alloc; +exports.allocUnsafe = allocUnsafe; + + +/***/ }), + +/***/ 61045: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var alloc = __webpack_require__(74240); +var asUint8array = __webpack_require__(25900); + +function concat(arrays, length) { + if (!length) { + length = arrays.reduce((acc, curr) => acc + curr.length, 0); + } + const output = alloc.allocUnsafe(length); + let offset = 0; + for (const arr of arrays) { + output.set(arr, offset); + offset += arr.length; + } + return asUint8array.asUint8Array(output); +} + +exports.concat = concat; + + +/***/ }), + +/***/ 27980: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +function equals(a, b) { + if (a === b) { + return true; + } + if (a.byteLength !== b.byteLength) { + return false; + } + for (let i = 0; i < a.byteLength; i++) { + if (a[i] !== b[i]) { + return false; + } + } + return true; +} + +exports.equals = equals; + + +/***/ }), + +/***/ 35195: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var bases = __webpack_require__(39116); +var asUint8array = __webpack_require__(25900); + +function fromString(string, encoding = 'utf8') { + const base = bases[encoding]; + if (!base) { + throw new Error(`Unsupported encoding "${ encoding }"`); + } + if ((encoding === 'utf8' || encoding === 'utf-8') && globalThis.Buffer != null && globalThis.Buffer.from != null) { + return asUint8array.asUint8Array(globalThis.Buffer.from(string, 'utf-8')); + } + return base.decoder.decode(`${ base.prefix }${ string }`); +} + +exports.fromString = fromString; + + +/***/ }), + +/***/ 9804: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var bases = __webpack_require__(39116); + +function toString(array, encoding = 'utf8') { + const base = bases[encoding]; + if (!base) { + throw new Error(`Unsupported encoding "${ encoding }"`); + } + if ((encoding === 'utf8' || encoding === 'utf-8') && globalThis.Buffer != null && globalThis.Buffer.from != null) { + return globalThis.Buffer.from(array.buffer, array.byteOffset, array.byteLength).toString('utf8'); + } + return base.encoder.encode(array).substring(1); +} + +exports.toString = toString; + + +/***/ }), + +/***/ 25900: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +function asUint8Array(buf) { + if (globalThis.Buffer != null) { + return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength); + } + return buf; +} + +exports.asUint8Array = asUint8Array; + + +/***/ }), + +/***/ 39116: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var basics = __webpack_require__(62399); +var alloc = __webpack_require__(74240); + +function createCodec(name, prefix, encode, decode) { + return { + name, + prefix, + encoder: { + name, + prefix, + encode + }, + decoder: { decode } + }; +} +const string = createCodec('utf8', 'u', buf => { + const decoder = new TextDecoder('utf8'); + return 'u' + decoder.decode(buf); +}, str => { + const encoder = new TextEncoder(); + return encoder.encode(str.substring(1)); +}); +const ascii = createCodec('ascii', 'a', buf => { + let string = 'a'; + for (let i = 0; i < buf.length; i++) { + string += String.fromCharCode(buf[i]); + } + return string; +}, str => { + str = str.substring(1); + const buf = alloc.allocUnsafe(str.length); + for (let i = 0; i < str.length; i++) { + buf[i] = str.charCodeAt(i); + } + return buf; +}); +const BASES = { + utf8: string, + 'utf-8': string, + hex: basics.bases.base16, + latin1: ascii, + ascii: ascii, + binary: ascii, + ...basics.bases +}; + +module.exports = BASES; + + /***/ }), /***/ 27983: @@ -75134,6 +81237,134 @@ nacl.setPRNG = function(fn) { module.exports = __webpack_require__(39023).deprecate; +/***/ }), + +/***/ 26797: +/***/ ((module) => { + +module.exports = read + +var MSB = 0x80 + , REST = 0x7F + +function read(buf, offset) { + var res = 0 + , offset = offset || 0 + , shift = 0 + , counter = offset + , b + , l = buf.length + + do { + if (counter >= l) { + read.bytes = 0 + throw new RangeError('Could not decode varint') + } + b = buf[counter++] + res += shift < 28 + ? (b & REST) << shift + : (b & REST) * Math.pow(2, shift) + shift += 7 + } while (b >= MSB) + + read.bytes = counter - offset + + return res +} + + +/***/ }), + +/***/ 81877: +/***/ ((module) => { + +module.exports = encode + +var MSB = 0x80 + , REST = 0x7F + , MSBALL = ~REST + , INT = Math.pow(2, 31) + +function encode(num, out, offset) { + out = out || [] + offset = offset || 0 + var oldOffset = offset + + while(num >= INT) { + out[offset++] = (num & 0xFF) | MSB + num /= 128 + } + while(num & MSBALL) { + out[offset++] = (num & 0xFF) | MSB + num >>>= 7 + } + out[offset] = num | 0 + + encode.bytes = offset - oldOffset + 1 + + return out +} + + +/***/ }), + +/***/ 61203: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +module.exports = { + encode: __webpack_require__(81877) + , decode: __webpack_require__(26797) + , encodingLength: __webpack_require__(37867) +} + + +/***/ }), + +/***/ 37867: +/***/ ((module) => { + + +var N1 = Math.pow(2, 7) +var N2 = Math.pow(2, 14) +var N3 = Math.pow(2, 21) +var N4 = Math.pow(2, 28) +var N5 = Math.pow(2, 35) +var N6 = Math.pow(2, 42) +var N7 = Math.pow(2, 49) +var N8 = Math.pow(2, 56) +var N9 = Math.pow(2, 63) + +module.exports = function (value) { + return ( + value < N1 ? 1 + : value < N2 ? 2 + : value < N3 ? 3 + : value < N4 ? 4 + : value < N5 ? 5 + : value < N6 ? 6 + : value < N7 ? 7 + : value < N8 ? 8 + : value < N9 ? 9 + : 10 + ) +} + + +/***/ }), + +/***/ 67019: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +exports.TextEncoder = + typeof TextEncoder !== "undefined" ? TextEncoder : (__webpack_require__(39023).TextEncoder) + +exports.TextDecoder = + typeof TextDecoder !== "undefined" ? TextDecoder : (__webpack_require__(39023).TextDecoder) + + /***/ }), /***/ 85616: @@ -143056,10 +149287,12 @@ class BrowserProvider extends JsonRpcApiPollingProvider { } } //# sourceMappingURL=provider-browser.js.map -// EXTERNAL MODULE: ./node_modules/cross-fetch/dist/node-ponyfill.js -var node_ponyfill = __webpack_require__(15221); // EXTERNAL MODULE: ./node_modules/bn.js/lib/bn.js var bn = __webpack_require__(39404); +// EXTERNAL MODULE: ./node_modules/@ensdomains/content-hash/src/index.js +var src = __webpack_require__(81810); +// EXTERNAL MODULE: ./node_modules/cross-fetch/dist/node-ponyfill.js +var node_ponyfill = __webpack_require__(15221); // EXTERNAL MODULE: ./node_modules/@tornado/core/node_modules/ajv/dist/ajv.js var ajv = __webpack_require__(43337); ;// external "module" @@ -181664,6 +187897,8 @@ var groth16 = __webpack_require__(36336); + + BigInt.prototype.toJSON = function() { return this.toString(); }; @@ -181775,9 +188010,265 @@ function numberFormatter(num, digits = 3) { function isHex(value) { return /^0x[0-9a-fA-F]*$/.test(value); } +function toContentHash(ipfsUrl) { + return contentHashUtils.fromIpfs(ipfsUrl); +} +function fromContentHash(contentHash) { + return contentHashUtils.decode(contentHash); +} -const defaultUserAgent = "Mozilla/5.0 (Windows NT 10.0; rv:109.0) Gecko/20100101 Firefox/115.0"; -const cli_fetch = node_ponyfill; +class BatchBlockService { + provider; + onProgress; + concurrencySize; + batchSize; + shouldRetry; + retryMax; + retryOn; + constructor({ + provider, + onProgress, + concurrencySize = 10, + batchSize = 10, + shouldRetry = true, + retryMax = 5, + retryOn = 500 + }) { + this.provider = provider; + this.onProgress = onProgress; + this.concurrencySize = concurrencySize; + this.batchSize = batchSize; + this.shouldRetry = shouldRetry; + this.retryMax = retryMax; + this.retryOn = retryOn; + } + async getBlock(blockTag) { + const blockObject = await this.provider.getBlock(blockTag); + if (!blockObject) { + const errMsg = `No block for ${blockTag}`; + throw new Error(errMsg); + } + return blockObject; + } + createBatchRequest(batchArray) { + return batchArray.map(async (blocks, index) => { + await dist_sleep(40 * index); + return (async () => { + let retries = 0; + let err; + while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) { + try { + return await Promise.all(blocks.map((b) => this.getBlock(b))); + } catch (e) { + retries++; + err = e; + await dist_sleep(this.retryOn); + } + } + throw err; + })(); + }); + } + async getBatchBlocks(blocks) { + let blockCount = 0; + const results = []; + for (const chunks of chunk(blocks, this.concurrencySize * this.batchSize)) { + const chunksResult = (await Promise.all(this.createBatchRequest(chunk(chunks, this.batchSize)))).flat(); + results.push(...chunksResult); + blockCount += chunks.length; + if (typeof this.onProgress === "function") { + this.onProgress({ + percentage: blockCount / blocks.length, + currentIndex: blockCount, + totalIndex: blocks.length + }); + } + } + return results; + } +} +class BatchTransactionService { + provider; + onProgress; + concurrencySize; + batchSize; + shouldRetry; + retryMax; + retryOn; + constructor({ + provider, + onProgress, + concurrencySize = 10, + batchSize = 10, + shouldRetry = true, + retryMax = 5, + retryOn = 500 + }) { + this.provider = provider; + this.onProgress = onProgress; + this.concurrencySize = concurrencySize; + this.batchSize = batchSize; + this.shouldRetry = shouldRetry; + this.retryMax = retryMax; + this.retryOn = retryOn; + } + async getTransaction(txHash) { + const txObject = await this.provider.getTransaction(txHash); + if (!txObject) { + const errMsg = `No transaction for ${txHash}`; + throw new Error(errMsg); + } + return txObject; + } + async getTransactionReceipt(txHash) { + const txObject = await this.provider.getTransactionReceipt(txHash); + if (!txObject) { + const errMsg = `No transaction receipt for ${txHash}`; + throw new Error(errMsg); + } + return txObject; + } + createBatchRequest(batchArray, receipt) { + return batchArray.map(async (txs, index) => { + await dist_sleep(40 * index); + return (async () => { + let retries = 0; + let err; + while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) { + try { + if (!receipt) { + return await Promise.all(txs.map((tx) => this.getTransaction(tx))); + } else { + return await Promise.all(txs.map((tx) => this.getTransactionReceipt(tx))); + } + } catch (e) { + retries++; + err = e; + await dist_sleep(this.retryOn); + } + } + throw err; + })(); + }); + } + async getBatchTransactions(txs) { + let txCount = 0; + const results = []; + for (const chunks of chunk(txs, this.concurrencySize * this.batchSize)) { + const chunksResult = (await Promise.all(this.createBatchRequest(chunk(chunks, this.batchSize)))).flat(); + results.push(...chunksResult); + txCount += chunks.length; + if (typeof this.onProgress === "function") { + this.onProgress({ + percentage: txCount / txs.length, + currentIndex: txCount, + totalIndex: txs.length + }); + } + } + return results; + } + async getBatchReceipt(txs) { + let txCount = 0; + const results = []; + for (const chunks of chunk(txs, this.concurrencySize * this.batchSize)) { + const chunksResult = (await Promise.all(this.createBatchRequest(chunk(chunks, this.batchSize), true))).flat(); + results.push(...chunksResult); + txCount += chunks.length; + if (typeof this.onProgress === "function") { + this.onProgress({ + percentage: txCount / txs.length, + currentIndex: txCount, + totalIndex: txs.length + }); + } + } + return results; + } +} +class BatchEventsService { + provider; + contract; + onProgress; + concurrencySize; + blocksPerRequest; + shouldRetry; + retryMax; + retryOn; + constructor({ + provider, + contract, + onProgress, + concurrencySize = 10, + blocksPerRequest = 5e3, + shouldRetry = true, + retryMax = 5, + retryOn = 500 + }) { + this.provider = provider; + this.contract = contract; + this.onProgress = onProgress; + this.concurrencySize = concurrencySize; + this.blocksPerRequest = blocksPerRequest; + this.shouldRetry = shouldRetry; + this.retryMax = retryMax; + this.retryOn = retryOn; + } + async getPastEvents({ fromBlock, toBlock, type }) { + let err; + let retries = 0; + while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) { + try { + return await this.contract.queryFilter(type, fromBlock, toBlock); + } catch (e) { + err = e; + retries++; + if (e.message.includes("after last accepted block")) { + const acceptedBlock = parseInt(e.message.split("after last accepted block ")[1]); + toBlock = acceptedBlock; + } + await dist_sleep(this.retryOn); + } + } + throw err; + } + createBatchRequest(batchArray) { + return batchArray.map(async (event, index) => { + await dist_sleep(10 * index); + return this.getPastEvents(event); + }); + } + async getBatchEvents({ fromBlock, toBlock, type = "*" }) { + if (!toBlock) { + toBlock = await this.provider.getBlockNumber(); + } + const eventsToSync = []; + for (let i = fromBlock; i < toBlock; i += this.blocksPerRequest) { + const j = i + this.blocksPerRequest - 1 > toBlock ? toBlock : i + this.blocksPerRequest - 1; + eventsToSync.push({ fromBlock: i, toBlock: j, type }); + } + const events = []; + const eventChunk = chunk(eventsToSync, this.concurrencySize); + let chunkCount = 0; + for (const chunk2 of eventChunk) { + chunkCount++; + const fetchedEvents = (await Promise.all(this.createBatchRequest(chunk2))).flat(); + events.push(...fetchedEvents); + if (typeof this.onProgress === "function") { + this.onProgress({ + percentage: chunkCount / eventChunk.length, + type, + fromBlock: chunk2[0].fromBlock, + toBlock: chunk2[chunk2.length - 1].toBlock, + count: fetchedEvents.length + }); + } + } + return events; + } +} + +const defaultUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0"; function getHttpAgent({ fetchUrl, proxyUrl, @@ -181808,6 +188299,7 @@ async function fetchData(url, options = {}) { const MAX_RETRY = options.maxRetry ?? 3; const RETRY_ON = options.retryOn ?? 500; const userAgent = options.userAgent ?? defaultUserAgent; + const fetch = globalThis.useGlobalFetch ? globalThis.fetch : node_ponyfill; let retry = 0; let errorObject; if (!options.method) { @@ -181831,6 +188323,14 @@ async function fetchData(url, options = {}) { timeout = setTimeout(() => { controller.abort(); }, options.timeout); + if (options.cancelSignal) { + if (options.cancelSignal.cancelled) { + throw new Error("request cancelled before sending"); + } + options.cancelSignal.addListener(() => { + controller.abort(); + }); + } } if (!options.agent && isNode && (options.proxy || options.torPort)) { options.agent = getHttpAgent({ @@ -181849,7 +188349,7 @@ async function fetchData(url, options = {}) { }); } try { - const resp = await cli_fetch(url, { + const resp = await fetch(url, { method: options.method, headers: options.headers, body: options.body, @@ -181895,20 +188395,13 @@ async function fetchData(url, options = {}) { throw errorObject; } const fetchGetUrlFunc = (options = {}) => async (req, _signal) => { - let signal; - if (_signal) { - const controller = new AbortController(); - signal = controller.signal; - _signal.addListener(() => { - controller.abort(); - }); - } const init = { ...options, method: req.method || "POST", headers: req.headers, body: req.body || void 0, - signal, + timeout: options.timeout || req.timeout, + cancelSignal: _signal, returnResponse: true }; const resp = await fetchData(req.url, init); @@ -182086,1213 +188579,6 @@ class TornadoBrowserProvider extends BrowserProvider { } } -const GET_STATISTIC = ` - query getStatistic($currency: String!, $amount: String!, $first: Int, $orderBy: BigInt, $orderDirection: String) { - deposits(first: $first, orderBy: $orderBy, orderDirection: $orderDirection, where: { currency: $currency, amount: $amount }) { - index - timestamp - blockNumber - } - _meta { - block { - number - } - hasIndexingErrors - } - } -`; -const _META = ` - query getMeta { - _meta { - block { - number - } - hasIndexingErrors - } - } -`; -const GET_REGISTERED = ` - query getRegistered($first: Int, $fromBlock: Int) { - relayers(first: $first, orderBy: blockRegistration, orderDirection: asc, where: { - blockRegistration_gte: $fromBlock - }) { - id - address - ensName - blockRegistration - } - _meta { - block { - number - } - hasIndexingErrors - } - } -`; -const GET_DEPOSITS = ` - query getDeposits($currency: String!, $amount: String!, $first: Int, $fromBlock: Int) { - deposits(first: $first, orderBy: index, orderDirection: asc, where: { - amount: $amount, - currency: $currency, - blockNumber_gte: $fromBlock - }) { - id - blockNumber - commitment - index - timestamp - from - } - _meta { - block { - number - } - hasIndexingErrors - } - } -`; -const GET_WITHDRAWALS = ` - query getWithdrawals($currency: String!, $amount: String!, $first: Int, $fromBlock: Int!) { - withdrawals(first: $first, orderBy: blockNumber, orderDirection: asc, where: { - currency: $currency, - amount: $amount, - blockNumber_gte: $fromBlock - }) { - id - blockNumber - nullifier - to - fee - timestamp - } - _meta { - block { - number - } - hasIndexingErrors - } - } -`; -const GET_NOTE_ACCOUNTS = ` - query getNoteAccount($address: String!) { - noteAccounts(where: { address: $address }) { - id - index - address - encryptedAccount - } - _meta { - block { - number - } - hasIndexingErrors - } - } -`; -const GET_ECHO_EVENTS = ` - query getNoteAccounts($first: Int, $fromBlock: Int) { - noteAccounts(first: $first, orderBy: blockNumber, orderDirection: asc, where: { blockNumber_gte: $fromBlock }) { - id - blockNumber - address - encryptedAccount - } - _meta { - block { - number - } - hasIndexingErrors - } - } -`; -const GET_ENCRYPTED_NOTES = ` - query getEncryptedNotes($first: Int, $fromBlock: Int) { - encryptedNotes(first: $first, orderBy: blockNumber, orderDirection: asc, where: { blockNumber_gte: $fromBlock }) { - blockNumber - index - transactionHash - encryptedNote - } - _meta { - block { - number - } - hasIndexingErrors - } - } -`; -const GET_GOVERNANCE_EVENTS = ` - query getGovernanceEvents($first: Int, $fromBlock: Int) { - proposals(first: $first, orderBy: blockNumber, orderDirection: asc, where: { blockNumber_gte: $fromBlock }) { - blockNumber - logIndex - transactionHash - proposalId - proposer - target - startTime - endTime - description - } - votes(first: $first, orderBy: blockNumber, orderDirection: asc, where: { blockNumber_gte: $fromBlock }) { - blockNumber - logIndex - transactionHash - proposalId - voter - support - votes - from - input - } - delegates(first: $first, orderBy: blockNumber, orderDirection: asc, where: { blockNumber_gte: $fromBlock }) { - blockNumber - logIndex - transactionHash - account - delegateTo - } - undelegates(first: $first, orderBy: blockNumber, orderDirection: asc, where: { blockNumber_gte: $fromBlock }) { - blockNumber - logIndex - transactionHash - account - delegateFrom - } - _meta { - block { - number - } - hasIndexingErrors - } - } -`; -const GET_GOVERNANCE_APY = ` - stakeDailyBurns(first: 30, orderBy: date, orderDirection: desc) { - id - date - dailyAmountBurned - } -`; - -const isEmptyArray = (arr) => !Array.isArray(arr) || !arr.length; -const GRAPHQL_LIMIT = 1e3; -async function queryGraph({ - graphApi, - subgraphName, - query, - variables, - fetchDataOptions: fetchDataOptions2 -}) { - const graphUrl = `${graphApi}/subgraphs/name/${subgraphName}`; - const { data, errors } = await fetchData(graphUrl, { - ...fetchDataOptions2, - method: "POST", - headers: { - "Content-Type": "application/json" - }, - body: JSON.stringify({ - query, - variables - }) - }); - if (errors) { - throw new Error(JSON.stringify(errors)); - } - if (data?._meta?.hasIndexingErrors) { - throw new Error("Subgraph has indexing errors"); - } - return data; -} -async function getStatistic({ - graphApi, - subgraphName, - currency, - amount, - fetchDataOptions: fetchDataOptions2 -}) { - try { - const { - deposits, - _meta: { - block: { number: lastSyncBlock } - } - } = await queryGraph({ - graphApi, - subgraphName, - query: GET_STATISTIC, - variables: { - currency, - first: 10, - orderBy: "index", - orderDirection: "desc", - amount - }, - fetchDataOptions: fetchDataOptions2 - }); - const events = deposits.map((e) => ({ - timestamp: Number(e.timestamp), - leafIndex: Number(e.index), - blockNumber: Number(e.blockNumber) - })).reverse(); - const [lastEvent] = events.slice(-1); - return { - events, - lastSyncBlock: lastEvent && lastEvent.blockNumber >= lastSyncBlock ? lastEvent.blockNumber + 1 : lastSyncBlock - }; - } catch (err) { - console.log("Error from getStatistic query"); - console.log(err); - return { - events: [], - lastSyncBlock: null - }; - } -} -async function getMeta({ graphApi, subgraphName, fetchDataOptions: fetchDataOptions2 }) { - try { - const { - _meta: { - block: { number: lastSyncBlock }, - hasIndexingErrors - } - } = await queryGraph({ - graphApi, - subgraphName, - query: _META, - fetchDataOptions: fetchDataOptions2 - }); - return { - lastSyncBlock, - hasIndexingErrors - }; - } catch (err) { - console.log("Error from getMeta query"); - console.log(err); - return { - lastSyncBlock: null, - hasIndexingErrors: null - }; - } -} -function getRegisters({ - graphApi, - subgraphName, - fromBlock, - fetchDataOptions: fetchDataOptions2 -}) { - return queryGraph({ - graphApi, - subgraphName, - query: GET_REGISTERED, - variables: { - first: GRAPHQL_LIMIT, - fromBlock - }, - fetchDataOptions: fetchDataOptions2 - }); -} -async function getAllRegisters({ - graphApi, - subgraphName, - fromBlock, - fetchDataOptions: fetchDataOptions2, - onProgress -}) { - try { - const events = []; - let lastSyncBlock = fromBlock; - while (true) { - let { - relayers: result2, - _meta: { - // eslint-disable-next-line prefer-const - block: { number: currentBlock } - } - } = await getRegisters({ - graphApi, - subgraphName, - fromBlock, - fetchDataOptions: fetchDataOptions2 - }); - lastSyncBlock = currentBlock; - if (isEmptyArray(result2)) { - break; - } - const [firstEvent] = result2; - const [lastEvent] = result2.slice(-1); - if (typeof onProgress === "function") { - onProgress({ - type: "Registers", - fromBlock: Number(firstEvent.blockRegistration), - toBlock: Number(lastEvent.blockRegistration), - count: result2.length - }); - } - if (result2.length < 900) { - events.push(...result2); - break; - } - result2 = result2.filter(({ blockRegistration }) => blockRegistration !== lastEvent.blockRegistration); - fromBlock = Number(lastEvent.blockRegistration); - events.push(...result2); - } - if (!events.length) { - return { - events: [], - lastSyncBlock - }; - } - const result = events.map(({ id, address, ensName, blockRegistration }) => { - const [transactionHash, logIndex] = id.split("-"); - return { - blockNumber: Number(blockRegistration), - logIndex: Number(logIndex), - transactionHash, - ensName, - relayerAddress: address_getAddress(address) - }; - }); - return { - events: result, - lastSyncBlock - }; - } catch (err) { - console.log("Error from getAllRegisters query"); - console.log(err); - return { events: [], lastSyncBlock: fromBlock }; - } -} -function getDeposits({ - graphApi, - subgraphName, - currency, - amount, - fromBlock, - fetchDataOptions: fetchDataOptions2 -}) { - return queryGraph({ - graphApi, - subgraphName, - query: GET_DEPOSITS, - variables: { - currency, - amount, - first: GRAPHQL_LIMIT, - fromBlock - }, - fetchDataOptions: fetchDataOptions2 - }); -} -async function getAllDeposits({ - graphApi, - subgraphName, - currency, - amount, - fromBlock, - fetchDataOptions: fetchDataOptions2, - onProgress -}) { - try { - const events = []; - let lastSyncBlock = fromBlock; - while (true) { - let { - deposits: result2, - _meta: { - // eslint-disable-next-line prefer-const - block: { number: currentBlock } - } - } = await getDeposits({ - graphApi, - subgraphName, - currency, - amount, - fromBlock, - fetchDataOptions: fetchDataOptions2 - }); - lastSyncBlock = currentBlock; - if (isEmptyArray(result2)) { - break; - } - const [firstEvent] = result2; - const [lastEvent2] = result2.slice(-1); - if (typeof onProgress === "function") { - onProgress({ - type: "Deposits", - fromBlock: Number(firstEvent.blockNumber), - toBlock: Number(lastEvent2.blockNumber), - count: result2.length - }); - } - if (result2.length < 900) { - events.push(...result2); - break; - } - result2 = result2.filter(({ blockNumber }) => blockNumber !== lastEvent2.blockNumber); - fromBlock = Number(lastEvent2.blockNumber); - events.push(...result2); - } - if (!events.length) { - return { - events: [], - lastSyncBlock - }; - } - const result = events.map(({ id, blockNumber, commitment, index, timestamp, from }) => { - const [transactionHash, logIndex] = id.split("-"); - return { - blockNumber: Number(blockNumber), - logIndex: Number(logIndex), - transactionHash, - commitment, - leafIndex: Number(index), - timestamp: Number(timestamp), - from: address_getAddress(from) - }; - }); - const [lastEvent] = result.slice(-1); - return { - events: result, - lastSyncBlock: lastEvent && lastEvent.blockNumber >= lastSyncBlock ? lastEvent.blockNumber + 1 : lastSyncBlock - }; - } catch (err) { - console.log("Error from getAllDeposits query"); - console.log(err); - return { - events: [], - lastSyncBlock: fromBlock - }; - } -} -function getWithdrawals({ - graphApi, - subgraphName, - currency, - amount, - fromBlock, - fetchDataOptions: fetchDataOptions2 -}) { - return queryGraph({ - graphApi, - subgraphName, - query: GET_WITHDRAWALS, - variables: { - currency, - amount, - first: GRAPHQL_LIMIT, - fromBlock - }, - fetchDataOptions: fetchDataOptions2 - }); -} -async function getAllWithdrawals({ - graphApi, - subgraphName, - currency, - amount, - fromBlock, - fetchDataOptions: fetchDataOptions2, - onProgress -}) { - try { - const events = []; - let lastSyncBlock = fromBlock; - while (true) { - let { - withdrawals: result2, - _meta: { - // eslint-disable-next-line prefer-const - block: { number: currentBlock } - } - } = await getWithdrawals({ - graphApi, - subgraphName, - currency, - amount, - fromBlock, - fetchDataOptions: fetchDataOptions2 - }); - lastSyncBlock = currentBlock; - if (isEmptyArray(result2)) { - break; - } - const [firstEvent] = result2; - const [lastEvent2] = result2.slice(-1); - if (typeof onProgress === "function") { - onProgress({ - type: "Withdrawals", - fromBlock: Number(firstEvent.blockNumber), - toBlock: Number(lastEvent2.blockNumber), - count: result2.length - }); - } - if (result2.length < 900) { - events.push(...result2); - break; - } - result2 = result2.filter(({ blockNumber }) => blockNumber !== lastEvent2.blockNumber); - fromBlock = Number(lastEvent2.blockNumber); - events.push(...result2); - } - if (!events.length) { - return { - events: [], - lastSyncBlock - }; - } - const result = events.map(({ id, blockNumber, nullifier, to, fee, timestamp }) => { - const [transactionHash, logIndex] = id.split("-"); - return { - blockNumber: Number(blockNumber), - logIndex: Number(logIndex), - transactionHash, - nullifierHash: nullifier, - to: address_getAddress(to), - fee, - timestamp: Number(timestamp) - }; - }); - const [lastEvent] = result.slice(-1); - return { - events: result, - lastSyncBlock: lastEvent && lastEvent.blockNumber >= lastSyncBlock ? lastEvent.blockNumber + 1 : lastSyncBlock - }; - } catch (err) { - console.log("Error from getAllWithdrawals query"); - console.log(err); - return { - events: [], - lastSyncBlock: fromBlock - }; - } -} -async function getNoteAccounts({ - graphApi, - subgraphName, - address, - fetchDataOptions: fetchDataOptions2 -}) { - try { - const { - noteAccounts: events, - _meta: { - block: { number: lastSyncBlock } - } - } = await queryGraph({ - graphApi, - subgraphName, - query: GET_NOTE_ACCOUNTS, - variables: { - address: address.toLowerCase() - }, - fetchDataOptions: fetchDataOptions2 - }); - return { - events, - lastSyncBlock - }; - } catch (err) { - console.log("Error from getNoteAccounts query"); - console.log(err); - return { - events: [], - lastSyncBlock: null - }; - } -} -function getGraphEchoEvents({ - graphApi, - subgraphName, - fromBlock, - fetchDataOptions: fetchDataOptions2 -}) { - return queryGraph({ - graphApi, - subgraphName, - query: GET_ECHO_EVENTS, - variables: { - first: GRAPHQL_LIMIT, - fromBlock - }, - fetchDataOptions: fetchDataOptions2 - }); -} -async function getAllGraphEchoEvents({ - graphApi, - subgraphName, - fromBlock, - fetchDataOptions: fetchDataOptions2, - onProgress -}) { - try { - const events = []; - let lastSyncBlock = fromBlock; - while (true) { - let { - noteAccounts: result2, - _meta: { - // eslint-disable-next-line prefer-const - block: { number: currentBlock } - } - } = await getGraphEchoEvents({ - graphApi, - subgraphName, - fromBlock, - fetchDataOptions: fetchDataOptions2 - }); - lastSyncBlock = currentBlock; - if (isEmptyArray(result2)) { - break; - } - const [firstEvent] = result2; - const [lastEvent2] = result2.slice(-1); - if (typeof onProgress === "function") { - onProgress({ - type: "EchoEvents", - fromBlock: Number(firstEvent.blockNumber), - toBlock: Number(lastEvent2.blockNumber), - count: result2.length - }); - } - if (result2.length < 900) { - events.push(...result2); - break; - } - result2 = result2.filter(({ blockNumber }) => blockNumber !== lastEvent2.blockNumber); - fromBlock = Number(lastEvent2.blockNumber); - events.push(...result2); - } - if (!events.length) { - return { - events: [], - lastSyncBlock - }; - } - const result = events.map((e) => { - const [transactionHash, logIndex] = e.id.split("-"); - return { - blockNumber: Number(e.blockNumber), - logIndex: Number(logIndex), - transactionHash, - address: address_getAddress(e.address), - encryptedAccount: e.encryptedAccount - }; - }); - const [lastEvent] = result.slice(-1); - return { - events: result, - lastSyncBlock: lastEvent && lastEvent.blockNumber >= lastSyncBlock ? lastEvent.blockNumber + 1 : lastSyncBlock - }; - } catch (err) { - console.log("Error from getAllGraphEchoEvents query"); - console.log(err); - return { - events: [], - lastSyncBlock: fromBlock - }; - } -} -function getEncryptedNotes({ - graphApi, - subgraphName, - fromBlock, - fetchDataOptions: fetchDataOptions2 -}) { - return queryGraph({ - graphApi, - subgraphName, - query: GET_ENCRYPTED_NOTES, - variables: { - first: GRAPHQL_LIMIT, - fromBlock - }, - fetchDataOptions: fetchDataOptions2 - }); -} -async function getAllEncryptedNotes({ - graphApi, - subgraphName, - fromBlock, - fetchDataOptions: fetchDataOptions2, - onProgress -}) { - try { - const events = []; - let lastSyncBlock = fromBlock; - while (true) { - let { - encryptedNotes: result2, - _meta: { - // eslint-disable-next-line prefer-const - block: { number: currentBlock } - } - } = await getEncryptedNotes({ - graphApi, - subgraphName, - fromBlock, - fetchDataOptions: fetchDataOptions2 - }); - lastSyncBlock = currentBlock; - if (isEmptyArray(result2)) { - break; - } - const [firstEvent] = result2; - const [lastEvent2] = result2.slice(-1); - if (typeof onProgress === "function") { - onProgress({ - type: "EncryptedNotes", - fromBlock: Number(firstEvent.blockNumber), - toBlock: Number(lastEvent2.blockNumber), - count: result2.length - }); - } - if (result2.length < 900) { - events.push(...result2); - break; - } - result2 = result2.filter(({ blockNumber }) => blockNumber !== lastEvent2.blockNumber); - fromBlock = Number(lastEvent2.blockNumber); - events.push(...result2); - } - if (!events.length) { - return { - events: [], - lastSyncBlock - }; - } - const result = events.map((e) => ({ - blockNumber: Number(e.blockNumber), - logIndex: Number(e.index), - transactionHash: e.transactionHash, - encryptedNote: e.encryptedNote - })); - const [lastEvent] = result.slice(-1); - return { - events: result, - lastSyncBlock: lastEvent && lastEvent.blockNumber >= lastSyncBlock ? lastEvent.blockNumber + 1 : lastSyncBlock - }; - } catch (err) { - console.log("Error from getAllEncryptedNotes query"); - console.log(err); - return { - events: [], - lastSyncBlock: fromBlock - }; - } -} -function getGovernanceEvents({ - graphApi, - subgraphName, - fromBlock, - fetchDataOptions: fetchDataOptions2 -}) { - return queryGraph({ - graphApi, - subgraphName, - query: GET_GOVERNANCE_EVENTS, - variables: { - first: GRAPHQL_LIMIT, - fromBlock - }, - fetchDataOptions: fetchDataOptions2 - }); -} -async function getAllGovernanceEvents({ - graphApi, - subgraphName, - fromBlock, - fetchDataOptions: fetchDataOptions2, - onProgress -}) { - try { - const result = []; - let lastSyncBlock = fromBlock; - while (true) { - const { - proposals, - votes, - delegates, - undelegates, - _meta: { - block: { number: currentBlock } - } - } = await getGovernanceEvents({ - graphApi, - subgraphName, - fromBlock, - fetchDataOptions: fetchDataOptions2 - }); - lastSyncBlock = currentBlock; - const eventsLength = proposals.length + votes.length + delegates.length + undelegates.length; - if (eventsLength === 0) { - break; - } - const formattedProposals = proposals.map( - ({ - blockNumber, - logIndex, - transactionHash, - proposalId, - proposer, - target, - startTime, - endTime, - description - }) => { - return { - blockNumber: Number(blockNumber), - logIndex: Number(logIndex), - transactionHash, - event: "ProposalCreated", - id: Number(proposalId), - proposer: address_getAddress(proposer), - target: address_getAddress(target), - startTime: Number(startTime), - endTime: Number(endTime), - description - }; - } - ); - const formattedVotes = votes.map( - ({ blockNumber, logIndex, transactionHash, proposalId, voter, support, votes: votes2, from, input }) => { - if (!input || input.length > 2048) { - input = ""; - } - return { - blockNumber: Number(blockNumber), - logIndex: Number(logIndex), - transactionHash, - event: "Voted", - proposalId: Number(proposalId), - voter: address_getAddress(voter), - support, - votes: votes2, - from: address_getAddress(from), - input - }; - } - ); - const formattedDelegates = delegates.map( - ({ blockNumber, logIndex, transactionHash, account, delegateTo }) => { - return { - blockNumber: Number(blockNumber), - logIndex: Number(logIndex), - transactionHash, - event: "Delegated", - account: address_getAddress(account), - delegateTo: address_getAddress(delegateTo) - }; - } - ); - const formattedUndelegates = undelegates.map( - ({ blockNumber, logIndex, transactionHash, account, delegateFrom }) => { - return { - blockNumber: Number(blockNumber), - logIndex: Number(logIndex), - transactionHash, - event: "Undelegated", - account: address_getAddress(account), - delegateFrom: address_getAddress(delegateFrom) - }; - } - ); - let formattedEvents = [ - ...formattedProposals, - ...formattedVotes, - ...formattedDelegates, - ...formattedUndelegates - ].sort((a, b) => { - if (a.blockNumber === b.blockNumber) { - return a.logIndex - b.logIndex; - } - return a.blockNumber - b.blockNumber; - }); - if (eventsLength < 900) { - result.push(...formattedEvents); - break; - } - const [firstEvent] = formattedEvents; - const [lastEvent2] = formattedEvents.slice(-1); - if (typeof onProgress === "function") { - onProgress({ - type: "Governance Events", - fromBlock: Number(firstEvent.blockNumber), - toBlock: Number(lastEvent2.blockNumber), - count: eventsLength - }); - } - formattedEvents = formattedEvents.filter(({ blockNumber }) => blockNumber !== lastEvent2.blockNumber); - fromBlock = Number(lastEvent2.blockNumber); - result.push(...formattedEvents); - } - const [lastEvent] = result.slice(-1); - return { - events: result, - lastSyncBlock: lastEvent && lastEvent.blockNumber >= lastSyncBlock ? lastEvent.blockNumber + 1 : lastSyncBlock - }; - } catch (err) { - console.log("Error from getAllGovernance query"); - console.log(err); - return { - events: [], - lastSyncBlock: fromBlock - }; - } -} - -var graph = /*#__PURE__*/Object.freeze({ - __proto__: null, - GET_DEPOSITS: GET_DEPOSITS, - GET_ECHO_EVENTS: GET_ECHO_EVENTS, - GET_ENCRYPTED_NOTES: GET_ENCRYPTED_NOTES, - GET_GOVERNANCE_APY: GET_GOVERNANCE_APY, - GET_GOVERNANCE_EVENTS: GET_GOVERNANCE_EVENTS, - GET_NOTE_ACCOUNTS: GET_NOTE_ACCOUNTS, - GET_REGISTERED: GET_REGISTERED, - GET_STATISTIC: GET_STATISTIC, - GET_WITHDRAWALS: GET_WITHDRAWALS, - _META: _META, - getAllDeposits: getAllDeposits, - getAllEncryptedNotes: getAllEncryptedNotes, - getAllGovernanceEvents: getAllGovernanceEvents, - getAllGraphEchoEvents: getAllGraphEchoEvents, - getAllRegisters: getAllRegisters, - getAllWithdrawals: getAllWithdrawals, - getDeposits: getDeposits, - getEncryptedNotes: getEncryptedNotes, - getGovernanceEvents: getGovernanceEvents, - getGraphEchoEvents: getGraphEchoEvents, - getMeta: getMeta, - getNoteAccounts: getNoteAccounts, - getRegisters: getRegisters, - getStatistic: getStatistic, - getWithdrawals: getWithdrawals, - queryGraph: queryGraph -}); - -class BatchBlockService { - provider; - onProgress; - concurrencySize; - batchSize; - shouldRetry; - retryMax; - retryOn; - constructor({ - provider, - onProgress, - concurrencySize = 10, - batchSize = 10, - shouldRetry = true, - retryMax = 5, - retryOn = 500 - }) { - this.provider = provider; - this.onProgress = onProgress; - this.concurrencySize = concurrencySize; - this.batchSize = batchSize; - this.shouldRetry = shouldRetry; - this.retryMax = retryMax; - this.retryOn = retryOn; - } - async getBlock(blockTag) { - const blockObject = await this.provider.getBlock(blockTag); - if (!blockObject) { - const errMsg = `No block for ${blockTag}`; - throw new Error(errMsg); - } - return blockObject; - } - createBatchRequest(batchArray) { - return batchArray.map(async (blocks, index) => { - await dist_sleep(20 * index); - return (async () => { - let retries = 0; - let err; - while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) { - try { - return await Promise.all(blocks.map((b) => this.getBlock(b))); - } catch (e) { - retries++; - err = e; - await dist_sleep(this.retryOn); - } - } - throw err; - })(); - }); - } - async getBatchBlocks(blocks) { - let blockCount = 0; - const results = []; - for (const chunks of chunk(blocks, this.concurrencySize * this.batchSize)) { - const chunksResult = (await Promise.all(this.createBatchRequest(chunk(chunks, this.batchSize)))).flat(); - results.push(...chunksResult); - blockCount += chunks.length; - if (typeof this.onProgress === "function") { - this.onProgress({ - percentage: blockCount / blocks.length, - currentIndex: blockCount, - totalIndex: blocks.length - }); - } - } - return results; - } -} -class BatchTransactionService { - provider; - onProgress; - concurrencySize; - batchSize; - shouldRetry; - retryMax; - retryOn; - constructor({ - provider, - onProgress, - concurrencySize = 10, - batchSize = 10, - shouldRetry = true, - retryMax = 5, - retryOn = 500 - }) { - this.provider = provider; - this.onProgress = onProgress; - this.concurrencySize = concurrencySize; - this.batchSize = batchSize; - this.shouldRetry = shouldRetry; - this.retryMax = retryMax; - this.retryOn = retryOn; - } - async getTransaction(txHash) { - const txObject = await this.provider.getTransaction(txHash); - if (!txObject) { - const errMsg = `No transaction for ${txHash}`; - throw new Error(errMsg); - } - return txObject; - } - createBatchRequest(batchArray) { - return batchArray.map(async (txs, index) => { - await dist_sleep(20 * index); - return (async () => { - let retries = 0; - let err; - while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) { - try { - return await Promise.all(txs.map((tx) => this.getTransaction(tx))); - } catch (e) { - retries++; - err = e; - await dist_sleep(this.retryOn); - } - } - throw err; - })(); - }); - } - async getBatchTransactions(txs) { - let txCount = 0; - const results = []; - for (const chunks of chunk(txs, this.concurrencySize * this.batchSize)) { - const chunksResult = (await Promise.all(this.createBatchRequest(chunk(chunks, this.batchSize)))).flat(); - results.push(...chunksResult); - txCount += chunks.length; - if (typeof this.onProgress === "function") { - this.onProgress({ - percentage: txCount / txs.length, - currentIndex: txCount, - totalIndex: txs.length - }); - } - } - return results; - } -} -class BatchEventsService { - provider; - contract; - onProgress; - concurrencySize; - blocksPerRequest; - shouldRetry; - retryMax; - retryOn; - constructor({ - provider, - contract, - onProgress, - concurrencySize = 10, - blocksPerRequest = 2e3, - shouldRetry = true, - retryMax = 5, - retryOn = 500 - }) { - this.provider = provider; - this.contract = contract; - this.onProgress = onProgress; - this.concurrencySize = concurrencySize; - this.blocksPerRequest = blocksPerRequest; - this.shouldRetry = shouldRetry; - this.retryMax = retryMax; - this.retryOn = retryOn; - } - async getPastEvents({ fromBlock, toBlock, type }) { - let err; - let retries = 0; - while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) { - try { - return await this.contract.queryFilter(type, fromBlock, toBlock); - } catch (e) { - err = e; - retries++; - if (e.message.includes("after last accepted block")) { - const acceptedBlock = parseInt(e.message.split("after last accepted block ")[1]); - toBlock = acceptedBlock; - } - await dist_sleep(this.retryOn); - } - } - throw err; - } - createBatchRequest(batchArray) { - return batchArray.map(async (event, index) => { - await dist_sleep(20 * index); - return this.getPastEvents(event); - }); - } - async getBatchEvents({ fromBlock, toBlock, type = "*" }) { - if (!toBlock) { - toBlock = await this.provider.getBlockNumber(); - } - const eventsToSync = []; - for (let i = fromBlock; i < toBlock; i += this.blocksPerRequest) { - const j = i + this.blocksPerRequest - 1 > toBlock ? toBlock : i + this.blocksPerRequest - 1; - eventsToSync.push({ fromBlock: i, toBlock: j, type }); - } - const events = []; - const eventChunk = chunk(eventsToSync, this.concurrencySize); - let chunkCount = 0; - for (const chunk2 of eventChunk) { - chunkCount++; - const fetchedEvents = (await Promise.all(this.createBatchRequest(chunk2))).flat(); - events.push(...fetchedEvents); - if (typeof this.onProgress === "function") { - this.onProgress({ - percentage: chunkCount / eventChunk.length, - type, - fromBlock: chunk2[0].fromBlock, - toBlock: chunk2[chunk2.length - 1].toBlock, - count: fetchedEvents.length - }); - } - } - return events; - } -} - var NetId = /* @__PURE__ */ ((NetId2) => { NetId2[NetId2["MAINNET"] = 1] = "MAINNET"; NetId2[NetId2["BSC"] = 56] = "BSC"; @@ -183322,11 +188608,11 @@ const defaultConfig = { deployedBlock: 9116966, rpcUrls: { mevblockerRPC: { - name: "MevblockerRPC", + name: "MEV Blocker", url: "https://rpc.mevblocker.io" }, keydonix: { - name: "keydonix", + name: "Horswap ( Keydonix )", url: "https://ethereum.keydonix.com/v1/mainnet" }, SecureRpc: { @@ -183334,7 +188620,7 @@ const defaultConfig = { url: "https://api.securerpc.com/v1" }, stackup: { - name: "Stackup RPC", + name: "Stackup", url: "https://public.stackup.sh/api/v1/node/ethereum-mainnet" }, oneRpc: { @@ -183469,7 +188755,7 @@ const defaultConfig = { url: "https://bsc-dataseed.bnbchain.org" }, ninicoin: { - name: "ninicoin", + name: "BNB Chain 2", url: "https://bsc-dataseed1.ninicoin.io" }, nodereal: { @@ -183477,7 +188763,7 @@ const defaultConfig = { url: "https://binance.nodereal.io" }, stackup: { - name: "Stackup RPC", + name: "Stackup", url: "https://public.stackup.sh/api/v1/node/bsc-mainnet" }, oneRpc: { @@ -183532,7 +188818,7 @@ const defaultConfig = { url: "https://1rpc.io/matic" }, stackup: { - name: "Stackup RPC", + name: "Stackup", url: "https://public.stackup.sh/api/v1/node/polygon-mainnet" } }, @@ -183584,7 +188870,7 @@ const defaultConfig = { url: "https://1rpc.io/op" }, stackup: { - name: "Stackup RPC", + name: "Stackup", url: "https://public.stackup.sh/api/v1/node/optimism-mainnet" } }, @@ -183631,11 +188917,11 @@ const defaultConfig = { subgraphs: {}, rpcUrls: { Arbitrum: { - name: "Arbitrum RPC", + name: "Arbitrum", url: "https://arb1.arbitrum.io/rpc" }, stackup: { - name: "Stackup RPC", + name: "Stackup", url: "https://public.stackup.sh/api/v1/node/arbitrum-one" }, oneRpc: { @@ -183741,7 +189027,7 @@ const defaultConfig = { url: "https://1rpc.io/avax/c" }, stackup: { - name: "Stackup RPC", + name: "Stackup", url: "https://public.stackup.sh/api/v1/node/avalanche-mainnet" } }, @@ -183840,6 +189126,7 @@ const defaultConfig = { GOVERNANCE_BLOCK: 5594395, NOTE_ACCOUNT_BLOCK: 5594395, ENCRYPTED_NOTES_BLOCK: 5594395, + REGISTRY_BLOCK: 5594395, MINING_BLOCK_TIME: 15 } } @@ -184041,16 +189328,79 @@ const governanceEventsSchema = { ] } }; -const registeredEventsSchema = { +const relayerRegistryEventsSchema = { + type: "array", + items: { + anyOf: [ + // RelayerRegisteredEvents + { + type: "object", + properties: { + ...baseEventsSchemaProperty, + event: { type: "string" }, + ensName: { type: "string" }, + relayerAddress: addressSchemaType, + ensHash: { type: "string" }, + stakedAmount: { type: "string" } + }, + required: [ + ...baseEventsSchemaRequired, + "event", + "ensName", + "relayerAddress", + "ensHash", + "stakedAmount" + ], + additionalProperties: false + }, + // RelayerUnregisteredEvents + { + type: "object", + properties: { + ...baseEventsSchemaProperty, + event: { type: "string" }, + relayerAddress: addressSchemaType + }, + required: [...baseEventsSchemaRequired, "event", "relayerAddress"], + additionalProperties: false + }, + // WorkerRegisteredEvents & WorkerUnregisteredEvents + { + type: "object", + properties: { + ...baseEventsSchemaProperty, + event: { type: "string" }, + relayerAddress: addressSchemaType, + workerAddress: addressSchemaType + }, + required: [...baseEventsSchemaRequired, "event", "relayerAddress", "workerAddress"], + additionalProperties: false + } + ] + } +}; +const stakeBurnedEventsSchema = { type: "array", items: { type: "object", properties: { ...baseEventsSchemaProperty, - ensName: { type: "string" }, - relayerAddress: addressSchemaType + relayerAddress: addressSchemaType, + amountBurned: bnSchemaType, + instanceAddress: addressSchemaType, + gasFee: bnSchemaType, + relayerFee: bnSchemaType, + timestamp: { type: "number" } }, - required: [...baseEventsSchemaRequired, "ensName", "relayerAddress"], + required: [ + ...baseEventsSchemaRequired, + "relayerAddress", + "amountBurned", + "instanceAddress", + "gasFee", + "relayerFee", + "timestamp" + ], additionalProperties: false } }; @@ -184110,17 +189460,20 @@ const encryptedNotesSchema = { } }; function getEventsSchemaValidator(type) { - if (type === DEPOSIT) { + if (type === "deposit") { return dist_ajv.compile(depositsEventsSchema); } - if (type === WITHDRAWAL) { + if (type === "withdrawal") { return dist_ajv.compile(withdrawalsEventsSchema); } if (type === "governance") { return dist_ajv.compile(governanceEventsSchema); } - if (type === "registered") { - return dist_ajv.compile(registeredEventsSchema); + if (type === "registry") { + return dist_ajv.compile(relayerRegistryEventsSchema); + } + if (type === "revenue") { + return dist_ajv.compile(stakeBurnedEventsSchema); } if (type === "echo") { return dist_ajv.compile(echoEventsSchema); @@ -184484,13 +189837,9 @@ class RelayerClient { } } -const DEPOSIT = "deposit"; -const WITHDRAWAL = "withdrawal"; class BaseEventsService { netId; provider; - graphApi; - subgraphName; contract; type; deployedBlock; @@ -184500,8 +189849,6 @@ class BaseEventsService { constructor({ netId, provider, - graphApi, - subgraphName, contract, type = "", deployedBlock = 0, @@ -184510,8 +189857,6 @@ class BaseEventsService { }) { this.netId = netId; this.provider = provider; - this.graphApi = graphApi; - this.subgraphName = subgraphName; this.fetchDataOptions = fetchDataOptions2; this.contract = contract; this.type = type; @@ -184532,17 +189877,6 @@ class BaseEventsService { getTovarishType() { return String(this.getType() || "").toLowerCase(); } - getGraphMethod() { - return ""; - } - getGraphParams() { - return { - graphApi: this.graphApi || "", - subgraphName: this.subgraphName || "", - fetchDataOptions: this.fetchDataOptions, - onProgress: this.updateGraphProgress - }; - } /* eslint-disable @typescript-eslint/no-unused-vars */ updateEventProgress({ percentage, type, fromBlock, toBlock, count }) { } @@ -184550,8 +189884,6 @@ class BaseEventsService { } updateTransactionProgress({ percentage, currentIndex, totalIndex }) { } - updateGraphProgress({ type, fromBlock, toBlock, count }) { - } /* eslint-enable @typescript-eslint/no-unused-vars */ async formatEvents(events) { return await new Promise((resolve) => resolve(events)); @@ -184582,28 +189914,6 @@ class BaseEventsService { } return dbEvents; } - /** - * Get latest events - */ - async getEventsFromGraph({ - fromBlock, - methodName = "" - }) { - if (!this.graphApi || !this.subgraphName) { - return { - events: [], - lastBlock: fromBlock - }; - } - const { events, lastSyncBlock } = await graph[methodName || this.getGraphMethod()]({ - fromBlock, - ...this.getGraphParams() - }); - return { - events, - lastBlock: lastSyncBlock - }; - } async getEventsFromRpc({ fromBlock, toBlock @@ -184639,7 +189949,7 @@ class BaseEventsService { } } async getLatestEvents({ fromBlock }) { - if (this.tovarishClient?.selectedRelayer && ![DEPOSIT, WITHDRAWAL].includes(this.type.toLowerCase())) { + if (this.tovarishClient?.selectedRelayer && !["Deposit", "Withdrawal"].includes(this.type)) { const { events, lastSyncBlock: lastBlock } = await this.tovarishClient.getEvents({ type: this.getTovarishType(), fromBlock @@ -184649,15 +189959,9 @@ class BaseEventsService { lastBlock }; } - const graphEvents = await this.getEventsFromGraph({ fromBlock }); - const lastSyncBlock = graphEvents.lastBlock && graphEvents.lastBlock >= fromBlock ? graphEvents.lastBlock : fromBlock; - const rpcEvents = await this.getEventsFromRpc({ - fromBlock: lastSyncBlock + return await this.getEventsFromRpc({ + fromBlock }); - return { - events: [...graphEvents.events, ...rpcEvents.events], - lastBlock: rpcEvents.lastBlock - }; } /* eslint-disable @typescript-eslint/no-unused-vars */ async validateEvents({ @@ -184741,23 +190045,13 @@ class BaseTornadoService extends BaseEventsService { getInstanceName() { return `${this.getType().toLowerCase()}s_${this.netId}_${this.currency}_${this.amount}`; } - getGraphMethod() { - return `getAll${this.getType()}s`; - } - getGraphParams() { - return { - graphApi: this.graphApi || "", - subgraphName: this.subgraphName || "", - amount: this.amount, - currency: this.currency, - fetchDataOptions: this.fetchDataOptions, - onProgress: this.updateGraphProgress - }; - } async formatEvents(events) { - const type = this.getType().toLowerCase(); - if (type === DEPOSIT) { - const formattedEvents = events.map(({ blockNumber, index: logIndex, transactionHash, args }) => { + const type = this.getType(); + if (type === "Deposit") { + const txs = await this.batchTransactionService.getBatchTransactions([ + ...new Set(events.map(({ transactionHash }) => transactionHash)) + ]); + return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => { const { commitment, leafIndex, timestamp } = args; return { blockNumber, @@ -184765,21 +190059,15 @@ class BaseTornadoService extends BaseEventsService { transactionHash, commitment, leafIndex: Number(leafIndex), - timestamp: Number(timestamp) - }; - }); - const txs = await this.batchTransactionService.getBatchTransactions([ - ...new Set(formattedEvents.map(({ transactionHash }) => transactionHash)) - ]); - return formattedEvents.map((event) => { - const { from } = txs.find(({ hash }) => hash === event.transactionHash); - return { - ...event, - from + timestamp: Number(timestamp), + from: txs.find(({ hash }) => hash === transactionHash)?.from || "" }; }); } else { - const formattedEvents = events.map(({ blockNumber, index: logIndex, transactionHash, args }) => { + const blocks = await this.batchBlockService.getBatchBlocks([ + ...new Set(events.map(({ blockNumber }) => blockNumber)) + ]); + return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => { const { nullifierHash, to, fee } = args; return { blockNumber, @@ -184787,17 +190075,8 @@ class BaseTornadoService extends BaseEventsService { transactionHash, nullifierHash: String(nullifierHash), to: address_getAddress(to), - fee: String(fee) - }; - }); - const blocks = await this.batchBlockService.getBatchBlocks([ - ...new Set(formattedEvents.map(({ blockNumber }) => blockNumber)) - ]); - return formattedEvents.map((event) => { - const { timestamp } = blocks.find(({ number }) => number === event.blockNumber); - return { - ...event, - timestamp + fee: String(fee), + timestamp: blocks.find(({ number }) => number === blockNumber)?.timestamp || 0 }; }); } @@ -184806,7 +190085,7 @@ class BaseTornadoService extends BaseEventsService { events, hasNewEvents }) { - if (events.length && this.getType().toLowerCase() === DEPOSIT) { + if (events.length && this.getType() === "Deposit") { const depositEvents = events; const lastEvent = depositEvents[depositEvents.length - 1]; if (lastEvent.leafIndex !== depositEvents.length - 1) { @@ -184848,9 +190127,6 @@ class BaseEchoService extends BaseEventsService { getInstanceName() { return `echo_${this.netId}`; } - getGraphMethod() { - return "getAllGraphEchoEvents"; - } async formatEvents(events) { return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => { const { who, data } = args; @@ -184868,15 +190144,6 @@ class BaseEchoService extends BaseEventsService { } }).filter((e) => e); } - async getEventsFromGraph({ fromBlock }) { - if (!this.graphApi || this.graphApi.includes("api.thegraph.com")) { - return { - events: [], - lastBlock: fromBlock - }; - } - return super.getEventsFromGraph({ fromBlock }); - } } class BaseEncryptedNotesService extends BaseEventsService { constructor(serviceConstructor) { @@ -184892,9 +190159,6 @@ class BaseEncryptedNotesService extends BaseEventsService { getTovarishType() { return "encrypted_notes"; } - getGraphMethod() { - return "getAllEncryptedNotes"; - } async formatEvents(events) { return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => { const { encryptedNote } = args; @@ -184963,11 +190227,11 @@ function parseDescription(id, text) { description }; } -function parseComment(Governance, calldata) { +function parseComment(Governance2, calldata) { try { const methodLength = 4; const result = abiCoder.decode(["address[]", "uint256", "bool"], data_dataSlice(calldata, methodLength)); - const data = Governance.interface.encodeFunctionData( + const data = Governance2.interface.encodeFunctionData( // @ts-expect-error encodeFunctionData is broken lol "castDelegatedVote", result @@ -184992,14 +190256,14 @@ class BaseGovernanceService extends BaseEventsService { ReverseRecords; batchTransactionService; constructor(serviceConstructor) { - const { Governance, Aggregator, ReverseRecords, provider } = serviceConstructor; + const { Governance: Governance2, Aggregator: Aggregator2, ReverseRecords, provider } = serviceConstructor; super({ ...serviceConstructor, - contract: Governance, + contract: Governance2, type: "*" }); - this.Governance = Governance; - this.Aggregator = Aggregator; + this.Governance = Governance2; + this.Aggregator = Aggregator2; this.ReverseRecords = ReverseRecords; this.batchTransactionService = new BatchTransactionService({ provider, @@ -185012,9 +190276,6 @@ class BaseGovernanceService extends BaseEventsService { getTovarishType() { return "governance"; } - getGraphMethod() { - return "getAllGovernanceEvents"; - } async formatEvents(events) { const proposalEvents = []; const votedEvents = []; @@ -185084,15 +190345,6 @@ class BaseGovernanceService extends BaseEventsService { } return [...proposalEvents, ...votedEvents, ...delegatedEvents, ...undelegatedEvents]; } - async getEventsFromGraph({ fromBlock }) { - if (!this.graphApi || !this.subgraphName || this.graphApi.includes("api.thegraph.com")) { - return { - events: [], - lastBlock: fromBlock - }; - } - return super.getEventsFromGraph({ fromBlock }); - } async getAllProposals() { const { events } = await this.updateEvents(); const proposalEvents = events.filter((e) => e.event === "ProposalCreated"); @@ -185228,39 +190480,74 @@ class BaseRegistryService extends BaseEventsService { relayerEnsSubdomains; updateInterval; constructor(serviceConstructor) { - const { RelayerRegistry: contract, Aggregator, relayerEnsSubdomains } = serviceConstructor; + const { RelayerRegistry: contract, Aggregator: Aggregator2, relayerEnsSubdomains } = serviceConstructor; super({ ...serviceConstructor, contract, - type: "RelayerRegistered" + type: "*" }); - this.Aggregator = Aggregator; + this.Aggregator = Aggregator2; this.relayerEnsSubdomains = relayerEnsSubdomains; this.updateInterval = 86400; } getInstanceName() { - return `registered_${this.netId}`; + return `registry_${this.netId}`; } getTovarishType() { - return "registered"; - } - // Name of method used for graph - getGraphMethod() { - return "getAllRegisters"; + return "registry"; } async formatEvents(events) { - return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => { + const relayerRegisteredEvents = []; + const relayerUnregisteredEvents = []; + const workerRegisteredEvents = []; + const workerUnregisteredEvents = []; + events.forEach(({ blockNumber, index: logIndex, transactionHash, args, eventName: event }) => { const eventObjects = { blockNumber, logIndex, - transactionHash - }; - return { - ...eventObjects, - ensName: args.ensName, - relayerAddress: args.relayerAddress + transactionHash, + event }; + if (event === "RelayerRegistered") { + const { relayer: ensHash, ensName, relayerAddress, stakedAmount } = args; + relayerRegisteredEvents.push({ + ...eventObjects, + ensName, + relayerAddress, + ensHash, + stakedAmount: formatEther(stakedAmount) + }); + } + if (event === "RelayerUnregistered") { + const { relayer: relayerAddress } = args; + relayerUnregisteredEvents.push({ + ...eventObjects, + relayerAddress + }); + } + if (event === "WorkerRegistered") { + const { relayer: relayerAddress, worker: workerAddress } = args; + workerRegisteredEvents.push({ + ...eventObjects, + relayerAddress, + workerAddress + }); + } + if (event === "WorkerUnregistered") { + const { relayer: relayerAddress, worker: workerAddress } = args; + workerUnregisteredEvents.push({ + ...eventObjects, + relayerAddress, + workerAddress + }); + } }); + return [ + ...relayerRegisteredEvents, + ...relayerUnregisteredEvents, + ...workerRegisteredEvents, + ...workerUnregisteredEvents + ]; } /** * Get saved or cached relayers @@ -185291,7 +190578,8 @@ class BaseRegistryService extends BaseEventsService { return cachedRelayers; } async getLatestRelayers() { - const { events, lastBlock } = await this.updateEvents(); + const { events: allEvents, lastBlock } = await this.updateEvents(); + const events = allEvents.filter((e) => e.event === "RelayerRegistered"); const subdomains = Object.values(this.relayerEnsSubdomains); const registerSet = /* @__PURE__ */ new Set(); const uniqueRegisters = events.filter(({ ensName }) => { @@ -185366,10 +190654,88 @@ class BaseRegistryService extends BaseEventsService { return { lastBlock, timestamp, relayers }; } } +class BaseRevenueService extends BaseEventsService { + batchTransactionService; + batchBlockService; + constructor(serviceConstructor) { + const { RelayerRegistry: contract, provider } = serviceConstructor; + super({ + ...serviceConstructor, + contract, + type: "StakeBurned" + }); + this.batchTransactionService = new BatchTransactionService({ + provider, + onProgress: this.updateTransactionProgress + }); + this.batchBlockService = new BatchBlockService({ + provider, + onProgress: this.updateBlockProgress + }); + } + getInstanceName() { + return `revenue_${this.netId}`; + } + getTovarishType() { + return "revenue"; + } + async formatEvents(events) { + const blocks = await this.batchBlockService.getBatchBlocks([ + ...new Set(events.map(({ blockNumber }) => blockNumber)) + ]); + const receipts = await this.batchTransactionService.getBatchReceipt([ + ...new Set(events.map(({ transactionHash }) => transactionHash)) + ]); + const registeredRelayers = new Set(events.map(({ args }) => args.relayer)); + const tornadoInterface = Tornado__factory.createInterface(); + const withdrawHash = tornadoInterface.getEvent("Withdrawal").topicHash; + const withdrawalLogs = receipts.map( + (receipt) => receipt.logs.map((log) => { + if (log.topics[0] === withdrawHash) { + const block = blocks.find((b) => b.number === log.blockNumber); + const parsedLog = tornadoInterface.parseLog(log); + if (parsedLog && registeredRelayers.has(parsedLog.args.relayer)) { + return { + instanceAddress: log.address, + gasFee: (receipt.cumulativeGasUsed * receipt.gasPrice).toString(), + relayerFee: parsedLog.args.fee.toString(), + timestamp: block?.timestamp || 0 + }; + } + } + }).filter((l) => l) + ).flat(); + if (withdrawalLogs.length !== events.length) { + console.log( + ` +RevenueService: Mismatch on withdrawal logs (${withdrawalLogs.length} ) and events logs (${events.length}) +` + ); + } + return events.map(({ blockNumber, index: logIndex, transactionHash, args }, index) => { + const eventObjects = { + blockNumber, + logIndex, + transactionHash + }; + const { relayer: relayerAddress, amountBurned } = args; + const { instanceAddress, gasFee, relayerFee, timestamp } = withdrawalLogs[index]; + return { + ...eventObjects, + relayerAddress, + amountBurned: amountBurned.toString(), + instanceAddress, + gasFee, + relayerFee, + timestamp + }; + }); + } +} -function zipAsync(file) { +function zipAsync(file, options) { return new Promise((res, rej) => { - zip(file, { mtime: /* @__PURE__ */ new Date("1/1/1980") }, (err, data) => { + zip(file, { ...options || {}, mtime: /* @__PURE__ */ new Date("1/1/1980") }, (err, data) => { if (err) { rej(err); return; @@ -185643,6 +191009,100 @@ class DBRegistryService extends BaseRegistryService { staticUrl; idb; zipDigest; + relayerJsonDigest; + constructor(params) { + super(params); + this.staticUrl = params.staticUrl; + this.idb = params.idb; + } + async getEventsFromDB() { + return await loadDBEvents({ + idb: this.idb, + instanceName: this.getInstanceName() + }); + } + async getEventsFromCache() { + return await loadRemoteEvents({ + staticUrl: this.staticUrl, + instanceName: this.getInstanceName(), + deployedBlock: this.deployedBlock, + zipDigest: this.zipDigest + }); + } + async saveEvents({ events, lastBlock }) { + await saveDBEvents({ + idb: this.idb, + instanceName: this.getInstanceName(), + events, + lastBlock + }); + } + async getRelayersFromDB() { + try { + const allCachedRelayers = await this.idb.getAll({ + storeName: `relayers_${this.netId}` + }); + if (!allCachedRelayers?.length) { + return { + lastBlock: 0, + timestamp: 0, + relayers: [] + }; + } + return allCachedRelayers.slice(-1)[0]; + } catch (err) { + console.log("Method getRelayersFromDB has error"); + console.log(err); + return { + lastBlock: 0, + timestamp: 0, + relayers: [] + }; + } + } + async getRelayersFromCache() { + const url = `${this.staticUrl}/relayers.json`; + try { + const resp = await fetchData(url, { + method: "GET", + returnResponse: true + }); + const data = new Uint8Array(await resp.arrayBuffer()); + if (this.relayerJsonDigest) { + const hash = "sha384-" + bytesToBase64(await digest(data)); + if (hash !== this.relayerJsonDigest) { + const errMsg = `Invalid digest hash for ${url}, wants ${this.relayerJsonDigest} has ${hash}`; + throw new Error(errMsg); + } + } + return JSON.parse(new TextDecoder().decode(data)); + } catch (err) { + console.log("Method getRelayersFromCache has error"); + console.log(err); + return { + lastBlock: 0, + timestamp: 0, + relayers: [] + }; + } + } + async saveRelayers(cachedRelayers) { + try { + await this.idb.putItem({ + data: cachedRelayers, + storeName: `relayers_${this.netId}` + }); + } catch (err) { + console.log("Method saveRelayers has error"); + console.log(err); + } + } +} +class DBRevenueService extends BaseRevenueService { + staticUrl; + idb; + zipDigest; + relayerJsonDigest; constructor(params) { super(params); this.staticUrl = params.staticUrl; @@ -191369,11 +196829,6 @@ class ENSUtils { const { labelhash: labelhash2, parentNode } = makeLabelNodeAndParent(name); return registry.setSubnodeRecord(parentNode, labelhash2, owner, resolver.target, BigInt(0)); } - // https://github.com/ensdomains/ensjs/blob/main/packages/ensjs/src/functions/wallet/setTextRecord.ts - async setText(signer, name, key, value) { - const resolver = ENSResolver__factory.connect((await this.getResolver(name))?.address, signer); - return resolver.setText(namehash(name), key, value); - } getResolver(name) { return EnsResolver.fromName(this.provider, name); } @@ -191384,6 +196839,11 @@ class ENSUtils { } return await resolver.getText(key) || ""; } + // https://github.com/ensdomains/ensjs/blob/main/packages/ensjs/src/functions/wallet/setTextRecord.ts + async setText(signer, name, key, value) { + const resolver = ENSResolver__factory.connect((await this.getResolver(name))?.address, signer); + return resolver.setText(namehash(name), key, value); + } } const DUMMY_ADDRESS = "0x1111111111111111111111111111111111111111"; @@ -191807,16 +197267,36 @@ async function getIndexedDB(netId) { const stores = [...defaultState]; if (registryContract) { stores.push({ - name: `registered_${netId}`, + name: `registry_${netId}`, keyPath: "ensName", indexes: [ ...minimalIndexes, { - name: "relayerAddress", + name: "event", unique: false } ] }); + stores.push({ + name: `relayers_${netId}`, + keyPath: "timestamp", + indexes: [ + { + name: "timestamp", + unique: true + } + ] + }); + stores.push({ + name: `revenue_${netId}`, + keyPath: "timestamp", + indexes: [ + { + name: "timestamp", + unique: true + } + ] + }); } if (governanceContract) { stores.push({ @@ -192912,18 +198392,6 @@ class NodeTornadoService extends BaseTornadoService { console.log(`Fetched ${currentIndex} withdrawal blocks of ${totalIndex}`); } } - updateGraphProgress({ type, fromBlock, toBlock, count }) { - if (toBlock) { - console.log(`fromBlock - ${fromBlock}`); - console.log(`toBlock - ${toBlock}`); - if (count) { - console.log(`downloaded ${type} events from graph node count - ${count}`); - console.log("____________________________________________"); - console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock} -`); - } - } - } async getEventsFromDB() { return await getEventsFromDB(this); } @@ -192988,18 +198456,6 @@ class NodeEchoService extends BaseEchoService { console.log(`downloaded ${type} events count - ${count}`); console.log("____________________________________________"); console.log(`Fetched ${type} events from ${fromBlock} to ${toBlock} -`); - } - } - } - updateGraphProgress({ type, fromBlock, toBlock, count }) { - if (toBlock) { - console.log(`fromBlock - ${fromBlock}`); - console.log(`toBlock - ${toBlock}`); - if (count) { - console.log(`downloaded ${type} events from graph node count - ${count}`); - console.log("____________________________________________"); - console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock} `); } } @@ -193042,18 +198498,6 @@ class NodeEncryptedNotesService extends BaseEncryptedNotesService { console.log(`downloaded ${type} events count - ${count}`); console.log("____________________________________________"); console.log(`Fetched ${type} events from ${fromBlock} to ${toBlock} -`); - } - } - } - updateGraphProgress({ type, fromBlock, toBlock, count }) { - if (toBlock) { - console.log(`fromBlock - ${fromBlock}`); - console.log(`toBlock - ${toBlock}`); - if (count) { - console.log(`downloaded ${type} events from graph node count - ${count}`); - console.log("____________________________________________"); - console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock} `); } } @@ -193096,18 +198540,6 @@ class NodeGovernanceService extends BaseGovernanceService { console.log(`downloaded ${type} events count - ${count}`); console.log("____________________________________________"); console.log(`Fetched ${type} events from ${fromBlock} to ${toBlock} -`); - } - } - } - updateGraphProgress({ type, fromBlock, toBlock, count }) { - if (toBlock) { - console.log(`fromBlock - ${fromBlock}`); - console.log(`toBlock - ${toBlock}`); - if (count) { - console.log(`downloaded ${type} events from graph node count - ${count}`); - console.log("____________________________________________"); - console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock} `); } } @@ -193155,18 +198587,6 @@ class NodeRegistryService extends BaseRegistryService { console.log(`downloaded ${type} events count - ${count}`); console.log("____________________________________________"); console.log(`Fetched ${type} events from ${fromBlock} to ${toBlock} -`); - } - } - } - updateGraphProgress({ type, fromBlock, toBlock, count }) { - if (toBlock) { - console.log(`fromBlock - ${fromBlock}`); - console.log(`toBlock - ${toBlock}`); - if (count) { - console.log(`downloaded ${type} events from graph node count - ${count}`); - console.log("____________________________________________"); - console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock} `); } } @@ -193180,7 +198600,7 @@ class NodeRegistryService extends BaseRegistryService { async saveEvents({ events, lastBlock }) { const eventTable = new (cli_table3_default())(); eventTable.push( - [{ colSpan: 2, content: "Registered Relayers", hAlign: "center" }], + [{ colSpan: 2, content: "Relayer Registry", hAlign: "center" }], ["Network", `${this.netId} chain`], ["Events", `${events.length} events`], [{ colSpan: 2, content: "Latest events" }], @@ -193256,6 +198676,58 @@ class NodeRegistryService extends BaseRegistryService { } } } +class NodeRevenueService extends BaseRevenueService { + cacheDirectory; + userDirectory; + constructor(serviceConstructor) { + super(serviceConstructor); + const { cacheDirectory, userDirectory } = serviceConstructor; + this.cacheDirectory = cacheDirectory; + this.userDirectory = userDirectory; + } + updateEventProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from ${fromBlock} to ${toBlock} +`); + } + } + } + updateTransactionProgress({ currentIndex, totalIndex }) { + if (totalIndex) { + console.log(`Fetched ${currentIndex} txs of ${totalIndex}`); + } + } + updateBlockProgress({ currentIndex, totalIndex }) { + if (totalIndex) { + console.log(`Fetched ${currentIndex} blocks of ${totalIndex}`); + } + } + async getEventsFromDB() { + return await getEventsFromDB(this); + } + async getEventsFromCache() { + return await getEventsFromCache(this); + } + async saveEvents({ events, lastBlock }) { + const eventTable = new (cli_table3_default())(); + eventTable.push( + [{ colSpan: 2, content: "Stake Burned", hAlign: "center" }], + ["Network", `${this.netId} chain`], + ["Events", `${events.length} events`], + [{ colSpan: 2, content: "Latest events" }], + ...events.slice(events.length - 10).reverse().map(({ blockNumber }, index) => { + const eventIndex = events.length - index; + return [eventIndex, blockNumber]; + }) + ); + await saveEvents(this, { events, lastBlock }, eventTable); + } +} ;// ./src/services/parser.ts @@ -193502,13 +198974,17 @@ async function getProgramOptions(options) { fetchDataOptions: fetchDataOptions2 }; } -function getProgramProvider(rpcUrl = "", providerOptions) { +async function getProgramProvider(rpcUrl = "", providerOptions) { const { netId } = providerOptions; const config = getConfig(netId); if (!rpcUrl) { rpcUrl = Object.values(config.rpcUrls)[0]?.url || ""; } - return dist_getProvider(rpcUrl, providerOptions); + const provider = await dist_getProvider(rpcUrl, providerOptions); + console.log(` +Connected with the ${config.networkName} RPC: ${provider._getConnection().url} +`); + return provider; } function getProgramSigner({ options, @@ -193529,7 +199005,7 @@ async function getProgramRelayer({ fetchDataOptions: fetchDataOptions2, netId }) { - const { ethRpc, relayer } = options; + const { rpc, ethRpc, relayer } = options; const netConfig = getConfig(netId); const ethConfig = getConfig(RELAYER_NETWORK); const { @@ -193537,7 +199013,8 @@ async function getProgramRelayer({ registryContract, constants: { REGISTRY_BLOCK } } = ethConfig; - const provider = await getProgramProvider(ethRpc, { + const rpcUrl = netId === RELAYER_NETWORK ? rpc : ethRpc; + const provider = await getProgramProvider(rpcUrl, { netId: RELAYER_NETWORK, ...fetchDataOptions2 }); @@ -193608,7 +199085,7 @@ async function getTovarishRelayer({ fetchDataOptions: fetchDataOptions2, netId }) { - const { ethRpc, relayer } = options; + const { rpc, ethRpc, relayer } = options; const netConfig = getConfig(netId); const ethConfig = getConfig(RELAYER_NETWORK); const { @@ -193616,7 +199093,8 @@ async function getTovarishRelayer({ registryContract, constants: { REGISTRY_BLOCK } } = ethConfig; - const provider = await getProgramProvider(ethRpc, { + const rpcUrl = netId === RELAYER_NETWORK ? rpc : ethRpc; + const provider = await getProgramProvider(rpcUrl, { netId: RELAYER_NETWORK, ...fetchDataOptions2 }); @@ -194204,7 +199682,7 @@ Connected with Tovarish Relayer ${tovarishClient.selectedRelayer.url} } let { fee, refund, proof, args } = await getProof(); const withdrawOverrides = { - from: !walletWithdrawal ? relayerClient?.selectedRelayer?.rewardAccount : signer?.address, + // from: !walletWithdrawal ? relayerClient?.selectedRelayer?.rewardAccount : (signer?.address as string), value: args[5] || 0 }; gasLimit = await TornadoProxy.withdraw.estimateGas(instanceAddress, proof, ...args, withdrawOverrides); @@ -194452,12 +199930,23 @@ Connected with Tovarish Relayer ${tovarishClient.selectedRelayer.url} relayerEnsSubdomains: getRelayerEnsSubdomains(), deployedBlock: REGISTRY_BLOCK, fetchDataOptions: fetchDataOptions2, - // Exclude tovarish relayer from updating registry events and use RPC directly - // tovarishClient, + tovarishClient, cacheDirectory: EVENTS_DIR, userDirectory: SAVED_DIR }); + await registryService.updateEvents(); await registryService.updateRelayers(); + const revenueService = new NodeRevenueService({ + netId, + provider, + RelayerRegistry: RelayerRegistry__factory.connect(registryContract, provider), + deployedBlock: REGISTRY_BLOCK, + fetchDataOptions: fetchDataOptions2, + tovarishClient, + cacheDirectory: EVENTS_DIR, + userDirectory: SAVED_DIR + }); + await revenueService.updateEvents(); } const echoService = new NodeEchoService({ netId, @@ -195225,6 +200714,86 @@ Connected with Tovarish Relayer ${tovarishClient.selectedRelayer.url} console.log(delegateTable.toString()); external_process_default().exit(0); }); + program.command("apy").description("Calculate TORN Staking APY from last 30 days revenue").action(async (cmdOptions) => { + const { options, fetchDataOptions: fetchDataOptions2 } = await getProgramOptions(cmdOptions); + const { rpc, disableTovarish } = options; + const netId = RELAYER_NETWORK; + const provider = await getProgramProvider(rpc, { + netId, + ...fetchDataOptions2 + }); + const config = getConfig(netId); + const { + tornContract, + governanceContract, + registryContract, + constants: { REGISTRY_BLOCK } + } = config; + const tovarishClient = !disableTovarish ? (await getTovarishRelayer({ + options, + fetchDataOptions: fetchDataOptions2, + netId + })).relayerClient : void 0; + if (tovarishClient?.selectedRelayer) { + console.log(` +Connected with Tovarish Relayer ${tovarishClient.selectedRelayer.url} +`); + } + const revenueService = new NodeRevenueService({ + netId, + provider, + RelayerRegistry: RelayerRegistry__factory.connect(registryContract, provider), + deployedBlock: REGISTRY_BLOCK, + fetchDataOptions: fetchDataOptions2, + tovarishClient, + cacheDirectory: EVENTS_DIR, + userDirectory: SAVED_DIR + }); + const Governance = GovernanceVaultUpgrade__factory.connect(governanceContract, provider); + const TORN = TORN__factory.connect(tornContract, provider); + const [stakedBalance, { events }] = await Promise.all([ + Governance.userVault().then((vault) => TORN.balanceOf(vault)), + revenueService.updateEvents() + ]); + const recentEvents = events.filter(({ timestamp }) => timestamp > Math.floor(Date.now() / 1e3) - 30 * 86400).reverse(); + const weeklyRevenue = recentEvents.filter(({ timestamp }) => timestamp > Math.floor(Date.now() / 1e3) - 7 * 86400).reduce((acc, { amountBurned }) => acc + BigInt(amountBurned), 0n); + const monthlyRevenue = recentEvents.reduce((acc, { amountBurned }) => acc + BigInt(amountBurned), 0n); + const weeklyYield = Number(weeklyRevenue * 52n) / Number(stakedBalance) * 100; + const monthlyYield = Number(monthlyRevenue * 12n) / Number(stakedBalance) * 100; + const statsTable = new (cli_table3_default())(); + statsTable.push( + [{ colSpan: 2, content: "APY Stats", hAlign: "center" }], + [ + "Yield (from 7d income):", + `${weeklyYield.toFixed(5)}% (${Number(formatEther(weeklyRevenue)).toFixed(3)} TORN)` + ], + [ + "Yield (from 30d income):", + `${monthlyYield.toFixed(5)}% (${Number(formatEther(monthlyRevenue)).toFixed(3)} TORN)` + ], + ["Total Staked:", `${Number(formatEther(stakedBalance)).toFixed(3)} TORN`] + ); + const apyTable = new (cli_table3_default())(); + apyTable.push( + [{ colSpan: 6, content: "Recent Burns", hAlign: "center" }], + ["Block", "Instance", "Relayer", "Relayer Fees", "TORN Distributed", "Timestamp"], + ...recentEvents.slice(0, 30).map(({ blockNumber, relayerAddress, amountBurned, instanceAddress, relayerFee, timestamp }) => { + const { amount, currency } = getInstanceByAddress(config, instanceAddress); + const { decimals } = config.tokens[currency]; + return [ + blockNumber, + `${amount} ${currency.toUpperCase()}`, + relayerAddress, + `${Number(formatUnits(relayerFee, decimals)).toFixed(5)} ${currency.toUpperCase()}`, + `${Number(formatEther(amountBurned)).toFixed(3)} TORN`, + moment_default().unix(timestamp).fromNow() + ]; + }) + ); + console.log("\n\n" + statsTable.toString() + "\n"); + console.log("\n\n" + apyTable.toString() + "\n"); + external_process_default().exit(0); + }); program.commands.forEach((cmd) => { cmd.option("-r, --rpc ", "The RPC that CLI should interact with", parseUrl); cmd.option("-e, --eth-rpc ", "The Ethereum Mainnet RPC that CLI should interact with", parseUrl); diff --git a/dist/services/nodeEvents.d.ts b/dist/services/nodeEvents.d.ts index 2ee8fd1..5a9b830 100644 --- a/dist/services/nodeEvents.d.ts +++ b/dist/services/nodeEvents.d.ts @@ -1,5 +1,4 @@ -import { BatchBlockOnProgress, BatchEventOnProgress, BaseTornadoService, BaseEncryptedNotesService, BaseGovernanceService, BaseRegistryService, BaseTornadoServiceConstructor, BaseEncryptedNotesServiceConstructor, BaseGovernanceServiceConstructor, BaseRegistryServiceConstructor, BaseEchoServiceConstructor, BaseEchoService, CachedRelayers } from '@tornado/core'; -import type { BaseEvents, DepositsEvents, WithdrawalsEvents, EncryptedNotesEvents, RegistersEvents, AllGovernanceEvents, EchoEvents } from '@tornado/core'; +import { BatchBlockOnProgress, BatchEventOnProgress, BaseTornadoService, BaseEncryptedNotesService, BaseGovernanceService, BaseRegistryService, BaseRevenueService, BaseTornadoServiceConstructor, BaseEncryptedNotesServiceConstructor, BaseGovernanceServiceConstructor, BaseRegistryServiceConstructor, BaseRevenueServiceConstructor, BaseEchoServiceConstructor, BaseEchoService, CachedRelayers, BaseEvents, DepositsEvents, WithdrawalsEvents, EncryptedNotesEvents, AllRelayerRegistryEvents, AllGovernanceEvents, EchoEvents, StakeBurnedEvents } from '@tornado/core'; import { TreeCache } from './treeCache'; export type NodeServiceConstructor = { cacheDirectory: string; @@ -18,7 +17,6 @@ export declare class NodeTornadoService extends BaseTornadoService { updateEventProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; updateTransactionProgress({ currentIndex, totalIndex }: Parameters[0]): void; updateBlockProgress({ currentIndex, totalIndex }: Parameters[0]): void; - updateGraphProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; getEventsFromDB(): Promise>; getEventsFromCache(): Promise>; validateEvents({ events, lastBlock, hasNewEvents, }: BaseEvents & { @@ -32,7 +30,6 @@ export declare class NodeEchoService extends BaseEchoService { userDirectory: string; constructor(serviceConstructor: NodeEchoServiceConstructor); updateEventProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; - updateGraphProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; getEventsFromDB(): Promise>; getEventsFromCache(): Promise>; saveEvents({ events, lastBlock }: BaseEvents): Promise; @@ -43,7 +40,6 @@ export declare class NodeEncryptedNotesService extends BaseEncryptedNotesService userDirectory: string; constructor(serviceConstructor: NodeEncryptedNotesServiceConstructor); updateEventProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; - updateGraphProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; getEventsFromDB(): Promise>; getEventsFromCache(): Promise>; saveEvents({ events, lastBlock }: BaseEvents): Promise; @@ -54,7 +50,6 @@ export declare class NodeGovernanceService extends BaseGovernanceService { userDirectory: string; constructor(serviceConstructor: NodeGovernanceServiceConstructor); updateEventProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; - updateGraphProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; updateTransactionProgress({ currentIndex, totalIndex }: Parameters[0]): void; getEventsFromDB(): Promise>; getEventsFromCache(): Promise>; @@ -66,11 +61,22 @@ export declare class NodeRegistryService extends BaseRegistryService { userDirectory: string; constructor(serviceConstructor: NodeRegistryServiceConstructor); updateEventProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; - updateGraphProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; - getEventsFromDB(): Promise>; - getEventsFromCache(): Promise>; - saveEvents({ events, lastBlock }: BaseEvents): Promise; + getEventsFromDB(): Promise>; + getEventsFromCache(): Promise>; + saveEvents({ events, lastBlock }: BaseEvents): Promise; getRelayersFromDB(): Promise; getRelayersFromCache(): Promise; saveRelayers({ lastBlock, timestamp, relayers }: CachedRelayers): Promise; } +export type NodeRevenueServiceConstructor = BaseRevenueServiceConstructor & NodeServiceConstructor; +export declare class NodeRevenueService extends BaseRevenueService { + cacheDirectory: string; + userDirectory: string; + constructor(serviceConstructor: NodeRevenueServiceConstructor); + updateEventProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; + updateTransactionProgress({ currentIndex, totalIndex }: Parameters[0]): void; + updateBlockProgress({ currentIndex, totalIndex }: Parameters[0]): void; + getEventsFromDB(): Promise>; + getEventsFromCache(): Promise>; + saveEvents({ events, lastBlock }: BaseEvents): Promise; +} diff --git a/package.json b/package.json index 5ce82df..b31c407 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,8 @@ "sign": "ts-node src/cli.ts sign", "broadcast": "ts-node src/cli.ts broadcast", "proposals": "ts-node src/cli.ts proposals", - "delegates": "ts-node src/cli.ts delegates" + "delegates": "ts-node src/cli.ts delegates", + "apy": "ts-node src/cli.ts apy" }, "author": "", "license": "MIT", @@ -53,7 +54,7 @@ "optionalDependencies": {}, "devDependencies": { "@colors/colors": "^1.6.0", - "@tornado/core": "git+https://git.tornado.ws/tornadocontrib/tornado-core.git#f411159f15566cb0cfe46d07b1c2c4eb23af2e1f", + "@tornado/core": "git+https://git.tornado.ws/tornadocontrib/tornado-core.git#092989ebaa2fcd84eff7d4aed66433e77c790c60", "@typechain/ethers-v6": "^0.5.1", "@types/figlet": "^1.7.0", "@typescript-eslint/eslint-plugin": "^8.11.0", diff --git a/src/program.ts b/src/program.ts index 0304f45..7ebd5ff 100644 --- a/src/program.ts +++ b/src/program.ts @@ -14,6 +14,8 @@ import { Aggregator__factory, Governance__factory, Echoer__factory, + TORN__factory, + GovernanceVaultUpgrade__factory, } from '@tornado/contracts'; import { JsonRpcProvider, @@ -88,6 +90,7 @@ import { NodeEncryptedNotesService, NodeGovernanceService, TreeCache, + NodeRevenueService, } from './services'; const EXEC_NAME = 'tornado-cli'; @@ -226,7 +229,10 @@ export async function getProgramOptions(options: commonProgramOptions): Promise< }; } -export function getProgramProvider(rpcUrl: string = '', providerOptions: getProviderOptions): Promise { +export async function getProgramProvider( + rpcUrl: string = '', + providerOptions: getProviderOptions, +): Promise { const { netId } = providerOptions; const config = getConfig(netId); @@ -235,7 +241,11 @@ export function getProgramProvider(rpcUrl: string = '', providerOptions: getProv rpcUrl = Object.values(config.rpcUrls)[0]?.url || ''; } - return getProvider(rpcUrl, providerOptions); + const provider = await getProvider(rpcUrl, providerOptions); + + console.log(`\nConnected with the ${config.networkName} RPC: ${provider._getConnection().url}\n`); + + return provider; } export function getProgramSigner({ @@ -271,7 +281,7 @@ export async function getProgramRelayer({ invalidRelayers: RelayerError[]; relayerClient: RelayerClient; }> { - const { ethRpc, relayer } = options; + const { rpc, ethRpc, relayer } = options; const netConfig = getConfig(netId); @@ -283,7 +293,9 @@ export async function getProgramRelayer({ constants: { REGISTRY_BLOCK }, } = ethConfig; - const provider = await getProgramProvider(ethRpc, { + const rpcUrl = netId === RELAYER_NETWORK ? rpc : ethRpc; + + const provider = await getProgramProvider(rpcUrl, { netId: RELAYER_NETWORK, ...fetchDataOptions, }); @@ -380,7 +392,7 @@ export async function getTovarishRelayer({ invalidRelayers: RelayerError[]; relayerClient: TovarishClient; }> { - const { ethRpc, relayer } = options; + const { rpc, ethRpc, relayer } = options; const netConfig = getConfig(netId); @@ -392,7 +404,9 @@ export async function getTovarishRelayer({ constants: { REGISTRY_BLOCK }, } = ethConfig; - const provider = await getProgramProvider(ethRpc, { + const rpcUrl = netId === RELAYER_NETWORK ? rpc : ethRpc; + + const provider = await getProgramProvider(rpcUrl, { netId: RELAYER_NETWORK, ...fetchDataOptions, }); @@ -1175,9 +1189,7 @@ export function tornadoProgram() { let { fee, refund, proof, args } = await getProof(); const withdrawOverrides = { - from: !walletWithdrawal - ? relayerClient?.selectedRelayer?.rewardAccount - : (signer?.address as string), + // from: !walletWithdrawal ? relayerClient?.selectedRelayer?.rewardAccount : (signer?.address as string), value: args[5] || 0, }; @@ -1507,13 +1519,27 @@ export function tornadoProgram() { relayerEnsSubdomains: getRelayerEnsSubdomains(), deployedBlock: REGISTRY_BLOCK, fetchDataOptions, - // Exclude tovarish relayer from updating registry events and use RPC directly - // tovarishClient, + tovarishClient, cacheDirectory: EVENTS_DIR, userDirectory: SAVED_DIR, }); + await registryService.updateEvents(); + await registryService.updateRelayers(); + + const revenueService = new NodeRevenueService({ + netId, + provider, + RelayerRegistry: RelayerRegistry__factory.connect(registryContract, provider), + deployedBlock: REGISTRY_BLOCK, + fetchDataOptions, + tovarishClient, + cacheDirectory: EVENTS_DIR, + userDirectory: SAVED_DIR, + }); + + await revenueService.updateEvents(); } const echoService = new NodeEchoService({ @@ -2537,6 +2563,124 @@ export function tornadoProgram() { process.exit(0); }); + program + .command('apy') + .description('Calculate TORN Staking APY from last 30 days revenue') + .action(async (cmdOptions: commonProgramOptions) => { + const { options, fetchDataOptions } = await getProgramOptions(cmdOptions); + const { rpc, disableTovarish } = options; + const netId = RELAYER_NETWORK; + + const provider = await getProgramProvider(rpc, { + netId, + ...fetchDataOptions, + }); + + const config = getConfig(netId); + + const { + tornContract, + governanceContract, + registryContract, + constants: { REGISTRY_BLOCK }, + } = config; + + const tovarishClient = !disableTovarish + ? ( + await getTovarishRelayer({ + options, + fetchDataOptions, + netId, + }) + ).relayerClient + : undefined; + + if (tovarishClient?.selectedRelayer) { + console.log(`\nConnected with Tovarish Relayer ${tovarishClient.selectedRelayer.url}\n`); + } + + const revenueService = new NodeRevenueService({ + netId, + provider, + RelayerRegistry: RelayerRegistry__factory.connect(registryContract as string, provider), + deployedBlock: REGISTRY_BLOCK, + fetchDataOptions, + tovarishClient, + cacheDirectory: EVENTS_DIR, + userDirectory: SAVED_DIR, + }); + + const Governance = GovernanceVaultUpgrade__factory.connect(governanceContract as string, provider); + + const TORN = TORN__factory.connect(tornContract as string, provider); + + const [stakedBalance, { events }] = await Promise.all([ + Governance.userVault().then((vault) => TORN.balanceOf(vault)), + revenueService.updateEvents(), + ]); + + // Recent 30 days events + const recentEvents = events + .filter(({ timestamp }) => timestamp > Math.floor(Date.now() / 1000) - 30 * 86400) + .reverse(); + + const weeklyRevenue = recentEvents + .filter(({ timestamp }) => timestamp > Math.floor(Date.now() / 1000) - 7 * 86400) + .reduce((acc, { amountBurned }) => acc + BigInt(amountBurned), 0n); + + const monthlyRevenue = recentEvents.reduce((acc, { amountBurned }) => acc + BigInt(amountBurned), 0n); + + const weeklyYield = (Number(weeklyRevenue * 52n) / Number(stakedBalance)) * 100; + + const monthlyYield = (Number(monthlyRevenue * 12n) / Number(stakedBalance)) * 100; + + const statsTable = new Table(); + + statsTable.push( + [{ colSpan: 2, content: 'APY Stats', hAlign: 'center' }], + [ + 'Yield (from 7d income):', + `${weeklyYield.toFixed(5)}% (${Number(formatEther(weeklyRevenue)).toFixed(3)} TORN)`, + ], + [ + 'Yield (from 30d income):', + `${monthlyYield.toFixed(5)}% (${Number(formatEther(monthlyRevenue)).toFixed(3)} TORN)`, + ], + ['Total Staked:', `${Number(formatEther(stakedBalance)).toFixed(3)} TORN`], + ); + + const apyTable = new Table(); + + apyTable.push( + [{ colSpan: 6, content: 'Recent Burns', hAlign: 'center' }], + ['Block', 'Instance', 'Relayer', 'Relayer Fees', 'TORN Distributed', 'Timestamp'], + ...recentEvents + .slice(0, 30) + .map(({ blockNumber, relayerAddress, amountBurned, instanceAddress, relayerFee, timestamp }) => { + const { amount, currency } = getInstanceByAddress(config, instanceAddress) as { + amount: string; + currency: string; + }; + + const { decimals } = config.tokens[currency]; + + return [ + blockNumber, + `${amount} ${currency.toUpperCase()}`, + relayerAddress, + `${Number(formatUnits(relayerFee, decimals)).toFixed(5)} ${currency.toUpperCase()}`, + `${Number(formatEther(amountBurned)).toFixed(3)} TORN`, + moment.unix(timestamp).fromNow(), + ]; + }), + ); + + console.log('\n\n' + statsTable.toString() + '\n'); + console.log('\n\n' + apyTable.toString() + '\n'); + + process.exit(0); + }); + // common options program.commands.forEach((cmd) => { cmd.option('-r, --rpc ', 'The RPC that CLI should interact with', parseUrl); diff --git a/src/services/nodeEvents.ts b/src/services/nodeEvents.ts index 3b90b0a..e873c27 100644 --- a/src/services/nodeEvents.ts +++ b/src/services/nodeEvents.ts @@ -9,25 +9,26 @@ import { BaseEncryptedNotesService, BaseGovernanceService, BaseRegistryService, + BaseRevenueService, BaseTornadoServiceConstructor, BaseEncryptedNotesServiceConstructor, BaseGovernanceServiceConstructor, BaseRegistryServiceConstructor, + BaseRevenueServiceConstructor, BaseEchoServiceConstructor, BaseEchoService, CachedRelayers, toFixedHex, -} from '@tornado/core'; -import type { BaseEvents, DepositsEvents, WithdrawalsEvents, EncryptedNotesEvents, - RegistersEvents, + AllRelayerRegistryEvents, AllGovernanceEvents, EchoEvents, BaseEventsService, MinimalEvents, + StakeBurnedEvents, } from '@tornado/core'; import type { MerkleTree } from '@tornado/fixed-merkle-tree'; import { TreeCache } from './treeCache'; @@ -161,19 +162,6 @@ export class NodeTornadoService extends BaseTornadoService { } } - updateGraphProgress({ type, fromBlock, toBlock, count }: Parameters[0]) { - if (toBlock) { - console.log(`fromBlock - ${fromBlock}`); - console.log(`toBlock - ${toBlock}`); - - if (count) { - console.log(`downloaded ${type} events from graph node count - ${count}`); - console.log('____________________________________________'); - console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock}\n`); - } - } - } - async getEventsFromDB() { return await getEventsFromDB(this); } @@ -264,19 +252,6 @@ export class NodeEchoService extends BaseEchoService { } } - updateGraphProgress({ type, fromBlock, toBlock, count }: Parameters[0]) { - if (toBlock) { - console.log(`fromBlock - ${fromBlock}`); - console.log(`toBlock - ${toBlock}`); - - if (count) { - console.log(`downloaded ${type} events from graph node count - ${count}`); - console.log('____________________________________________'); - console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock}\n`); - } - } - } - async getEventsFromDB() { return await getEventsFromDB(this); } @@ -335,19 +310,6 @@ export class NodeEncryptedNotesService extends BaseEncryptedNotesService { } } - updateGraphProgress({ type, fromBlock, toBlock, count }: Parameters[0]) { - if (toBlock) { - console.log(`fromBlock - ${fromBlock}`); - console.log(`toBlock - ${toBlock}`); - - if (count) { - console.log(`downloaded ${type} events from graph node count - ${count}`); - console.log('____________________________________________'); - console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock}\n`); - } - } - } - async getEventsFromDB() { return await getEventsFromDB(this); } @@ -406,19 +368,6 @@ export class NodeGovernanceService extends BaseGovernanceService { } } - updateGraphProgress({ type, fromBlock, toBlock, count }: Parameters[0]) { - if (toBlock) { - console.log(`fromBlock - ${fromBlock}`); - console.log(`toBlock - ${toBlock}`); - - if (count) { - console.log(`downloaded ${type} events from graph node count - ${count}`); - console.log('____________________________________________'); - console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock}\n`); - } - } - } - updateTransactionProgress({ currentIndex, totalIndex }: Parameters[0]) { if (totalIndex) { console.log(`Fetched ${currentIndex} governance txs of ${totalIndex}`); @@ -483,32 +432,19 @@ export class NodeRegistryService extends BaseRegistryService { } } - updateGraphProgress({ type, fromBlock, toBlock, count }: Parameters[0]) { - if (toBlock) { - console.log(`fromBlock - ${fromBlock}`); - console.log(`toBlock - ${toBlock}`); - - if (count) { - console.log(`downloaded ${type} events from graph node count - ${count}`); - console.log('____________________________________________'); - console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock}\n`); - } - } - } - async getEventsFromDB() { - return await getEventsFromDB(this); + return await getEventsFromDB(this); } async getEventsFromCache() { - return await getEventsFromCache(this); + return await getEventsFromCache(this); } - async saveEvents({ events, lastBlock }: BaseEvents) { + async saveEvents({ events, lastBlock }: BaseEvents) { const eventTable = new Table(); eventTable.push( - [{ colSpan: 2, content: 'Registered Relayers', hAlign: 'center' }], + [{ colSpan: 2, content: 'Relayer Registry', hAlign: 'center' }], ['Network', `${this.netId} chain`], ['Events', `${events.length} events`], [{ colSpan: 2, content: 'Latest events' }], @@ -522,7 +458,7 @@ export class NodeRegistryService extends BaseRegistryService { }), ); - await saveEvents(this, { events, lastBlock }, eventTable); + await saveEvents(this, { events, lastBlock }, eventTable); } async getRelayersFromDB(): Promise { @@ -600,3 +536,73 @@ export class NodeRegistryService extends BaseRegistryService { } } } + +export type NodeRevenueServiceConstructor = BaseRevenueServiceConstructor & NodeServiceConstructor; + +export class NodeRevenueService extends BaseRevenueService { + cacheDirectory: string; + userDirectory: string; + + constructor(serviceConstructor: NodeRevenueServiceConstructor) { + super(serviceConstructor); + + const { cacheDirectory, userDirectory } = serviceConstructor; + + this.cacheDirectory = cacheDirectory; + this.userDirectory = userDirectory; + } + + updateEventProgress({ type, fromBlock, toBlock, count }: Parameters[0]) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + + if (count) { + console.log(`downloaded ${type} events count - ${count}`); + console.log('____________________________________________'); + console.log(`Fetched ${type} events from ${fromBlock} to ${toBlock}\n`); + } + } + } + + updateTransactionProgress({ currentIndex, totalIndex }: Parameters[0]) { + if (totalIndex) { + console.log(`Fetched ${currentIndex} txs of ${totalIndex}`); + } + } + + updateBlockProgress({ currentIndex, totalIndex }: Parameters[0]) { + if (totalIndex) { + console.log(`Fetched ${currentIndex} blocks of ${totalIndex}`); + } + } + + async getEventsFromDB() { + return await getEventsFromDB(this); + } + + async getEventsFromCache() { + return await getEventsFromCache(this); + } + + async saveEvents({ events, lastBlock }: BaseEvents) { + const eventTable = new Table(); + + eventTable.push( + [{ colSpan: 2, content: 'Stake Burned', hAlign: 'center' }], + ['Network', `${this.netId} chain`], + ['Events', `${events.length} events`], + [{ colSpan: 2, content: 'Latest events' }], + ...events + .slice(events.length - 10) + .reverse() + .map(({ blockNumber }, index) => { + const eventIndex = events.length - index; + + return [eventIndex, blockNumber]; + }), + ); + + await saveEvents(this, { events, lastBlock }, eventTable); + } +} diff --git a/yarn.lock b/yarn.lock index 60a0ec5..1f83c54 100644 --- a/yarn.lock +++ b/yarn.lock @@ -52,6 +52,16 @@ resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw== +"@ensdomains/content-hash@2.5.7": + version "2.5.7" + resolved "https://registry.yarnpkg.com/@ensdomains/content-hash/-/content-hash-2.5.7.tgz#180e4ceb6e585a05d69ba307619d4a0cf12948f1" + integrity sha512-WNdGKCeubMIAfyPYTMlKeX6cgXKIEo42OcWPOLBiclzJwMibkVqpaGgWKVH9dniJq7bLXLa2tQ0k/F1pt6gUxA== + dependencies: + cids "^1.1.5" + js-base64 "^3.6.0" + multicodec "^3.2.0" + multihashes "^2.0.0" + "@esbuild/aix-ppc64@0.21.5": version "0.21.5" resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz#c7184a326533fcdf1b8ee0733e21c713b975575f" @@ -680,6 +690,11 @@ semver "^7.5.4" uuid "^9.0.1" +"@multiformats/base-x@^4.0.1": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@multiformats/base-x/-/base-x-4.0.1.tgz#95ff0fa58711789d53aefb2590a8b7a4e715d121" + integrity sha512-eMk0b9ReBbV23xXU693TAIrLyeO5iTgBZGSJfpqriG8UkYvr/hC9u9pyMlAakDNHWmbhMZCDs6KQO0jzKD8OTw== + "@noble/curves@1.2.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.2.0.tgz#92d7e12e4e49b23105a2555c6984d41733d65c35" @@ -785,10 +800,11 @@ "@openzeppelin/contracts-v3" "npm:@openzeppelin/contracts@3.2.0-rc.0" ethers "^6.13.4" -"@tornado/core@git+https://git.tornado.ws/tornadocontrib/tornado-core.git#f411159f15566cb0cfe46d07b1c2c4eb23af2e1f": +"@tornado/core@git+https://git.tornado.ws/tornadocontrib/tornado-core.git#092989ebaa2fcd84eff7d4aed66433e77c790c60": version "1.0.19" - resolved "git+https://git.tornado.ws/tornadocontrib/tornado-core.git#f411159f15566cb0cfe46d07b1c2c4eb23af2e1f" + resolved "git+https://git.tornado.ws/tornadocontrib/tornado-core.git#092989ebaa2fcd84eff7d4aed66433e77c790c60" dependencies: + "@ensdomains/content-hash" "2.5.7" "@metamask/eth-sig-util" "^8.0.0" "@tornado/contracts" "git+https://git.tornado.ws/tornadocontrib/tornado-contracts.git#1b1d707878c16a3dc60d295299d4f0e7ce6ba831" "@tornado/fixed-merkle-tree" "^0.7.3" @@ -1139,6 +1155,11 @@ resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== +"@zxing/text-encoding@0.9.0": + version "0.9.0" + resolved "https://registry.yarnpkg.com/@zxing/text-encoding/-/text-encoding-0.9.0.tgz#fb50ffabc6c7c66a0c96b4c03e3d9be74864b70b" + integrity sha512-U/4aVJ2mxI0aDNI8Uq0wEhMgY+u4CNtEb0om3+y3+niDAsoTCOB33UF0sxpzqzdqXLqmvc+vZyAt4O8pPdfkwA== + acorn-import-attributes@^1.9.5: version "1.9.5" resolved "https://registry.yarnpkg.com/acorn-import-attributes/-/acorn-import-attributes-1.9.5.tgz#7eb1557b1ba05ef18b5ed0ec67591bfab04688ef" @@ -1367,6 +1388,18 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== +base-x@^3.0.8: + version "3.0.10" + resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.10.tgz#62de58653f8762b5d6f8d9fe30fa75f7b2585a75" + integrity sha512-7d0s06rR9rYaIWHkpfLIFICM/tkSVdoPC9qYAQRpxn9DdKNWNsKC0uk++akckyLq16Tx2WIinnZ6WRriAt6njQ== + dependencies: + safe-buffer "^5.0.1" + +base64-js@^1.3.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" + integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== + bech32@1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" @@ -1481,6 +1514,14 @@ buffer-from@^1.0.0: resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== +buffer@^5.5.0, buffer@^5.6.0: + version "5.7.1" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" + integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.1.13" + call-bind@^1.0.2, call-bind@^1.0.5, call-bind@^1.0.6, call-bind@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.7.tgz#06016599c40c56498c18769d2730be242b6fa3b9" @@ -1554,6 +1595,16 @@ chrome-trace-event@^1.0.2: resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.4.tgz#05bffd7ff928465093314708c93bdfa9bd1f0f5b" integrity sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ== +cids@^1.1.5: + version "1.1.9" + resolved "https://registry.yarnpkg.com/cids/-/cids-1.1.9.tgz#402c26db5c07059377bcd6fb82f2a24e7f2f4a4f" + integrity sha512-l11hWRfugIcbGuTZwAM5PwpjPPjyb6UZOGwlHSnOBV5o07XhQ4gNpBN67FbODvpjyHtd+0Xs6KNvUcGBiDRsdg== + dependencies: + multibase "^4.0.1" + multicodec "^3.0.1" + multihashes "^4.0.1" + uint8arrays "^3.0.0" + circomlibjs@0.1.7: version "0.1.7" resolved "https://registry.yarnpkg.com/circomlibjs/-/circomlibjs-0.1.7.tgz#9f5a7d9a23323744b11ee456b05b0cd81f48b554" @@ -2801,6 +2852,11 @@ idb@^8.0.0: resolved "https://registry.yarnpkg.com/idb/-/idb-8.0.0.tgz#33d7ed894ed36e23bcb542fb701ad579bfaad41f" integrity sha512-l//qvlAKGmQO31Qn7xdzagVPPaHTxXx199MhrAFuVBTPqydcPYBWjkrbv4Y0ktB+GmWOiwHl237UUOrLmQxLvw== +ieee754@^1.1.13: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" + integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== + ignore@^4.0.6: version "4.0.6" resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" @@ -2891,6 +2947,14 @@ ip-address@^9.0.5: jsbn "1.1.0" sprintf-js "^1.1.3" +is-arguments@^1.0.4: + version "1.1.1" + resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.1.1.tgz#15b3f88fda01f2a97fec84ca761a560f123efa9b" + integrity sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA== + dependencies: + call-bind "^1.0.2" + has-tostringtag "^1.0.0" + is-array-buffer@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/is-array-buffer/-/is-array-buffer-3.0.4.tgz#7a1f92b3d61edd2bc65d24f130530ea93d7fae98" @@ -2969,6 +3033,13 @@ is-fullwidth-code-point@^3.0.0: resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== +is-generator-function@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/is-generator-function/-/is-generator-function-1.0.10.tgz#f1558baf1ac17e0deea7c0415c438351ff2b3c72" + integrity sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A== + dependencies: + has-tostringtag "^1.0.0" + is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" @@ -3039,7 +3110,7 @@ is-symbol@^1.0.2, is-symbol@^1.0.3: dependencies: has-symbols "^1.0.2" -is-typed-array@^1.1.13: +is-typed-array@^1.1.13, is-typed-array@^1.1.3: version "1.1.13" resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.13.tgz#d6c5ca56df62334959322d7d7dd1cca50debe229" integrity sha512-uZ25/bUAlUY5fR4OKT4rZQEBrzQWYV9ZJYGGsUmEJ6thodVJ1HX64ePQ6Z0qPWP+m+Uq6e9UugrE38jeYsDSMw== @@ -3077,6 +3148,11 @@ jest-worker@^27.4.5: merge-stream "^2.0.0" supports-color "^8.0.0" +js-base64@^3.6.0: + version "3.7.7" + resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-3.7.7.tgz#e51b84bf78fbf5702b9541e2cb7bfcb893b43e79" + integrity sha512-7rCnleh0z2CkXhH67J8K1Ytz0b2Y+yxTPL+/KOJoa20hfnVQ/3/T6W/KflYI4bRHRagNeXeU2bkNGI3v1oS/lw== + js-sha3@0.8.0, js-sha3@^0.8.0: version "0.8.0" resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" @@ -3371,6 +3447,54 @@ ms@^2.1.1, ms@^2.1.3: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== +multibase@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/multibase/-/multibase-2.0.0.tgz#e20a2a14813fa435dc69c702909209ac0741919e" + integrity sha512-xIrqUVsinSlFjqj+OtEgCJ6MRl5hXjHMBPWsUt1ZGSRMx8rzm+7hCLE4wDeSA3COomlUC9zHCoUlvWjvAMtfDg== + dependencies: + base-x "^3.0.8" + buffer "^5.5.0" + web-encoding "^1.0.2" + +multibase@^4.0.1: + version "4.0.6" + resolved "https://registry.yarnpkg.com/multibase/-/multibase-4.0.6.tgz#6e624341483d6123ca1ede956208cb821b440559" + integrity sha512-x23pDe5+svdLz/k5JPGCVdfn7Q5mZVMBETiC+ORfO+sor9Sgs0smJzAjfTbM5tckeCqnaUuMYoz+k3RXMmJClQ== + dependencies: + "@multiformats/base-x" "^4.0.1" + +multicodec@^3.0.1, multicodec@^3.2.0: + version "3.2.1" + resolved "https://registry.yarnpkg.com/multicodec/-/multicodec-3.2.1.tgz#82de3254a0fb163a107c1aab324f2a91ef51efb2" + integrity sha512-+expTPftro8VAW8kfvcuNNNBgb9gPeNYV9dn+z1kJRWF2vih+/S79f2RVeIwmrJBUJ6NT9IUPWnZDQvegEh5pw== + dependencies: + uint8arrays "^3.0.0" + varint "^6.0.0" + +multiformats@^9.4.2: + version "9.9.0" + resolved "https://registry.yarnpkg.com/multiformats/-/multiformats-9.9.0.tgz#c68354e7d21037a8f1f8833c8ccd68618e8f1d37" + integrity sha512-HoMUjhH9T8DDBNT+6xzkrd9ga/XiBI4xLr58LJACwK6G3HTOPeMz4nB4KJs33L2BelrIJa7P0VuNaVF3hMYfjg== + +multihashes@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/multihashes/-/multihashes-2.0.0.tgz#4fa599d2d726ec6de33bf1e6f6d9f04b2351ace9" + integrity sha512-Mp94Y+7h3oWQx8JickVghlWR6VhRPDnlv/KZEUyNP0ISSkNEe3kQkWoyIGt1B45D6cTLoulg+MP6bugVewx32Q== + dependencies: + buffer "^5.6.0" + multibase "^2.0.0" + varint "^5.0.0" + web-encoding "^1.0.2" + +multihashes@^4.0.1: + version "4.0.3" + resolved "https://registry.yarnpkg.com/multihashes/-/multihashes-4.0.3.tgz#426610539cd2551edbf533adeac4c06b3b90fb05" + integrity sha512-0AhMH7Iu95XjDLxIeuCOOE4t9+vQZsACyKZ9Fxw2pcsRmlX4iCn1mby0hS0bb+nQOVpdQYWPpnyusw4da5RPhA== + dependencies: + multibase "^4.0.1" + uint8arrays "^3.0.0" + varint "^5.0.2" + mute-stream@0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" @@ -3859,7 +3983,7 @@ safe-array-concat@^1.1.2: has-symbols "^1.0.3" isarray "^2.0.5" -safe-buffer@^5.1.0, safe-buffer@^5.2.0, safe-buffer@~5.2.0: +safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.2.0, safe-buffer@~5.2.0: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -4446,6 +4570,13 @@ typical@^5.2.0: resolved "https://registry.yarnpkg.com/typical/-/typical-5.2.0.tgz#4daaac4f2b5315460804f0acf6cb69c52bb93066" integrity sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg== +uint8arrays@^3.0.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/uint8arrays/-/uint8arrays-3.1.1.tgz#2d8762acce159ccd9936057572dade9459f65ae0" + integrity sha512-+QJa8QRnbdXVpHYjLoTpJIdCTiw9Ir62nocClWuXIq2JIh4Uta0cQsTSpFL678p2CN8B+XSApwcU+pQEqVpKWg== + dependencies: + multiformats "^9.4.2" + unbox-primitive@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.2.tgz#29032021057d5e6cdbd08c5129c226dff8ed6f9e" @@ -4486,6 +4617,17 @@ util-deprecate@^1.0.1: resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== +util@^0.12.3: + version "0.12.5" + resolved "https://registry.yarnpkg.com/util/-/util-0.12.5.tgz#5f17a6059b73db61a875668781a1c2b136bd6fbc" + integrity sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA== + dependencies: + inherits "^2.0.3" + is-arguments "^1.0.4" + is-generator-function "^1.0.7" + is-typed-array "^1.1.3" + which-typed-array "^1.1.2" + uuid@^9.0.1: version "9.0.1" resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30" @@ -4496,6 +4638,16 @@ v8-compile-cache-lib@^3.0.1: resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== +varint@^5.0.0, varint@^5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/varint/-/varint-5.0.2.tgz#5b47f8a947eb668b848e034dcfa87d0ff8a7f7a4" + integrity sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow== + +varint@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/varint/-/varint-6.0.0.tgz#9881eb0ce8feaea6512439d19ddf84bf551661d0" + integrity sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg== + wasmbuilder@0.0.16: version "0.0.16" resolved "https://registry.yarnpkg.com/wasmbuilder/-/wasmbuilder-0.0.16.tgz#f34c1f2c047d2f6e1065cbfec5603988f16d8549" @@ -4531,6 +4683,15 @@ watchpack@^2.4.1: glob-to-regexp "^0.4.1" graceful-fs "^4.1.2" +web-encoding@^1.0.2: + version "1.1.5" + resolved "https://registry.yarnpkg.com/web-encoding/-/web-encoding-1.1.5.tgz#fc810cf7667364a6335c939913f5051d3e0c4864" + integrity sha512-HYLeVCdJ0+lBYV2FvNZmv3HJ2Nt0QYXqZojk3d9FJOLkwnuhzM9tmamh8d7HPM8QqjKH8DeHkFTx+CFlWpZZDA== + dependencies: + util "^0.12.3" + optionalDependencies: + "@zxing/text-encoding" "0.9.0" + web-worker@1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/web-worker/-/web-worker-1.2.0.tgz#5d85a04a7fbc1e7db58f66595d7a3ac7c9c180da" @@ -4640,7 +4801,7 @@ which-module@^2.0.0: resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.1.tgz#776b1fe35d90aebe99e8ac15eb24093389a4a409" integrity sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ== -which-typed-array@^1.1.14, which-typed-array@^1.1.15: +which-typed-array@^1.1.14, which-typed-array@^1.1.15, which-typed-array@^1.1.2: version "1.1.15" resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.15.tgz#264859e9b11a649b388bfaaf4f767df1f779b38d" integrity sha512-oV0jmFtUky6CXfkqehVvBP/LSWJ2sy4vWMioiENyJLePrBO/yKyV9OyJySfAKosh+RYkIl5zJCNZ8/4JncrpdA==