@twin.org/dlt-iota 0.0.3-next.4 → 0.0.3-next.6
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/README.md +4 -6
- package/dist/es/index.js +5 -0
- package/dist/es/index.js.map +1 -1
- package/dist/es/iota.js +7 -0
- package/dist/es/iota.js.map +1 -1
- package/dist/es/iotaIdentityUtils.js +77 -0
- package/dist/es/iotaIdentityUtils.js.map +1 -0
- package/dist/es/models/IIotaClient.js +2 -0
- package/dist/es/models/IIotaClient.js.map +1 -0
- package/dist/es/models/IIotaControllerCapInfo.js +4 -0
- package/dist/es/models/IIotaControllerCapInfo.js.map +1 -0
- package/dist/es/models/IIotaTransaction.js +2 -0
- package/dist/es/models/IIotaTransaction.js.map +1 -0
- package/dist/es/models/IIotaTransactionBlockResponse.js +2 -0
- package/dist/es/models/IIotaTransactionBlockResponse.js.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/iota.d.ts +18 -12
- package/dist/types/iotaIdentityUtils.d.ts +23 -0
- package/dist/types/models/IIotaClient.d.ts +5 -0
- package/dist/types/models/IIotaControllerCapInfo.d.ts +16 -0
- package/dist/types/models/IIotaTransaction.d.ts +5 -0
- package/dist/types/models/IIotaTransactionBlockResponse.d.ts +5 -0
- package/docs/changelog.md +15 -1
- package/docs/examples.md +420 -1
- package/docs/reference/classes/Iota.md +14 -0
- package/docs/reference/classes/IotaIdentityUtils.md +65 -0
- package/docs/reference/index.md +5 -0
- package/docs/reference/interfaces/IIotaConfig.md +0 -42
- package/docs/reference/interfaces/IIotaControllerCapInfo.md +22 -0
- package/docs/reference/interfaces/IIotaResponseOptions.md +0 -6
- package/docs/reference/type-aliases/IIotaClient.md +5 -0
- package/docs/reference/type-aliases/IIotaTransaction.md +5 -0
- package/docs/reference/type-aliases/IIotaTransactionBlockResponse.md +5 -0
- package/locales/en.json +7 -0
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# TWIN DLT IOTA
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package provides utilities for integrating applications with IOTA distributed ledger capabilities, including client construction, transaction submission, sponsored transaction support, and smart contract migration helpers. It is intended for services that need a reliable and repeatable approach to ledger operations without rebuilding common primitives.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -8,14 +8,12 @@ DLT helpers for use with IOTA.
|
|
|
8
8
|
npm install @twin.org/dlt-iota
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Docker
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
The simplest way to set up the testing environment using our unified container:
|
|
13
|
+
To perform testing of this component it may be necessary to launch a local instance to communicate with.
|
|
16
14
|
|
|
17
15
|
```shell
|
|
18
|
-
docker run -d --name twin-
|
|
16
|
+
docker run -d --name twin-dlt-iota -p 9527:9527 -p 6379:6379 -p 9184:9184 twinfoundation/twin-gas-station-test:latest
|
|
19
17
|
```
|
|
20
18
|
|
|
21
19
|
## Examples
|
package/dist/es/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2024 IOTA Stiftung.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
3
|
export * from "./iota.js";
|
|
4
|
+
export * from "./iotaIdentityUtils.js";
|
|
4
5
|
export * from "./iotaSmartContractUtils.js";
|
|
5
6
|
export * from "./models/IAdminCapFields.js";
|
|
6
7
|
export * from "./models/IContractData.js";
|
|
@@ -9,6 +10,10 @@ export * from "./models/IGasStationConfig.js";
|
|
|
9
10
|
export * from "./models/IGasStationExecuteResponse.js";
|
|
10
11
|
export * from "./models/IGasStationReserveGasResponse.js";
|
|
11
12
|
export * from "./models/IGasStationReserveGasResult.js";
|
|
13
|
+
export * from "./models/IIotaClient.js";
|
|
14
|
+
export * from "./models/IIotaControllerCapInfo.js";
|
|
15
|
+
export * from "./models/IIotaTransaction.js";
|
|
16
|
+
export * from "./models/IIotaTransactionBlockResponse.js";
|
|
12
17
|
export * from "./models/IIotaConfig.js";
|
|
13
18
|
export * from "./models/IIotaDryRun.js";
|
|
14
19
|
export * from "./models/IIotaResponseOptions.js";
|
package/dist/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,WAAW,CAAC;AAC1B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wCAAwC,CAAC;AACvD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,yCAAyC,CAAC;AACxD,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,uCAAuC,CAAC;AACtD,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./iota.js\";\nexport * from \"./iotaSmartContractUtils.js\";\nexport * from \"./models/IAdminCapFields.js\";\nexport * from \"./models/IContractData.js\";\nexport * from \"./models/IGasReservationResult.js\";\nexport * from \"./models/IGasStationConfig.js\";\nexport * from \"./models/IGasStationExecuteResponse.js\";\nexport * from \"./models/IGasStationReserveGasResponse.js\";\nexport * from \"./models/IGasStationReserveGasResult.js\";\nexport * from \"./models/IIotaConfig.js\";\nexport * from \"./models/IIotaDryRun.js\";\nexport * from \"./models/IIotaResponseOptions.js\";\nexport * from \"./models/IMigrationStateFields.js\";\nexport * from \"./models/ISmartContractDeployments.js\";\nexport * from \"./models/ISmartContractObject.js\";\nexport * from \"./models/networkTypes.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,WAAW,CAAC;AAC1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wCAAwC,CAAC;AACvD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,yCAAyC,CAAC;AACxD,cAAc,yBAAyB,CAAC;AACxC,cAAc,oCAAoC,CAAC;AACnD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,uCAAuC,CAAC;AACtD,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./iota.js\";\nexport * from \"./iotaIdentityUtils.js\";\nexport * from \"./iotaSmartContractUtils.js\";\nexport * from \"./models/IAdminCapFields.js\";\nexport * from \"./models/IContractData.js\";\nexport * from \"./models/IGasReservationResult.js\";\nexport * from \"./models/IGasStationConfig.js\";\nexport * from \"./models/IGasStationExecuteResponse.js\";\nexport * from \"./models/IGasStationReserveGasResponse.js\";\nexport * from \"./models/IGasStationReserveGasResult.js\";\nexport * from \"./models/IIotaClient.js\";\nexport * from \"./models/IIotaControllerCapInfo.js\";\nexport * from \"./models/IIotaTransaction.js\";\nexport * from \"./models/IIotaTransactionBlockResponse.js\";\nexport * from \"./models/IIotaConfig.js\";\nexport * from \"./models/IIotaDryRun.js\";\nexport * from \"./models/IIotaResponseOptions.js\";\nexport * from \"./models/IMigrationStateFields.js\";\nexport * from \"./models/ISmartContractDeployments.js\";\nexport * from \"./models/ISmartContractObject.js\";\nexport * from \"./models/networkTypes.js\";\n"]}
|
package/dist/es/iota.js
CHANGED
|
@@ -96,6 +96,13 @@ export class Iota {
|
|
|
96
96
|
const keyPair = Bip44.keyPair(seed, KeyType.Ed25519, coinType ?? Iota.DEFAULT_COIN_TYPE, accountIndex, isInternal ?? false, addressIndex);
|
|
97
97
|
return keyPair;
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Create a new transaction instance.
|
|
101
|
+
* @returns A new transaction instance.
|
|
102
|
+
*/
|
|
103
|
+
static createTransaction() {
|
|
104
|
+
return new Transaction();
|
|
105
|
+
}
|
|
99
106
|
/**
|
|
100
107
|
* Prepare and post a transaction.
|
|
101
108
|
* @param config The configuration.
|
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,EAAqC,MAAM,uBAAuB,CAAC;AACtF,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,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAIzD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AASxD;;GAEG;AACH,MAAM,OAAO,IAAI;IAChB;;OAEG;IACI,MAAM,CAAU,4BAA4B,GAAW,UAAU,CAAC;IAEzE;;OAEG;IACI,MAAM,CAAU,wBAAwB,GAAW,MAAM,CAAC;IAEjE;;OAEG;IACI,MAAM,CAAU,iBAAiB,GAAW,I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OAAO;YACN,MAAM,EAAE,WAAW,CAAC,iBAAiB;YACrC,OAAO,EAAE,WAAsB;YAC/B,MAAM,EAAE,EAAE;YACV,aAAa,EAAE,EAAE;YACjB,uBAAuB,EAAE,IAAI;SACc,CAAC;IAC9C,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM,CAAC,KAAK,CAAC,sCAAsC,CACzD,MAAmB,EACnB,MAAkB,EAClB,aAAqB,EACrB,gBAA4B,EAC5B,aAAqB,EACrB,OAA8B;QAE9B,MAAM,CAAC,MAAM,CAAoB,IAAI,CAAC,UAAU,uBAA6B,MAAM,CAAC,UAAU,CAAC,CAAC;QAEhG,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,4BAA4B,CACvD,MAAM,EACN,aAAa,EACb,gBAAgB,EAChB,aAAa,CACb,CAAC;QAEF,IAAI,OAAO,EAAE,mBAAmB,IAAI,IAAI,EAAE,CAAC;YAC1C,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,8BAA8B,CACrE,MAAM,EACN,QAAQ,CAAC,MAAM,EACf,MAAM,EACN;gBACC,WAAW,EAAE,OAAO,EAAE,WAAW,IAAI,IAAI;gBACzC,UAAU,EAAE,OAAO,EAAE,UAAU,IAAI,IAAI;gBACvC,iBAAiB,EAAE,OAAO,EAAE,iBAAiB,IAAI,IAAI;aACrD,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, type IotaTransactionBlockResponse } 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 { IIotaConfig } from \"./models/IIotaConfig.js\";\nimport type { IIotaDryRun } from \"./models/IIotaDryRun.js\";\nimport type { IIotaResponseOptions } from \"./models/IIotaResponseOptions.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 * Default scan range.\n\t */\n\tpublic static readonly DEFAULT_SCAN_RANGE: number = 1000;\n\n\t/**\n\t * Default inclusion timeout.\n\t */\n\tpublic static readonly DEFAULT_INCLUSION_TIMEOUT: number = 60;\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 * 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): IotaClient {\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 * 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: IotaClient,\n\t\tsource: string,\n\t\tamount: bigint,\n\t\trecipient: string,\n\t\toptions?: IIotaResponseOptions\n\t): Promise<IotaTransactionBlockResponse> {\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: IotaClient,\n\t\towner: string,\n\t\ttransaction: Transaction,\n\t\toptions?: IIotaResponseOptions\n\t): Promise<IotaTransactionBlockResponse> {\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: IotaClient,\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: IotaClient,\n\t\tlogging: ILoggingComponent | undefined,\n\t\ttxb: Transaction,\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: IotaClient,\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<IotaTransactionBlockResponse> {\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: IotaClient,\n\t\towner: string,\n\t\ttransaction: Transaction,\n\t\toptions?: IIotaResponseOptions\n\t): Promise<IotaTransactionBlockResponse> {\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<IotaTransactionBlockResponse> {\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 IotaTransactionBlockResponse;\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: IotaClient,\n\t\treservationId: number,\n\t\ttransactionBytes: Uint8Array,\n\t\tuserSignature: string,\n\t\toptions?: IIotaResponseOptions\n\t): Promise<IotaTransactionBlockResponse> {\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,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,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAIzD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAYxD;;GAEG;AACH,MAAM,OAAO,IAAI;IAChB;;OAEG;IACI,MAAM,CAAU,4BAA4B,GAAW,UAAU,CAAC;IAEzE;;OAEG;IACI,MAAM,CAAU,wBAAwB,GAAW,MAAM,CAAC;IAEjE;;OAEG;IACI,MAAM,CAAU,iBAAiB,GAAW,IAAI,CAAC;IAExD;;OAEG;IACI,MAAM,CAAU,kBAAkB,GAAW,IAAI,CAAC;IAEzD;;OAEG;IACI,MAAM,CAAU,yBAAyB,GAAW,EAAE,CAAC;IAE9D;;OAEG;IACI,MAAM,CAAU,UAAU,UAA0B;IAE3D;;;;OAIG;IACI,MAAM,CAAC,YAAY,CAAC,MAAmB;QAC7C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,YAAkB,MAAM,CAAC,CAAC;QACvD,MAAM,CAAC,MAAM,C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AAmB,EACnB,MAAmB,EACnB,aAAqB,EACrB,gBAA4B,EAC5B,aAAqB,EACrB,OAA8B;QAE9B,MAAM,CAAC,MAAM,CAAoB,IAAI,CAAC,UAAU,uBAA6B,MAAM,CAAC,UAAU,CAAC,CAAC;QAEhG,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,4BAA4B,CACvD,MAAM,EACN,aAAa,EACb,gBAAgB,EAChB,aAAa,CACb,CAAC;QAEF,IAAI,OAAO,EAAE,mBAAmB,IAAI,IAAI,EAAE,CAAC;YAC1C,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,8BAA8B,CACrE,MAAM,EACN,QAAQ,CAAC,MAAM,EACf,MAAM,EACN;gBACC,WAAW,EAAE,OAAO,EAAE,WAAW,IAAI,IAAI;gBACzC,UAAU,EAAE,OAAO,EAAE,UAAU,IAAI,IAAI;gBACvC,iBAAiB,EAAE,OAAO,EAAE,iBAAiB,IAAI,IAAI;aACrD,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 * Default scan range.\n\t */\n\tpublic static readonly DEFAULT_SCAN_RANGE: number = 1000;\n\n\t/**\n\t * Default inclusion timeout.\n\t */\n\tpublic static readonly DEFAULT_INCLUSION_TIMEOUT: number = 60;\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 * 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"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { IdentityClient, IdentityClientReadOnly, OnChainIdentity } from "@iota/identity-wasm/node/index.js";
|
|
4
|
+
import { Ed25519PublicKey } from "@iota/iota-sdk/keypairs/ed25519";
|
|
5
|
+
import { GeneralError, Guards, Is, NotFoundError } from "@twin.org/core";
|
|
6
|
+
import { Iota } from "./iota.js";
|
|
7
|
+
/**
|
|
8
|
+
* Utility class for resolving IOTA Identity on-chain objects required by
|
|
9
|
+
* the NFT mint_with_identity() Move contract function.
|
|
10
|
+
*/
|
|
11
|
+
export class IotaIdentityUtils {
|
|
12
|
+
/**
|
|
13
|
+
* Runtime name for the class.
|
|
14
|
+
*/
|
|
15
|
+
static CLASS_NAME = "IotaIdentityUtils";
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the on-chain object IDs for an identity and its controller token.
|
|
18
|
+
* Returns the IDs needed to call mint_with_identity() on the NFT Move contract.
|
|
19
|
+
* @param identityId The DID of the identity (e.g. "did:iota:testnet:0x...").
|
|
20
|
+
* @param controllerAddress The on-chain address of the controller wallet.
|
|
21
|
+
* @param client The IOTA client instance.
|
|
22
|
+
* @returns The identity object ID and controller token object ID.
|
|
23
|
+
* @throws NotFoundError if the identity does not exist on-chain.
|
|
24
|
+
* @throws GeneralError if the identity has been deleted or the controller token is not found.
|
|
25
|
+
*/
|
|
26
|
+
static async getControllerCapInfo(identityId, controllerAddress, client) {
|
|
27
|
+
Guards.stringValue(IotaIdentityUtils.CLASS_NAME, "identityId", identityId);
|
|
28
|
+
Guards.stringValue(IotaIdentityUtils.CLASS_NAME, "controllerAddress", controllerAddress);
|
|
29
|
+
// Extract the Object ID from the DID — last colon-delimited segment, prefixed with 0x.
|
|
30
|
+
// IOTA DIDs have the format did:iota:<network>:<hex> where <hex> has no 0x prefix.
|
|
31
|
+
const idParts = identityId.split(":");
|
|
32
|
+
const identityObjectId = `0x${idParts[idParts.length - 1]}`;
|
|
33
|
+
let onChain;
|
|
34
|
+
let controllerToken;
|
|
35
|
+
try {
|
|
36
|
+
// Both are IotaClient@1.11.0 but TypeScript resolves them from different module
|
|
37
|
+
// entry points (dist/esm vs dist/cjs). The protected `transport` field causes a
|
|
38
|
+
// class-compatibility failure even though the runtime types are identical.
|
|
39
|
+
// Casting through the function's own parameter type keeps this refactor-safe.
|
|
40
|
+
const identityClientReadOnly = await IdentityClientReadOnly.create(client);
|
|
41
|
+
// getControllerTokenForAddress requires IdentityClient even though the operation is
|
|
42
|
+
// read-only — the signer is never called, only the embedded CoreClientReadOnly is
|
|
43
|
+
// used. TransactionSigner is a structural interface, so a minimal object literal
|
|
44
|
+
// that satisfies its shape avoids importing the heavyweight JWK store machinery.
|
|
45
|
+
const noOpSigner = {
|
|
46
|
+
sign: async (_txData) => {
|
|
47
|
+
throw new GeneralError(IotaIdentityUtils.CLASS_NAME, "unexpectedSignerCall", undefined);
|
|
48
|
+
},
|
|
49
|
+
publicKey: async () => new Ed25519PublicKey(new Uint8Array(32)),
|
|
50
|
+
iotaPublicKeyBytes: async () => new Uint8Array(32),
|
|
51
|
+
keyId: () => ""
|
|
52
|
+
};
|
|
53
|
+
const identityClient = await IdentityClient.create(identityClientReadOnly, noOpSigner);
|
|
54
|
+
onChain = await OnChainIdentity.getById(identityObjectId, identityClient);
|
|
55
|
+
if (!Is.undefined(onChain) && !onChain.hasDeletedDid()) {
|
|
56
|
+
controllerToken = await onChain.getControllerTokenForAddress(controllerAddress, identityClient);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
throw new GeneralError(IotaIdentityUtils.CLASS_NAME, "getControllerCapInfoFailed", undefined, Iota.extractPayloadError(error));
|
|
61
|
+
}
|
|
62
|
+
if (Is.undefined(onChain)) {
|
|
63
|
+
throw new NotFoundError(IotaIdentityUtils.CLASS_NAME, "identityNotFound", identityId);
|
|
64
|
+
}
|
|
65
|
+
if (onChain.hasDeletedDid()) {
|
|
66
|
+
throw new GeneralError(IotaIdentityUtils.CLASS_NAME, "identityDeleted", { identityId });
|
|
67
|
+
}
|
|
68
|
+
if (Is.undefined(controllerToken)) {
|
|
69
|
+
throw new NotFoundError(IotaIdentityUtils.CLASS_NAME, "controllerTokenNotFound", identityId);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
identityObjectId,
|
|
73
|
+
controllerCapObjectId: controllerToken.id()
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=iotaIdentityUtils.js.map
|
|
@@ -0,0 +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,eAAe,EACf,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IAC7B;;OAEG;IACI,MAAM,CAAU,UAAU,uBAAuC;IAExE;;;;;;;;;OASG;IACI,MAAM,CAAC,KAAK,CAAC,oBAAoB,CACvC,UAAkB,EAClB,iBAAyB,EACzB,MAAkB;QAElB,MAAM,CAAC,W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I,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC;gBACxD,eAAe,GAAG,MAAM,OAAO,CAAC,4BAA4B,CAC3D,iBAAiB,EACjB,cAAc,CACd,CAAC;YACH,CAAC;QACF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,YAAY,CACrB,iBAAiB,CAAC,UAAU,EAC5B,4BAA4B,EAC5B,SAAS,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\tOnChainIdentity\n} from \"@iota/identity-wasm/node/index.js\";\nimport type { IotaClient } from \"@iota/iota-sdk/client\";\nimport type { PublicKey } from \"@iota/iota-sdk/cryptography\";\nimport { Ed25519PublicKey } from \"@iota/iota-sdk/keypairs/ed25519\";\nimport { GeneralError, Guards, Is, NotFoundError } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { Iota } from \"./iota.js\";\nimport type { IIotaControllerCapInfo } from \"./models/IIotaControllerCapInfo.js\";\n\n/**\n * Utility class for resolving IOTA Identity on-chain objects required by\n * the NFT mint_with_identity() Move contract function.\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 * Resolve the on-chain object IDs for an identity and its controller token.\n\t * Returns the IDs needed to call mint_with_identity() on the NFT Move contract.\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: IotaClient\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\n\t\t// Extract the Object ID from the DID — last colon-delimited segment, prefixed with 0x.\n\t\t// IOTA DIDs have the format did:iota:<network>:<hex> where <hex> has no 0x prefix.\n\t\tconst idParts = identityId.split(\":\");\n\t\tconst identityObjectId = `0x${idParts[idParts.length - 1]}`;\n\n\t\tlet onChain: OnChainIdentity | undefined;\n\t\tlet controllerToken: Awaited<ReturnType<OnChainIdentity[\"getControllerTokenForAddress\"]>>;\n\n\t\ttry {\n\t\t\t// Both are IotaClient@1.11.0 but TypeScript resolves them from different module\n\t\t\t// entry points (dist/esm vs dist/cjs). The protected `transport` field causes a\n\t\t\t// class-compatibility failure even though the runtime types are identical.\n\t\t\t// Casting through the function's own parameter type keeps this refactor-safe.\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 is\n\t\t\t// read-only — the signer is never called, only the embedded CoreClientReadOnly is\n\t\t\t// used. TransactionSigner is a structural interface, so a minimal object literal\n\t\t\t// that satisfies its shape avoids importing the heavyweight JWK store machinery.\n\t\t\tconst noOpSigner = {\n\t\t\t\tsign: async (_txData: Uint8Array): Promise<string> => {\n\t\t\t\t\tthrow new GeneralError(IotaIdentityUtils.CLASS_NAME, \"unexpectedSignerCall\", undefined);\n\t\t\t\t},\n\t\t\t\tpublicKey: async (): Promise<PublicKey> => new Ed25519PublicKey(new Uint8Array(32)),\n\t\t\t\tiotaPublicKeyBytes: async (): Promise<Uint8Array> => new Uint8Array(32),\n\t\t\t\tkeyId: (): string => \"\"\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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IIotaClient.js","sourceRoot":"","sources":["../../../src/models/IIotaClient.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IotaClient } from \"@iota/iota-sdk/client\";\n\n/**\n * Interface representing the IOTA client.\n */\nexport type IIotaClient = IotaClient;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IIotaControllerCapInfo.js","sourceRoot":"","sources":["../../../src/models/IIotaControllerCapInfo.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * On-chain object IDs needed to call mint_with_identity() on the NFT Move contract.\n */\nexport interface IIotaControllerCapInfo {\n\t/**\n\t * The on-chain Object ID of the Identity Move object (hex string, e.g. \"0x...\").\n\t * Used as the Identity argument in mint_with_identity().\n\t */\n\tidentityObjectId: string;\n\n\t/**\n\t * The on-chain Object ID of the ControllerToken Move object (hex string, e.g. \"0x...\").\n\t * Proves that the controller address controls identityObjectId.\n\t * Used as the ControllerCap argument in mint_with_identity().\n\t */\n\tcontrollerCapObjectId: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IIotaTransaction.js","sourceRoot":"","sources":["../../../src/models/IIotaTransaction.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { Transaction } from \"@iota/iota-sdk/transactions\";\n\n/**\n * Interface representing the IOTA transaction.\n */\nexport type IIotaTransaction = Transaction;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IIotaTransactionBlockResponse.js","sourceRoot":"","sources":["../../../src/models/IIotaTransactionBlockResponse.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IotaTransactionBlockResponse } from \"@iota/iota-sdk/client\";\n\n/**\n * Interface representing the IOTA transaction block response.\n */\nexport type IIotaTransactionBlockResponse = IotaTransactionBlockResponse;\n"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from "./iota.js";
|
|
2
|
+
export * from "./iotaIdentityUtils.js";
|
|
2
3
|
export * from "./iotaSmartContractUtils.js";
|
|
3
4
|
export * from "./models/IAdminCapFields.js";
|
|
4
5
|
export * from "./models/IContractData.js";
|
|
@@ -7,6 +8,10 @@ export * from "./models/IGasStationConfig.js";
|
|
|
7
8
|
export * from "./models/IGasStationExecuteResponse.js";
|
|
8
9
|
export * from "./models/IGasStationReserveGasResponse.js";
|
|
9
10
|
export * from "./models/IGasStationReserveGasResult.js";
|
|
11
|
+
export * from "./models/IIotaClient.js";
|
|
12
|
+
export * from "./models/IIotaControllerCapInfo.js";
|
|
13
|
+
export * from "./models/IIotaTransaction.js";
|
|
14
|
+
export * from "./models/IIotaTransactionBlockResponse.js";
|
|
10
15
|
export * from "./models/IIotaConfig.js";
|
|
11
16
|
export * from "./models/IIotaDryRun.js";
|
|
12
17
|
export * from "./models/IIotaResponseOptions.js";
|
package/dist/types/iota.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { IotaClient, type IotaTransactionBlockResponse } from "@iota/iota-sdk/client";
|
|
2
|
-
import { Transaction } from "@iota/iota-sdk/transactions";
|
|
3
1
|
import { type IError } from "@twin.org/core";
|
|
4
2
|
import type { ILoggingComponent } from "@twin.org/logging-models";
|
|
5
3
|
import type { IVaultConnector } from "@twin.org/vault-models";
|
|
6
4
|
import type { IGasReservationResult } from "./models/IGasReservationResult.js";
|
|
5
|
+
import type { IIotaClient } from "./models/IIotaClient.js";
|
|
7
6
|
import type { IIotaConfig } from "./models/IIotaConfig.js";
|
|
8
7
|
import type { IIotaDryRun } from "./models/IIotaDryRun.js";
|
|
9
8
|
import type { IIotaResponseOptions } from "./models/IIotaResponseOptions.js";
|
|
9
|
+
import type { IIotaTransaction } from "./models/IIotaTransaction.js";
|
|
10
|
+
import type { IIotaTransactionBlockResponse } from "./models/IIotaTransactionBlockResponse.js";
|
|
10
11
|
/**
|
|
11
12
|
* Class for performing operations on IOTA.
|
|
12
13
|
*/
|
|
@@ -40,7 +41,7 @@ export declare class Iota {
|
|
|
40
41
|
* @param config The configuration.
|
|
41
42
|
* @returns The client instance.
|
|
42
43
|
*/
|
|
43
|
-
static createClient(config: IIotaConfig):
|
|
44
|
+
static createClient(config: IIotaConfig): IIotaClient;
|
|
44
45
|
/**
|
|
45
46
|
* Create configuration using defaults where necessary.
|
|
46
47
|
* @param config The configuration to populate.
|
|
@@ -70,6 +71,11 @@ export declare class Iota {
|
|
|
70
71
|
privateKey: Uint8Array;
|
|
71
72
|
publicKey: Uint8Array;
|
|
72
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* Create a new transaction instance.
|
|
76
|
+
* @returns A new transaction instance.
|
|
77
|
+
*/
|
|
78
|
+
static createTransaction(): IIotaTransaction;
|
|
73
79
|
/**
|
|
74
80
|
* Prepare and post a transaction.
|
|
75
81
|
* @param config The configuration.
|
|
@@ -83,7 +89,7 @@ export declare class Iota {
|
|
|
83
89
|
* @param options The transaction options.
|
|
84
90
|
* @returns The transaction result.
|
|
85
91
|
*/
|
|
86
|
-
static prepareAndPostValueTransaction(config: IIotaConfig, vaultConnector: IVaultConnector, logging: ILoggingComponent | undefined, identity: string, client:
|
|
92
|
+
static prepareAndPostValueTransaction(config: IIotaConfig, vaultConnector: IVaultConnector, logging: ILoggingComponent | undefined, identity: string, client: IIotaClient, source: string, amount: bigint, recipient: string, options?: IIotaResponseOptions): Promise<IIotaTransactionBlockResponse>;
|
|
87
93
|
/**
|
|
88
94
|
* Prepare and post a transaction.
|
|
89
95
|
* @param config The configuration.
|
|
@@ -96,7 +102,7 @@ export declare class Iota {
|
|
|
96
102
|
* @param options The transaction options.
|
|
97
103
|
* @returns The transaction response.
|
|
98
104
|
*/
|
|
99
|
-
static prepareAndPostTransaction(config: IIotaConfig, vaultConnector: IVaultConnector, logging: ILoggingComponent | undefined, identity: string, client:
|
|
105
|
+
static prepareAndPostTransaction(config: IIotaConfig, vaultConnector: IVaultConnector, logging: ILoggingComponent | undefined, identity: string, client: IIotaClient, owner: string, transaction: IIotaTransaction, options?: IIotaResponseOptions): Promise<IIotaTransactionBlockResponse>;
|
|
100
106
|
/**
|
|
101
107
|
* Get the seed from the vault.
|
|
102
108
|
* @param config The configuration to use.
|
|
@@ -146,7 +152,7 @@ export declare class Iota {
|
|
|
146
152
|
* @param packageId The package ID to check.
|
|
147
153
|
* @returns True if the package exists, false otherwise.
|
|
148
154
|
*/
|
|
149
|
-
static packageExistsOnNetwork(client:
|
|
155
|
+
static packageExistsOnNetwork(client: IIotaClient, packageId: string): Promise<boolean>;
|
|
150
156
|
/**
|
|
151
157
|
* Dry run a transaction and log the results.
|
|
152
158
|
* @param client The IOTA client.
|
|
@@ -156,7 +162,7 @@ export declare class Iota {
|
|
|
156
162
|
* @param operation The operation to log.
|
|
157
163
|
* @returns void.
|
|
158
164
|
*/
|
|
159
|
-
static dryRunTransaction(client:
|
|
165
|
+
static dryRunTransaction(client: IIotaClient, logging: ILoggingComponent | undefined, txb: IIotaTransaction, sender: string, operation: string): Promise<IIotaDryRun>;
|
|
160
166
|
/**
|
|
161
167
|
* Wait for a transaction to be indexed and available over the API.
|
|
162
168
|
* @param client The IOTA client instance.
|
|
@@ -168,11 +174,11 @@ export declare class Iota {
|
|
|
168
174
|
* @param options.showObjectChanges Whether to show object changes.
|
|
169
175
|
* @returns The confirmed transaction response.
|
|
170
176
|
*/
|
|
171
|
-
static waitForTransactionConfirmation(client:
|
|
177
|
+
static waitForTransactionConfirmation(client: IIotaClient, digest: string, config: IIotaConfig, options?: {
|
|
172
178
|
showEffects?: boolean;
|
|
173
179
|
showEvents?: boolean;
|
|
174
180
|
showObjectChanges?: boolean;
|
|
175
|
-
}): Promise<
|
|
181
|
+
}): Promise<IIotaTransactionBlockResponse>;
|
|
176
182
|
/**
|
|
177
183
|
* Check if the error is an abort error with a specific code.
|
|
178
184
|
* @param error The error to check.
|
|
@@ -191,7 +197,7 @@ export declare class Iota {
|
|
|
191
197
|
* @param options Response options including confirmation behavior.
|
|
192
198
|
* @returns The transaction response.
|
|
193
199
|
*/
|
|
194
|
-
static prepareAndPostGasStationTransaction(config: IIotaConfig, vaultConnector: IVaultConnector, identity: string, client:
|
|
200
|
+
static prepareAndPostGasStationTransaction(config: IIotaConfig, vaultConnector: IVaultConnector, identity: string, client: IIotaClient, owner: string, transaction: IIotaTransaction, options?: IIotaResponseOptions): Promise<IIotaTransactionBlockResponse>;
|
|
195
201
|
/**
|
|
196
202
|
* Reserve gas from the gas station.
|
|
197
203
|
* @param config The configuration containing gas station settings.
|
|
@@ -207,7 +213,7 @@ export declare class Iota {
|
|
|
207
213
|
* @param userSignature The user's signature.
|
|
208
214
|
* @returns The transaction response.
|
|
209
215
|
*/
|
|
210
|
-
static executeGasStationTransaction(config: IIotaConfig, reservationId: number, transactionBytes: Uint8Array, userSignature: string): Promise<
|
|
216
|
+
static executeGasStationTransaction(config: IIotaConfig, reservationId: number, transactionBytes: Uint8Array, userSignature: string): Promise<IIotaTransactionBlockResponse>;
|
|
211
217
|
/**
|
|
212
218
|
* Execute and confirm a gas station transaction.
|
|
213
219
|
* @param config The configuration containing gas station settings.
|
|
@@ -218,5 +224,5 @@ export declare class Iota {
|
|
|
218
224
|
* @param options Response options including confirmation behavior.
|
|
219
225
|
* @returns The transaction response (confirmed if waitForConfirmation is true).
|
|
220
226
|
*/
|
|
221
|
-
static executeAndConfirmGasStationTransaction(config: IIotaConfig, client:
|
|
227
|
+
static executeAndConfirmGasStationTransaction(config: IIotaConfig, client: IIotaClient, reservationId: number, transactionBytes: Uint8Array, userSignature: string, options?: IIotaResponseOptions): Promise<IIotaTransactionBlockResponse>;
|
|
222
228
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { IotaClient } from "@iota/iota-sdk/client";
|
|
2
|
+
import type { IIotaControllerCapInfo } from "./models/IIotaControllerCapInfo.js";
|
|
3
|
+
/**
|
|
4
|
+
* Utility class for resolving IOTA Identity on-chain objects required by
|
|
5
|
+
* the NFT mint_with_identity() Move contract function.
|
|
6
|
+
*/
|
|
7
|
+
export declare class IotaIdentityUtils {
|
|
8
|
+
/**
|
|
9
|
+
* Runtime name for the class.
|
|
10
|
+
*/
|
|
11
|
+
static readonly CLASS_NAME: string;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve the on-chain object IDs for an identity and its controller token.
|
|
14
|
+
* Returns the IDs needed to call mint_with_identity() on the NFT Move contract.
|
|
15
|
+
* @param identityId The DID of the identity (e.g. "did:iota:testnet:0x...").
|
|
16
|
+
* @param controllerAddress The on-chain address of the controller wallet.
|
|
17
|
+
* @param client The IOTA client instance.
|
|
18
|
+
* @returns The identity object ID and controller token object ID.
|
|
19
|
+
* @throws NotFoundError if the identity does not exist on-chain.
|
|
20
|
+
* @throws GeneralError if the identity has been deleted or the controller token is not found.
|
|
21
|
+
*/
|
|
22
|
+
static getControllerCapInfo(identityId: string, controllerAddress: string, client: IotaClient): Promise<IIotaControllerCapInfo>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On-chain object IDs needed to call mint_with_identity() on the NFT Move contract.
|
|
3
|
+
*/
|
|
4
|
+
export interface IIotaControllerCapInfo {
|
|
5
|
+
/**
|
|
6
|
+
* The on-chain Object ID of the Identity Move object (hex string, e.g. "0x...").
|
|
7
|
+
* Used as the Identity argument in mint_with_identity().
|
|
8
|
+
*/
|
|
9
|
+
identityObjectId: string;
|
|
10
|
+
/**
|
|
11
|
+
* The on-chain Object ID of the ControllerToken Move object (hex string, e.g. "0x...").
|
|
12
|
+
* Proves that the controller address controls identityObjectId.
|
|
13
|
+
* Used as the ControllerCap argument in mint_with_identity().
|
|
14
|
+
*/
|
|
15
|
+
controllerCapObjectId: string;
|
|
16
|
+
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.0.3-next.6](https://github.com/twinfoundation/dlt/compare/dlt-iota-v0.0.3-next.5...dlt-iota-v0.0.3-next.6) (2026-03-12)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add IotaIdentityUtils to resolve IOTA identity controller cap info ([#57](https://github.com/twinfoundation/dlt/issues/57)) ([f15281a](https://github.com/twinfoundation/dlt/commit/f15281af3b2812bde5130a1813f9c0143f1462bf))
|
|
9
|
+
|
|
10
|
+
## [0.0.3-next.5](https://github.com/twinfoundation/dlt/compare/dlt-iota-v0.0.3-next.4...dlt-iota-v0.0.3-next.5) (2026-03-03)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Miscellaneous Chores
|
|
14
|
+
|
|
15
|
+
* **dlt-iota:** Synchronize repo versions
|
|
2
16
|
|
|
3
17
|
## [0.0.3-next.4](https://github.com/twinfoundation/dlt/compare/dlt-iota-v0.0.3-next.3...dlt-iota-v0.0.3-next.4) (2026-02-25)
|
|
4
18
|
|