@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.
Files changed (60) hide show
  1. package/dist/es/index.js +7 -3
  2. package/dist/es/index.js.map +1 -1
  3. package/dist/es/iota.js +356 -93
  4. package/dist/es/iota.js.map +1 -1
  5. package/dist/es/iotaIdentityUtils.js +2 -4
  6. package/dist/es/iotaIdentityUtils.js.map +1 -1
  7. package/dist/es/iotaSmartContractUtils.js +31 -27
  8. package/dist/es/iotaSmartContractUtils.js.map +1 -1
  9. package/dist/es/models/IAdminCapFields.js.map +1 -1
  10. package/dist/es/models/IGasStationExecuteResponse.js.map +1 -1
  11. package/dist/es/models/IIotaConfig.js.map +1 -1
  12. package/dist/es/models/IIotaControllerCapInfo.js.map +1 -1
  13. package/dist/es/models/IIotaResponseOptions.js.map +1 -1
  14. package/dist/es/models/IMigrationStateFields.js.map +1 -1
  15. package/dist/es/models/ISmartContractObject.js.map +1 -1
  16. package/dist/es/models/ITransactionSigner.js +2 -0
  17. package/dist/es/models/ITransactionSigner.js.map +1 -0
  18. package/dist/es/vaultJwkStorage.js +71 -0
  19. package/dist/es/vaultJwkStorage.js.map +1 -0
  20. package/dist/es/vaultJwtSigner.js +49 -0
  21. package/dist/es/vaultJwtSigner.js.map +1 -0
  22. package/dist/es/vaultSigner.js +60 -0
  23. package/dist/es/vaultSigner.js.map +1 -0
  24. package/dist/es/vaultTransactionSigner.js +74 -0
  25. package/dist/es/vaultTransactionSigner.js.map +1 -0
  26. package/dist/types/index.d.ts +7 -3
  27. package/dist/types/iota.d.ts +82 -53
  28. package/dist/types/iotaIdentityUtils.d.ts +2 -4
  29. package/dist/types/iotaSmartContractUtils.d.ts +18 -17
  30. package/dist/types/models/IAdminCapFields.d.ts +2 -2
  31. package/dist/types/models/IGasStationExecuteResponse.d.ts +1 -3
  32. package/dist/types/models/IIotaConfig.d.ts +5 -0
  33. package/dist/types/models/IIotaControllerCapInfo.d.ts +3 -6
  34. package/dist/types/models/IIotaResponseOptions.d.ts +1 -1
  35. package/dist/types/models/IMigrationStateFields.d.ts +2 -2
  36. package/dist/types/models/ISmartContractObject.d.ts +2 -2
  37. package/dist/types/models/ITransactionSigner.d.ts +27 -0
  38. package/dist/types/vaultJwkStorage.d.ts +50 -0
  39. package/dist/types/vaultJwtSigner.d.ts +26 -0
  40. package/dist/types/vaultSigner.d.ts +32 -0
  41. package/dist/types/vaultTransactionSigner.d.ts +39 -0
  42. package/docs/changelog.md +112 -0
  43. package/docs/examples.md +6 -13
  44. package/docs/reference/classes/Iota.md +325 -189
  45. package/docs/reference/classes/IotaIdentityUtils.md +2 -4
  46. package/docs/reference/classes/IotaSmartContractUtils.md +57 -40
  47. package/docs/reference/classes/VaultJwtSigner.md +71 -0
  48. package/docs/reference/classes/VaultSigner.md +106 -0
  49. package/docs/reference/classes/VaultTransactionSigner.md +122 -0
  50. package/docs/reference/index.md +4 -0
  51. package/docs/reference/interfaces/IAdminCapFields.md +2 -2
  52. package/docs/reference/interfaces/IGasStationExecuteResponse.md +1 -3
  53. package/docs/reference/interfaces/IIotaConfig.md +14 -0
  54. package/docs/reference/interfaces/IIotaControllerCapInfo.md +3 -6
  55. package/docs/reference/interfaces/IIotaResponseOptions.md +1 -1
  56. package/docs/reference/interfaces/IMigrationStateFields.md +2 -2
  57. package/docs/reference/interfaces/ISmartContractObject.md +2 -2
  58. package/docs/reference/interfaces/ITransactionSigner.md +67 -0
  59. package/locales/en.json +7 -1
  60. package/package.json +12 -12
@@ -88,43 +88,111 @@ The configuration to populate.
88
88
 
89
89
  ***
90
90
 
91
- ### getAddresses() {#getaddresses}
91
+ ### storeMnemonic() {#storemnemonic}
92
92
 
93
- > `static` **getAddresses**(`seed`, `coinType`, `accountIndex`, `startAddressIndex`, `count`, `isInternal?`): `string`[]
93
+ > `static` **storeMnemonic**(`vaultConnector`, `config`, `identity`, `mnemonic`, `accountIndex`): `Promise`\<`string`\>
94
94
 
95
- Get addresses for the identity.
95
+ Store a mnemonic in the vault, derive and store the seed, and pre-cache the first keypair chunk.
96
96
 
97
97
  #### Parameters
98
98
 
99
- ##### seed
99
+ ##### vaultConnector
100
+
101
+ `IVaultConnector`
100
102
 
101
- `Uint8Array`
103
+ The vault connector.
104
+
105
+ ##### config
102
106
 
103
- The seed to use for generating addresses.
107
+ [`IIotaConfig`](../interfaces/IIotaConfig.md)
104
108
 
105
- ##### coinType
109
+ The configuration.
106
110
 
107
- `number`
111
+ ##### identity
112
+
113
+ `string`
114
+
115
+ The identity of the user to access the vault keys.
116
+
117
+ ##### mnemonic
108
118
 
109
- The coin type to use.
119
+ `string` \| `undefined`
120
+
121
+ The mnemonic to store, if undefined a new one will be generated and returned.
110
122
 
111
123
  ##### accountIndex
112
124
 
113
125
  `number`
114
126
 
115
- The account index to get the addresses for.
127
+ The account index to pre-cache.
116
128
 
117
- ##### startAddressIndex
129
+ #### Returns
130
+
131
+ `Promise`\<`string`\>
132
+
133
+ The mnemonic that was stored.
134
+
135
+ ***
136
+
137
+ ### publicKeyToAddress() {#publickeytoaddress}
138
+
139
+ > `static` **publicKeyToAddress**(`publicKey`): `string`
140
+
141
+ Derive an address from a public key.
142
+
143
+ #### Parameters
144
+
145
+ ##### publicKey
146
+
147
+ `Uint8Array`
148
+
149
+ The public key to derive the address from.
150
+
151
+ #### Returns
152
+
153
+ `string`
154
+
155
+ The derived address.
156
+
157
+ ***
158
+
159
+ ### getAddress() {#getaddress}
160
+
161
+ > `static` **getAddress**(`vaultConnector`, `config`, `identity`, `accountIndex`, `startAddressIndex`, `isInternal?`): `Promise`\<`string`\>
162
+
163
+ Get address for the identity.
164
+
165
+ #### Parameters
166
+
167
+ ##### vaultConnector
168
+
169
+ `IVaultConnector`
170
+
171
+ The vault connector.
172
+
173
+ ##### config
174
+
175
+ `Pick`\<[`IIotaConfig`](../interfaces/IIotaConfig.md), `"coinType"` \| `"vaultMnemonicId"` \| `"vaultSeedId"`\>
176
+
177
+ The configuration.
178
+
179
+ ##### identity
180
+
181
+ `string`
182
+
183
+ The identity of the user to access the vault keys.
184
+
185
+ ##### accountIndex
118
186
 
119
187
  `number`
120
188
 
121
- The start index for the addresses.
189
+ The account index to get the addresses for.
122
190
 
123
- ##### count
191
+ ##### startAddressIndex
124
192
 
125
193
  `number`
126
194
 
127
- The number of addresses to generate.
195
+ The start index for the addresses.
128
196
 
129
197
  ##### isInternal?
130
198
 
@@ -134,63 +202,113 @@ Whether the addresses are internal.
134
202
 
135
203
  #### Returns
136
204
 
137
- `string`[]
205
+ `Promise`\<`string`\>
138
206
 
139
- The list of addresses.
207
+ The address.
140
208
 
141
209
  ***
142
210
 
143
- ### getKeyPair() {#getkeypair}
211
+ ### getAddresses() {#getaddresses}
144
212
 
145
- > `static` **getKeyPair**(`seed`, `coinType`, `accountIndex`, `addressIndex`, `isInternal?`): `object`
213
+ > `static` **getAddresses**(`vaultConnector`, `config`, `identity`, `accountIndex`, `startAddressIndex`, `count`, `isInternal?`): `Promise`\<`string`[]\>
146
214
 
147
- Get a key pair for the specified index.
215
+ Get addresses for the identity.
148
216
 
149
217
  #### Parameters
150
218
 
151
- ##### seed
219
+ ##### vaultConnector
152
220
 
153
- `Uint8Array`
221
+ `IVaultConnector`
154
222
 
155
- The seed to use for generating the key pair.
223
+ The vault connector.
156
224
 
157
- ##### coinType
225
+ ##### config
158
226
 
159
- `number`
227
+ `Pick`\<[`IIotaConfig`](../interfaces/IIotaConfig.md), `"coinType"` \| `"vaultMnemonicId"` \| `"vaultSeedId"`\>
160
228
 
161
- The coin type to use.
229
+ The configuration.
230
+
231
+ ##### identity
232
+
233
+ `string`
234
+
235
+ The identity of the user to access the vault keys.
162
236
 
163
237
  ##### accountIndex
164
238
 
165
239
  `number`
166
240
 
167
- The account index to get the key pair for.
241
+ The account index to get the addresses for.
168
242
 
169
- ##### addressIndex
243
+ ##### startAddressIndex
244
+
245
+ `number`
246
+
247
+ The start index for the addresses.
248
+
249
+ ##### count
170
250
 
171
251
  `number`
172
252
 
173
- The address index to get the key pair for.
253
+ The number of addresses to generate.
174
254
 
175
255
  ##### isInternal?
176
256
 
177
257
  `boolean`
178
258
 
179
- Whether the address is internal.
259
+ Whether the addresses are internal.
180
260
 
181
261
  #### Returns
182
262
 
183
- `object`
263
+ `Promise`\<`string`[]\>
264
+
265
+ The list of addresses.
266
+
267
+ ***
184
268
 
185
- The key pair containing private key and public key.
269
+ ### getTransactionSigner() {#gettransactionsigner}
186
270
 
187
- ##### privateKey
271
+ > `static` **getTransactionSigner**(`vaultConnector`, `config`, `identity`, `accountIndex`, `addressIndex`): `Promise`\<[`VaultTransactionSigner`](VaultTransactionSigner.md)\>
188
272
 
189
- > **privateKey**: `Uint8Array`
273
+ Get a vault-backed transaction signer for the given identity and key indices.
190
274
 
191
- ##### publicKey
275
+ #### Parameters
276
+
277
+ ##### vaultConnector
278
+
279
+ `IVaultConnector`
280
+
281
+ The vault connector.
282
+
283
+ ##### config
192
284
 
193
- > **publicKey**: `Uint8Array`
285
+ [`IIotaConfig`](../interfaces/IIotaConfig.md)
286
+
287
+ The configuration.
288
+
289
+ ##### identity
290
+
291
+ `string`
292
+
293
+ The identity of the user to access the vault keys.
294
+
295
+ ##### accountIndex
296
+
297
+ `number`
298
+
299
+ The account index.
300
+
301
+ ##### addressIndex
302
+
303
+ `number`
304
+
305
+ The address index within the account.
306
+
307
+ #### Returns
308
+
309
+ `Promise`\<[`VaultTransactionSigner`](VaultTransactionSigner.md)\>
310
+
311
+ A VaultTransactionSigner for the specified key.
194
312
 
195
313
  ***
196
314
 
@@ -342,96 +460,6 @@ The transaction response.
342
460
 
343
461
  ***
344
462
 
345
- ### getSeed() {#getseed}
346
-
347
- > `static` **getSeed**(`config`, `vaultConnector`, `identity`): `Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
348
-
349
- Get the seed from the vault.
350
-
351
- #### Parameters
352
-
353
- ##### config
354
-
355
- [`IIotaConfig`](../interfaces/IIotaConfig.md)
356
-
357
- The configuration to use.
358
-
359
- ##### vaultConnector
360
-
361
- `IVaultConnector`
362
-
363
- The vault connector to use.
364
-
365
- ##### identity
366
-
367
- `string`
368
-
369
- The identity of the user to access the vault keys.
370
-
371
- #### Returns
372
-
373
- `Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
374
-
375
- The seed.
376
-
377
- ***
378
-
379
- ### findAddress() {#findaddress}
380
-
381
- > `static` **findAddress**(`maxScanRange`, `coinType`, `seed`, `address`): `object`
382
-
383
- Find the address in the seed.
384
-
385
- #### Parameters
386
-
387
- ##### maxScanRange
388
-
389
- `number`
390
-
391
- The maximum range to scan.
392
-
393
- ##### coinType
394
-
395
- `number`
396
-
397
- The coin type to use.
398
-
399
- ##### seed
400
-
401
- `Uint8Array`
402
-
403
- The seed to use.
404
-
405
- ##### address
406
-
407
- `string`
408
-
409
- The address to find.
410
-
411
- #### Returns
412
-
413
- `object`
414
-
415
- The address key pair.
416
-
417
- ##### address
418
-
419
- > **address**: `string`
420
-
421
- ##### privateKey
422
-
423
- > **privateKey**: `Uint8Array`
424
-
425
- ##### publicKey
426
-
427
- > **publicKey**: `Uint8Array`
428
-
429
- #### Throws
430
-
431
- Error if the address is not found.
432
-
433
- ***
434
-
435
463
  ### extractPayloadError() {#extractpayloaderror}
436
464
 
437
465
  > `static` **extractPayloadError**(`error`): `IError`
@@ -455,62 +483,6 @@ The extracted error.
455
483
 
456
484
  ***
457
485
 
458
- ### buildMnemonicKey() {#buildmnemonickey}
459
-
460
- > `static` **buildMnemonicKey**(`identity`, `vaultMnemonicId?`): `string`
461
-
462
- Get the key for storing the mnemonic.
463
-
464
- #### Parameters
465
-
466
- ##### identity
467
-
468
- `string`
469
-
470
- The identity to use.
471
-
472
- ##### vaultMnemonicId?
473
-
474
- `string`
475
-
476
- The mnemonic ID to use.
477
-
478
- #### Returns
479
-
480
- `string`
481
-
482
- The mnemonic key.
483
-
484
- ***
485
-
486
- ### buildSeedKey() {#buildseedkey}
487
-
488
- > `static` **buildSeedKey**(`identity`, `vaultSeedId?`): `string`
489
-
490
- Get the key for storing the seed.
491
-
492
- #### Parameters
493
-
494
- ##### identity
495
-
496
- `string`
497
-
498
- The identity to use.
499
-
500
- ##### vaultSeedId?
501
-
502
- `string`
503
-
504
- The seed ID to use.
505
-
506
- #### Returns
507
-
508
- `string`
509
-
510
- The seed key.
511
-
512
- ***
513
-
514
486
  ### packageExistsOnNetwork() {#packageexistsonnetwork}
515
487
 
516
488
  > `static` **packageExistsOnNetwork**(`client`, `packageId`): `Promise`\<`boolean`\>
@@ -581,7 +553,7 @@ The operation to log.
581
553
 
582
554
  `Promise`\<[`IIotaDryRun`](../interfaces/IIotaDryRun.md)\>
583
555
 
584
- void.
556
+ The dry run result including status, costs, events, and object changes.
585
557
 
586
558
  ***
587
559
 
@@ -669,6 +641,28 @@ True if the error is an abort error, false otherwise.
669
641
 
670
642
  ***
671
643
 
644
+ ### extractAbortCode() {#extractabortcode}
645
+
646
+ > `static` **extractAbortCode**(`response`): `number` \| `undefined`
647
+
648
+ Extracts the abort code from a transaction result if the transaction was aborted.
649
+
650
+ #### Parameters
651
+
652
+ ##### response
653
+
654
+ `IotaTransactionBlockResponse`
655
+
656
+ The transaction result to extract the abort code from.
657
+
658
+ #### Returns
659
+
660
+ `number` \| `undefined`
661
+
662
+ The abort code if the transaction was aborted, or undefined if it was not an abort error or the code could not be extracted.
663
+
664
+ ***
665
+
672
666
  ### prepareAndPostGasStationTransaction() {#prepareandpostgasstationtransaction}
673
667
 
674
668
  > `static` **prepareAndPostGasStationTransaction**(`config`, `vaultConnector`, `identity`, `client`, `owner`, `transaction`, `options?`): `Promise`\<`IotaTransactionBlockResponse`\>
@@ -729,7 +723,7 @@ The transaction response.
729
723
 
730
724
  ### reserveGas() {#reservegas}
731
725
 
732
- > `static` **reserveGas**(`config`, `gasBudget`): `Promise`\<[`IGasReservationResult`](../interfaces/IGasReservationResult.md)\>
726
+ > `static` **reserveGas**(`config`): `Promise`\<[`IGasReservationResult`](../interfaces/IGasReservationResult.md)\>
733
727
 
734
728
  Reserve gas from the gas station.
735
729
 
@@ -741,12 +735,6 @@ Reserve gas from the gas station.
741
735
 
742
736
  The configuration containing gas station settings.
743
737
 
744
- ##### gasBudget
745
-
746
- `number`
747
-
748
- The gas budget to reserve.
749
-
750
738
  #### Returns
751
739
 
752
740
  `Promise`\<[`IGasReservationResult`](../interfaces/IGasReservationResult.md)\>
@@ -844,3 +832,151 @@ Response options including confirmation behavior.
844
832
  `Promise`\<`IotaTransactionBlockResponse`\>
845
833
 
846
834
  The transaction response (confirmed if waitForConfirmation is true).
835
+
836
+ ***
837
+
838
+ ### fundAddress() {#fundaddress}
839
+
840
+ > `static` **fundAddress**(`config`, `faucetUrl`, `identity`, `address`, `timeoutInSeconds?`): `Promise`\<`bigint`\>
841
+
842
+ Fund an address with IOTA from the faucet.
843
+
844
+ #### Parameters
845
+
846
+ ##### config
847
+
848
+ [`IIotaConfig`](../interfaces/IIotaConfig.md)
849
+
850
+ The configuration containing endpoint information.
851
+
852
+ ##### faucetUrl
853
+
854
+ `string`
855
+
856
+ The URL of the faucet to request funds from.
857
+
858
+ ##### identity
859
+
860
+ `string`
861
+
862
+ The identity of the user to access the vault keys.
863
+
864
+ ##### address
865
+
866
+ `string`
867
+
868
+ The address to fund.
869
+
870
+ ##### timeoutInSeconds?
871
+
872
+ `number` = `60`
873
+
874
+ The timeout in seconds to wait for the funding to complete.
875
+
876
+ #### Returns
877
+
878
+ `Promise`\<`bigint`\>
879
+
880
+ The amount funded.
881
+
882
+ ***
883
+
884
+ ### ensureBalance() {#ensurebalance}
885
+
886
+ > `static` **ensureBalance**(`config`, `faucetUrl`, `identity`, `address`, `ensureBalance`, `timeoutInSeconds?`): `Promise`\<`boolean`\>
887
+
888
+ Ensure the balance for the given address is at least the given amount.
889
+
890
+ #### Parameters
891
+
892
+ ##### config
893
+
894
+ [`IIotaConfig`](../interfaces/IIotaConfig.md)
895
+
896
+ The configuration containing endpoint information.
897
+
898
+ ##### faucetUrl
899
+
900
+ `string` \| `undefined`
901
+
902
+ The URL of the faucet to request funds from.
903
+
904
+ ##### identity
905
+
906
+ `string`
907
+
908
+ The identity of the user to access the vault keys.
909
+
910
+ ##### address
911
+
912
+ `string`
913
+
914
+ The address to ensure the balance for.
915
+
916
+ ##### ensureBalance
917
+
918
+ `bigint`
919
+
920
+ The minimum balance to ensure.
921
+
922
+ ##### timeoutInSeconds?
923
+
924
+ `number`
925
+
926
+ Optional timeout in seconds, defaults to 10 seconds.
927
+
928
+ #### Returns
929
+
930
+ `Promise`\<`boolean`\>
931
+
932
+ True if the balance is at least the given amount, false otherwise.
933
+
934
+ ***
935
+
936
+ ### getBalance() {#getbalance}
937
+
938
+ > `static` **getBalance**(`config`, `address`): `Promise`\<`bigint`\>
939
+
940
+ Get the balance for the given address.
941
+
942
+ #### Parameters
943
+
944
+ ##### config
945
+
946
+ [`IIotaConfig`](../interfaces/IIotaConfig.md)
947
+
948
+ The configuration containing endpoint information.
949
+
950
+ ##### address
951
+
952
+ `string`
953
+
954
+ The address to get the balance for.
955
+
956
+ #### Returns
957
+
958
+ `Promise`\<`bigint`\>
959
+
960
+ The balance of the given address.
961
+
962
+ ***
963
+
964
+ ### transactionFromBytes() {#transactionfrombytes}
965
+
966
+ > `static` **transactionFromBytes**(`bytes`): `Transaction`
967
+
968
+ Create a transaction instance from the given bytes.
969
+
970
+ #### Parameters
971
+
972
+ ##### bytes
973
+
974
+ `Uint8Array`
975
+
976
+ The transaction bytes to create the transaction from.
977
+
978
+ #### Returns
979
+
980
+ `Transaction`
981
+
982
+ The transaction instance created from the given bytes.
@@ -1,7 +1,6 @@
1
1
  # Class: IotaIdentityUtils
2
2
 
3
- Utility class for resolving IOTA Identity on-chain objects required by
4
- the NFT mint_with_identity() Move contract function.
3
+ Utility class for resolving IOTA Identity on-chain objects and controller tokens.
5
4
 
6
5
  ## Constructors
7
6
 
@@ -27,8 +26,7 @@ Runtime name for the class.
27
26
 
28
27
  > `static` **getControllerCapInfo**(`identityId`, `controllerAddress`, `client`): `Promise`\<[`IIotaControllerCapInfo`](../interfaces/IIotaControllerCapInfo.md)\>
29
28
 
30
- Resolve the on-chain object IDs for an identity and its controller token.
31
- Returns the IDs needed to call mint_with_identity() on the NFT Move contract.
29
+ Resolves the on-chain object IDs for an identity and its controller token.
32
30
 
33
31
  #### Parameters
34
32