@twin.org/wallet-connector-iota 0.0.1-next.3

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2024 IOTA Stiftung.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # TWIN Wallet Connector IOTA
2
+
3
+ Wallet connector implementation using IOTA.
4
+
5
+ ## Installation
6
+
7
+ ```shell
8
+ npm install @twin.org/wallet-connector-iota
9
+ ```
10
+
11
+ ## Examples
12
+
13
+ Usage of the APIs is shown in the examples [docs/examples.md](docs/examples.md)
14
+
15
+ ## Reference
16
+
17
+ Detailed reference documentation for the API can be found in [docs/reference/index.md](docs/reference/index.md)
18
+
19
+ ## Changelog
20
+
21
+ The changes between each version can be found in [docs/changelog.md](docs/changelog.md)
@@ -0,0 +1,264 @@
1
+ 'use strict';
2
+
3
+ var index_js = require('@iota/sdk-wasm/node/lib/index.js');
4
+ var core = require('@twin.org/core');
5
+ var dltIota = require('@twin.org/dlt-iota');
6
+ var crypto = require('@twin.org/crypto');
7
+ var vaultModels = require('@twin.org/vault-models');
8
+ var walletModels = require('@twin.org/wallet-models');
9
+
10
+ // Copyright 2024 IOTA Stiftung.
11
+ // SPDX-License-Identifier: Apache-2.0.
12
+ /**
13
+ * Class for performing faucet operations on IOTA.
14
+ */
15
+ class IotaFaucetConnector {
16
+ /**
17
+ * The namespace supported by the wallet connector.
18
+ */
19
+ static NAMESPACE = "iota";
20
+ /**
21
+ * Runtime name for the class.
22
+ */
23
+ CLASS_NAME = "IotaFaucetConnector";
24
+ /**
25
+ * The configuration to use for tangle operations.
26
+ * @internal
27
+ */
28
+ _config;
29
+ /**
30
+ * The IOTA Wallet client.
31
+ * @internal
32
+ */
33
+ _client;
34
+ /**
35
+ * Create a new instance of IotaFaucetConnector.
36
+ * @param options The options for the connector.
37
+ * @param options.config The configuration to use.
38
+ */
39
+ constructor(options) {
40
+ core.Guards.object(this.CLASS_NAME, "options", options);
41
+ core.Guards.object(this.CLASS_NAME, "options.config", options.config);
42
+ core.Guards.object(this.CLASS_NAME, "options.config.clientOptions", options.config.clientOptions);
43
+ core.Guards.stringValue(this.CLASS_NAME, "options.config.endpoint", options.config.endpoint);
44
+ this._config = options.config;
45
+ }
46
+ /**
47
+ * Fund the wallet from the faucet.
48
+ * @param identity The identity of the user to access the vault keys.
49
+ * @param address The bech32 encoded address of the address to fund.
50
+ * @param timeoutInSeconds The timeout in seconds to wait for the funding to complete.
51
+ * @returns The amount added to the address by the faucet.
52
+ */
53
+ async fundAddress(identity, address, timeoutInSeconds = 60) {
54
+ core.Guards.stringValue(this.CLASS_NAME, "identity", identity);
55
+ try {
56
+ const client = await this.createClient();
57
+ const oldBalance = await this.getBalance(address);
58
+ await client.requestFundsFromFaucet(this._config.endpoint, address);
59
+ const numTries = Math.ceil(timeoutInSeconds / 5);
60
+ for (let i = 0; i < numTries; i++) {
61
+ const newBalance = await this.getBalance(address);
62
+ if (newBalance > oldBalance) {
63
+ // The balance increased so we can return the new balance
64
+ return newBalance - oldBalance;
65
+ }
66
+ // Still waiting for the balance to update so wait and try again
67
+ await new Promise(resolve => setTimeout(resolve, 5000));
68
+ }
69
+ }
70
+ catch (error) {
71
+ throw new core.GeneralError(this.CLASS_NAME, "fundingFailed", undefined, dltIota.Iota.extractPayloadError(error));
72
+ }
73
+ return 0n;
74
+ }
75
+ /**
76
+ * Calculate the balance on an address.
77
+ * @param address The bech32 encoded address to get the balance.
78
+ * @returns The amount available on the wallet address.
79
+ * @internal
80
+ */
81
+ async getBalance(address) {
82
+ const client = await this.createClient();
83
+ const outputIds = await client.basicOutputIds([
84
+ { address },
85
+ { hasExpiration: false },
86
+ { hasTimelock: false },
87
+ { hasStorageDepositReturn: false }
88
+ ]);
89
+ const outputs = await client.getOutputs(outputIds.items);
90
+ let totalAmount = BigInt(0);
91
+ for (const output of outputs) {
92
+ totalAmount += output.output.getAmount();
93
+ }
94
+ return totalAmount;
95
+ }
96
+ /**
97
+ * Create a client for the IOTA network.
98
+ * @returns The client.
99
+ * @internal
100
+ */
101
+ async createClient() {
102
+ if (!this._client) {
103
+ this._client = new index_js.Client(this._config.clientOptions);
104
+ }
105
+ return this._client;
106
+ }
107
+ }
108
+
109
+ // Copyright 2024 IOTA Stiftung.
110
+ // SPDX-License-Identifier: Apache-2.0.
111
+ /**
112
+ * Class for performing wallet operations on IOTA.
113
+ */
114
+ class IotaWalletConnector {
115
+ /**
116
+ * The namespace supported by the wallet connector.
117
+ */
118
+ static NAMESPACE = "iota";
119
+ /**
120
+ * Runtime name for the class.
121
+ */
122
+ CLASS_NAME = "IotaWalletConnector";
123
+ /**
124
+ * The configuration to use for tangle operations.
125
+ * @internal
126
+ */
127
+ _config;
128
+ /**
129
+ * The vault for the mnemonic or seed.
130
+ * @internal
131
+ */
132
+ _vaultConnector;
133
+ /**
134
+ * The IOTA faucet.
135
+ * @internal
136
+ */
137
+ _faucetConnector;
138
+ /**
139
+ * Create a new instance of IotaWalletConnector.
140
+ * @param options The options for the wallet connector.
141
+ * @param options.vaultConnectorType Vault connector to use for wallet secrets, defaults to "vault".
142
+ * @param options.faucetConnectorType Optional faucet for requesting funds, defaults to "faucet".
143
+ * @param options.config The configuration to use.
144
+ */
145
+ constructor(options) {
146
+ core.Guards.object(this.CLASS_NAME, "options", options);
147
+ core.Guards.object(this.CLASS_NAME, "options.config", options.config);
148
+ core.Guards.object(this.CLASS_NAME, "options.config.clientOptions", options.config.clientOptions);
149
+ this._vaultConnector = vaultModels.VaultConnectorFactory.get(options?.vaultConnectorType ?? "vault");
150
+ this._faucetConnector = walletModels.FaucetConnectorFactory.getIfExists(options?.faucetConnectorType ?? "faucet");
151
+ this._config = options.config;
152
+ dltIota.Iota.populateConfig(this._config);
153
+ }
154
+ /**
155
+ * Create a new wallet.
156
+ * @param identity The identity of the user to access the vault keys.
157
+ * @returns Nothing.
158
+ */
159
+ async create(identity) {
160
+ core.Guards.stringValue(this.CLASS_NAME, "identity", identity);
161
+ const mnemonic = crypto.Bip39.randomMnemonic();
162
+ await this._vaultConnector.setSecret(dltIota.Iota.buildMnemonicKey(this._config, identity), mnemonic);
163
+ const seed = crypto.Bip39.mnemonicToSeed(mnemonic);
164
+ await this._vaultConnector.setSecret(dltIota.Iota.buildSeedKey(this._config, identity), core.Converter.bytesToBase64(seed));
165
+ }
166
+ /**
167
+ * Get the addresses for the requested range.
168
+ * @param identity The identity of the user to access the vault keys.
169
+ * @param accountIndex The account index to get the addresses for.
170
+ * @param startAddressIndex The start index for the addresses.
171
+ * @param count The number of addresses to generate.
172
+ * @returns The list of addresses.
173
+ */
174
+ async getAddresses(identity, accountIndex, startAddressIndex, count) {
175
+ return dltIota.Iota.getAddresses(this._config, this._vaultConnector, identity, accountIndex, startAddressIndex, count);
176
+ }
177
+ /**
178
+ * Get the balance for an address in a wallet.
179
+ * @param identity The identity of the user to access the vault keys.
180
+ * @param address The bech32 encoded address.
181
+ * @returns The balance of the wallet address.
182
+ */
183
+ async getBalance(identity, address) {
184
+ core.Guards.stringValue(this.CLASS_NAME, "identity", identity);
185
+ core.Guards.stringValue(this.CLASS_NAME, "address", address);
186
+ const client = new index_js.Client(this._config.clientOptions);
187
+ const outputIds = await client.basicOutputIds([
188
+ { address },
189
+ { hasExpiration: false },
190
+ { hasTimelock: false },
191
+ { hasStorageDepositReturn: false }
192
+ ]);
193
+ const outputs = await client.getOutputs(outputIds.items);
194
+ let totalAmount = BigInt(0);
195
+ for (const output of outputs) {
196
+ totalAmount += output.output.getAmount();
197
+ }
198
+ return totalAmount;
199
+ }
200
+ /**
201
+ * Ensure the balance for an address in a wallet.
202
+ * @param identity The identity of the user to access the vault keys.
203
+ * @param address The bech32 encoded address.
204
+ * @param ensureBalance The balance to ensure on the address.
205
+ * @param timeoutInSeconds The timeout in seconds to wait for the funding to complete.
206
+ * @returns True if the balance has been ensured.
207
+ */
208
+ async ensureBalance(identity, address, ensureBalance, timeoutInSeconds) {
209
+ core.Guards.stringValue(this.CLASS_NAME, "identity", identity);
210
+ core.Guards.stringValue(this.CLASS_NAME, "address", address);
211
+ core.Guards.bigint(this.CLASS_NAME, "ensureBalance", ensureBalance);
212
+ if (this._faucetConnector) {
213
+ let retryCount = 10;
214
+ let currentBalance = await this.getBalance(identity, address);
215
+ while (currentBalance < ensureBalance && retryCount > 0) {
216
+ const addedBalance = await this._faucetConnector.fundAddress(identity, address, timeoutInSeconds);
217
+ if (addedBalance === 0n) {
218
+ // The balance has not increased, so return.
219
+ return false;
220
+ }
221
+ currentBalance += addedBalance;
222
+ if (currentBalance < ensureBalance) {
223
+ // The balance has increased but is still not enough, wait a second and try again.
224
+ await new Promise(resolve => setTimeout(resolve, 1000));
225
+ retryCount--;
226
+ }
227
+ }
228
+ return currentBalance >= ensureBalance;
229
+ }
230
+ return false;
231
+ }
232
+ /**
233
+ * Transfer funds to an address.
234
+ * @param identity The identity of the user to access the vault keys.
235
+ * @param addressSource The bech32 encoded address to send the funds from.
236
+ * @param addressDest The bech32 encoded address to send the funds to.
237
+ * @param amount The amount to transfer.
238
+ * @returns An identifier for the transfer if there was one.
239
+ */
240
+ async transfer(identity, addressSource, addressDest, amount) {
241
+ core.Guards.stringValue(this.CLASS_NAME, "identity", identity);
242
+ core.Guards.stringValue(this.CLASS_NAME, "addressSource", addressSource);
243
+ core.Guards.stringValue(this.CLASS_NAME, "addressDest", addressDest);
244
+ core.Guards.bigint(this.CLASS_NAME, "amount", amount);
245
+ try {
246
+ const client = new index_js.Client(this._config.clientOptions);
247
+ const inputs = await client.findInputs([addressSource], amount);
248
+ const blockDetails = await dltIota.Iota.prepareAndPostTransaction(this._config, this._vaultConnector, identity, client, {
249
+ inputs,
250
+ output: {
251
+ address: addressDest,
252
+ amount: amount.toString()
253
+ }
254
+ });
255
+ return blockDetails.blockId;
256
+ }
257
+ catch (error) {
258
+ throw new core.GeneralError(this.CLASS_NAME, "transferFailed", undefined, dltIota.Iota.extractPayloadError(error));
259
+ }
260
+ }
261
+ }
262
+
263
+ exports.IotaFaucetConnector = IotaFaucetConnector;
264
+ exports.IotaWalletConnector = IotaWalletConnector;
Binary file
@@ -0,0 +1,261 @@
1
+ import { Client } from '@iota/sdk-wasm/node/lib/index.js';
2
+ import { Guards, GeneralError, Converter } from '@twin.org/core';
3
+ import { Iota } from '@twin.org/dlt-iota';
4
+ import { Bip39 } from '@twin.org/crypto';
5
+ import { VaultConnectorFactory } from '@twin.org/vault-models';
6
+ import { FaucetConnectorFactory } from '@twin.org/wallet-models';
7
+
8
+ // Copyright 2024 IOTA Stiftung.
9
+ // SPDX-License-Identifier: Apache-2.0.
10
+ /**
11
+ * Class for performing faucet operations on IOTA.
12
+ */
13
+ class IotaFaucetConnector {
14
+ /**
15
+ * The namespace supported by the wallet connector.
16
+ */
17
+ static NAMESPACE = "iota";
18
+ /**
19
+ * Runtime name for the class.
20
+ */
21
+ CLASS_NAME = "IotaFaucetConnector";
22
+ /**
23
+ * The configuration to use for tangle operations.
24
+ * @internal
25
+ */
26
+ _config;
27
+ /**
28
+ * The IOTA Wallet client.
29
+ * @internal
30
+ */
31
+ _client;
32
+ /**
33
+ * Create a new instance of IotaFaucetConnector.
34
+ * @param options The options for the connector.
35
+ * @param options.config The configuration to use.
36
+ */
37
+ constructor(options) {
38
+ Guards.object(this.CLASS_NAME, "options", options);
39
+ Guards.object(this.CLASS_NAME, "options.config", options.config);
40
+ Guards.object(this.CLASS_NAME, "options.config.clientOptions", options.config.clientOptions);
41
+ Guards.stringValue(this.CLASS_NAME, "options.config.endpoint", options.config.endpoint);
42
+ this._config = options.config;
43
+ }
44
+ /**
45
+ * Fund the wallet from the faucet.
46
+ * @param identity The identity of the user to access the vault keys.
47
+ * @param address The bech32 encoded address of the address to fund.
48
+ * @param timeoutInSeconds The timeout in seconds to wait for the funding to complete.
49
+ * @returns The amount added to the address by the faucet.
50
+ */
51
+ async fundAddress(identity, address, timeoutInSeconds = 60) {
52
+ Guards.stringValue(this.CLASS_NAME, "identity", identity);
53
+ try {
54
+ const client = await this.createClient();
55
+ const oldBalance = await this.getBalance(address);
56
+ await client.requestFundsFromFaucet(this._config.endpoint, address);
57
+ const numTries = Math.ceil(timeoutInSeconds / 5);
58
+ for (let i = 0; i < numTries; i++) {
59
+ const newBalance = await this.getBalance(address);
60
+ if (newBalance > oldBalance) {
61
+ // The balance increased so we can return the new balance
62
+ return newBalance - oldBalance;
63
+ }
64
+ // Still waiting for the balance to update so wait and try again
65
+ await new Promise(resolve => setTimeout(resolve, 5000));
66
+ }
67
+ }
68
+ catch (error) {
69
+ throw new GeneralError(this.CLASS_NAME, "fundingFailed", undefined, Iota.extractPayloadError(error));
70
+ }
71
+ return 0n;
72
+ }
73
+ /**
74
+ * Calculate the balance on an address.
75
+ * @param address The bech32 encoded address to get the balance.
76
+ * @returns The amount available on the wallet address.
77
+ * @internal
78
+ */
79
+ async getBalance(address) {
80
+ const client = await this.createClient();
81
+ const outputIds = await client.basicOutputIds([
82
+ { address },
83
+ { hasExpiration: false },
84
+ { hasTimelock: false },
85
+ { hasStorageDepositReturn: false }
86
+ ]);
87
+ const outputs = await client.getOutputs(outputIds.items);
88
+ let totalAmount = BigInt(0);
89
+ for (const output of outputs) {
90
+ totalAmount += output.output.getAmount();
91
+ }
92
+ return totalAmount;
93
+ }
94
+ /**
95
+ * Create a client for the IOTA network.
96
+ * @returns The client.
97
+ * @internal
98
+ */
99
+ async createClient() {
100
+ if (!this._client) {
101
+ this._client = new Client(this._config.clientOptions);
102
+ }
103
+ return this._client;
104
+ }
105
+ }
106
+
107
+ // Copyright 2024 IOTA Stiftung.
108
+ // SPDX-License-Identifier: Apache-2.0.
109
+ /**
110
+ * Class for performing wallet operations on IOTA.
111
+ */
112
+ class IotaWalletConnector {
113
+ /**
114
+ * The namespace supported by the wallet connector.
115
+ */
116
+ static NAMESPACE = "iota";
117
+ /**
118
+ * Runtime name for the class.
119
+ */
120
+ CLASS_NAME = "IotaWalletConnector";
121
+ /**
122
+ * The configuration to use for tangle operations.
123
+ * @internal
124
+ */
125
+ _config;
126
+ /**
127
+ * The vault for the mnemonic or seed.
128
+ * @internal
129
+ */
130
+ _vaultConnector;
131
+ /**
132
+ * The IOTA faucet.
133
+ * @internal
134
+ */
135
+ _faucetConnector;
136
+ /**
137
+ * Create a new instance of IotaWalletConnector.
138
+ * @param options The options for the wallet connector.
139
+ * @param options.vaultConnectorType Vault connector to use for wallet secrets, defaults to "vault".
140
+ * @param options.faucetConnectorType Optional faucet for requesting funds, defaults to "faucet".
141
+ * @param options.config The configuration to use.
142
+ */
143
+ constructor(options) {
144
+ Guards.object(this.CLASS_NAME, "options", options);
145
+ Guards.object(this.CLASS_NAME, "options.config", options.config);
146
+ Guards.object(this.CLASS_NAME, "options.config.clientOptions", options.config.clientOptions);
147
+ this._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? "vault");
148
+ this._faucetConnector = FaucetConnectorFactory.getIfExists(options?.faucetConnectorType ?? "faucet");
149
+ this._config = options.config;
150
+ Iota.populateConfig(this._config);
151
+ }
152
+ /**
153
+ * Create a new wallet.
154
+ * @param identity The identity of the user to access the vault keys.
155
+ * @returns Nothing.
156
+ */
157
+ async create(identity) {
158
+ Guards.stringValue(this.CLASS_NAME, "identity", identity);
159
+ const mnemonic = Bip39.randomMnemonic();
160
+ await this._vaultConnector.setSecret(Iota.buildMnemonicKey(this._config, identity), mnemonic);
161
+ const seed = Bip39.mnemonicToSeed(mnemonic);
162
+ await this._vaultConnector.setSecret(Iota.buildSeedKey(this._config, identity), Converter.bytesToBase64(seed));
163
+ }
164
+ /**
165
+ * Get the addresses for the requested range.
166
+ * @param identity The identity of the user to access the vault keys.
167
+ * @param accountIndex The account index to get the addresses for.
168
+ * @param startAddressIndex The start index for the addresses.
169
+ * @param count The number of addresses to generate.
170
+ * @returns The list of addresses.
171
+ */
172
+ async getAddresses(identity, accountIndex, startAddressIndex, count) {
173
+ return Iota.getAddresses(this._config, this._vaultConnector, identity, accountIndex, startAddressIndex, count);
174
+ }
175
+ /**
176
+ * Get the balance for an address in a wallet.
177
+ * @param identity The identity of the user to access the vault keys.
178
+ * @param address The bech32 encoded address.
179
+ * @returns The balance of the wallet address.
180
+ */
181
+ async getBalance(identity, address) {
182
+ Guards.stringValue(this.CLASS_NAME, "identity", identity);
183
+ Guards.stringValue(this.CLASS_NAME, "address", address);
184
+ const client = new Client(this._config.clientOptions);
185
+ const outputIds = await client.basicOutputIds([
186
+ { address },
187
+ { hasExpiration: false },
188
+ { hasTimelock: false },
189
+ { hasStorageDepositReturn: false }
190
+ ]);
191
+ const outputs = await client.getOutputs(outputIds.items);
192
+ let totalAmount = BigInt(0);
193
+ for (const output of outputs) {
194
+ totalAmount += output.output.getAmount();
195
+ }
196
+ return totalAmount;
197
+ }
198
+ /**
199
+ * Ensure the balance for an address in a wallet.
200
+ * @param identity The identity of the user to access the vault keys.
201
+ * @param address The bech32 encoded address.
202
+ * @param ensureBalance The balance to ensure on the address.
203
+ * @param timeoutInSeconds The timeout in seconds to wait for the funding to complete.
204
+ * @returns True if the balance has been ensured.
205
+ */
206
+ async ensureBalance(identity, address, ensureBalance, timeoutInSeconds) {
207
+ Guards.stringValue(this.CLASS_NAME, "identity", identity);
208
+ Guards.stringValue(this.CLASS_NAME, "address", address);
209
+ Guards.bigint(this.CLASS_NAME, "ensureBalance", ensureBalance);
210
+ if (this._faucetConnector) {
211
+ let retryCount = 10;
212
+ let currentBalance = await this.getBalance(identity, address);
213
+ while (currentBalance < ensureBalance && retryCount > 0) {
214
+ const addedBalance = await this._faucetConnector.fundAddress(identity, address, timeoutInSeconds);
215
+ if (addedBalance === 0n) {
216
+ // The balance has not increased, so return.
217
+ return false;
218
+ }
219
+ currentBalance += addedBalance;
220
+ if (currentBalance < ensureBalance) {
221
+ // The balance has increased but is still not enough, wait a second and try again.
222
+ await new Promise(resolve => setTimeout(resolve, 1000));
223
+ retryCount--;
224
+ }
225
+ }
226
+ return currentBalance >= ensureBalance;
227
+ }
228
+ return false;
229
+ }
230
+ /**
231
+ * Transfer funds to an address.
232
+ * @param identity The identity of the user to access the vault keys.
233
+ * @param addressSource The bech32 encoded address to send the funds from.
234
+ * @param addressDest The bech32 encoded address to send the funds to.
235
+ * @param amount The amount to transfer.
236
+ * @returns An identifier for the transfer if there was one.
237
+ */
238
+ async transfer(identity, addressSource, addressDest, amount) {
239
+ Guards.stringValue(this.CLASS_NAME, "identity", identity);
240
+ Guards.stringValue(this.CLASS_NAME, "addressSource", addressSource);
241
+ Guards.stringValue(this.CLASS_NAME, "addressDest", addressDest);
242
+ Guards.bigint(this.CLASS_NAME, "amount", amount);
243
+ try {
244
+ const client = new Client(this._config.clientOptions);
245
+ const inputs = await client.findInputs([addressSource], amount);
246
+ const blockDetails = await Iota.prepareAndPostTransaction(this._config, this._vaultConnector, identity, client, {
247
+ inputs,
248
+ output: {
249
+ address: addressDest,
250
+ amount: amount.toString()
251
+ }
252
+ });
253
+ return blockDetails.blockId;
254
+ }
255
+ catch (error) {
256
+ throw new GeneralError(this.CLASS_NAME, "transferFailed", undefined, Iota.extractPayloadError(error));
257
+ }
258
+ }
259
+ }
260
+
261
+ export { IotaFaucetConnector, IotaWalletConnector };
Binary file
@@ -0,0 +1,4 @@
1
+ export * from "./iotaFaucetConnector";
2
+ export * from "./iotaWalletConnector";
3
+ export * from "./models/IIotaFaucetConnectorConfig";
4
+ export * from "./models/IIotaWalletConnectorConfig";
@@ -0,0 +1,31 @@
1
+ import type { IFaucetConnector } from "@twin.org/wallet-models";
2
+ import type { IIotaFaucetConnectorConfig } from "./models/IIotaFaucetConnectorConfig";
3
+ /**
4
+ * Class for performing faucet operations on IOTA.
5
+ */
6
+ export declare class IotaFaucetConnector implements IFaucetConnector {
7
+ /**
8
+ * The namespace supported by the wallet connector.
9
+ */
10
+ static readonly NAMESPACE: string;
11
+ /**
12
+ * Runtime name for the class.
13
+ */
14
+ readonly CLASS_NAME: string;
15
+ /**
16
+ * Create a new instance of IotaFaucetConnector.
17
+ * @param options The options for the connector.
18
+ * @param options.config The configuration to use.
19
+ */
20
+ constructor(options: {
21
+ config: IIotaFaucetConnectorConfig;
22
+ });
23
+ /**
24
+ * Fund the wallet from the faucet.
25
+ * @param identity The identity of the user to access the vault keys.
26
+ * @param address The bech32 encoded address of the address to fund.
27
+ * @param timeoutInSeconds The timeout in seconds to wait for the funding to complete.
28
+ * @returns The amount added to the address by the faucet.
29
+ */
30
+ fundAddress(identity: string, address: string, timeoutInSeconds?: number): Promise<bigint>;
31
+ }
@@ -0,0 +1,67 @@
1
+ import { type IWalletConnector } from "@twin.org/wallet-models";
2
+ import type { IIotaWalletConnectorConfig } from "./models/IIotaWalletConnectorConfig";
3
+ /**
4
+ * Class for performing wallet operations on IOTA.
5
+ */
6
+ export declare class IotaWalletConnector implements IWalletConnector {
7
+ /**
8
+ * The namespace supported by the wallet connector.
9
+ */
10
+ static readonly NAMESPACE: string;
11
+ /**
12
+ * Runtime name for the class.
13
+ */
14
+ readonly CLASS_NAME: string;
15
+ /**
16
+ * Create a new instance of IotaWalletConnector.
17
+ * @param options The options for the wallet connector.
18
+ * @param options.vaultConnectorType Vault connector to use for wallet secrets, defaults to "vault".
19
+ * @param options.faucetConnectorType Optional faucet for requesting funds, defaults to "faucet".
20
+ * @param options.config The configuration to use.
21
+ */
22
+ constructor(options: {
23
+ vaultConnectorType?: string;
24
+ faucetConnectorType?: string;
25
+ config: IIotaWalletConnectorConfig;
26
+ });
27
+ /**
28
+ * Create a new wallet.
29
+ * @param identity The identity of the user to access the vault keys.
30
+ * @returns Nothing.
31
+ */
32
+ create(identity: string): Promise<void>;
33
+ /**
34
+ * Get the addresses for the requested range.
35
+ * @param identity The identity of the user to access the vault keys.
36
+ * @param accountIndex The account index to get the addresses for.
37
+ * @param startAddressIndex The start index for the addresses.
38
+ * @param count The number of addresses to generate.
39
+ * @returns The list of addresses.
40
+ */
41
+ getAddresses(identity: string, accountIndex: number, startAddressIndex: number, count: number): Promise<string[]>;
42
+ /**
43
+ * Get the balance for an address in a wallet.
44
+ * @param identity The identity of the user to access the vault keys.
45
+ * @param address The bech32 encoded address.
46
+ * @returns The balance of the wallet address.
47
+ */
48
+ getBalance(identity: string, address: string): Promise<bigint>;
49
+ /**
50
+ * Ensure the balance for an address in a wallet.
51
+ * @param identity The identity of the user to access the vault keys.
52
+ * @param address The bech32 encoded address.
53
+ * @param ensureBalance The balance to ensure on the address.
54
+ * @param timeoutInSeconds The timeout in seconds to wait for the funding to complete.
55
+ * @returns True if the balance has been ensured.
56
+ */
57
+ ensureBalance(identity: string, address: string, ensureBalance: bigint, timeoutInSeconds?: number): Promise<boolean>;
58
+ /**
59
+ * Transfer funds to an address.
60
+ * @param identity The identity of the user to access the vault keys.
61
+ * @param addressSource The bech32 encoded address to send the funds from.
62
+ * @param addressDest The bech32 encoded address to send the funds to.
63
+ * @param amount The amount to transfer.
64
+ * @returns An identifier for the transfer if there was one.
65
+ */
66
+ transfer(identity: string, addressSource: string, addressDest: string, amount: bigint): Promise<string | undefined>;
67
+ }
@@ -0,0 +1,14 @@
1
+ import type { IClientOptions } from "@iota/sdk-wasm/node/lib/index.js";
2
+ /**
3
+ * Configuration for the IOTA Faucet Connector.
4
+ */
5
+ export interface IIotaFaucetConnectorConfig {
6
+ /**
7
+ * The configuration for the client.
8
+ */
9
+ clientOptions: IClientOptions;
10
+ /**
11
+ * The endpoint for the faucet.
12
+ */
13
+ endpoint: string;
14
+ }
@@ -0,0 +1,5 @@
1
+ import type { IIotaConfig } from "@twin.org/dlt-iota";
2
+ /**
3
+ * Configuration for the IOTA Wallet Connector.
4
+ */
5
+ export type IIotaWalletConnectorConfig = IIotaConfig;
@@ -0,0 +1,5 @@
1
+ # @twin.org/wallet-connector-iota - Changelog
2
+
3
+ ## v0.0.1-next.3
4
+
5
+ - Initial Release
@@ -0,0 +1 @@
1
+ # @twin.org/wallet-connector-iota - Examples
@@ -0,0 +1,81 @@
1
+ # Class: IotaFaucetConnector
2
+
3
+ Class for performing faucet operations on IOTA.
4
+
5
+ ## Implements
6
+
7
+ - `IFaucetConnector`
8
+
9
+ ## Constructors
10
+
11
+ ### new IotaFaucetConnector()
12
+
13
+ > **new IotaFaucetConnector**(`options`): [`IotaFaucetConnector`](IotaFaucetConnector.md)
14
+
15
+ Create a new instance of IotaFaucetConnector.
16
+
17
+ #### Parameters
18
+
19
+ • **options**
20
+
21
+ The options for the connector.
22
+
23
+ • **options.config**: [`IIotaFaucetConnectorConfig`](../interfaces/IIotaFaucetConnectorConfig.md)
24
+
25
+ The configuration to use.
26
+
27
+ #### Returns
28
+
29
+ [`IotaFaucetConnector`](IotaFaucetConnector.md)
30
+
31
+ ## Properties
32
+
33
+ ### NAMESPACE
34
+
35
+ > `readonly` `static` **NAMESPACE**: `string` = `"iota"`
36
+
37
+ The namespace supported by the wallet connector.
38
+
39
+ ***
40
+
41
+ ### CLASS\_NAME
42
+
43
+ > `readonly` **CLASS\_NAME**: `string`
44
+
45
+ Runtime name for the class.
46
+
47
+ #### Implementation of
48
+
49
+ `IFaucetConnector.CLASS_NAME`
50
+
51
+ ## Methods
52
+
53
+ ### fundAddress()
54
+
55
+ > **fundAddress**(`identity`, `address`, `timeoutInSeconds`): `Promise`\<`bigint`\>
56
+
57
+ Fund the wallet from the faucet.
58
+
59
+ #### Parameters
60
+
61
+ • **identity**: `string`
62
+
63
+ The identity of the user to access the vault keys.
64
+
65
+ • **address**: `string`
66
+
67
+ The bech32 encoded address of the address to fund.
68
+
69
+ • **timeoutInSeconds**: `number` = `60`
70
+
71
+ The timeout in seconds to wait for the funding to complete.
72
+
73
+ #### Returns
74
+
75
+ `Promise`\<`bigint`\>
76
+
77
+ The amount added to the address by the faucet.
78
+
79
+ #### Implementation of
80
+
81
+ `IFaucetConnector.fundAddress`
@@ -0,0 +1,217 @@
1
+ # Class: IotaWalletConnector
2
+
3
+ Class for performing wallet operations on IOTA.
4
+
5
+ ## Implements
6
+
7
+ - `IWalletConnector`
8
+
9
+ ## Constructors
10
+
11
+ ### new IotaWalletConnector()
12
+
13
+ > **new IotaWalletConnector**(`options`): [`IotaWalletConnector`](IotaWalletConnector.md)
14
+
15
+ Create a new instance of IotaWalletConnector.
16
+
17
+ #### Parameters
18
+
19
+ • **options**
20
+
21
+ The options for the wallet connector.
22
+
23
+ • **options.vaultConnectorType?**: `string`
24
+
25
+ Vault connector to use for wallet secrets, defaults to "vault".
26
+
27
+ • **options.faucetConnectorType?**: `string`
28
+
29
+ Optional faucet for requesting funds, defaults to "faucet".
30
+
31
+ • **options.config**: `IIotaConfig`
32
+
33
+ The configuration to use.
34
+
35
+ #### Returns
36
+
37
+ [`IotaWalletConnector`](IotaWalletConnector.md)
38
+
39
+ ## Properties
40
+
41
+ ### NAMESPACE
42
+
43
+ > `readonly` `static` **NAMESPACE**: `string` = `"iota"`
44
+
45
+ The namespace supported by the wallet connector.
46
+
47
+ ***
48
+
49
+ ### CLASS\_NAME
50
+
51
+ > `readonly` **CLASS\_NAME**: `string`
52
+
53
+ Runtime name for the class.
54
+
55
+ #### Implementation of
56
+
57
+ `IWalletConnector.CLASS_NAME`
58
+
59
+ ## Methods
60
+
61
+ ### create()
62
+
63
+ > **create**(`identity`): `Promise`\<`void`\>
64
+
65
+ Create a new wallet.
66
+
67
+ #### Parameters
68
+
69
+ • **identity**: `string`
70
+
71
+ The identity of the user to access the vault keys.
72
+
73
+ #### Returns
74
+
75
+ `Promise`\<`void`\>
76
+
77
+ Nothing.
78
+
79
+ #### Implementation of
80
+
81
+ `IWalletConnector.create`
82
+
83
+ ***
84
+
85
+ ### getAddresses()
86
+
87
+ > **getAddresses**(`identity`, `accountIndex`, `startAddressIndex`, `count`): `Promise`\<`string`[]\>
88
+
89
+ Get the addresses for the requested range.
90
+
91
+ #### Parameters
92
+
93
+ • **identity**: `string`
94
+
95
+ The identity of the user to access the vault keys.
96
+
97
+ • **accountIndex**: `number`
98
+
99
+ The account index to get the addresses for.
100
+
101
+ • **startAddressIndex**: `number`
102
+
103
+ The start index for the addresses.
104
+
105
+ • **count**: `number`
106
+
107
+ The number of addresses to generate.
108
+
109
+ #### Returns
110
+
111
+ `Promise`\<`string`[]\>
112
+
113
+ The list of addresses.
114
+
115
+ #### Implementation of
116
+
117
+ `IWalletConnector.getAddresses`
118
+
119
+ ***
120
+
121
+ ### getBalance()
122
+
123
+ > **getBalance**(`identity`, `address`): `Promise`\<`bigint`\>
124
+
125
+ Get the balance for an address in a wallet.
126
+
127
+ #### Parameters
128
+
129
+ • **identity**: `string`
130
+
131
+ The identity of the user to access the vault keys.
132
+
133
+ • **address**: `string`
134
+
135
+ The bech32 encoded address.
136
+
137
+ #### Returns
138
+
139
+ `Promise`\<`bigint`\>
140
+
141
+ The balance of the wallet address.
142
+
143
+ #### Implementation of
144
+
145
+ `IWalletConnector.getBalance`
146
+
147
+ ***
148
+
149
+ ### ensureBalance()
150
+
151
+ > **ensureBalance**(`identity`, `address`, `ensureBalance`, `timeoutInSeconds`?): `Promise`\<`boolean`\>
152
+
153
+ Ensure the balance for an address in a wallet.
154
+
155
+ #### Parameters
156
+
157
+ • **identity**: `string`
158
+
159
+ The identity of the user to access the vault keys.
160
+
161
+ • **address**: `string`
162
+
163
+ The bech32 encoded address.
164
+
165
+ • **ensureBalance**: `bigint`
166
+
167
+ The balance to ensure on the address.
168
+
169
+ • **timeoutInSeconds?**: `number`
170
+
171
+ The timeout in seconds to wait for the funding to complete.
172
+
173
+ #### Returns
174
+
175
+ `Promise`\<`boolean`\>
176
+
177
+ True if the balance has been ensured.
178
+
179
+ #### Implementation of
180
+
181
+ `IWalletConnector.ensureBalance`
182
+
183
+ ***
184
+
185
+ ### transfer()
186
+
187
+ > **transfer**(`identity`, `addressSource`, `addressDest`, `amount`): `Promise`\<`undefined` \| `string`\>
188
+
189
+ Transfer funds to an address.
190
+
191
+ #### Parameters
192
+
193
+ • **identity**: `string`
194
+
195
+ The identity of the user to access the vault keys.
196
+
197
+ • **addressSource**: `string`
198
+
199
+ The bech32 encoded address to send the funds from.
200
+
201
+ • **addressDest**: `string`
202
+
203
+ The bech32 encoded address to send the funds to.
204
+
205
+ • **amount**: `bigint`
206
+
207
+ The amount to transfer.
208
+
209
+ #### Returns
210
+
211
+ `Promise`\<`undefined` \| `string`\>
212
+
213
+ An identifier for the transfer if there was one.
214
+
215
+ #### Implementation of
216
+
217
+ `IWalletConnector.transfer`
@@ -0,0 +1,14 @@
1
+ # @twin.org/wallet-connector-iota
2
+
3
+ ## Classes
4
+
5
+ - [IotaFaucetConnector](classes/IotaFaucetConnector.md)
6
+ - [IotaWalletConnector](classes/IotaWalletConnector.md)
7
+
8
+ ## Interfaces
9
+
10
+ - [IIotaFaucetConnectorConfig](interfaces/IIotaFaucetConnectorConfig.md)
11
+
12
+ ## Type Aliases
13
+
14
+ - [IIotaWalletConnectorConfig](type-aliases/IIotaWalletConnectorConfig.md)
@@ -0,0 +1,19 @@
1
+ # Interface: IIotaFaucetConnectorConfig
2
+
3
+ Configuration for the IOTA Faucet Connector.
4
+
5
+ ## Properties
6
+
7
+ ### clientOptions
8
+
9
+ > **clientOptions**: `IClientOptions`
10
+
11
+ The configuration for the client.
12
+
13
+ ***
14
+
15
+ ### endpoint
16
+
17
+ > **endpoint**: `string`
18
+
19
+ The endpoint for the faucet.
@@ -0,0 +1,5 @@
1
+ # Type Alias: IIotaWalletConnectorConfig
2
+
3
+ > **IIotaWalletConnectorConfig**: `IIotaConfig`
4
+
5
+ Configuration for the IOTA Wallet Connector.
@@ -0,0 +1,13 @@
1
+ {
2
+ "error": {
3
+ "iotaWalletConnector": {
4
+ "transferFailed": "The wallet transfer failed.",
5
+ "inclusionFailed": "The transaction generated was not included in a reasonable amount of time",
6
+ "insufficientFunds": "There were insufficient funds to complete the operation"
7
+ },
8
+ "iotaFaucetConnector": {
9
+ "fundingFailed": "Fund the address from faucet failed",
10
+ "insufficientFunds": "There were insufficient funds to complete the operation"
11
+ }
12
+ }
13
+ }
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@twin.org/wallet-connector-iota",
3
+ "version": "0.0.1-next.3",
4
+ "description": "Wallet connector implementation using IOTA",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/twinfoundation/wallet.git",
8
+ "directory": "packages/wallet-connector-iota"
9
+ },
10
+ "author": "martyn.janes@iota.org",
11
+ "license": "Apache-2.0",
12
+ "type": "module",
13
+ "engines": {
14
+ "node": ">=20.0.0"
15
+ },
16
+ "scripts": {
17
+ "clean": "rimraf dist coverage docs/reference",
18
+ "build": "tspc",
19
+ "test": "vitest --run --config ./vitest.config.ts --no-cache",
20
+ "coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
21
+ "bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
22
+ "bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
23
+ "bundle": "npm run bundle:esm && npm run bundle:cjs",
24
+ "docs:clean": "rimraf docs/reference",
25
+ "docs:generate": "typedoc",
26
+ "docs": "npm run docs:clean && npm run docs:generate",
27
+ "dist": "npm run clean && npm run build && npm run test && npm run bundle && npm run docs"
28
+ },
29
+ "dependencies": {
30
+ "@twin.org/core": "next",
31
+ "@twin.org/crypto": "next",
32
+ "@twin.org/dlt-iota": "next",
33
+ "@twin.org/nameof": "next",
34
+ "@twin.org/vault-models": "next",
35
+ "@twin.org/wallet-models": "0.0.1-next.3",
36
+ "@iota/sdk-wasm": "1.1.3"
37
+ },
38
+ "devDependencies": {
39
+ "@twin.org/nameof-transformer": "next",
40
+ "@twin.org/entity": "next",
41
+ "@twin.org/entity-storage-connector-memory": "next",
42
+ "@twin.org/vault-connector-entity-storage": "next",
43
+ "@vitest/coverage-v8": "2.1.1",
44
+ "copyfiles": "2.4.1",
45
+ "dotenv": "16.4.5",
46
+ "rimraf": "6.0.1",
47
+ "rollup": "4.22.0",
48
+ "rollup-plugin-copy": "3.5.0",
49
+ "rollup-plugin-typescript2": "0.36.0",
50
+ "ts-patch": "3.2.1",
51
+ "typedoc": "0.26.7",
52
+ "typedoc-plugin-markdown": "4.2.7",
53
+ "typescript": "5.6.2",
54
+ "vitest": "2.1.1"
55
+ },
56
+ "main": "./dist/cjs/index.cjs",
57
+ "module": "./dist/esm/index.mjs",
58
+ "types": "./dist/types/index.d.ts",
59
+ "exports": {
60
+ ".": {
61
+ "require": "./dist/cjs/index.cjs",
62
+ "import": "./dist/esm/index.mjs",
63
+ "types": "./dist/types/index.d.ts"
64
+ },
65
+ "./locales": "./locales"
66
+ },
67
+ "files": [
68
+ "dist/cjs",
69
+ "dist/esm",
70
+ "dist/types",
71
+ "locales",
72
+ "docs"
73
+ ]
74
+ }