@twin.org/dlt-iota 0.0.3-next.9 → 0.9.0
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/index.js +7 -3
- package/dist/es/index.js.map +1 -1
- package/dist/es/iota.js +356 -93
- package/dist/es/iota.js.map +1 -1
- package/dist/es/iotaIdentityUtils.js +2 -4
- package/dist/es/iotaIdentityUtils.js.map +1 -1
- package/dist/es/iotaSmartContractUtils.js +31 -27
- package/dist/es/iotaSmartContractUtils.js.map +1 -1
- package/dist/es/models/IAdminCapFields.js.map +1 -1
- package/dist/es/models/IGasStationExecuteResponse.js.map +1 -1
- package/dist/es/models/IIotaConfig.js.map +1 -1
- package/dist/es/models/IIotaControllerCapInfo.js.map +1 -1
- package/dist/es/models/IIotaResponseOptions.js.map +1 -1
- package/dist/es/models/IMigrationStateFields.js.map +1 -1
- package/dist/es/models/ISmartContractObject.js.map +1 -1
- package/dist/es/models/ITransactionSigner.js +2 -0
- package/dist/es/models/ITransactionSigner.js.map +1 -0
- package/dist/es/vaultJwkStorage.js +71 -0
- package/dist/es/vaultJwkStorage.js.map +1 -0
- package/dist/es/vaultJwtSigner.js +49 -0
- package/dist/es/vaultJwtSigner.js.map +1 -0
- package/dist/es/vaultSigner.js +60 -0
- package/dist/es/vaultSigner.js.map +1 -0
- package/dist/es/vaultTransactionSigner.js +74 -0
- package/dist/es/vaultTransactionSigner.js.map +1 -0
- package/dist/types/index.d.ts +7 -3
- package/dist/types/iota.d.ts +82 -53
- package/dist/types/iotaIdentityUtils.d.ts +2 -4
- package/dist/types/iotaSmartContractUtils.d.ts +18 -17
- package/dist/types/models/IAdminCapFields.d.ts +2 -2
- package/dist/types/models/IGasStationExecuteResponse.d.ts +1 -3
- package/dist/types/models/IIotaConfig.d.ts +5 -0
- package/dist/types/models/IIotaControllerCapInfo.d.ts +3 -6
- package/dist/types/models/IIotaResponseOptions.d.ts +1 -1
- package/dist/types/models/IMigrationStateFields.d.ts +2 -2
- package/dist/types/models/ISmartContractObject.d.ts +2 -2
- package/dist/types/models/ITransactionSigner.d.ts +27 -0
- package/dist/types/vaultJwkStorage.d.ts +50 -0
- package/dist/types/vaultJwtSigner.d.ts +26 -0
- package/dist/types/vaultSigner.d.ts +32 -0
- package/dist/types/vaultTransactionSigner.d.ts +39 -0
- package/docs/changelog.md +112 -0
- package/docs/examples.md +6 -13
- package/docs/reference/classes/Iota.md +325 -189
- package/docs/reference/classes/IotaIdentityUtils.md +2 -4
- package/docs/reference/classes/IotaSmartContractUtils.md +57 -40
- package/docs/reference/classes/VaultJwtSigner.md +71 -0
- package/docs/reference/classes/VaultSigner.md +106 -0
- package/docs/reference/classes/VaultTransactionSigner.md +122 -0
- package/docs/reference/index.md +4 -0
- package/docs/reference/interfaces/IAdminCapFields.md +2 -2
- package/docs/reference/interfaces/IGasStationExecuteResponse.md +1 -3
- package/docs/reference/interfaces/IIotaConfig.md +14 -0
- package/docs/reference/interfaces/IIotaControllerCapInfo.md +3 -6
- package/docs/reference/interfaces/IIotaResponseOptions.md +1 -1
- package/docs/reference/interfaces/IMigrationStateFields.md +2 -2
- package/docs/reference/interfaces/ISmartContractObject.md +2 -2
- package/docs/reference/interfaces/ITransactionSigner.md +67 -0
- package/locales/en.json +7 -1
- package/package.json +12 -12
package/dist/es/iota.js.map
CHANGED
|
@@ -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,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EACN,SAAS,EACT,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,YAAY,EAEZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,K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rD,CACD,CAAC;YAEF,OAAO,oBAAoB,CAAC;QAC7B,CAAC;QAED,OAAO,QAAQ,CAAC;IACjB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { IotaClient } from \"@iota/iota-sdk/client\";\nimport { Ed25519Keypair } from \"@iota/iota-sdk/keypairs/ed25519\";\nimport { Transaction } from \"@iota/iota-sdk/transactions\";\nimport {\n\tBaseError,\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tStringHelper,\n\ttype IError\n} from \"@twin.org/core\";\nimport { Bip39, Bip44, 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 inclusion timeout.\n\t * @internal\n\t */\n\tprivate static readonly _DEFAULT_INCLUSION_TIMEOUT: 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 * Get addresses for the identity.\n\t * @param seed The seed to use for generating addresses.\n\t * @param coinType The coin type to use.\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 getAddresses(\n\t\tseed: Uint8Array,\n\t\tcoinType: number,\n\t\taccountIndex: number,\n\t\tstartAddressIndex: number,\n\t\tcount: number,\n\t\tisInternal?: boolean\n\t): string[] {\n\t\tGuards.integer(Iota.CLASS_NAME, nameof(coinType), coinType);\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\n\t\tfor (let i = startAddressIndex; i < startAddressIndex + count; i++) {\n\t\t\t// Derive the keypair using the seed\n\t\t\tconst keyPair = Bip44.keyPair(\n\t\t\t\tseed,\n\t\t\t\tKeyType.Ed25519,\n\t\t\t\tcoinType ?? Iota.DEFAULT_COIN_TYPE,\n\t\t\t\taccountIndex,\n\t\t\t\tisInternal ?? false,\n\t\t\t\ti\n\t\t\t);\n\n\t\t\tconst keypair = Ed25519Keypair.fromSecretKey(keyPair.privateKey);\n\t\t\taddresses.push(keypair.getPublicKey().toIotaAddress());\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 seed The seed to use for generating the key pair.\n\t * @param coinType The coin type to use.\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 getKeyPair(\n\t\tseed: Uint8Array,\n\t\tcoinType: number,\n\t\taccountIndex: number,\n\t\taddressIndex: number,\n\t\tisInternal?: boolean\n\t): {\n\t\tprivateKey: Uint8Array;\n\t\tpublicKey: Uint8Array;\n\t} {\n\t\tGuards.integer(Iota.CLASS_NAME, nameof(coinType), coinType);\n\t\tGuards.integer(Iota.CLASS_NAME, nameof(accountIndex), accountIndex);\n\t\tGuards.integer(Iota.CLASS_NAME, nameof(addressIndex), addressIndex);\n\n\t\tconst keyPair = Bip44.keyPair(\n\t\t\tseed,\n\t\t\tKeyType.Ed25519,\n\t\t\tcoinType ?? Iota.DEFAULT_COIN_TYPE,\n\t\t\taccountIndex,\n\t\t\tisInternal ?? false,\n\t\t\taddressIndex\n\t\t);\n\n\t\treturn keyPair;\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 seed = await Iota.getSeed(config, vaultConnector, identity);\n\t\tconst addressKeyPair = Iota.findAddress(\n\t\t\tconfig.maxAddressScanRange ?? Iota._DEFAULT_SCAN_RANGE,\n\t\t\tconfig.coinType ?? Iota.DEFAULT_COIN_TYPE,\n\t\t\tseed,\n\t\t\towner\n\t\t);\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 * Get the seed from the vault.\n\t * @param config The configuration to use.\n\t * @param vaultConnector The vault connector to use.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @returns The seed.\n\t */\n\tpublic static async getSeed(\n\t\tconfig: IIotaConfig,\n\t\tvaultConnector: IVaultConnector,\n\t\tidentity: string\n\t): Promise<Uint8Array> {\n\t\ttry {\n\t\t\tconst seedBase64 = await vaultConnector.getSecret<string>(\n\t\t\t\tIota.buildSeedKey(identity, config.vaultSeedId)\n\t\t\t);\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\treturn Bip39.mnemonicToSeed(mnemonic);\n\t}\n\n\t/**\n\t * Find the address in the seed.\n\t * @param maxScanRange The maximum range to scan.\n\t * @param coinType The coin type to use.\n\t * @param seed The seed to use.\n\t * @param address The address to find.\n\t * @returns The address key pair.\n\t * @throws Error if the address is not found.\n\t */\n\tpublic static findAddress(\n\t\tmaxScanRange: number,\n\t\tcoinType: number,\n\t\tseed: Uint8Array,\n\t\taddress: string\n\t): {\n\t\taddress: string;\n\t\tprivateKey: Uint8Array;\n\t\tpublicKey: Uint8Array;\n\t} {\n\t\tfor (let i = 0; i < maxScanRange; i++) {\n\t\t\tconst addressKeyPair = Bip44.address(seed, KeyType.Ed25519, coinType, 0, false, i);\n\n\t\t\tif (addressKeyPair.address === address) {\n\t\t\t\treturn addressKeyPair;\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 * 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 */\n\tpublic 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 */\n\tpublic static buildSeedKey(identity: string, vaultSeedId?: string): string {\n\t\treturn `${identity}/${vaultSeedId ?? Iota.DEFAULT_SEED_SECRET_NAME}`;\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\\s+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 * 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 gasBudget = config.gasBudget ?? 50000000;\n\t\t\tconst gasReservation = await Iota.reserveGas(config, gasBudget);\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(gasBudget);\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 seed = await Iota.getSeed(config, vaultConnector, identity);\n\t\t\tconst addressKeyPair = Iota.findAddress(\n\t\t\t\tconfig.maxAddressScanRange ?? Iota._DEFAULT_SCAN_RANGE,\n\t\t\t\tconfig.coinType ?? Iota.DEFAULT_COIN_TYPE,\n\t\t\t\tseed,\n\t\t\t\towner\n\t\t\t);\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 * @param gasBudget The gas budget to reserve.\n\t * @returns The gas reservation result.\n\t */\n\tpublic static async reserveGas(\n\t\tconfig: IIotaConfig,\n\t\tgasBudget: number\n\t): 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: gasBudget,\n\t\t\t// eslint-disable-next-line camelcase\n\t\t\treserve_duration_secs: 30\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"]}
|
|
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,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EACN,SAAS,EACT,MAAM,EACN,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF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AAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;gBAC1F,MAAM,cAAc,CAAC,MAAM,CAC1B,OAAO,EACP,YAAY,CAAC,OAAO,EACpB,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,SAAS,CACjB,CAAC;gBACF,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;YAC7D,CAAC;QACF,CAAC;QAED,OAAO,UAAU,CAAC;IACnB,CAAC;IAED;;;;;;;;OAQG;IACK,MAAM,CAAC,mBAAmB,CACjC,QAAgB,EAChB,YAAoB,EACpB,QAAiB,EACjB,YAAoB;QAEpB,OAAO,oBAAoB,CAAC,YAAY,CACvC,QAAQ,EACR,SAAS,EACT,YAAY,CAAC,QAAQ,EAAE,EACvB,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EACpB,GAAG,YAAY,EAAE,CACjB,CAAC;IACH,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 { 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 { VaultConnectorHelper, VaultKeyType } from \"@twin.org/vault-models\";\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\";\nimport { VaultSigner } from \"./vaultSigner.js\";\nimport { VaultTransactionSigner } from \"./vaultTransactionSigner.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.getPublicKeys(\n\t\t\tvaultConnector,\n\t\t\tconfig,\n\t\t\tidentity,\n\t\t\taccountIndex,\n\t\t\tfalse,\n\t\t\t0,\n\t\t\tasync () => seed\n\t\t);\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\t\tlet cachedSeed: Uint8Array | undefined;\n\t\tconst seedProvider = async (): Promise<Uint8Array> => {\n\t\t\tcachedSeed ??= await Iota.getSeed(vaultConnector, config, identity);\n\t\t\treturn cachedSeed;\n\t\t};\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 publicKeys = await Iota.getPublicKeys(\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\tseedProvider\n\t\t\t);\n\t\t\tconst chunk = publicKeys.map((pk: string) =>\n\t\t\t\tIota.publicKeyToAddress(Converter.base64ToBytes(pk))\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 vault-backed transaction signer for the given identity and key indices.\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.\n\t * @param addressIndex The address index within the account.\n\t * @returns A VaultTransactionSigner for the specified key.\n\t */\n\tpublic static async getTransactionSigner(\n\t\tvaultConnector: IVaultConnector,\n\t\tconfig: IIotaConfig,\n\t\tidentity: string,\n\t\taccountIndex: number,\n\t\taddressIndex: number\n\t): Promise<VaultTransactionSigner> {\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 publicKeys = await Iota.getPublicKeys(\n\t\t\tvaultConnector,\n\t\t\tconfig,\n\t\t\tidentity,\n\t\t\taccountIndex,\n\t\t\tfalse,\n\t\t\taddressIndex,\n\t\t\tasync () => Iota.getSeed(vaultConnector, config, identity)\n\t\t);\n\n\t\tconst chunkStart = addressIndex - (addressIndex % Iota._PRE_CALC_CHUNK_SIZE);\n\t\tconst offsetInChunk = addressIndex - chunkStart;\n\t\tconst publicKey = Converter.base64ToBytes(publicKeys[offsetInChunk]);\n\t\tconst keyName = Iota.buildAddressKeyName(identity, accountIndex, false, addressIndex);\n\n\t\treturn new VaultTransactionSigner(vaultConnector, keyName, publicKey);\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 { keyName, publicKey } = await Iota.ensureOwnerKey(\n\t\t\tvaultConnector,\n\t\t\tconfig,\n\t\t\tidentity,\n\t\t\towner\n\t\t);\n\t\tconst signer = new VaultSigner(vaultConnector, keyName, publicKey);\n\n\t\ttry {\n\t\t\tconst response = await client.signAndExecuteTransaction({\n\t\t\t\ttransaction,\n\t\t\t\tsigner,\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 * 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 The dry run result including status, costs, events, and object changes.\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\tconst { keyName, publicKey } = await Iota.ensureOwnerKey(\n\t\t\t\tvaultConnector,\n\t\t\t\tconfig,\n\t\t\t\tidentity,\n\t\t\t\towner\n\t\t\t);\n\t\t\tconst signer = new VaultSigner(vaultConnector, keyName, publicKey);\n\t\t\tconst signature = await signer.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 * Create a transaction instance from the given bytes.\n\t * @param bytes The transaction bytes to create the transaction from.\n\t * @returns The transaction instance created from the given bytes.\n\t */\n\tpublic static transactionFromBytes(bytes: Uint8Array): IIotaTransaction {\n\t\treturn Transaction.from(bytes);\n\t}\n\n\t/**\n\t * Find the vault key name and public key for the given owner address.\n\t * Keys are individually registered in the vault by buildKeyPairRange, so no addKey is needed here.\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 owner The owner address whose key should be located.\n\t * @param accountIndex The account index to search.\n\t * @returns The vault key name and the public key bytes.\n\t * @internal\n\t */\n\tprivate static async ensureOwnerKey(\n\t\tvaultConnector: IVaultConnector,\n\t\tconfig: IIotaConfig,\n\t\tidentity: string,\n\t\towner: string,\n\t\taccountIndex: number = 0\n\t): Promise<{ keyName: string; publicKey: Uint8Array }> {\n\t\tconst scanRange = config.maxAddressScanRange ?? Iota._DEFAULT_SCAN_RANGE;\n\t\tlet cachedSeed: Uint8Array | undefined;\n\t\tconst seedProvider = async (): Promise<Uint8Array> => {\n\t\t\tcachedSeed ??= await Iota.getSeed(vaultConnector, config, identity);\n\t\t\treturn cachedSeed;\n\t\t};\n\n\t\tfor (let chunkStart = 0; chunkStart < scanRange; chunkStart += Iota._PRE_CALC_CHUNK_SIZE) {\n\t\t\tconst publicKeys = await Iota.getPublicKeys(\n\t\t\t\tvaultConnector,\n\t\t\t\tconfig,\n\t\t\t\tidentity,\n\t\t\t\taccountIndex,\n\t\t\t\tfalse,\n\t\t\t\tchunkStart,\n\t\t\t\tseedProvider\n\t\t\t);\n\t\t\tconst matchIndex = publicKeys.findIndex(\n\t\t\t\t(pk: string) => Iota.publicKeyToAddress(Converter.base64ToBytes(pk)) === owner\n\t\t\t);\n\t\t\tif (matchIndex >= 0) {\n\t\t\t\tconst addressIndex = chunkStart + matchIndex;\n\t\t\t\treturn {\n\t\t\t\t\tkeyName: Iota.buildAddressKeyName(identity, accountIndex, false, addressIndex),\n\t\t\t\t\tpublicKey: Converter.base64ToBytes(publicKeys[matchIndex])\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tthrow new GeneralError(Iota.CLASS_NAME, \"addressNotFound\", { address: owner });\n\t}\n\n\t/**\n\t * Get the seed from the vault, deriving it from the mnemonic if necessary.\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 bytes.\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 VaultConnectorHelper.buildKeyName(\n\t\t\tidentity,\n\t\t\tvaultMnemonicId ?? Iota.DEFAULT_MNEMONIC_SECRET_NAME\n\t\t);\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 VaultConnectorHelper.buildKeyName(\n\t\t\tidentity,\n\t\t\tvaultSeedId ?? Iota.DEFAULT_SEED_SECRET_NAME\n\t\t);\n\t}\n\n\t/**\n\t * Ensure a range of BIP44-derived keys are registered as individual vault keys and return their public keys.\n\t * If the first key of the range already exists the range is considered registered and only public keys are derived.\n\t * If not registered, all keys are derived and added to the vault before returning the public keys.\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 Any address index within the desired chunk; aligned internally.\n\t * @param seedProvider Callback invoked at most once per call to supply the seed when a chunk is not yet registered.\n\t * @returns The base64-encoded public keys for each address in the range.\n\t * @internal\n\t */\n\tprivate static async getPublicKeys(\n\t\tvaultConnector: IVaultConnector,\n\t\tconfig: Pick<IIotaConfig, \"coinType\">,\n\t\tidentity: string,\n\t\taccountIndex: number,\n\t\tinternal: boolean,\n\t\taddressIndex: number,\n\t\tseedProvider: () => Promise<Uint8Array>\n\t): Promise<string[]> {\n\t\tconst chunkStart = addressIndex - (addressIndex % Iota._PRE_CALC_CHUNK_SIZE);\n\t\tconst firstKeyName = Iota.buildAddressKeyName(identity, accountIndex, internal, chunkStart);\n\t\tconst publicKeys: string[] = [];\n\n\t\tif (await vaultConnector.keyExists(firstKeyName)) {\n\t\t\tfor (let i = chunkStart; i < chunkStart + Iota._PRE_CALC_CHUNK_SIZE; i++) {\n\t\t\t\tconst keyName = Iota.buildAddressKeyName(identity, accountIndex, internal, i);\n\t\t\t\tconst keyData = await vaultConnector.getKey(keyName, \"public\");\n\t\t\t\tif (!keyData.publicKey) {\n\t\t\t\t\tthrow new GeneralError(Iota.CLASS_NAME, \"missingPublicKey\", { keyName });\n\t\t\t\t}\n\t\t\t\tpublicKeys.push(Converter.bytesToBase64(keyData.publicKey));\n\t\t\t}\n\t\t} else {\n\t\t\tconst seed = await seedProvider();\n\t\t\tconst coinType = config.coinType ?? Iota.DEFAULT_COIN_TYPE;\n\n\t\t\tfor (let i = chunkStart; i < chunkStart + Iota._PRE_CALC_CHUNK_SIZE; i++) {\n\t\t\t\tconst keyName = Iota.buildAddressKeyName(identity, accountIndex, internal, i);\n\t\t\t\tconst keyPair = Bip44.keyPair(seed, KeyType.Ed25519, coinType, accountIndex, internal, i);\n\t\t\t\tawait vaultConnector.addKey(\n\t\t\t\t\tkeyName,\n\t\t\t\t\tVaultKeyType.Ed25519,\n\t\t\t\t\tkeyPair.privateKey,\n\t\t\t\t\tkeyPair.publicKey\n\t\t\t\t);\n\t\t\t\tpublicKeys.push(Converter.bytesToBase64(keyPair.publicKey));\n\t\t\t}\n\t\t}\n\n\t\treturn publicKeys;\n\t}\n\n\t/**\n\t * Build the vault key name for a specific derived address.\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.\n\t * @returns The vault key name.\n\t * @internal\n\t */\n\tprivate static buildAddressKeyName(\n\t\tidentity: string,\n\t\taccountIndex: number,\n\t\tinternal: boolean,\n\t\taddressIndex: number\n\t): string {\n\t\treturn VaultConnectorHelper.buildKeyName(\n\t\t\tidentity,\n\t\t\t\"account\",\n\t\t\taccountIndex.toString(),\n\t\t\tinternal ? \"1\" : \"0\",\n\t\t\t`${addressIndex}`\n\t\t);\n\t}\n}\n"]}
|
|
@@ -6,8 +6,7 @@ import { Ed25519Keypair } from "@iota/iota-sdk/keypairs/ed25519";
|
|
|
6
6
|
import { Base64Url, GeneralError, Guards, Is, NotFoundError } from "@twin.org/core";
|
|
7
7
|
import { Iota } from "./iota.js";
|
|
8
8
|
/**
|
|
9
|
-
* Utility class for resolving IOTA Identity on-chain objects
|
|
10
|
-
* the NFT mint_with_identity() Move contract function.
|
|
9
|
+
* Utility class for resolving IOTA Identity on-chain objects and controller tokens.
|
|
11
10
|
*/
|
|
12
11
|
export class IotaIdentityUtils {
|
|
13
12
|
/**
|
|
@@ -15,8 +14,7 @@ export class IotaIdentityUtils {
|
|
|
15
14
|
*/
|
|
16
15
|
static CLASS_NAME = "IotaIdentityUtils";
|
|
17
16
|
/**
|
|
18
|
-
*
|
|
19
|
-
* Returns the IDs needed to call mint_with_identity() on the NFT Move contract.
|
|
17
|
+
* Resolves the on-chain object IDs for an identity and its controller token.
|
|
20
18
|
* @param identityId The DID of the identity (e.g. "did:iota:testnet:0x...").
|
|
21
19
|
* @param controllerAddress The on-chain address of the controller wallet.
|
|
22
20
|
* @param client The IOTA client instance.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iotaIdentityUtils.js","sourceRoot":"","sources":["../../src/iotaIdentityUtils.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,cAAc,EACd,sBAAsB,EACtB,GAAG,EACH,WAAW,EAGX,aAAa,EACb,eAAe,EACf,OAAO,EACP,aAAa,EACb,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC
|
|
1
|
+
{"version":3,"file":"iotaIdentityUtils.js","sourceRoot":"","sources":["../../src/iotaIdentityUtils.ts"],"names":[],"mappings":"AAAA,gCAAgC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AAS,EACT,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAC/B,CAAC;QACH,CAAC;QAED,IAAI,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,aAAa,CAAC,iBAAiB,CAAC,UAAU,EAAE,kBAAkB,EAAE,UAAU,CAAC,CAAC;QACvF,CAAC;QAED,IAAI,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC;YAC7B,MAAM,IAAI,YAAY,CAAC,iBAAiB,CAAC,UAAU,EAAE,iBAAiB,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;QACzF,CAAC;QAED,IAAI,EAAE,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,aAAa,CAAC,iBAAiB,CAAC,UAAU,EAAE,yBAAyB,EAAE,UAAU,CAAC,CAAC;QAC9F,CAAC;QAED,OAAO;YACN,gBAAgB;YAChB,qBAAqB,EAAE,eAAe,CAAC,EAAE,EAAE;SAC3C,CAAC;IACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tIdentityClient,\n\tIdentityClientReadOnly,\n\tJwk,\n\tJwkMemStore,\n\tJwkType,\n\tJwsAlgorithm,\n\tKeyIdMemStore,\n\tOnChainIdentity,\n\tStorage,\n\tStorageSigner\n} from \"@iota/identity-wasm/node/index.js\";\nimport { decodeIotaPrivateKey } from \"@iota/iota-sdk/cryptography\";\nimport { Ed25519Keypair } from \"@iota/iota-sdk/keypairs/ed25519\";\nimport { Base64Url, GeneralError, Guards, Is, NotFoundError } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { Iota } from \"./iota.js\";\nimport type { IIotaClient } from \"./models/IIotaClient.js\";\nimport type { IIotaControllerCapInfo } from \"./models/IIotaControllerCapInfo.js\";\n\n/**\n * Utility class for resolving IOTA Identity on-chain objects and controller tokens.\n */\nexport class IotaIdentityUtils {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IotaIdentityUtils>();\n\n\t/**\n\t * Resolves the on-chain object IDs for an identity and its controller token.\n\t * @param identityId The DID of the identity (e.g. \"did:iota:testnet:0x...\").\n\t * @param controllerAddress The on-chain address of the controller wallet.\n\t * @param client The IOTA client instance.\n\t * @returns The identity object ID and controller token object ID.\n\t * @throws NotFoundError if the identity does not exist on-chain.\n\t * @throws GeneralError if the identity has been deleted or the controller token is not found.\n\t */\n\tpublic static async getControllerCapInfo(\n\t\tidentityId: string,\n\t\tcontrollerAddress: string,\n\t\tclient: IIotaClient\n\t): Promise<IIotaControllerCapInfo> {\n\t\tGuards.stringValue(IotaIdentityUtils.CLASS_NAME, nameof(identityId), identityId);\n\t\tGuards.stringValue(IotaIdentityUtils.CLASS_NAME, nameof(controllerAddress), controllerAddress);\n\t\tGuards.object(IotaIdentityUtils.CLASS_NAME, nameof(client), client);\n\n\t\t// Extract the Object ID from the DID — last colon-delimited segment.\n\t\t// On-chain DIDs include the 0x prefix in the segment; the check avoids double-prefixing.\n\t\tconst idParts = identityId.split(\":\");\n\t\tconst lastSegment = idParts[idParts.length - 1];\n\t\tconst identityObjectId = lastSegment.startsWith(\"0x\") ? lastSegment : `0x${lastSegment}`;\n\n\t\tlet onChain: OnChainIdentity | undefined;\n\t\tlet controllerToken: Awaited<ReturnType<OnChainIdentity[\"getControllerTokenForAddress\"]>>;\n\n\t\ttry {\n\t\t\t// IIotaClient and the IotaClient expected by identity-wasm resolve from different\n\t\t\t// module entry points (dist/esm vs dist/cjs). The protected `transport` field causes\n\t\t\t// a structural incompatibility even though the runtime types are identical.\n\t\t\tconst identityClientReadOnly = await IdentityClientReadOnly.create(\n\t\t\t\tclient as unknown as Parameters<(typeof IdentityClientReadOnly)[\"create\"]>[0]\n\t\t\t);\n\n\t\t\t// getControllerTokenForAddress requires IdentityClient even though the operation\n\t\t\t// is read-only — the signer is never called, only the embedded read-only client.\n\t\t\t// StorageSigner is used (rather than a plain object satisfying TransactionSigner\n\t\t\t// structurally) because IdentityClient.create() validates iotaPublicKeyBytes()\n\t\t\t// through an internal WASM code path that only accepts bytes from the library's\n\t\t\t// own signer implementations. Plain JS objects fail with \"Unsupported curve\"\n\t\t\t// even for valid Ed25519 keys because they take a different callback path.\n\t\t\tconst noOpKeypair = new Ed25519Keypair();\n\t\t\tconst rawPublic = noOpKeypair.getPublicKey().toRawBytes();\n\t\t\tconst { secretKey: rawPrivate } = decodeIotaPrivateKey(noOpKeypair.getSecretKey());\n\t\t\tconst noOpSigner = new StorageSigner(\n\t\t\t\tnew Storage(new JwkMemStore(), new KeyIdMemStore()),\n\t\t\t\t\"\",\n\t\t\t\tnew Jwk({\n\t\t\t\t\tkty: JwkType.Okp,\n\t\t\t\t\tcrv: \"Ed25519\",\n\t\t\t\t\talg: JwsAlgorithm.EdDSA,\n\t\t\t\t\tx: Base64Url.encode(rawPublic),\n\t\t\t\t\td: Base64Url.encode(rawPrivate)\n\t\t\t\t})\n\t\t\t);\n\t\t\tconst identityClient = await IdentityClient.create(identityClientReadOnly, noOpSigner);\n\n\t\t\tonChain = await OnChainIdentity.getById(identityObjectId, identityClient);\n\t\t\tif (!Is.undefined(onChain) && !onChain.hasDeletedDid()) {\n\t\t\t\tcontrollerToken = await onChain.getControllerTokenForAddress(\n\t\t\t\t\tcontrollerAddress,\n\t\t\t\t\tidentityClient\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIotaIdentityUtils.CLASS_NAME,\n\t\t\t\t\"getControllerCapInfoFailed\",\n\t\t\t\tundefined,\n\t\t\t\tIota.extractPayloadError(error)\n\t\t\t);\n\t\t}\n\n\t\tif (Is.undefined(onChain)) {\n\t\t\tthrow new NotFoundError(IotaIdentityUtils.CLASS_NAME, \"identityNotFound\", identityId);\n\t\t}\n\n\t\tif (onChain.hasDeletedDid()) {\n\t\t\tthrow new GeneralError(IotaIdentityUtils.CLASS_NAME, \"identityDeleted\", { identityId });\n\t\t}\n\n\t\tif (Is.undefined(controllerToken)) {\n\t\t\tthrow new NotFoundError(IotaIdentityUtils.CLASS_NAME, \"controllerTokenNotFound\", identityId);\n\t\t}\n\n\t\treturn {\n\t\t\tidentityObjectId,\n\t\t\tcontrollerCapObjectId: controllerToken.id()\n\t\t};\n\t}\n}\n"]}
|
|
@@ -6,7 +6,6 @@ import { GeneralError, Is, StringHelper } from "@twin.org/core";
|
|
|
6
6
|
import { Iota } from "./iota.js";
|
|
7
7
|
/**
|
|
8
8
|
* Utility class providing common smart contract operations for IOTA-based contracts.
|
|
9
|
-
* This class uses composition pattern to provide shared functionality without inheritance complexity.
|
|
10
9
|
*/
|
|
11
10
|
export class IotaSmartContractUtils {
|
|
12
11
|
/**
|
|
@@ -19,7 +18,6 @@ export class IotaSmartContractUtils {
|
|
|
19
18
|
* @param config The IOTA configuration.
|
|
20
19
|
* @param client The IOTA client instance.
|
|
21
20
|
* @param vaultConnector The vault connector for key management.
|
|
22
|
-
* @param walletConnector The wallet connector for address generation.
|
|
23
21
|
* @param logging Optional logging component.
|
|
24
22
|
* @param gasBudget The gas budget for the transaction.
|
|
25
23
|
* @param identity The identity of the controller with admin privileges.
|
|
@@ -27,16 +25,17 @@ export class IotaSmartContractUtils {
|
|
|
27
25
|
* @param namespace The contract namespace (e.g., "nft", "verifiable_storage").
|
|
28
26
|
* @param packageId The deployed package ID for the contract.
|
|
29
27
|
* @param deploymentConfig The deployment configuration containing object IDs.
|
|
28
|
+
* @param accountAddressIndex Optional account address index for the controller.
|
|
30
29
|
* @param walletAddressIndex Optional wallet address index for the controller.
|
|
31
30
|
* @returns Promise that resolves when migration is complete.
|
|
32
31
|
*/
|
|
33
|
-
static async migrateSmartContract(config, client, vaultConnector,
|
|
32
|
+
static async migrateSmartContract(config, client, vaultConnector, logging, gasBudget, identity, objectId, namespace, packageId, deploymentConfig, accountAddressIndex, walletAddressIndex) {
|
|
34
33
|
try {
|
|
35
34
|
const txb = new Transaction();
|
|
36
35
|
txb.setGasBudget(gasBudget);
|
|
37
36
|
const moduleName = IotaSmartContractUtils.getModuleName(namespace);
|
|
38
37
|
// Get admin address for the transaction
|
|
39
|
-
const adminAddress = await IotaSmartContractUtils.getPackageControllerAddress(
|
|
38
|
+
const adminAddress = await IotaSmartContractUtils.getPackageControllerAddress(vaultConnector, config, identity, accountAddressIndex, walletAddressIndex);
|
|
40
39
|
// Get the required object IDs from deployment config
|
|
41
40
|
const { adminCapId, migrationStateId } = await IotaSmartContractUtils.getContractObjectIds(client, namespace, config.network, deploymentConfig, packageId, adminAddress);
|
|
42
41
|
txb.moveCall({
|
|
@@ -62,23 +61,23 @@ export class IotaSmartContractUtils {
|
|
|
62
61
|
* @param config The IOTA configuration.
|
|
63
62
|
* @param client The IOTA client instance.
|
|
64
63
|
* @param vaultConnector The vault connector for key management.
|
|
65
|
-
* @param walletConnector The wallet connector for address generation.
|
|
66
64
|
* @param logging Optional logging component.
|
|
67
65
|
* @param gasBudget The gas budget for the transaction.
|
|
68
66
|
* @param identity The identity of the controller with admin privileges.
|
|
69
67
|
* @param namespace The contract namespace (e.g., "nft", "verifiable_storage").
|
|
70
68
|
* @param packageId The deployed package ID for the contract.
|
|
71
69
|
* @param deploymentConfig The deployment configuration containing object IDs.
|
|
70
|
+
* @param accountAddressIndex Optional account address index for the controller.
|
|
72
71
|
* @param walletAddressIndex Optional wallet address index for the controller.
|
|
73
72
|
* @returns Promise that resolves when migration is enabled.
|
|
74
73
|
*/
|
|
75
|
-
static async enableMigration(config, client, vaultConnector,
|
|
74
|
+
static async enableMigration(config, client, vaultConnector, logging, gasBudget, identity, namespace, packageId, deploymentConfig, accountAddressIndex, walletAddressIndex) {
|
|
76
75
|
try {
|
|
77
76
|
const txb = new Transaction();
|
|
78
77
|
txb.setGasBudget(gasBudget);
|
|
79
78
|
const moduleName = IotaSmartContractUtils.getModuleName(namespace);
|
|
80
79
|
// Get admin address for the transaction
|
|
81
|
-
const adminAddress = await IotaSmartContractUtils.getPackageControllerAddress(
|
|
80
|
+
const adminAddress = await IotaSmartContractUtils.getPackageControllerAddress(vaultConnector, config, identity, accountAddressIndex, walletAddressIndex);
|
|
82
81
|
// Get the required object IDs from deployment config
|
|
83
82
|
const { adminCapId, migrationStateId } = await IotaSmartContractUtils.getContractObjectIds(client, namespace, config.network, deploymentConfig, packageId, adminAddress);
|
|
84
83
|
txb.moveCall({
|
|
@@ -103,23 +102,23 @@ export class IotaSmartContractUtils {
|
|
|
103
102
|
* @param config The IOTA configuration.
|
|
104
103
|
* @param client The IOTA client instance.
|
|
105
104
|
* @param vaultConnector The vault connector for key management.
|
|
106
|
-
* @param walletConnector The wallet connector for address generation.
|
|
107
105
|
* @param logging Optional logging component.
|
|
108
106
|
* @param gasBudget The gas budget for the transaction.
|
|
109
107
|
* @param identity The identity of the controller with admin privileges.
|
|
110
108
|
* @param namespace The contract namespace (e.g., "nft", "verifiable_storage").
|
|
111
109
|
* @param packageId The deployed package ID for the contract.
|
|
112
110
|
* @param deploymentConfig The deployment configuration containing object IDs.
|
|
111
|
+
* @param accountAddressIndex Optional account address index for the controller.
|
|
113
112
|
* @param walletAddressIndex Optional wallet address index for the controller.
|
|
114
113
|
* @returns Promise that resolves when migration is disabled.
|
|
115
114
|
*/
|
|
116
|
-
static async disableMigration(config, client, vaultConnector,
|
|
115
|
+
static async disableMigration(config, client, vaultConnector, logging, gasBudget, identity, namespace, packageId, deploymentConfig, accountAddressIndex, walletAddressIndex) {
|
|
117
116
|
try {
|
|
118
117
|
const txb = new Transaction();
|
|
119
118
|
txb.setGasBudget(gasBudget);
|
|
120
119
|
const moduleName = IotaSmartContractUtils.getModuleName(namespace);
|
|
121
120
|
// Get admin address for the transaction
|
|
122
|
-
const adminAddress = await IotaSmartContractUtils.getPackageControllerAddress(
|
|
121
|
+
const adminAddress = await IotaSmartContractUtils.getPackageControllerAddress(vaultConnector, config, identity, accountAddressIndex, walletAddressIndex);
|
|
123
122
|
// Get the required object IDs from deployment config
|
|
124
123
|
const { adminCapId, migrationStateId } = await IotaSmartContractUtils.getContractObjectIds(client, namespace, config.network, deploymentConfig, packageId, adminAddress);
|
|
125
124
|
txb.moveCall({
|
|
@@ -143,18 +142,19 @@ export class IotaSmartContractUtils {
|
|
|
143
142
|
* Check if migration is currently active for a smart contract.
|
|
144
143
|
* @param config The IOTA configuration.
|
|
145
144
|
* @param client The IOTA client instance.
|
|
145
|
+
* @param vaultConnector The vault connector for key management.
|
|
146
146
|
* @param namespace The contract namespace (e.g., "nft", "verifiable_storage").
|
|
147
147
|
* @param packageId The deployed package ID for the contract.
|
|
148
148
|
* @param deploymentConfig The deployment configuration containing object IDs.
|
|
149
149
|
* @param identity The identity for MigrationState discovery.
|
|
150
|
-
* @param
|
|
151
|
-
* @param walletAddressIndex Optional wallet address index.
|
|
150
|
+
* @param accountAddressIndex Optional account address index for the controller.
|
|
151
|
+
* @param walletAddressIndex Optional wallet address index for the controller.
|
|
152
152
|
* @returns True if migration is enabled, false otherwise.
|
|
153
153
|
*/
|
|
154
|
-
static async isMigrationActive(config, client, namespace, packageId, deploymentConfig, identity,
|
|
154
|
+
static async isMigrationActive(config, client, vaultConnector, namespace, packageId, deploymentConfig, identity, accountAddressIndex, walletAddressIndex) {
|
|
155
155
|
try {
|
|
156
156
|
// Get admin address for discovery
|
|
157
|
-
const adminAddress = await IotaSmartContractUtils.getPackageControllerAddress(
|
|
157
|
+
const adminAddress = await IotaSmartContractUtils.getPackageControllerAddress(vaultConnector, config, identity, accountAddressIndex, walletAddressIndex);
|
|
158
158
|
// Get the migration state ID
|
|
159
159
|
const { migrationStateId } = await IotaSmartContractUtils.getContractObjectIds(client, namespace, config.network, deploymentConfig, packageId, adminAddress);
|
|
160
160
|
const migrationStateResponse = await client.getObject({
|
|
@@ -184,14 +184,15 @@ export class IotaSmartContractUtils {
|
|
|
184
184
|
* Get the current contract version from the deployed smart contract.
|
|
185
185
|
* @param config The IOTA configuration.
|
|
186
186
|
* @param client The IOTA client instance.
|
|
187
|
+
* @param vaultConnector The vault connector for key management.
|
|
187
188
|
* @param namespace The contract namespace (e.g., "nft", "verifiable_storage").
|
|
188
189
|
* @param packageId The deployed package ID for the contract.
|
|
189
190
|
* @param identity The identity for package controller address.
|
|
190
|
-
* @param
|
|
191
|
-
* @param walletAddressIndex Optional wallet address index.
|
|
191
|
+
* @param accountAddressIndex Optional account address index for the controller.
|
|
192
|
+
* @param walletAddressIndex Optional wallet address index for the controller.
|
|
192
193
|
* @returns The current version number of the contract.
|
|
193
194
|
*/
|
|
194
|
-
static async getCurrentContractVersion(config, client, namespace, packageId, identity,
|
|
195
|
+
static async getCurrentContractVersion(config, client, vaultConnector, namespace, packageId, identity, accountAddressIndex, walletAddressIndex) {
|
|
195
196
|
try {
|
|
196
197
|
const tx = new Transaction();
|
|
197
198
|
const moduleName = IotaSmartContractUtils.getModuleName(namespace);
|
|
@@ -199,7 +200,7 @@ export class IotaSmartContractUtils {
|
|
|
199
200
|
target: `${packageId}::${moduleName}::get_current_version`,
|
|
200
201
|
arguments: []
|
|
201
202
|
});
|
|
202
|
-
const controllerAddress = await IotaSmartContractUtils.getPackageControllerAddress(
|
|
203
|
+
const controllerAddress = await IotaSmartContractUtils.getPackageControllerAddress(vaultConnector, config, identity, accountAddressIndex, walletAddressIndex);
|
|
203
204
|
const result = await client.devInspectTransactionBlock({
|
|
204
205
|
sender: controllerAddress,
|
|
205
206
|
transactionBlock: tx
|
|
@@ -234,19 +235,20 @@ export class IotaSmartContractUtils {
|
|
|
234
235
|
* Validate that an object version is compatible with the current contract.
|
|
235
236
|
* @param config The IOTA configuration.
|
|
236
237
|
* @param client The IOTA client instance.
|
|
238
|
+
* @param vaultConnector The vault connector for key management.
|
|
237
239
|
* @param namespace The contract namespace (e.g., "nft", "verifiable_storage").
|
|
238
240
|
* @param packageId The deployed package ID for the contract.
|
|
239
241
|
* @param identity The identity for version checking.
|
|
240
242
|
* @param objectId The object ID to validate.
|
|
241
|
-
* @param walletConnector The wallet connector for address generation.
|
|
242
243
|
* @param versionExtractor Function to extract version from object content.
|
|
243
|
-
* @param
|
|
244
|
+
* @param accountAddressIndex Optional account address index for the controller.
|
|
245
|
+
* @param walletAddressIndex Optional wallet address index for the controller.
|
|
244
246
|
* @returns True if the object version is compatible, false otherwise.
|
|
245
247
|
*/
|
|
246
|
-
static async validateObjectVersion(config, client, namespace, packageId, identity, objectId,
|
|
248
|
+
static async validateObjectVersion(config, client, vaultConnector, namespace, packageId, identity, objectId, versionExtractor, accountAddressIndex, walletAddressIndex) {
|
|
247
249
|
try {
|
|
248
250
|
// Get current contract version
|
|
249
|
-
const currentVersion = await IotaSmartContractUtils.getCurrentContractVersion(config, client, namespace, packageId, identity,
|
|
251
|
+
const currentVersion = await IotaSmartContractUtils.getCurrentContractVersion(config, client, vaultConnector, namespace, packageId, identity, accountAddressIndex, walletAddressIndex);
|
|
250
252
|
// Get object version
|
|
251
253
|
const objectResponse = await client.getObject({
|
|
252
254
|
id: objectId,
|
|
@@ -286,15 +288,17 @@ export class IotaSmartContractUtils {
|
|
|
286
288
|
}
|
|
287
289
|
/**
|
|
288
290
|
* Get the package controller address for transactions.
|
|
289
|
-
* @param
|
|
291
|
+
* @param vaultConnector The vault connector to use.
|
|
292
|
+
* @param config The IOTA configuration.
|
|
290
293
|
* @param identity The identity to use.
|
|
291
|
-
* @param
|
|
294
|
+
* @param accountAddressIndex Optional account address index to use.
|
|
295
|
+
* @param walletAddressIndex Optional address index to use.
|
|
292
296
|
* @returns The controller address.
|
|
293
297
|
* @internal
|
|
294
298
|
*/
|
|
295
|
-
static async getPackageControllerAddress(
|
|
296
|
-
const
|
|
297
|
-
return
|
|
299
|
+
static async getPackageControllerAddress(vaultConnector, config, identity, accountAddressIndex, walletAddressIndex) {
|
|
300
|
+
const address = await Iota.getAddress(vaultConnector, config, identity, accountAddressIndex ?? 0, walletAddressIndex ?? 0);
|
|
301
|
+
return address;
|
|
298
302
|
}
|
|
299
303
|
/**
|
|
300
304
|
* Get contract object IDs (AdminCap and MigrationState) from deployment config with fallback discovery.
|