@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/types/iota.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { IIotaDryRun } from "./models/IIotaDryRun.js";
|
|
|
8
8
|
import type { IIotaResponseOptions } from "./models/IIotaResponseOptions.js";
|
|
9
9
|
import type { IIotaTransaction } from "./models/IIotaTransaction.js";
|
|
10
10
|
import type { IIotaTransactionBlockResponse } from "./models/IIotaTransactionBlockResponse.js";
|
|
11
|
+
import { VaultTransactionSigner } from "./vaultTransactionSigner.js";
|
|
11
12
|
/**
|
|
12
13
|
* Class for performing operations on IOTA.
|
|
13
14
|
*/
|
|
@@ -39,30 +40,55 @@ export declare class Iota {
|
|
|
39
40
|
* @param config The configuration to populate.
|
|
40
41
|
*/
|
|
41
42
|
static populateConfig(config: IIotaConfig): void;
|
|
43
|
+
/**
|
|
44
|
+
* Store a mnemonic in the vault, derive and store the seed, and pre-cache the first keypair chunk.
|
|
45
|
+
* @param vaultConnector The vault connector.
|
|
46
|
+
* @param config The configuration.
|
|
47
|
+
* @param identity The identity of the user to access the vault keys.
|
|
48
|
+
* @param mnemonic The mnemonic to store, if undefined a new one will be generated and returned.
|
|
49
|
+
* @param accountIndex The account index to pre-cache.
|
|
50
|
+
* @returns The mnemonic that was stored.
|
|
51
|
+
*/
|
|
52
|
+
static storeMnemonic(vaultConnector: IVaultConnector, config: IIotaConfig, identity: string, mnemonic: string | undefined, accountIndex: number): Promise<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Derive an address from a public key.
|
|
55
|
+
* @param publicKey The public key to derive the address from.
|
|
56
|
+
* @returns The derived address.
|
|
57
|
+
*/
|
|
58
|
+
static publicKeyToAddress(publicKey: Uint8Array): string;
|
|
59
|
+
/**
|
|
60
|
+
* Get address for the identity.
|
|
61
|
+
* @param vaultConnector The vault connector.
|
|
62
|
+
* @param config The configuration.
|
|
63
|
+
* @param identity The identity of the user to access the vault keys.
|
|
64
|
+
* @param accountIndex The account index to get the addresses for.
|
|
65
|
+
* @param startAddressIndex The start index for the addresses.
|
|
66
|
+
* @param isInternal Whether the addresses are internal.
|
|
67
|
+
* @returns The address.
|
|
68
|
+
*/
|
|
69
|
+
static getAddress(vaultConnector: IVaultConnector, config: Pick<IIotaConfig, "coinType" | "vaultMnemonicId" | "vaultSeedId">, identity: string, accountIndex: number, startAddressIndex: number, isInternal?: boolean): Promise<string>;
|
|
42
70
|
/**
|
|
43
71
|
* Get addresses for the identity.
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
72
|
+
* @param vaultConnector The vault connector.
|
|
73
|
+
* @param config The configuration.
|
|
74
|
+
* @param identity The identity of the user to access the vault keys.
|
|
46
75
|
* @param accountIndex The account index to get the addresses for.
|
|
47
76
|
* @param startAddressIndex The start index for the addresses.
|
|
48
77
|
* @param count The number of addresses to generate.
|
|
49
78
|
* @param isInternal Whether the addresses are internal.
|
|
50
79
|
* @returns The list of addresses.
|
|
51
80
|
*/
|
|
52
|
-
static getAddresses(
|
|
81
|
+
static getAddresses(vaultConnector: IVaultConnector, config: Pick<IIotaConfig, "coinType" | "vaultMnemonicId" | "vaultSeedId">, identity: string, accountIndex: number, startAddressIndex: number, count: number, isInternal?: boolean): Promise<string[]>;
|
|
53
82
|
/**
|
|
54
|
-
* Get a
|
|
55
|
-
* @param
|
|
56
|
-
* @param
|
|
57
|
-
* @param
|
|
58
|
-
* @param
|
|
59
|
-
* @param
|
|
60
|
-
* @returns
|
|
83
|
+
* Get a vault-backed transaction signer for the given identity and key indices.
|
|
84
|
+
* @param vaultConnector The vault connector.
|
|
85
|
+
* @param config The configuration.
|
|
86
|
+
* @param identity The identity of the user to access the vault keys.
|
|
87
|
+
* @param accountIndex The account index.
|
|
88
|
+
* @param addressIndex The address index within the account.
|
|
89
|
+
* @returns A VaultTransactionSigner for the specified key.
|
|
61
90
|
*/
|
|
62
|
-
static
|
|
63
|
-
privateKey: Uint8Array;
|
|
64
|
-
publicKey: Uint8Array;
|
|
65
|
-
};
|
|
91
|
+
static getTransactionSigner(vaultConnector: IVaultConnector, config: IIotaConfig, identity: string, accountIndex: number, addressIndex: number): Promise<VaultTransactionSigner>;
|
|
66
92
|
/**
|
|
67
93
|
* Create a new transaction instance.
|
|
68
94
|
* @returns A new transaction instance.
|
|
@@ -95,28 +121,6 @@ export declare class Iota {
|
|
|
95
121
|
* @returns The transaction response.
|
|
96
122
|
*/
|
|
97
123
|
static prepareAndPostTransaction(config: IIotaConfig, vaultConnector: IVaultConnector, logging: ILoggingComponent | undefined, identity: string, client: IIotaClient, owner: string, transaction: IIotaTransaction, options?: IIotaResponseOptions): Promise<IIotaTransactionBlockResponse>;
|
|
98
|
-
/**
|
|
99
|
-
* Get the seed from the vault.
|
|
100
|
-
* @param config The configuration to use.
|
|
101
|
-
* @param vaultConnector The vault connector to use.
|
|
102
|
-
* @param identity The identity of the user to access the vault keys.
|
|
103
|
-
* @returns The seed.
|
|
104
|
-
*/
|
|
105
|
-
static getSeed(config: IIotaConfig, vaultConnector: IVaultConnector, identity: string): Promise<Uint8Array>;
|
|
106
|
-
/**
|
|
107
|
-
* Find the address in the seed.
|
|
108
|
-
* @param maxScanRange The maximum range to scan.
|
|
109
|
-
* @param coinType The coin type to use.
|
|
110
|
-
* @param seed The seed to use.
|
|
111
|
-
* @param address The address to find.
|
|
112
|
-
* @returns The address key pair.
|
|
113
|
-
* @throws Error if the address is not found.
|
|
114
|
-
*/
|
|
115
|
-
static findAddress(maxScanRange: number, coinType: number, seed: Uint8Array, address: string): {
|
|
116
|
-
address: string;
|
|
117
|
-
privateKey: Uint8Array;
|
|
118
|
-
publicKey: Uint8Array;
|
|
119
|
-
};
|
|
120
124
|
/**
|
|
121
125
|
* Extract error from SDK payload.
|
|
122
126
|
* Errors from the IOTA SDK are usually not JSON strings but objects.
|
|
@@ -124,20 +128,6 @@ export declare class Iota {
|
|
|
124
128
|
* @returns The extracted error.
|
|
125
129
|
*/
|
|
126
130
|
static extractPayloadError(error: unknown): IError;
|
|
127
|
-
/**
|
|
128
|
-
* Get the key for storing the mnemonic.
|
|
129
|
-
* @param identity The identity to use.
|
|
130
|
-
* @param vaultMnemonicId The mnemonic ID to use.
|
|
131
|
-
* @returns The mnemonic key.
|
|
132
|
-
*/
|
|
133
|
-
static buildMnemonicKey(identity: string, vaultMnemonicId?: string): string;
|
|
134
|
-
/**
|
|
135
|
-
* Get the key for storing the seed.
|
|
136
|
-
* @param identity The identity to use.
|
|
137
|
-
* @param vaultSeedId The seed ID to use.
|
|
138
|
-
* @returns The seed key.
|
|
139
|
-
*/
|
|
140
|
-
static buildSeedKey(identity: string, vaultSeedId?: string): string;
|
|
141
131
|
/**
|
|
142
132
|
* Check if the package exists on the network.
|
|
143
133
|
* @param client The client to use.
|
|
@@ -152,7 +142,7 @@ export declare class Iota {
|
|
|
152
142
|
* @param txb The transaction to dry run.
|
|
153
143
|
* @param sender The sender address.
|
|
154
144
|
* @param operation The operation to log.
|
|
155
|
-
* @returns
|
|
145
|
+
* @returns The dry run result including status, costs, events, and object changes.
|
|
156
146
|
*/
|
|
157
147
|
static dryRunTransaction(client: IIotaClient, logging: ILoggingComponent | undefined, txb: IIotaTransaction, sender: string, operation: string): Promise<IIotaDryRun>;
|
|
158
148
|
/**
|
|
@@ -178,6 +168,12 @@ export declare class Iota {
|
|
|
178
168
|
* @returns True if the error is an abort error, false otherwise.
|
|
179
169
|
*/
|
|
180
170
|
static isAbortError(error: unknown, code: number): boolean;
|
|
171
|
+
/**
|
|
172
|
+
* Extracts the abort code from a transaction result if the transaction was aborted.
|
|
173
|
+
* @param response The transaction result to extract the abort code from.
|
|
174
|
+
* @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.
|
|
175
|
+
*/
|
|
176
|
+
static extractAbortCode(response: IIotaTransactionBlockResponse): number | undefined;
|
|
181
177
|
/**
|
|
182
178
|
* Prepare and post a transaction using gas station sponsoring.
|
|
183
179
|
* @param config The configuration.
|
|
@@ -193,10 +189,9 @@ export declare class Iota {
|
|
|
193
189
|
/**
|
|
194
190
|
* Reserve gas from the gas station.
|
|
195
191
|
* @param config The configuration containing gas station settings.
|
|
196
|
-
* @param gasBudget The gas budget to reserve.
|
|
197
192
|
* @returns The gas reservation result.
|
|
198
193
|
*/
|
|
199
|
-
static reserveGas(config: IIotaConfig
|
|
194
|
+
static reserveGas(config: IIotaConfig): Promise<IGasReservationResult>;
|
|
200
195
|
/**
|
|
201
196
|
* Execute a sponsored transaction through the gas station.
|
|
202
197
|
* @param config The configuration containing gas station settings.
|
|
@@ -217,4 +212,38 @@ export declare class Iota {
|
|
|
217
212
|
* @returns The transaction response (confirmed if waitForConfirmation is true).
|
|
218
213
|
*/
|
|
219
214
|
static executeAndConfirmGasStationTransaction(config: IIotaConfig, client: IIotaClient, reservationId: number, transactionBytes: Uint8Array, userSignature: string, options?: IIotaResponseOptions): Promise<IIotaTransactionBlockResponse>;
|
|
215
|
+
/**
|
|
216
|
+
* Fund an address with IOTA from the faucet.
|
|
217
|
+
* @param config The configuration containing endpoint information.
|
|
218
|
+
* @param faucetUrl The URL of the faucet to request funds from.
|
|
219
|
+
* @param identity The identity of the user to access the vault keys.
|
|
220
|
+
* @param address The address to fund.
|
|
221
|
+
* @param timeoutInSeconds The timeout in seconds to wait for the funding to complete.
|
|
222
|
+
* @returns The amount funded.
|
|
223
|
+
*/
|
|
224
|
+
static fundAddress(config: IIotaConfig, faucetUrl: string, identity: string, address: string, timeoutInSeconds?: number): Promise<bigint>;
|
|
225
|
+
/**
|
|
226
|
+
* Ensure the balance for the given address is at least the given amount.
|
|
227
|
+
* @param config The configuration containing endpoint information.
|
|
228
|
+
* @param faucetUrl The URL of the faucet to request funds from.
|
|
229
|
+
* @param identity The identity of the user to access the vault keys.
|
|
230
|
+
* @param address The address to ensure the balance for.
|
|
231
|
+
* @param ensureBalance The minimum balance to ensure.
|
|
232
|
+
* @param timeoutInSeconds Optional timeout in seconds, defaults to 10 seconds.
|
|
233
|
+
* @returns True if the balance is at least the given amount, false otherwise.
|
|
234
|
+
*/
|
|
235
|
+
static ensureBalance(config: IIotaConfig, faucetUrl: string | undefined, identity: string, address: string, ensureBalance: bigint, timeoutInSeconds?: number): Promise<boolean>;
|
|
236
|
+
/**
|
|
237
|
+
* Get the balance for the given address.
|
|
238
|
+
* @param config The configuration containing endpoint information.
|
|
239
|
+
* @param address The address to get the balance for.
|
|
240
|
+
* @returns The balance of the given address.
|
|
241
|
+
*/
|
|
242
|
+
static getBalance(config: IIotaConfig, address: string): Promise<bigint>;
|
|
243
|
+
/**
|
|
244
|
+
* Create a transaction instance from the given bytes.
|
|
245
|
+
* @param bytes The transaction bytes to create the transaction from.
|
|
246
|
+
* @returns The transaction instance created from the given bytes.
|
|
247
|
+
*/
|
|
248
|
+
static transactionFromBytes(bytes: Uint8Array): IIotaTransaction;
|
|
220
249
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { IIotaClient } from "./models/IIotaClient.js";
|
|
2
2
|
import type { IIotaControllerCapInfo } from "./models/IIotaControllerCapInfo.js";
|
|
3
3
|
/**
|
|
4
|
-
* Utility class for resolving IOTA Identity on-chain objects
|
|
5
|
-
* the NFT mint_with_identity() Move contract function.
|
|
4
|
+
* Utility class for resolving IOTA Identity on-chain objects and controller tokens.
|
|
6
5
|
*/
|
|
7
6
|
export declare class IotaIdentityUtils {
|
|
8
7
|
/**
|
|
@@ -10,8 +9,7 @@ export declare class IotaIdentityUtils {
|
|
|
10
9
|
*/
|
|
11
10
|
static readonly CLASS_NAME: string;
|
|
12
11
|
/**
|
|
13
|
-
*
|
|
14
|
-
* Returns the IDs needed to call mint_with_identity() on the NFT Move contract.
|
|
12
|
+
* Resolves the on-chain object IDs for an identity and its controller token.
|
|
15
13
|
* @param identityId The DID of the identity (e.g. "did:iota:testnet:0x...").
|
|
16
14
|
* @param controllerAddress The on-chain address of the controller wallet.
|
|
17
15
|
* @param client The IOTA client instance.
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { IotaClient } from "@iota/iota-sdk/client";
|
|
2
2
|
import type { ILoggingComponent } from "@twin.org/logging-models";
|
|
3
3
|
import type { IVaultConnector } from "@twin.org/vault-models";
|
|
4
|
-
import type { IWalletConnector } from "@twin.org/wallet-models";
|
|
5
4
|
import type { IIotaConfig } from "./models/IIotaConfig.js";
|
|
6
5
|
import type { ISmartContractDeployments } from "./models/ISmartContractDeployments.js";
|
|
7
6
|
/**
|
|
8
7
|
* 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
8
|
*/
|
|
11
9
|
export declare class IotaSmartContractUtils {
|
|
12
10
|
/**
|
|
@@ -19,7 +17,6 @@ export declare class IotaSmartContractUtils {
|
|
|
19
17
|
* @param config The IOTA configuration.
|
|
20
18
|
* @param client The IOTA client instance.
|
|
21
19
|
* @param vaultConnector The vault connector for key management.
|
|
22
|
-
* @param walletConnector The wallet connector for address generation.
|
|
23
20
|
* @param logging Optional logging component.
|
|
24
21
|
* @param gasBudget The gas budget for the transaction.
|
|
25
22
|
* @param identity The identity of the controller with admin privileges.
|
|
@@ -27,79 +24,83 @@ export declare class IotaSmartContractUtils {
|
|
|
27
24
|
* @param namespace The contract namespace (e.g., "nft", "verifiable_storage").
|
|
28
25
|
* @param packageId The deployed package ID for the contract.
|
|
29
26
|
* @param deploymentConfig The deployment configuration containing object IDs.
|
|
27
|
+
* @param accountAddressIndex Optional account address index for the controller.
|
|
30
28
|
* @param walletAddressIndex Optional wallet address index for the controller.
|
|
31
29
|
* @returns Promise that resolves when migration is complete.
|
|
32
30
|
*/
|
|
33
|
-
static migrateSmartContract(config: IIotaConfig, client: IotaClient, vaultConnector: IVaultConnector,
|
|
31
|
+
static migrateSmartContract(config: IIotaConfig, client: IotaClient, vaultConnector: IVaultConnector, logging: ILoggingComponent | undefined, gasBudget: number, identity: string, objectId: string, namespace: string, packageId: string, deploymentConfig: ISmartContractDeployments, accountAddressIndex?: number, walletAddressIndex?: number): Promise<void>;
|
|
34
32
|
/**
|
|
35
33
|
* Enable migration operations using admin privileges.
|
|
36
34
|
* @param config The IOTA configuration.
|
|
37
35
|
* @param client The IOTA client instance.
|
|
38
36
|
* @param vaultConnector The vault connector for key management.
|
|
39
|
-
* @param walletConnector The wallet connector for address generation.
|
|
40
37
|
* @param logging Optional logging component.
|
|
41
38
|
* @param gasBudget The gas budget for the transaction.
|
|
42
39
|
* @param identity The identity of the controller with admin privileges.
|
|
43
40
|
* @param namespace The contract namespace (e.g., "nft", "verifiable_storage").
|
|
44
41
|
* @param packageId The deployed package ID for the contract.
|
|
45
42
|
* @param deploymentConfig The deployment configuration containing object IDs.
|
|
43
|
+
* @param accountAddressIndex Optional account address index for the controller.
|
|
46
44
|
* @param walletAddressIndex Optional wallet address index for the controller.
|
|
47
45
|
* @returns Promise that resolves when migration is enabled.
|
|
48
46
|
*/
|
|
49
|
-
static enableMigration(config: IIotaConfig, client: IotaClient, vaultConnector: IVaultConnector,
|
|
47
|
+
static enableMigration(config: IIotaConfig, client: IotaClient, vaultConnector: IVaultConnector, logging: ILoggingComponent | undefined, gasBudget: number, identity: string, namespace: string, packageId: string, deploymentConfig: ISmartContractDeployments, accountAddressIndex?: number, walletAddressIndex?: number): Promise<void>;
|
|
50
48
|
/**
|
|
51
49
|
* Disable migration operations using admin privileges.
|
|
52
50
|
* @param config The IOTA configuration.
|
|
53
51
|
* @param client The IOTA client instance.
|
|
54
52
|
* @param vaultConnector The vault connector for key management.
|
|
55
|
-
* @param walletConnector The wallet connector for address generation.
|
|
56
53
|
* @param logging Optional logging component.
|
|
57
54
|
* @param gasBudget The gas budget for the transaction.
|
|
58
55
|
* @param identity The identity of the controller with admin privileges.
|
|
59
56
|
* @param namespace The contract namespace (e.g., "nft", "verifiable_storage").
|
|
60
57
|
* @param packageId The deployed package ID for the contract.
|
|
61
58
|
* @param deploymentConfig The deployment configuration containing object IDs.
|
|
59
|
+
* @param accountAddressIndex Optional account address index for the controller.
|
|
62
60
|
* @param walletAddressIndex Optional wallet address index for the controller.
|
|
63
61
|
* @returns Promise that resolves when migration is disabled.
|
|
64
62
|
*/
|
|
65
|
-
static disableMigration(config: IIotaConfig, client: IotaClient, vaultConnector: IVaultConnector,
|
|
63
|
+
static disableMigration(config: IIotaConfig, client: IotaClient, vaultConnector: IVaultConnector, logging: ILoggingComponent | undefined, gasBudget: number, identity: string, namespace: string, packageId: string, deploymentConfig: ISmartContractDeployments, accountAddressIndex?: number, walletAddressIndex?: number): Promise<void>;
|
|
66
64
|
/**
|
|
67
65
|
* Check if migration is currently active for a smart contract.
|
|
68
66
|
* @param config The IOTA configuration.
|
|
69
67
|
* @param client The IOTA client instance.
|
|
68
|
+
* @param vaultConnector The vault connector for key management.
|
|
70
69
|
* @param namespace The contract namespace (e.g., "nft", "verifiable_storage").
|
|
71
70
|
* @param packageId The deployed package ID for the contract.
|
|
72
71
|
* @param deploymentConfig The deployment configuration containing object IDs.
|
|
73
72
|
* @param identity The identity for MigrationState discovery.
|
|
74
|
-
* @param
|
|
75
|
-
* @param walletAddressIndex Optional wallet address index.
|
|
73
|
+
* @param accountAddressIndex Optional account address index for the controller.
|
|
74
|
+
* @param walletAddressIndex Optional wallet address index for the controller.
|
|
76
75
|
* @returns True if migration is enabled, false otherwise.
|
|
77
76
|
*/
|
|
78
|
-
static isMigrationActive(config: IIotaConfig, client: IotaClient, namespace: string, packageId: string, deploymentConfig: ISmartContractDeployments, identity: string,
|
|
77
|
+
static isMigrationActive(config: IIotaConfig, client: IotaClient, vaultConnector: IVaultConnector, namespace: string, packageId: string, deploymentConfig: ISmartContractDeployments, identity: string, accountAddressIndex?: number, walletAddressIndex?: number): Promise<boolean>;
|
|
79
78
|
/**
|
|
80
79
|
* Get the current contract version from the deployed smart contract.
|
|
81
80
|
* @param config The IOTA configuration.
|
|
82
81
|
* @param client The IOTA client instance.
|
|
82
|
+
* @param vaultConnector The vault connector for key management.
|
|
83
83
|
* @param namespace The contract namespace (e.g., "nft", "verifiable_storage").
|
|
84
84
|
* @param packageId The deployed package ID for the contract.
|
|
85
85
|
* @param identity The identity for package controller address.
|
|
86
|
-
* @param
|
|
87
|
-
* @param walletAddressIndex Optional wallet address index.
|
|
86
|
+
* @param accountAddressIndex Optional account address index for the controller.
|
|
87
|
+
* @param walletAddressIndex Optional wallet address index for the controller.
|
|
88
88
|
* @returns The current version number of the contract.
|
|
89
89
|
*/
|
|
90
|
-
static getCurrentContractVersion(config: IIotaConfig, client: IotaClient, namespace: string, packageId: string, identity: string,
|
|
90
|
+
static getCurrentContractVersion(config: IIotaConfig, client: IotaClient, vaultConnector: IVaultConnector, namespace: string, packageId: string, identity: string, accountAddressIndex?: number, walletAddressIndex?: number): Promise<number>;
|
|
91
91
|
/**
|
|
92
92
|
* Validate that an object version is compatible with the current contract.
|
|
93
93
|
* @param config The IOTA configuration.
|
|
94
94
|
* @param client The IOTA client instance.
|
|
95
|
+
* @param vaultConnector The vault connector for key management.
|
|
95
96
|
* @param namespace The contract namespace (e.g., "nft", "verifiable_storage").
|
|
96
97
|
* @param packageId The deployed package ID for the contract.
|
|
97
98
|
* @param identity The identity for version checking.
|
|
98
99
|
* @param objectId The object ID to validate.
|
|
99
|
-
* @param walletConnector The wallet connector for address generation.
|
|
100
100
|
* @param versionExtractor Function to extract version from object content.
|
|
101
|
-
* @param
|
|
101
|
+
* @param accountAddressIndex Optional account address index for the controller.
|
|
102
|
+
* @param walletAddressIndex Optional wallet address index for the controller.
|
|
102
103
|
* @returns True if the object version is compatible, false otherwise.
|
|
103
104
|
*/
|
|
104
|
-
static validateObjectVersion<T>(config: IIotaConfig, client: IotaClient, namespace: string, packageId: string, identity: string, objectId: string,
|
|
105
|
+
static validateObjectVersion<T>(config: IIotaConfig, client: IotaClient, vaultConnector: IVaultConnector, namespace: string, packageId: string, identity: string, objectId: string, versionExtractor: (content: T) => number, accountAddressIndex?: number, walletAddressIndex?: number): Promise<boolean>;
|
|
105
106
|
}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export interface IAdminCapFields {
|
|
5
5
|
/**
|
|
6
|
-
* The
|
|
6
|
+
* The UID wrapper of the AdminCap object.
|
|
7
7
|
*/
|
|
8
8
|
id: {
|
|
9
9
|
/**
|
|
10
|
-
* The ID of the AdminCap object.
|
|
10
|
+
* The hex string ID of the AdminCap object.
|
|
11
11
|
*/
|
|
12
12
|
id: string;
|
|
13
13
|
};
|
|
@@ -4,12 +4,10 @@
|
|
|
4
4
|
export interface IGasStationExecuteResponse {
|
|
5
5
|
/**
|
|
6
6
|
* The transaction effects from the IOTA network.
|
|
7
|
-
* This contains the full IOTA transaction effects object.
|
|
8
7
|
*/
|
|
9
8
|
effects: {
|
|
10
9
|
/**
|
|
11
|
-
* Additional
|
|
12
|
-
* This includes messageVersion, status, executedEpoch, gasUsed, etc.
|
|
10
|
+
* Additional fields from the IOTA network effects object.
|
|
13
11
|
*/
|
|
14
12
|
[key: string]: unknown;
|
|
15
13
|
/**
|
|
@@ -47,6 +47,11 @@ export interface IIotaConfig {
|
|
|
47
47
|
* @default 50000000
|
|
48
48
|
*/
|
|
49
49
|
gasBudget?: number;
|
|
50
|
+
/**
|
|
51
|
+
* The default gas reservation duration in seconds for all transactions (including sponsored and direct).
|
|
52
|
+
* @default 60
|
|
53
|
+
*/
|
|
54
|
+
gasReservationDuration?: number;
|
|
50
55
|
/**
|
|
51
56
|
* Enable cost logging for transactions.
|
|
52
57
|
* @default false
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* On-chain object IDs
|
|
2
|
+
* On-chain object IDs for an identity and its associated controller token.
|
|
3
3
|
*/
|
|
4
4
|
export interface IIotaControllerCapInfo {
|
|
5
5
|
/**
|
|
6
|
-
* The on-chain
|
|
7
|
-
* Used as the Identity argument in mint_with_identity().
|
|
6
|
+
* The on-chain object ID of the Identity Move object (hex string, e.g. "0x...").
|
|
8
7
|
*/
|
|
9
8
|
identityObjectId: string;
|
|
10
9
|
/**
|
|
11
|
-
* The on-chain
|
|
12
|
-
* Proves that the controller address controls identityObjectId.
|
|
13
|
-
* Used as the ControllerCap argument in mint_with_identity().
|
|
10
|
+
* The on-chain object ID of the ControllerToken Move object (hex string, e.g. "0x...").
|
|
14
11
|
*/
|
|
15
12
|
controllerCapObjectId: string;
|
|
16
13
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IotaTransactionBlockResponseOptions } from "@iota/iota-sdk/client";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Options for controlling transaction execution and response behaviour.
|
|
4
4
|
*/
|
|
5
5
|
export interface IIotaResponseOptions extends IotaTransactionBlockResponseOptions {
|
|
6
6
|
/**
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export interface IMigrationStateFields {
|
|
5
5
|
/**
|
|
6
|
-
* The
|
|
6
|
+
* The UID wrapper of the MigrationState object.
|
|
7
7
|
*/
|
|
8
8
|
id: {
|
|
9
9
|
/**
|
|
10
|
-
* The ID of the MigrationState object.
|
|
10
|
+
* The hex string ID of the MigrationState object.
|
|
11
11
|
*/
|
|
12
12
|
id: string;
|
|
13
13
|
};
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export interface ISmartContractObject {
|
|
5
5
|
/**
|
|
6
|
-
* The
|
|
6
|
+
* The UID wrapper of the smart contract object.
|
|
7
7
|
*/
|
|
8
8
|
id: {
|
|
9
9
|
/**
|
|
10
|
-
* The ID of the smart contract object.
|
|
10
|
+
* The hex string ID of the smart contract object.
|
|
11
11
|
*/
|
|
12
12
|
id: string;
|
|
13
13
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PublicKey } from "@iota/iota-sdk/cryptography";
|
|
2
|
+
/**
|
|
3
|
+
* Interface for a transaction signer backed by a secure key store.
|
|
4
|
+
*/
|
|
5
|
+
export interface ITransactionSigner {
|
|
6
|
+
/**
|
|
7
|
+
* Sign the BCS-encoded transaction data and return a serialized IOTA signature string.
|
|
8
|
+
* @param txDataBcs The raw transaction bytes to sign.
|
|
9
|
+
* @returns The serialized signature string (scheme flag + signature + public key, base64-encoded).
|
|
10
|
+
*/
|
|
11
|
+
sign(txDataBcs: Uint8Array): Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Get the public key for this signer.
|
|
14
|
+
* @returns The public key.
|
|
15
|
+
*/
|
|
16
|
+
publicKey(): Promise<PublicKey>;
|
|
17
|
+
/**
|
|
18
|
+
* Get the IOTA-formatted public key bytes (scheme flag byte followed by the raw key bytes).
|
|
19
|
+
* @returns The IOTA public key bytes.
|
|
20
|
+
*/
|
|
21
|
+
iotaPublicKeyBytes(): Promise<Uint8Array>;
|
|
22
|
+
/**
|
|
23
|
+
* Get the key identifier for this signer.
|
|
24
|
+
* @returns The key identifier.
|
|
25
|
+
*/
|
|
26
|
+
keyId(): string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Jwk, JwkStorage, JwsAlgorithm } from "@iota/identity-wasm/node/index.js";
|
|
2
|
+
import type { IVaultConnector } from "@twin.org/vault-models";
|
|
3
|
+
/**
|
|
4
|
+
* JwkStorage implementation that delegates the sign operation to the vault connector,
|
|
5
|
+
* keeping the private key inside the vault at all times.
|
|
6
|
+
*/
|
|
7
|
+
export declare class VaultJwkStorage implements JwkStorage {
|
|
8
|
+
/**
|
|
9
|
+
* Runtime name for the class.
|
|
10
|
+
*/
|
|
11
|
+
static readonly CLASS_NAME: string;
|
|
12
|
+
/**
|
|
13
|
+
* Create a new VaultJwkStorage.
|
|
14
|
+
* @param vaultConnector The vault connector used to perform signing operations.
|
|
15
|
+
* @param keyName The name of the key in the vault to use for signing.
|
|
16
|
+
*/
|
|
17
|
+
constructor(vaultConnector: IVaultConnector, keyName: string);
|
|
18
|
+
/**
|
|
19
|
+
* Sign data by delegating to the vault connector.
|
|
20
|
+
* @param keyId The key identifier (unused; the vault key name is used directly).
|
|
21
|
+
* @param data The data to sign.
|
|
22
|
+
* @param publicKey The public key JWK (unused; the vault connector handles key lookup).
|
|
23
|
+
* @returns The raw signature bytes.
|
|
24
|
+
*/
|
|
25
|
+
sign(keyId: string, data: Uint8Array, publicKey: Jwk): Promise<Uint8Array>;
|
|
26
|
+
/**
|
|
27
|
+
* Accept a JWK entry and return the vault key name as the stable key identifier.
|
|
28
|
+
* @param jwk The JWK to register.
|
|
29
|
+
* @returns The key identifier.
|
|
30
|
+
*/
|
|
31
|
+
insert(jwk: Jwk): Promise<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Check whether the given key identifier is managed by this storage.
|
|
34
|
+
* @param keyId The key identifier to check.
|
|
35
|
+
* @returns True if the key exists in this storage.
|
|
36
|
+
*/
|
|
37
|
+
exists(keyId: string): Promise<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* Key generation is not supported; keys are managed entirely by the vault.
|
|
40
|
+
* @param keyType The key type requested.
|
|
41
|
+
* @param algorithm The JWS algorithm requested.
|
|
42
|
+
* @returns Never returns.
|
|
43
|
+
*/
|
|
44
|
+
generate(keyType: string, algorithm: JwsAlgorithm): Promise<never>;
|
|
45
|
+
/**
|
|
46
|
+
* Deletion is a no-op; keys are managed by the vault.
|
|
47
|
+
* @param keyId The key identifier to delete.
|
|
48
|
+
*/
|
|
49
|
+
delete(keyId: string): Promise<void>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { StorageSigner } from "@iota/identity-wasm/node/index.js";
|
|
2
|
+
import type { IVaultConnector } from "@twin.org/vault-models";
|
|
3
|
+
import type { IIotaConfig } from "./models/IIotaConfig.js";
|
|
4
|
+
/**
|
|
5
|
+
* Factory that creates a vault-backed StorageSigner for IOTA Identity operations.
|
|
6
|
+
* The private key never leaves the vault — only the raw signing operation is delegated.
|
|
7
|
+
*
|
|
8
|
+
* The returned StorageSigner is a genuine WASM object, satisfying the internal validation
|
|
9
|
+
* that IdentityClient.create() performs on the signer's iotaPublicKeyBytes() path.
|
|
10
|
+
*/
|
|
11
|
+
export declare class VaultJwtSigner {
|
|
12
|
+
/**
|
|
13
|
+
* Runtime name for the class.
|
|
14
|
+
*/
|
|
15
|
+
static readonly CLASS_NAME: string;
|
|
16
|
+
/**
|
|
17
|
+
* Create a StorageSigner whose cryptographic operations are backed by the vault connector.
|
|
18
|
+
* @param vaultConnector The vault connector.
|
|
19
|
+
* @param config The configuration.
|
|
20
|
+
* @param identity The identity of the user to access the vault keys.
|
|
21
|
+
* @param accountIndex The account index.
|
|
22
|
+
* @param addressIndex The address index within the account.
|
|
23
|
+
* @returns A StorageSigner backed by the vault for the specified key.
|
|
24
|
+
*/
|
|
25
|
+
static create(vaultConnector: IVaultConnector, config: IIotaConfig, identity: string, accountIndex: number, addressIndex: number): Promise<StorageSigner>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Signer, type SignatureScheme } from "@iota/iota-sdk/cryptography";
|
|
2
|
+
import { Ed25519PublicKey } from "@iota/iota-sdk/keypairs/ed25519";
|
|
3
|
+
import type { IVaultConnector } from "@twin.org/vault-models";
|
|
4
|
+
/**
|
|
5
|
+
* A signer that delegates all signing to the vault connector, ensuring the private key
|
|
6
|
+
* is never exposed to application code.
|
|
7
|
+
*/
|
|
8
|
+
export declare class VaultSigner extends Signer {
|
|
9
|
+
/**
|
|
10
|
+
* Create a new VaultSigner.
|
|
11
|
+
* @param vaultConnector The vault connector used to perform signing operations.
|
|
12
|
+
* @param keyName The name of the key in the vault to use for signing.
|
|
13
|
+
* @param publicKey The public key bytes corresponding to the vault key.
|
|
14
|
+
*/
|
|
15
|
+
constructor(vaultConnector: IVaultConnector, keyName: string, publicKey: Uint8Array);
|
|
16
|
+
/**
|
|
17
|
+
* Get the key scheme.
|
|
18
|
+
* @returns The signature scheme.
|
|
19
|
+
*/
|
|
20
|
+
getKeyScheme(): SignatureScheme;
|
|
21
|
+
/**
|
|
22
|
+
* Get the public key.
|
|
23
|
+
* @returns The Ed25519 public key.
|
|
24
|
+
*/
|
|
25
|
+
getPublicKey(): Ed25519PublicKey;
|
|
26
|
+
/**
|
|
27
|
+
* Sign the provided bytes via the vault connector.
|
|
28
|
+
* @param bytes The bytes to sign.
|
|
29
|
+
* @returns The raw Ed25519 signature bytes.
|
|
30
|
+
*/
|
|
31
|
+
sign(bytes: Uint8Array): Promise<Uint8Array>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type PublicKey } from "@iota/iota-sdk/cryptography";
|
|
2
|
+
import type { IVaultConnector } from "@twin.org/vault-models";
|
|
3
|
+
import type { ITransactionSigner } from "./models/ITransactionSigner.js";
|
|
4
|
+
/**
|
|
5
|
+
* A transaction signer that delegates all signing operations to the vault connector,
|
|
6
|
+
* ensuring the private key is never exposed to application code.
|
|
7
|
+
*/
|
|
8
|
+
export declare class VaultTransactionSigner implements ITransactionSigner {
|
|
9
|
+
/**
|
|
10
|
+
* Create a new VaultTransactionSigner.
|
|
11
|
+
* @param vaultConnector The vault connector used to perform signing operations.
|
|
12
|
+
* @param keyName The name of the key in the vault to use for signing.
|
|
13
|
+
* @param publicKey The public key bytes corresponding to the vault key.
|
|
14
|
+
*/
|
|
15
|
+
constructor(vaultConnector: IVaultConnector, keyName: string, publicKey: Uint8Array);
|
|
16
|
+
/**
|
|
17
|
+
* Sign the BCS-encoded transaction data.
|
|
18
|
+
* Applies the TransactionData intent, hashes the result, signs via the vault,
|
|
19
|
+
* and returns a serialized IOTA signature string.
|
|
20
|
+
* @param txDataBcs The raw transaction bytes to sign.
|
|
21
|
+
* @returns The serialized signature string.
|
|
22
|
+
*/
|
|
23
|
+
sign(txDataBcs: Uint8Array): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Get the public key for this signer.
|
|
26
|
+
* @returns The Ed25519 public key.
|
|
27
|
+
*/
|
|
28
|
+
publicKey(): Promise<PublicKey>;
|
|
29
|
+
/**
|
|
30
|
+
* Get the IOTA-formatted public key bytes (scheme flag byte followed by the raw key bytes).
|
|
31
|
+
* @returns The IOTA public key bytes.
|
|
32
|
+
*/
|
|
33
|
+
iotaPublicKeyBytes(): Promise<Uint8Array>;
|
|
34
|
+
/**
|
|
35
|
+
* Get the vault key name used by this signer.
|
|
36
|
+
* @returns The key name.
|
|
37
|
+
*/
|
|
38
|
+
keyId(): string;
|
|
39
|
+
}
|