@twin.org/nft-cli 0.0.2-next.8 → 0.0.3-next.2
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/bin/index.js +1 -1
- package/dist/es/cli.js +52 -0
- package/dist/es/cli.js.map +1 -0
- package/dist/es/commands/nftBurn.js +72 -0
- package/dist/es/commands/nftBurn.js.map +1 -0
- package/dist/es/commands/nftMint.js +139 -0
- package/dist/es/commands/nftMint.js.map +1 -0
- package/dist/es/commands/nftResolve.js +75 -0
- package/dist/es/commands/nftResolve.js.map +1 -0
- package/dist/es/commands/nftTransfer.js +80 -0
- package/dist/es/commands/nftTransfer.js.map +1 -0
- package/dist/es/commands/setupCommands.js +43 -0
- package/dist/es/commands/setupCommands.js.map +1 -0
- package/dist/es/index.js +9 -0
- package/dist/es/index.js.map +1 -0
- package/dist/locales/en.json +15 -1
- package/dist/types/index.d.ts +6 -6
- package/docs/changelog.md +42 -0
- package/package.json +7 -9
- package/dist/cjs/index.cjs +0 -440
- package/dist/esm/index.mjs +0 -427
package/dist/locales/en.json
CHANGED
|
@@ -77,6 +77,8 @@
|
|
|
77
77
|
"urn": "Property \"{property}\" must be a Urn formatted string, it is \"{value}\"",
|
|
78
78
|
"url": "Property \"{property}\" must be a Url formatted string, it is \"{value}\"",
|
|
79
79
|
"email": "Property \"{property}\" must be string in e-mail format, it is \"{value}\"",
|
|
80
|
+
"uuidV7": "Property \"{property}\" must be a UUIDv7 formatted string, it is \"{value}\"",
|
|
81
|
+
"uuidV7Compact": "Property \"{property}\" must be a UUIDv7 formatted string in compact mode, it is \"{value}\"",
|
|
80
82
|
"length32Multiple": "Property \"{property}\" should be a multiple of 32, it is {value}",
|
|
81
83
|
"lengthEntropy": "Property \"{property}\" should be a multiple of 4, >=16 and <= 32, it is {value}"
|
|
82
84
|
},
|
|
@@ -91,7 +93,8 @@
|
|
|
91
93
|
},
|
|
92
94
|
"factory": {
|
|
93
95
|
"noUnregister": "There is no {typeName} registered with the name \"{name}\"",
|
|
94
|
-
"noGet": "The requested {typeName} \"{name}\" does not exist in the factory"
|
|
96
|
+
"noGet": "The requested {typeName} \"{name}\" does not exist in the factory",
|
|
97
|
+
"noCreate": "The requested {typeName} \"{name}\" cannot be created by the factory, with params \"{params}\""
|
|
95
98
|
},
|
|
96
99
|
"bitString": {
|
|
97
100
|
"outOfRange": "The index should be >= 0 and less than the length of the bit string, the index is \"{index}\" and the number of bit is \"{numberBits}\""
|
|
@@ -162,6 +165,13 @@
|
|
|
162
165
|
"invalidOptional": "The entity property \"{property}\" of type \"{type}\" is not optional, but no value has been provided",
|
|
163
166
|
"invalidEntityKeys": "The entity had additional properties that are not in the schema, \"{keys}\""
|
|
164
167
|
},
|
|
168
|
+
"contextIdHelper": {
|
|
169
|
+
"contextIdMissing": "The context ID \"{key}\" is missing from the provided context IDs",
|
|
170
|
+
"contextIdSplitMismatch": "The context ID split parts length \"{actual}\" does not match the provided keys length \"{expected}\""
|
|
171
|
+
},
|
|
172
|
+
"contextIdStore": {
|
|
173
|
+
"asyncHooksNotAvailable": "Async Hooks are not available in this environment, please ensure you are running in Node.js"
|
|
174
|
+
},
|
|
165
175
|
"iotaNftConnector": {
|
|
166
176
|
"mintingFailed": "Minting the NFT failed",
|
|
167
177
|
"resolvingFailed": "Resolving the NFT failed",
|
|
@@ -238,6 +248,10 @@
|
|
|
238
248
|
"createFailed": "Failed to create JWS",
|
|
239
249
|
"verifyFailed": "Failed to verify JWS"
|
|
240
250
|
},
|
|
251
|
+
"headerHelper": {
|
|
252
|
+
"invalidLinkHeaderURL": "URL for Link header cannot contain \">\" character.",
|
|
253
|
+
"invalidLinkHeaderRel": "Relation type for Link header cannot contain \" character."
|
|
254
|
+
},
|
|
241
255
|
"entityStorageVaultConnector": {
|
|
242
256
|
"keyAlreadyExists": "The key \"{existingId}\" already exists in the vault",
|
|
243
257
|
"keyNotFound": "The key \"{notFoundId}\" was not found in the vault",
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./cli";
|
|
2
|
-
export * from "./commands/nftBurn";
|
|
3
|
-
export * from "./commands/nftMint";
|
|
4
|
-
export * from "./commands/nftResolve";
|
|
5
|
-
export * from "./commands/nftTransfer";
|
|
6
|
-
export * from "./commands/setupCommands";
|
|
1
|
+
export * from "./cli.js";
|
|
2
|
+
export * from "./commands/nftBurn.js";
|
|
3
|
+
export * from "./commands/nftMint.js";
|
|
4
|
+
export * from "./commands/nftResolve.js";
|
|
5
|
+
export * from "./commands/nftTransfer.js";
|
|
6
|
+
export * from "./commands/setupCommands.js";
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @twin.org/nft-cli - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.2](https://github.com/twinfoundation/nft/compare/nft-cli-v0.0.3-next.1...nft-cli-v0.0.3-next.2) (2026-02-25)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Miscellaneous Chores
|
|
7
|
+
|
|
8
|
+
* **nft-cli:** Synchronize repo versions
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/nft-connector-iota bumped from 0.0.3-next.1 to 0.0.3-next.2
|
|
16
|
+
|
|
17
|
+
## [0.0.3-next.1](https://github.com/twinfoundation/nft/compare/nft-cli-v0.0.3-next.0...nft-cli-v0.0.3-next.1) (2025-11-12)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* add context id features ([#50](https://github.com/twinfoundation/nft/issues/50)) ([56c31c7](https://github.com/twinfoundation/nft/commit/56c31c7ba10e3ef8ad44f6463153f90888e64711))
|
|
23
|
+
* add publish workflows ([3f2ae6b](https://github.com/twinfoundation/nft/commit/3f2ae6b5c29da8012e01ef719c2d91a6aa80c2ad))
|
|
24
|
+
* add validate-locales ([0055a56](https://github.com/twinfoundation/nft/commit/0055a56ed166946f1db860aa0725ad53248b3427))
|
|
25
|
+
* eslint migration to flat config ([0e6fc12](https://github.com/twinfoundation/nft/commit/0e6fc128c3c8f6cd34db793787437dd4af2c9994))
|
|
26
|
+
* iota rebased release ([8d05d1f](https://github.com/twinfoundation/nft/commit/8d05d1f58c1aacac983c100697ab40a314ad34ea))
|
|
27
|
+
* remove connector type from CLI ([59c0faa](https://github.com/twinfoundation/nft/commit/59c0faab46caf0def1981aab790238c289ae0e22))
|
|
28
|
+
* update dependencies ([8660f76](https://github.com/twinfoundation/nft/commit/8660f76ca324b0f476e45544cac6bee4b3146c3b))
|
|
29
|
+
* update dlt packages ([12c4966](https://github.com/twinfoundation/nft/commit/12c4966bceb926b7cdcf1449165bee09187a426c))
|
|
30
|
+
* update framework core ([f3496b6](https://github.com/twinfoundation/nft/commit/f3496b61bfebbb3479bb92df39ecfa9ac8d90b9b))
|
|
31
|
+
* use shared store mechanism ([#16](https://github.com/twinfoundation/nft/issues/16)) ([897bc78](https://github.com/twinfoundation/nft/commit/897bc7805248ba1388b2dd03df24c33f1633f344))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Bug Fixes
|
|
35
|
+
|
|
36
|
+
* contract independent tests ([#35](https://github.com/twinfoundation/nft/issues/35)) ([b54ad6e](https://github.com/twinfoundation/nft/commit/b54ad6e1727284230f21db0032dc8ff437444812))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Dependencies
|
|
40
|
+
|
|
41
|
+
* The following workspace dependencies were updated
|
|
42
|
+
* dependencies
|
|
43
|
+
* @twin.org/nft-connector-iota bumped from 0.0.3-next.0 to 0.0.3-next.1
|
|
44
|
+
|
|
3
45
|
## [0.0.2-next.8](https://github.com/twinfoundation/nft/compare/nft-cli-v0.0.2-next.7...nft-cli-v0.0.2-next.8) (2025-10-09)
|
|
4
46
|
|
|
5
47
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/nft-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3-next.2",
|
|
4
4
|
"description": "A command line interface for interacting with the nft connectors",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,27 +21,25 @@
|
|
|
21
21
|
"@twin.org/entity": "next",
|
|
22
22
|
"@twin.org/entity-storage-connector-memory": "next",
|
|
23
23
|
"@twin.org/nameof": "next",
|
|
24
|
-
"@twin.org/nft-connector-iota": "0.0.
|
|
24
|
+
"@twin.org/nft-connector-iota": "0.0.3-next.2",
|
|
25
25
|
"@twin.org/vault-connector-entity-storage": "next",
|
|
26
26
|
"@twin.org/vault-models": "next",
|
|
27
27
|
"@twin.org/wallet-cli": "next",
|
|
28
28
|
"@twin.org/wallet-models": "next",
|
|
29
|
-
"commander": "14.0.
|
|
29
|
+
"commander": "14.0.2"
|
|
30
30
|
},
|
|
31
|
-
"main": "./dist/
|
|
32
|
-
"module": "./dist/esm/index.mjs",
|
|
31
|
+
"main": "./dist/es/index.js",
|
|
33
32
|
"types": "./dist/types/index.d.ts",
|
|
34
33
|
"exports": {
|
|
35
34
|
".": {
|
|
36
35
|
"types": "./dist/types/index.d.ts",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
36
|
+
"import": "./dist/es/index.js",
|
|
37
|
+
"default": "./dist/es/index.js"
|
|
39
38
|
}
|
|
40
39
|
},
|
|
41
40
|
"files": [
|
|
42
41
|
"bin",
|
|
43
|
-
"dist/
|
|
44
|
-
"dist/esm",
|
|
42
|
+
"dist/es",
|
|
45
43
|
"dist/types",
|
|
46
44
|
"dist/locales",
|
|
47
45
|
"locales",
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1,440 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var path = require('node:path');
|
|
4
|
-
var node_url = require('node:url');
|
|
5
|
-
var cliCore = require('@twin.org/cli-core');
|
|
6
|
-
var cryptoCli = require('@twin.org/crypto-cli');
|
|
7
|
-
var walletCli = require('@twin.org/wallet-cli');
|
|
8
|
-
var core = require('@twin.org/core');
|
|
9
|
-
var nftConnectorIota = require('@twin.org/nft-connector-iota');
|
|
10
|
-
var vaultModels = require('@twin.org/vault-models');
|
|
11
|
-
var walletModels = require('@twin.org/wallet-models');
|
|
12
|
-
var commander = require('commander');
|
|
13
|
-
var entityStorageConnectorMemory = require('@twin.org/entity-storage-connector-memory');
|
|
14
|
-
var entityStorageModels = require('@twin.org/entity-storage-models');
|
|
15
|
-
var vaultConnectorEntityStorage = require('@twin.org/vault-connector-entity-storage');
|
|
16
|
-
|
|
17
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
18
|
-
// Copyright 2024 IOTA Stiftung.
|
|
19
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
20
|
-
/**
|
|
21
|
-
* Setup the vault for use in the CLI commands.
|
|
22
|
-
*/
|
|
23
|
-
function setupVault() {
|
|
24
|
-
vaultConnectorEntityStorage.initSchema();
|
|
25
|
-
entityStorageModels.EntityStorageConnectorFactory.register("vault-key", () => new entityStorageConnectorMemory.MemoryEntityStorageConnector({
|
|
26
|
-
entitySchema: "VaultKey"
|
|
27
|
-
}));
|
|
28
|
-
entityStorageModels.EntityStorageConnectorFactory.register("vault-secret", () => new entityStorageConnectorMemory.MemoryEntityStorageConnector({
|
|
29
|
-
entitySchema: "VaultSecret"
|
|
30
|
-
}));
|
|
31
|
-
const vaultConnector = new vaultConnectorEntityStorage.EntityStorageVaultConnector();
|
|
32
|
-
vaultModels.VaultConnectorFactory.register("vault", () => vaultConnector);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Setup the NFT connector for use in the CLI commands.
|
|
36
|
-
* @param options The options for the NFT connector.
|
|
37
|
-
* @param options.nodeEndpoint The node endpoint.
|
|
38
|
-
* @param options.network The network.
|
|
39
|
-
* @param options.vaultSeedId The vault seed ID.
|
|
40
|
-
* @param options.walletAddressIndex The wallet address index.
|
|
41
|
-
* @returns The NFT connector.
|
|
42
|
-
*/
|
|
43
|
-
function setupNftConnector(options) {
|
|
44
|
-
return new nftConnectorIota.IotaNftConnector({
|
|
45
|
-
config: {
|
|
46
|
-
clientOptions: {
|
|
47
|
-
url: options.nodeEndpoint
|
|
48
|
-
},
|
|
49
|
-
network: options.network ?? "",
|
|
50
|
-
vaultSeedId: options.vaultSeedId,
|
|
51
|
-
walletAddressIndex: options.walletAddressIndex ?? 0
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Copyright 2024 IOTA Stiftung.
|
|
57
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
58
|
-
/**
|
|
59
|
-
* Build the nft burn command for the CLI.
|
|
60
|
-
* @returns The command.
|
|
61
|
-
*/
|
|
62
|
-
function buildCommandNftBurn() {
|
|
63
|
-
const command = new commander.Command();
|
|
64
|
-
command
|
|
65
|
-
.name("nft-burn")
|
|
66
|
-
.summary(core.I18n.formatMessage("commands.nft-burn.summary"))
|
|
67
|
-
.description(core.I18n.formatMessage("commands.nft-burn.description"))
|
|
68
|
-
.requiredOption(core.I18n.formatMessage("commands.nft-burn.options.seed.param"), core.I18n.formatMessage("commands.nft-burn.options.seed.description"))
|
|
69
|
-
.requiredOption(core.I18n.formatMessage("commands.nft-burn.options.id.param"), core.I18n.formatMessage("commands.nft-burn.options.id.description"));
|
|
70
|
-
command
|
|
71
|
-
.option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
|
|
72
|
-
.option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
|
|
73
|
-
.option(core.I18n.formatMessage("commands.common.options.explorer.param"), core.I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
|
|
74
|
-
.action(actionCommandNftBurn);
|
|
75
|
-
return command;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Action the nft burn command.
|
|
79
|
-
* @param opts The options for the command.
|
|
80
|
-
* @param opts.seed The seed required for signing by the issuer.
|
|
81
|
-
* @param opts.id The id of the NFT to burn in urn format.
|
|
82
|
-
* @param opts.node The node URL.
|
|
83
|
-
* @param opts.network The network to use for connector.
|
|
84
|
-
* @param opts.explorer The explorer URL.
|
|
85
|
-
*/
|
|
86
|
-
async function actionCommandNftBurn(opts) {
|
|
87
|
-
const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
|
|
88
|
-
const id = cliCore.CLIParam.stringValue("id", opts.id);
|
|
89
|
-
const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
|
|
90
|
-
const network = cliCore.CLIParam.stringValue("network", opts.network);
|
|
91
|
-
const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
|
|
92
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-burn.labels.nftId"), id);
|
|
93
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
|
|
94
|
-
if (core.Is.stringValue(network)) {
|
|
95
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
|
|
96
|
-
}
|
|
97
|
-
cliCore.CLIDisplay.break();
|
|
98
|
-
setupVault();
|
|
99
|
-
const localIdentity = "local";
|
|
100
|
-
const vaultSeedId = "local-seed";
|
|
101
|
-
const vaultConnector = vaultModels.VaultConnectorFactory.get("vault");
|
|
102
|
-
await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, core.Converter.bytesToBase64(seed));
|
|
103
|
-
const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, network, vaultSeedId }, walletCli.WalletConnectorTypes.Iota);
|
|
104
|
-
walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
|
|
105
|
-
const nftConnector = setupNftConnector({ nodeEndpoint, network, vaultSeedId });
|
|
106
|
-
if (core.Is.function(nftConnector.start)) {
|
|
107
|
-
await nftConnector.start(localIdentity);
|
|
108
|
-
}
|
|
109
|
-
cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.nft-burn.progress.burningNft"));
|
|
110
|
-
cliCore.CLIDisplay.break();
|
|
111
|
-
cliCore.CLIDisplay.spinnerStart();
|
|
112
|
-
await nftConnector.burn(localIdentity, id);
|
|
113
|
-
cliCore.CLIDisplay.spinnerStop();
|
|
114
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${nftConnectorIota.IotaNftUtils.nftIdToObjectId(id)}?network=${network}`);
|
|
115
|
-
cliCore.CLIDisplay.break();
|
|
116
|
-
cliCore.CLIDisplay.done();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Copyright 2024 IOTA Stiftung.
|
|
120
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
121
|
-
/**
|
|
122
|
-
* Build the nft mint command for the CLI.
|
|
123
|
-
* @returns The command.
|
|
124
|
-
*/
|
|
125
|
-
function buildCommandNftMint() {
|
|
126
|
-
const command = new commander.Command();
|
|
127
|
-
command
|
|
128
|
-
.name("nft-mint")
|
|
129
|
-
.summary(core.I18n.formatMessage("commands.nft-mint.summary"))
|
|
130
|
-
.description(core.I18n.formatMessage("commands.nft-mint.description"))
|
|
131
|
-
.requiredOption(core.I18n.formatMessage("commands.nft-mint.options.seed.param"), core.I18n.formatMessage("commands.nft-mint.options.seed.description"))
|
|
132
|
-
.requiredOption(core.I18n.formatMessage("commands.nft-mint.options.issuer.param"), core.I18n.formatMessage("commands.nft-mint.options.issuer.description"))
|
|
133
|
-
.option(core.I18n.formatMessage("commands.nft-mint.options.wallet-address-index.param"), core.I18n.formatMessage("commands.nft-mint.options.wallet-address-index.description"), "0")
|
|
134
|
-
.requiredOption(core.I18n.formatMessage("commands.nft-mint.options.tag.param"), core.I18n.formatMessage("commands.nft-mint.options.tag.description"))
|
|
135
|
-
.option(core.I18n.formatMessage("commands.nft-mint.options.immutable-json.param"), core.I18n.formatMessage("commands.nft-mint.options.immutable-json.description"))
|
|
136
|
-
.option(core.I18n.formatMessage("commands.nft-mint.options.mutable-json.param"), core.I18n.formatMessage("commands.nft-mint.options.mutable-json.description"));
|
|
137
|
-
cliCore.CLIOptions.output(command, {
|
|
138
|
-
noConsole: true,
|
|
139
|
-
json: true,
|
|
140
|
-
env: true,
|
|
141
|
-
mergeJson: true,
|
|
142
|
-
mergeEnv: true
|
|
143
|
-
});
|
|
144
|
-
command
|
|
145
|
-
.option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
|
|
146
|
-
.option(core.I18n.formatMessage("commands.common.options.explorer.param"), core.I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
|
|
147
|
-
.option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
|
|
148
|
-
.action(actionCommandNftMint);
|
|
149
|
-
return command;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Action the nft mint command.
|
|
153
|
-
* @param opts The options for the command.
|
|
154
|
-
* @param opts.seed The seed required for signing by the issuer.
|
|
155
|
-
* @param opts.issuer The identity of the issuer.
|
|
156
|
-
* @param opts.walletAddressIndex The wallet address index.
|
|
157
|
-
* @param opts.tag The tag for the NFT.
|
|
158
|
-
* @param opts.immutableJson Filename of the immutable JSON data.
|
|
159
|
-
* @param opts.mutableJson Filename of the mutable JSON data.
|
|
160
|
-
* @param opts.node The node URL.
|
|
161
|
-
* @param opts.network The network to use for connector.
|
|
162
|
-
* @param opts.explorer The explorer URL.
|
|
163
|
-
*/
|
|
164
|
-
async function actionCommandNftMint(opts) {
|
|
165
|
-
const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
|
|
166
|
-
const issuer = cliCore.CLIParam.stringValue("issuer", opts.issuer);
|
|
167
|
-
const walletAddressIndex = core.Is.empty(opts.walletAddressIndex)
|
|
168
|
-
? undefined
|
|
169
|
-
: cliCore.CLIParam.integer("wallet-address-index", opts.walletAddressIndex);
|
|
170
|
-
const tag = cliCore.CLIParam.stringValue("tag", opts.tag);
|
|
171
|
-
const immutableJson = opts.immutableJson
|
|
172
|
-
? path.resolve(opts.immutableJson)
|
|
173
|
-
: undefined;
|
|
174
|
-
const mutableJson = opts.mutableJson
|
|
175
|
-
? path.resolve(opts.mutableJson)
|
|
176
|
-
: undefined;
|
|
177
|
-
const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
|
|
178
|
-
const network = cliCore.CLIParam.stringValue("network", opts.network);
|
|
179
|
-
const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
|
|
180
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-mint.labels.issuer"), issuer);
|
|
181
|
-
if (core.Is.integer(walletAddressIndex)) {
|
|
182
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-mint.labels.walletAddressIndex"), walletAddressIndex);
|
|
183
|
-
}
|
|
184
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-mint.labels.tag"), tag);
|
|
185
|
-
if (core.Is.stringValue(immutableJson)) {
|
|
186
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-mint.labels.immutableJsonFilename"), immutableJson);
|
|
187
|
-
}
|
|
188
|
-
if (core.Is.stringValue(mutableJson)) {
|
|
189
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-mint.labels.mutableJsonFilename"), mutableJson);
|
|
190
|
-
}
|
|
191
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
|
|
192
|
-
if (core.Is.stringValue(network)) {
|
|
193
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
|
|
194
|
-
}
|
|
195
|
-
cliCore.CLIDisplay.break();
|
|
196
|
-
setupVault();
|
|
197
|
-
const localIdentity = issuer;
|
|
198
|
-
const vaultSeedId = "local-seed";
|
|
199
|
-
const vaultConnector = vaultModels.VaultConnectorFactory.get("vault");
|
|
200
|
-
await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, core.Converter.bytesToBase64(seed));
|
|
201
|
-
const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, network, vaultSeedId }, walletCli.WalletConnectorTypes.Iota);
|
|
202
|
-
walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
|
|
203
|
-
const nftConnector = setupNftConnector({
|
|
204
|
-
nodeEndpoint,
|
|
205
|
-
network,
|
|
206
|
-
vaultSeedId,
|
|
207
|
-
walletAddressIndex
|
|
208
|
-
});
|
|
209
|
-
if (core.Is.function(nftConnector.start)) {
|
|
210
|
-
await nftConnector.start(localIdentity);
|
|
211
|
-
}
|
|
212
|
-
const immutableJsonData = core.Is.stringValue(immutableJson)
|
|
213
|
-
? await cliCore.CLIUtils.readJsonFile(immutableJson)
|
|
214
|
-
: undefined;
|
|
215
|
-
const mutableJsonData = core.Is.stringValue(mutableJson)
|
|
216
|
-
? await cliCore.CLIUtils.readJsonFile(mutableJson)
|
|
217
|
-
: undefined;
|
|
218
|
-
if (core.Is.object(immutableJsonData)) {
|
|
219
|
-
cliCore.CLIDisplay.section(core.I18n.formatMessage("commands.nft-mint.labels.immutableJson"));
|
|
220
|
-
cliCore.CLIDisplay.json(immutableJsonData);
|
|
221
|
-
cliCore.CLIDisplay.break();
|
|
222
|
-
}
|
|
223
|
-
if (core.Is.object(mutableJsonData)) {
|
|
224
|
-
cliCore.CLIDisplay.section(core.I18n.formatMessage("commands.nft-mint.labels.mutableJson"));
|
|
225
|
-
cliCore.CLIDisplay.json(mutableJsonData);
|
|
226
|
-
cliCore.CLIDisplay.break();
|
|
227
|
-
}
|
|
228
|
-
cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.nft-mint.progress.mintingNft"));
|
|
229
|
-
cliCore.CLIDisplay.break();
|
|
230
|
-
cliCore.CLIDisplay.spinnerStart();
|
|
231
|
-
const nftId = await nftConnector.mint(localIdentity, tag, immutableJsonData, mutableJsonData);
|
|
232
|
-
cliCore.CLIDisplay.spinnerStop();
|
|
233
|
-
if (opts.console) {
|
|
234
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-mint.labels.nftId"), nftId);
|
|
235
|
-
cliCore.CLIDisplay.break();
|
|
236
|
-
}
|
|
237
|
-
if (core.Is.stringValue(opts?.json)) {
|
|
238
|
-
await cliCore.CLIUtils.writeJsonFile(opts.json, { nftId }, opts.mergeJson);
|
|
239
|
-
}
|
|
240
|
-
if (core.Is.stringValue(opts?.env)) {
|
|
241
|
-
await cliCore.CLIUtils.writeEnvFile(opts.env, [`NFT_ID="${nftId}"`], opts.mergeEnv);
|
|
242
|
-
}
|
|
243
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${nftConnectorIota.IotaNftUtils.nftIdToObjectId(nftId)}?network=${network}`);
|
|
244
|
-
cliCore.CLIDisplay.break();
|
|
245
|
-
cliCore.CLIDisplay.done();
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// Copyright 2024 IOTA Stiftung.
|
|
249
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
250
|
-
/**
|
|
251
|
-
* Build the nft resolve command for the CLI.
|
|
252
|
-
* @returns The command.
|
|
253
|
-
*/
|
|
254
|
-
function buildCommandNftResolve() {
|
|
255
|
-
const command = new commander.Command();
|
|
256
|
-
command
|
|
257
|
-
.name("nft-resolve")
|
|
258
|
-
.summary(core.I18n.formatMessage("commands.nft-resolve.summary"))
|
|
259
|
-
.description(core.I18n.formatMessage("commands.nft-resolve.description"))
|
|
260
|
-
.requiredOption(core.I18n.formatMessage("commands.nft-resolve.options.id.param"), core.I18n.formatMessage("commands.nft-resolve.options.id.description"));
|
|
261
|
-
cliCore.CLIOptions.output(command, {
|
|
262
|
-
noConsole: true,
|
|
263
|
-
json: true,
|
|
264
|
-
env: false,
|
|
265
|
-
mergeJson: true,
|
|
266
|
-
mergeEnv: false
|
|
267
|
-
});
|
|
268
|
-
command
|
|
269
|
-
.option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
|
|
270
|
-
.option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
|
|
271
|
-
.option(core.I18n.formatMessage("commands.common.options.explorer.param"), core.I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
|
|
272
|
-
.action(actionCommandNftResolve);
|
|
273
|
-
return command;
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Action the nft resolve command.
|
|
277
|
-
* @param opts The options for the command.
|
|
278
|
-
* @param opts.id The id of the NFT to resolve in urn format.
|
|
279
|
-
* @param opts.node The node URL.
|
|
280
|
-
* @param opts.network The network to use for connector.
|
|
281
|
-
* @param opts.explorer The explorer URL.
|
|
282
|
-
*/
|
|
283
|
-
async function actionCommandNftResolve(opts) {
|
|
284
|
-
const id = cliCore.CLIParam.stringValue("id", opts.id);
|
|
285
|
-
const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
|
|
286
|
-
const network = cliCore.CLIParam.stringValue("network", opts.network);
|
|
287
|
-
const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
|
|
288
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-resolve.labels.nftId"), id);
|
|
289
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
|
|
290
|
-
if (core.Is.stringValue(network)) {
|
|
291
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
|
|
292
|
-
}
|
|
293
|
-
cliCore.CLIDisplay.break();
|
|
294
|
-
setupVault();
|
|
295
|
-
const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, network }, walletCli.WalletConnectorTypes.Iota);
|
|
296
|
-
walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
|
|
297
|
-
const nftConnector = setupNftConnector({ nodeEndpoint, network });
|
|
298
|
-
cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.nft-resolve.progress.resolvingNft"));
|
|
299
|
-
cliCore.CLIDisplay.break();
|
|
300
|
-
cliCore.CLIDisplay.spinnerStart();
|
|
301
|
-
const nft = await nftConnector.resolve(id);
|
|
302
|
-
cliCore.CLIDisplay.spinnerStop();
|
|
303
|
-
if (opts.console) {
|
|
304
|
-
cliCore.CLIDisplay.section(core.I18n.formatMessage("commands.nft-resolve.labels.nft"));
|
|
305
|
-
cliCore.CLIDisplay.json(nft);
|
|
306
|
-
cliCore.CLIDisplay.break();
|
|
307
|
-
}
|
|
308
|
-
if (core.Is.stringValue(opts?.json)) {
|
|
309
|
-
await cliCore.CLIUtils.writeJsonFile(opts.json, nft, opts.mergeJson);
|
|
310
|
-
}
|
|
311
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${nftConnectorIota.IotaNftUtils.nftIdToObjectId(id)}?network=${network}`);
|
|
312
|
-
cliCore.CLIDisplay.break();
|
|
313
|
-
cliCore.CLIDisplay.done();
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// Copyright 2024 IOTA Stiftung.
|
|
317
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
318
|
-
/**
|
|
319
|
-
* Build the nft transfer command for the CLI.
|
|
320
|
-
* @returns The command.
|
|
321
|
-
*/
|
|
322
|
-
function buildCommandNftTransfer() {
|
|
323
|
-
const command = new commander.Command();
|
|
324
|
-
command
|
|
325
|
-
.name("nft-transfer")
|
|
326
|
-
.summary(core.I18n.formatMessage("commands.nft-transfer.summary"))
|
|
327
|
-
.description(core.I18n.formatMessage("commands.nft-transfer.description"))
|
|
328
|
-
.requiredOption(core.I18n.formatMessage("commands.nft-transfer.options.seed.param"), core.I18n.formatMessage("commands.nft-transfer.options.seed.description"))
|
|
329
|
-
.requiredOption(core.I18n.formatMessage("commands.nft-transfer.options.id.param"), core.I18n.formatMessage("commands.nft-transfer.options.id.description"))
|
|
330
|
-
.requiredOption(core.I18n.formatMessage("commands.nft-transfer.options.recipient-identity.param"), core.I18n.formatMessage("commands.nft-transfer.options.recipient-identity.description"))
|
|
331
|
-
.requiredOption(core.I18n.formatMessage("commands.nft-transfer.options.recipient-address.param"), core.I18n.formatMessage("commands.nft-transfer.options.recipient-address.description"));
|
|
332
|
-
command
|
|
333
|
-
.option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
|
|
334
|
-
.option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
|
|
335
|
-
.option(core.I18n.formatMessage("commands.common.options.explorer.param"), core.I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
|
|
336
|
-
.action(actionCommandNftTransfer);
|
|
337
|
-
return command;
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Action the nft transfer command.
|
|
341
|
-
* @param opts The options for the command.
|
|
342
|
-
* @param opts.seed The seed required for signing by the issuer.
|
|
343
|
-
* @param opts.id The id of the NFT to transfer in urn format.
|
|
344
|
-
* @param opts.recipientIdentity The recipient address of the NFT.
|
|
345
|
-
* @param opts.recipientAddress The recipient address of the NFT.
|
|
346
|
-
* @param opts.node The node URL.
|
|
347
|
-
* @param opts.network The network to use for connector.
|
|
348
|
-
* @param opts.explorer The explorer URL.
|
|
349
|
-
*/
|
|
350
|
-
async function actionCommandNftTransfer(opts) {
|
|
351
|
-
const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
|
|
352
|
-
const id = cliCore.CLIParam.stringValue("id", opts.id);
|
|
353
|
-
const recipientIdentity = cliCore.CLIParam.stringValue("recipientIdentity", opts.recipientIdentity);
|
|
354
|
-
const recipientAddress = core.Converter.bytesToHex(cliCore.CLIParam.hex("recipientAddress", opts.recipientAddress), true);
|
|
355
|
-
const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
|
|
356
|
-
const network = cliCore.CLIParam.stringValue("network", opts.network);
|
|
357
|
-
const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
|
|
358
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-transfer.labels.nftId"), id);
|
|
359
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-transfer.labels.recipientIdentity"), recipientIdentity);
|
|
360
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.nft-transfer.labels.recipientAddress"), recipientAddress);
|
|
361
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
|
|
362
|
-
if (core.Is.stringValue(network)) {
|
|
363
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
|
|
364
|
-
}
|
|
365
|
-
cliCore.CLIDisplay.break();
|
|
366
|
-
setupVault();
|
|
367
|
-
const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, network }, walletCli.WalletConnectorTypes.Iota);
|
|
368
|
-
walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
|
|
369
|
-
const localIdentity = "local";
|
|
370
|
-
const vaultSeedId = "local-seed";
|
|
371
|
-
const vaultConnector = vaultModels.VaultConnectorFactory.get("vault");
|
|
372
|
-
await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, core.Converter.bytesToBase64(seed));
|
|
373
|
-
const nftConnector = setupNftConnector({ nodeEndpoint, network, vaultSeedId });
|
|
374
|
-
if (core.Is.function(nftConnector.start)) {
|
|
375
|
-
await nftConnector.start(localIdentity);
|
|
376
|
-
}
|
|
377
|
-
cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.nft-transfer.progress.transferringNft"));
|
|
378
|
-
cliCore.CLIDisplay.break();
|
|
379
|
-
cliCore.CLIDisplay.spinnerStart();
|
|
380
|
-
await nftConnector.transfer(localIdentity, id, recipientIdentity, recipientAddress);
|
|
381
|
-
cliCore.CLIDisplay.spinnerStop();
|
|
382
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${nftConnectorIota.IotaNftUtils.nftIdToObjectId(id)}?network=${network}`);
|
|
383
|
-
cliCore.CLIDisplay.break();
|
|
384
|
-
cliCore.CLIDisplay.done();
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
// Copyright 2024 IOTA Stiftung.
|
|
388
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
389
|
-
/**
|
|
390
|
-
* The main entry point for the CLI.
|
|
391
|
-
*/
|
|
392
|
-
class CLI extends cliCore.CLIBase {
|
|
393
|
-
/**
|
|
394
|
-
* Run the app.
|
|
395
|
-
* @param argv The process arguments.
|
|
396
|
-
* @param localesDirectory The directory for the locales, default to relative to the script.
|
|
397
|
-
* @param options Additional options for the CLI.
|
|
398
|
-
* @param options.overrideOutputWidth Override the output width.
|
|
399
|
-
* @returns The exit code.
|
|
400
|
-
*/
|
|
401
|
-
async run(argv, localesDirectory, options) {
|
|
402
|
-
return this.execute({
|
|
403
|
-
title: "TWIN NFT",
|
|
404
|
-
appName: "twin-nft",
|
|
405
|
-
version: "0.0.2-next.8", // x-release-please-version
|
|
406
|
-
icon: "🌍",
|
|
407
|
-
supportsEnvFiles: true,
|
|
408
|
-
overrideOutputWidth: options?.overrideOutputWidth,
|
|
409
|
-
showDevToolWarning: true
|
|
410
|
-
}, localesDirectory ?? path.join(path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)))), "../locales"), argv);
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* Get the commands for the CLI.
|
|
414
|
-
* @param program The main program to add the commands to.
|
|
415
|
-
* @internal
|
|
416
|
-
*/
|
|
417
|
-
getCommands(program) {
|
|
418
|
-
return [
|
|
419
|
-
cryptoCli.buildCommandMnemonic(),
|
|
420
|
-
cryptoCli.buildCommandAddress(),
|
|
421
|
-
walletCli.buildCommandFaucet(),
|
|
422
|
-
buildCommandNftMint(),
|
|
423
|
-
buildCommandNftResolve(),
|
|
424
|
-
buildCommandNftBurn(),
|
|
425
|
-
buildCommandNftTransfer()
|
|
426
|
-
];
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
exports.CLI = CLI;
|
|
431
|
-
exports.actionCommandNftBurn = actionCommandNftBurn;
|
|
432
|
-
exports.actionCommandNftMint = actionCommandNftMint;
|
|
433
|
-
exports.actionCommandNftResolve = actionCommandNftResolve;
|
|
434
|
-
exports.actionCommandNftTransfer = actionCommandNftTransfer;
|
|
435
|
-
exports.buildCommandNftBurn = buildCommandNftBurn;
|
|
436
|
-
exports.buildCommandNftMint = buildCommandNftMint;
|
|
437
|
-
exports.buildCommandNftResolve = buildCommandNftResolve;
|
|
438
|
-
exports.buildCommandNftTransfer = buildCommandNftTransfer;
|
|
439
|
-
exports.setupNftConnector = setupNftConnector;
|
|
440
|
-
exports.setupVault = setupVault;
|