@twin.org/nft-cli 0.0.1-next.8 → 0.0.1

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.
@@ -8,12 +8,26 @@ var walletCli = require('@twin.org/wallet-cli');
8
8
  var core = require('@twin.org/core');
9
9
  var nftConnectorIota = require('@twin.org/nft-connector-iota');
10
10
  var vaultModels = require('@twin.org/vault-models');
11
+ var walletModels = require('@twin.org/wallet-models');
11
12
  var commander = require('commander');
12
13
  var entityStorageConnectorMemory = require('@twin.org/entity-storage-connector-memory');
13
14
  var entityStorageModels = require('@twin.org/entity-storage-models');
14
15
  var vaultConnectorEntityStorage = require('@twin.org/vault-connector-entity-storage');
15
16
 
16
17
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
18
+ // Copyright 2024 IOTA Stiftung.
19
+ // SPDX-License-Identifier: Apache-2.0.
20
+ /**
21
+ * The NFT connector types.
22
+ */
23
+ // eslint-disable-next-line @typescript-eslint/naming-convention
24
+ const NftConnectorTypes = {
25
+ /**
26
+ * IOTA.
27
+ */
28
+ Iota: "iota"
29
+ };
30
+
17
31
  // Copyright 2024 IOTA Stiftung.
18
32
  // SPDX-License-Identifier: Apache-2.0.
19
33
  /**
@@ -30,6 +44,29 @@ function setupVault() {
30
44
  const vaultConnector = new vaultConnectorEntityStorage.EntityStorageVaultConnector();
31
45
  vaultModels.VaultConnectorFactory.register("vault", () => vaultConnector);
32
46
  }
47
+ /**
48
+ * Setup the NFT connector for use in the CLI commands.
49
+ * @param options The options for the NFT connector.
50
+ * @param options.nodeEndpoint The node endpoint.
51
+ * @param options.network The network.
52
+ * @param options.vaultSeedId The vault seed ID.
53
+ * @param options.walletAddressIndex The wallet address index.
54
+ * @param connector The connector to use.
55
+ * @returns The NFT connector.
56
+ */
57
+ function setupNftConnector(options, connector) {
58
+ connector ??= NftConnectorTypes.Iota;
59
+ return new nftConnectorIota.IotaNftConnector({
60
+ config: {
61
+ clientOptions: {
62
+ url: options.nodeEndpoint
63
+ },
64
+ network: options.network ?? "",
65
+ vaultSeedId: options.vaultSeedId,
66
+ walletAddressIndex: options.walletAddressIndex ?? 0
67
+ }
68
+ });
69
+ }
33
70
 
34
71
  // Copyright 2024 IOTA Stiftung.
35
72
  // SPDX-License-Identifier: Apache-2.0.
@@ -44,10 +81,13 @@ function buildCommandNftBurn() {
44
81
  .summary(core.I18n.formatMessage("commands.nft-burn.summary"))
45
82
  .description(core.I18n.formatMessage("commands.nft-burn.description"))
46
83
  .requiredOption(core.I18n.formatMessage("commands.nft-burn.options.seed.param"), core.I18n.formatMessage("commands.nft-burn.options.seed.description"))
47
- .requiredOption(core.I18n.formatMessage("commands.nft-burn.options.issuer.param"), core.I18n.formatMessage("commands.nft-burn.options.issuer.description"))
48
84
  .requiredOption(core.I18n.formatMessage("commands.nft-burn.options.id.param"), core.I18n.formatMessage("commands.nft-burn.options.id.description"));
49
85
  command
86
+ .addOption(new commander.Option(core.I18n.formatMessage("commands.common.options.connector.param"), core.I18n.formatMessage("commands.common.options.connector.description"))
87
+ .choices(Object.values(NftConnectorTypes))
88
+ .default(NftConnectorTypes.Iota))
50
89
  .option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
90
+ .option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
51
91
  .option(core.I18n.formatMessage("commands.common.options.explorer.param"), core.I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
52
92
  .action(actionCommandNftBurn);
53
93
  return command;
@@ -56,41 +96,43 @@ function buildCommandNftBurn() {
56
96
  * Action the nft burn command.
57
97
  * @param opts The options for the command.
58
98
  * @param opts.seed The seed required for signing by the issuer.
59
- * @param opts.issuer The issuer address of the NFT.
60
99
  * @param opts.id The id of the NFT to burn in urn format.
100
+ * @param opts.connector The connector to perform the operations with.
61
101
  * @param opts.node The node URL.
102
+ * @param opts.network The network to use for connector.
62
103
  * @param opts.explorer The explorer URL.
63
104
  */
64
105
  async function actionCommandNftBurn(opts) {
65
106
  const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
66
- const issuer = cliCore.CLIParam.bech32("issuer", opts.issuer);
67
107
  const id = cliCore.CLIParam.stringValue("id", opts.id);
68
108
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
109
+ const network = opts.connector === NftConnectorTypes.Iota
110
+ ? cliCore.CLIParam.stringValue("network", opts.network)
111
+ : undefined;
69
112
  const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
70
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-burn.labels.issuer"), issuer);
71
113
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-burn.labels.nftId"), id);
72
114
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
115
+ if (core.Is.stringValue(network)) {
116
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
117
+ }
73
118
  cliCore.CLIDisplay.break();
74
119
  setupVault();
75
120
  const localIdentity = "local";
76
121
  const vaultSeedId = "local-seed";
77
122
  const vaultConnector = vaultModels.VaultConnectorFactory.get("vault");
78
123
  await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, core.Converter.bytesToBase64(seed));
79
- const iotaNftConnector = new nftConnectorIota.IotaNftConnector({
80
- config: {
81
- clientOptions: {
82
- nodes: [nodeEndpoint],
83
- localPow: true
84
- },
85
- vaultSeedId
86
- }
87
- });
124
+ const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
125
+ walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
126
+ const nftConnector = setupNftConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
127
+ if (core.Is.function(nftConnector.start)) {
128
+ await nftConnector.start(localIdentity);
129
+ }
88
130
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.nft-burn.progress.burningNft"));
89
131
  cliCore.CLIDisplay.break();
90
132
  cliCore.CLIDisplay.spinnerStart();
91
- await iotaNftConnector.burn(localIdentity, id);
133
+ await nftConnector.burn(localIdentity, id);
92
134
  cliCore.CLIDisplay.spinnerStop();
93
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${nftConnectorIota.IotaNftUtils.nftIdToAddress(id)}`);
135
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${nftConnectorIota.IotaNftUtils.nftIdToObjectId(id)}?network=${network}`);
94
136
  cliCore.CLIDisplay.break();
95
137
  cliCore.CLIDisplay.done();
96
138
  }
@@ -109,6 +151,7 @@ function buildCommandNftMint() {
109
151
  .description(core.I18n.formatMessage("commands.nft-mint.description"))
110
152
  .requiredOption(core.I18n.formatMessage("commands.nft-mint.options.seed.param"), core.I18n.formatMessage("commands.nft-mint.options.seed.description"))
111
153
  .requiredOption(core.I18n.formatMessage("commands.nft-mint.options.issuer.param"), core.I18n.formatMessage("commands.nft-mint.options.issuer.description"))
154
+ .option(core.I18n.formatMessage("commands.nft-mint.options.wallet-address-index.param"), core.I18n.formatMessage("commands.nft-mint.options.wallet-address-index.description"), "0")
112
155
  .requiredOption(core.I18n.formatMessage("commands.nft-mint.options.tag.param"), core.I18n.formatMessage("commands.nft-mint.options.tag.description"))
113
156
  .option(core.I18n.formatMessage("commands.nft-mint.options.immutable-json.param"), core.I18n.formatMessage("commands.nft-mint.options.immutable-json.description"))
114
157
  .option(core.I18n.formatMessage("commands.nft-mint.options.mutable-json.param"), core.I18n.formatMessage("commands.nft-mint.options.mutable-json.description"));
@@ -120,8 +163,12 @@ function buildCommandNftMint() {
120
163
  mergeEnv: true
121
164
  });
122
165
  command
123
- .option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
166
+ .addOption(new commander.Option(core.I18n.formatMessage("commands.common.options.connector.param"), core.I18n.formatMessage("commands.common.options.connector.description"))
167
+ .choices(Object.values(NftConnectorTypes))
168
+ .default(NftConnectorTypes.Iota))
169
+ .option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
124
170
  .option(core.I18n.formatMessage("commands.common.options.explorer.param"), core.I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
171
+ .option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
125
172
  .action(actionCommandNftMint);
126
173
  return command;
127
174
  }
@@ -129,16 +176,22 @@ function buildCommandNftMint() {
129
176
  * Action the nft mint command.
130
177
  * @param opts The options for the command.
131
178
  * @param opts.seed The seed required for signing by the issuer.
132
- * @param opts.issuer The issuer address of the NFT.
179
+ * @param opts.issuer The identity of the issuer.
180
+ * @param opts.walletAddressIndex The wallet address index.
133
181
  * @param opts.tag The tag for the NFT.
134
182
  * @param opts.immutableJson Filename of the immutable JSON data.
135
183
  * @param opts.mutableJson Filename of the mutable JSON data.
184
+ * @param opts.connector The connector to perform the operations with.
136
185
  * @param opts.node The node URL.
186
+ * @param opts.network The network to use for connector.
137
187
  * @param opts.explorer The explorer URL.
138
188
  */
139
189
  async function actionCommandNftMint(opts) {
140
190
  const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
141
- const issuer = cliCore.CLIParam.bech32("issuer", opts.issuer);
191
+ const issuer = cliCore.CLIParam.stringValue("issuer", opts.issuer);
192
+ const walletAddressIndex = core.Is.empty(opts.walletAddressIndex)
193
+ ? undefined
194
+ : cliCore.CLIParam.integer("wallet-address-index", opts.walletAddressIndex);
142
195
  const tag = cliCore.CLIParam.stringValue("tag", opts.tag);
143
196
  const immutableJson = opts.immutableJson
144
197
  ? path.resolve(opts.immutableJson)
@@ -147,8 +200,14 @@ async function actionCommandNftMint(opts) {
147
200
  ? path.resolve(opts.mutableJson)
148
201
  : undefined;
149
202
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
203
+ const network = opts.connector === NftConnectorTypes.Iota
204
+ ? cliCore.CLIParam.stringValue("network", opts.network)
205
+ : undefined;
150
206
  const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
151
207
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-mint.labels.issuer"), issuer);
208
+ if (core.Is.integer(walletAddressIndex)) {
209
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-mint.labels.walletAddressIndex"), walletAddressIndex);
210
+ }
152
211
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-mint.labels.tag"), tag);
153
212
  if (core.Is.stringValue(immutableJson)) {
154
213
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-mint.labels.immutableJsonFilename"), immutableJson);
@@ -157,21 +216,21 @@ async function actionCommandNftMint(opts) {
157
216
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-mint.labels.mutableJsonFilename"), mutableJson);
158
217
  }
159
218
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
219
+ if (core.Is.stringValue(network)) {
220
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
221
+ }
160
222
  cliCore.CLIDisplay.break();
161
223
  setupVault();
162
- const localIdentity = "local";
224
+ const localIdentity = issuer;
163
225
  const vaultSeedId = "local-seed";
164
226
  const vaultConnector = vaultModels.VaultConnectorFactory.get("vault");
165
227
  await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, core.Converter.bytesToBase64(seed));
166
- const iotaNftConnector = new nftConnectorIota.IotaNftConnector({
167
- config: {
168
- clientOptions: {
169
- nodes: [nodeEndpoint],
170
- localPow: true
171
- },
172
- vaultSeedId
173
- }
174
- });
228
+ const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
229
+ walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
230
+ const nftConnector = setupNftConnector({ nodeEndpoint, network, vaultSeedId, walletAddressIndex }, opts.connector);
231
+ if (core.Is.function(nftConnector.start)) {
232
+ await nftConnector.start(localIdentity);
233
+ }
175
234
  const immutableJsonData = core.Is.stringValue(immutableJson)
176
235
  ? await cliCore.CLIUtils.readJsonFile(immutableJson)
177
236
  : undefined;
@@ -191,7 +250,7 @@ async function actionCommandNftMint(opts) {
191
250
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.nft-mint.progress.mintingNft"));
192
251
  cliCore.CLIDisplay.break();
193
252
  cliCore.CLIDisplay.spinnerStart();
194
- const nftId = await iotaNftConnector.mint(localIdentity, issuer, tag, immutableJsonData, mutableJsonData);
253
+ const nftId = await nftConnector.mint(localIdentity, tag, immutableJsonData, mutableJsonData);
195
254
  cliCore.CLIDisplay.spinnerStop();
196
255
  if (opts.console) {
197
256
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-mint.labels.nftId"), nftId);
@@ -203,7 +262,7 @@ async function actionCommandNftMint(opts) {
203
262
  if (core.Is.stringValue(opts?.env)) {
204
263
  await cliCore.CLIUtils.writeEnvFile(opts.env, [`NFT_ID="${nftId}"`], opts.mergeEnv);
205
264
  }
206
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${nftConnectorIota.IotaNftUtils.nftIdToAddress(nftId)}`);
265
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${nftConnectorIota.IotaNftUtils.nftIdToObjectId(nftId)}?network=${network}`);
207
266
  cliCore.CLIDisplay.break();
208
267
  cliCore.CLIDisplay.done();
209
268
  }
@@ -229,7 +288,11 @@ function buildCommandNftResolve() {
229
288
  mergeEnv: false
230
289
  });
231
290
  command
291
+ .addOption(new commander.Option(core.I18n.formatMessage("commands.common.options.connector.param"), core.I18n.formatMessage("commands.common.options.connector.description"))
292
+ .choices(Object.values(NftConnectorTypes))
293
+ .default(NftConnectorTypes.Iota))
232
294
  .option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
295
+ .option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
233
296
  .option(core.I18n.formatMessage("commands.common.options.explorer.param"), core.I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
234
297
  .action(actionCommandNftResolve);
235
298
  return command;
@@ -238,29 +301,32 @@ function buildCommandNftResolve() {
238
301
  * Action the nft resolve command.
239
302
  * @param opts The options for the command.
240
303
  * @param opts.id The id of the NFT to resolve in urn format.
304
+ * @param opts.connector The connector to perform the operations with.
241
305
  * @param opts.node The node URL.
306
+ * @param opts.network The network to use for connector.
242
307
  * @param opts.explorer The explorer URL.
243
308
  */
244
309
  async function actionCommandNftResolve(opts) {
245
310
  const id = cliCore.CLIParam.stringValue("id", opts.id);
246
311
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
312
+ const network = opts.connector === NftConnectorTypes.Iota
313
+ ? cliCore.CLIParam.stringValue("network", opts.network)
314
+ : undefined;
247
315
  const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
248
316
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-resolve.labels.nftId"), id);
249
317
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
318
+ if (core.Is.stringValue(network)) {
319
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
320
+ }
250
321
  cliCore.CLIDisplay.break();
251
322
  setupVault();
252
- const iotaNftConnector = new nftConnectorIota.IotaNftConnector({
253
- config: {
254
- clientOptions: {
255
- nodes: [nodeEndpoint],
256
- localPow: true
257
- }
258
- }
259
- });
323
+ const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, network }, opts.connector);
324
+ walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
325
+ const nftConnector = setupNftConnector({ nodeEndpoint, network }, opts.connector);
260
326
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.nft-resolve.progress.resolvingNft"));
261
327
  cliCore.CLIDisplay.break();
262
328
  cliCore.CLIDisplay.spinnerStart();
263
- const nft = await iotaNftConnector.resolve(id);
329
+ const nft = await nftConnector.resolve(id);
264
330
  cliCore.CLIDisplay.spinnerStop();
265
331
  if (opts.console) {
266
332
  cliCore.CLIDisplay.section(core.I18n.formatMessage("commands.nft-resolve.labels.nft"));
@@ -270,7 +336,7 @@ async function actionCommandNftResolve(opts) {
270
336
  if (core.Is.stringValue(opts?.json)) {
271
337
  await cliCore.CLIUtils.writeJsonFile(opts.json, nft, opts.mergeJson);
272
338
  }
273
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${nftConnectorIota.IotaNftUtils.nftIdToAddress(id)}`);
339
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${nftConnectorIota.IotaNftUtils.nftIdToObjectId(id)}?network=${network}`);
274
340
  cliCore.CLIDisplay.break();
275
341
  cliCore.CLIDisplay.done();
276
342
  }
@@ -289,9 +355,14 @@ function buildCommandNftTransfer() {
289
355
  .description(core.I18n.formatMessage("commands.nft-transfer.description"))
290
356
  .requiredOption(core.I18n.formatMessage("commands.nft-transfer.options.seed.param"), core.I18n.formatMessage("commands.nft-transfer.options.seed.description"))
291
357
  .requiredOption(core.I18n.formatMessage("commands.nft-transfer.options.id.param"), core.I18n.formatMessage("commands.nft-transfer.options.id.description"))
292
- .requiredOption(core.I18n.formatMessage("commands.nft-transfer.options.recipient.param"), core.I18n.formatMessage("commands.nft-transfer.options.recipient.description"));
358
+ .requiredOption(core.I18n.formatMessage("commands.nft-transfer.options.recipient-identity.param"), core.I18n.formatMessage("commands.nft-transfer.options.recipient-identity.description"))
359
+ .requiredOption(core.I18n.formatMessage("commands.nft-transfer.options.recipient-address.param"), core.I18n.formatMessage("commands.nft-transfer.options.recipient-address.description"));
293
360
  command
361
+ .addOption(new commander.Option(core.I18n.formatMessage("commands.common.options.connector.param"), core.I18n.formatMessage("commands.common.options.connector.description"))
362
+ .choices(Object.values(NftConnectorTypes))
363
+ .default(NftConnectorTypes.Iota))
294
364
  .option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
365
+ .option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
295
366
  .option(core.I18n.formatMessage("commands.common.options.explorer.param"), core.I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
296
367
  .action(actionCommandNftTransfer);
297
368
  return command;
@@ -301,40 +372,50 @@ function buildCommandNftTransfer() {
301
372
  * @param opts The options for the command.
302
373
  * @param opts.seed The seed required for signing by the issuer.
303
374
  * @param opts.id The id of the NFT to transfer in urn format.
304
- * @param opts.recipient The recipient address of the NFT.
375
+ * @param opts.recipientIdentity The recipient address of the NFT.
376
+ * @param opts.recipientAddress The recipient address of the NFT.
377
+ * @param opts.connector The connector to perform the operations with.
305
378
  * @param opts.node The node URL.
379
+ * @param opts.network The network to use for connector.
306
380
  * @param opts.explorer The explorer URL.
307
381
  */
308
382
  async function actionCommandNftTransfer(opts) {
309
383
  const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
310
384
  const id = cliCore.CLIParam.stringValue("id", opts.id);
311
- const recipient = cliCore.CLIParam.bech32("recipient", opts.recipient);
385
+ const recipientIdentity = cliCore.CLIParam.stringValue("recipientIdentity", opts.recipientIdentity);
386
+ const recipientAddress = opts.connector === NftConnectorTypes.Iota
387
+ ? core.Converter.bytesToHex(cliCore.CLIParam.hex("recipientAddress", opts.recipientAddress), true)
388
+ : cliCore.CLIParam.bech32("recipientAddress", opts.recipientAddress);
312
389
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
390
+ const network = opts.connector === NftConnectorTypes.Iota
391
+ ? cliCore.CLIParam.stringValue("network", opts.network)
392
+ : undefined;
313
393
  const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
314
394
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-transfer.labels.nftId"), id);
315
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-transfer.labels.recipient"), recipient);
395
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-transfer.labels.recipientIdentity"), recipientIdentity);
396
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-transfer.labels.recipientAddress"), recipientAddress);
316
397
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
398
+ if (core.Is.stringValue(network)) {
399
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
400
+ }
317
401
  cliCore.CLIDisplay.break();
318
402
  setupVault();
403
+ const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, network }, opts.connector);
404
+ walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
319
405
  const localIdentity = "local";
320
406
  const vaultSeedId = "local-seed";
321
407
  const vaultConnector = vaultModels.VaultConnectorFactory.get("vault");
322
408
  await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, core.Converter.bytesToBase64(seed));
323
- const iotaNftConnector = new nftConnectorIota.IotaNftConnector({
324
- config: {
325
- clientOptions: {
326
- nodes: [nodeEndpoint],
327
- localPow: true
328
- },
329
- vaultSeedId
330
- }
331
- });
409
+ const nftConnector = setupNftConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
410
+ if (core.Is.function(nftConnector.start)) {
411
+ await nftConnector.start(localIdentity);
412
+ }
332
413
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.nft-transfer.progress.transferringNft"));
333
414
  cliCore.CLIDisplay.break();
334
415
  cliCore.CLIDisplay.spinnerStart();
335
- await iotaNftConnector.transfer(localIdentity, id, recipient);
416
+ await nftConnector.transfer(localIdentity, id, recipientIdentity, recipientAddress);
336
417
  cliCore.CLIDisplay.spinnerStop();
337
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${nftConnectorIota.IotaNftUtils.nftIdToAddress(id)}`);
418
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${nftConnectorIota.IotaNftUtils.nftIdToObjectId(id)}?network=${network}`);
338
419
  cliCore.CLIDisplay.break();
339
420
  cliCore.CLIDisplay.done();
340
421
  }
@@ -357,7 +438,7 @@ class CLI extends cliCore.CLIBase {
357
438
  return this.execute({
358
439
  title: "TWIN NFT",
359
440
  appName: "twin-nft",
360
- version: "0.0.1-next.8",
441
+ version: "0.0.1", // x-release-please-version
361
442
  icon: "🌍",
362
443
  supportsEnvFiles: true,
363
444
  overrideOutputWidth: options?.overrideOutputWidth
@@ -382,6 +463,7 @@ class CLI extends cliCore.CLIBase {
382
463
  }
383
464
 
384
465
  exports.CLI = CLI;
466
+ exports.NftConnectorTypes = NftConnectorTypes;
385
467
  exports.actionCommandNftBurn = actionCommandNftBurn;
386
468
  exports.actionCommandNftMint = actionCommandNftMint;
387
469
  exports.actionCommandNftResolve = actionCommandNftResolve;
@@ -390,3 +472,5 @@ exports.buildCommandNftBurn = buildCommandNftBurn;
390
472
  exports.buildCommandNftMint = buildCommandNftMint;
391
473
  exports.buildCommandNftResolve = buildCommandNftResolve;
392
474
  exports.buildCommandNftTransfer = buildCommandNftTransfer;
475
+ exports.setupNftConnector = setupNftConnector;
476
+ exports.setupVault = setupVault;