PHP WebShell
Текущая директория: /usr/lib/node_modules/bitgo/node_modules/@vechain/sdk-core/dist
Просмотр файла: index.mjs.map
{"version":3,"sources":["../src/core.ts","../src/vcdm/Hex.ts","../src/vcdm/abi/ABI.ts","../src/vcdm/abi/ABIItem.ts","../src/vcdm/abi/ABIEvent.ts","../src/vcdm/abi/ABIFunction.ts","../src/vcdm/abi/ABIContract.ts","../src/vcdm/account/Account.ts","../src/vcdm/Txt.ts","../src/vcdm/FixedPointNumber.ts","../src/vcdm/HexInt.ts","../src/vcdm/HexUInt.ts","../src/vcdm/hash/Sha256.ts","../src/secp256k1/Secp256k1.ts","../src/hdkey/HDKey.ts","../src/vcdm/hash/Keccak256.ts","../src/vcdm/Address.ts","../src/vcdm/BlockRef.ts","../src/vcdm/hash/Blake2b256.ts","../src/vcdm/BloomFilter.ts","../src/vcdm/currency/Coin.ts","../src/vcdm/currency/Units.ts","../src/vcdm/currency/VET.ts","../src/vcdm/currency/VTHO.ts","../src/vcdm/currency/Token.ts","../src/vcdm/encoding/rlp/kind/ScalarKind.ts","../src/vcdm/encoding/rlp/RLP.ts","../src/vcdm/encoding/rlp/RLPProfiler.ts","../src/vcdm/encoding/rlp/helpers/numerickind.ts","../src/vcdm/encoding/rlp/helpers/hexblobkind.ts","../src/vcdm/encoding/rlp/helpers/fixedhexblobkind.ts","../src/vcdm/encoding/rlp/helpers/compactfixedhexblobkind.ts","../src/vcdm/encoding/rlp/kind/BufferKind.ts","../src/vcdm/encoding/rlp/kind/NumericKind.ts","../src/vcdm/encoding/rlp/kind/hexblob/HexBlobKind.ts","../src/vcdm/encoding/rlp/kind/hexblob/FixedHexBlobKind.ts","../src/vcdm/encoding/rlp/kind/hexblob/OptionalFixedHexBlobKind.ts","../src/vcdm/encoding/rlp/kind/hexblob/CompactFixedHexBlobKind.ts","../src/vcdm/Mnemonic.ts","../src/vcdm/Quantity.ts","../src/vcdm/Revision.ts","../src/vcdm/BlockId.ts","../src/certificate/Certificate.ts","../src/keystore/cryptography/ethers/const/keystore.ts","../src/keystore/cryptography/ethers/keystore.ts","../src/keystore/cryptography/experimental/keystore.ts","../src/keystore/keystore.ts","../src/utils/const/abi.ts","../src/utils/const/data.ts","../src/utils/data/data.ts","../src/utils/const/network.ts","../src/transaction/Clause.ts","../src/transaction/TransactionType.ts","../src/transaction/Transaction.ts"],"names":["core_exports","__export","ABI","ABIContract","ABIEvent","ABIFunction","ABIItem","Account","Address","Blake2b256","BlockId","BlockRef","BloomFilter","BufferKind","Certificate","Clause","Coin","CompactFixedHexBlobKind","ERC1155_ABI","ERC20_ABI","ERC721_ABI","FixedHexBlobKind","FixedPointNumber","HDKey","Hex","HexBlobKind","HexInt","HexUInt","Keccak256","MAINNET_NETWORK","Mnemonic","NUMERIC_REGEX","NumericKind","OptionalFixedHexBlobKind","Quantity","RLP","RLPProfiler","Revision","SOLO_NETWORK","ScalarKind","Secp256k1","Sha256","TESTNET_NETWORK","ThorId","Token","Transaction","TransactionType","Txt","Units","VET","VIP180_ABI","VIP181_ABI","VIP210_ABI","VTHO","VTHO_ADDRESS","ZERO_ADDRESS","ZERO_BYTES","assertCompactFixedHexBlobBuffer","assertFixedHexBlobKindBuffer","assertFixedHexBlobKindData","assertValidHexBlobKindData","assertValidNumericKindBuffer","dataUtils","decodeBufferToHexWithLeadingZeros","decodeBufferToNumberOrHex","encodeBigIntToBuffer","encodeCompactFixedHexBlob","fromTransactionType","keystore","networkInfo","toTransactionType","validateNumericKindData","_Hex","sign","digits","normalize","InvalidOperation","that","thisBytes","thatBytes","i","compareByte","cue","InvalidDataType","exp","dataView","e","bytes","compact","stripped","compactDigits","_ABI","types","values","parseAbiParameters","type","index","value","error","InvalidAbiDataToEncodeOrDecode","dataEncoded","hexDataEncoded","parsedAbiParams","decodeAbiParameters","obj","recursiveParse","currentObj","currentValues","key","abiParametersEncoded","encodeAbiParameters","signature","toFunctionSignature","parseAbiItem","ABIItemConstructor","formatType","toFunctionHash","_ABIEvent","InvalidAbiItem","abi","eventData","viemDecodeEventLog","topic","t","event","rawDecodedData","dataToEncode","topics","dataTypes","dataValues","param","valuesToEncode","valuesToEncodeLength","encodeEventTopics","data","decodeFunctionData","encodeFunctionData","decodeFunctionResult","resultDecoded","_ABIContract","name","functionAbiItem","getAbiItem","eventAbiItem","functionName","functionData","encodedFunctionInput","encodedFunctionOutput","eventName","eventArgs","eventToDecode","eventLogDecoded","address","balance","transactions","transaction","typeDiff","addressDiff","codeDiff","_Txt","_FixedPointNumber","fd","sv","ef","delta","dividend","divisor","decimalPlaces","dp","cmp","minFixedDigits","modulo","multiplicand","multiplicator","exponent","base","result","sf","iteration","actualResult","storedResult","decimalSeparator","padded","decimals","integers","integersShow","decimalsShow","str","sub","fc","di","ie","fe","_HexInt","bi","hex","_HexUInt","hint","_Sha256","hash","_Secp256k1","publicKey","x","y","isYOdd","S","privateKey","isCompressed","nc_secp256k1","InvalidSecp256k1PrivateKey","resolve","reject","bytesLength","nh_randomBytes","messageHash","sig","InvalidSecp256k1MessageHash","InvalidSecp256k1Signature","recovery","words","path","master","ht","InvalidHDKeyMnemonic","InvalidHDKey","chainCode","header","Q","checksum","expandedPrivateKey","base58","expandedPublicKey","component","derivationPath","_Keccak256","nh_keccak_256","_Address","huint","stringAddress","pad","addressChecksummed","publicKeyInflated","publicKeyHash","mnemonic","root","_BlockRef","_Blake2b256","nh_blake2b","_BloomFilter","k","we","distribute","bit","m","other","joinedBytes","keys","builder","BloomFilterBuilder","_BloomFilterBuilder","nBytes","bits","nBits","UINT32_LIMIT","addAndWrapAsUInt32","a","b","collision","bitPos","code","formatEther","wei","formatUnits","unit","fpn","parseEther","ether","parseUnits","_VET","_VTHO","valueUnits","diffUnits","convertUnits","displayDecimals","whole","fraction","decimal","_RLP","EthereumjsRLP","bytesToNumberBE","InvalidRLP","encodedData","profile","context","kind","item","part","packed","parts","_RLPProfiler","validObject","packedData","_validateNumericKindNumber","_validateNumericKindString","num","isHexUInt","isDecimal","buf","maxBytes","buffer","zeroIndex","byte","dataBI","_context","encoder","decoder","_Mnemonic","_that","numberOfWords","xt","wordlistSize","randomGenerator","strength","numberOfBytes","wordlist","wordsToValidate","_Quantity","_Revision","txtValue","_BlockId","_ThorId","blockId","_Certificate","purpose","payload","domain","timestamp","signer","object","fastJsonStableStringify","CertificateSignatureMismatch","SCRYPT_PARAMS","encrypt","password","derivePublicKey","keystoreAccount","encryptOptions","keystoreJsonString","ethers","decrypt","isValid","InvalidKeystore","stringifyData","InvalidKeystoreParams","KEYSTORE_CRYPTO_CIPHER","KEYSTORE_CRYPTO_PARAMS_DKLEN","KEYSTORE_CRYPTO_KDF","KEYSTORE_VERSION","decodeScryptParams","salt","M","N","r","p","dkLen","encodeScryptParams","options","encryptKeystore","kdf","scrypt","iv","uuidRandom","macPrefix","ciphertext","ctr","uuidV4","decryptKeystore","copy","EXPERIMENTAL_CRYPTOGRAPHY","useExperimentalCryptography","experimentalCryptography","VeChainSDKLogger","size","decodeBytes32String","valueInBytes","firstZeroIndex","firstNotZeroIndex","encodeBytes32String","zeroPadding","ze","mainnetGenesisBlock","testnetGenesisBlock","soloGenesisBlock","_Clause","to","comment","contractAddress","functionAbi","args","amount","clauseOptions","contractBytecode","deployParams","senderAddress","recipientAddress","tokenId","vthoAddress","token","TRANSACTION_TYPE_VALUES","VALID_TRANSACTION_TYPES","InvalidTransactionType","_Transaction","body","gasPayer","gasPayerPublicKey","UnavailableTransactionField","NotDelegatedTransaction","z","rawTransaction","isSigned","rawPrefix","txType","decodedRLPBody","bodyWithoutReservedField","correctTransactionBody","sender","txHash","clauses","sum","clause","isValidCommonFields","isValidEip1559Fields","isValidLegacyFields","InvalidTransactionField","senderPrivateKey","gasPayerPrivateKey","senderHash","transactionHash","gasPayerHash","reserved","featuresField","encodedBody","featuresList","expectedSignatureLength"],"mappings":";;;;;;;;;;;;;;;;;;;;;8FAAAA,IAAAA,EAAAA,CAAA,GAAAC,EAAAD,CAAAA,EAAAA,CAAA,SAAAE,CAAA,CAAA,WAAA,CAAA,IAAAC,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CAAAA,CAAAA,CAAY,qCACtB,CAAA,CAAE,OAGCvX,CAAAA,CAAAA,CAAY,SACfwX,CACA,CAAA,IAAA,CAAK,eAAoB,GAAA,SAAA,CACnBD,CAAY,CAAA,wCAAA,CACZA,EAAY,uCACtB,CAAA,CAAE,OACN,CAaQ,mBAAoC,EAAA,CAExC,IAAM4B,CAAW,CAAA,IAAA,CAAK,KAAK,QAAY,EAAA,GAIjCG,CAAe,CAAA,CAFA/B,CAAY,CAAA,YAAA,CAAa,IAIrC,CAAA,IAAA,CAAK4B,EAAS,QAAY,EAAA,CAAA,CAAG5B,CAAY,CAAA,YAAA,CAAa,IAAI,CAAA,CAC1D,QACL,CAAA,GAAI4B,CAAS,CAAA,MAAA,EAAU,EAC3B,EAEA,KAAOG,CAAAA,CAAa,OAAS,CACrBA,EAAAA,CAAAA,CAAaA,EAAa,MAAS,CAAA,CAAC,CAAE,CAAA,MAAA,GAAW,CACjDA,EAAAA,CAAAA,CAAa,KAKrB,CAAA,OAAOA,CACX,CAQA,OAAe,WAAA,CAAY9B,EAAgC,CAMvD,OAAA,CAAA,CAAA,CAJiBA,CAAK,CAAA,QAAA,EAAY,EAAC,EAET,UAAY,CAEnB,EAAA,CAAA,IAAO,CAC9B,CASA,OAAe,uBACXA,CACA7S,CAAAA,CAAAA,CACO,CAEP,IAAM4U,CAA0B,CAAA,IAAA,CAAK,YAAY/B,CAAI,CAAA,CAC/CpX,CAAU,CAAA,gBAAA,CAAmB,CAC7BA,CAAAA,CAAAA,CAAU,iBAEhB,OAAOuE,CAAAA,CAAU,MAAW4U,GAAAA,CAChC,CACJ","file":"index.mjs","sourcesContent":["// Our core library\nexport * from './certificate';\nexport * from './hdkey';\nexport * from './keystore';\nexport * from './secp256k1';\nexport * from './transaction';\nexport * from './utils';\nexport * from './vcdm';\n","import * as nc_utils from '@noble/curves/abstract/utils';\nimport * as nh_utils from '@noble/hashes/utils';\nimport { InvalidDataType, InvalidOperation } from '@vechain/sdk-errors';\nimport { type VeChainDataModel } from './VeChainDataModel';\n\n/**\n * Represents a hexadecimal value expressed as\n * * `-` sign if the value is negative,\n * * `0x` hexadecimal notation tag,\n * * a not empty string of hexadecimal digits from `0` to `9` and from `a` to `f`.\n *\n * @description This hexadecimal notation is coherent with the decimal notation:\n * * the sign is only expressed for negative values, and it is always the first symbol,\n * * the `0x` tags the string as a hexadecimal expression,\n * * hexadecimal digits follow.\n * * An empty content results is no digits.\n *\n * @implements {VeChainDataModel<Hex>}\n */\nclass Hex implements VeChainDataModel<Hex> {\n /**\n * Negative multiplier of the {@link digits} absolute value.\n *\n * @type {number}\n */\n protected static readonly NEGATIVE: number = -1;\n\n /**\n * Positive multiplier of the {@link digits} absolute value.\n *\n * @type {number}\n */\n protected static readonly POSITIVE: number = 1;\n\n /**\n * A constant string prefix used in hexadecimal notation.\n */\n public static readonly PREFIX = '0x';\n\n /**\n * The radix used for representing numbers base 16 in a positional numeral notation system.\n *\n * @typedef {number} RADIX\n */\n public static readonly RADIX: number = 16;\n\n /**\n * Regular expression for matching hexadecimal strings.\n * An empty input is represented as a empty digits.\n *\n * @type {RegExp}\n */\n private static readonly REGEX_HEX: RegExp = /^-?(0x)?[0-9a-f]*$/i;\n\n /**\n * Regular expression pattern to match a prefix indicating hexadecimal number.\n *\n * @type {RegExp}\n */\n protected static readonly REGEX_HEX_PREFIX: RegExp = /^-?0x/i;\n\n /**\n * Returns the hexadecimal digits expressing this absolute value, sign and `0x` prefix omitted.\n\n * @remarks An empty content results in an empty string returned.\n */\n public readonly digits: string;\n\n /**\n * Represents the sign multiplier of a given number:\n * * {@link NEGATIVE} `-1` if negative,\n * * {@link POSITIVE} `1` if positive.\n */\n public readonly sign: number;\n\n /**\n * Creates a new instance of this class to represent the value\n * built multiplying `sign` for the absolute value expressed by the hexadecimal `digits`.\n *\n * @param {number} sign - The sign of the value.\n * @param {string} digits - The digits of the absolute value in hexadecimal base.\n * @param {function} [normalize] - The function used to normalize the digits. Defaults to converting digits to lowercase.\n */\n protected constructor(\n sign: number,\n digits: string,\n normalize: (digits: string) => string = (digits) => digits.toLowerCase()\n ) {\n this.digits = normalize(digits);\n this.sign = sign;\n }\n\n /**\n * Returns the absolute value of this Hex object.\n *\n * @return {Hex} A new Hex object representing the absolute value of this Hex.\n */\n public get abs(): Hex {\n return new Hex(Hex.POSITIVE, this.digits);\n }\n\n /**\n * Returns the value of `bi` as a `BigInt` type.\n *\n * @returns {bigint} The value of `bi` as a `BigInt`.\n */\n get bi(): bigint {\n return BigInt(this.sign) * nc_utils.hexToNumber(this.digits);\n }\n\n /**\n * Returns the Uint8Array representation of the aligned bytes.\n *\n * @return {Uint8Array} The Uint8Array representation of the aligned bytes.\n */\n get bytes(): Uint8Array {\n return nc_utils.hexToBytes(this.alignToBytes().digits);\n }\n\n /**\n * Returns the value of n.\n *\n * @return {number} The value of n.\n *\n * @throws {InvalidOperation<Hex>} Throws an error if this instance doesn't represent\n * an [IEEE 754 double precision 64 bits floating point format](https://en.wikipedia.org/wiki/Double-precision_floating-point_format).\n */\n get n(): number {\n if (this.isNumber()) {\n // The sign is part of the IEEE 754 representation hence no need to consider `this.sign` property.\n return new DataView(this.bytes.buffer).getFloat64(0);\n }\n throw new InvalidOperation('Hex.n', 'not an IEEE 754 float 64 number', {\n hex: this.toString()\n });\n }\n\n /**\n * Aligns the hexadecimal string to bytes by adding a leading '0' if the string length is odd.\n *\n * @returns {Hex} - The aligned hexadecimal string.\n */\n public alignToBytes(): Hex {\n return this.digits.length % 2 === 0\n ? this\n : new Hex(this.sign, '0' + this.digits);\n }\n\n /**\n * Compares the current Hex object with another Hex object.\n *\n * @param {Hex} that - The Hex object to compare with.\n *\n * @return {number} - Returns a negative number if the current Hex object is less than the given Hex object,\n * zero if they are equal, or a positive number if the current Hex object is greater than the given Hex object.\n */\n compareTo(that: Hex): number {\n if (this.sign === that.sign) {\n const digits = Math.max(this.digits.length, that.digits.length);\n const thisBytes = this.fit(digits).bytes;\n const thatBytes = that.fit(digits).bytes;\n let i = 0;\n let compareByte = 0;\n while (compareByte === 0 && i < thisBytes.length) {\n compareByte = thisBytes[i] - thatBytes[i];\n i++;\n }\n return compareByte;\n }\n return this.sign - that.sign;\n }\n\n /**\n * Returns a new instance of the Hex class, its value fits to the specified number of digits.\n *\n * @param {number} digits - The number of digits to fit the Hex value into.\n *\n * @returns {Hex} - A new Hex instance that represents the fitted Hex value.\n *\n * @throws {InvalidDataType} - If the Hex value cannot be fit into the specified number of digits.\n */\n public fit(digits: number): Hex {\n if (digits < this.digits.length) {\n // Cut.\n let cue = 0;\n while (\n this.digits.length - cue > digits &&\n this.digits.at(cue) === '0'\n ) {\n cue++;\n }\n if (this.digits.length - cue === digits) {\n return new Hex(this.sign, this.digits.slice(cue));\n }\n throw new InvalidDataType(\n 'Hex.fit',\n `can't fit in ${digits} digits`,\n { digits, hex: this }\n );\n }\n if (digits > this.digits.length) {\n // Pad.\n return new Hex(\n this.sign,\n '0'.repeat(digits - this.digits.length) + this.digits\n );\n }\n return this;\n }\n\n /**\n * Determines whether this Hex instance is equal to the given Hex instance.\n *\n * @param {Hex} that - The Hex instance to compare with.\n * @return {boolean} - True if the Hex instances are equal, otherwise false.\n */\n isEqual(that: Hex): boolean {\n return this.compareTo(that) === 0;\n }\n\n /**\n * Checks if this instance expresses a valid {@link Number} value\n * according the\n * [IEEE 754 double precision 64 bits floating point format](https://en.wikipedia.org/wiki/Double-precision_floating-point_format).\n *\n * @returns {boolean} Returns true if this instance expresses 32 hex digits (16 bytes, 128 bits) needed to represent\n * a {@link Number} value, else it returns false.\n */\n isNumber(): boolean {\n return this.digits.length === 32;\n }\n\n /**\n * Checks if the given string expression is a valid hexadecimal value.\n *\n * @param {string} exp - The string representation of a hexadecimal value.\n *\n * @return {boolean} - True if the expression is a valid hexadecimal value, case-insensitive,\n * optionally prefixed with `0x`; false otherwise.\n */\n public static isValid(exp: string): boolean {\n return Hex.REGEX_HEX.test(exp);\n }\n\n /**\n * Determines whether the given string is a valid hexadecimal number prefixed with '0x'.\n *\n * @param {string} exp - The string to be evaluated.\n * @return {boolean} - True if the string is a valid hexadecimal number prefixed with '0x', otherwise false.\n */\n public static isValid0x(exp: string): boolean {\n return Hex.REGEX_HEX_PREFIX.test(exp) && Hex.isValid(exp);\n }\n\n /**\n * Create a Hex instance from a bigint, number, string, or Uint8Array.\n *\n * @param {bigint | number | string | Uint8Array} exp - The value to represent in a Hex instance:\n * * bigint is always representable in hexadecimal base notation;\n * * number, encoded as [IEEE 754 double precision 64 bits floating point format](https://en.wikipedia.org/wiki/Double-precision_floating-point_format);\n * * string is parsed as the hexadecimal expression of a bigint value, optionally tagged with `0x`;\n * * Uint8Array is interpreted as the sequence of bytes.\n *\n * @returns {Hex} - A Hex instance representing the input value.\n *\n * @throws {InvalidDataType} if the given `exp` can't be represented as a hexadecimal expression.\n */\n public static of(exp: bigint | number | string | Uint8Array): Hex {\n try {\n if (typeof exp === 'bigint') {\n if (exp < 0n) {\n return new Hex(\n this.NEGATIVE,\n nc_utils.numberToHexUnpadded(-1n * exp)\n );\n }\n return new Hex(\n this.POSITIVE,\n nc_utils.numberToHexUnpadded(exp)\n );\n } else if (typeof exp === 'number') {\n const dataView = new DataView(new ArrayBuffer(16));\n dataView.setFloat64(0, exp);\n return new Hex(\n exp < 0 ? this.NEGATIVE : this.POSITIVE,\n nc_utils.bytesToHex(new Uint8Array(dataView.buffer))\n );\n } else if (typeof exp === 'string') {\n if (!this.isValid(exp)) {\n throw new InvalidDataType(\n 'Hex.of',\n 'not an hexadecimal string',\n { exp }\n );\n }\n if (exp.startsWith('-')) {\n return new Hex(\n this.NEGATIVE,\n this.REGEX_HEX_PREFIX.test(exp)\n ? exp.slice(3)\n : exp.slice(1)\n );\n }\n return new Hex(\n this.POSITIVE,\n this.REGEX_HEX_PREFIX.test(exp) ? exp.slice(2) : exp\n );\n }\n return new Hex(this.POSITIVE, nc_utils.bytesToHex(exp));\n } catch (e) {\n throw new InvalidDataType(\n 'Hex.of',\n 'not an hexadecimal expression',\n { exp: `${exp}` }, // Needed to serialize bigint values.\n e\n );\n }\n }\n\n /**\n * Generates a random Hex value of the given number of bytes length.\n *\n * @param {number} bytes - The number of bytes to generate.\n * @throws {InvalidDataType} - If the bytes argument is not greater than 0.\n * @returns {Hex} - A randomly generated Hex value.\n *\n * @remarks Security auditable method, depends on\n * * [`nh_utils.randomBytes`](https://github.com/paulmillr/noble-hashes?tab=readme-ov-file#utils).\n */\n public static random(bytes: number): Hex {\n if (bytes > 0) {\n return Hex.of(nh_utils.randomBytes(bytes));\n }\n throw new InvalidDataType('Hex.random', 'bytes argument not > 0', {\n bytes\n });\n }\n\n /**\n * Returns a string representation of the object.\n *\n * @param {boolean} compact - Whether to compact the string representation.\n * @return {string} The string representation of the object.\n */\n public toString(compact: boolean = false): string {\n if (compact) {\n const stripped = this.digits.replace(/^0+/, '');\n const compactDigits = stripped === '' ? '0' : stripped;\n return (this.sign < 0 ? '-0x' : '0x') + compactDigits;\n }\n\n return (this.sign < 0 ? '-0x' : '0x') + this.digits;\n }\n}\n\nexport { Hex };\n","import {\n InvalidAbiDataToEncodeOrDecode,\n InvalidOperation\n} from '@vechain/sdk-errors';\nimport {\n decodeAbiParameters,\n encodeAbiParameters,\n parseAbiParameters,\n type AbiParameter\n} from 'viem';\nimport { Hex } from '../Hex';\nimport { type VeChainDataModel } from '../VeChainDataModel';\n\n/**\n * Represents an ABI (Application Binary Interface).\n * @extends VeChainDataModel\n */\nclass ABI implements VeChainDataModel<ABI> {\n private readonly types: readonly AbiParameter[];\n private readonly values: unknown[];\n /**\n * ABI constructor from types and values.\n *\n * @param {string | AbiParameter[]} types - A list of ABI types representing the types of the values.\n * @param {unknown[]} values - An array of values according to the specified ABI types.\n **/\n protected constructor(\n types: string | AbiParameter[] = [],\n values: unknown[] = []\n ) {\n this.types =\n typeof types === 'string' ? parseAbiParameters(types) : types;\n this.values = values;\n }\n\n /**\n * Compares the current ABI instance with another ABI instance.\n * @param that The ABI to compare with.\n * @returns {number} A non-zero number if the current ABI is different to the other ABI or zero if they are equal.\n * @override {@link VeChainDataModel#compareTo}\n * @remark The comparison is done by comparing the types and values of the ABI instances.\n **/\n public compareTo(that: ABI): number {\n this.types.forEach((type, index) => {\n if (type !== that.types[index]) {\n return -1;\n }\n });\n this.values.forEach((value, index) => {\n if (value !== that.values[index]) {\n return 1;\n }\n });\n\n return 0;\n }\n\n /**\n * Checks if the current ABI object is equal to the given ABI object.\n * @param that The ABI object to compare with.\n * @returns {boolean} True if the objects are equal, false otherwise.\n * @override {@link VeChainDataModel#isEqual}\n * @remark The comparison is done by comparing the types and values of the ABI instances.\n **/\n public isEqual(that: ABI): boolean {\n return this.compareTo(that) === 0;\n }\n\n /**\n * Throws an exception because the ABI cannot be represented as a big integer.\n * @returns {bigint} The BigInt representation of the ABI.\n * @throws {InvalidOperation} The ABI cannot be represented as a bigint.\n * @override {@link VeChainDataModel#bi}\n * @remark The conversion to BigInt is not supported for an ABI.\n */\n public get bi(): bigint {\n throw new InvalidOperation(\n 'ABI.bi',\n 'There is no big integer representation for an ABI.',\n { data: '' }\n );\n }\n\n /**\n * Encodes the values according to the specified ABI types when creating the ABI instance.\n *\n * @returns The ABI-encoded bytes representing the given values.\n * @throws {InvalidAbiDataToEncodeOrDecode, InvalidDataType}\n */\n public get bytes(): Uint8Array {\n return this.toHex().bytes;\n }\n\n /**\n * Throws an exception because the ABI cannot be represented as a number.\n * @returns {bigint} The number representation of the ABI.\n * @throws {InvalidOperation} The mnemonic cannot be represented as a number.\n * @override {@link VeChainDataModel#n}\n * @remark The conversion to number is not supported for an ABI.\n */\n public get n(): number {\n throw new InvalidOperation(\n 'ABI.n',\n 'There is no number representation for an ABI.',\n { data: '' }\n );\n }\n\n /**\n * Instantiates an ABI object from the given types and values.\n * @param {string | AbiParameter[]} types ABI parameters representing the types of the values.\n * @param {unknown[]} values ABI values.\n * @returns {ABI} The ABI object with the given types and values.\n */\n public static of(types: string | AbiParameter[], values: unknown[]): ABI {\n try {\n return new ABI(types, values);\n } catch (error) {\n throw new InvalidAbiDataToEncodeOrDecode(\n 'ABI.of',\n 'Types and values must be valid ABI parameters.',\n {\n types,\n values\n },\n error\n );\n }\n }\n\n /**\n * Decodes the ABI values from the given ABI types and encoded data.\n * @param {string| AbiParameter[]} types The list of ABI types representing the types of the values to decode.\n * @param {Hex} dataEncoded The encoded data to decode.\n * @returns An ABI instance with the decoded values.\n */\n public static ofEncoded(\n types: string | AbiParameter[],\n dataEncoded: string | Uint8Array\n ): ABI {\n try {\n const hexDataEncoded = Hex.of(dataEncoded);\n let values: readonly unknown[];\n if (typeof types === 'string') {\n const parsedAbiParams = parseAbiParameters(types);\n values = decodeAbiParameters(\n parsedAbiParams,\n hexDataEncoded.bytes\n );\n } else {\n values = decodeAbiParameters([...types], hexDataEncoded.bytes);\n }\n return new ABI(types, [...values]);\n } catch (error) {\n throw new InvalidAbiDataToEncodeOrDecode(\n 'ABI.of',\n 'Decoding failed: Data must be a valid ABI type with corresponding valid data.',\n {\n types,\n data: dataEncoded\n },\n error\n );\n }\n }\n\n /**\n * Recursively parses an object and collects the values of each attribute into an array,\n * with nested arrays for nested objects.\n * @param {object} obj - The object to parse.\n * @returns {unknown[]} An array of values from the object, with nested arrays for nested objects.\n */\n public parseObjectValues(obj: object): unknown[] {\n const values: unknown[] = [];\n\n const recursiveParse = (currentObj: object): unknown[] => {\n const currentValues: unknown[] = [];\n for (const key in currentObj) {\n if (Object.prototype.hasOwnProperty.call(currentObj, key)) {\n const value = (currentObj as never)[key];\n if (typeof value === 'object' && value !== null) {\n currentValues.push(recursiveParse(value));\n } else {\n currentValues.push(value);\n }\n }\n }\n return currentValues;\n };\n\n values.push(...recursiveParse(obj));\n return values;\n }\n\n /**\n * It gets the first decoded value from the ABI.\n * @returns {ReturnType} The first decoded value from the ABI.\n */\n public getFirstDecodedValue<ReturnType>(): ReturnType {\n if (this.values[0] instanceof Object) {\n return this.parseObjectValues(\n this.values[0] as object\n ) as ReturnType;\n }\n return this.values[0] as ReturnType;\n }\n\n /**\n * Parses an ABI to its Hex representation.\n * @returns {Hex} The Hex representation of the ABI.\n */\n public toHex(): Hex {\n try {\n const abiParametersEncoded = encodeAbiParameters(\n this.types,\n this.values\n );\n return Hex.of(abiParametersEncoded);\n } catch (error) {\n throw new InvalidAbiDataToEncodeOrDecode(\n 'ABI.toHex',\n 'Encoding failed: Data must be a valid ABI type with corresponding valid data.',\n {\n types: this.types,\n values: this.values\n },\n error\n );\n }\n }\n}\n\nexport { ABI };\n","import {\n parseAbiItem,\n toFunctionHash,\n toFunctionSignature,\n type AbiEvent,\n type AbiFunction\n} from 'viem';\nimport { ABI } from './ABI';\n\ntype SignatureType = string | AbiFunction | AbiEvent;\n\n/**\n * Represents an ABI (Application Binary Interface) item.\n * @extends ABI\n */\nabstract class ABIItem extends ABI {\n public readonly signature: AbiFunction | AbiEvent;\n public readonly stringSignature: string;\n\n /**\n * ABIItem constructor from item (Event, Function...) signature.\n *\n * @param {SignatureType} signature - The signature of the ABI item (Function, Event...).\n **/\n public constructor(signature: SignatureType) {\n super();\n switch (typeof signature) {\n case 'string':\n this.stringSignature = signature;\n break;\n case 'object':\n this.stringSignature = toFunctionSignature(signature);\n break;\n default:\n this.stringSignature = '';\n }\n this.signature =\n typeof signature === 'string'\n ? parseAbiItem([signature])\n : signature;\n }\n\n public static ofSignature<T extends ABIItem>(\n ABIItemConstructor: new (signature: string) => T,\n signature: string\n ): T;\n\n public static ofSignature<T extends ABIItem>(\n ABIItemConstructor: new (signature: AbiFunction) => T,\n signature: AbiFunction\n ): T;\n\n public static ofSignature<T extends ABIItem>(\n ABIItemConstructor: new (signature: AbiEvent) => T,\n signature: AbiEvent\n ): T;\n\n /**\n * Returns and instance of an ABIItem from a signature.\n * @param ABIItemConstructor ABIItem constructor.\n * @param {SignatureType} signature Signature of the ABIIItem.\n * @returns {T} An instance of the ABIItem.\n */\n public static ofSignature<T extends ABIItem>(\n ABIItemConstructor: new (signature: SignatureType) => T,\n signature: SignatureType\n ): T {\n return new ABIItemConstructor(signature);\n }\n\n /**\n * Returns a string representation of a JSON object or a string.\n * @param {'json' | 'string'} formatType Either JSON or String\n * @returns The string representation of the ABI item.\n */\n public format(formatType: 'json' | 'string' = 'string'): string {\n return formatType === 'json'\n ? JSON.stringify(this.signature)\n : this.stringSignature;\n }\n\n /**\n * The signature hash of the ABIItem.\n * @returns {string} The signature hash of the ABIItem.\n * @remarks Wrapper for {@link toFunctionHash}.\n **/\n public get signatureHash(): string {\n return toFunctionHash(this.stringSignature);\n }\n\n /**\n * Compares the current ABIItem instance with another ABIItem instance.\n * @param {ABIItem} that The item to compare with.\n * @returns {number} A non-zero number if the current ABIItem is different to the other ABI or zero if they are equal.\n * @override {@link VeChainDataModel#compareTo}\n **/\n public override compareTo(that: ABIItem): number {\n if (super.compareTo(that) !== 0) {\n return -1;\n }\n return this.stringSignature.localeCompare(that.stringSignature);\n }\n}\n\nexport { ABIItem };\n","import {\n InvalidAbiDataToEncodeOrDecode,\n InvalidAbiItem\n} from '@vechain/sdk-errors';\nimport { type AbiEventParameter } from 'abitype';\nimport {\n type AbiEvent,\n type ContractEventName,\n type DecodeEventLogReturnType,\n encodeEventTopics,\n type EncodeEventTopicsReturnType,\n type Abi as ViemABI,\n decodeEventLog as viemDecodeEventLog,\n type Hex as ViemHex\n} from 'viem';\nimport { Hex } from '../Hex';\nimport { ABI } from './ABI';\nimport { ABIItem } from './ABIItem';\n\ntype Topics = [] | [signature: ViemHex, ...args: ViemHex[]];\n\ninterface ABIEventData {\n data: Hex;\n topics: Array<null | Hex | Hex[]>;\n}\n\n/**\n * Represents a function call in the Event ABI.\n * @extends ABIItem\n */\nclass ABIEvent<\n TAbi extends ViemABI = ViemABI,\n TEventName extends ContractEventName<TAbi> = ContractEventName<TAbi>\n> extends ABIItem {\n private readonly abiEvent: AbiEvent;\n public constructor(signature: string);\n public constructor(signature: AbiEvent);\n public constructor(signature: string | AbiEvent) {\n try {\n super(signature);\n this.abiEvent = this.signature as AbiEvent;\n } catch (error) {\n throw new InvalidAbiItem(\n 'ABIEvent constructor',\n 'Initialization failed: Cannot create Event ABI. Event format is invalid.',\n {\n type: 'event',\n value: signature\n },\n error\n );\n }\n }\n\n /**\n * Decode event log data using the event's ABI.\n *\n * @param abi - Event to decode.\n * @returns Decoding results.\n * @throws {InvalidAbiDataToEncodeOrDecode}\n */\n public static parseLog<\n TAbi extends ViemABI,\n TEventName extends ContractEventName<TAbi>\n >(\n abi: TAbi,\n eventData: ABIEventData\n ): DecodeEventLogReturnType<TAbi, TEventName> {\n try {\n return viemDecodeEventLog({\n abi,\n data: eventData.data.toString() as ViemHex,\n topics: eventData.topics.map((topic) => {\n if (topic === null) {\n return topic;\n } else if (Array.isArray(topic)) {\n return topic.map((t) => t.toString());\n }\n return topic.toString();\n }) as Topics\n });\n } catch (error) {\n throw new InvalidAbiDataToEncodeOrDecode(\n 'ABIEvent.parseLog',\n 'Decoding failed: Data must be a valid hex string encoding a compliant ABI type.',\n {\n data: {\n abi,\n data: eventData.data,\n topics: eventData.topics\n }\n },\n error\n );\n }\n }\n\n /**\n * Decode event log data using the event's ABI.\n *\n * @param event - Event to decode.\n * @returns Decoding results.\n * @throws {InvalidAbiDataToEncodeOrDecode}\n */\n public decodeEventLog(\n event: ABIEventData\n ): DecodeEventLogReturnType<TAbi, TEventName> {\n try {\n return ABIEvent.parseLog([this.abiEvent] as ViemABI, event);\n } catch (error) {\n throw new InvalidAbiDataToEncodeOrDecode(\n 'ABIEvent.decodeEventLog',\n 'Decoding failed: Data must be a valid hex string encoding a compliant ABI type.',\n { data: event },\n error\n );\n }\n }\n\n /**\n * Decode event log data as an array of values\n * @param {ABIEvent} event The data to decode.\n * @returns {unknown[]} The decoded data as array of values.\n */\n public decodeEventLogAsArray(event: ABIEventData): unknown[] {\n const rawDecodedData = this.decodeEventLog(event);\n\n if (rawDecodedData.args === undefined) {\n return [];\n }\n\n return this.parseObjectValues(rawDecodedData.args as unknown as object);\n }\n\n /**\n * Encode event log data returning the encoded data and topics.\n * @param dataToEncode - Data to encode.\n * @returns {ABIEventData} Encoded data along with topics.\n * @remarks There is no equivalent to encodeEventLog in viem {@link https://viem.sh/docs/ethers-migration}. Discussion started here {@link https://github.com/wevm/viem/discussions/2676}.\n */\n public encodeEventLog(dataToEncode: unknown[]): ABIEventData {\n try {\n const topics = this.encodeFilterTopics(dataToEncode);\n const dataTypes: AbiEventParameter[] = [];\n const dataValues: unknown[] = [];\n this.abiEvent.inputs.forEach((param, index) => {\n if (param.indexed ?? false) {\n // Skip indexed parameters\n return;\n }\n const value = dataToEncode[index];\n dataTypes.push(param);\n dataValues.push(value);\n });\n return {\n data: ABI.of(dataTypes, dataValues).toHex(),\n topics: topics.map((topic) => {\n if (topic === null) {\n return topic;\n } else if (Array.isArray(topic)) {\n return topic.map((t) => Hex.of(t));\n }\n return Hex.of(topic);\n })\n };\n } catch (error) {\n throw new InvalidAbiDataToEncodeOrDecode(\n 'ABIEvent.encodeEventLog',\n 'Encoding failed: Data format is invalid. Event data must be correctly formatted for ABI-compliant encoding.',\n { dataToEncode },\n error\n );\n }\n }\n\n /**\n * Encode event log topics using the event's ABI.\n *\n * @param valuesToEncode - values to encode as topics. Non-indexed values are ignored.\n * Only the values of the indexed parameters are needed.\n * @returns Encoded topics array.\n * @throws {InvalidAbiDataToEncodeOrDecode}\n */\n public encodeFilterTopics(\n valuesToEncode: Record<string, unknown> | unknown[] | undefined\n ): EncodeEventTopicsReturnType {\n const valuesToEncodeLength = Array.isArray(valuesToEncode)\n ? valuesToEncode.length\n : Object.values(valuesToEncode ?? {}).length;\n if (this.abiEvent.inputs.length < valuesToEncodeLength) {\n throw new InvalidAbiDataToEncodeOrDecode(\n 'ABIEvent.encodeEventLog',\n 'Encoding failed: Data format is invalid. Number of values to encode is greater than the inputs.',\n { valuesToEncode }\n );\n }\n\n try {\n return encodeEventTopics({\n abi: [this.abiEvent],\n args: valuesToEncode\n });\n } catch (error) {\n throw new InvalidAbiDataToEncodeOrDecode(\n 'ABIEvent.encodeEventLog',\n 'Encoding failed: Data format is invalid. Event topics values must be correctly formatted for ABI-compliant encoding.',\n { valuesToEncode },\n error\n );\n }\n }\n\n /**\n * Encode event log topics using the event's ABI, replacing null values with undefined.\n * @param valuesToEncode - values to encode as topics. Non-indexed values are ignored.\n * Only the values of the indexed parameters are needed.\n * @returns Encoded topics array.\n * @throws {InvalidAbiDataToEncodeOrDecode}\n */\n public encodeFilterTopicsNoNull(\n valuesToEncode: Record<string, unknown> | unknown[] | undefined\n ): Array<string | undefined> {\n const encodedTopics = this.encodeFilterTopics(\n valuesToEncode\n ) as unknown as Array<string | undefined>;\n return encodedTopics.map((topic) =>\n topic === null ? undefined : topic\n );\n }\n}\n\nexport { ABIEvent, type ABIEventData };\n","import {\n InvalidAbiDataToEncodeOrDecode,\n InvalidAbiItem\n} from '@vechain/sdk-errors';\nimport {\n type AbiFunction,\n type ContractFunctionName,\n decodeFunctionData,\n type DecodeFunctionDataReturnType,\n decodeFunctionResult,\n type DecodeFunctionResultReturnType,\n encodeFunctionData,\n type Abi as ViemABI,\n type Hex as ViemHex\n} from 'viem';\nimport { Hex } from '../Hex';\nimport { ABIItem } from './ABIItem';\n\n/**\n * Represents a function call in the Function ABI.\n * @extends ABIItem\n */\nclass ABIFunction<\n TAbi extends ViemABI = ViemABI,\n TFunctionName extends\n ContractFunctionName<TAbi> = ContractFunctionName<TAbi>\n> extends ABIItem {\n private readonly abiFunction: AbiFunction;\n public constructor(signature: string);\n public constructor(signature: AbiFunction);\n public constructor(signature: string | AbiFunction) {\n try {\n super(signature);\n this.abiFunction = this.signature as AbiFunction;\n } catch (error) {\n throw new InvalidAbiItem(\n 'ABIFunction constructor',\n 'Initialization failed: Cannot create Function ABI. Function format is invalid.',\n {\n type: 'function',\n value: signature\n },\n error\n );\n }\n }\n\n /**\n * Get the function selector.\n * @returns {string} The function selector.\n * @override {@link ABIItem#signatureHash}\n */\n public get signatureHash(): string {\n return super.signatureHash.substring(0, 10);\n }\n\n /**\n * Decode data using the function's ABI.\n *\n * @param {Hex} data - Data to decode.\n * @returns Decoding results.\n * @throws {InvalidAbiDataToEncodeOrDecode}\n */\n public decodeData(\n data: Hex\n ): DecodeFunctionDataReturnType<TAbi, TFunctionName> {\n try {\n return decodeFunctionData({\n abi: [this.abiFunction],\n data: data.toString() as ViemHex\n });\n } catch (error) {\n throw new InvalidAbiDataToEncodeOrDecode(\n 'ABIFunction.decodeData',\n 'Decoding failed: Data must be a valid hex string encoding a compliant ABI type.',\n { data },\n error\n );\n }\n }\n\n /**\n * Encode data using the function's ABI.\n *\n * @param dataToEncode - Data to encode.\n * @returns {Hex} Encoded data.\n * @throws {InvalidAbiDataToEncodeOrDecode}\n */\n public encodeData<TValue>(dataToEncode?: TValue[]): Hex {\n try {\n return Hex.of(\n encodeFunctionData({\n abi: [this.abiFunction],\n args: dataToEncode\n })\n );\n } catch (e) {\n throw new InvalidAbiDataToEncodeOrDecode(\n 'ABIFunction.encodeData',\n 'Encoding failed: Data format is invalid. Function data does not match the expected format for ABI type encoding.',\n { dataToEncode },\n e\n );\n }\n }\n\n /**\n * Decodes the output data from a transaction based on ABI (Application Binary Interface) specifications.\n * This method attempts to decode the given hex-like data into a readable format using the contract's interface.\n *\n * @param {Hex} data - The data to be decoded, typically representing the output of a contract function call.\n * @returns {DecodeFunctionResultReturnType} An object containing the decoded data.\n * @throws {InvalidAbiDataToEncodeOrDecode}\n *\n * @example\n * ```typescript\n * const decoded = abiFunctionInstance.decodeResult(rawTransactionOutput);\n * console.log('Decoded Output:', decoded);\n * ```\n */\n public decodeResult(\n data: Hex\n ): DecodeFunctionResultReturnType<TAbi, TFunctionName> {\n try {\n const result = decodeFunctionResult({\n abi: [this.abiFunction],\n data: data.toString() as ViemHex\n });\n\n return result as DecodeFunctionResultReturnType<\n TAbi,\n TFunctionName\n >;\n } catch (error) {\n throw new InvalidAbiDataToEncodeOrDecode(\n 'ABIFunction.decodeResult',\n 'Decoding failed: Data must be a valid hex string encoding a compliant ABI type.',\n { data },\n error\n );\n }\n }\n\n /**\n * Decodes a function output returning an array of values.\n * @param {Hex} data The data to be decoded\n * @returns {unknown[]} The decoded data as array of values\n */\n public decodeOutputAsArray(data: Hex): unknown[] {\n const resultDecoded = this.decodeResult(data);\n if (this.abiFunction.outputs.length > 1) {\n return this.parseObjectValues(resultDecoded as object);\n } else if (\n this.abiFunction.outputs.length === 1 &&\n this.abiFunction.outputs[0].type === 'tuple'\n ) {\n return [this.parseObjectValues(resultDecoded as object)];\n }\n return [resultDecoded];\n }\n}\nexport { ABIFunction };\n","import {\n InvalidAbiDataToEncodeOrDecode,\n InvalidAbiItem\n} from '@vechain/sdk-errors';\nimport {\n getAbiItem,\n type AbiEvent,\n type AbiFunction,\n type ContractEventName,\n type ContractFunctionName,\n type DecodeEventLogReturnType,\n type DecodeFunctionDataReturnType,\n type DecodeFunctionResultReturnType,\n type Abi as ViemABI\n} from 'viem';\nimport { type Hex } from '../Hex';\nimport { ABI } from './ABI';\nimport { ABIEvent, type ABIEventData } from './ABIEvent';\nimport { ABIFunction } from './ABIFunction';\n\nclass ABIContract<TAbi extends ViemABI> extends ABI {\n private readonly viemABI: ViemABI;\n\n constructor(readonly abi: TAbi) {\n super();\n this.viemABI = abi as ViemABI;\n }\n\n /**\n * Creates an ABIContract instance from a viem ABI.\n * @param {ViemABI} abi representation of the contract.\n * @returns New instance of ABIContract.\n */\n public static ofAbi<TAbi extends ViemABI>(abi: TAbi): ABIContract<TAbi> {\n return new ABIContract(abi);\n }\n\n /**\n * Returns the function with the given name.\n * @param {string} name The function's name.\n * @returns {ABIFunction} The function with the given name.\n * @throws {InvalidAbiItem}\n */\n public getFunction<TFunctionName extends ContractFunctionName<TAbi>>(\n name: TFunctionName | string\n ): ABIFunction<TAbi, TFunctionName> {\n const functionAbiItem = getAbiItem({\n abi: this.viemABI,\n name: name as string\n });\n if (functionAbiItem === null || functionAbiItem === undefined) {\n throw new InvalidAbiItem(\n 'ABIContract.getFunction()',\n `Function '${name}' not found in contract ABI.`,\n {\n type: 'function',\n value: name\n }\n );\n }\n return new ABIFunction<TAbi, TFunctionName>(\n functionAbiItem as AbiFunction\n );\n }\n\n /**\n * Returns the event with the given name.\n * @param {string} name The event's name.\n * @returns {ABIEvent} The event with the given name.\n * @throws {InvalidAbiItem}\n */\n public getEvent<TEventName extends ContractEventName<TAbi>>(\n name: TEventName | string\n ): ABIEvent<TAbi, TEventName> {\n const eventAbiItem = getAbiItem({\n abi: this.viemABI,\n name: name as string\n });\n if (eventAbiItem === null || eventAbiItem === undefined) {\n throw new InvalidAbiItem(\n 'ABIContract.getEvent()',\n `Function '${name}' not found in contract ABI.`,\n {\n type: 'event',\n value: name\n }\n );\n }\n return new ABIEvent<TAbi, TEventName>(eventAbiItem as AbiEvent);\n }\n\n /**\n * Encode function data that can be used to send a transaction.\n * @param {string} functionName The name of the function defined in the ABI.\n * @param {unknown[]} functionData The data to pass to the function.\n * @returns {Hex} The encoded data in hexadecimal that can be used to send a transaction.\n * @throws {InvalidAbiDataToEncodeOrDecode}\n */\n public encodeFunctionInput<\n TFunctionName extends ContractFunctionName<TAbi>\n >(functionName: TFunctionName | string, functionData?: unknown[]): Hex {\n try {\n const functionAbiItem = getAbiItem({\n abi: this.viemABI,\n name: functionName as string\n });\n const functionAbi = new ABIFunction<TAbi, TFunctionName>(\n functionAbiItem as AbiFunction\n );\n\n return functionAbi.encodeData(functionData);\n } catch (error) {\n throw new InvalidAbiDataToEncodeOrDecode(\n 'ABIContract.encodeFunctionInput()',\n `Encoding failed: Data format is invalid. Function data does not match the expected format for ABI type encoding.`,\n { functionName, functionData },\n error\n );\n }\n }\n\n /**\n * Decode the function data of an encoded function\n * @param {string} functionName The name of the function defined in the ABI.\n * @param {Hex} encodedFunctionInput The encoded function data.\n * @returns {DecodeFunctionDataReturnType} an array of the decoded function data\n * @throws {InvalidAbiDataToEncodeOrDecode}\n */\n public decodeFunctionInput<\n TFunctionName extends ContractFunctionName<TAbi>\n >(\n functionName: TFunctionName | string,\n encodedFunctionInput: Hex\n ): DecodeFunctionDataReturnType<TAbi, TFunctionName> {\n try {\n const functionAbiItem = getAbiItem({\n abi: this.viemABI,\n name: functionName as string\n });\n const functionAbi = new ABIFunction<TAbi, TFunctionName>(\n functionAbiItem as AbiFunction\n );\n\n return functionAbi.decodeData(encodedFunctionInput);\n } catch (error) {\n throw new InvalidAbiDataToEncodeOrDecode(\n 'ABIContract.decodeFunctionInput()',\n 'Decoding failed: Data must be a valid hex string encoding a compliant ABI type.',\n { functionName, encodedFunctionInput },\n error\n );\n }\n }\n\n /**\n * Decodes the output from a contract function using the specified ABI and function name.\n * It takes the encoded function output and attempts to decode it according to the ABI definition.\n *\n * @param {string} functionName - The name of the function in the contract to decode the output for.\n * @param {Hex} encodedFunctionOutput - The encoded output data from the contract function.\n * @returns {DecodeFunctionResultReturnType} - The decoded output, which provides a user-friendly way\n * to interact with the decoded data.\n * @throws {InvalidAbiDataToEncodeOrDecode}\n *\n * @example\n * // Example of decoding output for a function called \"getValue\":\n * const decodedOutput = decodeFunctionOutput('getValue', encodedValue);\n *\n */\n public decodeFunctionOutput<\n TFunctionName extends ContractFunctionName<TAbi>\n >(\n functionName: TFunctionName | string,\n encodedFunctionOutput: Hex\n ): DecodeFunctionResultReturnType<TAbi, TFunctionName> {\n try {\n const functionAbiItem = getAbiItem({\n abi: this.viemABI,\n name: functionName as string\n });\n const functionAbi = new ABIFunction<TAbi, TFunctionName>(\n functionAbiItem as AbiFunction\n );\n\n return functionAbi.decodeResult(encodedFunctionOutput);\n } catch (error) {\n throw new InvalidAbiDataToEncodeOrDecode(\n 'ABIContract.decodeFunctionOutput()',\n 'Decoding failed: Data must be a valid hex string encoding a compliant ABI type.',\n { functionName, encodedFunctionOutput },\n error\n );\n }\n }\n\n /**\n * Encodes event log data based on the provided event name, and data to encode.\n * @param {string} eventName - The name of the event to be encoded.\n * @param {unknown[]} eventArgs - An array of data to be encoded in the event log.\n * @returns {ABIEventData} An object containing the encoded data and topics.\n * @throws {InvalidAbiDataToEncodeOrDecode}\n */\n public encodeEventLog<TEventName extends ContractEventName<TAbi>>(\n eventName: TEventName | string,\n eventArgs: unknown[]\n ): ABIEventData {\n try {\n const eventAbiItem = getAbiItem({\n abi: this.viemABI,\n name: eventName as string\n });\n const eventAbi = new ABIEvent<TAbi, TEventName>(\n eventAbiItem as AbiEvent\n );\n return eventAbi.encodeEventLog(eventArgs);\n } catch (error) {\n throw new InvalidAbiDataToEncodeOrDecode(\n 'ABIContract.encodeEventLog()',\n `Encoding failed: Data format is invalid. Event data does not match the expected format for ABI type encoding.`,\n { eventName, dataToEncode: eventArgs },\n error\n );\n }\n }\n\n /**\n * Decodes event log data based on the provided event name, and data/topics to decode.\n * @param {string} eventName - The name of the event to be decoded.\n * @param {ABIEventData} eventToDecode - An object containing the data and topics to be decoded.\n * @returns {DecodeEventLogReturnType} The decoded data of the event log.\n * @throws {InvalidAbiDataToEncodeOrDecode}\n */\n public decodeEventLog<TEventName extends ContractEventName<TAbi>>(\n eventName: TEventName | string,\n eventToDecode: ABIEventData\n ): DecodeEventLogReturnType<TAbi, TEventName> {\n try {\n const eventAbiItem = getAbiItem({\n abi: this.viemABI,\n name: eventName as string\n });\n const eventAbi = new ABIEvent<TAbi, TEventName>(\n eventAbiItem as AbiEvent\n );\n return eventAbi.decodeEventLog(eventToDecode);\n } catch (error) {\n throw new InvalidAbiDataToEncodeOrDecode(\n 'ABIContract.encodeEventLog()',\n `Encoding failed: Data format is invalid. Event data does not match the expected format for ABI type encoding.`,\n { eventName, dataToDecode: eventToDecode },\n error\n );\n }\n }\n\n /**\n * Decodes a VeChain log based on the ABI definition.\n *\n * This method takes raw `data` and `topics` from a VeChain log and attempts\n * to decode them using the contract's ABI definition. If the decoding is successful,\n * it returns a log object representing the decoded information. If the decoding fails,\n * it throws a custom error with detailed information.\n *\n * @param {Hex} data - The hexadecimal string of the data field in the log.\n * @param {Hex[]} topics - An array of hexadecimal strings representing the topics of the log.\n * @returns {DecodeEventLogReturnType} - A log object representing the decoded log or null if decoding fails.\n * @throws {InvalidAbiDataToEncodeOrDecode}\n */\n public parseLog<TEventName extends ContractEventName<TAbi>>(\n data: Hex,\n topics: Hex[]\n ): DecodeEventLogReturnType<TAbi, TEventName> {\n try {\n return ABIEvent.parseLog(this.abi, {\n data,\n topics\n });\n } catch (e) {\n throw new InvalidAbiDataToEncodeOrDecode(\n 'ABIContract.parseLog()',\n `Decoding failed: Data must be a valid hex string encoding a compliant ABI type.`,\n { data, topics },\n e\n );\n }\n }\n\n /**\n *\n * Parses the log data and topics into an array of values.\n *\n * @param {Hex} data - The hexadecimal string of the data field in the log.\n * @param {Hex[]} topics - An array of hexadecimal strings representing the topics of the log.\n * @returns {unknown[]} - An array of values of the decoded log data.\n */\n public parseLogAsArray(data: Hex, topics: Hex[]): unknown[] {\n const eventLogDecoded = this.parseLog(data, topics);\n if (eventLogDecoded.args === undefined) {\n return [];\n }\n\n return this.parseObjectValues(\n eventLogDecoded.args as unknown as object\n );\n }\n}\n\nexport { ABIContract };\n","import { InvalidOperation } from '@vechain/sdk-errors';\nimport { type Address } from '../Address';\nimport { type Currency } from '../currency/Currency';\nimport { type VeChainDataModel } from '../VeChainDataModel';\n\ntype AccountType = 'EOA' | 'Contract';\n\n/**\n * Represents a VeChain account.\n *\n * @implements {VeChainDataModel<Account>}\n */\nclass Account implements VeChainDataModel<Account> {\n public readonly address: Address;\n public readonly balance: Currency;\n // Replace the string array with a Transaction class #1162\n public readonly transactions: string[];\n\n public readonly type: AccountType;\n\n constructor(\n address: Address,\n balance: Currency,\n type: AccountType = 'EOA',\n transactions?: string[]\n ) {\n this.address = address;\n this.balance = balance;\n this.type = type;\n this.transactions = transactions ?? [];\n }\n\n /**\n * Throws an exception because the account cannot be represented as a big integer.\n * @returns {bigint} The BigInt representation of the account.\n * @throws {InvalidOperation} The account cannot be represented as a bigint.\n * @override {@link VeChainDataModel#bi}\n * @remarks The conversion to BigInt is not supported for an account.\n */\n public get bi(): bigint {\n throw new InvalidOperation(\n 'Account.bi',\n 'There is no big integer representation for an account.',\n { data: '' }\n );\n }\n\n /**\n * Throws an exception because the account cannot be represented as a byte array.\n * @returns {Uint8Array} The byte array representation of the account.\n * @throws {InvalidOperation} The account cannot be represented as a byte array.\n * @override {@link VeChainDataModel#bytes}\n * @remarks The conversion to byte array is not supported for an account.\n */\n public get bytes(): Uint8Array {\n throw new InvalidOperation(\n 'Account.bytes',\n 'There is no bytes representation for an account.',\n { data: '' }\n );\n }\n\n /**\n * Throws an exception because the account cannot be represented as a number.\n * @returns {bigint} The number representation of the account.\n * @throws {InvalidOperation} The account cannot be represented as a number.\n * @override {@link VeChainDataModel#n}\n * @remarks The conversion to number is not supported for an account.\n */\n public get n(): number {\n throw new InvalidOperation(\n 'Account.n',\n 'There is no number representation for an account.',\n { data: '' }\n );\n }\n\n /**\n * Adds a transaction to the account.\n * @param {string} transaction The transaction to add.\n */\n public addTransaction(transaction: string): void {\n // Replace body once Transaction class is implemented #1162\n this.transactions.push(transaction);\n }\n\n /**\n * Compare this instance with `that` in a meaningful way.\n *\n * @param {Account} that object to compare.\n * @return a negative number if `this` < `that`, zero if `this` = `that`, a positive number if `this` > that`.\n * @override {@link VeChainDataModel#compareTo}\n */\n public compareTo(that: Account): number {\n const typeDiff = this.type.localeCompare(that.type);\n if (typeDiff === 0) {\n const addressDiff = this.address.compareTo(that.address);\n if (addressDiff === 0) {\n const codeDiff = this.balance.code.compareTo(that.balance.code);\n if (codeDiff === 0) {\n return this.balance.value.compareTo(that.balance.value);\n }\n return codeDiff;\n }\n return addressDiff;\n }\n return typeDiff;\n }\n\n /**\n * Checks if the given value is equal to the current instance.\n *\n * @param {Account} that - The value to compare.\n * @returns {boolean} - True if the values are equal, false otherwise.\n * @override {@link VeChainDataModel#isEqual}\n */\n public isEqual(that: Account): boolean {\n return this.compareTo(that) === 0;\n }\n\n /**\n * Returns a string representation of the account.\n *\n * @returns {string} A string representation of the account.\n */\n public toString(): string {\n return `${this.type} Address: ${this.address.toString()} Balance: ${this.balance.value} ${this.balance.code}`;\n }\n}\n\nexport { Account };\nexport type { AccountType };\n","import { InvalidOperation } from '@vechain/sdk-errors';\nimport { type VeChainDataModel } from './VeChainDataModel';\n\n/**\n * Represents a text string encoded according the *Normalization Form Canonical Composition*\n * [Unicode Equivalence](https://en.wikipedia.org/wiki/Unicode_equivalence).\n *\n * @implements {VeChainDataModel<Txt>}\n */\nclass Txt extends String implements VeChainDataModel<Txt> {\n /**\n * Decoder object used for decoding bytes as text data.\n *\n * @class\n * @constructor\n */\n private static readonly DECODER = new TextDecoder();\n\n /**\n * *Normalization Form Canonical Composition*\n * [Unicode Equivalence](https://en.wikipedia.org/wiki/Unicode_equivalence)\n * flag.\n *\n * @type {string}\n * @constant\n */\n private static readonly NFC = 'NFC';\n\n /**\n * A TextEncoder instance used for encoding text to bytes.\n *\n * @type {TextEncoder}\n */\n private static readonly ENCODER = new TextEncoder();\n\n /**\n * Creates a new instance of this class representing the `exp` string\n * normalized according the *Canonical Composition Form*\n * [Unicode Equivalence](https://en.wikipedia.org/wiki/Unicode_equivalence).\n *\n * @param {string} exp - The expression to be passed to the constructor.\n * @protected\n * @constructor\n */\n protected constructor(exp: string) {\n super(exp.normalize(Txt.NFC));\n }\n\n /**\n * Converts the current Txt string to a BigInt.\n *\n * @returns {bigint} The BigInt representation of the Txt string.\n *\n * @throws {InvalidOperation} If the conversion to BigInt fails because this Txt string doesn't represent an integer.\n */\n get bi(): bigint {\n try {\n return BigInt(this.toString());\n } catch (e) {\n throw new InvalidOperation(\n 'Txt.bi()',\n \"Can't cast to big integer\",\n { txt: this.toString() },\n e\n );\n }\n }\n\n /**\n * Converts the current Txt string to a buffer of bytes.\n *\n * @returns {Uint8Array} The bytes representation of the Txt string.\n */\n get bytes(): Uint8Array {\n return Txt.ENCODER.encode(this.toString());\n }\n\n /**\n * Returns the value of n as a number.\n *\n * @returns {number} The value of n as a number.\n */\n /**\n * Converts the current Txt string to a number.\n *\n * @returns {number} The numeric value of the Txt string.\n *\n * @throws {InvalidOperation} If the conversion to number fails because this Txt string doesn't represent a decimal number.\n */\n get n(): number {\n return Number(this.toString());\n }\n\n /**\n * Compares the current instance to another instance of Txt.\n *\n * @param {Txt} that - The instance to compare with.\n *\n * @return {number} - A negative number if the current instance is less than the specified instance,\n * zero if they are equal, or a positive number if the current instance is greater.\n */\n public compareTo(that: Txt): number {\n return this.toString().localeCompare(that.toString());\n }\n\n /**\n * Checks if the current Txt object is equal to the given Txt object.\n *\n * @param {Txt} that - The Txt object to compare with.\n *\n * @return {boolean} - True if the objects are equal, false otherwise.\n */\n public isEqual(that: Txt): boolean {\n return this.compareTo(that) === 0;\n }\n\n /**\n * Returns a string representation of the object.\n *\n * @returns {string} A string representation of the object.\n */\n public toString(): string {\n return this.valueOf();\n }\n\n /**\n * Creates a new Txt instance from the provided expression.\n *\n * @param {bigint | number | string | Uint8Array} exp - The expression to convert to Txt:\n * * {@link bigint} is represented as a {@link NFC} encoded string expressing the value in base 10;\n * * {@link number} is represented as a {@link NFC} encoded string expressing the value in base 10;\n * * {@link string} is encoded as {@link NFC} string;\n * * {@link Uint8Array} is {@link NFC} decoded to a string.\n *\n * @returns {Txt} - A new Txt instance.\n */\n public static of(exp: bigint | number | string | Uint8Array): Txt {\n if (typeof exp === 'string') {\n return new Txt(exp);\n } else if (typeof exp === 'bigint' || typeof exp === 'number') {\n return new Txt(exp.toString());\n }\n return new Txt(Txt.DECODER.decode(exp));\n }\n}\n\nexport { Txt };\n","import { InvalidDataType, InvalidOperation } from '@vechain/sdk-errors';\nimport { type VeChainDataModel } from './VeChainDataModel';\nimport { Txt } from './Txt';\n\n/**\n * Represents a fixed-point number for precision arithmetic.\n */\nclass FixedPointNumber implements VeChainDataModel<FixedPointNumber> {\n /**\n * Base of value notation.\n */\n private static readonly BASE = 10n;\n\n /**\n * The default number of decimal places to use for fixed-point math.\n *\n * @see\n * [bignumber.js DECIMAL_PLACES](https://mikemcl.github.io/bignumber.js/#decimal-places)\n *\n * @constant {bigint}\n */\n protected static readonly DEFAULT_FRACTIONAL_DECIMALS = 20n;\n\n /**\n * Not a Number.\n *\n * @remarks {@link fractionalDigits} and {@link scaledValue} not meaningful.\n *\n * @see [Number.NaN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NaN)\n *\n */\n public static readonly NaN = new FixedPointNumber(0n, 0n, NaN);\n\n /**\n * The negative Infinity value.\n *\n * @remarks {@link fractionalDigits} and {@link scaledValue} not meaningful.\n *\n * @see [Number.NEGATIVE_INFINITY](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY)\n */\n public static readonly NEGATIVE_INFINITY = new FixedPointNumber(\n 0n,\n 0n,\n Number.NEGATIVE_INFINITY\n );\n\n /**\n * Represents the one constant.\n */\n public static readonly ONE = FixedPointNumber.of(1n);\n\n /**\n * The positive Infinite value.\n *\n * @remarks {@link fractionalDigits} and {@link scaledValue} not meaningful.\n *\n * @see [Number.POSITIVE_INFINITY](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY)\n */\n public static readonly POSITIVE_INFINITY = new FixedPointNumber(\n 0n,\n 0n,\n Number.POSITIVE_INFINITY\n );\n\n /**\n * Regular expression pattern for matching integers expressed as base 10 strings.\n */\n private static readonly REGEX_INTEGER: RegExp = /^[-+]?\\d+$/;\n\n /**\n * Regular expression for matching numeric values expressed as base 10 strings.\n */\n private static readonly REGEX_NUMBER =\n /(^[-+]?\\d+(\\.\\d+)?)$|(^[-+]?\\.\\d+)$/;\n\n /**\n * Regular expression pattern for matching natural numbers expressed as base 10 strings.\n */\n private static readonly REGEX_NATURAL: RegExp = /^\\d+$/;\n\n /**\n * Represents the zero constant.\n */\n public static readonly ZERO = new FixedPointNumber(0n, 0n, 0);\n\n /**\n * Edge Flag denotes the {@link NaN} or {@link NEGATIVE_INFINITY} or {@link POSITIVE_INFINITY} value.\n *\n * @remarks If `ef` is not zero, {@link fractionalDigits} and {@link scaledValue} are not meaningful.\n */\n protected readonly edgeFlag: number;\n\n /**\n * Fractional Digits or decimal places.\n *\n * @see [bignumber.js precision](https://mikemcl.github.io/bignumber.js/#sd)\n */\n public readonly fractionalDigits: bigint;\n\n /**\n * Scaled Value = value * 10 ^ {@link fractionalDigits}.\n */\n public readonly scaledValue: bigint;\n\n /**\n * Returns the integer part of this FixedPointNumber value.\n *\n * @return {bigint} the integer part of this FixedPointNumber value.\n *\n * @throws {InvalidOperation} If the value is not finite.\n */\n get bi(): bigint {\n if (this.isFinite()) {\n return (\n this.scaledValue /\n FixedPointNumber.BASE ** this.fractionalDigits\n );\n }\n throw new InvalidOperation(\n 'FixedPointNumber.bi',\n 'not finite value cannot cast to big integer',\n { this: this.toString() }\n );\n }\n\n /**\n * Returns the array of bytes representing the *Normalization Form Canonical Composition*\n * [Unicode Equivalence](https://en.wikipedia.org/wiki/Unicode_equivalence)\n * of this value expressed in decimal base.\n */\n get bytes(): Uint8Array {\n return Txt.of(this.toString()).bytes;\n }\n\n /**\n * Return this value approximated as {@link number}.\n */\n get n(): number {\n if (this.isNaN()) return Number.NaN;\n if (this.isNegativeInfinite()) return Number.NEGATIVE_INFINITY;\n if (this.isPositiveInfinite()) return Number.POSITIVE_INFINITY;\n if (this.isZero()) return 0;\n return Number(this.scaledValue) * 10 ** -Number(this.fractionalDigits);\n }\n\n /**\n * Returns the new Fixed-Point Number (FixedPointNumber) instance having\n *\n * @param {bigint} fd - Number of Fractional Digits (or decimal places).\n * @param {bigint} sv - Scaled Value.\n * @param {number} [ef=0] - Edge Flag.\n */\n protected constructor(fd: bigint, sv: bigint, ef: number = 0) {\n this.fractionalDigits = fd;\n this.edgeFlag = ef;\n this.scaledValue = sv;\n }\n\n /**\n * Returns a FixedPointNumber whose value is the absolute value, i.e. the magnitude, of the value of this FixedPointNumber.\n *\n * @return {FixedPointNumber} the absolute value of this FixedPointNumber.\n *\n * @see [bignumber.js absoluteValue](https://mikemcl.github.io/bignumber.js/#abs)\n */\n public abs(): FixedPointNumber {\n if (this.isNaN()) return FixedPointNumber.NaN;\n if (this.isNegativeInfinite())\n return FixedPointNumber.POSITIVE_INFINITY;\n return new FixedPointNumber(\n this.fractionalDigits,\n this.scaledValue < 0n ? -this.scaledValue : this.scaledValue,\n this.edgeFlag\n );\n }\n\n /**\n * Compares this instance with `that` FixedPointNumber instance.\n * * Returns 0 if this is equal to `that` FixedPointNumber, including infinite with equal sign;\n * * Returns -1, if this is -Infinite or less than `that` FixedPointNumber;,\n * * Returns 1 if this is +Infinite or greater than `that` FixedPointNumber.\n *\n * @param {FixedPointNumber} that - The instance to compare with this instance.\n * @return {number} Returns -1, 0, or 1 if this instance is less than, equal to, or greater\n * than the specified instance, respectively.\n * @throw InvalidOperation If this or `that` FixedPointNumber is {@link NaN}.\n *\n * @see [bignumber.js comparedTo](https://mikemcl.github.io/bignumber.js/#cmp)\n */\n public compareTo(that: FixedPointNumber): number {\n if (this.isNaN() || that.isNaN())\n throw new InvalidOperation(\n 'FixedPointNumber.compareTo',\n 'compare between NaN',\n {\n this: `${this}`,\n that: `${that}`\n }\n );\n if (this.isNegativeInfinite())\n return that.isNegativeInfinite() ? 0 : -1;\n if (this.isPositiveInfinite()) return that.isPositiveInfinite() ? 0 : 1;\n if (that.isNegativeInfinite()) return 1;\n if (that.isPositiveInfinite()) return -1;\n const fd = this.maxFractionalDigits(that, this.fractionalDigits); // Max common fractional decimals.\n const delta = this.dp(fd).scaledValue - that.dp(fd).scaledValue;\n return delta < 0n ? -1 : delta === 0n ? 0 : 1;\n }\n\n /**\n * Compares this instance with `that` FixedPointNumber instance.\n * * **Returns `null` if either instance is NaN;**\n * * Returns 0 if this is equal to `that` FixedPointNumber, including infinite with equal sign;\n * * Returns -1, if this is -Infinite or less than `that` FixedPointNumber;,\n * * Returns 1 if this is +Infinite or greater than `that` FixedPointNumber.\n *\n * @param {FixedPointNumber} that - The instance to compare with this instance.\n * @return {null | number} A null if either instance is NaN;\n * -1, 0, or 1 if this instance is less than, equal to, or greater\n * than the specified instance, respectively.\n *\n * @remarks This method uses internally {@link compareTo} wrapping the {@link InvalidOperation} exception\n * when comparing between {@link NaN} values to behave according the\n * [[bignumber.js comparedTo](https://mikemcl.github.io/bignumber.js/#cmp)] rules.\n */\n public comparedTo(that: FixedPointNumber): null | number {\n try {\n return this.compareTo(that);\n } catch {\n return null;\n }\n }\n\n /**\n * Returns a FixedPointNumber whose value is the value of this FixedPointNumber divided by `that` FixedPointNumber.\n *\n * Limit cases\n * * 0 / 0 = NaN\n * * NaN / ±n = NaN\n * * ±Infinity / ±Infinity = NaN\n * * +n / NaN = NaN\n * * +n / ±Infinity = 0\n * * -n / 0 = -Infinity\n * * +n / 0 = +Infinity\n *\n * @param {FixedPointNumber} that - The fixed-point number to divide by.\n * @return {FixedPointNumber} The result of the division.\n *\n * @remarks The precision is the greater of the precision of the two operands.\n *\n * @see [bignumber.js dividedBy](https://mikemcl.github.io/bignumber.js/#div)\n */\n public div(that: FixedPointNumber): FixedPointNumber {\n if (this.isNaN() || that.isNaN()) return FixedPointNumber.NaN;\n if (this.isNegativeInfinite()) {\n if (that.isInfinite()) return FixedPointNumber.NaN;\n if (that.isPositive()) return FixedPointNumber.NEGATIVE_INFINITY;\n return FixedPointNumber.POSITIVE_INFINITY;\n }\n if (this.isPositiveInfinite()) {\n if (that.isInfinite()) return FixedPointNumber.NaN;\n if (that.isPositive()) return FixedPointNumber.POSITIVE_INFINITY;\n return FixedPointNumber.NEGATIVE_INFINITY;\n }\n if (that.isInfinite()) return FixedPointNumber.ZERO;\n if (that.isZero()) {\n if (this.isZero()) return FixedPointNumber.NaN;\n if (this.isNegative()) return FixedPointNumber.NEGATIVE_INFINITY;\n return FixedPointNumber.POSITIVE_INFINITY;\n }\n const fd = this.maxFractionalDigits(that, this.fractionalDigits); // Max common fractional decimals.\n return new FixedPointNumber(\n fd,\n FixedPointNumber.div(\n fd,\n this.dp(fd).scaledValue,\n that.dp(fd).scaledValue\n )\n ).dp(this.fractionalDigits); // Minimize fractional decimals without precision loss.\n }\n\n /**\n * Divides the given dividend by the given divisor, adjusted by a factor based on fd.\n *\n * @param {bigint} fd - The factor determining the power of 10 to apply to the dividend.\n * @param {bigint} dividend - The number to be divided.\n * @param {bigint} divisor - The number by which to divide the dividend.\n *\n * @return {bigint} - The result of the division, adjusted by the given factor fd.\n */\n private static div(fd: bigint, dividend: bigint, divisor: bigint): bigint {\n return (FixedPointNumber.BASE ** fd * dividend) / divisor;\n }\n\n /**\n * Adjust the precision of the floating-point number by the specified\n * number of decimal places.\n *\n * @param decimalPlaces The number of decimal places to adjust to,\n * it must be a positive value.\n * @return {FixedPointNumber} A new FixedPointNumber instance with the adjusted precision.\n * @throws InvalidDataType if `decimalPlaces` is negative.\n */\n public dp(decimalPlaces: bigint | number): FixedPointNumber {\n const dp = BigInt(decimalPlaces);\n if (dp >= 0) {\n let fd = this.fractionalDigits;\n let sv = this.scaledValue;\n if (dp > fd) {\n // Scale up.\n sv *= FixedPointNumber.BASE ** (dp - fd);\n fd = dp;\n } else {\n // Scale down.\n while (fd > dp && sv % FixedPointNumber.BASE === 0n) {\n fd--;\n sv /= FixedPointNumber.BASE;\n }\n }\n return new FixedPointNumber(fd, sv, this.edgeFlag);\n }\n throw new InvalidDataType(\n 'FixedPointNumber.scale',\n 'negative `dp` arg',\n { dp: `${dp}` }\n );\n }\n\n /**\n * Returns `true `if the value of thisFPN is equal to the value of `that` FixedPointNumber, otherwise returns `false`.\n *\n * As with JavaScript, `NaN` does not equal `NaN`.\n *\n * @param {FixedPointNumber} that - The FixedPointNumber to compare against.\n * @return {boolean} `true` if the FixedPointNumber numbers are equal, otherwise `false`.\n *\n * @remarks This method uses {@link comparedTo} internally.\n *\n * @see [bigbumber.js isEqualTo](https://mikemcl.github.io/bignumber.js/#eq)\n */\n public eq(that: FixedPointNumber): boolean {\n return this.comparedTo(that) === 0;\n }\n\n /**\n * Returns `true` if the value of this FixedPointNumber is greater than `that` FixedPointNumber`, otherwise returns `false`.\n *\n * @param {FixedPointNumber} that The FixedPointNumber to compare against.\n * @return {boolean} `true` if this FixedPointNumber is greater than `that` FixedPointNumber, otherwise `false`.\n *\n * @remarks This method uses {@link comparedTo} internally.\n *\n * @see [bignummber.js isGreaterThan](https://mikemcl.github.io/bignumber.js/#gt)\n */\n public gt(that: FixedPointNumber): boolean {\n const cmp = this.comparedTo(that);\n return cmp !== null && cmp > 0;\n }\n\n /**\n * Returns `true` if the value of this FixedPointNumber is greater or equal than `that` FixedPointNumber`, otherwise returns `false`.\n *\n * @param {FixedPointNumber} that - The FixedPointNumber to compare against.\n * @return {boolean} `true` if this FixedPointNumber is greater or equal than `that` FixedPointNumber, otherwise `false`.\n *\n * @remarks This method uses {@link comparedTo} internally.\n *\n * @see [bignumber.js isGreaterThanOrEqualTo](https://mikemcl.github.io/bignumber.js/#gte)\n */\n public gte(that: FixedPointNumber): boolean {\n const cmp = this.comparedTo(that);\n return cmp !== null && cmp >= 0;\n }\n\n /**\n * Returns a fixed-point number whose value is the integer part of dividing the value of this fixed-point number\n * by `that` fixed point number.\n *\n * Limit cases\n * * 0 / 0 = NaN\n * * NaN / ±n = NaN\n * * ±Infinity / ±Infinity = NaN\n * * +n / NaN = NaN\n * * +n / ±Infinite = 0\n * * -n / 0 = -Infinite\n * * +n / 0 = +Infinite\n *\n * @param {FixedPointNumber} that - The fixed-point number to divide by.\n * @return {FixedPointNumber} The result of the division.\n *\n * @remarks The precision is the greater of the precision of the two operands.\n *\n * @see [bignumber.js dividedToIntegerBy](https://mikemcl.github.io/bignumber.js/#divInt)\n */\n public idiv(that: FixedPointNumber): FixedPointNumber {\n if (this.isNaN() || that.isNaN()) return FixedPointNumber.NaN;\n if (this.isNegativeInfinite()) {\n if (that.isInfinite()) return FixedPointNumber.NaN;\n if (that.isPositive()) return FixedPointNumber.NEGATIVE_INFINITY;\n return FixedPointNumber.POSITIVE_INFINITY;\n }\n if (this.isPositiveInfinite()) {\n if (that.isInfinite()) return FixedPointNumber.NaN;\n if (that.isPositive()) return FixedPointNumber.POSITIVE_INFINITY;\n return FixedPointNumber.NEGATIVE_INFINITY;\n }\n if (that.isInfinite()) return FixedPointNumber.ZERO;\n if (that.isZero()) {\n if (this.isZero()) return FixedPointNumber.NaN;\n if (this.isNegative()) return FixedPointNumber.NEGATIVE_INFINITY;\n return FixedPointNumber.POSITIVE_INFINITY;\n }\n const fd = this.maxFractionalDigits(that, this.fractionalDigits); // Max common fractional decimals.\n return new FixedPointNumber(\n fd,\n FixedPointNumber.idiv(\n fd,\n this.dp(fd).scaledValue,\n that.dp(fd).scaledValue\n )\n ).dp(this.fractionalDigits); // Minimize fractional decimals without precision loss.\n }\n\n /**\n * Performs integer division on two big integers and scales the result by a factor of 10 raised to the power of fd.\n *\n * @param {bigint} fd - The power to which 10 is raised to scale the result.\n * @param {bigint} dividend - The number to be divided.\n * @param {bigint} divisor - The number by which dividend is divided.\n * @return {bigint} - The scaled result of the integer division.\n */\n private static idiv(fd: bigint, dividend: bigint, divisor: bigint): bigint {\n return (dividend / divisor) * FixedPointNumber.BASE ** fd;\n }\n\n /**\n * Returns `true `if the value of thisFPN is equal to the value of `that` FixedPointNumber, otherwise returns `false`.\n *\n * As with JavaScript, `NaN` does not equal `NaN`.\n *\n * @param {FixedPointNumber} that - The FixedPointNumber to compare against.\n * @return {boolean} `true` if the FixedPointNumber numbers are equal, otherwise `false`.\n *\n * @remarks This method uses {@link eq} internally.\n */\n public isEqual(that: FixedPointNumber): boolean {\n return this.eq(that);\n }\n\n /**\n * Returns `true` if the value of this FixedPointNumber is a finite number, otherwise returns `false`.\n *\n * The only possible non-finite values of a FixedPointNumber are {@link NaN}, {@link NEGATIVE_INFINITY} and {@link POSITIVE_INFINITY}.\n *\n * @return `true` if the value of this FixedPointNumber is a finite number, otherwise returns `false`.\n *\n * @see [bignumber.js isFinite](https://mikemcl.github.io/bignumber.js/#isF)\n */\n public isFinite(): boolean {\n return this.edgeFlag === 0;\n }\n\n /**\n * Return `true` if the value of this FixedPointNumber is {@link NEGATIVE_INFINITY} or {@link POSITIVE_INFINITY},\n * otherwise returns false.\n *\n * @return true` if the value of this FixedPointNumber is {@link NEGATIVE_INFINITY} or {@link POSITIVE_INFINITY},\n */\n public isInfinite(): boolean {\n return this.isNegativeInfinite() || this.isPositiveInfinite();\n }\n\n /**\n * Returns `true` if the value of this FixedPointNumber is an integer,\n * otherwise returns `false`.\n *\n * @return `true` if the value of this FixedPointNumber is an integer.\n *\n * @see [bignumber.js isInteger](https://mikemcl.github.io/bignumber.js/#isInt)\n */\n public isInteger(): boolean {\n if (this.isFinite()) {\n return (\n this.scaledValue %\n FixedPointNumber.BASE ** this.fractionalDigits ===\n 0n\n );\n }\n return false;\n }\n\n /**\n * Checks if a given string expression is an integer in base 10 notation,\n * considering `-` for negative and `+` optional for positive values.\n *\n * @param {string} exp - The string expression to be tested.\n *\n * @return {boolean} `true` if the expression is an integer,\n * `false` otherwise.\n */\n public static isIntegerExpression(exp: string): boolean {\n return this.REGEX_INTEGER.test(exp);\n }\n\n /**\n * Returns `true` if the value of this FixedPointNumber is `NaN`, otherwise returns `false`.\n *\n * @return `true` if the value of this FixedPointNumber is `NaN`, otherwise returns `false`.\n *\n * @see [bignumber.js isNaN](https://mikemcl.github.io/bignumber.js/#isNaN)\n */\n public isNaN(): boolean {\n return Number.isNaN(this.edgeFlag);\n }\n\n /**\n * Checks if a given string expression is a natural (unsigned positive integer)\n * number in base 10 notation.\n *\n * @param {string} exp - The string expression to be tested.\n *\n * @return {boolean} `true` if the expression is a natural number,\n * `false` otherwise.\n */\n public static isNaturalExpression(exp: string): boolean {\n return this.REGEX_NATURAL.test(exp);\n }\n\n /**\n * Returns `true` if the sign of this FixedPointNumber is negative, otherwise returns `false`.\n *\n * @return `true` if the sign of this FixedPointNumber is negative, otherwise returns `false`.\n *\n * @see [bignumber.js isNegative](https://mikemcl.github.io/bignumber.js/#isNeg)\n */\n public isNegative(): boolean {\n return (\n (this.isFinite() && this.scaledValue < 0n) ||\n this.isNegativeInfinite()\n );\n }\n\n /**\n * Returns `true` if this FixedPointNumber value is {@link NEGATIVE_INFINITY}, otherwise returns `false`.\n */\n public isNegativeInfinite(): boolean {\n return this.edgeFlag === Number.NEGATIVE_INFINITY;\n }\n\n /**\n * Checks if a given string expression is a number in base 10 notation,\n * considering `-` for negative and `+` optional for positive values.\n *\n * The method returns `true` for the following cases.\n * - Whole numbers:\n * - Positive whole numbers, optionally signed: 1, +2, 3, ...\n * - Negative whole numbers: -1, -2, -3, ...\n * - Decimal numbers:\n * - Positive decimal numbers, optionally signed: 1.0, +2.5, 3.14, ...\n * - Negative decimal numbers: -1.0, -2.5, -3.14, ...\n * - Decimal numbers without whole part:\n * - Positive decimal numbers, optionally signed: .1, +.5, .75, ...\n * - Negative decimal numbers: -.1, -.5, -.75, ...\n *\n * @param exp - The string expression to be checked.\n *\n * @return `true` is `exp` represents a number, otherwise `false`.\n */\n public static isNumberExpression(exp: string): boolean {\n return FixedPointNumber.REGEX_NUMBER.test(exp);\n }\n\n /**\n * Returns `true` if the sign of this FixedPointNumber is positive, otherwise returns `false`.\n *\n * @return `true` if the sign of this FixedPointNumber is positive, otherwise returns `false`.\n *\n * @see [bignumber.js isPositive](https://mikemcl.github.io/bignumber.js/#isPos)\n */\n public isPositive(): boolean {\n return (\n (this.isFinite() && this.scaledValue >= 0n) ||\n this.isPositiveInfinite()\n );\n }\n\n /**\n * Returns `true` if this FixedPointNumber value is {@link POSITIVE_INFINITY}, otherwise returns `false`.\n *\n * @return `true` if this FixedPointNumber value is {@link POSITIVE_INFINITY}, otherwise returns `false`.\n */\n public isPositiveInfinite(): boolean {\n return this.edgeFlag === Number.POSITIVE_INFINITY;\n }\n\n /**\n * Returns `true` if the value of this FixedPointNumber is zero or minus zero, otherwise returns `false`.\n *\n * @return `true` if the value of this FixedPointNumber is zero or minus zero, otherwise returns `false`.\n *\n * [see bignumber.js isZero](https://mikemcl.github.io/bignumber.js/#isZ)\n */\n public isZero(): boolean {\n return this.isFinite() && this.scaledValue === 0n;\n }\n\n /**\n * Returns `true` if the value of this FixedPointNumber is less than the value of `that` FixedPointNumber, otherwise returns `false`.\n *\n * @param {FixedPointNumber} that - The FixedPointNumber to compare against.\n *\n * @return {boolean} `true` if the value of this FixedPointNumber is less than the value of `that` FixedPointNumber, otherwise returns `false`.\n *\n * @remarks This method uses {@link comparedTo} internally.\n *\n * @see [bignumber.js isLessThan](https://mikemcl.github.io/bignumber.js/#lt)\n */\n public lt(that: FixedPointNumber): boolean {\n const cmp = this.comparedTo(that);\n return cmp !== null && cmp < 0;\n }\n\n /**\n * Returns `true` if the value of this FixedPointNumber is less than or equal to the value of `that` FixedPointNumber,\n * otherwise returns `false`.\n *\n * @param {FixedPointNumber} that - The FixedPointNumber to compare against.\n * @return {boolean} `true` if the value of this FixedPointNumber is less than or equal to the value of `that` FixedPointNumber,\n * otherwise returns `false`.\n *\n * @remarks This method uses {@link comparedTo} internally.\n *\n * @see [bignumber.js isLessThanOrEqualTo](https://mikemcl.github.io/bignumber.js/#lte)\n */\n public lte(that: FixedPointNumber): boolean {\n const cmp = this.comparedTo(that);\n return cmp !== null && cmp <= 0;\n }\n\n /**\n * Return the maximum between the fixed decimal value of this object and `that` one.\n * If the maximum fixed digits value is less than `minFixedDigits`, return `minFixedDigits`.\n *\n * @param {FixedPointNumber} that to evaluate if `that` has the maximum fixed digits value.\n * @param {bigint} minFixedDigits Min value of returned value.\n *\n * @return the greater fixed digits value among `this`, `that` and `minFixedDigits`.\n */\n private maxFractionalDigits(\n that: FixedPointNumber,\n minFixedDigits: bigint\n ): bigint {\n const fd =\n this.fractionalDigits < that.fractionalDigits\n ? that.fractionalDigits\n : this.fractionalDigits;\n return fd > minFixedDigits ? fd : minFixedDigits;\n }\n\n /**\n * Returns a FixedPointNumber whose value is the value of this FixedPointNumber minus `that` FixedPointNumber.\n *\n * Limit cases\n * * NaN - ±n = NaN\n * * ±n - NaN = NaN\n * * -Infinity - -Infinity = NaN\n * * -Infinity - +n = -Infinity\n * * +Infinity - +Infinity = NaN\n * * +Infinity - +n = +Infinity\n *\n * @param {FixedPointNumber} that - The fixed-point number to subtract.\n * @return {FixedPointNumber} The result of the subtraction. The return value is always exact and unrounded.\n *\n * @remarks The precision is the greater of the precision of the two operands.\n *\n * @see [bignumber.js minus](https://mikemcl.github.io/bignumber.js/#minus)\n */\n public minus(that: FixedPointNumber): FixedPointNumber {\n if (this.isNaN() || that.isNaN()) return FixedPointNumber.NaN;\n if (this.isNegativeInfinite())\n return that.isNegativeInfinite()\n ? FixedPointNumber.NaN\n : FixedPointNumber.NEGATIVE_INFINITY;\n if (this.isPositiveInfinite())\n return that.isPositiveInfinite()\n ? FixedPointNumber.NaN\n : FixedPointNumber.POSITIVE_INFINITY;\n const fd = this.maxFractionalDigits(that, this.fractionalDigits); // Max common fractional decimals.\n return new FixedPointNumber(\n fd,\n this.dp(fd).scaledValue - that.dp(fd).scaledValue\n ).dp(this.fractionalDigits); // Minimize fractional decimals without precision loss.\n }\n\n /**\n * Returns a FixedPointNumber whose value is the value of this FixedPointNumber modulo `that` FixedPointNumber,\n * i.e. the integer remainder of dividing this FixedPointNumber by `that`.\n *\n * Limit cases\n * * NaN % ±n = NaN\n * * ±n % NaN = NaN\n * * ±Infinity % n = NaN\n * * n % ±Infinity = NaN\n *\n * @param that {FixedPointNumber} - The fixed-point number to divide by.\n * @return {FixedPointNumber} the integer remainder of dividing this FixedPointNumber by `that`.\n *\n * @remarks The precision is the greater of the precision of the two operands.\n *\n * @see [bignumber.js modulo](https://mikemcl.github.io/bignumber.js/#mod)\n */\n public modulo(that: FixedPointNumber): FixedPointNumber {\n if (this.isNaN() || that.isNaN()) return FixedPointNumber.NaN;\n if (this.isInfinite() || that.isInfinite()) return FixedPointNumber.NaN;\n if (that.isZero()) return FixedPointNumber.NaN;\n const fd = this.maxFractionalDigits(that, this.fractionalDigits); // Max common fractional decimals.\n let modulo = this.abs().dp(fd).scaledValue;\n const divisor = that.abs().dp(fd).scaledValue;\n while (modulo >= divisor) {\n modulo -= divisor;\n }\n return new FixedPointNumber(fd, modulo).dp(this.fractionalDigits); // Minimize fractional decimals without precision loss.\n }\n\n /**\n * Multiplies two big integer values and divides by a factor of ten raised to a specified power.\n *\n * @param {bigint} multiplicand - The first number to be multiplied.\n * @param {bigint} multiplicator - The second number to be multiplied.\n * @param {bigint} fd - The power of ten by which the product is to be divided.\n *\n * @return {bigint} The result of the multiplication divided by ten raised to the specified power.\n */\n private static mul(\n multiplicand: bigint,\n multiplicator: bigint,\n fd: bigint\n ): bigint {\n return (multiplicand * multiplicator) / FixedPointNumber.BASE ** fd;\n }\n\n /**\n * Returns a new instance of FixedPointNumber whose value is the value of this FixedPointNumber value\n * negated, i.e. multiplied by -1.\n *\n * @see [bignumber.js negated](https://mikemcl.github.io/bignumber.js/#neg)\n */\n public negated(): FixedPointNumber {\n if (this.isNegativeInfinite())\n return FixedPointNumber.POSITIVE_INFINITY;\n if (this.isPositiveInfinite())\n return FixedPointNumber.NEGATIVE_INFINITY;\n return new FixedPointNumber(\n this.fractionalDigits,\n -this.scaledValue,\n this.edgeFlag\n );\n }\n\n /**\n * Constructs a new instance of FixedPointNumber (Fixed Point Number) parsing the\n * `exp` numeric expression in base 10 and representing the value with the\n * precision of `decimalPlaces` fractional decimal digits.\n *\n * @param {bigint|number|string} exp - The value to represent.\n * It can be a bigint, number, or string representation of the number.\n * @param {bigint} [decimalPlaces=this.DEFAULT_FRACTIONAL_DECIMALS] - The\n * number of fractional decimal digits to be used to represent the value.\n *\n * @return {FixedPointNumber} A new instance of FixedPointNumber with the given parameters.\n *\n * @throws {InvalidDataType} If `exp` is not a numeric expression.\n */\n public static of(\n exp: bigint | number | string | FixedPointNumber,\n decimalPlaces: bigint = this.DEFAULT_FRACTIONAL_DECIMALS\n ): FixedPointNumber {\n try {\n if (exp instanceof FixedPointNumber) {\n return new FixedPointNumber(\n exp.fractionalDigits,\n exp.scaledValue,\n exp.edgeFlag\n );\n }\n if (Number.isNaN(exp))\n return new FixedPointNumber(decimalPlaces, 0n, Number.NaN);\n if (exp === Number.NEGATIVE_INFINITY)\n return new FixedPointNumber(\n decimalPlaces,\n -1n,\n Number.NEGATIVE_INFINITY\n );\n if (exp === Number.POSITIVE_INFINITY)\n return new FixedPointNumber(\n decimalPlaces,\n 1n,\n Number.POSITIVE_INFINITY\n );\n return new FixedPointNumber(\n decimalPlaces,\n this.txtToSV(exp.toString(), decimalPlaces)\n );\n } catch (e) {\n throw new InvalidDataType(\n 'FixedPointNumber.of',\n 'not a number',\n { exp },\n e\n );\n }\n }\n\n /**\n * Returns a FixedPointNumber whose value is the value of this FixedPointNumber plus `that` FixedPointNumber.\n *\n * Limit cases\n * * NaN + ±n = NaN\n * * ±n + NaN = NaN\n * * -Infinity + -Infinity = -Infinity\n * * -Infinity + +Infinity = NaN\n * * +Infinity + -Infinity = NaN\n * * +Infinity + +Infinity = +Infinity\n *\n * @param {FixedPointNumber} that - The fixed-point number to add to the current number.\n * @return {FixedPointNumber} The result of the addition. The return value is always exact and unrounded.\n *\n * @remarks The precision is the greater of the precision of the two operands.\n *\n * @see [bignumber.js plus](https://mikemcl.github.io/bignumber.js/#plus)\n */\n public plus(that: FixedPointNumber): FixedPointNumber {\n if (this.isNaN() || that.isNaN()) return FixedPointNumber.NaN;\n if (this.isNegativeInfinite())\n return that.isPositiveInfinite()\n ? FixedPointNumber.NaN\n : FixedPointNumber.NEGATIVE_INFINITY;\n if (this.isPositiveInfinite())\n return that.isNegativeInfinite()\n ? FixedPointNumber.NaN\n : FixedPointNumber.POSITIVE_INFINITY;\n const fd = this.maxFractionalDigits(that, this.fractionalDigits); // Max common fractional decimals.\n return new FixedPointNumber(\n fd,\n this.dp(fd).scaledValue + that.dp(fd).scaledValue\n ).dp(this.fractionalDigits); // Minimize fractional decimals without precision loss.\n }\n\n /**\n * Returns a FixedPointNumber whose value is the value of this FixedPointNumber raised to the power of `that` FixedPointNumber.\n *\n * This method implements the\n * [Exponentiation by Squaring](https://en.wikipedia.org/wiki/Exponentiation_by_squaring)\n * algorithm.\n *\n * Limit cases\n * * NaN ^ e = NaN\n * * b ^ NaN = NaN\n * * b ^ -Infinite = 0\n * * b ^ 0 = 1\n * * b ^ +Infinite = +Infinite\n * * ±Infinite ^ -e = 0\n * * ±Infinite ^ +e = +Infinite\n *\n * @param {FixedPointNumber} that - The exponent as a fixed-point number.\n * truncated to its integer component because **Exponentiation by Squaring** is not valid for rational exponents.\n * @return {FixedPointNumber} - The result of raising this fixed-point number to the power of the given exponent.\n *\n * @see [bignumber.js exponentiatedBy](https://mikemcl.github.io/bignumber.js/#pow)\n */\n public pow(that: FixedPointNumber): FixedPointNumber {\n // Limit cases\n if (this.isNaN() || that.isNaN()) return FixedPointNumber.NaN;\n if (this.isInfinite())\n return that.isZero()\n ? FixedPointNumber.ONE\n : that.isNegative()\n ? FixedPointNumber.ZERO\n : FixedPointNumber.POSITIVE_INFINITY;\n if (that.isNegativeInfinite()) return FixedPointNumber.ZERO;\n if (that.isPositiveInfinite()) {\n return FixedPointNumber.POSITIVE_INFINITY;\n }\n if (that.isZero()) return FixedPointNumber.ONE;\n // Exponentiation by squaring works for natural exponent value.\n let exponent = that.abs().bi;\n let base = FixedPointNumber.of(this);\n let result = FixedPointNumber.ONE;\n while (exponent > 0n) {\n // If the exponent is odd, multiply the result by the current base.\n if (exponent % 2n === 1n) {\n result = result.times(base);\n }\n // Square the base and halve the exponent.\n base = base.times(base);\n exponent = exponent / 2n;\n }\n // If exponent is negative, convert the problem to positive exponent.\n return that.isNegative() ? FixedPointNumber.ONE.div(result) : result;\n }\n\n /**\n * Computes the square root of a given positive bigint value using a fixed-point iteration method.\n *\n * @param {bigint} value - The positive bigint value for which the square root is to be calculated.\n * @param {bigint} fd - The iteration factor determinant.\n * @return {bigint} The calculated square root of the input bigint value.\n *\n * @throws {RangeError} If the input value is negative.\n */\n private static sqr(value: bigint, fd: bigint): bigint {\n if (value < 0n) {\n throw new RangeError(`Value must be positive`);\n }\n const sf = fd * FixedPointNumber.BASE; // Scale Factor.\n let iteration = 0;\n let actualResult = value;\n let storedResult = 0n;\n while (actualResult !== storedResult && iteration < sf) {\n storedResult = actualResult;\n actualResult =\n (actualResult + FixedPointNumber.div(fd, value, actualResult)) /\n 2n;\n iteration++;\n }\n return actualResult;\n }\n\n /**\n * Returns a FixedPointNumber whose value is the square root of the value of this FixedPointNumber\n *\n * Limit cases\n * * NaN = NaN\n * * +Infinite = +Infinite\n * * -n = NaN\n *\n * @return {FixedPointNumber} The square root of the number.\n *\n * @see [bignumber.js sqrt](https://mikemcl.github.io/bignumber.js/#sqrt)\n */\n public sqrt(): FixedPointNumber {\n if (this.isNaN()) return FixedPointNumber.NaN;\n if (this.isNegativeInfinite()) return FixedPointNumber.NaN;\n if (this.isPositiveInfinite())\n return FixedPointNumber.POSITIVE_INFINITY;\n try {\n return new FixedPointNumber(\n this.fractionalDigits,\n FixedPointNumber.sqr(this.scaledValue, this.fractionalDigits)\n );\n } catch {\n return FixedPointNumber.NaN;\n }\n }\n\n /**\n * Returns a FixedPointNumber whose value is the value of this FixedPointNumber multiplied by `that` FixedPointNumber.\n *\n * Limits cases\n * * NaN * n = NaN\n * * n * NaN = NaN\n * * -Infinite * -n = +Infinite\n * * -Infinite * +n = -Infinite\n * * +Infinite * -n = -Infinite\n * * +Infinite * +n = +Infinite\n *\n * @param {FixedPointNumber} that - The fixed-point number to multiply with this number.\n * @return {FixedPointNumber} a FixedPointNumber whose value is the value of this FixedPointNumber multiplied by `that` FixedPointNumber.\n *\n * @remarks The precision is the greater of the precision of the two operands.\n *\n * @see [bignumber.js multipliedBy](https://mikemcl.github.io/bignumber.js/#times)\n */\n public times(that: FixedPointNumber): FixedPointNumber {\n if (this.isNaN() || that.isNaN()) return FixedPointNumber.NaN;\n if (this.isNegativeInfinite())\n return that.isNegative()\n ? FixedPointNumber.POSITIVE_INFINITY\n : FixedPointNumber.NEGATIVE_INFINITY;\n if (this.isPositiveInfinite())\n return that.isNegative()\n ? FixedPointNumber.NEGATIVE_INFINITY\n : FixedPointNumber.POSITIVE_INFINITY;\n const fd =\n this.fractionalDigits > that.fractionalDigits\n ? this.fractionalDigits\n : that.fractionalDigits; // Max common fractional decimals.\n return new FixedPointNumber(\n fd,\n FixedPointNumber.mul(\n this.dp(fd).scaledValue,\n that.dp(fd).scaledValue,\n fd\n )\n ).dp(this.fractionalDigits); // Minimize fractional decimals without precision loss.\n }\n\n /**\n * Converts the fixed-point number to its string representation.\n *\n * @param {string} [decimalSeparator='.'] - The character to use as the decimal separator in the string representation. Default is '.'.\n * @return {string} A string representation of the fixed-point number.\n */\n public toString(decimalSeparator = '.'): string {\n if (this.edgeFlag === 0) {\n const sign = this.scaledValue < 0n ? '-' : '';\n const digits =\n this.scaledValue < 0n\n ? (-this.scaledValue).toString()\n : this.scaledValue.toString();\n const padded = digits.padStart(Number(this.fractionalDigits), '0');\n const decimals =\n this.fractionalDigits > 0\n ? padded.slice(Number(-this.fractionalDigits))\n : '';\n const integers = padded.slice(0, padded.length - decimals.length);\n const integersShow = integers.length < 1 ? '0' : integers;\n const decimalsShow = FixedPointNumber.trimEnd(decimals);\n return (\n sign +\n integersShow +\n (decimalsShow.length > 0 ? decimalSeparator + decimalsShow : '')\n );\n }\n return this.edgeFlag.toString();\n }\n\n /**\n * Trims the specified trailing substring from the end of the input string recursively.\n *\n * @param {string} str - The input string to be trimmed.\n * @param {string} [sub='0'] - The substring to be removed from the end of the input string. Defaults to '0' if not provided.\n * @return {string} The trimmed string with the specified trailing substring removed.\n */\n private static trimEnd(str: string, sub: string = '0'): string {\n // Check if the input string ends with the trailing substring\n if (str.endsWith(sub)) {\n // Remove the trailing substring recursively.\n return FixedPointNumber.trimEnd(\n str.substring(0, str.length - sub.length),\n sub\n );\n }\n return str;\n }\n\n /**\n * Converts a string expression of a number into a scaled value.\n *\n * @param {string} exp - The string expression of the number to be converted.\n * @param {bigint} fd - The scale factor to be used for conversion.\n * @param {string} [decimalSeparator='.'] - The character used as the decimal separator in the string expression.\n * @return {bigint} - The converted scaled value as a bigint.\n */\n private static txtToSV(\n exp: string,\n fd: bigint,\n decimalSeparator = '.'\n ): bigint {\n const fc = exp.charAt(0); // First Character.\n let sign = 1n;\n if (fc === '-') {\n sign = -1n;\n exp = exp.substring(1);\n } else if (fc === '+') {\n exp = exp.substring(1);\n }\n const sf = FixedPointNumber.BASE ** fd; // Scale Factor.\n const di = exp.lastIndexOf(decimalSeparator); // Decimal Index.\n if (di < 0) {\n return sign * sf * BigInt(exp); // Signed Integer.\n }\n const ie = exp.substring(0, di); // Integer Expression.\n const fe = exp.substring(di + 1); // Fractional Expression.\n return (\n sign * sf * BigInt(ie) + // Integer part\n (sign * (sf * BigInt(fe))) / BigInt(10 ** fe.length) // Fractional part.\n );\n }\n}\n\nexport { FixedPointNumber };\n","import { Hex } from './Hex';\nimport { InvalidDataType } from '@vechain/sdk-errors';\n\n/**\n * Represents a hexadecimal signed integer value.\n *\n * @remarks This class makes equal instances created from the same value as number or as bigint.\n *\n * @extends {Hex}\n */\nclass HexInt extends Hex {\n /**\n * Retrieves the value of n cast from this instance interpreted as the hexadecimal expression of a bigint value.\n *\n * @return {number} The value of n.\n *\n * @throws {InvalidDataType} If n is not within the safe number range, if the number representation of this\n * instance results approximated.\n *\n * @remarks This class makes equal instances created from the same value as number or as bigint.\n */\n public override get n(): number {\n const bi = this.bi;\n if (Number.MIN_SAFE_INTEGER <= bi && bi <= Number.MAX_SAFE_INTEGER) {\n return Number(bi);\n }\n throw new InvalidDataType('HexInt.n', 'not in the safe number range', {\n bi: `${bi}`,\n hex: this.toString()\n });\n }\n\n /**\n * Create a HexInt instance from a bigint, number, string, Uint8Array, or {@link Hex}.\n *\n * @param {bigint | number | string | Uint8Array | Hex} exp - The expression to be interpreted as an integer:\n * * bigint is always representable in hexadecimal base notation;\n * * number is converted to a bigint then represented in hexadecimal base notation;\n * it throws {@link InvalidDataType} if not an integer value;\n * * string is parsed as the hexadecimal expression of a bigint value, optionally tagged with `0x`;\n * * Uint8Array is interpreted as the sequence of bytes expressing a bigint value;\n * * {@link Hex} is interpreted as expressing a bigint value.\n *\n * @returns {HexInt} - The new HexInt object representing the given `exp`.\n *\n * @throws {InvalidDataType} - If the given `exp` is not a valid hexadecimal integer expression,\n * if `exp` is a not integer number.\n *\n * @remarks This class makes equal instances created from the same value as number or as bigint.\n */\n public static of(exp: bigint | number | string | Uint8Array | Hex): HexInt {\n try {\n if (exp instanceof Hex) {\n return new HexInt(exp.sign, exp.digits);\n }\n if (typeof exp === 'number') {\n if (Number.isInteger(exp)) {\n const hex = Hex.of(BigInt(exp));\n return new HexInt(hex.sign, hex.digits);\n }\n // noinspection ExceptionCaughtLocallyJS\n throw new InvalidDataType('HexInt.of', 'not an integer', {\n exp\n });\n }\n const hex = Hex.of(exp);\n return new HexInt(hex.sign, hex.digits);\n } catch (e) {\n throw new InvalidDataType(\n 'HexInt.of',\n 'not an hexadecimal integer expression',\n { exp: `${exp}`, e } // Needed to serialize bigint values.\n );\n }\n }\n}\n\nexport { HexInt };\n","import { InvalidDataType } from '@vechain/sdk-errors';\nimport { Hex } from './Hex';\nimport { HexInt } from './HexInt';\n\n/**\n * Represents a hexadecimal unsigned integer value.\n *\n * @extends HexInt\n */\nclass HexUInt extends HexInt {\n /**\n * Regular expression for matching hexadecimal strings.\n * An empty input is represented as a empty digits.\n *\n * @type {RegExp}\n */\n private static readonly REGEX_HEXUINT: RegExp = /^(0x)?[0-9a-f]*$/i;\n\n /**\n * Regular expression pattern to match a prefix indicating hexadecimal number.\n *\n * @type {RegExp}\n */\n protected static readonly REGEX_HEXUINT_PREFIX: RegExp = /^0x/i;\n\n /**\n * Checks if the given string expression is a valid unsigned hexadecimal value.\n *\n * @param {string} exp - The string representation of a hexadecimal value.\n *\n * @return {boolean} - True if the expression is a valid unsigned hexadecimal value, case-insensitive,\n * optionally prefixed with `0x`; false otherwise.\n */\n public static isValid(exp: string): boolean {\n return HexUInt.REGEX_HEXUINT.test(exp);\n }\n\n /**\n * Determines whether the given string is a valid unsigned hexadecimal number prefixed with '0x'.\n *\n * @param {string} exp - The string to be evaluated.\n * @return {boolean} - True if the string is a valid unsigned hexadecimal number prefixed with '0x', otherwise false.\n */\n public static isValid0x(exp: string): boolean {\n return HexUInt.REGEX_HEX_PREFIX.test(exp) && Hex.isValid(exp);\n }\n\n /**\n * Create a HexUInt instance from a bigint, number, string, Uint8Array, or {@link HexInt}.\n *\n * @param {bigint | number | string | Uint8Array | HexInt} exp - The expression to be interpreted as an unsigned integer:\n * * bigint is always representable in hexadecimal base notation,\n * it throws {@link InvalidDataType} if not positive;\n * * number is converted to a bigint then represented in hexadecimal base notation,\n * it throws {@link InvalidDataType} if not a positive integer value;\n * * string is parsed as the hexadecimal expression of a bigint value, optionally tagged with `0x`;\n * it throws {@link InvalidDataType} if not positive;\n * * Uint8Array is interpreted as the sequence of bytes expressing a positive bigint value;\n * * {@link HexInt} is interpreted as expressing a bigint value,\n * it throws {@link InvalidDataType} if not positive.\n *\n * @returns {HexUInt} he new HexInt object representing the given `exp`.\n *\n * @throws {InvalidDataType} If the given expression is not a valid hexadecimal positive integer expression.\n */\n public static of(\n exp: bigint | number | string | Uint8Array | HexInt\n ): HexUInt {\n try {\n const hint = HexInt.of(exp);\n if (hint.sign >= Hex.POSITIVE) {\n return new HexUInt(hint.sign, hint.digits);\n }\n throw new InvalidDataType(\n 'HexUInt.of',\n 'not positive',\n { exp: `${exp}` } // Needed to serialize bigint values.\n );\n } catch (e) {\n throw new InvalidDataType(\n 'HexUInt.of',\n 'not a hexadecimal positive integer expression',\n { exp: `${exp}`, e }, // Needed to serialize bigint values.\n e\n );\n }\n }\n}\n\nexport { HexUInt };\n","import * as nh_sha256 from '@noble/hashes/sha256';\nimport { InvalidOperation } from '@vechain/sdk-errors';\nimport { Hex } from '../Hex';\nimport { HexUInt } from '../HexUInt';\n\n/**\n * Represents the result of an [SHA256](https://en.wikipedia.org/wiki/SHA-2) hash operation.\n *\n * @extends HexUInt\n * @implements Hash\n */\nclass Sha256 extends HexUInt {\n /**\n * Generates the [SHA 256](https://en.wikipedia.org/wiki/SHA-2) hash of the given input.\n *\n * @param {bigint | number | string | Uint8Array | Hex} exp - The input value to hash.\n *\n * @returns {Sha256} - The [SHA256](https://en.wikipedia.org/wiki/SHA-2) hash of the input value.\n *\n * @throws {InvalidOperation} - If a hash error occurs.\n *\n * @remarks Security auditable method, depends on\n * * [`nh_sha256.sha256`](https://github.com/paulmillr/noble-hashes#sha2-sha256-sha384-sha512-and-others).\n */\n public static of(exp: bigint | number | string | Uint8Array): Sha256 {\n try {\n const hash = nh_sha256.sha256(HexUInt.of(exp).bytes);\n return new Sha256(Hex.POSITIVE, HexUInt.of(hash).digits);\n } catch (e) {\n throw new InvalidOperation('Sha256.of', 'hash error', {\n exp: `${exp}`, // Needed to serialize bigint values.\n e\n });\n }\n }\n}\n\nexport { Sha256 };\n","import * as nc_utils from '@noble/curves/abstract/utils';\nimport { HexUInt } from '../vcdm/HexUInt';\nimport { randomBytes as nh_randomBytes } from '@noble/hashes/utils';\nimport { secp256k1 as nc_secp256k1 } from '@noble/curves/secp256k1';\nimport {\n InvalidSecp256k1MessageHash,\n InvalidSecp256k1PrivateKey,\n InvalidSecp256k1Signature\n} from '@vechain/sdk-errors';\n\n/**\n * The Secp256k1 class provides cryptographic utilities for the\n * [SECP256K1](https://en.bitcoin.it/wiki/Secp256k1)\n * [elliptic curve](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm),\n * including compressing and inflating public keys,\n * generating private keys, and validating message hashes and private keys.\n */\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nclass Secp256k1 {\n /**\n * This value is used to identify compressed public key.\n */\n private static readonly COMPRESSED_PREFIX = 2;\n\n /**\n * Represents the fixed length of the cryptographic signature.\n * The value is set to 65, which is the size in bytes\n * required for a 520-bit signature.\n *\n * @constant {number} SIGNATURE_LENGTH\n */\n public static readonly SIGNATURE_LENGTH = 65;\n\n /**\n * This value is used to identify uncompressed public key.\n */\n private static readonly UNCOMPRESS_PREFIX = 4;\n\n /**\n * Defines the required length for a valid hash.\n */\n private static readonly VALID_HASH_LENGTH = 32;\n\n /**\n * Compresses an uncompressed public key.\n *\n * @param {Uint8Array} publicKey - The uncompressed public key to be compressed.\n * @return {Uint8Array} - The compressed public key.\n *\n * @see Secp256k1.inflatePublicKey\n */\n public static compressPublicKey(publicKey: Uint8Array): Uint8Array {\n const prefix = publicKey.at(0);\n if (prefix === Secp256k1.UNCOMPRESS_PREFIX) {\n // To compress.\n const x = publicKey.slice(1, 33);\n const y = publicKey.slice(33, 65);\n const isYOdd = y[y.length - 1] & 1;\n // Prefix with 0x02 if Y coordinate is even, 0x03 if odd.\n return nc_utils.concatBytes(\n Uint8Array.of(Secp256k1.COMPRESSED_PREFIX + isYOdd),\n x\n );\n } else {\n // Compressed.\n return publicKey;\n }\n }\n\n /**\n * Derives the public key from a given private key.\n *\n * @param {Uint8Array} privateKey - The private key in Uint8Array format. Must be a valid 32-byte secp256k1 private key.\n * @param {boolean} [isCompressed=true] - Indicates whether the derived public key should be in compressed format.\n * @return {Uint8Array} The derived public key in Uint8Array format.\n * @throws {InvalidSecp256k1PrivateKey} Throws an error if the provided private key is not valid.\n *\n * @remarks Security auditable method, depends on\n * * [nc_secp256k1.getPublicKey](https://github.com/paulmillr/noble-secp256k1).\n */\n public static derivePublicKey(\n privateKey: Uint8Array,\n isCompressed: boolean = true\n ): Uint8Array {\n // Check if the private key is valid.\n if (Secp256k1.isValidPrivateKey(privateKey)) {\n return nc_secp256k1.getPublicKey(privateKey, isCompressed);\n }\n throw new InvalidSecp256k1PrivateKey(\n 'Secp256k1.derivePublicKey',\n 'Invalid private key given as input. Ensure it is a valid 32-byte secp256k1 private key.',\n undefined\n );\n }\n\n /**\n * Generates a new Secp256k1 private key using a secure random number generator.\n *\n * @return {Promise<Uint8Array>} A promise that resolves to a Uint8Array representing the generated private key.\n * This encoded private key is suitable for cryptographic operations.\n * @throws {InvalidSecp256k1PrivateKey} Throws an error if private key generation fails if a secure random number\n * generator is not provided by the hosting operating system.\n *\n * @remarks Security auditable method, depends on\n * * [nc_secp256k1.utils.randomPrivateKey](https://github.com/paulmillr/noble-secp256k1).\n */\n public static async generatePrivateKey(): Promise<Uint8Array> {\n return await new Promise<Uint8Array>((resolve, reject) => {\n try {\n const privateKey = nc_secp256k1.utils.randomPrivateKey();\n resolve(privateKey); // Resolve the promise with the generated private key\n } catch (e) {\n reject(\n new InvalidSecp256k1PrivateKey(\n 'Secp256k1.generatePrivateKey',\n 'Private key generation failed: ensure you have a secure random number generator available at runtime.',\n undefined,\n e\n )\n );\n }\n });\n }\n\n /**\n * Inflate a compressed public key to its uncompressed form.\n *\n * @param {Uint8Array} publicKey - The compressed public key to be inflated.\n * @return {Uint8Array} - The uncompressed public key.\n *\n * @remarks Security auditable method, depends on\n * * [nc_secp256k1.ProjectivePoint.fromAffine](https://github.com/paulmillr/noble-secp256k1);\n * * [nc_secp256k1.ProjectivePoint.fromHex](https://github.com/paulmillr/noble-secp256k1);\n * * [nc_secp256k1.ProjectivePoint.toAffine](https://github.com/paulmillr/noble-secp256k1).\n *\n * @see Secp256K1.compressPublicKey\n */\n public static inflatePublicKey(publicKey: Uint8Array): Uint8Array {\n const prefix = publicKey.at(0);\n if (prefix !== Secp256k1.UNCOMPRESS_PREFIX) {\n // To inflate.\n const x = publicKey.slice(0, 33);\n const p = nc_secp256k1.ProjectivePoint.fromAffine(\n nc_secp256k1.ProjectivePoint.fromHex(\n HexUInt.of(x).digits\n ).toAffine()\n );\n return p.toRawBytes(false);\n } else {\n // Inflated.\n return publicKey;\n }\n }\n\n /**\n * Checks whether the provided hash is a valid message hash.\n *\n * @param {Uint8Array} hash - The hash to be validated.\n * @return {boolean} `true` if the hash is 32 bytes long, otherwise `false`.\n */\n public static isValidMessageHash(hash: Uint8Array): boolean {\n return hash.length === Secp256k1.VALID_HASH_LENGTH;\n }\n\n /**\n * Checks if the provided private key is valid.\n *\n * @param {Uint8Array} privateKey - The private key to validate.\n * @return {boolean} `true` if the private key is valid, `false` otherwise.\n *\n * @remarks Security auditable method, depends on\n * * [nc_secp256k1.utils.isValidPrivateKey](https://github.com/paulmillr/noble-secp256k1).\n */\n public static isValidPrivateKey(privateKey: Uint8Array): boolean {\n return nc_secp256k1.utils.isValidPrivateKey(privateKey);\n }\n\n /**\n * Generates a random sequence of bytes.\n * If an error occurs during generation using\n * [nc_secp256k1](https://github.com/paulmillr/noble-secp256k1),\n * {@link {@link global.crypto} is used as fall back togenerate\n * the random sequence.\n *\n * @param {number} [bytesLength=32] - Optional. The number of random bytes to generate, 32 by default.\n * @return {Uint8Array} - A Uint8Array containing the random bytes.\n *\n * @remarks Security auditable method, depends on\n * * {@link global.crypto.getRandomValues};\n * * [nh_randomBytes](https://github.com/paulmillr/noble-hashes).\n */\n public static randomBytes(bytesLength: number = 32): Uint8Array {\n try {\n return nh_randomBytes(bytesLength);\n } catch {\n return global.crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n }\n\n /**\n * Recovers the public key associated with the message hash from the given signature.\n *\n * @param {Uint8Array} messageHash - The 32-byte message hash to be verified.\n * @param {Uint8Array} sig - The 65-byte signature used for recovery, consisting of the compact signature and recovery byte.\n * @return {Uint8Array} The recovered public key in its raw bytes form.\n * @throws {InvalidSecp256k1MessageHash} If the provided message hash is invalid.\n * @throws {InvalidSecp256k1Signature} If the provided signature is not 65 bytes or contains an invalid recovery value.\n *\n * @remarks Security auditable method, depends on\n * * [nc_secp256k1.Signature](https://github.com/paulmillr/noble-secp256k1).\n *\n * @see Secp256k1.isValidMessageHash\n */\n public static recover(\n messageHash: Uint8Array,\n sig: Uint8Array\n ): Uint8Array {\n // Check if the message hash is valid.\n if (!Secp256k1.isValidMessageHash(messageHash)) {\n throw new InvalidSecp256k1MessageHash(\n 'Secp256k1.recover',\n 'Invalid message hash given as input. Ensure it is a valid 32-byte message hash.',\n { messageHash }\n );\n }\n if (sig.length !== Secp256k1.SIGNATURE_LENGTH)\n throw new InvalidSecp256k1Signature(\n 'Secp256k1.recover',\n 'Invalid signature given as input. Length must be exactly 65 bytes.',\n { signature: sig }\n );\n const recovery = sig[64];\n if (recovery !== 0 && recovery !== 1)\n throw new InvalidSecp256k1Signature(\n 'Secp256k1.recover',\n 'Invalid signature recovery value. Signature bytes at position 64 must be 0 or 1.',\n { signature: sig, recovery }\n );\n return nc_secp256k1.Signature.fromCompact(sig.slice(0, 64))\n .addRecoveryBit(recovery)\n .recoverPublicKey(messageHash)\n .toRawBytes(false);\n }\n\n /**\n * Signs a given message hash using the provided private key.\n *\n * @param messageHash - A 32-byte message hash that needs to be signed.\n * @param privateKey - A 32-byte private key used for signing the message hash.\n * @return The signature of the message hash consisting of the r, s, and recovery values.\n * @throws InvalidSecp256k1MessageHash if the message hash is not a valid 32-byte hash.\n * @throws InvalidSecp256k1PrivateKey if the private key is not a valid 32-byte private key.\n *\n * @remarks Security auditable method, depends on\n * * [nc_secp256k1.sign](https://github.com/paulmillr/noble-secp256k1).\n *\n * @see Secp256k1.isValidMessageHash\n * @see Secp256k1.isValidPrivateKey\n */\n public static sign(\n messageHash: Uint8Array,\n privateKey: Uint8Array\n ): Uint8Array {\n // Check if the message hash is valid.\n if (!Secp256k1.isValidMessageHash(messageHash)) {\n throw new InvalidSecp256k1MessageHash(\n 'Secp256k1.sign',\n 'Invalid message hash given as input. Ensure it is a valid 32-byte message hash.',\n { messageHash }\n );\n }\n // Check if the private key is valid.\n if (!Secp256k1.isValidPrivateKey(privateKey)) {\n throw new InvalidSecp256k1PrivateKey(\n 'Secp256k1.sign',\n 'Invalid private key given as input. Ensure it is a valid 32-byte secp256k1 private key.',\n undefined\n );\n }\n const sig = nc_secp256k1.sign(messageHash, privateKey);\n return nc_utils.concatBytes(\n nc_utils.numberToBytesBE(sig.r, 32),\n nc_utils.numberToBytesBE(sig.s, 32),\n nc_utils.numberToVarBytesBE(sig.recovery)\n );\n }\n}\n\nexport { Secp256k1 };\n","import * as s_bip32 from '@scure/bip32';\nimport * as s_bip39 from '@scure/bip39';\nimport * as nc_utils from '@noble/curves/abstract/utils';\nimport { base58 } from '@scure/base';\nimport { FixedPointNumber } from '../vcdm/FixedPointNumber';\nimport { Sha256 } from '../vcdm/hash/Sha256';\nimport { HexUInt } from '../vcdm/HexUInt';\nimport { Secp256k1 } from '../secp256k1/Secp256k1';\nimport {\n InvalidHDKey,\n InvalidHDKeyMnemonic,\n InvalidSecp256k1PrivateKey\n} from '@vechain/sdk-errors';\n\n/**\n * This class extends the\n * [BIP32 Hierarchical Deterministic Key](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)\n * [HDKey](https://github.com/paulmillr/scure-bip32) class\n * to provide interoperability with\n * [ethers.js 6 HDNodeWallet](https://docs.ethers.org/v6/api/wallet/#HDNodeWallet).\n *\n * @extends s_bip32.HDKey\n */\nclass HDKey extends s_bip32.HDKey {\n /**\n * Prefix for extended private key\n */\n public static readonly EXTENDED_PRIVATE_KEY_PREFIX = HexUInt.of(\n '0488ade4000000000000000000'\n ).bytes;\n\n /**\n * Prefix for extended public key\n */\n public static readonly EXTENDED_PUBLIC_KEY_PREFIX = HexUInt.of(\n '0488b21e000000000000000000'\n ).bytes;\n\n /**\n * Default VET derivation path.\n *\n * See\n * [SLIP-0044 : Registered coin types for BIP-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md)\n * for more info.\n */\n public static readonly VET_DERIVATION_PATH = \"m/44'/818'/0'/0\";\n\n /**\n * Creates a\n * [BIP32 Hierarchical Deterministic Key](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)\n * from\n * [BIP39 Mnemonic Words](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki)\n * and the given derivation path.\n *\n * @param {string[]} words - An array of words representing the mnemonic.\n * @param {string} path - The derivation path to derive the child node.\n * Default value is {@link VET_DERIVATION_PATH}.\n *\n * @return The derived child hierarchical deterministic key.\n *\n * @throws {InvalidHDKey} If `path` is not valid to derive a node wallet.\n * @throws {InvalidHDKeyMnemonic} If `words` is an invalid array mnemonic.\n *\n * @remarks Security auditable method, depends on\n * * [s_bip32.HDKey.derive](https://github.com/paulmillr/scure-bip32);\n * * [s_bip32.HDKey.fromMasterSeed](https://github.com/paulmillr/scure-bip32);\n * * [s_bip39.mnemonicToSeedSync](https://github.com/paulmillr/scure-bip39).\n */\n public static fromMnemonic(\n words: string[],\n path: string = this.VET_DERIVATION_PATH\n ): HDKey {\n let master: s_bip32.HDKey;\n try {\n master = s_bip32.HDKey.fromMasterSeed(\n s_bip39.mnemonicToSeedSync(words.join(' ').toLowerCase())\n );\n } catch (error) {\n // The error masks any mnemonic words leak.\n throw new InvalidHDKeyMnemonic(\n 'HDNode.fromMnemonic',\n 'Invalid mnemonic words given as input.',\n undefined,\n error\n );\n }\n try {\n return master.derive(path) as HDKey;\n } catch (error) {\n throw new InvalidHDKey(\n 'HDNode.fromMnemonic',\n 'Invalid derivation path given as input.',\n { derivationPath: path },\n error\n );\n }\n }\n\n /**\n * Creates a\n * [BIP32 Hierarchical Deterministic Key](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)\n * from a private key and chain code.\n *\n * @param {Uint8Array} - privateKey The private key.\n * @param {Uint8Array} - chainCode The chain code.\n *\n * @returns Returns the hierarchical deterministic key from `privateKey` and `chainCode`.\n *\n * @throws {InvalidSecp256k1PrivateKey} If the `privateKey` is invalid.\n *\n * @remarks **This method wipes `privateKey`** for security reasons.\n * @remarks Security auditable method, depends on\n * * [base58.encode](https://github.com/paulmillr/scure-base);\n * * {@link Sha256};\n * * [s_bip32.HDKey.fromExtendedKey](https://github.com/paulmillr/scure-bip32).\n */\n public static fromPrivateKey(\n privateKey: Uint8Array,\n chainCode: Uint8Array\n ): HDKey {\n if (privateKey.length === 32) {\n const header = nc_utils.concatBytes(\n this.EXTENDED_PRIVATE_KEY_PREFIX,\n chainCode,\n Uint8Array.of(0),\n privateKey\n );\n privateKey.fill(0); // Clear the private key from memory.\n const checksum = Sha256.of(Sha256.of(header).bytes).bytes.subarray(\n 0,\n 4\n );\n const expandedPrivateKey = nc_utils.concatBytes(header, checksum);\n try {\n return s_bip32.HDKey.fromExtendedKey(\n base58.encode(expandedPrivateKey)\n ) as HDKey;\n } catch {\n throw new InvalidSecp256k1PrivateKey(\n 'HDNode.fromPrivateKey',\n 'Invalid private key path given as input.',\n undefined\n );\n }\n }\n\n // We reach this case if privateKey length is not exactly 32 bytes.\n privateKey.fill(0); // Clear the private key from memory, albeit it is invalid.\n throw new InvalidSecp256k1PrivateKey(\n 'HDNode.fromPrivateKey()',\n 'Invalid private key path given as input. Length must be exactly 32 bytes.',\n undefined\n );\n }\n\n /**\n * Creates a\n * [BIP32 Hierarchical Deterministic Key](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)\n * key from a public key and chain code.\n *\n * @param {Uint8Array} publicKey - The public key bytes.\n * @param {Uint8Array} chainCode - The chain code bytes.\n *\n * @returns {HDKey} Returns the hierarchical deterministic key from `public` and `chainCode`.\n *\n * @throws {InvalidHDKey} if the `publicKey` is invalid.\n *\n * @remarks Security auditable method, depends on\n * * [base58.encode](https://github.com/paulmillr/scure-base);\n * * {@link Secp256k1.compressPublicKey};\n * * {@link Sha256};\n * * [HDKey.fromExtendedKey](https://github.com/paulmillr/scure-bip32).\n */\n public static fromPublicKey(\n publicKey: Uint8Array,\n chainCode: Uint8Array\n ): HDKey {\n if (chainCode.length === 32) {\n const header = nc_utils.concatBytes(\n this.EXTENDED_PUBLIC_KEY_PREFIX,\n chainCode,\n Secp256k1.compressPublicKey(publicKey)\n );\n const checksum = Sha256.of(Sha256.of(header).bytes).bytes.subarray(\n 0,\n 4\n );\n const expandedPublicKey = nc_utils.concatBytes(header, checksum);\n try {\n return s_bip32.HDKey.fromExtendedKey(\n base58.encode(expandedPublicKey)\n ) as HDKey;\n } catch (error) {\n throw new InvalidHDKey(\n 'HDNode.fromPublicKey()',\n 'Invalid public key path given as input.',\n { publicKey },\n error\n );\n }\n }\n\n // We reach this case if chainCode length is not exactly 32 bytes.\n throw new InvalidHDKey(\n 'HDNode.fromPublicKey()',\n 'Invalid chain code given as input. Length must be exactly 32 bytes.',\n { chainCode }\n );\n }\n\n /**\n * Checks if derivation path single component is valid\n *\n * @param component - Derivation path single component to check\n * @param index - Derivation path single component index\n *\n * @returns `true`` if derivation path single component is valid, otherwise `false`.\n *\n */\n private static isDerivationPathComponentValid(\n component: string,\n index: number\n ): boolean {\n // Zero component can be \"m\" or \"number\" or \"number'\", other components can be only \"number\" or \"number'\"\n return (\n // m\n (index === 0 ? component === 'm' : false) ||\n // \"number\"\n FixedPointNumber.isNaturalExpression(component) ||\n // \"number'\"\n (FixedPointNumber.isNaturalExpression(component.slice(0, -1)) &&\n component.endsWith(\"'\"))\n );\n }\n\n /**\n * Checks if BIP32 derivation path is valid.\n *\n * @param derivationPath - Derivation path to check.\n *\n * @returns `true` if derivation path is valid, otherwise `false`.\n */\n public static isDerivationPathValid(derivationPath: string): boolean {\n const bip32Regex = /^m(\\/\\d+'?){3}(\\/\\d+){1,2}$/;\n return bip32Regex.test(derivationPath);\n }\n}\n\nexport { HDKey };\n","import { keccak_256 as nh_keccak_256 } from '@noble/hashes/sha3';\nimport { InvalidOperation } from '@vechain/sdk-errors';\nimport { Hex } from '../Hex';\nimport { HexUInt } from '../HexUInt';\n\n/**\n * Represents the result of an [KECCAK 256](https://keccak.team/keccak.html) hash operation.\n *\n * @extends HexUInt\n */\nclass Keccak256 extends HexUInt {\n /**\n * Generates the [KECCAK 256](https://keccak.team/keccak.html) hash of the given input.\n *\n * @param {bigint | number | string | Uint8Array | Hex} exp - The input value to hash.\n *\n * @returns {Sha256} - The [KECCAK 256](https://keccak.team/keccak.html) hash of the input value.\n *\n * @throws {InvalidOperation} - If a hash error occurs.\n *\n * @remarks Security auditable method, depends on\n * * [`nh_keccak_256`](https://github.com/paulmillr/noble-hashes#sha3-fips-shake-keccak).\n */\n public static of(\n exp: bigint | number | string | Uint8Array | Hex\n ): Keccak256 {\n try {\n const hash = nh_keccak_256(HexUInt.of(exp).bytes);\n return new Keccak256(Hex.POSITIVE, HexUInt.of(hash).digits);\n } catch (e) {\n throw new InvalidOperation('Keccak256.of', 'hash error', {\n exp: `${exp}`, // Needed to serialize bigint values.\n e\n });\n }\n }\n}\n\nexport { Keccak256 };\n","import { HDKey } from '../hdkey/HDKey';\nimport { Hex } from './Hex';\nimport { HexUInt } from './HexUInt';\nimport { InvalidDataType, InvalidHDKey } from '@vechain/sdk-errors';\nimport { Keccak256 } from './hash/Keccak256';\nimport { Secp256k1 } from '../secp256k1/Secp256k1';\nimport { Txt } from './Txt';\n\n/**\n * Represents a VeChain Address as unsigned integer.\n *\n * @extends {HexUInt}\n */\nclass Address extends HexUInt {\n /**\n * The address is 20 bytes hence 40 digits long.\n */\n public static readonly DIGITS: number = 40;\n\n /**\n * It checksums a given hexadecimal address.\n *\n * @param {HexUInt} huint - The HexUInt object representing the hexadecimal value.\n *\n * @returns {string} The checksummed address.\n */\n public static checksum(huint: HexUInt): string {\n const stringAddress: string = huint.digits;\n const hash: string = Keccak256.of(Txt.of(stringAddress).bytes).digits;\n\n let checksum = '';\n for (let i = 0; i < stringAddress.length; i++) {\n checksum +=\n parseInt(hash[i], 16) > 7\n ? stringAddress[i].toUpperCase()\n : stringAddress[i];\n }\n\n return '0x' + checksum;\n }\n\n /**\n * Validate the given expression to be a valid address.\n *\n * @param {string} exp - Expression to validate\n *\n * @returns {boolean} true if the expression is a valid address, false otherwise\n */\n public static isValid(exp: string): boolean {\n return Hex.isValid0x(exp) && exp.length === Address.DIGITS + 2;\n }\n\n /**\n * Create an Address instance from the given expression interpreted as an unsigned integer.\n *\n * @param exp - The expression to convert.\n * It can be of type bigint, number, string, Uint8Array, or HexUInt.\n * Not meaningful `0` digits on the left of the expression can be omitted,\n * the returned address is always 20 bytes, 40 digits expression.\n *\n * @returns {Address} The converted hexadecimal unsigned integer.\n *\n * @throws {InvalidDataType} If the expression is not a valid hexadecimal positive integer expression.\n */\n public static of(\n exp: bigint | number | string | Uint8Array | HexUInt\n ): Address {\n try {\n const huint = HexUInt.of(exp);\n const pad = HexUInt.of(huint.digits.padStart(40, '0'));\n const addressChecksummed: string = Address.checksum(pad);\n return new Address(\n Hex.POSITIVE,\n '0x0', // When we normalize we return the checksummed address as digits\n () => addressChecksummed.substring(2)\n );\n } catch (error) {\n throw new InvalidDataType(\n 'Address.of',\n 'not a valid hexadecimal positive integer expression',\n { exp: `${exp}` },\n error\n );\n }\n }\n\n /**\n * Generates an Address object from the given private key.\n *\n * @param {Uint8Array} privateKey - The private key used to derive the corresponding address.\n * @return {Address} The derived Address object.\n * @throws {InvalidDataType} If the provided private key is invalid or cannot derive an address.\n */\n public static ofPrivateKey(privateKey: Uint8Array): Address {\n try {\n return Address.ofPublicKey(\n Secp256k1.derivePublicKey(privateKey, true)\n );\n } catch (error) {\n throw new InvalidDataType(\n 'Address.ofPrivateKey',\n 'not a valid private key',\n { privateKey: 'private key is obfuscated' },\n error\n );\n }\n }\n\n /**\n * Create an Address instance from the given public key.\n *\n * @param {Uint8Array} publicKey - The public key to convert.\n *\n * @returns {Address} The converted address.\n *\n * @remarks Security auditable method, depends on\n * * {@link Secp256k1.inflatePublicKey}.\n */\n public static ofPublicKey(publicKey: Uint8Array): Address {\n try {\n const publicKeyInflated = Secp256k1.inflatePublicKey(publicKey);\n const publicKeyHash = Keccak256.of(\n publicKeyInflated.slice(1)\n ).bytes;\n return Address.of(publicKeyHash.slice(12));\n } catch (error) {\n throw new InvalidDataType(\n 'Address.ofPublicKey',\n 'not a valid public key',\n { publicKey: `${publicKey}` },\n error\n );\n }\n }\n\n /**\n * Derives the address from a given list of words of\n * [BIP39 Mnemonic Words](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki)\n * and a [BIP44 Derivation Path](https://github.com/satoshilabs/slips/blob/master/slip-0044.md)\n * as in the examples.\n *\n * Secure audit function.\n * - {@link bip32.HDKey}(https://github.com/paulmillr/scure-bip32)\n * - {@link HDKey}\n *\n * @example `m/0` (default)\n * @example `m/0/2`\n * @example `m/0/2/4/6`\n *\n * @param {string[]} mnemonic - Mnemonic used to generate the HD node.\n * @param {string} [path='m/0'] - The derivation path from the current node.\n * @return {Address} - The derived address.\n * @throws {InvalidHDKey}\n *\n */\n public static ofMnemonic(\n mnemonic: string[],\n path: string = 'm/0'\n ): Address {\n const root = HDKey.fromMnemonic(mnemonic);\n try {\n // Public key is always available.\n return Address.ofPublicKey(\n root.derive(path).publicKey as Uint8Array\n );\n } catch (error) {\n throw new InvalidHDKey(\n 'mnemonic.deriveAddress()',\n 'Invalid derivation path given as input.',\n { derivationPath: path },\n error\n );\n }\n }\n}\n\nexport { Address };\n","import { Hex } from './Hex';\nimport { HexUInt } from './HexUInt';\nimport { InvalidDataType } from '@vechain/sdk-errors';\n\n/**\n * The BlockRef class represents a Thor block ID value, which is a hexadecimal positive integer having 64 digits.\n *\n * @extends HexInt\n */\nclass BlockRef extends HexUInt {\n /**\n * Number of digits to represent a block reference value.\n *\n * @remarks The `0x` prefix is excluded.\n *\n * @type {number}\n */\n private static readonly DIGITS = 16;\n\n /**\n * Constructs a BlockRef object with the provided hexadecimal value.\n *\n * @param {HexUInt} huint - The hexadecimal value representing the BlockId.\n */\n protected constructor(huint: HexUInt) {\n super(Hex.POSITIVE, huint.fit(BlockRef.DIGITS).digits);\n }\n\n /**\n * Check if the given expression is a valid BlockRef.\n *\n * @param {string} exp - The expression to be validated.\n *\n * @return {boolean} Returns true if the expression is a valid BlockRef, false otherwise.\n */\n public static isValid(exp: string): boolean {\n return Hex.isValid(exp) && HexUInt.REGEX_HEXUINT_PREFIX.test(exp)\n ? exp.length === BlockRef.DIGITS + 2\n : exp.length === BlockRef.DIGITS;\n }\n\n /**\n * Determines whether the given string is a valid hex number prefixed with '0x'.\n *\n * @param {string} exp - The hex number to be checked.\n *\n * @returns {boolean} - True if the hex number is valid, false otherwise.\n */\n public static isValid0x(exp: string): boolean {\n return HexUInt.REGEX_HEXUINT_PREFIX.test(exp) && BlockRef.isValid(exp);\n }\n\n /**\n * Creates a new BlockRef object from the given expression.\n *\n * @param {bigint | number | string | Hex | Uint8Array} exp - The expression to create the BlockRef from.\n * It can be one of the following types:\n * - bigint: A BigInteger value that represents the BlockRef.\n * - number: A number value that represents the BlockRef.\n * - string: A string value that represents the BlockRef.\n * - HexUInt: A HexUInt object that represents the BlockRef.\n * - Uint8Array: A Uint8Array object that represents the BlockRef.\n *\n * @returns {BlockRef} - A new BlockRef object created from the given expression.\n *\n * @throws {InvalidDataType} If the given expression is not a valid hexadecimal positive integer expression.\n */\n public static of(\n exp: bigint | number | string | Uint8Array | HexUInt\n ): BlockRef {\n try {\n if (exp instanceof HexUInt) {\n return new BlockRef(exp);\n }\n return new BlockRef(HexUInt.of(exp));\n } catch (e) {\n throw new InvalidDataType(\n 'BlockRef.of',\n 'not a BlockRef expression',\n { exp: `${exp}` }, // Needed to serialize bigint values.\n e\n );\n }\n }\n}\n\nexport { BlockRef };\n","import { blake2b as nh_blake2b } from '@noble/hashes/blake2b';\nimport { InvalidOperation } from '@vechain/sdk-errors';\nimport { Hex } from '../Hex';\nimport { HexUInt } from '../HexUInt';\n\n/**\n * Represents the result of an [BLAKE](https://en.wikipedia.org/wiki/BLAKE_(hash_function)) [BlAKE2B 256](https://www.blake2.net/) hash operation.\n *\n * @extends HexUInt\n */\nclass Blake2b256 extends HexUInt {\n /**\n * Generates the [BLAKE](https://en.wikipedia.org/wiki/BLAKE_(hash_function)) [BLAKE2B 256](https://www.blake2.net/) hash of the given input.\n *\n * @param {bigint | number | string | Uint8Array | Hex} exp - The input value to hash.\n *\n * @returns {Sha256} - The [BLAKE2B 256](https://www.blake2.net/) hash of the input value.\n *\n * @throws {InvalidOperation} - If a hash error occurs.\n *\n * @remarks Security auditable method, depends on\n * * [`nh_blake2b.create(...).update(...).digest(...)`](https://github.com/paulmillr/noble-hashes#sha3-fips-shake-keccak).\n */\n public static of(\n exp: bigint | number | string | Uint8Array | Hex\n ): Blake2b256 {\n try {\n const hash = nh_blake2b\n .create({ dkLen: 32 })\n .update(HexUInt.of(exp).bytes)\n .digest();\n return new Blake2b256(Hex.POSITIVE, HexUInt.of(hash).digits);\n } catch (e) {\n throw new InvalidOperation('Blake2b256.of', 'hash error', {\n exp: `${exp}`, // Needed to serialize bigint values.\n e\n });\n }\n }\n}\n\nexport { Blake2b256 };\n","import * as nc_utils from '@noble/curves/abstract/utils';\nimport { Blake2b256 } from './hash/Blake2b256';\nimport { Hex } from './Hex';\nimport { InvalidDataType, InvalidOperation } from '@vechain/sdk-errors';\nimport { type VeChainDataModel } from './VeChainDataModel';\n\n/**\n * A [Bloom Filter](https://en.wikipedia.org/wiki/Bloom_filter)\n * is a space-efficient probabilistic data structure\n * that is used to test whether an element is a member of a set.\n *\n * @remarks False positive matches are possible, but false negatives are not.\n *\n * @implements {VeChainDataModel<Hex>}\n */\nclass BloomFilter implements VeChainDataModel<BloomFilter> {\n /**\n * Return the Bloom filter structure: an array of `m` bits per key encoding if a key is not part of the structure.\n *\n * @typedef {Uint8Array} bytes\n */\n public readonly bytes: Uint8Array;\n\n /**\n * Return the number of hash functions used to compute this Bloom filter.\n *\n * @type {number}\n */\n public readonly k: number;\n\n /**\n * Creates a new instance of this class.\n *\n * @param {Uint8Array} bytes - The Bloom filter structure of `m` bits per key encoding if the key\n * likely belongs to the structure or surely doesn't.\n * @param {number} k - The number of hash functions used to compute this Bloom filter.\n *\n */\n constructor(bytes: Uint8Array, k: number) {\n this.bytes = bytes;\n this.k = k;\n }\n\n /**\n * Return the Bloom filter data structure represented as a {@link bigint} value.\n *\n * @returns {bigint} - The Bloom filter data structure represented as a {@link bigint} value.\n */\n get bi(): bigint {\n return nc_utils.bytesToNumberBE(this.bytes);\n }\n\n /**\n * Return the Bloom filter data structure represented as a {@link number} value.\n *\n * @returns {bigint} - The Bloom filter data structure represented as a {@link number} value.\n *\n * @throws InvalidDataType if the data structure of the bloom filter can't be represented as a number\n * because underflow or overflow number safe integer range according\n * [IEEE 754 double precision 64 bits floating point format](https://en.wikipedia.org/wiki/Double-precision_floating-point_format).\n *\n * @remarks Preferably use {@link bi} because the Bloom filter data structure can always be represented as a {@link bigint} value.\n */\n get n(): number {\n const bi = this.bi;\n if (Number.MIN_SAFE_INTEGER <= bi && bi <= Number.MAX_SAFE_INTEGER) {\n return Number(bi);\n }\n throw new InvalidDataType(\n 'BloomFilter.n',\n 'not in the safe number range',\n {\n bytes: this.bytes,\n k: this.k\n }\n );\n }\n\n /**\n * Compare the current BloomFilter instance with another BloomFilter instance according their\n * * {@link bytes} data structure first,\n * * {@link k} if the data structures are equal.\n *\n * @param {BloomFilter} that - The BloomFilter instance to compare with.\n *\n * @return {number} - Returns a negative number if the current instance is less than the provided instance,\n * returns zero if they are equal, and returns a positive number if the current instance is greater than the provided instance.\n */\n compareTo(that: BloomFilter): number {\n if (this.bi < that.bi) {\n return -1;\n } else if (this.bi > that.bi) {\n return 1;\n } else {\n return this.k - that.k;\n }\n }\n\n /**\n * Checks if the current BloomFilter instance is equal to another BloomFilter instance.\n *\n * @param {BloomFilter} that - The other BloomFilter instance to compare with.\n *\n * @return {boolean} - Returns true if the current BloomFilter instance is equal to the other BloomFilter instance, otherwise returns false.\n */\n isEqual(that: BloomFilter): boolean {\n return this.bi === that.bi && this.k === that.k;\n }\n\n /**\n * Checks if the specified key may be contained within this Bloom filter or surely isn't.\n *\n * @param {Hex|Uint8Array} key - The key to check. It can be either a Hex object or a Uint8Array.\n *\n * @return {boolean} Returns true if this Bloom filter may contain the key, otherwise returns false.\n *\n * @remarks False positive matches are possible, but false negatives are not.\n * @remarks Security auditable method, depends on\n * * {@link hash}.\n */\n public contains(key: Hex | Uint8Array): boolean {\n return distribute(\n hash(key instanceof Hex ? key.bytes : key),\n this.k,\n this.bytes.byteLength * 8,\n (index, bit) => {\n return (this.bytes[index] & bit) === bit;\n }\n );\n }\n\n /**\n * Calculates the optimal number of bits per key (`m` in math literature) based\n * on the number of hash functions (`k` in math literature) used to generate the Bloom Filter.\n *\n * Mathematically, `m` is approximated as `(k / ln(2))` which is simplified\n * to the higher integer close to `(m / 0.69)` for computational efficiency.\n * It also ensures that `k` is within a practical range [1, 30], hence the function\n * - returns `2` for `k = 1`,\n * - returns `44` for `k >= 30`.\n *\n * @param {number} k - The number of keys.\n *\n * @return {number} - The number of bits per key.\n */\n public static computeBestBitsPerKey(k: number): number {\n if (k <= 1) return 2;\n return k >= 30 ? 44 : Math.ceil(k / 0.69);\n }\n\n /**\n * Calculates the optimal number of hash functions (`k` in math literature)\n * based on bits per key (`m` in math literature).\n *\n * Mathematically, `k` is approximated as `(m * ln(2))` which is simplified\n * to the lower integer close to `(m * 0.69)` for computational efficiency.\n * It also ensures that `k` stays within a practical range [1, 30].\n *\n * @param m - The number of bits per key.\n *\n * @returns The calculated optimal `k` value.\n */\n public static computeBestHashFunctionsQuantity(m: number): number {\n const k = Math.floor(m * 0.69); // m * ln(2), 0.69 =~ ln(2)\n if (k < 1) return 1;\n return k > 30 ? 30 : k;\n }\n\n /**\n * Checks if the current BloomFilter instance is possible to join with another BloomFilter instance.\n *\n * @param {BloomFilter} other - The BloomFilter instance to check if it is possible to join with the current instance.\n *\n * @return {boolean} - Returns true if the BloomFilter instances have the same 'k' value and 'bytes' length, false otherwise.\n */\n public isJoinable(other: BloomFilter): boolean {\n return this.k === other.k && this.bytes.length === other.bytes.length;\n }\n\n /**\n * Joins the current BloomFilter with another BloomFilter by performing a bitwise OR operation on the\n * data structures of the filters.\n * Both filters must have been generated with the same number of hash functions, and they must have the same length.\n *\n * @param other - The BloomFilter to join with.\n *\n * @returns A new BloomFilter that represents the result of the join operation.\n * They keys made this and `other` filter may belong to the returned filter.\n * Any key not part of the joined filter surely doesn't belong to the returned filter.\n *\n * @throws {InvalidOperation} If the k values of the BloomFilters are different.\n * @throws {InvalidOperation} If the length of the byte arrays are different.\n */\n public join(other: BloomFilter): BloomFilter {\n if (this.k !== other.k) {\n throw new InvalidOperation(\n 'BloomFilter.join',\n 'different k values',\n {\n this: this,\n other\n }\n );\n }\n\n if (this.bytes.length !== other.bytes.length) {\n throw new InvalidOperation(\n 'BloomFilter.join',\n 'different length values',\n {\n this: this,\n other\n }\n );\n }\n\n const joinedBytes = new Uint8Array(this.bytes.length);\n for (let index = 0; index < this.bytes.length; index++) {\n joinedBytes[index] = this.bytes[index] | other.bytes[index];\n }\n\n return new BloomFilter(joinedBytes, this.k);\n }\n\n /**\n * Creates a new instance of BloomFilterBuilder and adds the specified keys to it.\n * * Call {@link BloomFilterBuilder.add} to add more keys.\n * * Call {@link BloomFilterBuilder.build} to create a new Bloom filter once\n *\n * @param {...(Hex[] | Uint8Array[])} keys - The keys to be added to the BloomFilterBuilder.\n *\n * @returns {BloomFilterBuilder} - A new instance of BloomFilterBuilder with the specified keys added.\n *\n * @remarks Security auditable method, depends on\n * * {@link BloomFilterBuilder.add}.\n */\n public static of(...keys: Hex[] | Uint8Array[]): BloomFilterBuilder {\n const builder = new BloomFilterBuilder();\n builder.add(...keys);\n return builder;\n }\n} // ~ BloomFilter\n\n/**\n * The `BloomFilterBuilder` class provides methods for constructing a Bloom filter,\n * This builder class allows you to add keys to the filter and specify its `m` (bits per key) and `k` (hash functions)\n * parameters before building it.\n *\n * @see {BloomFilter.of}\n *\n */\nclass BloomFilterBuilder {\n /**\n * The default value number of hash functions used to create {@link BloomFilter} instances.\n */\n private static readonly DEFAULT_K = 5;\n\n /**\n * Map each element of the keys as likely part of the data structure of the Bloom filter to build.\n * Each key is mapped in `m` bits using `k` hash functions.\n *\n * @see {hash}\n */\n private readonly hashMap = new Map<number, boolean>();\n\n /**\n * Adds one or more keys to the Bloom filter to create.\n *\n * @param {Hex[] | Uint8Array[]} keys - The keys to be added to Bloom filter to create.\n *\n * @return {this} - Returns this {@link BloomFilterBuilder} instance, the {@link this.hashMap} is updated to\n * map the keys presence in the filter data structure.\n *\n * @remarks Security auditable method, depends on\n * * {@link hash}.\n */\n public add(...keys: Hex[] | Uint8Array[]): this {\n for (const key of keys) {\n this.hashMap.set(hash(key instanceof Hex ? key.bytes : key), true);\n }\n return this;\n }\n\n /**\n * Builds a Bloom filter with the specified parameters and returns it.\n *\n * @param k - The number of hash functions to use in the Bloom filter. to BloomFilterBuilder.DEFAULT_K.\n * @param m - The number of bits per key in the Bloom filter. Defaults to the value computed by BloomFilter.computeBestBitsPerKey(k).\n *\n * @return The built Bloom filter.\n */\n public build(\n k: number = BloomFilterBuilder.DEFAULT_K,\n m: number = BloomFilter.computeBestBitsPerKey(k)\n ): BloomFilter {\n // Compute bloom filter size in bytes\n let nBytes = Math.floor((this.hashMap.size * m + 7) / 8);\n // Enforce a minimum bloom filter length to reduce very high false positive rate for small n\n nBytes = nBytes < 8 ? 8 : nBytes;\n const bits = new Uint8Array(nBytes);\n // Filter bit length\n const nBits = nBytes * 8;\n for (const hash of this.hashMap.keys()) {\n distribute(hash, k, nBits, (index, bit) => {\n bits[index] |= bit;\n return true;\n });\n }\n return new BloomFilter(bits, k);\n }\n} // ~ BloomFilterBuilder\n\n/**\n * Upper limit of an unsigned 32 bits value pre-computed for sake of efficiencyto be used\n * in the {@link addAndWrapAsUInt32} function.\n */\nconst UINT32_LIMIT = 2 ** 32;\n\n/**\n * Adds two numbers and wraps the result as a 32-bit unsigned integer.\n *\n * @param {number} a - The first number to add.\n * @param {number} b - The second number to add.\n *\n * @return {number} The sum of `a` and `b`, wrapped as a 32-bit unsigned integer.\n *\n * @remarks JavaScript represents numbers using the\n * [IEEE 754 double precision 64 bits floating point format](https://en.wikipedia.org/wiki/Double-precision_floating-point_format)\n * which does not automatically handle wrapping of integers.\n * This function ensures that the addition of two numbers returns a result that is wrapped to a 32-bit unsigned integer,\n * emulating the behavior of integer addition in languages with fixed-width integers.\n */\nfunction addAndWrapAsUInt32(a: number, b: number): number {\n return (a + b) % UINT32_LIMIT;\n}\n\n/**\n * Distributes a given hash value across a set of bits.\n *\n * @param {number} hash - The hash value to distribute.\n * @param {number} k - The number of times to distribute the hash value.\n * @param {number} m - The total number of bits to distribute the hash value across.\n * @param {function} collision - The callback function to be called for each distributed bit.\n * It takes two arguments: index (the index of the byte containing the distributed bit)\n * and bit (the distributed bit itself).\n *\n * @returns {boolean} Returns true if all bits were successfully distributed, false otherwise.\n */\nfunction distribute(\n hash: number,\n k: number,\n m: number,\n collision: (index: number, bit: number) => boolean\n): boolean {\n const delta = ((hash >>> 17) | (hash << 15)) >>> 0;\n for (let i = 0; i < k; i++) {\n const bitPos = hash % m;\n if (!collision(Math.floor(bitPos / 8), 1 << bitPos % 8)) {\n return false;\n }\n hash = addAndWrapAsUInt32(hash, delta);\n }\n return true;\n}\n\n/**\n * Computes the hash of the given key using the {@link Blake2b256} algorithm.\n *\n * @param {Uint8Array} key - The key to be hashed.\n *\n * @return {number} The computed hash value as a number.\n *\n * @remarks Security auditable method, depends on\n * * {@link Blake2b256.of}.\n */\nfunction hash(key: Uint8Array): number {\n return Number(\n nc_utils.bytesToNumberBE(Blake2b256.of(key).bytes.slice(0, 4))\n );\n}\n\nexport { BloomFilter };\n","import { type Currency } from './Currency';\nimport { type FixedPointNumber } from '../FixedPointNumber';\nimport { Txt } from '../Txt';\nimport { InvalidDataType } from '@vechain/sdk-errors';\n\n/**\n * Abstract class representing a coin, implementing the Currency interface.\n */\nabstract class Coin implements Currency {\n /**\n * Represent coin {@link code} denomination.\n */\n private readonly _code: Txt;\n\n /**\n * Represent the coin {@link value}.\n *\n * @type {FixedPointNumber}\n */\n private readonly _value: FixedPointNumber;\n\n /**\n * Creates an instance of the class with the specified code and value.\n *\n * @param {Txt} code - The code associated with this instance.\n * @param {FixedPointNumber} value - The value associated with this instance.\n */\n protected constructor(code: Txt, value: FixedPointNumber) {\n this._code = code;\n this._value = value;\n }\n\n /**\n * Return the code as a Txt object.\n *\n * @return {Txt} The code object\n *\n * @remarks Since currency codes likely use Unicode composite symbols,\n * {@link Txt} type enforce the representation of the code is normalized.\n */\n get code(): Txt {\n return this._code;\n }\n\n /**\n * Return the current value as an FixedPointNumber (Fixed-Point Number).\n *\n * @return {FixedPointNumber} The current value in Fixed-Point Number format.\n */\n get value(): FixedPointNumber {\n return this._value;\n }\n\n /**\n * Returns the integer part of the FixedPointNumber {@link value}.\n *\n * @return {bigint} the integer part of this FixedPointNumber {@link value}.\n *\n * @throws {InvalidOperation} If the {@link value} is not finite.\n *\n * @remarks Do not use for financial math: apply {@link FixedPointNumber} methods instead.\n */\n get bi(): bigint {\n return this._value.bi;\n }\n\n /**\n * Returns the array of bytes representing the *Normalization Form Canonical Composition*\n * [Unicode Equivalence](https://en.wikipedia.org/wiki/Unicode_equivalence)\n * of the textual expression '{@link value} {@link code}'.\n */\n get bytes(): Uint8Array {\n return Txt.of(this.toString()).bytes;\n }\n\n /**\n * Return this {@linl value} approximated as {@link number}.\n *\n * @remarks Do not use for financial math: apply {@link FixedPointNumber} methods instead.\n */\n get n(): number {\n return this._value.n;\n }\n\n /**\n * Compares this Currency object with another Currency object for order.\n *\n * @param {Currency} that - The Currency object to be compared.\n * @return {number} A negative integer, zero, or a positive integer as this Currency\n * is less than, equal to, or greater than the specified Currency.\n * @throws {InvalidDataType} If the currency codes do not match.\n */\n compareTo(that: Currency): number {\n if (this.code.isEqual(that.code)) {\n return this.value.compareTo(that.value);\n }\n throw new InvalidDataType('Coin.compareTo', 'not VET currency', {\n // eslint-disable-next-line sonarjs/no-base-to-string, @typescript-eslint/no-base-to-string\n that: `${that}` // Needed to serialize bigint value.\n });\n }\n\n /**\n * Determines if this Currency object is equal to another Currency object.\n *\n * @param {Currency} that - The Currency object to compare with the current instance.\n * @return {boolean} - `true` if the objects are considered equal, otherwise `false`.\n */\n isEqual(that: Currency): boolean {\n try {\n return this.compareTo(that) === 0;\n } catch {\n return false;\n }\n }\n\n /**\n * Returns the textual representation of this currency as\n * '{@link value} {@link code}'.\n *\n * @return A string that contains the value and code properties of the object.\n */\n public toString(): string {\n return `${this.value.toString()} ${this._code}`;\n }\n}\n\nexport { Coin };\n","import { FixedPointNumber } from '../FixedPointNumber';\n\n/**\n * Enumeration representing units (i.e. order of magnitude)\n * of cryptocurrency (e.g., ETH or VET).\n * Each unit is defined by its name and its corresponding decimal place shift.\n * The decimal place shift if the exponent of the power of 10 to multiply\n * a value expressed in the name unit to result in the equivalent value\n * expressed in `wei` unit.\n *\n * @remarks The unit `ether` refers to an order of magnitude, not to the\n * `ETH` cryptocurrency, albeit 1 ETH = 10E18 wei in\n * [scientific notation](https://en.wikipedia.org/wiki/Scientific_notation).\n *\n * @enum {number}\n */\nenum Units {\n /**\n * 1 ether = 1,000,000,000,000,000,000 wei. 0 fractional digits FixedPointNumber.\n */\n wei = 0,\n\n /**\n * 1 ether = 1,000,000,000,000,000 kwei. 3 fractional digits FixedPointNumber.\n */\n kwei = 3,\n\n /**\n * 1 ether = 1,000,000,000,000 mwei. 6 fractional digits FixedPointNumber.\n */\n mwei = 6,\n\n /**\n * 1 ether = 1,000,000,000 gwei. 9 fractional digits FixedPointNumber.\n */\n gwei = 9,\n\n /**\n * 1 ether = 1,000,000,000 szabo. 12 fractional digits FixedPointNumber.\n */\n szabo = 12,\n\n /**\n * 1 ether = 1,000,000 finney. 15 fractional digits FixedPointNumber.\n */\n finney = 15,\n\n /**\n * 18 fractional diguts FixedPointNumber.\n */\n ether = 18\n}\n\n/**\n * Namespace for unit conversion functions,\n * providing the same functionalities of\n * [ethers v6 Unit Conversion](https://docs.ethers.org/v6/api/utils/#about-units).\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nnamespace Units {\n /**\n * Convert a value expressed in {@link Units.wei} as a string\n * representing the same value expressed in {@link Units.ether}.\n *\n * @param {FixedPointNumber} wei - The value in {@link Units.wei}.\n * @return {string} The formatted string representing the value in\n * {@link Units.ether}.\n *\n * @remarks The term `ether` refers to the order of magnitude 10E18,\n * not to the `ETH` cryptocurrency.\n *\n * @see [ethers formatEther](https://docs.ethers.org/v6/api/utils/#formatEther)\n */\n export function formatEther(wei: FixedPointNumber): string {\n return formatUnits(wei, Units.ether);\n }\n\n /**\n * Convert a value expressed in {@link Units.wei} as a string\n * representing the same value expressed in `unit`.\n *\n * @param {FixedPointNumber} wei - The value in {@link Units.wei}.\n * @param {Units} unit The order of magnitude to express the `wei` value.\n * @return {string} The formatted string representing the value\n * in the named `unit`.\n *\n * @remarks The term `ether` refers to the order of magnitude 10E18,\n * not to the `ETH` cryptocurrency.\n *\n * @see [ethers formatUnits](https://docs.ethers.org/v6/api/utils/#formatUnits)\n */\n export function formatUnits(\n wei: FixedPointNumber,\n unit: Units = Units.ether\n ): string {\n const fpn = wei.div(FixedPointNumber.of(10n ** BigInt(unit)));\n return fpn.isInteger() ? `${fpn}.0` : `${fpn}`;\n }\n\n /**\n * Parse the decimal string expressing a value in {@link Units.ether}\n * to return a {@link FixedPointNumber} value expressed in {@link Units.wei}.\n\n * @param ether = The representation of a numeric value expressed\n * in {@link Units.ether}.\n * @return The equivalent value in {@link Units.wei}.\n *\n * @throws {InvalidDataType} If `exp` is not a numeric expression.\n *\n * @remarks The term `ether` refers to the order of magnitude 10E18,\n * not to the `ETH` cryptocurrency.\n *\n * @see [ethers parseEther](https://docs.ethers.org/v6/api/utils/#parseEther)\n */\n export function parseEther(ether: string): FixedPointNumber {\n return parseUnits(ether, Units.ether);\n }\n\n /**\n * Parse the decimal string expressing a value in the named `unit`\n * ro return a {@link FixedPointNumber} value expressed in {@link Units.wei}.\n\n * @param {string} exp - The representation of a numeric value expressed\n * in {@link Units.ether}.\n * @param {Units} unit - The order of magnitude to use to parse the `exp`\n * representation.\n *\n * @throws {InvalidDataType} If `exp` is not a numeric expression.\n *\n * @remarks The term `ether` refers to the order of magnitude 10E18,\n * not to the `ETH` cryptocurrency.\n *\n * @see [ethers parseUnits](https://docs.ethers.org/v6/api/utils/#parseUnits)\n */\n export function parseUnits(\n exp: string,\n unit: Units = Units.ether\n ): FixedPointNumber {\n return FixedPointNumber.of(exp).times(\n FixedPointNumber.of(10n ** BigInt(unit))\n );\n }\n}\n\nexport { Units };\n","import { Coin } from './Coin';\nimport { FixedPointNumber } from '../FixedPointNumber';\nimport { Txt } from '../Txt';\nimport { Units } from './Units';\n\n/**\n * Represents a\n * [VeChain VET](https://docs.vechain.org/introduction-to-vechain/dual-token-economic-model/vechain-vet)\n * monetary amount.\n *\n * @extends Coin\n */\nclass VET extends Coin {\n /**\n * The code for VET is the sequence of Unicode\n * - U+1D64D - mathematical double strike capital letter 'V',\n * - U+039F - Greek capital letter 'Xi',\n * - U+0054 - Latin capital letter 'T'.\n */\n public static readonly CODE = Txt.of('𝕍ΞT');\n\n /**\n * Wei fractional digits to express this value.\n */\n private static readonly WEI_FD = 18n;\n\n /**\n * Represents this monetary amount in terms of {@link Units.wei}.\n *\n * @type {bigint}\n */\n public readonly wei: bigint = this.value.dp(VET.WEI_FD).scaledValue;\n\n /**\n * Create a new instance with the given `value`.\n *\n * @param {FixedPointNumber} value The value to be used for initializing the instance.\n */\n protected constructor(value: FixedPointNumber) {\n super(VET.CODE, value);\n }\n\n /**\n * Return a new VET instance with the specified value and unit.\n *\n * @param {bigint | number | string | FixedPointNumber} value - The numerical value for the VET instance.\n * @param {Units} unit - The unit for the value.\n * Defaults to {@link Units.ether} if not provided.\n * @return {VET} A new VET instance with the provided value and unit.\n *\n * @throws {InvalidDataType} If `value` is not a numeric expression.\n */\n public static of(\n value: bigint | number | string | FixedPointNumber,\n unit: Units = Units.ether\n ): VET {\n const fpn =\n value instanceof FixedPointNumber\n ? value\n : FixedPointNumber.of(value);\n return new VET(\n fpn.div(FixedPointNumber.of(10n ** (VET.WEI_FD - BigInt(unit))))\n );\n }\n}\n\nexport { VET };\n","import { Coin } from './Coin';\nimport { FixedPointNumber } from '../FixedPointNumber';\nimport { Txt } from '../Txt';\nimport { Units } from './Units';\n\n/**\n * Represents a\n * [VeChain VeThor](https://docs.vechain.org/introduction-to-vechain/dual-token-economic-model/vethor-vtho)\n * monetary amount.\n *\n * @extends Coin\n */\nclass VTHO extends Coin {\n /**\n * The code for VET is the sequence of Unicode\n * - U+1D64D - mathematical double strike capital letter 'V',\n * - U+0054 - Latin capital letter 'T',\n * - U+0048 - Latin capital letter 'H',\n * - U+004F - Latin capital letter 'O'.\n */\n public static readonly CODE = Txt.of('𝕍THO');\n\n /**\n * Wei fractional digits to express this value.\n */\n private static readonly WEI_FD = 18n;\n\n /**\n * Represents this monetary amount in terms of {@link Units.wei}.\n *\n * @type {bigint}\n */\n public readonly wei: bigint = this.value.dp(VTHO.WEI_FD).scaledValue;\n\n /**\n * Create a new instance with the given `value`.\n *\n * @param {FixedPointNumber} value The value to be used for initializing the instance.\n */\n protected constructor(value: FixedPointNumber) {\n super(VTHO.CODE, value);\n }\n\n /**\n * Return a new VTHO instance with the specified value and unit.\n *\n * @param {bigint | number | string | FixedPointNumber} value - The numerical value for the VTHO instance.\n * @param {Units} unit - The unit for the value.\n * Defaults to {@link Units.ether} if not provided.\n * @return {VTHO} A new VTHO instance with the provided value and unit.\n *\n * @throws {InvalidDataType} If `value` is not a numeric expression.\n */\n public static of(\n value: bigint | number | string | FixedPointNumber,\n unit: Units = Units.ether\n ): VTHO {\n const fpn =\n value instanceof FixedPointNumber\n ? value\n : FixedPointNumber.of(value);\n return new VTHO(\n fpn.div(FixedPointNumber.of(10n ** (VTHO.WEI_FD - BigInt(unit))))\n );\n }\n}\n\nexport { VTHO };\n","import { type Address } from '../Address';\nimport { Units } from './Units';\n\n/**\n * Represents a generic Token\n * A token has base units (e.g. wei) and display units\n * For example 1 VTHO (1 in display units) = 10^18 base units (wei)\n */\nabstract class Token {\n /**\n * Base units to represent the token\n */\n abstract readonly units: Units;\n\n /**\n * Token name\n */\n abstract readonly name: string;\n\n /**\n * Token contract address\n */\n abstract readonly tokenAddress: Address;\n\n // Store the token's value in wei (smallest possible)\n protected _valueWei: bigint;\n\n /**\n * Create a new instance\n */\n constructor() {\n // covert value to wei units\n this._valueWei = 0n;\n }\n\n /**\n * Initilises the instance with a value\n * @param value Token value\n * @param valueUnits Units for the token value\n */\n protected initialize(value: bigint, valueUnits?: Units): undefined {\n this._valueWei = this.convertToWei(value, valueUnits);\n }\n\n /**\n * Converts provided value to the tokens base units value\n * @param value Provided value\n * @param valueUnits Units of the provided value\n * @returns The value converted to base units\n */\n private convertWeiToBaseUnits(): bigint {\n const diffUnits = BigInt(this.units - Units.wei);\n return this._valueWei * 10n ** diffUnits;\n }\n\n /**\n * Converts a value to the tokens internal representation of Wei\n * @param value Value to convert\n * @param valueUnits Units the value is in\n * @returns Wei value conversion\n */\n private convertToWei(value: bigint, valueUnits?: Units): bigint {\n const convertUnits = valueUnits ?? this.units;\n const diffUnits = BigInt(convertUnits);\n const baseValue = value * 10n ** diffUnits;\n return baseValue;\n }\n\n /**\n * Get the token's value in base units.\n * @returns {bigint} Token value in base units\n */\n public get value(): bigint {\n return this.convertWeiToBaseUnits();\n }\n\n /**\n * Converts the base unit value to a human-readable string.\n * If `displayDecimals` is provided the value is rounded to that number of decimals\n * Otherwise, it falls back to the token's inherent `units`.\n * @param {number} displayDecimals Number of decimal places to round to\n */\n public format(displayDecimals?: number): string {\n const divisor = 10n ** BigInt(Units.ether);\n const whole = this._valueWei / divisor;\n const fraction = this._valueWei % divisor;\n const decimal = Number(`${whole}.${fraction}`);\n const result =\n displayDecimals === undefined\n ? decimal.toFixed(Units.ether - this.units)\n : decimal.toFixed(displayDecimals);\n return result;\n }\n}\n\nexport { Token };\n","import {\n type BufferOutput,\n type DataOutput,\n type RLPInput,\n type RLPValidObject\n} from '../types';\n\n/* ------- RLP Profile Types ------- */\n/**\n * `RLPProfile` Interface - Describes the profile of the RLP encoding.\n */\ninterface RLPProfile {\n name: string;\n kind: ScalarKind | ArrayKind | StructKind;\n}\n\n/**\n * `ArrayKind` Interface - Describes an array-kind in the RLP encoding profile.\n */\ninterface ArrayKind {\n item: RLPProfile['kind'];\n}\n\n/**\n * `StructKind` Type - Describes a structured-kind in the RLP encoding profile using an array of `RLPProfile`.\n */\ntype StructKind = RLPProfile[];\n\n/**\n * `ScalarKind` Abstract Class - A base for scalar kinds providing contract for data and buffer manipulations.\n */\nabstract class ScalarKind {\n /**\n * Abstract method to handle data encoding.\n * @param data - The data to encode.\n * @param context - Contextual information for error messaging.\n * @returns An object providing a mechanism to encode the data into a Uint8Array.\n */\n public abstract data(\n data: RLPInput | RLPValidObject,\n context: string\n ): DataOutput;\n\n /**\n * Abstract method to handle buffer decoding.\n * @param buffer - The buffer to decode.\n * @param context - Contextual information for error messaging.\n * @returns An object providing a mechanism to decode the buffer back into data.\n */\n public abstract buffer(buffer: Uint8Array, context: string): BufferOutput;\n}\n\nexport { ScalarKind, type RLPProfile };\n","import { RLP as EthereumjsRLP } from '@ethereumjs/rlp';\nimport { bytesToNumberBE } from '@noble/ciphers/utils';\nimport { InvalidDataType, InvalidRLP } from '@vechain/sdk-errors';\nimport { Hex } from '../../Hex';\nimport { type VeChainDataModel } from '../../VeChainDataModel';\nimport { ScalarKind, type RLPProfile } from './kind/ScalarKind';\nimport { type RLPInput, type RLPValidObject, type RLPValueType } from './types';\n\nclass RLP implements VeChainDataModel<RLP> {\n public readonly encoded: Uint8Array;\n public readonly decoded: RLPInput;\n\n protected constructor(data: RLPInput);\n protected constructor(data: Uint8Array);\n protected constructor(data: RLPInput | Uint8Array) {\n // ArrayBuffer.isView so we support https://github.com/vitest-dev/vitest/issues/5183\n this.decoded = ArrayBuffer.isView(data)\n ? EthereumjsRLP.decode(data)\n : data;\n this.encoded = ArrayBuffer.isView(data)\n ? data\n : EthereumjsRLP.encode(data);\n }\n\n /**\n * Returns the bigint representation of the encoded data in the RLP instance.\n * @returns {bigint} The bigint representation of the encoded data.\n */\n get bi(): bigint {\n return bytesToNumberBE(this.bytes);\n }\n\n /**\n * Returns the encoded data as a Uint8Array.\n * @returns {Uint8Array} The encoded data.\n */\n get bytes(): Uint8Array {\n return this.encoded;\n }\n\n /**\n * Returns the number representation of the encoded data in the RLP instance.\n * @returns {number} The number representation of the encoded data.\n */\n get n(): number {\n const bi = this.bi;\n if (bi <= Number.MAX_SAFE_INTEGER) {\n return Number(bi);\n }\n throw new InvalidDataType('RLP.n', 'not in the safe number range', {\n bytes: this.bytes\n });\n }\n\n /**\n * Compares the current RLP instance with another RLP instance.\n * @param {RLP} that The RLP instance to compare.\n * @returns 0 if the RLP instances are equal, -1/1 if they are not.\n */\n public compareTo(that: RLP): number {\n if (this.encoded.length !== that.encoded.length) {\n return -1;\n }\n\n for (let i = 0; i < this.encoded.length; i++) {\n if (this.encoded[i] !== that.encoded[i]) {\n return 1;\n }\n }\n\n return 0;\n }\n\n /**\n * Relies on compareTo to check if the RLP instances are equal.\n * @param {RLP} that The RLP instance to compare.\n * @returns true if the RLP instances are equal, false otherwise.\n */\n public isEqual(that: RLP): boolean {\n return this.compareTo(that) === 0;\n }\n\n /**\n * Creates {@link Hex} instance from the RLP encoded value.\n * @returns {Hex} The Hex instance.\n */\n public toHex(): Hex {\n return Hex.of(this.bytes);\n }\n\n /**\n * Returns an RLP instance from a plain value.\n * @param data - The plain data\n * @returns {RLP} The RLP instance.\n */\n public static of(data: RLPInput): RLP {\n try {\n return new RLP(data);\n } catch (error) {\n throw new InvalidRLP(\n 'RLP.of()',\n `Error when creating an RLP instance for data ${data}`,\n {\n context:\n 'This method creates an RLP instance from a plain value.',\n data: {\n data\n }\n },\n error\n );\n }\n }\n\n /**\n * Returns an RLP instancen from an encoded value.\n * @param {Uint8Array} encodedData - The RLP-encoded data.\n * @returns The decoded data or null if decoding fails.\n */\n public static ofEncoded(encodedData: Uint8Array): RLP {\n try {\n return new RLP(encodedData);\n } catch (error) {\n throw new InvalidRLP(\n 'RLP.ofEncoded()',\n `Error when creating an RLP instance for encoded data.`,\n {\n context:\n 'This method creates an RLP instance from an encoded value.',\n data: {\n encodedData\n }\n },\n error\n );\n }\n }\n\n /**\n * Handles the RLP packing of data.\n * Recursively processes through object properties or array elements to prepare data for RLP encoding.\n *\n * @param obj - The object data to be packed.\n * @param profile - Profile for encoding structures.\n * @param context - Encoding context for error tracing.\n * @returns Packed data as RLPInput.\n * @throws {InvalidRLP}\n *\n */\n protected static packData(\n obj: RLPValidObject,\n profile: RLPProfile,\n context: string\n ): RLPInput {\n context = context !== '' ? context + '.' + profile.name : profile.name;\n const kind = profile.kind;\n\n // ScalarKind: direct encoding using the provided method.\n if (kind instanceof ScalarKind) {\n return kind.data(obj, context).encode();\n }\n\n // StructKind: recursively pack each struct member based on its profile.\n if (Array.isArray(kind)) {\n return kind.map((k) =>\n this.packData(obj[k.name] as RLPValidObject, k, context)\n );\n }\n\n // Valid RLP array\n if (!Array.isArray(obj)) {\n throw new InvalidRLP(\n 'RLP.packData()',\n `Validation error: Expected an array in ${context}.`,\n {\n context,\n data: {\n obj,\n profile\n }\n }\n );\n }\n\n // ArrayKind: recursively pack each array item based on the shared item profile.\n if ('item' in kind && Array.isArray(obj)) {\n const item = kind.item;\n return obj.map((part, i) =>\n this.packData(\n part as RLPValidObject,\n { name: '#' + i, kind: item },\n context\n )\n );\n }\n }\n\n /**\n * Handles the RLP unpacking of data.\n * Recursively processes through packed properties or elements to prepare data post RLP decoding.\n *\n * @param packed - The packed data to be unpacked.\n * @param profile - Profile for decoding structures.\n * @param context - Decoding context for error tracing.\n * @returns Unpacked data as RLPValueType.\n * @throws {InvalidRLP}\n *\n */\n protected static unpackData(\n packed: RLPInput,\n profile: RLPProfile,\n context: string\n ): RLPValueType {\n context = context !== '' ? context + '.' + profile.name : profile.name;\n\n const kind = profile.kind;\n\n // ScalarKind: Direct decoding using the provided method.\n if (kind instanceof ScalarKind) {\n // ArrayBuffer.isView so we support https://github.com/vitest-dev/vitest/issues/5183\n if (!ArrayBuffer.isView(packed)) {\n throw new InvalidRLP(\n 'RLP.unpackData()',\n `Unpacking error: Expected data type is Uint8Array.`,\n {\n context,\n data: {\n packed,\n profile\n }\n }\n );\n }\n\n return kind.buffer(packed, context).decode();\n }\n\n // StructKind: Recursively unpack each struct member based on its profile.\n if (Array.isArray(kind) && Array.isArray(packed)) {\n const parts = packed;\n\n if (kind.length !== parts.length) {\n throw new InvalidRLP(\n 'RLP.unpackData()',\n `Unpacking error: Expected ${kind.length} items, but got ${parts.length}.`,\n {\n context,\n data: {\n packed,\n profile\n }\n }\n );\n }\n\n return kind.reduce(\n (obj: RLPValidObject, profile: RLPProfile, index: number) => {\n obj[profile.name] = this.unpackData(\n parts[index],\n profile,\n context\n );\n\n return obj;\n },\n {}\n );\n }\n\n // Valid RLP array\n if (!Array.isArray(packed)) {\n throw new InvalidRLP(\n 'RLP.unpackData()',\n `Validation error: Expected an array in ${context}.`,\n {\n context,\n data: {\n packed,\n profile\n }\n }\n );\n }\n\n // ArrayKind: Recursively unpack each array item based on the shared item profile.\n if ('item' in kind && Array.isArray(packed)) {\n const item = kind.item;\n\n return packed.map((part, index) =>\n this.unpackData(\n part,\n { name: '#' + index, kind: item },\n context\n )\n ) as RLPValueType;\n }\n }\n}\n\nexport { RLP };\n","import { type RLPProfile } from './kind/ScalarKind';\nimport { RLP } from './RLP';\nimport { type RLPInput, type RLPValidObject, type RLPValueType } from './types';\n\n/**\n * Class handling the profiling of RLP encoded/decoded objects.\n * Provides methods to encode and decode objects based on a provided RLP profile.\n */\nclass RLPProfiler extends RLP {\n /**\n * Creates a new Profiler instance.\n * @param profile - Profile for encoding/decoding structures.\n */\n private constructor(\n data: RLPInput,\n readonly profile: RLPProfile\n ) {\n super(data);\n }\n\n /**\n * Creates an RLPProfiler instance from a valid object.\n * @param {RLPValidObject} validObject Object to be encoded.\n * @returns {RLPProfiler} RLPProfiler instance.\n */\n public static ofObject(\n validObject: RLPValidObject,\n profile: RLPProfile\n ): RLPProfiler {\n const packedData = this.packData(validObject, profile, '');\n return new RLPProfiler(packedData, profile);\n }\n\n /**\n * Decodes an object following the provided profile.\n * @param encodedData Data to be decoded.\n * @param profile Profile for encoding/decoding structures.\n * @returns - Decoded data as RLPValueType.\n */\n public static ofObjectEncoded(\n encodedData: Uint8Array,\n profile: RLPProfile\n ): RLPProfiler {\n const packedData = RLP.ofEncoded(encodedData).decoded;\n return new RLPProfiler(packedData, profile);\n }\n\n /**\n * Returns the decoded unpacked object.\n * @returns {RLPValueType} Decoded unpacked object.\n */\n get object(): RLPValueType {\n return RLPProfiler.unpackData(this.decoded, this.profile, '');\n }\n}\n\nexport { RLPProfiler };\n","import { InvalidRLP } from '@vechain/sdk-errors';\nimport { FixedPointNumber } from '../../../FixedPointNumber';\nimport { Hex } from '../../../Hex';\nimport { HexUInt } from '../../../HexUInt';\nimport { type RLPInput } from '../types';\n\n/**\n * Validates and converts the input data to a BigInt.\n *\n * @param data - Either a number or a string representing a non-negative integer.\n * @param context - A string representing the context in which this function is used,\n * to create meaningful error messages.\n * @returns The input data converted to a BigInt.\n * @throws {InvalidRLP}\n */\nconst validateNumericKindData = (data: RLPInput, context: string): bigint => {\n // Input data must be either a number or a string.\n if (typeof data !== 'number' && typeof data !== 'string') {\n throw new InvalidRLP(\n 'validateNumericKindData()',\n `Validation error: Input in ${context} must be a string or number.`,\n {\n context,\n data: {\n data\n }\n }\n );\n }\n\n if (typeof data === 'number') {\n _validateNumericKindNumber(data, context);\n } else if (typeof data === 'string') {\n _validateNumericKindString(data, context);\n }\n\n return BigInt(data);\n};\n\n/**\n * Ensures that a numeric input is a safe and non-negative integer.\n *\n * @remarks\n * A \"safe integer\" in JavaScript is an integer that can be precisely represented\n * without rounding in the double-precision floating point format used by the language,\n * i.e., between 0 and 2^53 - 1, since we're ensuring non-negativity.\n *\n * @param num - The number to be validated.\n * @param context - A string indicating the context, used for error messaging.\n * @throws {InvalidRLP}\n */\nconst _validateNumericKindNumber = (num: number, context: string): void => {\n if (!Number.isSafeInteger(num) || num < 0) {\n throw new InvalidRLP(\n '_validateNumericKindNumber()',\n `Validation error: Number in ${context} must be a safe and non-negative integer.`,\n {\n context,\n data: {\n num\n }\n }\n );\n }\n};\n\n/**\n * Validates a string to ensure it represents a valid non-negative integer.\n *\n * @remarks\n * The input string can represent an unsigned integer in either decimal or hexadecimal format.\n *\n * @param str - A string expected to represent a non-negative integer.\n * @param context - A string indicating the context, for creating meaningful error messages.\n * @throws {InvalidRLP}\n *\n * @private\n */\nconst _validateNumericKindString = (str: string, context: string): void => {\n const isHexUInt = HexUInt.isValid0x(str);\n const isDecimal = FixedPointNumber.isNaturalExpression(str);\n // Ensure the string is either a hex or decimal number.\n if (!isHexUInt && !isDecimal) {\n throw new InvalidRLP(\n '_validateNumericKindString()',\n `Validation error: String in ${context} must represent a non-negative integer in hex or decimal format.`,\n {\n context,\n data: {\n str\n }\n }\n );\n }\n\n // Ensure hex numbers are of a valid length.\n if (isHexUInt && str.length <= 2) {\n throw new InvalidRLP(\n '_validateNumericKindString()',\n `Validation error: Hex string number in ${context} must be of valid length.`,\n {\n context,\n data: {\n str\n }\n }\n );\n }\n};\n\n/**\n * Validates a buffer to ensure it adheres to constraints and does not contain\n * leading zero bytes which are not canonical representation in integers.\n *\n * @param {Uint8Array} buf - The buffer to validate.\n * @param {string} context - A string providing context for error messages.\n * @param {number} maxBytes - [Optional] An integer representing the maximum allowed length\n * of the buffer. If provided, an error will be thrown if buf is longer.\n * @throws {InvalidRLP}\n *\n * @private\n */\nconst assertValidNumericKindBuffer = (\n buf: Uint8Array,\n context: string,\n maxBytes?: number\n): void => {\n // If maxBytes is defined, ensure buffer length is within bounds.\n if (maxBytes !== undefined && buf.length > maxBytes) {\n throw new InvalidRLP(\n 'assertValidNumericKindBuffer()',\n `Validation error: Buffer in ${context} must be less than ${maxBytes} bytes.`,\n {\n context,\n data: {\n buf,\n maxBytes\n }\n }\n );\n }\n\n // Ensure the buffer does not have leading zeros, as it's not canonical in integer representation.\n if (buf[0] === 0) {\n throw new InvalidRLP(\n 'assertValidNumericKindBuffer()',\n `Validation error: Buffer in ${context} must represent a canonical integer (no leading zeros).`,\n {\n context,\n data: {\n buf,\n maxBytes\n }\n }\n );\n }\n};\n\n/**\n * Encode a BigInt instance into a Buffer, ensuring it adheres to specific constraints.\n *\n * @param {bigint} bi - BigInt instance to encode.\n * @param {number | undefined} maxBytes - Maximum byte length allowed for the encoding. If undefined, no byte size limit is imposed.\n * @param {string} context - Contextual information for error messages.\n * @returns {Uint8Array} Encoded data.\n * @throws {InvalidRLP}\n */\nconst encodeBigIntToBuffer = (\n bi: bigint,\n maxBytes: number | undefined,\n context: string\n): Uint8Array => {\n if (bi === 0n) return Uint8Array.from([]);\n const hex = Hex.of(bi).digits;\n\n if (maxBytes !== undefined && hex.length > maxBytes * 2) {\n throw new InvalidRLP(\n 'encodeBigIntToBuffer()',\n `Validation error: Encoded number in ${context} must fit within ${maxBytes} bytes.`,\n {\n context,\n data: {\n hex,\n maxBytes\n }\n }\n );\n }\n\n return Hex.of(hex).bytes;\n};\n\n/**\n * Decode a Uint8Array into a number or hexadecimal string.\n * @param {Uint8Array} buffer - Instance to decode.\n * @returns A number if the decoded BigInt is a safe integer, otherwise returns a hexadecimal string.\n */\nconst decodeBufferToNumberOrHex = (buffer: Uint8Array): number | string => {\n if (buffer.length === 0) return 0;\n\n const bi = Hex.of(buffer).bi;\n const num = Number(bi);\n\n // Return number or hex based on integer safety\n return Number.isSafeInteger(num) ? num : '0x' + bi.toString(16);\n};\n\nexport {\n assertValidNumericKindBuffer,\n decodeBufferToNumberOrHex,\n encodeBigIntToBuffer,\n validateNumericKindData\n};\n","import { InvalidRLP } from '@vechain/sdk-errors';\nimport { Hex } from '../../../Hex';\nimport { type RLPInput } from '../types';\n\n/**\n * Validates if the input is a proper hex string for HexBlobKind.\n *\n * @param data - The input data to validate.\n * @param context - Additional context for error handling.\n * @throws {InvalidRLP}\n */\nconst assertValidHexBlobKindData = (data: RLPInput, context: string): void => {\n if (typeof data !== 'string') {\n throw new InvalidRLP(\n 'assertValidHexBlobKindData()',\n `Validation error: Input must be a string.`,\n {\n context,\n data: {\n data\n }\n }\n );\n }\n\n // Check if data is a valid hex string with '0x' prefix.\n if (!Hex.isValid(data)) {\n throw new InvalidRLP(\n 'assertValidHexBlobKindData()',\n `Validation error: Input must be a valid hex string with a '0x' prefix.`,\n {\n context,\n data: {\n data\n }\n }\n );\n }\n\n // Ensure the hex string length is even.\n if (data.length % 2 !== 0) {\n throw new InvalidRLP(\n 'assertValidHexBlobKindData()',\n `Validation error: Hex string must have an even length.`,\n {\n context,\n data: {\n data\n }\n }\n );\n }\n};\n\nexport { assertValidHexBlobKindData };\n","import { InvalidRLP } from '@vechain/sdk-errors';\n\n/**\n * Asserts that the data is a hex string of the correct length.\n *\n * @param data - The data to validate.\n * @param context - Descriptive context for error messages.\n * @param bytes - The expected number of bytes that the data can contain.\n * @throws {InvalidRLP}\n */\nconst assertFixedHexBlobKindData = (\n data: string,\n context: string,\n bytes: number\n): void => {\n if (data.length !== bytes * 2 + 2) {\n throw new InvalidRLP(\n 'assertFixedHexBlobKindData()',\n `Validation error: Hex string in ${context} must be exactly ${bytes} bytes in length.`,\n {\n context,\n data: {\n data,\n bytes\n }\n }\n );\n }\n};\n\n/**\n * Asserts that the buffer is of a specific length.\n *\n * @param {Uint8Array} buffer The buffer to validate.\n * @param {string} context Descriptive context for error messages.\n * @param {number} bytes The expected number of bytes that the buffer can contain.\n * @throws {InvalidRLP}\n */\nconst assertFixedHexBlobKindBuffer = (\n buffer: Uint8Array,\n context: string,\n bytes: number\n): void => {\n if (buffer.length !== bytes) {\n throw new InvalidRLP(\n 'assertFixedHexBlobKindData()',\n `Validation error: Hex string in ${context} must be exactly ${bytes} bytes in length.`,\n {\n context,\n data: {\n buffer,\n bytes\n }\n }\n );\n }\n};\n\nexport { assertFixedHexBlobKindData, assertFixedHexBlobKindBuffer };\n","import { InvalidRLP } from '@vechain/sdk-errors';\nimport { Hex } from '../../../Hex';\n\n/**\n * Asserts that the provided buffer is of a specific length and does not contain leading zeros.\n *\n * @param {Uint8Array} buffer - The buffer to validate.\n * @param {string} context - Descriptive context for error messages, usually representing the caller's identity.\n * @param {number} bytes - The expected maximum number of bytes that the buffer can contain.\n * @throws {InvalidRLP}\n */\nconst assertCompactFixedHexBlobBuffer = (\n buffer: Uint8Array,\n context: string,\n bytes: number\n): void => {\n if (buffer.length > bytes) {\n throw new InvalidRLP(\n 'assertCompactFixedHexBlobBuffer()',\n `Validation error: Buffer in ${context} must be at most ${bytes} bytes.`,\n {\n context,\n data: {\n buffer,\n bytes\n }\n }\n );\n }\n\n if (buffer.length !== 0 && buffer[0] === 0) {\n throw new InvalidRLP(\n 'assertCompactFixedHexBlobBuffer()',\n `Validation error: Buffer in ${context} should not have leading zero bytes.`,\n {\n context,\n data: {\n buffer,\n bytes\n }\n }\n );\n }\n};\n\n/**\n * Encodes a buffer by trimming leading zero bytes.\n * Finds the first non-zero byte and returns a new buffer starting from that byte. Returns an empty buffer if all bytes are zero.\n *\n * @param {Uint8Array} buffer - The buffer to be compacted.\n * @returns {Uint8Array} A Uint8Array instance compacted of leading zero bytes, or an empty Uint8Array if all bytes are zero.\n */\nconst encodeCompactFixedHexBlob = (buffer: Uint8Array): Uint8Array => {\n const zeroIndex: number = buffer.findIndex((byte: number) => byte !== 0);\n\n return zeroIndex !== -1 ? buffer.subarray(zeroIndex) : Uint8Array.from([]);\n};\n\n/**\n * Decodes a buffer into a hexadecimal string, ensuring a specific total byte length by prepending zeros if necessary.\n * Calculates the number of missing bytes compared to the expected total and prepends the corresponding number of '0' characters to the hexadecimal string representation of the buffer.\n *\n * @param {Uint8Array} buffer The buffer to decode.\n * @param {number} bytes The expected total number of bytes in the final hexadecimal string (including leading zeros).\n * @returns A hexadecimal string with the necessary leading '0' characters to ensure the specified total byte length.\n */\nconst decodeBufferToHexWithLeadingZeros = (\n buffer: Uint8Array,\n bytes: number\n): string => {\n return Hex.of(buffer)\n .fit(bytes * 2)\n .toString();\n};\n\nexport {\n assertCompactFixedHexBlobBuffer,\n decodeBufferToHexWithLeadingZeros,\n encodeCompactFixedHexBlob\n};\n","import { ScalarKind } from './ScalarKind';\nimport { type BufferOutput, type DataOutput, type RLPInput } from '../types';\nimport { InvalidRLP } from '@vechain/sdk-errors';\n\n/**\n * Represents a scalar kind with Buffer functionality.\n * This class extends the {@link ScalarKind} class.\n */\nclass BufferKind extends ScalarKind {\n /**\n * Encodes the input data into buffer format.\n *\n * @param {RLPInput} data The data to encode, expected to be of Uint8Array type.\n * @param {string} context Descriptive context for error messages\n * @returns {DataOutput} Object with an encode function.\n * @throws {InvalidRLP}\n */\n public data(data: RLPInput, context: string): DataOutput {\n // Ensure that the data is indeed a Buffer before encoding.\n // ArrayBuffer.isView so we support https://github.com/vitest-dev/vitest/issues/5183\n if (!ArrayBuffer.isView(data)) {\n throw new InvalidRLP(\n 'BufferKind.data()',\n `Validation error: Expected a Uint8Array type in ${context}.`,\n {\n context,\n data: {\n data\n }\n }\n );\n }\n\n return {\n encode: () => data // Data is already a Buffer, so return as-is.\n };\n }\n\n /**\n * Decodes the input buffer.\n *\n * @param {Uint8Array} buffer - The buffer to decode, expected to be of buffer type.\n * @returns BufferOutput object with a decode function.\n * @throws {InvalidRLP}\n */\n public buffer(buffer: Uint8Array): BufferOutput {\n return {\n decode: () => buffer // Buffer is already in the correct format, so return as-is.\n };\n }\n}\n\nexport { BufferKind };\n","import { ScalarKind } from './ScalarKind';\nimport {\n assertValidNumericKindBuffer,\n decodeBufferToNumberOrHex,\n encodeBigIntToBuffer,\n validateNumericKindData\n} from '../helpers';\nimport { type BufferOutput, type DataOutput, type RLPInput } from '../types';\n\n/**\n * Represents a scalar kind with numeric functionality.\n * This class extends the {@link ScalarKind} class.\n */\nclass NumericKind extends ScalarKind {\n /**\n * Constructs a new instance of NumericKind.\n *\n * @param maxBytes - Optional parameter that specifies the maximum number of bytes that numeric data can occupy when encoded.\n */\n constructor(readonly maxBytes?: number) {\n super();\n }\n\n /**\n * Encodes the input data into numeric format and ensures it doesn't exceed the maximum bytes, if specified.\n *\n * @param data - The data to encode, expected to be numeric.\n * @param context - Descriptive context for error messages\n * @returns DataOutput object with an encode function.\n * @throws Will throw an error if data validation fails or encoding issues occur.\n */\n public data(data: RLPInput, context: string): DataOutput {\n // Validate and convert the numeric data to a BigInt instance.\n const dataBI = validateNumericKindData(data, context);\n\n return {\n encode: () => encodeBigIntToBuffer(dataBI, this.maxBytes, context) // Encodes BigInt to Buffer, respecting maxBytes.\n };\n }\n\n /**\n * Decodes the input buffer into a number or hexadecimal string, ensuring it meets numeric data constraints.\n *\n * @param {Uint8Array} buffer - The buffer to decode, containing numeric data.\n * @param context - Descriptive context for error messages.\n * @returns BufferOutput object with a decode function.\n * @throws Will throw an error if buffer validation fails.\n */\n public buffer(buffer: Uint8Array, context: string): BufferOutput {\n // Ensure the buffer adheres to constraints related to numeric data.\n assertValidNumericKindBuffer(buffer, context, this.maxBytes);\n\n return {\n decode: () => decodeBufferToNumberOrHex(buffer) // Decodes buffer to either a number or a hexadecimal string.\n };\n }\n}\n\nexport { NumericKind };\n","import { Hex } from '../../../../Hex';\nimport { HexUInt } from '../../../../HexUInt';\nimport { assertValidHexBlobKindData } from '../../helpers';\nimport { type BufferOutput, type DataOutput, type RLPInput } from '../../types';\nimport { ScalarKind } from '../ScalarKind';\n\n/**\n * Represents a scalar kind with hex blob functionality.\n * This class extends the {@link ScalarKind} class.\n *\n * @remarks\n * A hex blob is a hex string that is prefixed with '0x' and has even length.\n */\nclass HexBlobKind extends ScalarKind {\n /**\n * Encodes the input data into a Uint8Array.\n *\n * @param data - The data to encode, expected to be a '0x' prefixed even sized hex string.\n * @param context - Context string for error handling.\n * @returns An object containing an encode function which returns the encoded Uint8Array.\n */\n public data(data: RLPInput, context: string): DataOutput {\n assertValidHexBlobKindData(data, context);\n\n return {\n encode: () => HexUInt.of((data as string).slice(2)).bytes\n };\n }\n\n /**\n * Decodes the input buffer into a hex string.\n *\n * @param buffer - The buffer to decode.\n * @param context - Context string for error handling.\n * @returns An object containing a decode function which returns the decoded hex string.\n */\n public buffer(buffer: Uint8Array, _context: string): BufferOutput {\n return {\n decode: () => Hex.of(buffer).toString()\n };\n }\n}\n\nexport { HexBlobKind };\n","import {\n assertFixedHexBlobKindBuffer,\n assertFixedHexBlobKindData\n} from '../../helpers';\nimport { type BufferOutput, type DataOutput, type RLPInput } from '../../types';\nimport { HexBlobKind } from './HexBlobKind';\n\n/**\n * Represents a hex blob kind with fixed bytes size functionality.\n * This class extends the {@link HexBlobKind} class.\n */\nclass FixedHexBlobKind extends HexBlobKind {\n /**\n * Creates a new instance of the {@link FixedHexBlobKind} class.\n * @param bytes - The number of bytes the blob must have.\n */\n constructor(readonly bytes: number) {\n super();\n }\n\n /**\n * Encodes the input data into a Uint8Array with validation against fixed size.\n *\n * @param data - The data to encode, expected to be a '0x' prefixed even sized hex string.\n * @param context - Context string for error handling.\n * @returns An object containing an encode function which returns the encoded Uint8Array.\n */\n public data(data: RLPInput, context: string): DataOutput {\n const encoder = super.data(data, context);\n\n // Validate the data length against the fixed size. `typeof data === 'string'` is checked in super.data\n assertFixedHexBlobKindData(data as string, context, this.bytes);\n\n return encoder;\n }\n\n /**\n * Decodes the input buffer into a hex string with validation against fixed size.\n *\n * @param buffer - The buffer to decode.\n * @param context - Context string for error handling.\n * @returns An object containing a decode function which returns the decoded hex string.\n */\n public buffer(buffer: Uint8Array, context: string): BufferOutput {\n const decoder = super.buffer(buffer, context);\n\n // Validate the buffer length against the fixed size.\n assertFixedHexBlobKindBuffer(buffer, context, this.bytes);\n\n return decoder;\n }\n}\n\nexport { FixedHexBlobKind };\n","import { type BufferOutput, type DataOutput, type RLPInput } from '../../types';\nimport { FixedHexBlobKind } from './FixedHexBlobKind';\n\n/**\n * Represents a fixed hex blob kind with optional data functionality.\n * This class extends the {@link FixedHexBlobKind} class.\n */\nclass OptionalFixedHexBlobKind extends FixedHexBlobKind {\n /**\n * Encodes the input data (which can be null or undefined) into a Uint8Array.\n *\n * @param data - The data to encode, can be null or undefined.\n * @param context - Context string for error handling.\n * @returns An object containing an encode function which returns the encoded Uint8Array.\n */\n public data(data: RLPInput, context: string): DataOutput {\n // If data is null or undefined, return an empty Uint8Array.\n return data == null\n ? {\n encode: () => Uint8Array.from([])\n }\n : super.data(data, context);\n }\n\n /**\n * Decodes the input buffer into a hex string or null if the buffer is empty.\n *\n * @param buffer - The buffer to decode, can be empty.\n * @param context - Context string for error handling.\n * @returns An object containing a decode function which returns the decoded hex string or null.\n */\n public buffer(buffer: Uint8Array, context: string): BufferOutput {\n return buffer.length === 0\n ? {\n decode: () => null\n }\n : super.buffer(buffer, context);\n }\n}\n\nexport { OptionalFixedHexBlobKind };\n","import { Hex } from '../../../../Hex';\nimport {\n assertCompactFixedHexBlobBuffer,\n encodeCompactFixedHexBlob\n} from '../../helpers';\nimport { type BufferOutput, type DataOutput, type RLPInput } from '../../types';\nimport { FixedHexBlobKind } from './FixedHexBlobKind';\n\n/**\n * Represents a fixed hex blob kind with zero trimming and padding functionality.\n * This class extends the {@link FixedHexBlobKind} class.\n */\nclass CompactFixedHexBlobKind extends FixedHexBlobKind {\n /**\n * Encodes the input data into a Uint8Array, trimming leading zeros.\n *\n * @param data - The data to encode, expected to be a '0x' prefixed hex string.\n * @param context - Context string for error handling.\n * @returns An object containing an encode function which returns the encoded Uint8Array.\n */\n public data(data: RLPInput, context: string): DataOutput {\n const buffer: Uint8Array = super.data(data, context).encode();\n\n return {\n encode: () => encodeCompactFixedHexBlob(buffer) // Encode the buffer, trimming leading zeros.\n };\n }\n\n /**\n * Decodes the input buffer into a number or hexadecimal string, ensuring it meets the fixed size by padding with zeros.\n *\n * @param buffer - The buffer to decode, containing numeric data.\n * @param context - Descriptive context for error messages, usually representing the caller's identity.\n * @returns BufferOutput object with a decode function.\n * @throws Will throw an error if buffer validation fails.\n */\n public buffer(buffer: Uint8Array, context: string): BufferOutput {\n assertCompactFixedHexBlobBuffer(buffer, context, this.bytes);\n\n return {\n decode: () =>\n // Decode the buffer, returning a hex string with leading zeros.\n Hex.of(buffer)\n .fit(this.bytes * 2)\n .toString()\n };\n }\n}\n\nexport { CompactFixedHexBlobKind };\n","import * as s_bip32 from '@scure/bip32';\nimport * as s_bip39 from '@scure/bip39';\nimport { wordlist } from '@scure/bip39/wordlists/english';\nimport {\n InvalidDataType,\n InvalidHDKey,\n InvalidHDKeyMnemonic,\n InvalidOperation\n} from '@vechain/sdk-errors';\nimport { type VeChainDataModel } from './VeChainDataModel';\nimport { HDKey } from '../hdkey';\n\n/**\n * Type of the wordlist size.\n * Every 4 bytes produce 3 words.\n */\ntype WordlistSizeType = 12 | 15 | 18 | 21 | 24;\n\n/**\n * Size of the mnemonic words in bytes.\n */\ntype WordListRandomGeneratorSizeInBytes = 16 | 20 | 24 | 28 | 32;\n\n/**\n * The Mnemonic class provides functionality related to mnemonic phrases, including encoding to bytes,\n * generating, validating, and deriving keys from mnemonic words based on the BIP39 standard.\n * It implements the VeChainDataModel interface.\n *\n * @implements VeChainDataModel\n */\nclass Mnemonic implements VeChainDataModel<Mnemonic> {\n /**\n * A TextEncoder instance used for encoding text to bytes.\n *\n * @type {TextEncoder}\n */\n private static readonly ENCODER = new TextEncoder();\n\n /**\n * Throws an exception because the mnemonic cannot be represented as a big integer.\n * @returns {bigint} The BigInt representation of the mnemonic.\n * @throws {InvalidOperation} The mnemonic cannot be represented as a bigint.\n * @override {@link VeChainDataModel#bi}\n * @remark The conversion to BigInt is not supported for a mnemonic.\n */\n public get bi(): bigint {\n throw new InvalidOperation(\n 'Mnemonic.bi',\n 'There is no big integer representation for a mnemonic.',\n { data: '' }\n );\n }\n\n /**\n * Generates a mnemonic as encoded bytes.\n *\n * @returns {Uint8Array} The bytes representation of the words with spaces.\n */\n get bytes(): Uint8Array {\n return Mnemonic.ENCODER.encode(Mnemonic.of().join(' '));\n }\n\n /**\n * Throws an exception because the mnemonic cannot be represented as a number.\n * @returns {bigint} The number representation of the mnemonic.\n * @throws {InvalidOperation} The mnemonic cannot be represented as a number.\n * @override {@link VeChainDataModel#n}\n * @remark The conversion to number is not supported for a mnemonic.\n */\n public get n(): number {\n throw new InvalidOperation(\n 'Mnemonic.n',\n 'There is no number representation for a mnemonic.',\n { data: '' }\n );\n }\n\n /**\n * There is no comparison for a mnemonic.\n *\n * @throws {InvalidOperation} The mnemonic cannot be compared.\n */\n public compareTo(_that: Mnemonic): number {\n throw new InvalidOperation(\n 'Mnemonic.compareTo',\n 'There is no comparison for a mnemonic since it is not stored in memory.',\n { data: '' }\n );\n }\n\n /**\n * There is no comparison for a mnemonic.\n *\n * @throws {InvalidOperation} The mnemonic cannot be compared.\n */\n public isEqual(_that: Mnemonic): boolean {\n throw new InvalidOperation(\n 'Mnemonic.isEqual',\n 'There is no comparison for a mnemonic since it is not stored in memory.',\n { data: '' }\n );\n }\n\n /**\n * Convert the number of words to the corresponding strength.\n *\n * @param numberOfWords - The number of words.\n *\n * @returns {number} The corresponding strength.\n *\n * @throws {InvalidDataType} If the number of words is not valid.\n */\n private static wordsNoToStrength(numberOfWords: number): number {\n switch (numberOfWords) {\n case 12:\n return 128;\n case 15:\n return 160;\n case 18:\n return 192;\n case 21:\n return 224;\n case 24:\n return 256;\n default:\n throw new InvalidDataType(\n 'Mnemonic.wordsNoToStrength',\n 'not a valid number of words',\n { numberOfWords }\n );\n }\n }\n\n // Legacy method, probably should be part of a Private Key class (ofMnemonic) #1122\n /**\n * Derives a private key from a given list of\n * [BIP39 Mnemonic Words](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki)\n * and a derivation path as in the examples.\n *\n * @example `m/0` (default)\n * @example `m/0/2`\n * @example `m/0/2/4/6`\n *\n * @param {string[]} words - The set of words used for mnemonic generation.\n * @param {string} [path='m/0'] - The derivation path from the current node.\n *\n * @returns {Uint8Array} - The derived private key as a Uint8Array.\n *\n * @throws {InvalidHDKey}\n *\n * @remarks Security auditable method, depends on\n * * {@link HDKey}.\n */\n public static toPrivateKey(\n words: string[],\n path: string = HDKey.VET_DERIVATION_PATH\n ): Uint8Array {\n const master = s_bip32.HDKey.fromMasterSeed(\n s_bip39.mnemonicToSeedSync(words.join(' ').toLowerCase())\n );\n // Any exception involving mnemonic words is thrown before this point: words are not leaked next.\n try {\n // Derived from root, private key is always available.\n return master.derive(path).privateKey as Uint8Array;\n } catch (error) {\n throw new InvalidHDKey(\n 'mnemonic.derivePrivateKey()',\n 'Invalid derivation path given as input.',\n { derivationPath: path },\n error\n );\n }\n }\n\n /**\n * Generates a\n * [BIP39 Mnemonic Words](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki)\n * phrase using the specified wordlist size and random generator.\n *\n * @param {WordlistSizeType} wordlistSize - The number of words to generate the mnemonic.\n * @param {function} [randomGenerator] - The random generator function used to generate the entropy.\n *\n * @returns {Mnemonic} The generated mnemonic.\n *\n * @throws {InvalidDataType} If the number of words is not valid.\n *\n * @remarks Security auditable method, depends on\n * * [entropyToMnemonic](https://github.com/paulmillr/scure-bip39);\n * * [generateMnemonic](https://github.com/paulmillr/scure-bip39);\n * * `randomGenerator` - **Must provide a cryptographic secure source of entropy\n * else any secure audit certification related with this software is invalid.**\n */\n public static of(\n wordlistSize: WordlistSizeType = 12,\n randomGenerator?: (\n numberOfBytes: WordListRandomGeneratorSizeInBytes\n ) => Uint8Array\n ): string[] {\n try {\n const strength: number = Mnemonic.wordsNoToStrength(wordlistSize);\n if (randomGenerator != null) {\n const numberOfBytes = (strength /\n 8) as WordListRandomGeneratorSizeInBytes;\n return s_bip39\n .entropyToMnemonic(randomGenerator(numberOfBytes), wordlist)\n .split(' ');\n }\n return s_bip39.generateMnemonic(wordlist, strength).split(' ');\n } catch (error) {\n throw new InvalidHDKeyMnemonic(\n 'Mnemonic.of',\n 'error while generating mnemonic',\n { wordlistSize },\n error\n );\n }\n }\n\n /**\n * Check if the given mnemonic words are valid.\n *\n * @param {string | string[]} words - The mnemonic words to check.\n *\n * @returns {boolean} true if the words are valid, false otherwise.\n *\n * @remarks Security auditable method, depends on\n * * [validateMnemonic](https://github.com/paulmillr/scure-bip39).\n */\n public static isValid(words: string | string[]): boolean {\n const wordsToValidate = Array.isArray(words) ? words.join(' ') : words;\n return s_bip39.validateMnemonic(wordsToValidate, wordlist);\n }\n}\n\nexport { Mnemonic };\nexport type { WordListRandomGeneratorSizeInBytes, WordlistSizeType };\n","import { HexUInt } from './HexUInt';\nimport { InvalidDataType } from '@vechain/sdk-errors';\n\n/**\n * Represents a hexadecimal numeric value compatible with the result of\n * [ethers](https://docs.ethers.org/v6/)\n * [utils.toQuantity](https://docs.ethers.org/v6/api/utils/#toQuantity) function.\n * This is most commonly used for JSON-RPC numeric values.\n *\n * @remarks A quantity instance:\n * * has not empty content,\n * * the hexadecimal representation removes any not meaningful zero on the left side of the expression,\n * * represents only positive integers.\n *\n * @extends HexUInt\n */\nclass Quantity extends HexUInt {\n /**\n * Creates a Quantity instance from a bigint or number given expression\n *\n * @param {bigint | number} exp - The value to be expressed as Quantity object:\n * * bigint must be positive;\n * * number must be positive, it is converted to bigint to create the Quantity.\n *\n * @returns {Quantity} - The new Quantity object.\n *\n * @throws {InvalidDataType} - If the provided expression is not a positive integer value.\n */\n public static of(exp: bigint | number): Quantity {\n try {\n const huint = HexUInt.of(exp);\n let cue = 0;\n while (cue < huint.digits.length && huint.digits.at(cue) === '0') {\n cue++;\n }\n return new Quantity(\n huint.sign,\n cue === huint.digits.length ? '0' : huint.digits.slice(cue)\n );\n } catch (e) {\n throw new InvalidDataType(\n 'Quantity.of',\n 'not a Quantity expression',\n { exp: `${exp}` }, // Needed to serialize bigint values.\n e\n );\n }\n }\n}\n\nexport { Quantity };\n","import { InvalidDataType } from '@vechain/sdk-errors';\nimport { Hex } from './Hex';\nimport { Txt } from './Txt';\n\n/**\n * Represents a revision for a Thor transaction or block\n * Revision strings can be one of the following:\n * - \"best\": indicating the best revision\n * - \"finalized\": indicating a finalized revision\n * - \"next\": indicating the next revision\n * - \"justified\": indicating the justified revision\n * - A hex string prefixed with \"0x\" indicating a specific block id\n * - A positive number indicating a specific block number\n *\n * @extends Txt\n */\nclass Revision extends Txt {\n /**\n * Regular expression pattern for revision strings.\n *\n * @type {RegExp}\n */\n private static readonly VALID_REVISION_REGEX =\n /^(best|finalized|next|justified|0x[a-fA-F0-9]+|\\d+)$/;\n\n /**\n * Determines if the given value is a valid revision.\n * @param {bigint| number | string | Hex} value - The value to be validated.\n * @returns {boolean} - Returns `true` if the value is valid, `false` otherwise.\n */\n public static isValid(value: bigint | number | string | Hex): boolean {\n if (typeof value === 'number') {\n return Number.isInteger(value) && value >= 0;\n }\n if (typeof value === 'bigint') {\n return value >= BigInt(0);\n }\n if (value instanceof Hex) {\n return Revision.isValid(value.bi);\n }\n return Revision.VALID_REVISION_REGEX.test(value);\n }\n\n /**\n * Creates a new Revision object from the given value.\n *\n * @param {bigint | number | string | Uint8Array | Hex } value - The value to create the Revision from:\n * * {@link Hex} must be positive;\n * * {@link Uint8Array} is decoded as a string: see {@link Txt.of}.\n *\n * @returns {Revision} - The created Revision object.\n *\n * @throws {InvalidDataType} if the given value is not a valid revision: see {@link isValid}.\n *\n * @remarks The string representation of the revision is always expressed as a number in base 10.\n * @remarks The {@link Uint8Array} value is decoded as a string content: see {@link Txt.of}.\n */\n public static of(value: bigint | number | string | Uint8Array | Hex): Txt {\n try {\n // handle Uint8Array which is needed to extend Txt.of\n if (ArrayBuffer.isView(value)) {\n const txtValue = Txt.of(value).toString();\n if (Revision.isValid(txtValue)) {\n return new Revision(txtValue);\n } else {\n throw new InvalidDataType('Revision.of', 'not a revision', {\n value: `${value}`\n });\n }\n }\n // handle other types\n if (Revision.isValid(value)) {\n return new Revision(`${value}`);\n } else {\n throw new InvalidDataType('Revision.of', 'not a revision', {\n value: `${value}`\n });\n }\n } catch (e) {\n throw new InvalidDataType('Revision.of', 'not a revision', {\n value: `${value}`,\n e\n });\n }\n }\n\n /**\n * Return the `best` revision instance.\n */\n public static readonly BEST: Revision = Revision.of('best');\n\n /**\n * Return the `finalized` revision instance.\n */\n public static readonly FINALIZED: Revision = Revision.of('finalized');\n\n /**\n * Return the `next` revision instance.\n */\n public static readonly NEXT: Revision = Revision.of('next');\n\n /**\n * Return the `justified` revision instance.\n */\n public static readonly JUSTIFIED: Revision = Revision.of('justified');\n}\n\nexport { Revision };\n","import { Hex } from './Hex';\nimport { HexUInt } from './HexUInt';\nimport { InvalidDataType } from '@vechain/sdk-errors';\n\n/**\n * The BlockId class represents a Thor block ID value, which is a hexadecimal positive integer having 64 digits.\n *\n * @extends HexInt\n */\nclass BlockId extends HexUInt {\n /**\n * Number of digits to represent a Thor block ID value.\n *\n * @remarks The `0x` prefix is excluded.\n *\n * @type {number}\n */\n private static readonly DIGITS = 64;\n\n /**\n * Constructs a BlockId object with the provided hexadecimal value.\n *\n * @param {HexUInt} huint - The hexadecimal value representing the BlockId.\n */\n protected constructor(huint: HexUInt) {\n super(Hex.POSITIVE, huint.fit(BlockId.DIGITS).digits);\n }\n\n /**\n * Check if the given expression is a valid BlockId.\n *\n * @param {string} exp - The expression to be validated.\n *\n * @return {boolean} Returns true if the expression is a valid BlockId, false otherwise.\n */\n public static isValid(exp: string): boolean {\n return Hex.isValid(exp) && HexUInt.REGEX_HEXUINT_PREFIX.test(exp)\n ? exp.length === BlockId.DIGITS + 2\n : exp.length === BlockId.DIGITS;\n }\n\n /**\n * Determines whether the given string is a valid hex number prefixed with '0x'.\n *\n * @param {string} exp - The hex number to be checked.\n *\n * @returns {boolean} - True if the hex number is valid, false otherwise.\n */\n public static isValid0x(exp: string): boolean {\n return HexUInt.REGEX_HEXUINT_PREFIX.test(exp) && BlockId.isValid(exp);\n }\n\n /**\n * Creates a new BlockId object from the given expression.\n *\n * @param {bigint | number | string | Hex | Uint8Array} exp - The expression to create the BlockId from.\n * It can be one of the following types:\n * - bigint: A BigInteger value that represents the BlockId.\n * - number: A number value that represents the BlockId.\n * - string: A string value that represents the BlockId.\n * - HexUInt: A HexUInt object that represents the BlockId.\n * - Uint8Array: A Uint8Array object that represents the BlockId.\n *\n * @returns {BlockId} - A new BlockId object created from the given expression.\n *\n * @throws {InvalidDataType} If the given expression is not a valid hexadecimal positive integer expression.\n */\n public static of(\n exp: bigint | number | string | Uint8Array | HexUInt\n ): BlockId {\n try {\n if (exp instanceof HexUInt) {\n return new BlockId(exp);\n }\n return new BlockId(HexUInt.of(exp));\n } catch (e) {\n throw new InvalidDataType(\n 'BlockId.of',\n 'not a BlockId expression',\n { exp: `${exp}` }, // Needed to serialize bigint values.\n e\n );\n }\n }\n}\n\n/**\n * This class is an alias of {@link BlockId} for back compatibility.\n */\nclass ThorId extends BlockId {\n /**\n * Constructs an instance of the class with the specified block ID.\n *\n * @param {BlockId} blockId - The unique identifier for the block.\n */\n protected constructor(blockId: BlockId) {\n super(blockId);\n }\n\n /**\n * See {@link BlockId.of}.\n */\n public static of(\n exp: bigint | number | string | Uint8Array | HexUInt\n ): ThorId {\n return new ThorId(BlockId.of(exp));\n }\n}\n\nexport { BlockId, ThorId };\n","import fastJsonStableStringify from 'fast-json-stable-stringify';\nimport { Address, Blake2b256, HexUInt, Txt } from '../vcdm';\nimport { Secp256k1 } from '../secp256k1';\nimport {\n CertificateSignatureMismatch,\n InvalidDataType\n} from '@vechain/sdk-errors';\nimport { type CertificateData } from './CertificateData';\n\n/**\n * The Certificate class provides functionality to create, sign, and verify certificates.\n * It implements the CertificateData interface.\n *\n * @remarks\n * The properties of those class are immutable, except {@link signature},\n * because properties are part of the {@link signature} computation.\n * The signature is used of extract and match the {@link signer}.\n * The fact the properties are immutable assure is not possible to create\n * an object tampering properties and carry on the legitimate signature and\n * signer address of the object before tampering to make tampered content\n * to result in a validated certificate.\n *\n * @remarks\n * Classes extending {@link Certificate} should expose immutable properties.\n *\n * @remarks\n * This class implementation supports {@link signer}\n * [mixed-case checksum address encoding](https://eips.ethereum.org/EIPS/eip-55).\n *\n * @implements CertificateData\n */\nclass Certificate implements CertificateData {\n /**\n * Return the intended use or context of the certificate.\n */\n readonly purpose: string;\n\n /**\n * Returns the content of the certificate.\n */\n readonly payload: {\n /**\n * Return the description of the type of content.\n */\n readonly type: string;\n /**\n * Return the content serialized as a string.\n */\n readonly content: string;\n };\n\n /**\n * Return the description of the context of validity of this certificate.\n */\n readonly domain: string;\n\n /**\n * The value expressed as of milliseconds elapsed since the\n * [epoch](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#the_epoch_timestamps_and_invalid_date),\n * when the certificate was issued.\n *\n * @remarks\n * The value is a natural number in the safe integer range of JS `number` type.\n */\n readonly timestamp: number;\n\n /**\n * Return the address of the entity signed the certificate, as\n * a lowercase hexadecimal expression prefixed by `0x`.\n *\n * @remarks\n * Normalized lowercase prefixed expression is needed because\n * the content of this property is part of the {@signature} computation:\n * certificates made from checksum case address of the signer should\n * result valid as the certificate made from the same signer address\n * not checksum case.\n */\n readonly signer: string;\n\n /**\n * Return the signature computed evaluating the properties of this object\n * and the private key of the signer.\n *\n * @remarks\n * The signature is a lowercase hexadecimal expression prefixed with `0x`.\n */\n signature?: string;\n\n /**\n * Returns a new instance of this class assuring the formal validity of the\n * arguments used to build the object.\n *\n * @param {string} purpose - The purpose of the certificate.\n * @param {Object} payload - The payload containing type and content.\n * @param {string} payload.type - The type of the payload.\n * @param {string} payload.content - The content of the payload.\n * @param {string} domain - The domain associated with the certificate.\n * @param {number} timestamp - The time at which the certificate is created;\n * must be a positive safe integer.\n * @param {string} signer - The signer of the certificate;\n * must be a valid address.\n * @param {string|undefined} [signature] - The signature of the certificate;\n * optional parameter.\n *\n * @throws {InvalidDataType} If timestamp is not a positive safe integer.\n * @throws {InvalidDataType} If signer is not a valid address.\n * @throws {InvalidDataType} If signature is invalid.\n *\n * @remarks\n * The `signer` address is represented lowercase and `0x` prefixed.\n */\n protected constructor(\n purpose: string,\n payload: { type: string; content: string },\n domain: string,\n timestamp: number,\n signer: string,\n signature?: string\n ) {\n if (Number.isSafeInteger(timestamp) && timestamp >= 0) {\n if (Address.isValid(signer)) {\n this.purpose = purpose;\n this.payload = payload;\n this.domain = domain;\n this.timestamp = timestamp;\n this.signer = signer.toString().toLowerCase();\n try {\n this.signature =\n typeof signature === 'string'\n ? HexUInt.of(signature).alignToBytes().toString()\n : signature;\n } catch (e) {\n throw new InvalidDataType(\n 'Certificate.constructor',\n 'invalid signature',\n { signature },\n e\n );\n }\n } else\n throw new InvalidDataType(\n 'Certificate.constructor',\n 'signer is not an address',\n { signer }\n );\n } else\n throw new InvalidDataType(\n 'Certificate.constructor',\n 'not positive safe integer timestamp',\n { timestamp }\n );\n }\n\n /**\n * Encodes a given object into a Uint8Array representation\n * applying the following operation to normalize the content:\n * - the properties are sorted in ascending alphabetic order;\n * - the key/value properties are delimited with `\"` when serialized as JSON\n * before to be encoded as bytes;\n * - any not meaningful blank characters are ignored;\n * - the JSON representation of this object is byte encoded using the UTF-8\n * [normalization form for canonical composition](https://en.wikipedia.org/wiki/Unicode_equivalence#Normal_forms).\n *\n * @param {unknown} object - The input object to be encoded.\n * @return {Uint8Array} The encoded Uint8Array representation of the input object.\n */\n protected static encode(object: unknown): Uint8Array {\n return Txt.of(fastJsonStableStringify(object)).bytes;\n }\n\n /**\n * Encodes the current certificate instance into a Uint8Array representation.\n *\n * @remarks\n * This method normalizes the content by:\n * - Sorting the properties in ascending alphabetic order.\n * - Delimiting key/value properties with `\"` when serialized as JSON before encoding as bytes.\n * - Ignoring any not meaningful blank characters.\n * - Using the UTF-8 normalization form for canonical composition for byte encoding.\n *\n * @return {Uint8Array} The encoded Uint8Array representation of the current certificate instance.\n */\n public encode(): Uint8Array {\n return Certificate.encode({ ...this, signature: undefined });\n }\n\n /**\n * Return `true` if the current instance has a signature.\n *\n * @return {boolean} `true` if the signature is a valid hexadecimal string,\n * otherwise `false`.\n */\n public isSigned(): boolean {\n return (\n typeof this.signature === 'string' &&\n HexUInt.isValid(this.signature)\n );\n }\n\n /**\n * Creates a new Certificate instance from the provided CertificateData.\n *\n * @param {CertificateData} data - The data required to create the Certificate.\n * @return {Certificate} A new Certificate instance.\n * @throws {InvalidDataType} If the provided data is invalid:\n * - if timestamp is not a positive safe integer;\n * - if signer is not a valid address;\n * - if signature is an invalid hexadecimal expression.\n *\n * @remarks\n * This method supports {@link signer}\n * [mixed-case checksum address encoding](https://eips.ethereum.org/EIPS/eip-55).\n *\n * @see constructor\n */\n public static of(data: CertificateData): Certificate {\n try {\n return new Certificate(\n data.purpose,\n data.payload,\n data.domain,\n data.timestamp,\n data.signer,\n data.signature\n );\n } catch (e) {\n throw new InvalidDataType(\n 'Certificate.of',\n 'invalid certificate data',\n { certifiable: data },\n e\n );\n }\n }\n\n /**\n * Signs the current object using a given private key.\n *\n * The {@link signature} is computed encoding this object according\n * the following normalization rules:\n * - the {@link signature} property is ignored, because its value\n * is the result of this method.\n * - the properties are sorted in ascending alphabetic order;\n * - the key/value properties are delimited with `\"` when serialized as JSON\n * before to be encoded as bytes;\n * - any not meaningful blank characters are ignored;\n * - the JSON representation of this object is byte encoded using the UTF-8\n * [normalization form for canonical composition](https://en.wikipedia.org/wiki/Unicode_equivalence#Normal_forms).\n *\n * @param {Uint8Array} privateKey - The private key used for signing.\n * @return {this} The current instance after signing.\n *\n * @throws {InvalidOperation} - If a hash error occurs.\n * @throws {InvalidSecp256k1PrivateKey} - If the private key is not a valid 32-byte private key.\n *\n * @remarks Security auditable method, depends on\n * * {@link Blake2b256.of};\n * * {@link Secp256k1.sign}.\n *\n * @see encode\n * @see verify\n */\n public sign(privateKey: Uint8Array): this {\n this.signature = undefined;\n this.signature = HexUInt.of(\n Secp256k1.sign(\n Blake2b256.of(Certificate.encode(this)).bytes,\n privateKey\n )\n ).toString();\n return this;\n }\n\n /**\n * Verifies the certificate by checking its signature.\n *\n * @throws {CertificateSignatureMismatch} if the certificate\n * - is not signed, or\n * - the signature does not match the signer's public key.\n *\n * @remarks\n * This method supports {@link signer}\n * [mixed-case checksum address encoding](https://eips.ethereum.org/EIPS/eip-55).\n *\n * @remarks Security auditable method, depends on\n * * {@link Blake2b256.of};\n * * {@link Secp256k1.recover}.\n */\n public verify(): void {\n if (!this.isSigned())\n throw new CertificateSignatureMismatch(\n 'Certificate.verify',\n 'signature missing',\n { certificate: this }\n );\n const signer = Address.ofPublicKey(\n Secp256k1.recover(\n Blake2b256.of(\n Certificate.encode({ ...this, signature: undefined })\n ).bytes,\n HexUInt.of(this.signature as string).bytes\n )\n );\n if (signer.toString().toLowerCase() !== this.signer)\n throw new CertificateSignatureMismatch(\n 'Certificate.verify',\n \"signature doesn't match with signer's public key\",\n { certificate: this }\n );\n }\n}\n\nexport { Certificate };\n","/**\n * The [Scrypt](https://en.wikipedia.org/wiki/Scrypt) parameters\n * used in the keystore encryption.\n *\n * @property {number} N - The CPU/memory cost parameter = 2^17 = 131072.\n * @property {number} r - The block size parameter = 8.\n * @property {number} p - The parallelization parameter = 1.\n */\nconst SCRYPT_PARAMS = {\n N: 131072,\n r: 8,\n p: 1\n};\n\nexport { SCRYPT_PARAMS };\n","/**\n * Implements the JSON Keystore v3 Wallet encryption, decryption, and validation functionality.\n */\nimport {\n InvalidKeystore,\n InvalidKeystoreParams,\n stringifyData\n} from '@vechain/sdk-errors';\nimport { ethers } from 'ethers';\nimport { Secp256k1 } from '../../../secp256k1';\nimport { Address, HexUInt } from '../../../vcdm';\nimport { type Keystore, type KeystoreAccount } from '../../types';\nimport { SCRYPT_PARAMS } from './const';\n\n/**\n * Encrypts a given private key into a keystore format using the specified password.\n *\n * @param privateKey - The private key to be encrypted.\n * @param password - The password used for the encryption.\n * @returns A Promise that resolves to the encrypted keystore.\n */\nasync function encrypt(\n privateKey: Uint8Array,\n password: string\n): Promise<Keystore> {\n // Public and Address are derived from a private key\n const derivePublicKey = Secp256k1.derivePublicKey(privateKey);\n const deriveAddress = Address.ofPublicKey(derivePublicKey).toString();\n\n // Create keystore account compatible with ethers\n const keystoreAccount: ethers.KeystoreAccount = {\n address: deriveAddress,\n privateKey: HexUInt.of(privateKey).toString()\n };\n\n // Scrypt options\n const encryptOptions: ethers.EncryptOptions = {\n scrypt: {\n N: SCRYPT_PARAMS.N,\n r: SCRYPT_PARAMS.r,\n p: SCRYPT_PARAMS.p\n }\n };\n\n // String version of keystore\n const keystoreJsonString = await ethers.encryptKeystoreJson(\n keystoreAccount,\n password,\n encryptOptions\n );\n\n return JSON.parse(keystoreJsonString) as Keystore;\n}\n\n/**\n * Decrypts a keystore to obtain the private key using the given password.\n *\n * @param keystore - The keystore containing the encrypted private key.\n * @param password - The password used to decrypt the keystore.\n * @returns A Promise that resolves to the decrypted KeystoreAccount or rejects if the keystore or password is invalid.\n * @throws {InvalidKeystore, InvalidKeystoreParams}\n */\nasync function decrypt(\n keystore: Keystore,\n password: string\n): Promise<KeystoreAccount> {\n // Invalid keystore\n if (!isValid(keystore)) {\n throw new InvalidKeystore(\n 'keystore.decrypt()',\n 'Invalid keystore. Ensure the keystore is properly formatted and contains the necessary data.',\n { keystore }\n );\n }\n\n try {\n return (await ethers.decryptKeystoreJson(\n stringifyData(keystore),\n password\n )) as KeystoreAccount;\n } catch {\n throw new InvalidKeystoreParams(\n 'keystore.decrypt()',\n 'Decryption failed: Invalid Password for the given keystore.',\n // @NOTE: We are not exposing the password in the error data for security reasons.\n {\n keystore\n }\n );\n }\n}\n\n/**\n * Validates if the provided keystore adheres to the expected format and structure.\n *\n * @param keystore - The keystore to be validated.\n * @returns A boolean indicating whether the keystore is valid or not.\n */\nfunction isValid(keystore: Keystore): boolean {\n return ethers.isKeystoreJson(stringifyData(keystore));\n}\n\n/**\n * Exports the keystore functions for encryption, decryption, and validation.\n */\nconst keystore = { encrypt, decrypt, isValid };\nexport { keystore };\n","/**\n * Implements the\n * [JSON Keystore v3 Wallet](https://ethereum.org/en/developers/docs/data-structures-and-encoding/web3-secret-storage)\n * encryption, decryption, and validation functionality.\n */\nimport * as n_utils from '@noble/curves/abstract/utils';\nimport { Address, Hex, Keccak256 } from '../../../vcdm';\nimport { InvalidKeystoreParams, stringifyData } from '@vechain/sdk-errors';\nimport { Secp256k1 } from '../../../secp256k1';\nimport { ctr } from '@noble/ciphers/aes';\nimport { scrypt } from '@noble/hashes/scrypt';\nimport { type Keystore, type KeystoreAccount } from '../../types';\n\n/**\n * The cryptographic algorithm used to store the private key in the\n * keystore is the\n * [Advanced Encryption Standard](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard)\n * [128 bits Counter Mode](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation)\n * as defined by\n * [NIST AES Recommendation for Block Cipher Modes of Operation](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf).\n *\n * @constant {string}\n */\nconst KEYSTORE_CRYPTO_CIPHER = 'aes-128-ctr';\n\n/**\n * The length of the key returned by the\n * [Scrypt](https://en.wikipedia.org/wiki/Scrypt)\n * [Key Derivation Function](https://en.wikipedia.org/wiki/Key_derivation_function)\n * used in the keystore.\n */\nconst KEYSTORE_CRYPTO_PARAMS_DKLEN = 32;\n\n/**\n * The [Key Derivation Function](https://en.wikipedia.org/wiki/Key_derivation_function)\n * of the keystore is [Scrypt](https://en.wikipedia.org/wiki/Scrypt).\n */\nconst KEYSTORE_CRYPTO_KDF = 'scrypt';\n\n/**\n * The version number of the\n * [Web3 Secret Storage Definition](https://ethereum.org/en/developers/docs/data-structures-and-encoding/web3-secret-storage)\n * specifications used in keystore.\n */\nconst KEYSTORE_VERSION = 3;\n\n/**\n * The [Scrypt](https://en.wikipedia.org/wiki/Scrypt) parameters\n * used in the keystore encryption.\n *\n * @property {number} N - The CPU/memory cost parameter = 2^17 = 131072.\n * @property {number} r - The block size parameter = 8.\n * @property {number} p - The parallelization parameter = 1.\n */\nconst SCRYPT_PARAMS = {\n N: 131072,\n r: 8,\n p: 1\n};\n\n/**\n * EncryptOptions interface defines the options of the\n * [Scrypt](https://en.wikipedia.org/wiki/Scrypt) algorithm for the\n * [Key Derivation Function](https://en.wikipedia.org/wiki/Key_derivation_function)\n * used in keystore encryption.\n *\n * @property {Uint8Array} iv - Initialization Vector.\n * @property {Uint8Array} salt - Random bytes to protect against [Rainbow table](https://en.wikipedia.org/wiki/Rainbow_table).\n * @property {number} scrypt.N - CPU/memory cost parameter.\n * @property {number} scrypt.p - Parallelization parameter.\n * @property {number} scrypt.r - Block size parameter.\n *\n * @see {encodeScryptParams}\n */\ninterface EncryptOptions {\n iv?: Uint8Array;\n salt?: Uint8Array;\n uuid?: Uint8Array;\n scrypt?: {\n N?: number;\n p?: number;\n r?: number;\n };\n}\n\n/**\n * ScryptParams interfaces defines the parameters of the\n * [Scrypt](https://en.wikipedia.org/wiki/Scrypt) algorithm for the\n * [Key Derivation Function](https://en.wikipedia.org/wiki/Key_derivation_function)\n * used in keystore encryption.\n *\n * Compatible with\n * [ethers ScryptParams](https://github.com/ethers-io/ethers.js/blob/main/src.ts/wallet/json-keystore.ts).\n *\n * @property {number} N - CPU/memory cost parameter.\n * @property {number} dkLen - Derived key length in bytes.\n * @property {string} name - constant \"scrypt\".\n * @property {number} p - Parallelization parameter.\n * @property {number} r - Block size parameter.\n * @property {Uint8Array} salt - Random bytes to protect against [Rainbow table](https://en.wikipedia.org/wiki/Rainbow_table).\n */\ninterface ScryptParams {\n N: number;\n dkLen: number;\n name: string;\n p: number;\n r: number;\n salt: Uint8Array;\n}\n\n/**\n * Retrieves the\n * [Key Derivation Function](https://en.wikipedia.org/wiki/Key_derivation_function)\n * parameters from the given keystore.\n *\n * Only [Scrypt](https://en.wikipedia.org/wiki/Scrypt) is supported as key-derivation function.\n * [PBKDF2](https://en.wikipedia.org/wiki/PBKDF2) superseded by Scrypt, hence\n * not implemented.\n *\n * @param {Keystore} keystore - The key store object.\n * @returns {ScryptParams} - The decryption key-derivation function parameters.\n * @throws {InvalidKeystoreParams}\n *\n * @see {decryptKeystore}\n * @see {encodeScryptParams}\n */\nfunction decodeScryptParams(keystore: Keystore): ScryptParams {\n const salt = n_utils.hexToBytes(keystore.crypto.kdfparams.salt);\n const N = keystore.crypto.kdfparams.n;\n const r = keystore.crypto.kdfparams.r;\n const p: number = keystore.crypto.kdfparams.p;\n // Make sure N is a power of 2\n if (N <= 0 || (N & (N - 1)) !== 0)\n throw new InvalidKeystoreParams(\n '(EXPERIMENTAL) keystore.decodeScryptParams()',\n 'Decryption failed: invalid keystore.crypto.kdfparams.n parameter.',\n {\n keystore,\n N\n }\n );\n\n // Make sure r and p are positive\n if (r <= 0 || p <= 0)\n throw new InvalidKeystoreParams(\n '(EXPERIMENTAL) keystore.decodeScryptParams()',\n 'Decryption failed: both keystore.crypto.kdfparams.r or keystore.crypto.kdfparams.p parameter must be > 0.',\n {\n keystore,\n r,\n p\n }\n );\n const dkLen = keystore.crypto.kdfparams.dklen;\n\n if (dkLen !== KEYSTORE_CRYPTO_PARAMS_DKLEN)\n throw new InvalidKeystoreParams(\n '(EXPERIMENTAL) keystore.decodeScryptParams()',\n `Decryption failed: keystore.crypto.kdfparams.dklen parameter must be ${KEYSTORE_CRYPTO_PARAMS_DKLEN}`,\n {\n keystore,\n dkLen\n }\n );\n\n return {\n N,\n dkLen: KEYSTORE_CRYPTO_PARAMS_DKLEN,\n name: KEYSTORE_CRYPTO_KDF,\n p,\n r,\n salt\n } satisfies ScryptParams;\n}\n\n/**\n * Encodes the parameters of the\n * [Scrypt](https://en.wikipedia.org/wiki/Scrypt) algorithm of the\n * [Key Derivation Function](https://en.wikipedia.org/wiki/Key_derivation_function)\n * used in the keystore encryption.\n *\n * @param {EncryptOptions} options - The encryption options used to override\n * the default Scrypt parameters:\n * - N: CPU/memory cost,\n * - p: Parallelization parameter,\n * - r: Block size parameter.\n * @returns {ScryptParams} - The encoded scrypt parameters.\n * @throws {InvalidKeystoreParams}\n *\n * @see {decodeScryptParams}\n * @see {encryptKeystore}\n */\nfunction encodeScryptParams(options: EncryptOptions): ScryptParams {\n // Use or generate the salt.\n const salt =\n options.salt ?? Secp256k1.randomBytes(KEYSTORE_CRYPTO_PARAMS_DKLEN);\n // Override the scrypt password-based key derivation function parameters,\n let N = SCRYPT_PARAMS.N;\n let r = SCRYPT_PARAMS.r;\n let p = SCRYPT_PARAMS.p;\n if (options.scrypt != null) {\n if (options.scrypt.N != null) {\n N = options.scrypt.N;\n }\n if (options.scrypt.r != null) {\n r = options.scrypt.r;\n }\n if (options.scrypt.p != null) {\n p = options.scrypt.p;\n }\n }\n\n if (N <= 0 || (BigInt(N) & BigInt(N - 1)) !== BigInt(0))\n throw new InvalidKeystoreParams(\n '(EXPERIMENTAL) keystore.encodeScryptParams()',\n 'Encryption failed: invalid options.scrypt.N parameter.',\n {\n options,\n N\n }\n );\n\n if (r <= 0 || !Number.isSafeInteger(r))\n throw new InvalidKeystoreParams(\n '(EXPERIMENTAL) keystore.encodeScryptParams()',\n 'Encryption failed: invalid options.scrypt.r parameter.',\n {\n options,\n r\n }\n );\n\n if (p <= 0 || !Number.isSafeInteger(p))\n throw new InvalidKeystoreParams(\n '(EXPERIMENTAL) keystore.encodeScryptParams()',\n 'Encryption failed: invalid options.scrypt.p parameter.',\n {\n options,\n p\n }\n );\n\n return {\n name: KEYSTORE_CRYPTO_KDF,\n dkLen: KEYSTORE_CRYPTO_PARAMS_DKLEN,\n N,\n p,\n r,\n salt\n } satisfies ScryptParams;\n}\n\n/**\n * Encrypts a private key with a password to returns a keystore object\n * compliant with [Web3 Secret Storage Definition](https://ethereum.org/en/developers/docs/data-structures-and-encoding/web3-secret-storage/)\n * version 3.\n *\n * The private key is encoded using the\n * [Advanced Encryption Standard](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard)\n * [128 bits Counter Mode](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation)\n * as defined by\n * [NIST AES Recommendation for Block Cipher Modes of Operation](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf).\n *\n * The [Key Derivation Function](https://en.wikipedia.org/wiki/Key_derivation_function)\n * algorithm is [Scrypt](https://en.wikipedia.org/wiki/Scrypt).\n *\n * Secure audit function.\n * - {@link encryptKeystore}.\n * - `password` wiped after use.\n * - `privateKey` wiped after use.\n *\n * @param {Uint8Array} privateKey - The private key to encrypt, the memory location is wiped after use.\n * @param {Uint8Array} password - The password to use for encryption, the memory location is wiped after use.\n * @returns {Keystore} - The encrypted keystore object.\n * @throws {InvalidKeystoreParams}\n *\n * @see {encryptKeystore}\n *\n * @remarks **The private key must not be represented as string to avoid the\n * [Memory Dumping](https://github.com/paulmillr/noble-hashes?tab=readme-ov-file#memory-dumping)\n * attack**.\n */\nfunction encrypt(privateKey: Uint8Array, password: Uint8Array): Keystore {\n return encryptKeystore(privateKey, password, {\n scrypt: {\n N: SCRYPT_PARAMS.N,\n r: SCRYPT_PARAMS.r,\n p: SCRYPT_PARAMS.p\n }\n });\n}\n\n/**\n * Encrypts a private key with a password to returns a keystore object compliant with\n * [Web3 Secret Storage Definition](https://ethereum.org/en/developers/docs/data-structures-and-encoding/web3-secret-storage/)\n * version {@link KEYSTORE_VERSION}.\n *\n * The private key is encoded using the\n * [Advanced Encryption Standard](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard)\n * [128 bits Counter Mode](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation)\n * as defined by\n * [NIST AES Recommendation for Block Cipher Modes of Operation](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf).\n *\n * The [Key Derivation Function](https://en.wikipedia.org/wiki/Key_derivation_function)\n * algorithm is [Scrypt](https://en.wikipedia.org/wiki/Scrypt).\n *\n * Secure audit function.\n * - [ctr](https://github.com/paulmillr/noble-ciphers?tab=readme-ov-file#aes).\n * - {@link Keccak256.of}\n * - `password` wiped after use.\n * - `privateKey` wiped after use.\n * - {@link Secp256k1.derivePublicKey}.\n * - {@link Secp256k1.randomBytes}.\n * - [scrypt](https://github.com/paulmillr/noble-hashes/?tab=readme-ov-file#scrypt).\n *\n * @param privateKey - The private key to encrypt, the memory location is wiped after use.\n * @param password - The password to use for encryption, the memory location is wiped after use.\n * @param options - Parameters used to configure the **AES** encryption of the private key and the **Scrypt** derivation key function.\n * @returns {Keystore} - The encrypted keystore object.\n * @throws {InvalidKeystoreParams}\n *\n * @remarks **The private key must not be represented as string to avoid the\n * [Memory Dumping](https://github.com/paulmillr/noble-hashes?tab=readme-ov-file#memory-dumping)\n * attack**.\n *\n * @see {encrypt}\n * @see {uuidV4}\n */\nfunction encryptKeystore(\n privateKey: Uint8Array,\n password: Uint8Array,\n options: EncryptOptions\n): Keystore {\n try {\n const kdf = encodeScryptParams(options);\n const key = scrypt(password, kdf.salt, {\n N: kdf.N,\n r: kdf.r,\n p: kdf.p,\n dkLen: kdf.dkLen\n });\n // Override initialization vector.\n const iv = options.iv ?? Secp256k1.randomBytes(16);\n if (iv.length !== 16)\n throw new InvalidKeystoreParams(\n '(EXPERIMENTAL) keystore.encryptKeystore()',\n 'Encryption failed: invalid options.iv length.',\n { iv }\n );\n\n // Override the uuid.\n const uuidRandom = options.uuid ?? Secp256k1.randomBytes(16);\n\n if (uuidRandom.length !== 16)\n throw new InvalidKeystoreParams(\n '(EXPERIMENTAL) keystore.encryptKeystore()',\n 'Encryption failed: invalid options.uuid length.',\n { uuidRandom }\n );\n\n // Message Authentication Code prefix.\n const macPrefix = key.slice(16, 32);\n // Encrypt the private key: 32 bytes for the Web3 Secret Storage (derivedKey, macPrefix)\n const ciphertext = ctr(key.slice(0, 16), iv).encrypt(privateKey);\n return {\n address: Address.ofPrivateKey(privateKey).toString(),\n crypto: {\n cipher: KEYSTORE_CRYPTO_CIPHER,\n cipherparams: {\n iv: Hex.of(iv).digits\n },\n ciphertext: Hex.of(ciphertext).digits,\n kdf: 'scrypt',\n kdfparams: {\n dklen: KEYSTORE_CRYPTO_PARAMS_DKLEN,\n n: kdf.N,\n p: kdf.p,\n r: kdf.r,\n salt: Hex.of(kdf.salt).digits\n },\n // Compute the message authentication code, used to check the password.\n mac: Keccak256.of(n_utils.concatBytes(macPrefix, ciphertext))\n .digits\n },\n id: uuidV4(uuidRandom),\n version: KEYSTORE_VERSION\n } satisfies Keystore;\n } finally {\n privateKey.fill(0); // Clear the private key from memory.\n password.fill(0); // Clear the password from memory.\n }\n}\n\n/**\n * Decrypts a keystore compliant with\n * [Web3 Secret Storage Definition](https://ethereum.org/en/developers/docs/data-structures-and-encoding/web3-secret-storage/)\n * version 3, using the given password to obtain the private key and wallet address.\n *\n * **WARNING:** call\n * ```javascript\n * privateKey.fill(0)\n * ```\n * after use to avoid to invalidate any security audit and certification granted to this code.\n *\n * The private key should be encoded using the\n * [Advanced Encryption Standard](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard)\n * [128 bits Counter Mode](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation)\n * as defined by\n * [NIST AES Recommendation for Block Cipher Modes of Operation](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf),\n * any different encryption not supported.\n *\n * The [Key Derivation Function](https://en.wikipedia.org/wiki/Key_derivation_function)\n * algorithm should be [Scrypt](https://en.wikipedia.org/wiki/Scrypt),\n * any different KDF function not supported.\n *\n * Secure audit function.\n * - {@link decryptKeystore}\n *\n * @param {Keystore} keystore - The keystore object to decrypt.\n * @param {Uint8Array} password - The password used for decryption, wiped after use.\n * @return {KeystoreAccount} - The decrypted keystore account object.\n *\n * @see {decryptKeystore}\n * @see {isValid}\n */\nfunction decrypt(keystore: Keystore, password: Uint8Array): KeystoreAccount {\n return decryptKeystore(keystore, password);\n}\n\n/**\n * Decrypts a keystore compliant with\n * [Web3 Secret Storage Definition](https://ethereum.org/en/developers/docs/data-structures-and-encoding/web3-secret-storage/)\n * using the given password to obtain the private key and wallet address.\n *\n * **WARNING:** call\n * ```javascript\n * privateKey.fill(0)\n * ```\n * after use to avoid to invalidate any security audit and certification granted to this code.\n *\n * The private key should be encoded using the\n * [Advanced Encryption Standard](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard)\n * [128 bits Counter Mode](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation)\n * as defined by\n * [NIST AES Recommendation for Block Cipher Modes of Operation](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf),\n * any different encryption not supported.\n *\n * The [Key Derivation Function](https://en.wikipedia.org/wiki/Key_derivation_function)\n * algorithm should be [Scrypt](https://en.wikipedia.org/wiki/Scrypt),\n * any different KDF function not supported.\n *\n * Secure audit function.\n * - {@link Address.ofPrivateKey}\n * - [ctr](https://github.com/paulmillr/noble-ciphers?tab=readme-ov-file#aes).\n * - `password` wiped after use.\n * - [scrypt](https://github.com/paulmillr/noble-hashes/?tab=readme-ov-file#scrypt).\n *\n * @param {Keystore} keystore - The keystore object to decrypt.\n * @param {Uint8Array} password - The password used for decryption, wiped after use.\n * @return {KeystoreAccount} - The decrypted keystore account object.\n * @throws {InvalidKeystoreParams}\n *\n * @see {decodeScryptParams}\n * @see {decrypt}\n */\nfunction decryptKeystore(\n keystore: Keystore,\n password: Uint8Array\n): KeystoreAccount {\n try {\n if (keystore.crypto.cipher.toLowerCase() !== KEYSTORE_CRYPTO_CIPHER)\n throw new InvalidKeystoreParams(\n '(EXPERIMENTAL) keystore.decryptKeystore()',\n 'Decryption failed: unsupported crypto cipher algorithm.',\n { cipher: keystore.crypto.cipher.toLowerCase() }\n );\n\n if (keystore.crypto.kdf.toLowerCase() !== KEYSTORE_CRYPTO_KDF)\n throw new InvalidKeystoreParams(\n '(EXPERIMENTAL) keystore.decryptKeystore()',\n 'Decryption failed: unsupported crypto key derivation function.',\n { keyDerivationFunction: keystore.crypto.kdf.toLowerCase() }\n );\n\n if (keystore.version !== KEYSTORE_VERSION)\n throw new InvalidKeystoreParams(\n '(EXPERIMENTAL) keystore.decryptKeystore()',\n 'Decryption failed: unsupported keystore version.',\n { version: keystore.version }\n );\n\n const kdf = decodeScryptParams(keystore);\n const key = scrypt(password, kdf.salt, {\n N: kdf.N,\n r: kdf.r,\n p: kdf.p,\n dkLen: kdf.dkLen\n });\n const ciphertext = n_utils.hexToBytes(keystore.crypto.ciphertext);\n if (\n keystore.crypto.mac !==\n Keccak256.of(n_utils.concatBytes(key.slice(16, 32), ciphertext))\n .digits\n ) {\n throw new InvalidKeystoreParams(\n '(EXPERIMENTAL) keystore.decryptKeystore()',\n 'Decryption failed: Invalid Password for the given keystore.',\n // @NOTE: We are not exposing the password in the error data for security reasons.\n {\n keystore\n }\n );\n }\n const privateKey = ctr(\n key.slice(0, 16),\n n_utils.hexToBytes(keystore.crypto.cipherparams.iv)\n ).decrypt(ciphertext);\n const address = Address.ofPrivateKey(privateKey).toString();\n if (\n keystore.address !== '' &&\n address !== Address.checksum(Hex.of(keystore.address))\n ) {\n throw new InvalidKeystoreParams(\n '(EXPERIMENTAL) keystore.decryptKeystore()',\n 'Decryption failed: address/password mismatch.',\n { keystoreAddress: keystore.address }\n );\n }\n return {\n address,\n // @note: Convert the private key to a string to be compatible with ethers\n privateKey: Hex.of(privateKey).toString()\n } satisfies KeystoreAccount;\n } finally {\n password.fill(0); // Clear the password from memory.\n }\n}\n\n/**\n * Checks if a given keystore object is valid parsing its JSON representation\n * to catch any parsing errors, only valid\n * [Web3 Secret Storage Definition](https://ethereum.org/en/developers/docs/data-structures-and-encoding/web3-secret-storage/)\n * version 3 keystore are accepted, using\n * [Advanced Encryption Standard](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard)\n * [128 bits Counter Mode](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation)\n * to encrypt the private key and using\n * [Scrypt](https://en.wikipedia.org/wiki/Scrypt) as\n * [Key Derivation Function](https://en.wikipedia.org/wiki/Key_derivation_function).\n *\n * @param {Keystore} keystore - The keystore object to validate.\n * @return {boolean} Returns true if the keystore is valid, false otherwise.\n */\nfunction isValid(keystore: Keystore): boolean {\n try {\n const copy = JSON.parse(stringifyData(keystore)) as Keystore;\n if (\n copy.crypto.cipher.toLowerCase() === KEYSTORE_CRYPTO_CIPHER &&\n copy.crypto.kdf.toLowerCase() === KEYSTORE_CRYPTO_KDF &&\n copy.version === KEYSTORE_VERSION\n ) {\n return true;\n }\n } catch {} // Return false if parsing fails.\n return false;\n}\n\n/**\n * Generates a version 4\n * [UUID (Universally Unique Identifier)](https://en.wikipedia.org/wiki/Universally_unique_identifier)\n * based on the given bytes.\n *\n * @param {Uint8Array} bytes - The byte array used to generate the UUID.\n * @returns {string} The generated UUID.\n */\nfunction uuidV4(bytes: Uint8Array): string {\n // Section: 4.1.3:\n // - time_hi_and_version[12:16] = 0b0100\n bytes[6] = (bytes[6] & 0x0f) | 0x40;\n // Section 4.4\n // - clock_seq_hi_and_reserved[6] = 0b0\n // - clock_seq_hi_and_reserved[7] = 0b1\n bytes[8] = (bytes[8] & 0x3f) | 0x80;\n const value = Hex.of(bytes).digits;\n return [\n value.substring(0, 8),\n value.substring(8, 12),\n value.substring(12, 16),\n value.substring(16, 20),\n value.substring(20, 32)\n ].join('-');\n}\n\n/**\n * Exports the keystore functions for encryption, decryption, and validation.\n */\nexport const keystore = { decrypt, encrypt, isValid };\n","import { VeChainSDKLogger } from '@vechain/sdk-logging';\nimport { Txt } from '../vcdm';\nimport { keystoreEthers, keystoreExperimental } from './cryptography';\nimport { type Keystore, type KeystoreAccount } from './types';\n\n/**\n * A boolean indicating whether the keystore cryptography is experimental or not.\n */\nlet EXPERIMENTAL_CRYPTOGRAPHY: boolean = false;\n\n/**\n * Sets the keystore cryptography to experimental mode.\n *\n * @param experimentalCryptography - A boolean indicating whether the keystore cryptography is experimental or not.\n */\nfunction useExperimentalCryptography(experimentalCryptography: boolean): void {\n EXPERIMENTAL_CRYPTOGRAPHY = experimentalCryptography;\n}\n\n/**\n * Encrypts a given private key into a keystore format using the specified password.\n *\n * @param privateKey - The private key to be encrypted.\n * @param password - The password used for the encryption.\n * @returns A Promise that resolves to the encrypted keystore.\n */\nasync function encrypt(\n privateKey: Uint8Array,\n password: string\n): Promise<Keystore> {\n if (EXPERIMENTAL_CRYPTOGRAPHY)\n VeChainSDKLogger('warning').log({\n title: `Experimental cryptography`,\n messages: [\n `Remember, you are using an experimental cryptography library.`,\n 'functions: keystore.encrypt'\n ]\n });\n\n return EXPERIMENTAL_CRYPTOGRAPHY\n ? keystoreExperimental.encrypt(privateKey, Txt.of(password).bytes)\n : await keystoreEthers.encrypt(privateKey, password);\n}\n\n/**\n * Decrypts a keystore to obtain the private key using the given password.\n *\n * @throws {InvalidKeystoreError, InvalidKeystorePasswordError}\n * @param keystore - The keystore containing the encrypted private key.\n * @param password - The password used to decrypt the keystore.\n * @returns A Promise that resolves to the decrypted KeystoreAccount or rejects if the keystore or password is invalid.\n */\nasync function decrypt(\n keystore: Keystore,\n password: string\n): Promise<KeystoreAccount> {\n if (EXPERIMENTAL_CRYPTOGRAPHY)\n VeChainSDKLogger('warning').log({\n title: `Experimental cryptography`,\n messages: [\n `Remember, you are using an experimental cryptography library.`,\n 'functions: keystore.decrypt'\n ]\n });\n\n return EXPERIMENTAL_CRYPTOGRAPHY\n ? keystoreExperimental.decrypt(keystore, Txt.of(password).bytes)\n : await keystoreEthers.decrypt(keystore, password);\n}\n\n/**\n * Validates if the provided keystore adheres to the expected format and structure.\n *\n * @param keystore - The keystore to be validated.\n * @returns A boolean indicating whether the keystore is valid or not.\n */\nfunction isValid(keystore: Keystore): boolean {\n if (EXPERIMENTAL_CRYPTOGRAPHY)\n VeChainSDKLogger('warning').log({\n title: `Experimental cryptography`,\n messages: [\n `Remember, you are using an experimental cryptography library.`,\n 'functions: keystore.isValid'\n ]\n });\n\n return EXPERIMENTAL_CRYPTOGRAPHY\n ? keystoreExperimental.isValid(keystore)\n : keystoreEthers.isValid(keystore);\n}\n\n/**\n * Exports the keystore functions for encryption, decryption, and validation.\n */\nconst keystore = { encrypt, decrypt, isValid, useExperimentalCryptography };\nexport { keystore };\n","/**\n * ABI of the ERC20 token standard.\n *\n * @see [EIP 20](https://eips.ethereum.org/EIPS/eip-20)\n */\nconst ERC20_ABI = [\n { inputs: [], stateMutability: 'nonpayable', type: 'constructor' },\n {\n inputs: [\n { internalType: 'address', name: 'spender', type: 'address' },\n { internalType: 'uint256', name: 'allowance', type: 'uint256' },\n { internalType: 'uint256', name: 'needed', type: 'uint256' }\n ],\n name: 'ERC20InsufficientAllowance',\n type: 'error'\n },\n {\n inputs: [\n { internalType: 'address', name: 'sender', type: 'address' },\n { internalType: 'uint256', name: 'balance', type: 'uint256' },\n { internalType: 'uint256', name: 'needed', type: 'uint256' }\n ],\n name: 'ERC20InsufficientBalance',\n type: 'error'\n },\n {\n inputs: [\n { internalType: 'address', name: 'approver', type: 'address' }\n ],\n name: 'ERC20InvalidApprover',\n type: 'error'\n },\n {\n inputs: [\n { internalType: 'address', name: 'receiver', type: 'address' }\n ],\n name: 'ERC20InvalidReceiver',\n type: 'error'\n },\n {\n inputs: [{ internalType: 'address', name: 'sender', type: 'address' }],\n name: 'ERC20InvalidSender',\n type: 'error'\n },\n {\n inputs: [{ internalType: 'address', name: 'spender', type: 'address' }],\n name: 'ERC20InvalidSpender',\n type: 'error'\n },\n {\n anonymous: false,\n inputs: [\n {\n indexed: true,\n internalType: 'address',\n name: 'owner',\n type: 'address'\n },\n {\n indexed: true,\n internalType: 'address',\n name: 'spender',\n type: 'address'\n },\n {\n indexed: false,\n internalType: 'uint256',\n name: 'value',\n type: 'uint256'\n }\n ],\n name: 'Approval',\n type: 'event'\n },\n {\n anonymous: false,\n inputs: [\n {\n indexed: true,\n internalType: 'address',\n name: 'from',\n type: 'address'\n },\n {\n indexed: true,\n internalType: 'address',\n name: 'to',\n type: 'address'\n },\n {\n indexed: false,\n internalType: 'uint256',\n name: 'value',\n type: 'uint256'\n }\n ],\n name: 'Transfer',\n type: 'event'\n },\n {\n inputs: [\n { internalType: 'address', name: 'owner', type: 'address' },\n { internalType: 'address', name: 'spender', type: 'address' }\n ],\n name: 'allowance',\n outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function'\n },\n {\n inputs: [\n { internalType: 'address', name: 'spender', type: 'address' },\n { internalType: 'uint256', name: 'value', type: 'uint256' }\n ],\n name: 'approve',\n outputs: [{ internalType: 'bool', name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n type: 'function'\n },\n {\n inputs: [{ internalType: 'address', name: 'account', type: 'address' }],\n name: 'balanceOf',\n outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function'\n },\n {\n inputs: [],\n name: 'decimals',\n outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }],\n stateMutability: 'view',\n type: 'function'\n },\n {\n inputs: [],\n name: 'name',\n outputs: [{ internalType: 'string', name: '', type: 'string' }],\n stateMutability: 'view',\n type: 'function'\n },\n {\n inputs: [],\n name: 'symbol',\n outputs: [{ internalType: 'string', name: '', type: 'string' }],\n stateMutability: 'view',\n type: 'function'\n },\n {\n inputs: [],\n name: 'totalSupply',\n outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function'\n },\n {\n inputs: [\n { internalType: 'address', name: 'to', type: 'address' },\n { internalType: 'uint256', name: 'value', type: 'uint256' }\n ],\n name: 'transfer',\n outputs: [{ internalType: 'bool', name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n type: 'function'\n },\n {\n inputs: [\n { internalType: 'address', name: 'from', type: 'address' },\n { internalType: 'address', name: 'to', type: 'address' },\n { internalType: 'uint256', name: 'value', type: 'uint256' }\n ],\n name: 'transferFrom',\n outputs: [{ internalType: 'bool', name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n type: 'function'\n }\n] as const;\n\n/**\n * ABI of the ERC721 token standard.\n *\n * @see [EIP 721](https://eips.ethereum.org/EIPS/eip-721)\n */\nconst ERC721_ABI = [\n {\n inputs: [],\n stateMutability: 'nonpayable',\n type: 'constructor'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'sender',\n type: 'address'\n },\n {\n internalType: 'uint256',\n name: 'tokenId',\n type: 'uint256'\n },\n {\n internalType: 'address',\n name: 'owner',\n type: 'address'\n }\n ],\n name: 'ERC721IncorrectOwner',\n type: 'error'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'operator',\n type: 'address'\n },\n {\n internalType: 'uint256',\n name: 'tokenId',\n type: 'uint256'\n }\n ],\n name: 'ERC721InsufficientApproval',\n type: 'error'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'approver',\n type: 'address'\n }\n ],\n name: 'ERC721InvalidApprover',\n type: 'error'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'operator',\n type: 'address'\n }\n ],\n name: 'ERC721InvalidOperator',\n type: 'error'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'owner',\n type: 'address'\n }\n ],\n name: 'ERC721InvalidOwner',\n type: 'error'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'receiver',\n type: 'address'\n }\n ],\n name: 'ERC721InvalidReceiver',\n type: 'error'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'sender',\n type: 'address'\n }\n ],\n name: 'ERC721InvalidSender',\n type: 'error'\n },\n {\n inputs: [\n {\n internalType: 'uint256',\n name: 'tokenId',\n type: 'uint256'\n }\n ],\n name: 'ERC721NonexistentToken',\n type: 'error'\n },\n {\n anonymous: false,\n inputs: [\n {\n indexed: true,\n internalType: 'address',\n name: 'owner',\n type: 'address'\n },\n {\n indexed: true,\n internalType: 'address',\n name: 'approved',\n type: 'address'\n },\n {\n indexed: true,\n internalType: 'uint256',\n name: 'tokenId',\n type: 'uint256'\n }\n ],\n name: 'Approval',\n type: 'event'\n },\n {\n anonymous: false,\n inputs: [\n {\n indexed: true,\n internalType: 'address',\n name: 'owner',\n type: 'address'\n },\n {\n indexed: true,\n internalType: 'address',\n name: 'operator',\n type: 'address'\n },\n {\n indexed: false,\n internalType: 'bool',\n name: 'approved',\n type: 'bool'\n }\n ],\n name: 'ApprovalForAll',\n type: 'event'\n },\n {\n anonymous: false,\n inputs: [\n {\n indexed: true,\n internalType: 'address',\n name: 'from',\n type: 'address'\n },\n {\n indexed: true,\n internalType: 'address',\n name: 'to',\n type: 'address'\n },\n {\n indexed: true,\n internalType: 'uint256',\n name: 'tokenId',\n type: 'uint256'\n }\n ],\n name: 'Transfer',\n type: 'event'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'to',\n type: 'address'\n },\n {\n internalType: 'uint256',\n name: 'tokenId',\n type: 'uint256'\n }\n ],\n name: 'approve',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'owner',\n type: 'address'\n }\n ],\n name: 'balanceOf',\n outputs: [\n {\n internalType: 'uint256',\n name: '',\n type: 'uint256'\n }\n ],\n stateMutability: 'view',\n type: 'function'\n },\n {\n inputs: [\n {\n internalType: 'uint256',\n name: 'tokenId',\n type: 'uint256'\n }\n ],\n name: 'getApproved',\n outputs: [\n {\n internalType: 'address',\n name: '',\n type: 'address'\n }\n ],\n stateMutability: 'view',\n type: 'function'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'owner',\n type: 'address'\n },\n {\n internalType: 'address',\n name: 'operator',\n type: 'address'\n }\n ],\n name: 'isApprovedForAll',\n outputs: [\n {\n internalType: 'bool',\n name: '',\n type: 'bool'\n }\n ],\n stateMutability: 'view',\n type: 'function'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'receiver',\n type: 'address'\n }\n ],\n name: 'mintItem',\n outputs: [\n {\n internalType: 'uint256',\n name: '',\n type: 'uint256'\n }\n ],\n stateMutability: 'nonpayable',\n type: 'function'\n },\n {\n inputs: [],\n name: 'name',\n outputs: [\n {\n internalType: 'string',\n name: '',\n type: 'string'\n }\n ],\n stateMutability: 'view',\n type: 'function'\n },\n {\n inputs: [\n {\n internalType: 'uint256',\n name: 'tokenId',\n type: 'uint256'\n }\n ],\n name: 'ownerOf',\n outputs: [\n {\n internalType: 'address',\n name: '',\n type: 'address'\n }\n ],\n stateMutability: 'view',\n type: 'function'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'from',\n type: 'address'\n },\n {\n internalType: 'address',\n name: 'to',\n type: 'address'\n },\n {\n internalType: 'uint256',\n name: 'tokenId',\n type: 'uint256'\n }\n ],\n name: 'safeTransferFrom',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'from',\n type: 'address'\n },\n {\n internalType: 'address',\n name: 'to',\n type: 'address'\n },\n {\n internalType: 'uint256',\n name: 'tokenId',\n type: 'uint256'\n },\n {\n internalType: 'bytes',\n name: 'data',\n type: 'bytes'\n }\n ],\n name: 'safeTransferFrom',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'operator',\n type: 'address'\n },\n {\n internalType: 'bool',\n name: 'approved',\n type: 'bool'\n }\n ],\n name: 'setApprovalForAll',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function'\n },\n {\n inputs: [\n {\n internalType: 'bytes4',\n name: 'interfaceId',\n type: 'bytes4'\n }\n ],\n name: 'supportsInterface',\n outputs: [\n {\n internalType: 'bool',\n name: '',\n type: 'bool'\n }\n ],\n stateMutability: 'view',\n type: 'function'\n },\n {\n inputs: [],\n name: 'symbol',\n outputs: [\n {\n internalType: 'string',\n name: '',\n type: 'string'\n }\n ],\n stateMutability: 'view',\n type: 'function'\n },\n {\n inputs: [\n {\n internalType: 'uint256',\n name: 'tokenId',\n type: 'uint256'\n }\n ],\n name: 'tokenURI',\n outputs: [\n {\n internalType: 'string',\n name: '',\n type: 'string'\n }\n ],\n stateMutability: 'view',\n type: 'function'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'from',\n type: 'address'\n },\n {\n internalType: 'address',\n name: 'to',\n type: 'address'\n },\n {\n internalType: 'uint256',\n name: 'tokenId',\n type: 'uint256'\n }\n ],\n name: 'transferFrom',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function'\n }\n] as const;\n\n/**\n * ABI of the ERC1155 token standard.\n *\n * @see [EIP 1155](https://eips.ethereum.org/EIPS/eip-1155)\n */\nconst ERC1155_ABI = [\n {\n anonymous: false,\n inputs: [\n {\n indexed: true,\n internalType: 'address',\n name: 'account',\n type: 'address'\n },\n {\n indexed: true,\n internalType: 'address',\n name: 'operator',\n type: 'address'\n },\n {\n indexed: false,\n internalType: 'bool',\n name: 'approved',\n type: 'bool'\n }\n ],\n name: 'ApprovalForAll',\n type: 'event'\n },\n {\n anonymous: false,\n inputs: [\n {\n indexed: true,\n internalType: 'address',\n name: 'operator',\n type: 'address'\n },\n {\n indexed: true,\n internalType: 'address',\n name: 'from',\n type: 'address'\n },\n {\n indexed: true,\n internalType: 'address',\n name: 'to',\n type: 'address'\n },\n {\n indexed: false,\n internalType: 'uint256[]',\n name: 'ids',\n type: 'uint256[]'\n },\n {\n indexed: false,\n internalType: 'uint256[]',\n name: 'values',\n type: 'uint256[]'\n }\n ],\n name: 'TransferBatch',\n type: 'event'\n },\n {\n anonymous: false,\n inputs: [\n {\n indexed: true,\n internalType: 'address',\n name: 'operator',\n type: 'address'\n },\n {\n indexed: true,\n internalType: 'address',\n name: 'from',\n type: 'address'\n },\n {\n indexed: true,\n internalType: 'address',\n name: 'to',\n type: 'address'\n },\n {\n indexed: false,\n internalType: 'uint256',\n name: 'id',\n type: 'uint256'\n },\n {\n indexed: false,\n internalType: 'uint256',\n name: 'value',\n type: 'uint256'\n }\n ],\n name: 'TransferSingle',\n type: 'event'\n },\n {\n anonymous: false,\n inputs: [\n {\n indexed: false,\n internalType: 'string',\n name: 'value',\n type: 'string'\n },\n {\n indexed: true,\n internalType: 'uint256',\n name: 'id',\n type: 'uint256'\n }\n ],\n name: 'URI',\n type: 'event'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'account',\n type: 'address'\n },\n {\n internalType: 'uint256',\n name: 'id',\n type: 'uint256'\n }\n ],\n name: 'balanceOf',\n outputs: [\n {\n internalType: 'uint256',\n name: '',\n type: 'uint256'\n }\n ],\n stateMutability: 'view',\n type: 'function'\n },\n {\n inputs: [\n {\n internalType: 'address[]',\n name: 'accounts',\n type: 'address[]'\n },\n {\n internalType: 'uint256[]',\n name: 'ids',\n type: 'uint256[]'\n }\n ],\n name: 'balanceOfBatch',\n outputs: [\n {\n internalType: 'uint256[]',\n name: '',\n type: 'uint256[]'\n }\n ],\n stateMutability: 'view',\n type: 'function'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'account',\n type: 'address'\n },\n {\n internalType: 'address',\n name: 'operator',\n type: 'address'\n }\n ],\n name: 'isApprovedForAll',\n outputs: [\n {\n internalType: 'bool',\n name: '',\n type: 'bool'\n }\n ],\n stateMutability: 'view',\n type: 'function'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'from',\n type: 'address'\n },\n {\n internalType: 'address',\n name: 'to',\n type: 'address'\n },\n {\n internalType: 'uint256[]',\n name: 'ids',\n type: 'uint256[]'\n },\n {\n internalType: 'uint256[]',\n name: 'amounts',\n type: 'uint256[]'\n },\n {\n internalType: 'bytes',\n name: 'data',\n type: 'bytes'\n }\n ],\n name: 'safeBatchTransferFrom',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'from',\n type: 'address'\n },\n {\n internalType: 'address',\n name: 'to',\n type: 'address'\n },\n {\n internalType: 'uint256',\n name: 'id',\n type: 'uint256'\n },\n {\n internalType: 'uint256',\n name: 'amount',\n type: 'uint256'\n },\n {\n internalType: 'bytes',\n name: 'data',\n type: 'bytes'\n }\n ],\n name: 'safeTransferFrom',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function'\n },\n {\n inputs: [\n {\n internalType: 'address',\n name: 'operator',\n type: 'address'\n },\n {\n internalType: 'bool',\n name: 'approved',\n type: 'bool'\n }\n ],\n name: 'setApprovalForAll',\n outputs: [],\n stateMutability: 'nonpayable',\n type: 'function'\n },\n {\n inputs: [\n {\n internalType: 'bytes4',\n name: 'interfaceId',\n type: 'bytes4'\n }\n ],\n name: 'supportsInterface',\n outputs: [\n {\n internalType: 'bool',\n name: '',\n type: 'bool'\n }\n ],\n stateMutability: 'view',\n type: 'function'\n },\n {\n inputs: [\n {\n internalType: 'uint256',\n name: 'id',\n type: 'uint256'\n }\n ],\n name: 'uri',\n outputs: [\n {\n internalType: 'string',\n name: '',\n type: 'string'\n }\n ],\n stateMutability: 'view',\n type: 'function'\n }\n] as const;\n\n/**\n * ABI of the VIP180 token standard.\n *\n * @see [VIP 180](https://github.com/vechain/VIPs/blob/master/vips/VIP-180.md)\n */\nconst VIP180_ABI = ERC20_ABI;\n\n/**\n * ABI of the VIP181 token standard.\n *\n * @see [VIP 181](https://github.com/vechain/VIPs/blob/master/vips/VIP-181.md)\n */\nconst VIP181_ABI = ERC721_ABI;\n\n/**\n * ABI of the VIP210 token standard.\n *\n * @see [VIP 210](https://github.com/vechain/VIPs/blob/master/vips/VIP-210.md)\n */\nconst VIP210_ABI = ERC1155_ABI;\n\nexport {\n VIP180_ABI,\n VIP181_ABI,\n VIP210_ABI,\n ERC20_ABI,\n ERC721_ABI,\n ERC1155_ABI\n};\n","/**\n * Create a Uint8Array filled with zero bytes of the specified size.\n *\n * @param {number} size - The size of the Uint8Array to create.\n * @returns {Uint8Array} - A Uint8Array filled with zero bytes.\n */\nconst ZERO_BYTES = (size: number): Uint8Array => new Uint8Array(size);\n\n/**\n * Regular expression for matching numeric values expressed as base 10 strings.\n *\n * The regular expression matches the following numeric patterns:\n * - Whole numbers:\n * - Positive whole numbers: 1, 2, 3, ...\n * - Negative whole numbers: -1, -2, -3, ...\n * - Decimal numbers:\n * - Positive decimal numbers: 1.0, 2.5, 3.14, ...\n * - Negative decimal numbers: -1.0, -2.5, -3.14, ...\n * - Decimal numbers without whole part:\n * - Positive decimal numbers: .1, .5, .75, ...\n * - Negative decimal numbers: -.1, -.5, -.75, ...\n *\n * @constant {RegExp} NUMERIC_REGEX\n */\nconst NUMERIC_REGEX = /(^-?\\d+(\\.\\d+)?)$|(^-?\\.\\d+)$/;\n\nexport { NUMERIC_REGEX, ZERO_BYTES };\n","import * as nc_utils from '@noble/curves/abstract/utils';\nimport { InvalidDataType } from '@vechain/sdk-errors';\nimport { Hex } from '../../vcdm/Hex';\nimport { Txt } from '../../vcdm/Txt';\nimport { ZERO_BYTES } from '../const';\n\n/**\n * Decodes a hexadecimal string representing a bytes32 value into a string.\n * The bytes32 string can be padded with zeros to the left or right.\n * An example of usage is to decode a bytes32 string returned by a smart contract function.\n *\n * @param {string} hex - The hexadecimal string to decode.\n * @returns {string} - The decoded string value.\n * @throws {InvalidDataType}\n */\nconst decodeBytes32String = (hex: string): string => {\n if (!Hex.isValid(hex) || Hex.of(hex).digits.length !== 64)\n throw new InvalidDataType(\n 'dataUtils.decodeBytes32String()',\n `Failed to decode value ${hex} to string. Value is not a valid hex string or it is not 64 characters long`,\n { value: hex }\n );\n\n const valueInBytes = Hex.of(hex).bytes;\n // Find the first zero byte.\n const firstZeroIndex = valueInBytes.findIndex((byte) => byte === 0);\n // If the first byte is zero, then the encoded bytes 32 string is padded with zeros to the left.\n if (firstZeroIndex === 0) {\n // Find the first non-zero byte.\n const firstNotZeroIndex = valueInBytes.findIndex((byte) => byte !== 0);\n // Decode the encoded bytes 32 string to string by removing the padded zeros.\n return Txt.of(valueInBytes.subarray(firstNotZeroIndex)).toString();\n } else if (firstZeroIndex !== -1) {\n // Decode the encoded bytes 32 string to string by removing the padded zeros.\n return Txt.of(valueInBytes.subarray(0, firstZeroIndex)).toString();\n } else {\n return Txt.of(valueInBytes).toString();\n }\n};\n\n/**\n * Encodes a string into a bytes32 hexadecimal expression with optional zero padding.\n * The encoded bytes32 string can be used as a parameter for a smart contract function.\n *\n * @param {string} value - The value to encode.\n * @param {'left' | 'right'} [zeroPadding='left'] - The type of zero padding to apply.\n * @returns {string} The encoded bytes32 string is a hexadecimal expression prefixed with `0x.\n * @throws {InvalidDataType}\n */\nconst encodeBytes32String = (\n value: string,\n zeroPadding: 'left' | 'right' = 'right' // Default to 'right' as ethers.js does.\n): string => {\n // Wrap any error raised by utf8BytesOf(value).\n try {\n const valueInBytes = Txt.of(value).bytes;\n\n if (valueInBytes.length > 32) {\n throw new InvalidDataType(\n 'dataUtils.encodeBytes32String()',\n `Failed to encode value ${value} to bytes32 string. Value exceeds 32 bytes.`,\n { value }\n );\n }\n\n const pad = ZERO_BYTES(32 - valueInBytes.length);\n return zeroPadding === 'left'\n ? Hex.of(nc_utils.concatBytes(pad, valueInBytes)).toString()\n : Hex.of(nc_utils.concatBytes(valueInBytes, pad)).toString();\n } catch (e) {\n throw new InvalidDataType(\n 'dataUtils.encodeBytes32String()',\n `Failed to encode value ${value} to bytes32 string.`,\n { value },\n e\n );\n }\n};\n\nexport const dataUtils = {\n decodeBytes32String,\n encodeBytes32String\n};\n","/**\n * Constant defining VeChain mainnet chain tag. The chain tag is the last byte of the genesis block ID\n */\nconst VECHAIN_MAINNET_CHAIN_TAG = 0x4a;\n\n/**\n * Constant defining VeChain testnet chain tag. The chain tag is the last byte of the genesis block ID\n */\nconst VECHAIN_TESTNET_CHAIN_TAG = 0x27;\n\n/**\n * Constant defining VeChain testnet chain tag. The chain tag is the last byte of the genesis block ID\n */\nconst VECHAIN_SOLO_CHAIN_TAG = 0xf6;\n\n/**\n * Constant representing the zero address in hexadecimal format\n */\nconst ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';\n\n/**\n * VTHO token address (energy.sol smart contract address)\n */\nconst VTHO_ADDRESS = '0x0000000000000000000000000000456e65726779';\n\n/**\n * Genesis block for VeChain mainnet\n */\nconst mainnetGenesisBlock = {\n number: 0,\n id: '0x00000000851caf3cfdb6e899cf5958bfb1ac3413d346d43539627e6be7ec1b4a',\n size: 170,\n parentID:\n '0xffffffff53616c757465202620526573706563742c20457468657265756d2100',\n timestamp: 1530316800,\n gasLimit: 10000000,\n beneficiary: '0x0000000000000000000000000000000000000000',\n gasUsed: 0,\n totalScore: 0,\n txsRoot:\n '0x45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0',\n txsFeatures: 0,\n stateRoot:\n '0x09bfdf9e24dd5cd5b63f3c1b5d58b97ff02ca0490214a021ed7d99b93867839c',\n receiptsRoot:\n '0x45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0',\n signer: '0x0000000000000000000000000000000000000000',\n isTrunk: true,\n transactions: []\n};\n\n/**\n * Genesis block for VeChain testnet\n */\nconst testnetGenesisBlock = {\n number: 0,\n id: '0x000000000b2bce3c70bc649a02749e8687721b09ed2e15997f466536b20bb127',\n size: 170,\n parentID:\n '0xffffffff00000000000000000000000000000000000000000000000000000000',\n timestamp: 1530014400,\n gasLimit: 10000000,\n beneficiary: '0x0000000000000000000000000000000000000000',\n gasUsed: 0,\n totalScore: 0,\n txsRoot:\n '0x45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0',\n txsFeatures: 0,\n stateRoot:\n '0x4ec3af0acbad1ae467ad569337d2fe8576fe303928d35b8cdd91de47e9ac84bb',\n receiptsRoot:\n '0x45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0',\n signer: '0x0000000000000000000000000000000000000000',\n isTrunk: true,\n transactions: []\n};\n\n/**\n * Genesis block for VeChain solo network\n */\nconst soloGenesisBlock = {\n number: 0,\n id: '0x00000000c05a20fbca2bf6ae3affba6af4a74b800b585bf7a4988aba7aea69f6',\n size: 170,\n parentID:\n '0xffffffff00000000000000000000000000000000000000000000000000000000',\n timestamp: 1526400000,\n gasLimit: 10000000,\n beneficiary: '0x0000000000000000000000000000000000000000',\n gasUsed: 0,\n totalScore: 0,\n txsRoot:\n '0x45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0',\n txsFeatures: 0,\n stateRoot:\n '0x93de0ffb1f33bc0af053abc2a87c4af44594f5dcb1cb879dd823686a15d68550',\n receiptsRoot:\n '0x45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0',\n signer: '0x0000000000000000000000000000000000000000',\n isTrunk: true,\n transactions: []\n};\n\n/**\n * Constant defining VeChain mainnet information\n */\nconst MAINNET_NETWORK = {\n genesisBlock: mainnetGenesisBlock,\n chainTag: VECHAIN_MAINNET_CHAIN_TAG\n};\n\n/**\n * Constant defining VeChain testnet information\n */\nconst TESTNET_NETWORK = {\n genesisBlock: testnetGenesisBlock,\n chainTag: VECHAIN_TESTNET_CHAIN_TAG\n};\n\n/**\n * Constant defining VeChain solo network information\n */\nconst SOLO_NETWORK = {\n genesisBlock: soloGenesisBlock,\n chainTag: VECHAIN_SOLO_CHAIN_TAG\n};\n\n/**\n * Constant defining VeChain mainnet and testnet network information\n */\nconst networkInfo = {\n mainnet: MAINNET_NETWORK,\n testnet: TESTNET_NETWORK,\n solo: SOLO_NETWORK\n};\n\nexport {\n networkInfo,\n VTHO_ADDRESS,\n ZERO_ADDRESS,\n MAINNET_NETWORK,\n TESTNET_NETWORK,\n SOLO_NETWORK\n};\n","import { InvalidDataType } from '@vechain/sdk-errors';\nimport { ERC721_ABI, VIP180_ABI } from '../utils';\nimport { VTHO_ADDRESS } from '../utils/const/network';\nimport {\n ABI,\n ABIContract,\n Address,\n FixedPointNumber,\n VET,\n type ABIFunction,\n type HexUInt,\n type Token,\n type VTHO\n} from '../vcdm';\nimport { Hex } from '../vcdm/Hex';\nimport { HexInt } from '../vcdm/HexInt';\nimport type { ClauseOptions } from './ClauseOptions';\nimport type { DeployParams } from './DeployParams';\nimport type { TransactionClause } from './TransactionClause';\n\n/**\n * This class represent a transaction clause.\n *\n * @extends {TransactionClause}\n */\nclass Clause implements TransactionClause {\n /**\n * Used internally in {@link Clause.callFunction}.\n */\n private static readonly FORMAT_TYPE = 'json';\n\n /**\n * Used internally to tag a transaction without data.\n */\n private static readonly NO_DATA = Hex.PREFIX;\n\n /**\n * Used internally in {@link Clause.transferNFT} method.\n */\n private static readonly TRANSFER_NFT_FUNCTION = 'transferFrom';\n\n /**\n * Used internally in {@link Clause.transferVTHOToken} method.\n */\n private static readonly TRANSFER_TOKEN_FUNCTION = 'transfer';\n\n /**\n * Represents the address where:\n * - transfer token to, or\n * - invoke contract method on.\n */\n readonly to: string | null;\n\n /**\n * Return the hexadecimal expression of the amount of VET or VTHO\n * token in {@link Units.wei} to transfer to the destination.\n *\n * @see {Clause.callFunction}\n * @see {Clause.transferVTHOToken}\n * @see {Clause.transferVET}\n */\n readonly value: string;\n\n /**\n * Return the hexadecimal expression of the encoding of the arguments\n * of the called function of a smart contract.\n */\n readonly data: string;\n\n /**\n * An optional comment to describe the purpose of the clause.\n */\n readonly comment?: string;\n\n /**\n * An optional Application Binary Interface (ABI) of the called\n * function of a smart contract.\n */\n readonly abi?: string;\n\n /**\n * Used publicly to tag a transaction not tranferring token amount.\n */\n public static readonly NO_VALUE = Hex.PREFIX + '0';\n\n /**\n * Creates an instance of the class.\n *\n * @param {string|null} to - The address to transfer token\n * or the smart contract to call, can be null.\n * @param {string} value - The token amount being transferred in wei units\n * as hexadecimal expression.\n * @param {string} data - Arguments of the smart contract function called\n * as encoded as a hexadecimal expression\n * @param {string} [comment] - An optional comment.\n * @param {string} [abi] - An optional ABI string.\n */\n protected constructor(\n to: string | null,\n value: string,\n data: string,\n comment?: string,\n abi?: string\n ) {\n this.to = to;\n this.value = value;\n this.data = data;\n this.comment = comment;\n this.abi = abi;\n }\n\n /**\n * Return the amount of {@link VET} or {@link VTHO} token\n * in {@link Units.wei} to transfer to the destination.\n *\n * @return {FixedPointNumber} The amount as a fixed-point number.\n */\n public amount(): FixedPointNumber {\n return FixedPointNumber.of(HexInt.of(this.value).bi);\n }\n\n /**\n * Return a new clause to call a function of a smart contract.\n *\n * @param {Address} contractAddress - The address of the smart contract.\n * @param {ABIFunction} functionAbi - The ABI definition of the function to be called.\n * @param {unknown[]} args - The arguments for the function.\n * @param {VET} [amount=VET.of(FixedPointNumber.ZERO)] - The amount of VET to be sent with the transaction calling the function.\n * @param {ClauseOptions} [clauseOptions] - Optional clause settings.\n * @return {Clause} A clause object to call the function in a transaction.\n * @throws {InvalidDataType} Throws an error if the amount is not a finite positive value.\n */\n public static callFunction(\n contractAddress: Address,\n functionAbi: ABIFunction,\n args: unknown[],\n amount: VET = VET.of(FixedPointNumber.ZERO),\n clauseOptions?: ClauseOptions\n ): Clause {\n if (\n amount.value.isFinite() &&\n amount.value.gte(FixedPointNumber.ZERO)\n ) {\n return new Clause(\n contractAddress.toString().toLowerCase(),\n Hex.PREFIX + amount.wei.toString(Hex.RADIX),\n functionAbi.encodeData(args).toString(),\n clauseOptions?.comment,\n clauseOptions?.includeABI === true\n ? functionAbi.format(Clause.FORMAT_TYPE)\n : undefined\n );\n }\n throw new InvalidDataType(\n 'Clause.callFunction',\n 'not finite positive amount',\n { amount: `${amount.value}` }\n );\n }\n\n /**\n * Returns a new clause to deploy a smart contract.\n *\n * @param {HexUInt} contractBytecode - The bytecode of the contract to be deployed.\n * @param {DeployParams} [deployParams] - Optional parameters to pass to the smart contract constructor.\n * @param {ClauseOptions} [clauseOptions] - Optional clause settings.\n * @return {Clause} The clause to deploy the smart contract as part of a transaction.\n */\n public static deployContract(\n contractBytecode: HexUInt,\n deployParams?: DeployParams,\n clauseOptions?: ClauseOptions\n ): Clause {\n const data =\n deployParams != null && deployParams !== undefined\n ? contractBytecode.digits +\n ABI.of(deployParams.types, deployParams.values)\n .toHex()\n .toString()\n .replace(Hex.PREFIX, '')\n : contractBytecode.digits;\n return new Clause(\n null,\n clauseOptions?.value ?? Clause.NO_VALUE,\n Hex.PREFIX + data,\n clauseOptions?.comment\n );\n }\n\n /**\n * Transfers an NFT from the sender to the recipient.\n *\n * @param {Address} contractAddress - The address of the NFT contract.\n * @param {Address} senderAddress - The address of the current owner (sender) of the NFT.\n * @param {Address} recipientAddress - The address of the new owner (recipient) of the NFT.\n * @param {HexUInt} tokenId - The unique identifier of the NFT to be transferred.\n * @param {ClauseOptions} [clauseOptions] - Optional clause settings.\n * @return {Clause} The clause object representing the transfer operation as part of a transaction.\n */\n public static transferNFT(\n contractAddress: Address,\n senderAddress: Address,\n recipientAddress: Address,\n tokenId: HexUInt,\n clauseOptions?: ClauseOptions\n ): Clause {\n return Clause.callFunction(\n contractAddress,\n ABIContract.ofAbi(ERC721_ABI).getFunction(\n Clause.TRANSFER_NFT_FUNCTION\n ),\n [\n senderAddress.toString(),\n recipientAddress.toString(),\n tokenId.bi.toString()\n ],\n undefined,\n clauseOptions\n );\n }\n\n /**\n * Return a new clause to transfers the specified amount of VTHO\n *\n * @param {Address} tokenAddress - The address of the VIP180 token.\n * @param {Address} recipientAddress - The address of the recipient.\n * @param {VTHO} amount - The amount of token to be transferred.\n * @param {ClauseOptions} [clauseOptions] - Optional clause settings.\n * @return {Clause} The clause to transfer VIP180 tokens as part of a transaction.\n * @throws {InvalidDataType} Throws an error if the amount is not a positive integer.\n *\n * @see VTHO.transferTokenTo\n */\n public static transferVTHOToken(\n recipientAddress: Address,\n amount: VTHO\n ): Clause {\n if (amount.value.isFinite() && amount.value.isPositive()) {\n const vthoAddress = Address.of(VTHO_ADDRESS);\n return this.callFunction(\n vthoAddress,\n ABIContract.ofAbi(VIP180_ABI).getFunction(\n Clause.TRANSFER_TOKEN_FUNCTION\n ),\n [recipientAddress.toString(), amount.wei],\n undefined,\n { comment: 'Transfer VTHO' }\n );\n }\n throw new InvalidDataType(\n 'Clause.transferVTHOToken',\n 'not positive integer amount',\n { amount: `${amount.value}` }\n );\n }\n\n /**\n * Return a new clause to transfer a generic VIP180/ERC20 Token\n *\n * @param {Address} recipientAddress - The address of the recipient.\n * @param {Token} amount - The amount of token to be transferred.\n * @return {Clause} The clause to transfer tokens as part of a transaction.\n * @throws {InvalidDataType} Throws an error if the amount is not a positive integer.\n */\n public static transferToken(\n recipientAddress: Address,\n token: Token\n ): Clause {\n if (token.value >= 0) {\n return this.callFunction(\n token.tokenAddress,\n ABIContract.ofAbi(VIP180_ABI).getFunction(\n Clause.TRANSFER_TOKEN_FUNCTION\n ),\n [recipientAddress.toString(), token.value],\n undefined,\n { comment: `Transfer ${token.name}` }\n );\n }\n throw new InvalidDataType(\n 'Clause.transferToken',\n 'not positive integer amount',\n { amount: `${token.value}` }\n );\n }\n\n /**\n * Return a new clause to transfers VET to a specified recipient address.\n *\n * @param {Address} recipientAddress - The address of the recipient.\n * @param {VET} amount - The amount of VET to transfer.\n * @param {ClauseOptions} [clauseOptions] - Optional clause settings.\n * @return {Clause} - The clause object to transfer VET as part of a transaction.\n * @throws {InvalidDataType} - If the amount is not a finite positive value.\n *\n * @see VET.transferTo\n */\n public static transferVET(\n recipientAddress: Address,\n amount: VET,\n clauseOptions?: ClauseOptions\n ): Clause {\n if (amount.value.isFinite() && amount.value.isPositive()) {\n return new Clause(\n recipientAddress.toString().toLowerCase(),\n Hex.PREFIX + amount.wei.toString(Hex.RADIX),\n Clause.NO_DATA,\n clauseOptions?.comment\n );\n }\n throw new InvalidDataType(\n 'Clause.transferVET',\n 'not finite positive amount',\n { amount: `${amount.value}` }\n );\n }\n}\n\nexport { Clause };\n","import { InvalidTransactionType } from '@vechain/sdk-errors';\n\n/**\n * Represents the type of a transaction\n */\nexport enum TransactionType {\n Legacy = 'legacy',\n EIP1559 = 'eip1559'\n}\n\n/**\n * Constants for transaction type values\n */\nconst TRANSACTION_TYPE_VALUES = {\n [TransactionType.Legacy]: 0,\n [TransactionType.EIP1559]: 81 // 0x51\n} as const;\n\n/**\n * Valid transaction type values\n */\nconst VALID_TRANSACTION_TYPES: number[] = Object.values(\n TRANSACTION_TYPE_VALUES\n);\n\n/**\n * Converts a transaction type number to TransactionType string.\n * Type 0 represents legacy transactions, type 81 (0x51) represents EIP-1559 transactions\n *\n * @param type - The transaction type number (0 or 81)\n * @returns The transaction type as 'legacy' or 'eip1559'\n * @throws {Error} If the input type is not a valid transaction type\n * @example\n * ```typescript\n * const type = toTransactionType(81); // returns TransactionType.EIP1559\n * const type = toTransactionType(0); // returns TransactionType.Legacy\n * ```\n */\nexport function toTransactionType(type: number): TransactionType {\n if (!VALID_TRANSACTION_TYPES.includes(type)) {\n throw new InvalidTransactionType(\n 'TransactionType.toTransactionType()',\n 'Invalid transaction type',\n {\n transactionType: type.toString(),\n validTypes: VALID_TRANSACTION_TYPES.map((t) =>\n t.toString()\n ).join(', ')\n }\n );\n }\n return type === TRANSACTION_TYPE_VALUES[TransactionType.Legacy]\n ? TransactionType.Legacy\n : TransactionType.EIP1559;\n}\n\n/**\n * Converts a TransactionType string to its corresponding number representation.\n * 'legacy' transactions are type 0, 'eip1559' transactions are type 81 (0x51).\n *\n * @param type - The transaction type as TransactionType\n * @returns The transaction type number (0 for legacy, 81 for eip1559)\n * @example\n * ```typescript\n * const type = fromTransactionType(TransactionType.EIP1559); // returns 81\n * const type = fromTransactionType(TransactionType.Legacy); // returns 0\n * ```\n */\nexport function fromTransactionType(type: TransactionType): number {\n return TRANSACTION_TYPE_VALUES[type];\n}\n","import * as nc_utils from '@noble/curves/abstract/utils';\nimport {\n InvalidDataType,\n InvalidSecp256k1PrivateKey,\n InvalidTransactionField,\n NotDelegatedTransaction,\n UnavailableTransactionField\n} from '@vechain/sdk-errors';\nimport { Secp256k1 } from '../secp256k1';\nimport {\n Address,\n BufferKind,\n CompactFixedHexBlobKind,\n Hex,\n HexBlobKind,\n HexUInt,\n NumericKind,\n OptionalFixedHexBlobKind,\n type RLPProfile,\n RLPProfiler,\n type RLPValidObject,\n Units,\n VTHO\n} from '../vcdm';\nimport { Blake2b256 } from '../vcdm/hash/Blake2b256';\nimport type { TransactionClause } from './TransactionClause';\nimport { TransactionType } from './TransactionType';\nimport { type TransactionBody } from './TransactionBody';\n\n/**\n * Represents an immutable transaction entity.\n */\nclass Transaction {\n /**\n * Represent the block reference length in bytes.\n */\n private static readonly BLOCK_REF_LENGTH = 8;\n\n /**\n * A collection of constants used for gas calculations in transactions.\n *\n * Properties\n * - `TX_GAS` - The base gas cost for a transaction.\n * - `CLAUSE_GAS` - The gas cost for executing a clause in a transaction.\n * - `CLAUSE_GAS_CONTRACT_CREATION` - The gas cost for creating a contract via a clause.\n * - `ZERO_GAS_DATA` - The gas cost for transmitting zero bytes of data.\n * - `NON_ZERO_GAS_DATA` - The gas cost for transmitting non-zero bytes of data.\n */\n public static readonly GAS_CONSTANTS = {\n TX_GAS: 5000n,\n CLAUSE_GAS: 16000n,\n CLAUSE_GAS_CONTRACT_CREATION: 48000n,\n ZERO_GAS_DATA: 4n,\n NON_ZERO_GAS_DATA: 68n\n };\n\n /**\n * Represents the prefix for raw EIP-1559 transaction type.\n */\n private static readonly EIP1559_TX_TYPE_PREFIX = 0x51;\n\n /**\n * RLP_FIELDS is an array of objects that defines the structure and encoding scheme\n * for various components in a transaction using Recursive Length Prefix (RLP) encoding.\n * Each object in the array represents a field in the transaction, specifying its name and kind.\n * The `kind` attribute is an instance of an RLP coder that determines how the field is encoded.\n *\n * Properties\n * - `chainTag` - Represent the id of the chain the transaction is sent to.\n * - `blockRef` - Represent the last block of the chain the transaction is sent to.\n * - `expiration` - Represent the expiration date of the transaction.\n * - `clauses` - List of clause objects, each containing:\n * - `to` - Represent the destination of the transaction.\n * - `value` - Represent the 'wei' quantity (VET or VTHO) value the transaction is worth.\n * - `data` - Represent the content of the transaction.\n * - `gasPriceCoef` - Represent the gas price coefficient of the transaction.\n * - `gas` - Represent the gas limit of the transaction.\n * - `dependsOn` - Represent the hash of the transaction the current transaction depends on.\n * - `nonce` - Represent the nonce of the transaction.\n * - `reserved` - Reserved field.\n */\n private static readonly LEGACY_RLP_FIELDS = [\n { name: 'chainTag', kind: new NumericKind(1) },\n { name: 'blockRef', kind: new CompactFixedHexBlobKind(8) },\n { name: 'expiration', kind: new NumericKind(4) },\n {\n name: 'clauses',\n kind: {\n item: [\n {\n name: 'to',\n kind: new OptionalFixedHexBlobKind(20)\n },\n { name: 'value', kind: new NumericKind(32) },\n { name: 'data', kind: new HexBlobKind() }\n ]\n }\n },\n { name: 'gasPriceCoef', kind: new NumericKind(1) },\n { name: 'gas', kind: new NumericKind(8) },\n { name: 'dependsOn', kind: new OptionalFixedHexBlobKind(32) },\n { name: 'nonce', kind: new NumericKind(8) },\n { name: 'reserved', kind: { item: new BufferKind() } }\n ];\n\n /**\n * Represents the RLP fields for EIP-1559 transactions.\n */\n private static readonly EIP1559_RLP_FIELDS = [\n { name: 'chainTag', kind: new NumericKind(1) },\n { name: 'blockRef', kind: new CompactFixedHexBlobKind(8) },\n { name: 'expiration', kind: new NumericKind(4) },\n {\n name: 'clauses',\n kind: {\n item: [\n {\n name: 'to',\n kind: new OptionalFixedHexBlobKind(20)\n },\n { name: 'value', kind: new NumericKind(32) },\n { name: 'data', kind: new HexBlobKind() }\n ]\n }\n },\n { name: 'maxPriorityFeePerGas', kind: new NumericKind(32) },\n { name: 'maxFeePerGas', kind: new NumericKind(32) },\n { name: 'gas', kind: new NumericKind(8) },\n { name: 'dependsOn', kind: new OptionalFixedHexBlobKind(32) },\n { name: 'nonce', kind: new NumericKind(8) },\n { name: 'reserved', kind: { item: new BufferKind() } }\n ];\n\n /**\n * Represent the Recursive Length Prefix (RLP) of the transaction features.\n *\n * Properties\n * - `name` - A string indicating the name of the field in the RLP structure.\n * - `kind` - RLP profile type.\n */\n private static readonly RLP_FEATURES = {\n name: 'reserved.features',\n kind: new NumericKind(4)\n };\n\n /**\n * Represents a Recursive Length Prefix (RLP) of the transaction signature.\n *\n * Properties\n * - `name` - A string indicating the name of the field in the RLP structure.\n * - `kind` - RLP profile type.\n */\n private static readonly RLP_SIGNATURE = {\n name: 'signature',\n kind: new BufferKind()\n };\n\n /**\n * Represents a Recursive Length Prefix (RLP) of the signed transaction.\n *\n * Properties\n * - `name` - A string indicating the name of the field in the RLP structure.\n * - `kind` - RLP profile type.\n */\n private static readonly RLP_SIGNED_LEGACY_TRANSACTION_PROFILE: RLPProfile =\n {\n name: 'tx',\n kind: Transaction.LEGACY_RLP_FIELDS.concat([\n Transaction.RLP_SIGNATURE\n ])\n };\n\n /**\n * Represents a Recursive Length Prefix (RLP) of the unsigned transaction.\n *\n * Properties\n * - `name` - A string indicating the name of the field in the RLP structure.\n * - `kind` - RLP profile type.\n */\n private static readonly RLP_UNSIGNED_LEGACY_TRANSACTION_PROFILE: RLPProfile =\n {\n name: 'tx',\n kind: Transaction.LEGACY_RLP_FIELDS\n };\n\n /**\n * Represents a Recursive Length Prefix (RLP) of the signed EIP-1559 transaction.\n *\n * Properties\n * - `name` - A string indicating the name of the field in the RLP structure.\n * - `kind` - RLP profile type.\n */\n private static readonly RLP_SIGNED_EIP1559_TRANSACTION_PROFILE: RLPProfile =\n {\n name: 'tx',\n kind: Transaction.EIP1559_RLP_FIELDS.concat([\n Transaction.RLP_SIGNATURE\n ])\n };\n\n /**\n * Represents a Recursive Length Prefix (RLP) of the unsigned EIP-1559 transaction.\n *\n * Properties\n * - `name` - A string indicating the name of the field in the RLP structure.\n * - `kind` - RLP profile type.\n */\n private static readonly RLP_UNSIGNED_EIP1559_TRANSACTION_PROFILE: RLPProfile =\n {\n name: 'tx',\n kind: Transaction.EIP1559_RLP_FIELDS\n };\n\n /**\n * It represents the content of the transaction.\n */\n public readonly body: TransactionBody;\n\n /**\n * It represents the type of the transaction.\n */\n public readonly transactionType: TransactionType;\n\n /**\n * It represents the signature of the transaction content.\n */\n public readonly signature?: Uint8Array;\n\n /**\n * Creates a new instance of the class with the specified transaction body and optional signature.\n *\n * @param {TransactionBody} body The transaction body to be used.\n * @param {Uint8Array} [signature] The optional signature for the transaction.\n */\n protected constructor(\n body: TransactionBody,\n type: TransactionType,\n signature?: Uint8Array\n ) {\n this.body = body;\n this.transactionType = type;\n this.signature = signature;\n }\n\n // ********** GET COMPUTED PROPERTIES **********\n\n /**\n * Get the gas payer's address if the transaction is delegated.\n *\n * If the transaction is delegated and a signature is available, this method recovers\n * the gas payer parameter from the signature and subsequently recovers the gas payer's public key\n * to derive the gas payer's address.\n *\n * @return {Address} The address of the gas payer.\n * @throws {UnavailableTransactionField} If the transaction is delegated but the signature is missing.\n * @throws {NotDelegatedTransaction} If the transaction is not delegated.\n *\n * @remarks Security auditable method, depends on\n * - {@link Address.ofPublicKey};\n * - {@link Secp256k1.recover};\n * - {@link Transaction.getTransactionHash}.\n */\n public get gasPayer(): Address {\n if (this.isDelegated) {\n if (this.signature !== undefined) {\n // Recover the gas payer param from the signature\n const gasPayer = this.signature.slice(\n Secp256k1.SIGNATURE_LENGTH,\n this.signature.length\n );\n // Recover the gas payer's public key.\n const gasPayerPublicKey = Secp256k1.recover(\n this.getTransactionHash(this.origin).bytes,\n gasPayer\n );\n return Address.ofPublicKey(gasPayerPublicKey);\n }\n throw new UnavailableTransactionField(\n 'Transaction.gasPayer()',\n 'missing gas payer signature',\n { fieldName: 'gasPayer' }\n );\n }\n throw new NotDelegatedTransaction(\n 'Transaction.gasPayer()',\n 'not delegated transaction',\n undefined\n );\n }\n\n /**\n * Get the encoded bytes as a Uint8Array.\n * The encoding is determined by whether the data is signed.\n *\n * @return {Uint8Array} The encoded byte array.\n *\n * @see decode\n */\n public get encoded(): Uint8Array {\n return this.encode(this.isSigned);\n }\n\n /**\n * Get transaction ID.\n *\n * The ID is the Blake2b256 hash of the transaction's signature\n * concatenated with the origin's address.\n * If the transaction is not signed,\n * it throws an UnavailableTransactionField error.\n *\n * @return {Blake2b256} The concatenated hash of the signature\n * and origin if the transaction is signed.\n * @throws {UnavailableTransactionField} If the transaction is not signed.\n *\n * @remarks Security auditable method, depends on\n * - {@link Blake2b256.of}\n */\n public get id(): Blake2b256 {\n if (this.isSigned) {\n return Blake2b256.of(\n nc_utils.concatBytes(\n this.getTransactionHash().bytes,\n this.origin.bytes\n )\n );\n }\n throw new UnavailableTransactionField(\n 'Transaction.id()',\n 'not signed transaction: id unavailable',\n { fieldName: 'id' }\n );\n }\n\n /**\n * Return the intrinsic gas required for this transaction.\n *\n * @return {VTHO} The computed intrinsic gas for the transaction.\n */\n public get intrinsicGas(): VTHO {\n return Transaction.intrinsicGas(this.body.clauses);\n }\n\n /**\n * Returns `true` if the transaction is delegated, otherwise `false`.\n *\n * @return {boolean} `true` if the transaction is delegated,\n * otherwise `false`.\n */\n public get isDelegated(): boolean {\n return Transaction.isDelegated(this.body);\n }\n\n /**\n * Return `true` if the signature is defined and complete, otherwise `false`.\n *\n * @return {boolean} return `true` if the signature is defined and complete, otherwise `false`.\n *\n * @remarks Any delegated transaction signed with {@link signAsSender}\n * but not yet signed with {@link signAsGasPayer} is not signed.\n */\n public get isSigned(): boolean {\n if (this.signature !== undefined) {\n return Transaction.isSignatureLengthValid(\n this.body,\n this.signature\n );\n }\n return false;\n }\n\n /**\n * Return the origin (also known as sender) address of the transaction.\n *\n * The origin is determined by recovering the public key from the transaction's sender.\n *\n * @return {Address} The address derived from the public key of the transaction's sender.\n * @throws {UnavailableTransactionField} If the transaction is not signed, an exception is thrown indicating the absence of the origin field.\n *\n * @remarks Security auditable method, depends on\n * - {@link Address.ofPublicKey};\n * - {@link Secp256k1.recover}.\n */\n public get origin(): Address {\n if (this.signature !== undefined) {\n return Address.ofPublicKey(\n // Get the origin public key.\n Secp256k1.recover(\n this.getTransactionHash().bytes,\n // Get the (r, s) of ECDSA digital signature without gas payer params.\n this.signature.slice(0, Secp256k1.SIGNATURE_LENGTH)\n )\n );\n }\n throw new UnavailableTransactionField(\n 'Transaction.origin()',\n 'not signed transaction, no origin',\n { fieldName: 'origin' }\n );\n }\n\n // ********** PUBLIC METHODS **********\n\n /**\n * Decodes a raw transaction byte array into a new Transaction object.\n *\n * @param {Uint8Array} rawTransaction - The raw transaction bytes to decode.\n * @param {boolean} isSigned - Flag indicating if the transaction is signed.\n * @return {Transaction} The decoded transaction object.\n *\n * @see encoded\n */\n public static decode(\n rawTransaction: Uint8Array,\n isSigned: boolean\n ): Transaction {\n // check prefix to get tx type\n const rawPrefix = rawTransaction[0];\n let txType: TransactionType = TransactionType.Legacy;\n if (Number(rawPrefix) === Transaction.EIP1559_TX_TYPE_PREFIX) {\n txType = TransactionType.EIP1559;\n }\n\n // Get correct decoder profiler\n const profile = isSigned\n ? txType === TransactionType.Legacy\n ? Transaction.RLP_SIGNED_LEGACY_TRANSACTION_PROFILE\n : Transaction.RLP_SIGNED_EIP1559_TRANSACTION_PROFILE\n : txType === TransactionType.Legacy\n ? Transaction.RLP_UNSIGNED_LEGACY_TRANSACTION_PROFILE\n : Transaction.RLP_UNSIGNED_EIP1559_TRANSACTION_PROFILE;\n\n // if eip1559, remove prefix\n if (txType === TransactionType.EIP1559) {\n rawTransaction = rawTransaction.slice(1);\n }\n\n // Get decoded body\n const decodedRLPBody = RLPProfiler.ofObjectEncoded(\n rawTransaction,\n profile\n ).object as RLPValidObject;\n // Create correct transaction body without reserved field\n const bodyWithoutReservedField: TransactionBody = {\n blockRef: decodedRLPBody.blockRef as string,\n chainTag: decodedRLPBody.chainTag as number,\n clauses: decodedRLPBody.clauses as [],\n dependsOn: decodedRLPBody.dependsOn as string | null,\n expiration: decodedRLPBody.expiration as number,\n gas: decodedRLPBody.gas as number,\n nonce: decodedRLPBody.nonce as number,\n // Handle both legacy and EIP-1559 gas pricing\n ...(decodedRLPBody.gasPriceCoef !== undefined\n ? { gasPriceCoef: decodedRLPBody.gasPriceCoef as number }\n : {\n maxFeePerGas: decodedRLPBody.maxFeePerGas as string,\n maxPriorityFeePerGas:\n decodedRLPBody.maxPriorityFeePerGas as string\n })\n };\n // Create correct transaction body (with correct reserved field)\n const correctTransactionBody: TransactionBody =\n (decodedRLPBody.reserved as Uint8Array[]).length > 0\n ? {\n ...bodyWithoutReservedField,\n reserved: Transaction.decodeReservedField(\n decodedRLPBody.reserved as Uint8Array[]\n )\n }\n : bodyWithoutReservedField;\n // Return decoded transaction (with signature or not)\n return decodedRLPBody.signature !== undefined\n ? Transaction.of(\n correctTransactionBody,\n decodedRLPBody.signature as Uint8Array\n )\n : Transaction.of(correctTransactionBody);\n }\n\n /**\n * Computes the transaction hash, optionally incorporating a gas payer's address.\n *\n * @param {Address} [sender] - Optional transaction origin's address to include in the hash computation.\n * @return {Blake2b256} - The computed transaction hash.\n *\n * @remarks\n * `sender` is used to sign a transaction on behalf of another account.\n *\n * @remarks Security auditable method, depends on\n * - {@link Blake2b256.of}.\n */\n public getTransactionHash(sender?: Address): Blake2b256 {\n const txHash = Blake2b256.of(this.encode(false));\n if (sender !== undefined) {\n return Blake2b256.of(\n nc_utils.concatBytes(txHash.bytes, sender.bytes)\n );\n }\n return txHash;\n }\n\n /**\n * Calculates the intrinsic gas required for the given transaction clauses.\n *\n * @param {TransactionClause[]} clauses - An array of transaction clauses to calculate the intrinsic gas for.\n * @return {VTHO} The total intrinsic gas required for the provided clauses.\n * @throws {InvalidDataType} If clauses have invalid data as invalid addresses.\n */\n public static intrinsicGas(clauses: TransactionClause[]): VTHO {\n if (clauses.length > 0) {\n // Some clauses.\n return VTHO.of(\n clauses.reduce((sum: bigint, clause: TransactionClause) => {\n if (clause.to !== null) {\n // Invalid address or no vet.domains name\n if (\n !Address.isValid(clause.to) &&\n !clause.to.includes('.')\n )\n throw new InvalidDataType(\n 'Transaction.intrinsicGas',\n 'invalid data type in clause: each `to` field must be a valid address.',\n { clause }\n );\n\n sum += Transaction.GAS_CONSTANTS.CLAUSE_GAS;\n } else {\n sum +=\n Transaction.GAS_CONSTANTS\n .CLAUSE_GAS_CONTRACT_CREATION;\n }\n sum += Transaction.computeUsedGasFor(clause.data);\n return sum;\n }, Transaction.GAS_CONSTANTS.TX_GAS),\n Units.wei\n );\n }\n // No clauses.\n return VTHO.of(\n Transaction.GAS_CONSTANTS.TX_GAS +\n Transaction.GAS_CONSTANTS.CLAUSE_GAS,\n Units.wei\n );\n }\n\n /**\n * Validates the transaction body's fields according to the transaction type.\n *\n * @param {TransactionBody} body - The transaction body to validate.\n * @param {TransactionType} type - The transaction type to validate the body against.\n * @return {boolean} True if the transaction body is valid for the given type.\n */\n public static isValidBody(\n body: TransactionBody,\n type: TransactionType\n ): boolean {\n // Legacy transactions shouldn't have any EIP-1559 parameters\n if (\n type === TransactionType.Legacy &&\n (body.maxFeePerGas !== undefined ||\n body.maxPriorityFeePerGas !== undefined)\n ) {\n return false;\n }\n\n // EIP-1559 transactions shouldn't have legacy parameters\n if (\n type === TransactionType.EIP1559 &&\n body.gasPriceCoef !== undefined\n ) {\n return false;\n }\n\n // validate common fields\n const isValidCommonFields =\n // Chain tag\n body.chainTag !== undefined &&\n body.chainTag >= 0 &&\n body.chainTag <= 255 &&\n // Block reference\n body.blockRef !== undefined &&\n Hex.isValid0x(body.blockRef) &&\n HexUInt.of(body.blockRef).bytes.length ===\n Transaction.BLOCK_REF_LENGTH &&\n // Expiration\n body.expiration !== undefined &&\n // Clauses\n body.clauses !== undefined &&\n // Gas\n body.gas !== undefined &&\n // Depends on\n body.dependsOn !== undefined &&\n // Nonce\n body.nonce !== undefined;\n\n // validate eip1559 fields\n const isValidEip1559Fields =\n type === TransactionType.EIP1559 &&\n body.maxFeePerGas !== undefined &&\n body.maxPriorityFeePerGas !== undefined &&\n ((typeof body.maxFeePerGas === 'string' &&\n Hex.isValid0x(body.maxFeePerGas)) ||\n typeof body.maxFeePerGas === 'number') &&\n ((typeof body.maxPriorityFeePerGas === 'string' &&\n Hex.isValid0x(body.maxPriorityFeePerGas)) ||\n typeof body.maxPriorityFeePerGas === 'number');\n\n // validate legacy fields\n const isValidLegacyFields =\n type === TransactionType.Legacy && body.gasPriceCoef !== undefined;\n\n // return true if the transaction body is valid\n if (type === TransactionType.EIP1559) {\n return isValidCommonFields && isValidEip1559Fields;\n }\n return isValidCommonFields && isValidLegacyFields;\n }\n\n /**\n * Returns the type of the transaction.\n *\n * @param {TransactionBody} body - The transaction body to get the type of.\n * @return {TransactionType} The type of the transaction.\n */\n private static getTransactionType(body: TransactionBody): TransactionType {\n if (body.gasPriceCoef !== undefined) {\n return TransactionType.Legacy;\n }\n if (\n body.maxFeePerGas !== undefined &&\n body.maxPriorityFeePerGas !== undefined\n ) {\n return TransactionType.EIP1559;\n }\n throw new InvalidTransactionField(\n 'Transaction.getTransactionType',\n 'invalid transaction body',\n {\n fieldName: 'body',\n body\n }\n );\n }\n\n /**\n * Creates a new Transaction instance if the provided body is valid.\n *\n * @param {TransactionBody} body - The transaction body to be validated.\n * @param {Uint8Array} [signature] - Optional signature.\n * @return {Transaction} A new Transaction instance if validation is successful.\n * @throws {InvalidTransactionField} If the provided body is invalid.\n */\n public static of(\n body: TransactionBody,\n signature?: Uint8Array\n ): Transaction {\n const txType = Transaction.getTransactionType(body);\n if (Transaction.isValidBody(body, txType)) {\n return new Transaction(body, txType, signature);\n }\n throw new InvalidTransactionField('Transaction.of', 'invalid body', {\n fieldName: 'body',\n body\n });\n }\n\n /**\n * Signs the transaction using the provided private key of the transaction sender.\n *\n * @param {Uint8Array} senderPrivateKey - The private key used to sign the transaction.\n * @return {Transaction} The signed transaction.\n * @throws {InvalidTransactionField} If attempting to sign a delegated transaction.\n * @throws {InvalidSecp256k1PrivateKey} If the provided private key is not valid.\n *\n * @remarks Security auditable method, depends on\n * - {@link Secp256k1.isValidPrivateKey};\n * - {@link Secp256k1.sign}.\n */\n public sign(senderPrivateKey: Uint8Array): Transaction {\n // Check if the private key is valid.\n if (Secp256k1.isValidPrivateKey(senderPrivateKey)) {\n if (!this.isDelegated) {\n // Sign transaction\n const signature = Secp256k1.sign(\n this.getTransactionHash().bytes,\n senderPrivateKey\n );\n // Return new signed transaction.\n return Transaction.of(this.body, signature);\n }\n throw new InvalidTransactionField(\n `Transaction.sign`,\n 'delegated transaction: use signAsSenderAndGasPayer method',\n { fieldName: 'gasPayer', body: this.body }\n );\n }\n throw new InvalidSecp256k1PrivateKey(\n `Transaction.sign`,\n 'invalid private key: ensure it is a secp256k1 key',\n undefined\n );\n }\n\n /**\n * Signs a transaction as a gas payer using the provided private key. This is applicable only if the transaction\n * has been marked as delegated and already contains the signature of the transaction sender\n * that needs to be extended with the gas payer's signature.\n *\n * @param {Address} sender - The address of the sender for whom the transaction hash is generated.\n * @param {Uint8Array} gasPayerPrivateKey - The private key of the gas payer. Must be a valid secp256k1 key.\n *\n * @return {Transaction} - A new transaction object with the gas payer's signature appended.\n *\n * @throws {InvalidSecp256k1PrivateKey} If the provided gas payer private key is not valid.\n * @throws {InvalidTransactionField} If the transaction is unsigned or lacks a valid signature.\n * @throws {NotDelegatedTransaction} If the transaction is not set as delegated.\n *\n * @remarks Security auditable method, depends on\n * - {@link Secp256k1.isValidPrivateKey};\n * - {@link Secp256k1.sign}.\n */\n public signAsGasPayer(\n sender: Address,\n gasPayerPrivateKey: Uint8Array\n ): Transaction {\n if (Secp256k1.isValidPrivateKey(gasPayerPrivateKey)) {\n if (this.isDelegated) {\n const senderHash = this.getTransactionHash(sender).bytes;\n if (this.signature !== undefined) {\n return new Transaction(\n this.body,\n this.transactionType,\n nc_utils.concatBytes(\n // Drop any previous gas payer signature.\n this.signature.slice(0, Secp256k1.SIGNATURE_LENGTH),\n Secp256k1.sign(senderHash, gasPayerPrivateKey)\n )\n );\n } else {\n return new Transaction(\n this.body,\n this.transactionType,\n Secp256k1.sign(senderHash, gasPayerPrivateKey)\n );\n }\n }\n throw new NotDelegatedTransaction(\n 'Transaction.signAsGasPayer',\n 'not delegated transaction: use sign method',\n undefined\n );\n }\n throw new InvalidSecp256k1PrivateKey(\n `Transaction.signAsGasPayer`,\n 'invalid gas payer private key: ensure it is a secp256k1 key',\n undefined\n );\n }\n\n /**\n * Signs a delegated transaction using the provided transaction sender's private key,\n * call the {@link signAsGasPayer} to complete the signature,\n * before such call {@link isDelegated} returns `true` but\n * {@link isSigned} returns `false`.\n *\n * @param senderPrivateKey The private key of the transaction sender, represented as a Uint8Array. It must be a valid secp256k1 private key.\n * @return A new Transaction object with the signature applied, if the transaction is delegated and the private key is valid.\n * @throws NotDelegatedTransaction if the current transaction is not marked as delegated, instructing to use the regular sign method instead.\n * @throws InvalidSecp256k1PrivateKey if the provided senderPrivateKey is not a valid secp256k1 private key.\n *\n * @remarks Security auditable method, depends on\n * - {@link Secp256k1.isValidPrivateKey};\n * - {@link Secp256k1.sign}.\n */\n public signAsSender(senderPrivateKey: Uint8Array): Transaction {\n if (Secp256k1.isValidPrivateKey(senderPrivateKey)) {\n if (this.isDelegated) {\n const transactionHash = this.getTransactionHash().bytes;\n return new Transaction(\n this.body,\n this.transactionType,\n Secp256k1.sign(transactionHash, senderPrivateKey)\n );\n }\n throw new NotDelegatedTransaction(\n 'Transaction.signAsSender',\n 'not delegated transaction: use sign method',\n undefined\n );\n }\n throw new InvalidSecp256k1PrivateKey(\n `Transaction.signAsSender`,\n 'invalid sender private key: ensure it is a secp256k1 key',\n undefined\n );\n }\n\n /**\n * Signs the transaction using both the transaction sender and the gas payer private keys.\n *\n * @param {Uint8Array} senderPrivateKey - The private key of the transaction sender.\n * @param {Uint8Array} gasPayerPrivateKey - The private key of the gas payer.\n * @return {Transaction} A new transaction with the concatenated signatures\n * of the transaction sender and the gas payer.\n * @throws {InvalidSecp256k1PrivateKey} - If either the private key of the transaction sender or gas payer is invalid.\n * @throws {NotDelegatedTransaction} - If the transaction is not delegated.\n *\n * @remarks Security auditable method, depends on\n * - {@link Address.ofPublicKey}\n * - {@link Secp256k1.isValidPrivateKey};\n * - {@link Secp256k1.sign}.\n */\n public signAsSenderAndGasPayer(\n senderPrivateKey: Uint8Array,\n gasPayerPrivateKey: Uint8Array\n ): Transaction {\n // Check if the private key of the sender is valid.\n if (Secp256k1.isValidPrivateKey(senderPrivateKey)) {\n // Check if the private key of the gas payer is valid.\n if (Secp256k1.isValidPrivateKey(gasPayerPrivateKey)) {\n if (this.isDelegated) {\n const senderHash = this.getTransactionHash().bytes;\n const gasPayerHash = this.getTransactionHash(\n Address.ofPublicKey(\n Secp256k1.derivePublicKey(senderPrivateKey)\n )\n ).bytes;\n // Return new signed transaction\n return Transaction.of(\n this.body,\n nc_utils.concatBytes(\n Secp256k1.sign(senderHash, senderPrivateKey),\n Secp256k1.sign(gasPayerHash, gasPayerPrivateKey)\n )\n );\n }\n throw new NotDelegatedTransaction(\n 'Transaction.signAsSenderAndGasPayer',\n 'not delegated transaction: use sign method',\n undefined\n );\n }\n throw new InvalidSecp256k1PrivateKey(\n `Transaction.signAsSenderAndGasPayer`,\n 'invalid gas payer private key: ensure it is a secp256k1 key',\n undefined\n );\n }\n throw new InvalidSecp256k1PrivateKey(\n `Transaction.signAsSenderAndGasPayer`,\n 'invalid sender private key: ensure it is a secp256k1 key',\n undefined\n );\n }\n\n // ********** PRIVATE FUNCTIONS **********\n\n /**\n * Computes the amount of gas used for the given data.\n *\n * @param {string} data - The hexadecimal string data for which the gas usage is computed.\n * @return {bigint} The total gas used for the provided data.\n * @throws {InvalidDataType} If the data is not a valid hexadecimal string.\n *\n * @remarks gas value is expressed in {@link Units.wei} unit.\n */\n private static computeUsedGasFor(data: string): bigint {\n // Invalid data\n if (data !== '' && !Hex.isValid(data))\n throw new InvalidDataType(\n 'calculateDataUsedGas()',\n `Invalid data type for gas calculation. Data should be a hexadecimal string.`,\n { data }\n );\n\n let sum = 0n;\n for (let i = 2; i < data.length; i += 2) {\n if (data.substring(i, i + 2) === '00') {\n sum += Transaction.GAS_CONSTANTS.ZERO_GAS_DATA;\n } else {\n sum += Transaction.GAS_CONSTANTS.NON_ZERO_GAS_DATA;\n }\n }\n return sum;\n }\n\n /**\n * Decodes the {@link TransactionBody.reserved} field from the given buffer array.\n *\n * @param {Buffer[]} reserved - An array of Uint8Array objects representing the reserved field data.\n * @return {Object} An object containing the decoded features and any unused buffer data.\n * @return {number} [return.features] The decoded features from the reserved field.\n * @return {Buffer[]} [return.unused] An array of Buffer objects representing unused data, if any.\n * @throws {InvalidTransactionField} Thrown if the reserved field is not properly trimmed.\n */\n private static decodeReservedField(reserved: Uint8Array[]): {\n features?: number;\n unused?: Uint8Array[];\n } {\n // Not trimmed reserved field\n if (reserved[reserved.length - 1].length > 0) {\n // Get features field.\n const featuresField = Transaction.RLP_FEATURES.kind\n .buffer(reserved[0], Transaction.RLP_FEATURES.name)\n .decode() as number;\n // Return encoded reserved field\n return reserved.length > 1\n ? {\n features: featuresField,\n unused: reserved.slice(1)\n }\n : { features: featuresField };\n }\n throw new InvalidTransactionField(\n 'Transaction.decodeReservedField',\n 'invalid reserved field: fields in the `reserved` property must be properly trimmed',\n { fieldName: 'reserved', reserved }\n );\n }\n\n /**\n * Encodes the transaction body using RLP encoding.\n *\n * @param {boolean} isSigned - Indicates whether the transaction is signed.\n * @return {Uint8Array} The RLP encoded transaction body.\n *\n * @see encoded\n */\n private encode(isSigned: boolean): Uint8Array {\n // Encode transaction body with RLP\n const encodedBody = this.encodeBodyField(\n {\n // Existing body and the optional `reserved` field if present.\n ...this.body,\n /*\n * The `body.clauses` property is already an array,\n * albeit TypeScript realize, hence cast is needed\n * otherwise encodeObject will throw an error.\n */\n clauses: this.body.clauses as Array<{\n to: string | null;\n value: string | number;\n data: string;\n }>,\n // New reserved field.\n reserved: this.encodeReservedField()\n },\n isSigned\n );\n // add prefix if eip1559\n if (this.transactionType === TransactionType.EIP1559) {\n return nc_utils.concatBytes(\n Uint8Array.from([Transaction.EIP1559_TX_TYPE_PREFIX]),\n encodedBody\n );\n }\n return encodedBody;\n }\n\n /**\n * Encodes the given transaction body into a Uint8Array, depending on whether\n * the transaction is signed or not.\n *\n * @param body - The transaction object adhering to the RLPValidObject structure.\n * @param isSigned - A boolean indicating if the transaction is signed.\n * @return A Uint8Array representing the encoded transaction.\n *\n * @see encoded\n */\n private encodeBodyField(\n body: RLPValidObject,\n isSigned: boolean\n ): Uint8Array {\n // Encode transaction object - SIGNED\n if (isSigned) {\n return RLPProfiler.ofObject(\n {\n ...body,\n signature: Uint8Array.from(this.signature as Uint8Array)\n },\n this.transactionType === TransactionType.EIP1559\n ? Transaction.RLP_SIGNED_EIP1559_TRANSACTION_PROFILE\n : Transaction.RLP_SIGNED_LEGACY_TRANSACTION_PROFILE\n ).encoded;\n }\n // Encode transaction object - UNSIGNED\n return RLPProfiler.ofObject(\n body,\n this.transactionType === TransactionType.EIP1559\n ? Transaction.RLP_UNSIGNED_EIP1559_TRANSACTION_PROFILE\n : Transaction.RLP_UNSIGNED_LEGACY_TRANSACTION_PROFILE\n ).encoded;\n }\n\n /**\n * Encodes the {@link TransactionBody.reserved} field data for a transaction.\n *\n * @return {Uint8Array[]} The encoded list of reserved features.\n * It removes any trailing unused features that have zero length from the list.\n *\n * @remarks The {@link TransactionBody.reserved} is optional, albeit\n * is required to perform RLP encoding.\n *\n * @see encode\n */\n private encodeReservedField(): Uint8Array[] {\n // Check if is reserved or not\n const reserved = this.body.reserved ?? {};\n // Init kind for features\n const featuresKind = Transaction.RLP_FEATURES.kind;\n // Features list\n const featuresList = [\n featuresKind\n .data(reserved.features ?? 0, Transaction.RLP_FEATURES.name)\n .encode(),\n ...(reserved.unused ?? [])\n ];\n // Trim features list\n while (featuresList.length > 0) {\n if (featuresList[featuresList.length - 1].length === 0) {\n featuresList.pop();\n } else {\n break;\n }\n }\n return featuresList;\n }\n\n /**\n * Return `true` if the transaction is delegated, else `false`.\n *\n * @param {TransactionBody} body - The transaction body.\n * @return {boolean} `true` if the transaction is delegated, else `false`.\n */\n private static isDelegated(body: TransactionBody): boolean {\n // Check if is reserved or not\n const reserved = body.reserved ?? {};\n // Features\n const features = reserved.features ?? 0;\n // Fashion bitwise way to check if a number is even or not\n return (features & 1) === 1;\n }\n\n /**\n * Validates the length of a given signature against the expected length.\n *\n * @param {TransactionBody} body - The body of the transaction being validated.\n * @param {Uint8Array} signature - The signature to verify the length of.\n * @return {boolean} Returns true if the signature length matches the expected length, otherwise false.\n */\n private static isSignatureLengthValid(\n body: TransactionBody,\n signature: Uint8Array\n ): boolean {\n // Verify signature length\n const expectedSignatureLength = this.isDelegated(body)\n ? Secp256k1.SIGNATURE_LENGTH * 2\n : Secp256k1.SIGNATURE_LENGTH;\n\n return signature.length === expectedSignatureLength;\n }\n}\n\nexport { Transaction };\n"]}Выполнить команду
Для локальной разработки. Не используйте в интернете!