@twin.org/dlt-iota 0.0.3-next.11 → 0.0.3-next.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/es/iota.js CHANGED
@@ -724,7 +724,7 @@ export class Iota {
724
724
  * @internal
725
725
  */
726
726
  static async buildKeyPairRange(vaultConnector, config, identity, accountIndex, internal, addressIndex) {
727
- const keyPairChunkKey = Iota.buildKeyPairChunkKey(identity, accountIndex, internal, addressIndex);
727
+ const keyPairChunkKey = Iota.buildAccountChunkKey(identity, accountIndex, internal, addressIndex);
728
728
  let keyPairChunk;
729
729
  try {
730
730
  keyPairChunk =
@@ -756,8 +756,8 @@ export class Iota {
756
756
  * @returns The keypair chunk key.
757
757
  * @internal
758
758
  */
759
- static buildKeyPairChunkKey(identity, accountIndex, internal, addressIndex) {
760
- return `${identity}/keypair/${accountIndex}/${internal ? "internal" : "external"}/${addressIndex % Iota._PRE_CALC_CHUNK_SIZE}`;
759
+ static buildAccountChunkKey(identity, accountIndex, internal, addressIndex) {
760
+ return `${identity}/account/${accountIndex}/${internal ? "1" : "0"}/${addressIndex % Iota._PRE_CALC_CHUNK_SIZE}`;
761
761
  }
762
762
  }
763
763
  //# sourceMappingURL=iota.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"iota.js","sourceRoot":"","sources":["../../src/iota.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EACN,SAAS,EACT,MAAM,EACN,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,YAAY,EAEZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KA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AC,IAAI,CAAC;oBACjB,UAAU,EAAE,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC;oBACvD,SAAS,EAAE,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC;iBACrD,CAAC,CAAC;YACJ,CAAC;YAED,MAAM,cAAc,CAAC,SAAS,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;QAC/D,CAAC;QAED,OAAO,YAAY,CAAC;IACrB,CAAC;IAED;;;;;;;;OAQG;IACK,MAAM,CAAC,oBAAoB,CAClC,QAAgB,EAChB,YAAoB,EACpB,QAAiB,EACjB,YAAoB;QAEpB,OAAO,GAAG,QAAQ,YAAY,YAAY,IAAI,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,IAAI,YAAY,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAChI,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { IotaClient } from \"@iota/iota-sdk/client\";\nimport { requestIotaFromFaucetV0 } from \"@iota/iota-sdk/faucet\";\nimport { Ed25519Keypair } from \"@iota/iota-sdk/keypairs/ed25519\";\nimport { Transaction } from \"@iota/iota-sdk/transactions\";\nimport {\n\tBaseError,\n\tCoerce,\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tStringHelper,\n\ttype IError\n} from \"@twin.org/core\";\nimport { Bip39, Bip44, Blake2b, KeyType } from \"@twin.org/crypto\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IVaultConnector } from \"@twin.org/vault-models\";\nimport { FetchHelper, HttpMethod } from \"@twin.org/web\";\nimport type { IGasReservationResult } from \"./models/IGasReservationResult.js\";\nimport type { IGasStationConfig } from \"./models/IGasStationConfig.js\";\nimport type { IGasStationExecuteResponse } from \"./models/IGasStationExecuteResponse.js\";\nimport type { IGasStationReserveGasResponse } from \"./models/IGasStationReserveGasResponse.js\";\nimport type { IIotaClient } from \"./models/IIotaClient.js\";\nimport type { IIotaConfig } from \"./models/IIotaConfig.js\";\nimport type { IIotaDryRun } from \"./models/IIotaDryRun.js\";\nimport type { IIotaResponseOptions } from \"./models/IIotaResponseOptions.js\";\nimport type { IIotaTransaction } from \"./models/IIotaTransaction.js\";\nimport type { IIotaTransactionBlockResponse } from \"./models/IIotaTransactionBlockResponse.js\";\n\n/**\n * Class for performing operations on IOTA.\n */\nexport class Iota {\n\t/**\n\t * Default name for the mnemonic secret.\n\t */\n\tpublic static readonly DEFAULT_MNEMONIC_SECRET_NAME: string = \"mnemonic\";\n\n\t/**\n\t * Default name for the seed secret.\n\t */\n\tpublic static readonly DEFAULT_SEED_SECRET_NAME: string = \"seed\";\n\n\t/**\n\t * Default coin type.\n\t */\n\tpublic static readonly DEFAULT_COIN_TYPE: number = 4218;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Iota>();\n\n\t/**\n\t * Default scan range.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_SCAN_RANGE: number = 1000;\n\n\t/**\n\t * Default pre-calculation chunk size.\n\t * @internal\n\t */\n\tprivate static readonly _PRE_CALC_CHUNK_SIZE: number = 25;\n\n\t/**\n\t * Default inclusion timeout.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_INCLUSION_TIMEOUT: number = 60;\n\n\t/**\n\t * Default gas budget for all transactions (including sponsored and direct).\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_GAS_BUDGET: number = 50000000;\n\n\t/**\n\t * Default gas reservation duration.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_GAS_RESERVATION_DURATION: number = 60;\n\n\t/**\n\t * Create a new IOTA client.\n\t * @param config The configuration.\n\t * @returns The client instance.\n\t */\n\tpublic static createClient(config: IIotaConfig): IIotaClient {\n\t\tGuards.object(Iota.CLASS_NAME, nameof(config), config);\n\t\tGuards.object(Iota.CLASS_NAME, nameof(config.clientOptions), config.clientOptions);\n\t\tGuards.string(Iota.CLASS_NAME, nameof(config.clientOptions.url), config.clientOptions.url);\n\n\t\treturn new IotaClient(config.clientOptions);\n\t}\n\n\t/**\n\t * Create configuration using defaults where necessary.\n\t * @param config The configuration to populate.\n\t */\n\tpublic static populateConfig(config: IIotaConfig): void {\n\t\tGuards.object<IIotaConfig[\"clientOptions\"]>(\n\t\t\tIota.CLASS_NAME,\n\t\t\tnameof(config.clientOptions),\n\t\t\tconfig.clientOptions\n\t\t);\n\n\t\tconfig.vaultMnemonicId ??= Iota.DEFAULT_MNEMONIC_SECRET_NAME;\n\t\tconfig.vaultSeedId ??= Iota.DEFAULT_SEED_SECRET_NAME;\n\t\tconfig.coinType ??= Iota.DEFAULT_COIN_TYPE;\n\t\tconfig.inclusionTimeoutSeconds ??= Iota._DEFAULT_INCLUSION_TIMEOUT;\n\t}\n\n\t/**\n\t * Store a mnemonic in the vault, derive and store the seed, and pre-cache the first keypair chunk.\n\t * @param vaultConnector The vault connector.\n\t * @param config The configuration.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param mnemonic The mnemonic to store, if undefined a new one will be generated and returned.\n\t * @param accountIndex The account index to pre-cache.\n\t * @returns The mnemonic that was stored.\n\t */\n\tpublic static async storeMnemonic(\n\t\tvaultConnector: IVaultConnector,\n\t\tconfig: IIotaConfig,\n\t\tidentity: string,\n\t\tmnemonic: string | undefined,\n\t\taccountIndex: number\n\t): Promise<string> {\n\t\tGuards.object(Iota.CLASS_NAME, nameof(vaultConnector), vaultConnector);\n\t\tGuards.object<IIotaConfig>(Iota.CLASS_NAME, nameof(config), config);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.integer(Iota.CLASS_NAME, nameof(accountIndex), accountIndex);\n\n\t\tconst mnemonicToStore = mnemonic ?? Bip39.randomMnemonic();\n\n\t\tawait vaultConnector.setSecret(\n\t\t\tIota.buildMnemonicKey(identity, config.vaultMnemonicId),\n\t\t\tmnemonicToStore\n\t\t);\n\n\t\tconst seed = Bip39.mnemonicToSeed(mnemonicToStore);\n\t\tawait vaultConnector.setSecret(\n\t\t\tIota.buildSeedKey(identity, config.vaultSeedId),\n\t\t\tConverter.bytesToBase64(seed)\n\t\t);\n\n\t\tawait Iota.buildKeyPairRange(vaultConnector, config, identity, accountIndex, false, 0);\n\n\t\treturn mnemonicToStore;\n\t}\n\n\t/**\n\t * Derive an address from a public key.\n\t * @param publicKey The public key to derive the address from.\n\t * @returns The derived address.\n\t */\n\tpublic static publicKeyToAddress(publicKey: Uint8Array): string {\n\t\treturn Converter.bytesToHex(Blake2b.sum256(publicKey), true);\n\t}\n\n\t/**\n\t * Get address for the identity.\n\t * @param vaultConnector The vault connector.\n\t * @param config The configuration.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param accountIndex The account index to get the addresses for.\n\t * @param startAddressIndex The start index for the addresses.\n\t * @param isInternal Whether the addresses are internal.\n\t * @returns The address.\n\t */\n\tpublic static async getAddress(\n\t\tvaultConnector: IVaultConnector,\n\t\tconfig: Pick<IIotaConfig, \"coinType\" | \"vaultMnemonicId\" | \"vaultSeedId\">,\n\t\tidentity: string,\n\t\taccountIndex: number,\n\t\tstartAddressIndex: number,\n\t\tisInternal?: boolean\n\t): Promise<string> {\n\t\tconst addresses = await Iota.getAddresses(\n\t\t\tvaultConnector,\n\t\t\tconfig,\n\t\t\tidentity,\n\t\t\taccountIndex,\n\t\t\tstartAddressIndex,\n\t\t\t1,\n\t\t\tisInternal\n\t\t);\n\t\treturn addresses[0];\n\t}\n\n\t/**\n\t * Get addresses for the identity.\n\t * @param vaultConnector The vault connector.\n\t * @param config The configuration.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param accountIndex The account index to get the addresses for.\n\t * @param startAddressIndex The start index for the addresses.\n\t * @param count The number of addresses to generate.\n\t * @param isInternal Whether the addresses are internal.\n\t * @returns The list of addresses.\n\t */\n\tpublic static async getAddresses(\n\t\tvaultConnector: IVaultConnector,\n\t\tconfig: Pick<IIotaConfig, \"coinType\" | \"vaultMnemonicId\" | \"vaultSeedId\">,\n\t\tidentity: string,\n\t\taccountIndex: number,\n\t\tstartAddressIndex: number,\n\t\tcount: number,\n\t\tisInternal?: boolean\n\t): Promise<string[]> {\n\t\tGuards.object(Iota.CLASS_NAME, nameof(vaultConnector), vaultConnector);\n\t\tGuards.object<IIotaConfig>(Iota.CLASS_NAME, nameof(config), config);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.integer(Iota.CLASS_NAME, nameof(accountIndex), accountIndex);\n\t\tGuards.integer(Iota.CLASS_NAME, nameof(startAddressIndex), startAddressIndex);\n\t\tGuards.integer(Iota.CLASS_NAME, nameof(count), count);\n\n\t\tconst addresses: string[] = [];\n\t\tconst internal = isInternal ?? false;\n\t\tlet currentIndex = startAddressIndex;\n\n\t\twhile (addresses.length < count) {\n\t\t\tconst chunkStart =\n\t\t\t\tMath.floor(currentIndex / Iota._PRE_CALC_CHUNK_SIZE) * Iota._PRE_CALC_CHUNK_SIZE;\n\t\t\tconst keyPairs = await Iota.buildKeyPairRange(\n\t\t\t\tvaultConnector,\n\t\t\t\tconfig,\n\t\t\t\tidentity,\n\t\t\t\taccountIndex,\n\t\t\t\tinternal,\n\t\t\t\tchunkStart\n\t\t\t);\n\t\t\tconst chunk = keyPairs.map(kp =>\n\t\t\t\tIota.publicKeyToAddress(Converter.base64ToBytes(kp.publicKey))\n\t\t\t);\n\t\t\tconst offsetInChunk = currentIndex - chunkStart;\n\t\t\tconst remaining = count - addresses.length;\n\t\t\taddresses.push(...chunk.slice(offsetInChunk, offsetInChunk + remaining));\n\t\t\tcurrentIndex = chunkStart + Iota._PRE_CALC_CHUNK_SIZE;\n\t\t}\n\n\t\treturn addresses;\n\t}\n\n\t/**\n\t * Get a key pair for the specified index.\n\t * @param vaultConnector The vault connector.\n\t * @param config The configuration.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param accountIndex The account index to get the key pair for.\n\t * @param addressIndex The address index to get the key pair for.\n\t * @param isInternal Whether the address is internal.\n\t * @returns The key pair containing private key and public key.\n\t */\n\tpublic static async getKeyPair(\n\t\tvaultConnector: IVaultConnector,\n\t\tconfig: IIotaConfig,\n\t\tidentity: string,\n\t\taccountIndex: number,\n\t\taddressIndex: number,\n\t\tisInternal?: boolean\n\t): Promise<{\n\t\tprivateKey: Uint8Array;\n\t\tpublicKey: Uint8Array;\n\t}> {\n\t\tGuards.object(Iota.CLASS_NAME, nameof(vaultConnector), vaultConnector);\n\t\tGuards.object<IIotaConfig>(Iota.CLASS_NAME, nameof(config), config);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.integer(Iota.CLASS_NAME, nameof(accountIndex), accountIndex);\n\t\tGuards.integer(Iota.CLASS_NAME, nameof(addressIndex), addressIndex);\n\n\t\tconst internal = isInternal ?? false;\n\t\tconst chunkStart =\n\t\t\tMath.floor(addressIndex / Iota._PRE_CALC_CHUNK_SIZE) * Iota._PRE_CALC_CHUNK_SIZE;\n\t\tconst keyPairs = await Iota.buildKeyPairRange(\n\t\t\tvaultConnector,\n\t\t\tconfig,\n\t\t\tidentity,\n\t\t\taccountIndex,\n\t\t\tinternal,\n\t\t\tchunkStart\n\t\t);\n\t\tconst offsetInChunk = addressIndex - chunkStart;\n\t\tconst entry = keyPairs[offsetInChunk];\n\n\t\treturn {\n\t\t\tprivateKey: Converter.base64ToBytes(entry.privateKey),\n\t\t\tpublicKey: Converter.base64ToBytes(entry.publicKey)\n\t\t};\n\t}\n\n\t/**\n\t * Create a new transaction instance.\n\t * @returns A new transaction instance.\n\t */\n\tpublic static createTransaction(): IIotaTransaction {\n\t\treturn new Transaction();\n\t}\n\n\t/**\n\t * Prepare and post a transaction.\n\t * @param config The configuration.\n\t * @param vaultConnector The vault connector.\n\t * @param logging The logging component.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param client The client instance.\n\t * @param source The source address.\n\t * @param amount The amount to transfer.\n\t * @param recipient The recipient address.\n\t * @param options The transaction options.\n\t * @returns The transaction result.\n\t */\n\tpublic static async prepareAndPostValueTransaction(\n\t\tconfig: IIotaConfig,\n\t\tvaultConnector: IVaultConnector,\n\t\tlogging: ILoggingComponent | undefined,\n\t\tidentity: string,\n\t\tclient: IIotaClient,\n\t\tsource: string,\n\t\tamount: bigint,\n\t\trecipient: string,\n\t\toptions?: IIotaResponseOptions\n\t): Promise<IIotaTransactionBlockResponse> {\n\t\ttry {\n\t\t\tconst txb = new Transaction();\n\t\t\tconst [coin] = txb.splitCoins(txb.gas, [txb.pure.u64(amount)]);\n\t\t\ttxb.transferObjects([coin], txb.pure.address(recipient));\n\n\t\t\t// Check if gas station configuration is present\n\t\t\tif (Is.object<IGasStationConfig>(config.gasStation)) {\n\t\t\t\treturn await Iota.prepareAndPostGasStationTransaction(\n\t\t\t\t\tconfig,\n\t\t\t\t\tvaultConnector,\n\t\t\t\t\tidentity,\n\t\t\t\t\tclient,\n\t\t\t\t\tsource,\n\t\t\t\t\ttxb\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst result = await Iota.prepareAndPostTransaction(\n\t\t\t\tconfig,\n\t\t\t\tvaultConnector,\n\t\t\t\tlogging,\n\t\t\t\tidentity,\n\t\t\t\tclient,\n\t\t\t\tsource,\n\t\t\t\ttxb,\n\t\t\t\toptions\n\t\t\t);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIota.CLASS_NAME,\n\t\t\t\t\"valueTransactionFailed\",\n\t\t\t\tundefined,\n\t\t\t\tIota.extractPayloadError(error)\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Prepare and post a transaction.\n\t * @param config The configuration.\n\t * @param vaultConnector The vault connector.\n\t * @param logging The logging component.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param client The client instance.\n\t * @param owner The owner of the address.\n\t * @param transaction The transaction to execute.\n\t * @param options The transaction options.\n\t * @returns The transaction response.\n\t */\n\tpublic static async prepareAndPostTransaction(\n\t\tconfig: IIotaConfig,\n\t\tvaultConnector: IVaultConnector,\n\t\tlogging: ILoggingComponent | undefined,\n\t\tidentity: string,\n\t\tclient: IIotaClient,\n\t\towner: string,\n\t\ttransaction: IIotaTransaction,\n\t\toptions?: IIotaResponseOptions\n\t): Promise<IIotaTransactionBlockResponse> {\n\t\t// Check if gas station configuration is present\n\t\tif (Is.object<IGasStationConfig>(config.gasStation)) {\n\t\t\treturn Iota.prepareAndPostGasStationTransaction(\n\t\t\t\tconfig,\n\t\t\t\tvaultConnector,\n\t\t\t\tidentity,\n\t\t\t\tclient,\n\t\t\t\towner,\n\t\t\t\ttransaction,\n\t\t\t\toptions\n\t\t\t);\n\t\t}\n\n\t\t// Traditional transaction flow\n\t\t// Dry run the transaction if cost logging is enabled to get the gas and storage costs\n\t\tif (Is.stringValue(options?.dryRunLabel)) {\n\t\t\tawait Iota.dryRunTransaction(client, logging, transaction, owner, options.dryRunLabel);\n\t\t}\n\n\t\tconst addressKeyPair = await Iota.findAddress(vaultConnector, config, identity, owner, 0);\n\t\tconst keypair = Ed25519Keypair.fromSecretKey(addressKeyPair.privateKey);\n\n\t\ttry {\n\t\t\tconst response = await client.signAndExecuteTransaction({\n\t\t\t\ttransaction,\n\t\t\t\tsigner: keypair,\n\t\t\t\trequestType: \"WaitForLocalExecution\",\n\t\t\t\toptions: {\n\t\t\t\t\tshowEffects: options?.showEffects ?? true,\n\t\t\t\t\tshowEvents: options?.showEvents ?? true,\n\t\t\t\t\tshowObjectChanges: options?.showObjectChanges ?? true\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (options?.waitForConfirmation ?? true) {\n\t\t\t\t// Wait for transaction to be indexed and available over API\n\t\t\t\tconst confirmedTransaction = await Iota.waitForTransactionConfirmation(\n\t\t\t\t\tclient,\n\t\t\t\t\tresponse.digest,\n\t\t\t\t\tconfig,\n\t\t\t\t\t{\n\t\t\t\t\t\tshowEffects: options?.showEffects ?? true,\n\t\t\t\t\t\tshowEvents: options?.showEvents ?? true,\n\t\t\t\t\t\tshowObjectChanges: options?.showObjectChanges ?? true\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\treturn confirmedTransaction;\n\t\t\t}\n\n\t\t\treturn response;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIota.CLASS_NAME,\n\t\t\t\t\"transactionFailed\",\n\t\t\t\tundefined,\n\t\t\t\tIota.extractPayloadError(error)\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Find the address in the seed.\n\t * @param vaultConnector The vault connector to use.\n\t * @param config The configuration to use.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param address The address to find.\n\t * @param accountIndex The account index to search.\n\t * @param isInternal Whether to search internal addresses.\n\t * @param startScanIndex The address index to start scanning from.\n\t * @param maxScanRange The maximum range to scan.\n\t * @returns The address key pair.\n\t * @throws Error if the address is not found.\n\t */\n\tpublic static async findAddress(\n\t\tvaultConnector: IVaultConnector,\n\t\tconfig: IIotaConfig,\n\t\tidentity: string,\n\t\taddress: string,\n\t\taccountIndex: number,\n\t\tisInternal?: boolean,\n\t\tstartScanIndex?: number,\n\t\tmaxScanRange?: number\n\t): Promise<{\n\t\taddress: string;\n\t\tprivateKey: Uint8Array;\n\t\tpublicKey: Uint8Array;\n\t}> {\n\t\tconst internal = isInternal ?? false;\n\t\tconst startIndex = startScanIndex ?? 0;\n\t\tconst scanRange = maxScanRange ?? config.maxAddressScanRange ?? Iota._DEFAULT_SCAN_RANGE;\n\n\t\tfor (\n\t\t\tlet chunkStart = startIndex;\n\t\t\tchunkStart < startIndex + scanRange;\n\t\t\tchunkStart += Iota._PRE_CALC_CHUNK_SIZE\n\t\t) {\n\t\t\tconst keyPairs = await Iota.buildKeyPairRange(\n\t\t\t\tvaultConnector,\n\t\t\t\tconfig,\n\t\t\t\tidentity,\n\t\t\t\taccountIndex,\n\t\t\t\tinternal,\n\t\t\t\tchunkStart\n\t\t\t);\n\t\t\tconst offsetInChunk = keyPairs.findIndex(\n\t\t\t\tkp => Iota.publicKeyToAddress(Converter.base64ToBytes(kp.publicKey)) === address\n\t\t\t);\n\t\t\tif (offsetInChunk !== -1) {\n\t\t\t\tconst entry = keyPairs[offsetInChunk];\n\t\t\t\treturn {\n\t\t\t\t\taddress,\n\t\t\t\t\tprivateKey: Converter.base64ToBytes(entry.privateKey),\n\t\t\t\t\tpublicKey: Converter.base64ToBytes(entry.publicKey)\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tthrow new GeneralError(Iota.CLASS_NAME, \"addressNotFound\", { address });\n\t}\n\n\t/**\n\t * Extract error from SDK payload.\n\t * Errors from the IOTA SDK are usually not JSON strings but objects.\n\t * @param error The error to extract.\n\t * @returns The extracted error.\n\t */\n\tpublic static extractPayloadError(error: unknown): IError {\n\t\tif (Is.object<{ code?: string; message?: string; inner?: unknown; cause?: unknown }>(error)) {\n\t\t\tif (!Is.empty(error.inner)) {\n\t\t\t\terror.inner = Iota.extractPayloadError(error.inner);\n\t\t\t}\n\t\t\tif (!Is.empty(error.cause)) {\n\t\t\t\terror.cause = Iota.extractPayloadError(error.cause);\n\t\t\t}\n\n\t\t\tif (error.code === \"InsufficientGas\") {\n\t\t\t\treturn new GeneralError(Iota.CLASS_NAME, \"insufficientFunds\");\n\t\t\t} else if (error.message?.startsWith(\"ErrorObject\")) {\n\t\t\t\tconst msg = /message: \"(.*)\"/.exec(error.message);\n\t\t\t\tif (msg && msg.length > 1) {\n\t\t\t\t\terror = msg[1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst baseError = BaseError.fromError(error);\n\t\tif (baseError.name === \"Base\" && !Is.stringValue(baseError.source)) {\n\t\t\tbaseError.name = \"IOTA\";\n\t\t\tbaseError.source = Iota.CLASS_NAME;\n\t\t}\n\t\treturn baseError;\n\t}\n\n\t/**\n\t * Check if the package exists on the network.\n\t * @param client The client to use.\n\t * @param packageId The package ID to check.\n\t * @returns True if the package exists, false otherwise.\n\t */\n\tpublic static async packageExistsOnNetwork(\n\t\tclient: IIotaClient,\n\t\tpackageId: string\n\t): Promise<boolean> {\n\t\ttry {\n\t\t\tconst packageObject = await client.getObject({\n\t\t\t\tid: packageId,\n\t\t\t\toptions: {\n\t\t\t\t\tshowType: true\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (\"error\" in packageObject) {\n\t\t\t\tif (packageObject?.error?.code === \"notExists\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tthrow new GeneralError(Iota.CLASS_NAME, \"packageObjectError\", {\n\t\t\t\t\tpackageId,\n\t\t\t\t\terror: packageObject.error\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIota.CLASS_NAME,\n\t\t\t\t\"packageNotFoundOnNetwork\",\n\t\t\t\t{\n\t\t\t\t\tpackageId\n\t\t\t\t},\n\t\t\t\tIota.extractPayloadError(error)\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Dry run a transaction and log the results.\n\t * @param client The IOTA client.\n\t * @param logging The logging component.\n\t * @param txb The transaction to dry run.\n\t * @param sender The sender address.\n\t * @param operation The operation to log.\n\t * @returns void.\n\t */\n\tpublic static async dryRunTransaction(\n\t\tclient: IIotaClient,\n\t\tlogging: ILoggingComponent | undefined,\n\t\ttxb: IIotaTransaction,\n\t\tsender: string,\n\t\toperation: string\n\t): Promise<IIotaDryRun> {\n\t\ttry {\n\t\t\ttxb.setSender(sender);\n\n\t\t\tconst builtTx = await txb.build({\n\t\t\t\tclient,\n\t\t\t\tonlyTransactionKind: false\n\t\t\t});\n\n\t\t\tconst dryRunResult = await client.dryRunTransactionBlock({\n\t\t\t\ttransactionBlock: builtTx\n\t\t\t});\n\n\t\t\tif (dryRunResult.effects.status?.status !== \"success\") {\n\t\t\t\tthrow new GeneralError(Iota.CLASS_NAME, \"dryRunFailed\", {\n\t\t\t\t\terror: dryRunResult.effects?.status?.error\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst result = {\n\t\t\t\tstatus: dryRunResult.effects.status.status,\n\t\t\t\tcosts: {\n\t\t\t\t\tcomputationCost: dryRunResult.effects.gasUsed.computationCost,\n\t\t\t\t\tcomputationCostBurned: dryRunResult.effects.gasUsed.computationCostBurned,\n\t\t\t\t\tstorageCost: dryRunResult.effects.gasUsed.storageCost,\n\t\t\t\t\tstorageRebate: dryRunResult.effects.gasUsed.storageRebate,\n\t\t\t\t\tnonRefundableStorageFee: dryRunResult.effects.gasUsed.nonRefundableStorageFee\n\t\t\t\t},\n\t\t\t\tevents: dryRunResult.events ?? [],\n\t\t\t\tbalanceChanges: dryRunResult.balanceChanges ?? [],\n\t\t\t\tobjectChanges: dryRunResult.objectChanges ?? []\n\t\t\t};\n\n\t\t\tawait logging?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: Iota.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"transactionCosts\",\n\t\t\t\tdata: {\n\t\t\t\t\toperation,\n\t\t\t\t\tcost: JSON.stringify(result)\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tif (BaseError.isErrorName(error, GeneralError.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIota.CLASS_NAME,\n\t\t\t\t\"dryRunFailed\",\n\t\t\t\tundefined,\n\t\t\t\tIota.extractPayloadError(error)\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Wait for a transaction to be indexed and available over the API.\n\t * @param client The IOTA client instance.\n\t * @param digest The digest of the transaction to wait for.\n\t * @param config The IOTA configuration.\n\t * @param options Additional options for the transaction query.\n\t * @param options.showEffects Whether to show effects.\n\t * @param options.showEvents Whether to show events.\n\t * @param options.showObjectChanges Whether to show object changes.\n\t * @returns The confirmed transaction response.\n\t */\n\tpublic static async waitForTransactionConfirmation(\n\t\tclient: IIotaClient,\n\t\tdigest: string,\n\t\tconfig: IIotaConfig,\n\t\toptions?: {\n\t\t\tshowEffects?: boolean;\n\t\t\tshowEvents?: boolean;\n\t\t\tshowObjectChanges?: boolean;\n\t\t}\n\t): Promise<IIotaTransactionBlockResponse> {\n\t\tconst timeoutMs = (config.inclusionTimeoutSeconds ?? Iota._DEFAULT_INCLUSION_TIMEOUT) * 1000;\n\n\t\treturn client.waitForTransaction({\n\t\t\tdigest,\n\t\t\ttimeout: timeoutMs,\n\t\t\toptions: {\n\t\t\t\tshowEffects: options?.showEffects ?? true,\n\t\t\t\tshowEvents: options?.showEvents ?? true,\n\t\t\t\tshowObjectChanges: options?.showObjectChanges ?? true\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Check if the error is an abort error with a specific code.\n\t * @param error The error to check.\n\t * @param code The error code to check for.\n\t * @returns True if the error is an abort error, false otherwise.\n\t */\n\tpublic static isAbortError(error: unknown, code: number): boolean {\n\t\tconst err = BaseError.fromError(error);\n\t\tif (Is.stringValue(err.properties?.error)) {\n\t\t\tconst abortCodeMatch = /abort code\\s*:\\s*(\\d+)/i.exec(err.properties.error);\n\t\t\treturn abortCodeMatch?.[1] === code.toString();\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Extracts the abort code from a transaction result if the transaction was aborted.\n\t * @param response The transaction result to extract the abort code from.\n\t * @returns The abort code if the transaction was aborted, or undefined if it was not an abort error or the code could not be extracted.\n\t */\n\tpublic static extractAbortCode(response: IIotaTransactionBlockResponse): number | undefined {\n\t\tif (\n\t\t\tresponse.effects?.status?.status === \"failure\" &&\n\t\t\tIs.stringValue(response.effects.status.error)\n\t\t) {\n\t\t\tconst match = /abort code: (\\d+)/.exec(response.effects.status.error);\n\t\t\tif (match) {\n\t\t\t\treturn Coerce.integer(match[1]);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Prepare and post a transaction using gas station sponsoring.\n\t * @param config The configuration.\n\t * @param vaultConnector The vault connector.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param client The client instance.\n\t * @param owner The owner of the address.\n\t * @param transaction The transaction to execute.\n\t * @param options Response options including confirmation behavior.\n\t * @returns The transaction response.\n\t */\n\tpublic static async prepareAndPostGasStationTransaction(\n\t\tconfig: IIotaConfig,\n\t\tvaultConnector: IVaultConnector,\n\t\tidentity: string,\n\t\tclient: IIotaClient,\n\t\towner: string,\n\t\ttransaction: IIotaTransaction,\n\t\toptions?: IIotaResponseOptions\n\t): Promise<IIotaTransactionBlockResponse> {\n\t\tGuards.object(Iota.CLASS_NAME, nameof(config.gasStation), config.gasStation);\n\n\t\ttry {\n\t\t\t// Reserve gas from the gas station\n\t\t\tconst gasReservation = await Iota.reserveGas(config);\n\n\t\t\t// Set transaction parameters for sponsoring\n\t\t\ttransaction.setSender(owner);\n\t\t\ttransaction.setGasOwner(gasReservation.sponsorAddress);\n\t\t\ttransaction.setGasPayment(gasReservation.gasCoins);\n\t\t\ttransaction.setGasBudget(config.gasBudget ?? Iota._DEFAULT_GAS_BUDGET);\n\n\t\t\t// Build and sign transaction\n\t\t\tconst unsignedTxBytes = await transaction.build({ client });\n\n\t\t\t// Sign the transaction with the user's private key\n\t\t\tconst addressKeyPair = await Iota.findAddress(vaultConnector, config, identity, owner, 0);\n\t\t\tconst keypair = Ed25519Keypair.fromSecretKey(addressKeyPair.privateKey);\n\t\t\tconst signature = await keypair.signTransaction(unsignedTxBytes);\n\n\t\t\treturn await Iota.executeAndConfirmGasStationTransaction(\n\t\t\t\tconfig,\n\t\t\t\tclient,\n\t\t\t\tgasReservation.reservationId,\n\t\t\t\tunsignedTxBytes,\n\t\t\t\tsignature.signature,\n\t\t\t\toptions\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIota.CLASS_NAME,\n\t\t\t\t\"gasStationTransactionFailed\",\n\t\t\t\tundefined,\n\t\t\t\tIota.extractPayloadError(error)\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Reserve gas from the gas station.\n\t * @param config The configuration containing gas station settings.\n\t * @returns The gas reservation result.\n\t */\n\tpublic static async reserveGas(config: IIotaConfig): Promise<IGasReservationResult> {\n\t\tGuards.object(Iota.CLASS_NAME, nameof(config.gasStation), config.gasStation);\n\n\t\tconst requestData = {\n\t\t\t// eslint-disable-next-line camelcase\n\t\t\tgas_budget: config.gasBudget ?? Iota._DEFAULT_GAS_BUDGET,\n\t\t\t// eslint-disable-next-line camelcase\n\t\t\treserve_duration_secs: config.gasReservationDuration ?? Iota._DEFAULT_GAS_RESERVATION_DURATION\n\t\t};\n\n\t\tconst baseUrl = StringHelper.trimTrailingSlashes(config.gasStation.gasStationUrl);\n\t\tconst result = await FetchHelper.fetchJson<typeof requestData, IGasStationReserveGasResponse>(\n\t\t\tIota.CLASS_NAME,\n\t\t\t`${baseUrl}/v1/reserve_gas`,\n\t\t\tHttpMethod.POST,\n\t\t\trequestData,\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\tAuthorization: `Bearer ${config.gasStation.gasStationAuthToken}`\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tconst apiResponse = result.result;\n\n\t\treturn {\n\t\t\tsponsorAddress: apiResponse.sponsor_address,\n\t\t\treservationId: apiResponse.reservation_id,\n\t\t\tgasCoins: apiResponse.gas_coins\n\t\t};\n\t}\n\n\t/**\n\t * Execute a sponsored transaction through the gas station.\n\t * @param config The configuration containing gas station settings.\n\t * @param reservationId The reservation ID from gas reservation.\n\t * @param transactionBytes The unsigned transaction bytes.\n\t * @param userSignature The user's signature.\n\t * @returns The transaction response.\n\t */\n\tpublic static async executeGasStationTransaction(\n\t\tconfig: IIotaConfig,\n\t\treservationId: number,\n\t\ttransactionBytes: Uint8Array,\n\t\tuserSignature: string\n\t): Promise<IIotaTransactionBlockResponse> {\n\t\tGuards.object<IGasStationConfig>(Iota.CLASS_NAME, nameof(config.gasStation), config.gasStation);\n\n\t\tconst requestData = {\n\t\t\t// eslint-disable-next-line camelcase\n\t\t\treservation_id: reservationId,\n\t\t\t// eslint-disable-next-line camelcase\n\t\t\ttx_bytes: Converter.bytesToBase64(transactionBytes),\n\t\t\t// eslint-disable-next-line camelcase\n\t\t\tuser_sig: userSignature\n\t\t};\n\n\t\tconst baseUrl = StringHelper.trimTrailingSlashes(config.gasStation.gasStationUrl);\n\t\tconst result = await FetchHelper.fetchJson<typeof requestData, IGasStationExecuteResponse>(\n\t\t\tIota.CLASS_NAME,\n\t\t\t`${baseUrl}/v1/execute_tx`,\n\t\t\tHttpMethod.POST,\n\t\t\trequestData,\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\tAuthorization: `Bearer ${config.gasStation.gasStationAuthToken}`\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tconst effectsData = result.effects;\n\n\t\t// Match IotaTransactionBlockResponse format\n\t\treturn {\n\t\t\tdigest: effectsData.transactionDigest,\n\t\t\teffects: effectsData as unknown,\n\t\t\tevents: [],\n\t\t\tobjectChanges: [],\n\t\t\tconfirmedLocalExecution: true\n\t\t} as unknown as IIotaTransactionBlockResponse;\n\t}\n\n\t/**\n\t * Execute and confirm a gas station transaction.\n\t * @param config The configuration containing gas station settings.\n\t * @param client The IOTA client for confirmation.\n\t * @param reservationId The reservation ID from gas reservation.\n\t * @param transactionBytes The unsigned transaction bytes.\n\t * @param userSignature The user's signature.\n\t * @param options Response options including confirmation behavior.\n\t * @returns The transaction response (confirmed if waitForConfirmation is true).\n\t */\n\tpublic static async executeAndConfirmGasStationTransaction(\n\t\tconfig: IIotaConfig,\n\t\tclient: IIotaClient,\n\t\treservationId: number,\n\t\ttransactionBytes: Uint8Array,\n\t\tuserSignature: string,\n\t\toptions?: IIotaResponseOptions\n\t): Promise<IIotaTransactionBlockResponse> {\n\t\tGuards.object<IGasStationConfig>(Iota.CLASS_NAME, nameof(config.gasStation), config.gasStation);\n\n\t\tconst response = await Iota.executeGasStationTransaction(\n\t\t\tconfig,\n\t\t\treservationId,\n\t\t\ttransactionBytes,\n\t\t\tuserSignature\n\t\t);\n\n\t\tif (options?.waitForConfirmation ?? true) {\n\t\t\tconst confirmedTransaction = await Iota.waitForTransactionConfirmation(\n\t\t\t\tclient,\n\t\t\t\tresponse.digest,\n\t\t\t\tconfig,\n\t\t\t\t{\n\t\t\t\t\tshowEffects: options?.showEffects ?? true,\n\t\t\t\t\tshowEvents: options?.showEvents ?? true,\n\t\t\t\t\tshowObjectChanges: options?.showObjectChanges ?? true\n\t\t\t\t}\n\t\t\t);\n\n\t\t\treturn confirmedTransaction;\n\t\t}\n\n\t\treturn response;\n\t}\n\n\t/**\n\t * Fund an address with IOTA from the faucet.\n\t * @param config The configuration containing endpoint information.\n\t * @param faucetUrl The URL of the faucet to request funds from.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param address The address to fund.\n\t * @param timeoutInSeconds The timeout in seconds to wait for the funding to complete.\n\t * @returns The amount funded.\n\t */\n\tpublic static async fundAddress(\n\t\tconfig: IIotaConfig,\n\t\tfaucetUrl: string,\n\t\tidentity: string,\n\t\taddress: string,\n\t\ttimeoutInSeconds: number = 60\n\t): Promise<bigint> {\n\t\tGuards.objectValue<IIotaConfig>(Iota.CLASS_NAME, nameof(config), config);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(config.clientOptions.url), config.clientOptions.url);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(faucetUrl), faucetUrl);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(address), address);\n\n\t\ttry {\n\t\t\tconst initialBalance = await Iota.getBalance(config, address);\n\n\t\t\tconst response = await requestIotaFromFaucetV0({\n\t\t\t\thost: faucetUrl,\n\t\t\t\trecipient: address\n\t\t\t});\n\n\t\t\tif (response?.error) {\n\t\t\t\tthrow new GeneralError(Iota.CLASS_NAME, \"fundingFailed\", undefined, response.error);\n\t\t\t}\n\n\t\t\t// Poll for balance change\n\t\t\tconst numTries = Math.ceil(timeoutInSeconds / 5);\n\t\t\tfor (let i = 0; i < numTries; i++) {\n\t\t\t\tconst newBalance = await Iota.getBalance(config, address);\n\n\t\t\t\tif (newBalance > initialBalance) {\n\t\t\t\t\treturn newBalance - initialBalance;\n\t\t\t\t}\n\n\t\t\t\tif (i < numTries - 1) {\n\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, 5000));\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst payloadError = Iota.extractPayloadError(error);\n\t\t\tif (\n\t\t\t\tpayloadError.message.includes(\n\t\t\t\t\t\"Too many requests from this client have been sent to the faucet\"\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tIota.CLASS_NAME,\n\t\t\t\t\t\"faucetRateLimit\",\n\t\t\t\t\tundefined,\n\t\t\t\t\tIota.extractPayloadError(error)\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIota.CLASS_NAME,\n\t\t\t\t\"fundingFailed\",\n\t\t\t\tundefined,\n\t\t\t\tIota.extractPayloadError(error)\n\t\t\t);\n\t\t}\n\n\t\treturn 0n;\n\t}\n\n\t/**\n\t * Ensure the balance for the given address is at least the given amount.\n\t * @param config The configuration containing endpoint information.\n\t * @param faucetUrl The URL of the faucet to request funds from.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param address The address to ensure the balance for.\n\t * @param ensureBalance The minimum balance to ensure.\n\t * @param timeoutInSeconds Optional timeout in seconds, defaults to 10 seconds.\n\t * @returns True if the balance is at least the given amount, false otherwise.\n\t */\n\tpublic static async ensureBalance(\n\t\tconfig: IIotaConfig,\n\t\tfaucetUrl: string | undefined,\n\t\tidentity: string,\n\t\taddress: string,\n\t\tensureBalance: bigint,\n\t\ttimeoutInSeconds?: number\n\t): Promise<boolean> {\n\t\tGuards.objectValue<IIotaConfig>(Iota.CLASS_NAME, nameof(config), config);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(config.clientOptions.url), config.clientOptions.url);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(address), address);\n\t\tGuards.bigint(Iota.CLASS_NAME, nameof(ensureBalance), ensureBalance);\n\n\t\tlet currentBalance = await Iota.getBalance(config, address);\n\n\t\tif (Is.stringValue(faucetUrl)) {\n\t\t\tlet retryCount = 10;\n\n\t\t\twhile (currentBalance < ensureBalance && retryCount > 0) {\n\t\t\t\tconst addedBalance = await Iota.fundAddress(\n\t\t\t\t\tconfig,\n\t\t\t\t\tfaucetUrl,\n\t\t\t\t\tidentity,\n\t\t\t\t\taddress,\n\t\t\t\t\ttimeoutInSeconds\n\t\t\t\t);\n\t\t\t\tif (addedBalance === 0n) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tcurrentBalance += addedBalance;\n\t\t\t\tif (currentBalance < ensureBalance) {\n\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, 1000));\n\t\t\t\t\tretryCount--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn currentBalance >= ensureBalance;\n\t}\n\n\t/**\n\t * Get the balance for the given address.\n\t * @param config The configuration containing endpoint information.\n\t * @param address The address to get the balance for.\n\t * @returns The balance of the given address.\n\t */\n\tpublic static async getBalance(config: IIotaConfig, address: string): Promise<bigint> {\n\t\tGuards.objectValue<IIotaConfig>(Iota.CLASS_NAME, nameof(config), config);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(config.clientOptions.url), config.clientOptions.url);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(address), address);\n\n\t\tconst client = Iota.createClient(config);\n\t\tconst balance = await client.getBalance({\n\t\t\towner: address\n\t\t});\n\t\treturn BigInt(balance.totalBalance);\n\t}\n\n\t/**\n\t * Get the seed from the vault.\n\t * @param vaultConnector The vault connector to use.\n\t * @param config The configuration to use.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @returns The seed.\n\t * @internal\n\t */\n\tprivate static async getSeed(\n\t\tvaultConnector: IVaultConnector,\n\t\tconfig: Pick<IIotaConfig, \"vaultMnemonicId\" | \"vaultSeedId\">,\n\t\tidentity: string\n\t): Promise<Uint8Array> {\n\t\tconst seedKey = Iota.buildSeedKey(identity, config.vaultSeedId);\n\n\t\ttry {\n\t\t\tconst seedBase64 = await vaultConnector.getSecret<string>(seedKey);\n\t\t\treturn Converter.base64ToBytes(seedBase64);\n\t\t} catch {}\n\n\t\tconst mnemonic = await vaultConnector.getSecret<string>(\n\t\t\tIota.buildMnemonicKey(identity, config.vaultMnemonicId)\n\t\t);\n\n\t\t// If the seed is not found but the mnemonic exists, derive the seed and store it for future use\n\t\tconst seed = Bip39.mnemonicToSeed(mnemonic);\n\t\tawait vaultConnector.setSecret(seedKey, Converter.bytesToBase64(seed));\n\n\t\treturn seed;\n\t}\n\n\t/**\n\t * Get the key for storing the mnemonic.\n\t * @param identity The identity to use.\n\t * @param vaultMnemonicId The mnemonic ID to use.\n\t * @returns The mnemonic key.\n\t * @internal\n\t */\n\tprivate static buildMnemonicKey(identity: string, vaultMnemonicId?: string): string {\n\t\treturn `${identity}/${vaultMnemonicId ?? Iota.DEFAULT_MNEMONIC_SECRET_NAME}`;\n\t}\n\n\t/**\n\t * Get the key for storing the seed.\n\t * @param identity The identity to use.\n\t * @param vaultSeedId The seed ID to use.\n\t * @returns The seed key.\n\t * @internal\n\t */\n\tprivate static buildSeedKey(identity: string, vaultSeedId?: string): string {\n\t\treturn `${identity}/${vaultSeedId ?? Iota.DEFAULT_SEED_SECRET_NAME}`;\n\t}\n\n\t/**\n\t * Build a chunk of key pairs from vault cache or derived from seed.\n\t * @param vaultConnector The vault connector to use.\n\t * @param config The configuration to use.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param accountIndex The account index.\n\t * @param internal Whether the addresses are internal or external.\n\t * @param addressIndex The starting address index.\n\t * @returns The key pairs for the chunk.\n\t * @internal\n\t */\n\tprivate static async buildKeyPairRange(\n\t\tvaultConnector: IVaultConnector,\n\t\tconfig: Pick<IIotaConfig, \"coinType\" | \"vaultMnemonicId\" | \"vaultSeedId\">,\n\t\tidentity: string,\n\t\taccountIndex: number,\n\t\tinternal: boolean,\n\t\taddressIndex: number\n\t): Promise<{ privateKey: string; publicKey: string }[]> {\n\t\tconst keyPairChunkKey = Iota.buildKeyPairChunkKey(\n\t\t\tidentity,\n\t\t\taccountIndex,\n\t\t\tinternal,\n\t\t\taddressIndex\n\t\t);\n\n\t\tlet keyPairChunk: { privateKey: string; publicKey: string }[] | undefined;\n\t\ttry {\n\t\t\tkeyPairChunk =\n\t\t\t\tawait vaultConnector.getSecret<{ privateKey: string; publicKey: string }[]>(\n\t\t\t\t\tkeyPairChunkKey\n\t\t\t\t);\n\t\t} catch {}\n\n\t\tif (Is.empty(keyPairChunk)) {\n\t\t\tconst startChunkIndex = addressIndex % Iota._PRE_CALC_CHUNK_SIZE;\n\t\t\tconst endChunkIndex = startChunkIndex + Iota._PRE_CALC_CHUNK_SIZE;\n\n\t\t\tconst seed = await Iota.getSeed(vaultConnector, config, identity);\n\n\t\t\tkeyPairChunk = [];\n\n\t\t\tfor (let i = startChunkIndex; i < endChunkIndex; i++) {\n\t\t\t\tconst keyPair = Bip44.keyPair(\n\t\t\t\t\tseed,\n\t\t\t\t\tKeyType.Ed25519,\n\t\t\t\t\tconfig.coinType ?? Iota.DEFAULT_COIN_TYPE,\n\t\t\t\t\taccountIndex,\n\t\t\t\t\tinternal,\n\t\t\t\t\ti\n\t\t\t\t);\n\t\t\t\tkeyPairChunk.push({\n\t\t\t\t\tprivateKey: Converter.bytesToBase64(keyPair.privateKey),\n\t\t\t\t\tpublicKey: Converter.bytesToBase64(keyPair.publicKey)\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tawait vaultConnector.setSecret(keyPairChunkKey, keyPairChunk);\n\t\t}\n\n\t\treturn keyPairChunk;\n\t}\n\n\t/**\n\t * Get the key for storing a keypair chunk.\n\t * @param identity The identity to use.\n\t * @param accountIndex The account index.\n\t * @param internal Whether the address is internal or external.\n\t * @param addressIndex The address index to determine the chunk.\n\t * @returns The keypair chunk key.\n\t * @internal\n\t */\n\tprivate static buildKeyPairChunkKey(\n\t\tidentity: string,\n\t\taccountIndex: number,\n\t\tinternal: boolean,\n\t\taddressIndex: number\n\t): string {\n\t\treturn `${identity}/keypair/${accountIndex}/${internal ? \"internal\" : \"external\"}/${addressIndex % Iota._PRE_CALC_CHUNK_SIZE}`;\n\t}\n}\n"]}
1
+ {"version":3,"file":"iota.js","sourceRoot":"","sources":["../../src/iota.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EACN,SAAS,EACT,MAAM,EACN,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,YAAY,EAEZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAIlE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAYxD;;GAEG;AACH,MAAM,OAAO,IAAI;IAChB;;OAEG;IACI,MAAM,CAAU,4BAA4B,GAAW,UAAU,CAAC;IAEzE;;OAEG;IACI,MAAM,CAAU,wBAAwB,GAAW,MAAM,CAAC;IAEjE;;OAEG;IACI,MAAM,CAAU,iBAAiB,GAAW,IAAI,CAAC;IAExD;;OAEG;IACI,MAAM,CAAU,UAAU,UAA0B;IAE3D;;;OAGG;IACK,MAAM,CAAU,mBAAmB,GAAW,IAAI,CAAC;IAE3D;;;OAGG;IACK,MAAM,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G,CAAC,CAAC,CAAC,GAAG,IAAI,YAAY,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAClH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { IotaClient } from \"@iota/iota-sdk/client\";\nimport { requestIotaFromFaucetV0 } from \"@iota/iota-sdk/faucet\";\nimport { Ed25519Keypair } from \"@iota/iota-sdk/keypairs/ed25519\";\nimport { Transaction } from \"@iota/iota-sdk/transactions\";\nimport {\n\tBaseError,\n\tCoerce,\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tStringHelper,\n\ttype IError\n} from \"@twin.org/core\";\nimport { Bip39, Bip44, Blake2b, KeyType } from \"@twin.org/crypto\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IVaultConnector } from \"@twin.org/vault-models\";\nimport { FetchHelper, HttpMethod } from \"@twin.org/web\";\nimport type { IGasReservationResult } from \"./models/IGasReservationResult.js\";\nimport type { IGasStationConfig } from \"./models/IGasStationConfig.js\";\nimport type { IGasStationExecuteResponse } from \"./models/IGasStationExecuteResponse.js\";\nimport type { IGasStationReserveGasResponse } from \"./models/IGasStationReserveGasResponse.js\";\nimport type { IIotaClient } from \"./models/IIotaClient.js\";\nimport type { IIotaConfig } from \"./models/IIotaConfig.js\";\nimport type { IIotaDryRun } from \"./models/IIotaDryRun.js\";\nimport type { IIotaResponseOptions } from \"./models/IIotaResponseOptions.js\";\nimport type { IIotaTransaction } from \"./models/IIotaTransaction.js\";\nimport type { IIotaTransactionBlockResponse } from \"./models/IIotaTransactionBlockResponse.js\";\n\n/**\n * Class for performing operations on IOTA.\n */\nexport class Iota {\n\t/**\n\t * Default name for the mnemonic secret.\n\t */\n\tpublic static readonly DEFAULT_MNEMONIC_SECRET_NAME: string = \"mnemonic\";\n\n\t/**\n\t * Default name for the seed secret.\n\t */\n\tpublic static readonly DEFAULT_SEED_SECRET_NAME: string = \"seed\";\n\n\t/**\n\t * Default coin type.\n\t */\n\tpublic static readonly DEFAULT_COIN_TYPE: number = 4218;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Iota>();\n\n\t/**\n\t * Default scan range.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_SCAN_RANGE: number = 1000;\n\n\t/**\n\t * Default pre-calculation chunk size.\n\t * @internal\n\t */\n\tprivate static readonly _PRE_CALC_CHUNK_SIZE: number = 25;\n\n\t/**\n\t * Default inclusion timeout.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_INCLUSION_TIMEOUT: number = 60;\n\n\t/**\n\t * Default gas budget for all transactions (including sponsored and direct).\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_GAS_BUDGET: number = 50000000;\n\n\t/**\n\t * Default gas reservation duration.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_GAS_RESERVATION_DURATION: number = 60;\n\n\t/**\n\t * Create a new IOTA client.\n\t * @param config The configuration.\n\t * @returns The client instance.\n\t */\n\tpublic static createClient(config: IIotaConfig): IIotaClient {\n\t\tGuards.object(Iota.CLASS_NAME, nameof(config), config);\n\t\tGuards.object(Iota.CLASS_NAME, nameof(config.clientOptions), config.clientOptions);\n\t\tGuards.string(Iota.CLASS_NAME, nameof(config.clientOptions.url), config.clientOptions.url);\n\n\t\treturn new IotaClient(config.clientOptions);\n\t}\n\n\t/**\n\t * Create configuration using defaults where necessary.\n\t * @param config The configuration to populate.\n\t */\n\tpublic static populateConfig(config: IIotaConfig): void {\n\t\tGuards.object<IIotaConfig[\"clientOptions\"]>(\n\t\t\tIota.CLASS_NAME,\n\t\t\tnameof(config.clientOptions),\n\t\t\tconfig.clientOptions\n\t\t);\n\n\t\tconfig.vaultMnemonicId ??= Iota.DEFAULT_MNEMONIC_SECRET_NAME;\n\t\tconfig.vaultSeedId ??= Iota.DEFAULT_SEED_SECRET_NAME;\n\t\tconfig.coinType ??= Iota.DEFAULT_COIN_TYPE;\n\t\tconfig.inclusionTimeoutSeconds ??= Iota._DEFAULT_INCLUSION_TIMEOUT;\n\t}\n\n\t/**\n\t * Store a mnemonic in the vault, derive and store the seed, and pre-cache the first keypair chunk.\n\t * @param vaultConnector The vault connector.\n\t * @param config The configuration.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param mnemonic The mnemonic to store, if undefined a new one will be generated and returned.\n\t * @param accountIndex The account index to pre-cache.\n\t * @returns The mnemonic that was stored.\n\t */\n\tpublic static async storeMnemonic(\n\t\tvaultConnector: IVaultConnector,\n\t\tconfig: IIotaConfig,\n\t\tidentity: string,\n\t\tmnemonic: string | undefined,\n\t\taccountIndex: number\n\t): Promise<string> {\n\t\tGuards.object(Iota.CLASS_NAME, nameof(vaultConnector), vaultConnector);\n\t\tGuards.object<IIotaConfig>(Iota.CLASS_NAME, nameof(config), config);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.integer(Iota.CLASS_NAME, nameof(accountIndex), accountIndex);\n\n\t\tconst mnemonicToStore = mnemonic ?? Bip39.randomMnemonic();\n\n\t\tawait vaultConnector.setSecret(\n\t\t\tIota.buildMnemonicKey(identity, config.vaultMnemonicId),\n\t\t\tmnemonicToStore\n\t\t);\n\n\t\tconst seed = Bip39.mnemonicToSeed(mnemonicToStore);\n\t\tawait vaultConnector.setSecret(\n\t\t\tIota.buildSeedKey(identity, config.vaultSeedId),\n\t\t\tConverter.bytesToBase64(seed)\n\t\t);\n\n\t\tawait Iota.buildKeyPairRange(vaultConnector, config, identity, accountIndex, false, 0);\n\n\t\treturn mnemonicToStore;\n\t}\n\n\t/**\n\t * Derive an address from a public key.\n\t * @param publicKey The public key to derive the address from.\n\t * @returns The derived address.\n\t */\n\tpublic static publicKeyToAddress(publicKey: Uint8Array): string {\n\t\treturn Converter.bytesToHex(Blake2b.sum256(publicKey), true);\n\t}\n\n\t/**\n\t * Get address for the identity.\n\t * @param vaultConnector The vault connector.\n\t * @param config The configuration.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param accountIndex The account index to get the addresses for.\n\t * @param startAddressIndex The start index for the addresses.\n\t * @param isInternal Whether the addresses are internal.\n\t * @returns The address.\n\t */\n\tpublic static async getAddress(\n\t\tvaultConnector: IVaultConnector,\n\t\tconfig: Pick<IIotaConfig, \"coinType\" | \"vaultMnemonicId\" | \"vaultSeedId\">,\n\t\tidentity: string,\n\t\taccountIndex: number,\n\t\tstartAddressIndex: number,\n\t\tisInternal?: boolean\n\t): Promise<string> {\n\t\tconst addresses = await Iota.getAddresses(\n\t\t\tvaultConnector,\n\t\t\tconfig,\n\t\t\tidentity,\n\t\t\taccountIndex,\n\t\t\tstartAddressIndex,\n\t\t\t1,\n\t\t\tisInternal\n\t\t);\n\t\treturn addresses[0];\n\t}\n\n\t/**\n\t * Get addresses for the identity.\n\t * @param vaultConnector The vault connector.\n\t * @param config The configuration.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param accountIndex The account index to get the addresses for.\n\t * @param startAddressIndex The start index for the addresses.\n\t * @param count The number of addresses to generate.\n\t * @param isInternal Whether the addresses are internal.\n\t * @returns The list of addresses.\n\t */\n\tpublic static async getAddresses(\n\t\tvaultConnector: IVaultConnector,\n\t\tconfig: Pick<IIotaConfig, \"coinType\" | \"vaultMnemonicId\" | \"vaultSeedId\">,\n\t\tidentity: string,\n\t\taccountIndex: number,\n\t\tstartAddressIndex: number,\n\t\tcount: number,\n\t\tisInternal?: boolean\n\t): Promise<string[]> {\n\t\tGuards.object(Iota.CLASS_NAME, nameof(vaultConnector), vaultConnector);\n\t\tGuards.object<IIotaConfig>(Iota.CLASS_NAME, nameof(config), config);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.integer(Iota.CLASS_NAME, nameof(accountIndex), accountIndex);\n\t\tGuards.integer(Iota.CLASS_NAME, nameof(startAddressIndex), startAddressIndex);\n\t\tGuards.integer(Iota.CLASS_NAME, nameof(count), count);\n\n\t\tconst addresses: string[] = [];\n\t\tconst internal = isInternal ?? false;\n\t\tlet currentIndex = startAddressIndex;\n\n\t\twhile (addresses.length < count) {\n\t\t\tconst chunkStart =\n\t\t\t\tMath.floor(currentIndex / Iota._PRE_CALC_CHUNK_SIZE) * Iota._PRE_CALC_CHUNK_SIZE;\n\t\t\tconst keyPairs = await Iota.buildKeyPairRange(\n\t\t\t\tvaultConnector,\n\t\t\t\tconfig,\n\t\t\t\tidentity,\n\t\t\t\taccountIndex,\n\t\t\t\tinternal,\n\t\t\t\tchunkStart\n\t\t\t);\n\t\t\tconst chunk = keyPairs.map(kp =>\n\t\t\t\tIota.publicKeyToAddress(Converter.base64ToBytes(kp.publicKey))\n\t\t\t);\n\t\t\tconst offsetInChunk = currentIndex - chunkStart;\n\t\t\tconst remaining = count - addresses.length;\n\t\t\taddresses.push(...chunk.slice(offsetInChunk, offsetInChunk + remaining));\n\t\t\tcurrentIndex = chunkStart + Iota._PRE_CALC_CHUNK_SIZE;\n\t\t}\n\n\t\treturn addresses;\n\t}\n\n\t/**\n\t * Get a key pair for the specified index.\n\t * @param vaultConnector The vault connector.\n\t * @param config The configuration.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param accountIndex The account index to get the key pair for.\n\t * @param addressIndex The address index to get the key pair for.\n\t * @param isInternal Whether the address is internal.\n\t * @returns The key pair containing private key and public key.\n\t */\n\tpublic static async getKeyPair(\n\t\tvaultConnector: IVaultConnector,\n\t\tconfig: IIotaConfig,\n\t\tidentity: string,\n\t\taccountIndex: number,\n\t\taddressIndex: number,\n\t\tisInternal?: boolean\n\t): Promise<{\n\t\tprivateKey: Uint8Array;\n\t\tpublicKey: Uint8Array;\n\t}> {\n\t\tGuards.object(Iota.CLASS_NAME, nameof(vaultConnector), vaultConnector);\n\t\tGuards.object<IIotaConfig>(Iota.CLASS_NAME, nameof(config), config);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.integer(Iota.CLASS_NAME, nameof(accountIndex), accountIndex);\n\t\tGuards.integer(Iota.CLASS_NAME, nameof(addressIndex), addressIndex);\n\n\t\tconst internal = isInternal ?? false;\n\t\tconst chunkStart =\n\t\t\tMath.floor(addressIndex / Iota._PRE_CALC_CHUNK_SIZE) * Iota._PRE_CALC_CHUNK_SIZE;\n\t\tconst keyPairs = await Iota.buildKeyPairRange(\n\t\t\tvaultConnector,\n\t\t\tconfig,\n\t\t\tidentity,\n\t\t\taccountIndex,\n\t\t\tinternal,\n\t\t\tchunkStart\n\t\t);\n\t\tconst offsetInChunk = addressIndex - chunkStart;\n\t\tconst entry = keyPairs[offsetInChunk];\n\n\t\treturn {\n\t\t\tprivateKey: Converter.base64ToBytes(entry.privateKey),\n\t\t\tpublicKey: Converter.base64ToBytes(entry.publicKey)\n\t\t};\n\t}\n\n\t/**\n\t * Create a new transaction instance.\n\t * @returns A new transaction instance.\n\t */\n\tpublic static createTransaction(): IIotaTransaction {\n\t\treturn new Transaction();\n\t}\n\n\t/**\n\t * Prepare and post a transaction.\n\t * @param config The configuration.\n\t * @param vaultConnector The vault connector.\n\t * @param logging The logging component.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param client The client instance.\n\t * @param source The source address.\n\t * @param amount The amount to transfer.\n\t * @param recipient The recipient address.\n\t * @param options The transaction options.\n\t * @returns The transaction result.\n\t */\n\tpublic static async prepareAndPostValueTransaction(\n\t\tconfig: IIotaConfig,\n\t\tvaultConnector: IVaultConnector,\n\t\tlogging: ILoggingComponent | undefined,\n\t\tidentity: string,\n\t\tclient: IIotaClient,\n\t\tsource: string,\n\t\tamount: bigint,\n\t\trecipient: string,\n\t\toptions?: IIotaResponseOptions\n\t): Promise<IIotaTransactionBlockResponse> {\n\t\ttry {\n\t\t\tconst txb = new Transaction();\n\t\t\tconst [coin] = txb.splitCoins(txb.gas, [txb.pure.u64(amount)]);\n\t\t\ttxb.transferObjects([coin], txb.pure.address(recipient));\n\n\t\t\t// Check if gas station configuration is present\n\t\t\tif (Is.object<IGasStationConfig>(config.gasStation)) {\n\t\t\t\treturn await Iota.prepareAndPostGasStationTransaction(\n\t\t\t\t\tconfig,\n\t\t\t\t\tvaultConnector,\n\t\t\t\t\tidentity,\n\t\t\t\t\tclient,\n\t\t\t\t\tsource,\n\t\t\t\t\ttxb\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst result = await Iota.prepareAndPostTransaction(\n\t\t\t\tconfig,\n\t\t\t\tvaultConnector,\n\t\t\t\tlogging,\n\t\t\t\tidentity,\n\t\t\t\tclient,\n\t\t\t\tsource,\n\t\t\t\ttxb,\n\t\t\t\toptions\n\t\t\t);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIota.CLASS_NAME,\n\t\t\t\t\"valueTransactionFailed\",\n\t\t\t\tundefined,\n\t\t\t\tIota.extractPayloadError(error)\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Prepare and post a transaction.\n\t * @param config The configuration.\n\t * @param vaultConnector The vault connector.\n\t * @param logging The logging component.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param client The client instance.\n\t * @param owner The owner of the address.\n\t * @param transaction The transaction to execute.\n\t * @param options The transaction options.\n\t * @returns The transaction response.\n\t */\n\tpublic static async prepareAndPostTransaction(\n\t\tconfig: IIotaConfig,\n\t\tvaultConnector: IVaultConnector,\n\t\tlogging: ILoggingComponent | undefined,\n\t\tidentity: string,\n\t\tclient: IIotaClient,\n\t\towner: string,\n\t\ttransaction: IIotaTransaction,\n\t\toptions?: IIotaResponseOptions\n\t): Promise<IIotaTransactionBlockResponse> {\n\t\t// Check if gas station configuration is present\n\t\tif (Is.object<IGasStationConfig>(config.gasStation)) {\n\t\t\treturn Iota.prepareAndPostGasStationTransaction(\n\t\t\t\tconfig,\n\t\t\t\tvaultConnector,\n\t\t\t\tidentity,\n\t\t\t\tclient,\n\t\t\t\towner,\n\t\t\t\ttransaction,\n\t\t\t\toptions\n\t\t\t);\n\t\t}\n\n\t\t// Traditional transaction flow\n\t\t// Dry run the transaction if cost logging is enabled to get the gas and storage costs\n\t\tif (Is.stringValue(options?.dryRunLabel)) {\n\t\t\tawait Iota.dryRunTransaction(client, logging, transaction, owner, options.dryRunLabel);\n\t\t}\n\n\t\tconst addressKeyPair = await Iota.findAddress(vaultConnector, config, identity, owner, 0);\n\t\tconst keypair = Ed25519Keypair.fromSecretKey(addressKeyPair.privateKey);\n\n\t\ttry {\n\t\t\tconst response = await client.signAndExecuteTransaction({\n\t\t\t\ttransaction,\n\t\t\t\tsigner: keypair,\n\t\t\t\trequestType: \"WaitForLocalExecution\",\n\t\t\t\toptions: {\n\t\t\t\t\tshowEffects: options?.showEffects ?? true,\n\t\t\t\t\tshowEvents: options?.showEvents ?? true,\n\t\t\t\t\tshowObjectChanges: options?.showObjectChanges ?? true\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (options?.waitForConfirmation ?? true) {\n\t\t\t\t// Wait for transaction to be indexed and available over API\n\t\t\t\tconst confirmedTransaction = await Iota.waitForTransactionConfirmation(\n\t\t\t\t\tclient,\n\t\t\t\t\tresponse.digest,\n\t\t\t\t\tconfig,\n\t\t\t\t\t{\n\t\t\t\t\t\tshowEffects: options?.showEffects ?? true,\n\t\t\t\t\t\tshowEvents: options?.showEvents ?? true,\n\t\t\t\t\t\tshowObjectChanges: options?.showObjectChanges ?? true\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\treturn confirmedTransaction;\n\t\t\t}\n\n\t\t\treturn response;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIota.CLASS_NAME,\n\t\t\t\t\"transactionFailed\",\n\t\t\t\tundefined,\n\t\t\t\tIota.extractPayloadError(error)\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Find the address in the seed.\n\t * @param vaultConnector The vault connector to use.\n\t * @param config The configuration to use.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param address The address to find.\n\t * @param accountIndex The account index to search.\n\t * @param isInternal Whether to search internal addresses.\n\t * @param startScanIndex The address index to start scanning from.\n\t * @param maxScanRange The maximum range to scan.\n\t * @returns The address key pair.\n\t * @throws Error if the address is not found.\n\t */\n\tpublic static async findAddress(\n\t\tvaultConnector: IVaultConnector,\n\t\tconfig: IIotaConfig,\n\t\tidentity: string,\n\t\taddress: string,\n\t\taccountIndex: number,\n\t\tisInternal?: boolean,\n\t\tstartScanIndex?: number,\n\t\tmaxScanRange?: number\n\t): Promise<{\n\t\taddress: string;\n\t\tprivateKey: Uint8Array;\n\t\tpublicKey: Uint8Array;\n\t}> {\n\t\tconst internal = isInternal ?? false;\n\t\tconst startIndex = startScanIndex ?? 0;\n\t\tconst scanRange = maxScanRange ?? config.maxAddressScanRange ?? Iota._DEFAULT_SCAN_RANGE;\n\n\t\tfor (\n\t\t\tlet chunkStart = startIndex;\n\t\t\tchunkStart < startIndex + scanRange;\n\t\t\tchunkStart += Iota._PRE_CALC_CHUNK_SIZE\n\t\t) {\n\t\t\tconst keyPairs = await Iota.buildKeyPairRange(\n\t\t\t\tvaultConnector,\n\t\t\t\tconfig,\n\t\t\t\tidentity,\n\t\t\t\taccountIndex,\n\t\t\t\tinternal,\n\t\t\t\tchunkStart\n\t\t\t);\n\t\t\tconst offsetInChunk = keyPairs.findIndex(\n\t\t\t\tkp => Iota.publicKeyToAddress(Converter.base64ToBytes(kp.publicKey)) === address\n\t\t\t);\n\t\t\tif (offsetInChunk !== -1) {\n\t\t\t\tconst entry = keyPairs[offsetInChunk];\n\t\t\t\treturn {\n\t\t\t\t\taddress,\n\t\t\t\t\tprivateKey: Converter.base64ToBytes(entry.privateKey),\n\t\t\t\t\tpublicKey: Converter.base64ToBytes(entry.publicKey)\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tthrow new GeneralError(Iota.CLASS_NAME, \"addressNotFound\", { address });\n\t}\n\n\t/**\n\t * Extract error from SDK payload.\n\t * Errors from the IOTA SDK are usually not JSON strings but objects.\n\t * @param error The error to extract.\n\t * @returns The extracted error.\n\t */\n\tpublic static extractPayloadError(error: unknown): IError {\n\t\tif (Is.object<{ code?: string; message?: string; inner?: unknown; cause?: unknown }>(error)) {\n\t\t\tif (!Is.empty(error.inner)) {\n\t\t\t\terror.inner = Iota.extractPayloadError(error.inner);\n\t\t\t}\n\t\t\tif (!Is.empty(error.cause)) {\n\t\t\t\terror.cause = Iota.extractPayloadError(error.cause);\n\t\t\t}\n\n\t\t\tif (error.code === \"InsufficientGas\") {\n\t\t\t\treturn new GeneralError(Iota.CLASS_NAME, \"insufficientFunds\");\n\t\t\t} else if (error.message?.startsWith(\"ErrorObject\")) {\n\t\t\t\tconst msg = /message: \"(.*)\"/.exec(error.message);\n\t\t\t\tif (msg && msg.length > 1) {\n\t\t\t\t\terror = msg[1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst baseError = BaseError.fromError(error);\n\t\tif (baseError.name === \"Base\" && !Is.stringValue(baseError.source)) {\n\t\t\tbaseError.name = \"IOTA\";\n\t\t\tbaseError.source = Iota.CLASS_NAME;\n\t\t}\n\t\treturn baseError;\n\t}\n\n\t/**\n\t * Check if the package exists on the network.\n\t * @param client The client to use.\n\t * @param packageId The package ID to check.\n\t * @returns True if the package exists, false otherwise.\n\t */\n\tpublic static async packageExistsOnNetwork(\n\t\tclient: IIotaClient,\n\t\tpackageId: string\n\t): Promise<boolean> {\n\t\ttry {\n\t\t\tconst packageObject = await client.getObject({\n\t\t\t\tid: packageId,\n\t\t\t\toptions: {\n\t\t\t\t\tshowType: true\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (\"error\" in packageObject) {\n\t\t\t\tif (packageObject?.error?.code === \"notExists\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tthrow new GeneralError(Iota.CLASS_NAME, \"packageObjectError\", {\n\t\t\t\t\tpackageId,\n\t\t\t\t\terror: packageObject.error\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIota.CLASS_NAME,\n\t\t\t\t\"packageNotFoundOnNetwork\",\n\t\t\t\t{\n\t\t\t\t\tpackageId\n\t\t\t\t},\n\t\t\t\tIota.extractPayloadError(error)\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Dry run a transaction and log the results.\n\t * @param client The IOTA client.\n\t * @param logging The logging component.\n\t * @param txb The transaction to dry run.\n\t * @param sender The sender address.\n\t * @param operation The operation to log.\n\t * @returns void.\n\t */\n\tpublic static async dryRunTransaction(\n\t\tclient: IIotaClient,\n\t\tlogging: ILoggingComponent | undefined,\n\t\ttxb: IIotaTransaction,\n\t\tsender: string,\n\t\toperation: string\n\t): Promise<IIotaDryRun> {\n\t\ttry {\n\t\t\ttxb.setSender(sender);\n\n\t\t\tconst builtTx = await txb.build({\n\t\t\t\tclient,\n\t\t\t\tonlyTransactionKind: false\n\t\t\t});\n\n\t\t\tconst dryRunResult = await client.dryRunTransactionBlock({\n\t\t\t\ttransactionBlock: builtTx\n\t\t\t});\n\n\t\t\tif (dryRunResult.effects.status?.status !== \"success\") {\n\t\t\t\tthrow new GeneralError(Iota.CLASS_NAME, \"dryRunFailed\", {\n\t\t\t\t\terror: dryRunResult.effects?.status?.error\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst result = {\n\t\t\t\tstatus: dryRunResult.effects.status.status,\n\t\t\t\tcosts: {\n\t\t\t\t\tcomputationCost: dryRunResult.effects.gasUsed.computationCost,\n\t\t\t\t\tcomputationCostBurned: dryRunResult.effects.gasUsed.computationCostBurned,\n\t\t\t\t\tstorageCost: dryRunResult.effects.gasUsed.storageCost,\n\t\t\t\t\tstorageRebate: dryRunResult.effects.gasUsed.storageRebate,\n\t\t\t\t\tnonRefundableStorageFee: dryRunResult.effects.gasUsed.nonRefundableStorageFee\n\t\t\t\t},\n\t\t\t\tevents: dryRunResult.events ?? [],\n\t\t\t\tbalanceChanges: dryRunResult.balanceChanges ?? [],\n\t\t\t\tobjectChanges: dryRunResult.objectChanges ?? []\n\t\t\t};\n\n\t\t\tawait logging?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: Iota.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"transactionCosts\",\n\t\t\t\tdata: {\n\t\t\t\t\toperation,\n\t\t\t\t\tcost: JSON.stringify(result)\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tif (BaseError.isErrorName(error, GeneralError.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIota.CLASS_NAME,\n\t\t\t\t\"dryRunFailed\",\n\t\t\t\tundefined,\n\t\t\t\tIota.extractPayloadError(error)\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Wait for a transaction to be indexed and available over the API.\n\t * @param client The IOTA client instance.\n\t * @param digest The digest of the transaction to wait for.\n\t * @param config The IOTA configuration.\n\t * @param options Additional options for the transaction query.\n\t * @param options.showEffects Whether to show effects.\n\t * @param options.showEvents Whether to show events.\n\t * @param options.showObjectChanges Whether to show object changes.\n\t * @returns The confirmed transaction response.\n\t */\n\tpublic static async waitForTransactionConfirmation(\n\t\tclient: IIotaClient,\n\t\tdigest: string,\n\t\tconfig: IIotaConfig,\n\t\toptions?: {\n\t\t\tshowEffects?: boolean;\n\t\t\tshowEvents?: boolean;\n\t\t\tshowObjectChanges?: boolean;\n\t\t}\n\t): Promise<IIotaTransactionBlockResponse> {\n\t\tconst timeoutMs = (config.inclusionTimeoutSeconds ?? Iota._DEFAULT_INCLUSION_TIMEOUT) * 1000;\n\n\t\treturn client.waitForTransaction({\n\t\t\tdigest,\n\t\t\ttimeout: timeoutMs,\n\t\t\toptions: {\n\t\t\t\tshowEffects: options?.showEffects ?? true,\n\t\t\t\tshowEvents: options?.showEvents ?? true,\n\t\t\t\tshowObjectChanges: options?.showObjectChanges ?? true\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Check if the error is an abort error with a specific code.\n\t * @param error The error to check.\n\t * @param code The error code to check for.\n\t * @returns True if the error is an abort error, false otherwise.\n\t */\n\tpublic static isAbortError(error: unknown, code: number): boolean {\n\t\tconst err = BaseError.fromError(error);\n\t\tif (Is.stringValue(err.properties?.error)) {\n\t\t\tconst abortCodeMatch = /abort code\\s*:\\s*(\\d+)/i.exec(err.properties.error);\n\t\t\treturn abortCodeMatch?.[1] === code.toString();\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Extracts the abort code from a transaction result if the transaction was aborted.\n\t * @param response The transaction result to extract the abort code from.\n\t * @returns The abort code if the transaction was aborted, or undefined if it was not an abort error or the code could not be extracted.\n\t */\n\tpublic static extractAbortCode(response: IIotaTransactionBlockResponse): number | undefined {\n\t\tif (\n\t\t\tresponse.effects?.status?.status === \"failure\" &&\n\t\t\tIs.stringValue(response.effects.status.error)\n\t\t) {\n\t\t\tconst match = /abort code: (\\d+)/.exec(response.effects.status.error);\n\t\t\tif (match) {\n\t\t\t\treturn Coerce.integer(match[1]);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Prepare and post a transaction using gas station sponsoring.\n\t * @param config The configuration.\n\t * @param vaultConnector The vault connector.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param client The client instance.\n\t * @param owner The owner of the address.\n\t * @param transaction The transaction to execute.\n\t * @param options Response options including confirmation behavior.\n\t * @returns The transaction response.\n\t */\n\tpublic static async prepareAndPostGasStationTransaction(\n\t\tconfig: IIotaConfig,\n\t\tvaultConnector: IVaultConnector,\n\t\tidentity: string,\n\t\tclient: IIotaClient,\n\t\towner: string,\n\t\ttransaction: IIotaTransaction,\n\t\toptions?: IIotaResponseOptions\n\t): Promise<IIotaTransactionBlockResponse> {\n\t\tGuards.object(Iota.CLASS_NAME, nameof(config.gasStation), config.gasStation);\n\n\t\ttry {\n\t\t\t// Reserve gas from the gas station\n\t\t\tconst gasReservation = await Iota.reserveGas(config);\n\n\t\t\t// Set transaction parameters for sponsoring\n\t\t\ttransaction.setSender(owner);\n\t\t\ttransaction.setGasOwner(gasReservation.sponsorAddress);\n\t\t\ttransaction.setGasPayment(gasReservation.gasCoins);\n\t\t\ttransaction.setGasBudget(config.gasBudget ?? Iota._DEFAULT_GAS_BUDGET);\n\n\t\t\t// Build and sign transaction\n\t\t\tconst unsignedTxBytes = await transaction.build({ client });\n\n\t\t\t// Sign the transaction with the user's private key\n\t\t\tconst addressKeyPair = await Iota.findAddress(vaultConnector, config, identity, owner, 0);\n\t\t\tconst keypair = Ed25519Keypair.fromSecretKey(addressKeyPair.privateKey);\n\t\t\tconst signature = await keypair.signTransaction(unsignedTxBytes);\n\n\t\t\treturn await Iota.executeAndConfirmGasStationTransaction(\n\t\t\t\tconfig,\n\t\t\t\tclient,\n\t\t\t\tgasReservation.reservationId,\n\t\t\t\tunsignedTxBytes,\n\t\t\t\tsignature.signature,\n\t\t\t\toptions\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIota.CLASS_NAME,\n\t\t\t\t\"gasStationTransactionFailed\",\n\t\t\t\tundefined,\n\t\t\t\tIota.extractPayloadError(error)\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Reserve gas from the gas station.\n\t * @param config The configuration containing gas station settings.\n\t * @returns The gas reservation result.\n\t */\n\tpublic static async reserveGas(config: IIotaConfig): Promise<IGasReservationResult> {\n\t\tGuards.object(Iota.CLASS_NAME, nameof(config.gasStation), config.gasStation);\n\n\t\tconst requestData = {\n\t\t\t// eslint-disable-next-line camelcase\n\t\t\tgas_budget: config.gasBudget ?? Iota._DEFAULT_GAS_BUDGET,\n\t\t\t// eslint-disable-next-line camelcase\n\t\t\treserve_duration_secs: config.gasReservationDuration ?? Iota._DEFAULT_GAS_RESERVATION_DURATION\n\t\t};\n\n\t\tconst baseUrl = StringHelper.trimTrailingSlashes(config.gasStation.gasStationUrl);\n\t\tconst result = await FetchHelper.fetchJson<typeof requestData, IGasStationReserveGasResponse>(\n\t\t\tIota.CLASS_NAME,\n\t\t\t`${baseUrl}/v1/reserve_gas`,\n\t\t\tHttpMethod.POST,\n\t\t\trequestData,\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\tAuthorization: `Bearer ${config.gasStation.gasStationAuthToken}`\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tconst apiResponse = result.result;\n\n\t\treturn {\n\t\t\tsponsorAddress: apiResponse.sponsor_address,\n\t\t\treservationId: apiResponse.reservation_id,\n\t\t\tgasCoins: apiResponse.gas_coins\n\t\t};\n\t}\n\n\t/**\n\t * Execute a sponsored transaction through the gas station.\n\t * @param config The configuration containing gas station settings.\n\t * @param reservationId The reservation ID from gas reservation.\n\t * @param transactionBytes The unsigned transaction bytes.\n\t * @param userSignature The user's signature.\n\t * @returns The transaction response.\n\t */\n\tpublic static async executeGasStationTransaction(\n\t\tconfig: IIotaConfig,\n\t\treservationId: number,\n\t\ttransactionBytes: Uint8Array,\n\t\tuserSignature: string\n\t): Promise<IIotaTransactionBlockResponse> {\n\t\tGuards.object<IGasStationConfig>(Iota.CLASS_NAME, nameof(config.gasStation), config.gasStation);\n\n\t\tconst requestData = {\n\t\t\t// eslint-disable-next-line camelcase\n\t\t\treservation_id: reservationId,\n\t\t\t// eslint-disable-next-line camelcase\n\t\t\ttx_bytes: Converter.bytesToBase64(transactionBytes),\n\t\t\t// eslint-disable-next-line camelcase\n\t\t\tuser_sig: userSignature\n\t\t};\n\n\t\tconst baseUrl = StringHelper.trimTrailingSlashes(config.gasStation.gasStationUrl);\n\t\tconst result = await FetchHelper.fetchJson<typeof requestData, IGasStationExecuteResponse>(\n\t\t\tIota.CLASS_NAME,\n\t\t\t`${baseUrl}/v1/execute_tx`,\n\t\t\tHttpMethod.POST,\n\t\t\trequestData,\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\tAuthorization: `Bearer ${config.gasStation.gasStationAuthToken}`\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tconst effectsData = result.effects;\n\n\t\t// Match IotaTransactionBlockResponse format\n\t\treturn {\n\t\t\tdigest: effectsData.transactionDigest,\n\t\t\teffects: effectsData as unknown,\n\t\t\tevents: [],\n\t\t\tobjectChanges: [],\n\t\t\tconfirmedLocalExecution: true\n\t\t} as unknown as IIotaTransactionBlockResponse;\n\t}\n\n\t/**\n\t * Execute and confirm a gas station transaction.\n\t * @param config The configuration containing gas station settings.\n\t * @param client The IOTA client for confirmation.\n\t * @param reservationId The reservation ID from gas reservation.\n\t * @param transactionBytes The unsigned transaction bytes.\n\t * @param userSignature The user's signature.\n\t * @param options Response options including confirmation behavior.\n\t * @returns The transaction response (confirmed if waitForConfirmation is true).\n\t */\n\tpublic static async executeAndConfirmGasStationTransaction(\n\t\tconfig: IIotaConfig,\n\t\tclient: IIotaClient,\n\t\treservationId: number,\n\t\ttransactionBytes: Uint8Array,\n\t\tuserSignature: string,\n\t\toptions?: IIotaResponseOptions\n\t): Promise<IIotaTransactionBlockResponse> {\n\t\tGuards.object<IGasStationConfig>(Iota.CLASS_NAME, nameof(config.gasStation), config.gasStation);\n\n\t\tconst response = await Iota.executeGasStationTransaction(\n\t\t\tconfig,\n\t\t\treservationId,\n\t\t\ttransactionBytes,\n\t\t\tuserSignature\n\t\t);\n\n\t\tif (options?.waitForConfirmation ?? true) {\n\t\t\tconst confirmedTransaction = await Iota.waitForTransactionConfirmation(\n\t\t\t\tclient,\n\t\t\t\tresponse.digest,\n\t\t\t\tconfig,\n\t\t\t\t{\n\t\t\t\t\tshowEffects: options?.showEffects ?? true,\n\t\t\t\t\tshowEvents: options?.showEvents ?? true,\n\t\t\t\t\tshowObjectChanges: options?.showObjectChanges ?? true\n\t\t\t\t}\n\t\t\t);\n\n\t\t\treturn confirmedTransaction;\n\t\t}\n\n\t\treturn response;\n\t}\n\n\t/**\n\t * Fund an address with IOTA from the faucet.\n\t * @param config The configuration containing endpoint information.\n\t * @param faucetUrl The URL of the faucet to request funds from.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param address The address to fund.\n\t * @param timeoutInSeconds The timeout in seconds to wait for the funding to complete.\n\t * @returns The amount funded.\n\t */\n\tpublic static async fundAddress(\n\t\tconfig: IIotaConfig,\n\t\tfaucetUrl: string,\n\t\tidentity: string,\n\t\taddress: string,\n\t\ttimeoutInSeconds: number = 60\n\t): Promise<bigint> {\n\t\tGuards.objectValue<IIotaConfig>(Iota.CLASS_NAME, nameof(config), config);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(config.clientOptions.url), config.clientOptions.url);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(faucetUrl), faucetUrl);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(address), address);\n\n\t\ttry {\n\t\t\tconst initialBalance = await Iota.getBalance(config, address);\n\n\t\t\tconst response = await requestIotaFromFaucetV0({\n\t\t\t\thost: faucetUrl,\n\t\t\t\trecipient: address\n\t\t\t});\n\n\t\t\tif (response?.error) {\n\t\t\t\tthrow new GeneralError(Iota.CLASS_NAME, \"fundingFailed\", undefined, response.error);\n\t\t\t}\n\n\t\t\t// Poll for balance change\n\t\t\tconst numTries = Math.ceil(timeoutInSeconds / 5);\n\t\t\tfor (let i = 0; i < numTries; i++) {\n\t\t\t\tconst newBalance = await Iota.getBalance(config, address);\n\n\t\t\t\tif (newBalance > initialBalance) {\n\t\t\t\t\treturn newBalance - initialBalance;\n\t\t\t\t}\n\n\t\t\t\tif (i < numTries - 1) {\n\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, 5000));\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst payloadError = Iota.extractPayloadError(error);\n\t\t\tif (\n\t\t\t\tpayloadError.message.includes(\n\t\t\t\t\t\"Too many requests from this client have been sent to the faucet\"\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tIota.CLASS_NAME,\n\t\t\t\t\t\"faucetRateLimit\",\n\t\t\t\t\tundefined,\n\t\t\t\t\tIota.extractPayloadError(error)\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIota.CLASS_NAME,\n\t\t\t\t\"fundingFailed\",\n\t\t\t\tundefined,\n\t\t\t\tIota.extractPayloadError(error)\n\t\t\t);\n\t\t}\n\n\t\treturn 0n;\n\t}\n\n\t/**\n\t * Ensure the balance for the given address is at least the given amount.\n\t * @param config The configuration containing endpoint information.\n\t * @param faucetUrl The URL of the faucet to request funds from.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param address The address to ensure the balance for.\n\t * @param ensureBalance The minimum balance to ensure.\n\t * @param timeoutInSeconds Optional timeout in seconds, defaults to 10 seconds.\n\t * @returns True if the balance is at least the given amount, false otherwise.\n\t */\n\tpublic static async ensureBalance(\n\t\tconfig: IIotaConfig,\n\t\tfaucetUrl: string | undefined,\n\t\tidentity: string,\n\t\taddress: string,\n\t\tensureBalance: bigint,\n\t\ttimeoutInSeconds?: number\n\t): Promise<boolean> {\n\t\tGuards.objectValue<IIotaConfig>(Iota.CLASS_NAME, nameof(config), config);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(config.clientOptions.url), config.clientOptions.url);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(address), address);\n\t\tGuards.bigint(Iota.CLASS_NAME, nameof(ensureBalance), ensureBalance);\n\n\t\tlet currentBalance = await Iota.getBalance(config, address);\n\n\t\tif (Is.stringValue(faucetUrl)) {\n\t\t\tlet retryCount = 10;\n\n\t\t\twhile (currentBalance < ensureBalance && retryCount > 0) {\n\t\t\t\tconst addedBalance = await Iota.fundAddress(\n\t\t\t\t\tconfig,\n\t\t\t\t\tfaucetUrl,\n\t\t\t\t\tidentity,\n\t\t\t\t\taddress,\n\t\t\t\t\ttimeoutInSeconds\n\t\t\t\t);\n\t\t\t\tif (addedBalance === 0n) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tcurrentBalance += addedBalance;\n\t\t\t\tif (currentBalance < ensureBalance) {\n\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, 1000));\n\t\t\t\t\tretryCount--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn currentBalance >= ensureBalance;\n\t}\n\n\t/**\n\t * Get the balance for the given address.\n\t * @param config The configuration containing endpoint information.\n\t * @param address The address to get the balance for.\n\t * @returns The balance of the given address.\n\t */\n\tpublic static async getBalance(config: IIotaConfig, address: string): Promise<bigint> {\n\t\tGuards.objectValue<IIotaConfig>(Iota.CLASS_NAME, nameof(config), config);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(config.clientOptions.url), config.clientOptions.url);\n\t\tGuards.stringValue(Iota.CLASS_NAME, nameof(address), address);\n\n\t\tconst client = Iota.createClient(config);\n\t\tconst balance = await client.getBalance({\n\t\t\towner: address\n\t\t});\n\t\treturn BigInt(balance.totalBalance);\n\t}\n\n\t/**\n\t * Get the seed from the vault.\n\t * @param vaultConnector The vault connector to use.\n\t * @param config The configuration to use.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @returns The seed.\n\t * @internal\n\t */\n\tprivate static async getSeed(\n\t\tvaultConnector: IVaultConnector,\n\t\tconfig: Pick<IIotaConfig, \"vaultMnemonicId\" | \"vaultSeedId\">,\n\t\tidentity: string\n\t): Promise<Uint8Array> {\n\t\tconst seedKey = Iota.buildSeedKey(identity, config.vaultSeedId);\n\n\t\ttry {\n\t\t\tconst seedBase64 = await vaultConnector.getSecret<string>(seedKey);\n\t\t\treturn Converter.base64ToBytes(seedBase64);\n\t\t} catch {}\n\n\t\tconst mnemonic = await vaultConnector.getSecret<string>(\n\t\t\tIota.buildMnemonicKey(identity, config.vaultMnemonicId)\n\t\t);\n\n\t\t// If the seed is not found but the mnemonic exists, derive the seed and store it for future use\n\t\tconst seed = Bip39.mnemonicToSeed(mnemonic);\n\t\tawait vaultConnector.setSecret(seedKey, Converter.bytesToBase64(seed));\n\n\t\treturn seed;\n\t}\n\n\t/**\n\t * Get the key for storing the mnemonic.\n\t * @param identity The identity to use.\n\t * @param vaultMnemonicId The mnemonic ID to use.\n\t * @returns The mnemonic key.\n\t * @internal\n\t */\n\tprivate static buildMnemonicKey(identity: string, vaultMnemonicId?: string): string {\n\t\treturn `${identity}/${vaultMnemonicId ?? Iota.DEFAULT_MNEMONIC_SECRET_NAME}`;\n\t}\n\n\t/**\n\t * Get the key for storing the seed.\n\t * @param identity The identity to use.\n\t * @param vaultSeedId The seed ID to use.\n\t * @returns The seed key.\n\t * @internal\n\t */\n\tprivate static buildSeedKey(identity: string, vaultSeedId?: string): string {\n\t\treturn `${identity}/${vaultSeedId ?? Iota.DEFAULT_SEED_SECRET_NAME}`;\n\t}\n\n\t/**\n\t * Build a chunk of key pairs from vault cache or derived from seed.\n\t * @param vaultConnector The vault connector to use.\n\t * @param config The configuration to use.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param accountIndex The account index.\n\t * @param internal Whether the addresses are internal or external.\n\t * @param addressIndex The starting address index.\n\t * @returns The key pairs for the chunk.\n\t * @internal\n\t */\n\tprivate static async buildKeyPairRange(\n\t\tvaultConnector: IVaultConnector,\n\t\tconfig: Pick<IIotaConfig, \"coinType\" | \"vaultMnemonicId\" | \"vaultSeedId\">,\n\t\tidentity: string,\n\t\taccountIndex: number,\n\t\tinternal: boolean,\n\t\taddressIndex: number\n\t): Promise<{ privateKey: string; publicKey: string }[]> {\n\t\tconst keyPairChunkKey = Iota.buildAccountChunkKey(\n\t\t\tidentity,\n\t\t\taccountIndex,\n\t\t\tinternal,\n\t\t\taddressIndex\n\t\t);\n\n\t\tlet keyPairChunk: { privateKey: string; publicKey: string }[] | undefined;\n\t\ttry {\n\t\t\tkeyPairChunk =\n\t\t\t\tawait vaultConnector.getSecret<{ privateKey: string; publicKey: string }[]>(\n\t\t\t\t\tkeyPairChunkKey\n\t\t\t\t);\n\t\t} catch {}\n\n\t\tif (Is.empty(keyPairChunk)) {\n\t\t\tconst startChunkIndex = addressIndex % Iota._PRE_CALC_CHUNK_SIZE;\n\t\t\tconst endChunkIndex = startChunkIndex + Iota._PRE_CALC_CHUNK_SIZE;\n\n\t\t\tconst seed = await Iota.getSeed(vaultConnector, config, identity);\n\n\t\t\tkeyPairChunk = [];\n\n\t\t\tfor (let i = startChunkIndex; i < endChunkIndex; i++) {\n\t\t\t\tconst keyPair = Bip44.keyPair(\n\t\t\t\t\tseed,\n\t\t\t\t\tKeyType.Ed25519,\n\t\t\t\t\tconfig.coinType ?? Iota.DEFAULT_COIN_TYPE,\n\t\t\t\t\taccountIndex,\n\t\t\t\t\tinternal,\n\t\t\t\t\ti\n\t\t\t\t);\n\t\t\t\tkeyPairChunk.push({\n\t\t\t\t\tprivateKey: Converter.bytesToBase64(keyPair.privateKey),\n\t\t\t\t\tpublicKey: Converter.bytesToBase64(keyPair.publicKey)\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tawait vaultConnector.setSecret(keyPairChunkKey, keyPairChunk);\n\t\t}\n\n\t\treturn keyPairChunk;\n\t}\n\n\t/**\n\t * Get the key for storing a keypair chunk.\n\t * @param identity The identity to use.\n\t * @param accountIndex The account index.\n\t * @param internal Whether the address is internal or external.\n\t * @param addressIndex The address index to determine the chunk.\n\t * @returns The keypair chunk key.\n\t * @internal\n\t */\n\tprivate static buildAccountChunkKey(\n\t\tidentity: string,\n\t\taccountIndex: number,\n\t\tinternal: boolean,\n\t\taddressIndex: number\n\t): string {\n\t\treturn `${identity}/account/${accountIndex}/${internal ? \"1\" : \"0\"}/${addressIndex % Iota._PRE_CALC_CHUNK_SIZE}`;\n\t}\n}\n"]}
package/docs/changelog.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3-next.13](https://github.com/iotaledger/twin-dlt/compare/dlt-iota-v0.0.3-next.12...dlt-iota-v0.0.3-next.13) (2026-05-20)
4
+
5
+
6
+ ### Features
7
+
8
+ * update dependencies ([cd1bdef](https://github.com/iotaledger/twin-dlt/commit/cd1bdef487bb3cfe3ea57f584395ad2ae1105245))
9
+
10
+ ## [0.0.3-next.12](https://github.com/iotaledger/twin-dlt/compare/dlt-iota-v0.0.3-next.11...dlt-iota-v0.0.3-next.12) (2026-05-12)
11
+
12
+
13
+ ### Features
14
+
15
+ * use bip 44 path for chunks ([c5f8b1c](https://github.com/iotaledger/twin-dlt/commit/c5f8b1c659d33a117a8baa785f1981e557996f5f))
16
+
3
17
  ## [0.0.3-next.11](https://github.com/iotaledger/twin-dlt/compare/dlt-iota-v0.0.3-next.10...dlt-iota-v0.0.3-next.11) (2026-05-12)
4
18
 
5
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/dlt-iota",
3
- "version": "0.0.3-next.11",
3
+ "version": "0.0.3-next.13",
4
4
  "description": "IOTA distributed ledger utilities for clients, transactions, and contract operations.",
5
5
  "repository": {
6
6
  "type": "git",