@parity/dotns-cli 0.5.5 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +108 -59
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2886,7 +2886,7 @@ var init_Store = __esm(() => {
2886
2886
  });
2887
2887
 
2888
2888
  // src/utils/constants.ts
2889
- var PREVIEW_BASE_URL = "http://dotns.paseo.li/#/preview", DEFAULT_BULLETIN_RPC = "wss://paseo-bulletin-rpc.polkadot.io", DEFAULT_CHUNK_SIZE_BYTES, MAX_SINGLE_UPLOAD_SIZE_BYTES, DEFAULT_UPLOAD_MAX_RETRIES = 5, MAX_UPLOAD_MAX_RETRIES = 20, UPLOAD_RETRY_BASE_DELAYS_MS, DEFAULT_AUTHORIZATION_TRANSACTIONS = 1e6, DEFAULT_AUTHORIZATION_BYTES, DEFAULT_VERIFICATION_GATEWAY = "https://paseo-ipfs.polkadot.io", DOT_NODE = "0x3fce7d1364a893e213bc4212792b517ffc88f5b13b86c8ef9c8d390c3a1370ce", DECIMALS = 12n, NATIVE_TO_ETH_RATIO = 1000000n, DEFAULT_MNEMONIC = "bottom drive obey lake curtain smoke basket hold race lonely fit walk", DEFAULT_SUDO_KEY_URI = "//Alice", BULLETIN_BLOCK_TIME_MS = 6000, OPERATION_TIMEOUT_MILLISECONDS = 300000, DEFAULT_COMMITMENT_BUFFER_SECONDS = 6, COMMITMENT_POLL_TIMEOUT_MS = 30000, COMMITMENT_POLL_INTERVAL_MS = 2000, DOTNS_REGISTRAR_CONTROLLER_ABI, DOTNS_REGISTRY_ABI, DOTNS_REGISTRAR_ABI, DOTNS_REVERSE_RESOLVER_ABI, DOTNS_CONTENT_RESOLVER_ABI, DOTNS_RESOLVER_ABI, POP_RULES_ABI, STORE_FACTORY_ABI, STORE_ABI, RPC_ENDPOINTS, CONTRACTS;
2889
+ var PREVIEW_BASE_URL = "http://dotns.paseo.li/#/preview", DEFAULT_BULLETIN_RPC = "wss://paseo-bulletin-rpc.polkadot.io", DEFAULT_CHUNK_SIZE_BYTES, MAX_SINGLE_UPLOAD_SIZE_BYTES, DEFAULT_UPLOAD_MAX_RETRIES = 5, MAX_UPLOAD_MAX_RETRIES = 20, UPLOAD_RETRY_BASE_DELAYS_MS, DEFAULT_AUTHORIZATION_TRANSACTIONS = 1e6, DEFAULT_AUTHORIZATION_BYTES, DEFAULT_VERIFICATION_GATEWAY = "https://paseo-ipfs.polkadot.io", DOT_NODE = "0x3fce7d1364a893e213bc4212792b517ffc88f5b13b86c8ef9c8d390c3a1370ce", DECIMALS_DOT = 10n, NATIVE_TO_ETH_RATIO = 1000000n, DEFAULT_MNEMONIC = "bottom drive obey lake curtain smoke basket hold race lonely fit walk", DEFAULT_SUDO_KEY_URI = "//Alice", BULLETIN_BLOCK_TIME_MS = 6000, OPERATION_TIMEOUT_MILLISECONDS = 300000, DEFAULT_COMMITMENT_BUFFER_SECONDS = 6, COMMITMENT_POLL_TIMEOUT_MS = 30000, COMMITMENT_POLL_INTERVAL_MS = 2000, DOTNS_REGISTRAR_CONTROLLER_ABI, DOTNS_REGISTRY_ABI, DOTNS_REGISTRAR_ABI, DOTNS_REVERSE_RESOLVER_ABI, DOTNS_CONTENT_RESOLVER_ABI, DOTNS_RESOLVER_ABI, POP_RULES_ABI, STORE_FACTORY_ABI, STORE_ABI, RPC_ENDPOINTS, CONTRACTS;
2890
2890
  var init_constants = __esm(() => {
2891
2891
  init_DotnsRegistrarController();
2892
2892
  init_DotnsRegistry();
@@ -8292,11 +8292,11 @@ var init_reporter = __esm(() => {
8292
8292
 
8293
8293
  // src/utils/formatting.ts
8294
8294
  function formatNativeBalance(valueInNativeUnits) {
8295
- const divisor = 10n ** DECIMALS;
8295
+ const divisor = 10n ** DECIMALS_DOT;
8296
8296
  const wholePart = valueInNativeUnits / divisor;
8297
8297
  const fractionalPart = valueInNativeUnits % divisor;
8298
8298
  let fractionalString = fractionalPart.toString();
8299
- const missingZeroCount = DECIMALS - BigInt(fractionalString.length);
8299
+ const missingZeroCount = DECIMALS_DOT - BigInt(fractionalString.length);
8300
8300
  if (missingZeroCount > 0n) {
8301
8301
  fractionalString = "0".repeat(Number(missingZeroCount)) + fractionalString;
8302
8302
  }
@@ -8306,8 +8306,8 @@ function parseNativeBalance(decimalValue) {
8306
8306
  const parts = decimalValue.split(".");
8307
8307
  const wholePart = BigInt(parts[0] || "0");
8308
8308
  const fractionalPart = parts[1] || "0";
8309
- const paddedFraction = fractionalPart.padEnd(Number(DECIMALS), "0").slice(0, Number(DECIMALS));
8310
- return wholePart * 10n ** DECIMALS + BigInt(paddedFraction);
8309
+ const paddedFraction = fractionalPart.padEnd(Number(DECIMALS_DOT), "0").slice(0, Number(DECIMALS_DOT));
8310
+ return wholePart * 10n ** DECIMALS_DOT + BigInt(paddedFraction);
8311
8311
  }
8312
8312
  function convertWeiToNative(weiValue) {
8313
8313
  return weiValue / NATIVE_TO_ETH_RATIO;
@@ -240167,6 +240167,20 @@ var require_bn = __commonJS((exports, module) => {
240167
240167
  });
240168
240168
 
240169
240169
  // src/utils/contractInteractions.ts
240170
+ function isRevertFlag(flags) {
240171
+ return (flags & 1n) === 1n;
240172
+ }
240173
+ function buildRevertError(data, abi) {
240174
+ if (data === "0x") {
240175
+ return new Error(UNMAPPED_ORIGIN_REVERT_HINT);
240176
+ }
240177
+ let revertReason = data;
240178
+ try {
240179
+ const decoded = decodeErrorResult({ abi, data });
240180
+ revertReason = decoded.args ? `${decoded.errorName}(${decoded.args.map(String).join(", ")})` : decoded.errorName;
240181
+ } catch {}
240182
+ return new Error(`Contract reverted: ${revertReason}`);
240183
+ }
240170
240184
  async function performContractCall(clientWrapper, originSubstrateAddress, contractAddress, abi, functionName, args) {
240171
240185
  const encodedData = encodeFunctionData({
240172
240186
  abi,
@@ -240176,13 +240190,8 @@ async function performContractCall(clientWrapper, originSubstrateAddress, contra
240176
240190
  const call = await clientWrapper.performDryRunCall(originSubstrateAddress, contractAddress, 0n, encodedData);
240177
240191
  const data = call?.result?.value?.data ?? "0x";
240178
240192
  const flags = call?.result?.value?.flags ?? 1n;
240179
- if ((flags & 1n) === 1n) {
240180
- let revertReason = data;
240181
- try {
240182
- const decoded2 = decodeErrorResult({ abi, data });
240183
- revertReason = decoded2.args ? `${decoded2.errorName}(${decoded2.args.map(String).join(", ")})` : decoded2.errorName;
240184
- } catch {}
240185
- throw new Error(`Contract reverted: ${revertReason}`);
240193
+ if (isRevertFlag(flags)) {
240194
+ throw buildRevertError(data, abi);
240186
240195
  }
240187
240196
  const decoded = decodeFunctionResult({
240188
240197
  abi,
@@ -240225,10 +240234,12 @@ function computeDomainTokenId(label) {
240225
240234
  const node = keccak256(concatHex([DOT_NODE, labelhash]));
240226
240235
  return BigInt(node);
240227
240236
  }
240237
+ var UNMAPPED_ORIGIN_REVERT_HINT;
240228
240238
  var init_contractInteractions = __esm(() => {
240229
240239
  init__esm();
240230
240240
  init_constants();
240231
240241
  init_formatting();
240242
+ UNMAPPED_ORIGIN_REVERT_HINT = "Contract reverted with empty data. The origin SS58 is likely not mapped on " + "Asset Hub Revive. Run `dotns account map` (or any signed transaction from " + "this account), then retry.";
240232
240243
  });
240233
240244
 
240234
240245
  // abis/Multicall3.json
@@ -264950,6 +264961,9 @@ async function createAccountFromSource(source, isKeyUri) {
264950
264961
  const keyring = new Keyring({ type: "sr25519" });
264951
264962
  return isKeyUri ? keyring.addFromUri(source) : keyring.addFromMnemonic(source);
264952
264963
  }
264964
+ function createSubstrateSigner(keypair3) {
264965
+ return getPolkadotSigner(keypair3.publicKey, "Sr25519", async (input) => keypair3.sign(input));
264966
+ }
264953
264967
  async function readDefaultAccountName2(keystoreDirectoryPath) {
264954
264968
  try {
264955
264969
  const defaultPointerPath = path8.join(keystoreDirectoryPath, ".default");
@@ -264964,7 +264978,21 @@ function toSafeAccountFilename(accountName) {
264964
264978
  const safeFilename = accountName.trim().replaceAll(/[^\w.-]/g, "_");
264965
264979
  return `${safeFilename}.json`;
264966
264980
  }
264981
+ function resolveAuthSourceFromEnv(account) {
264982
+ const envMnemonic = process.env[ENV.MNEMONIC];
264983
+ if (envMnemonic && envMnemonic.length > 0) {
264984
+ return { source: envMnemonic, isKeyUri: false, resolvedFrom: "env", account };
264985
+ }
264986
+ const envKeyUri = process.env[ENV.KEY_URI];
264987
+ if (envKeyUri && envKeyUri.length > 0) {
264988
+ return { source: envKeyUri, isKeyUri: true, resolvedFrom: "env", account };
264989
+ }
264990
+ return;
264991
+ }
264967
264992
  async function resolveAuthSourceReadOnly() {
264993
+ const fromEnv = resolveAuthSourceFromEnv("readonly");
264994
+ if (fromEnv)
264995
+ return fromEnv;
264968
264996
  return {
264969
264997
  source: DEFAULT_MNEMONIC,
264970
264998
  isKeyUri: false,
@@ -264980,14 +265008,9 @@ async function resolveAuthSource(opts) {
264980
265008
  if (opts.keyUri) {
264981
265009
  return { source: opts.keyUri, isKeyUri: true, resolvedFrom: "cli", account: accountName };
264982
265010
  }
264983
- const envMnemonic = process.env[ENV.MNEMONIC];
264984
- const envKeyUri = process.env[ENV.KEY_URI];
264985
- if (envMnemonic && envMnemonic.length > 0) {
264986
- return { source: envMnemonic, isKeyUri: false, resolvedFrom: "env", account: accountName };
264987
- }
264988
- if (envKeyUri && envKeyUri.length > 0) {
264989
- return { source: envKeyUri, isKeyUri: true, resolvedFrom: "env", account: accountName };
264990
- }
265011
+ const fromEnv = resolveAuthSourceFromEnv(accountName);
265012
+ if (fromEnv)
265013
+ return fromEnv;
264991
265014
  const keystoreDirectoryPath = resolveKeystorePath(opts.keystorePath);
264992
265015
  if (await pathExists(keystoreDirectoryPath)) {
264993
265016
  const password = await getPasswordForDecrypt(opts.password);
@@ -265062,7 +265085,7 @@ async function prepareAssetHubContext(options2) {
265062
265085
  }));
265063
265086
  const account = await step("Loading keypair", async () => createAccountFromSource(auth.source, auth.isKeyUri));
265064
265087
  const substrateAddress = account.address;
265065
- const signer = getPolkadotSigner(account.publicKey, "Sr25519", async (input) => account.sign(input));
265088
+ const signer = createSubstrateSigner(account);
265066
265089
  const clientWrapper = new ReviveClientWrapper(client);
265067
265090
  const evmAddress = await step("Resolving EVM address", async () => clientWrapper.getEvmAddress(substrateAddress));
265068
265091
  console.log(source_default.bold(`
@@ -265108,7 +265131,7 @@ async function prepareBulletinContext(options2) {
265108
265131
  }));
265109
265132
  const account = await step("Loading keypair", async () => createAccountFromSource(auth.source, auth.isKeyUri));
265110
265133
  const substrateAddress = account.address;
265111
- const signer = getPolkadotSigner(account.publicKey, "Sr25519", async (input) => account.sign(input));
265134
+ const signer = createSubstrateSigner(account);
265112
265135
  console.log(source_default.bold(`
265113
265136
  \uD83D\uDCCB Configuration
265114
265137
  `));
@@ -265391,7 +265414,7 @@ function attachBulletinCommands(root) {
265391
265414
  const force = Boolean(options2.force);
265392
265415
  const signerKeyUri = String(mergedOptions.keyUri || DEFAULT_SUDO_KEY_URI);
265393
265416
  const targetAddress = await resolveTargetAddress(positionalAddress, mergedOptions, reporterMode);
265394
- const signerContext = await withBulletinHumanOutput(reporterMode, () => prepareContext({ keyUri: signerKeyUri, useBulletin: true }));
265417
+ const signerContext = await withBulletinHumanOutput(reporterMode, () => prepareContext({ keyUri: signerKeyUri, useBulletin: true, bulletinRpc }));
265395
265418
  if (!jsonOutput) {
265396
265419
  console.log(source_default.blue(`
265397
265420
  ▶ Bulletin Authorize`));
@@ -266420,11 +266443,18 @@ async function waitForMinimumCommitmentAge(clientWrapper, originSubstrateAddress
266420
266443
  clearInterval(intervalId);
266421
266444
  waitSpinner.text = "Verifying commitment age on-chain";
266422
266445
  const pollDeadline = Date.now() + COMMITMENT_POLL_TIMEOUT_MS;
266446
+ const timestampQuery = clientWrapper.client.query?.Timestamp?.Now;
266423
266447
  while (Date.now() < pollDeadline) {
266424
266448
  const polledTimestamp = await performContractCall(clientWrapper, originSubstrateAddress, CONTRACTS.DOTNS_REGISTRAR_CONTROLLER, DOTNS_REGISTRAR_CONTROLLER_ABI, "commitments", [commitment]);
266425
266449
  const polledCommitTime = typeof polledTimestamp === "bigint" ? Number(polledTimestamp) : polledTimestamp;
266426
- const nowSeconds = Math.floor(Date.now() / 1000);
266427
- if (polledCommitTime > 0 && nowSeconds - polledCommitTime >= minimumAgeSeconds) {
266450
+ let chainNowSeconds;
266451
+ if (timestampQuery?.getValue) {
266452
+ const timestampMs = await timestampQuery.getValue();
266453
+ chainNowSeconds = Math.floor(Number(timestampMs) / 1000);
266454
+ } else {
266455
+ chainNowSeconds = Math.floor(Date.now() / 1000);
266456
+ }
266457
+ if (polledCommitTime > 0 && chainNowSeconds - polledCommitTime >= minimumAgeSeconds) {
266428
266458
  waitSpinner.succeed("Commitment age requirement met (verified on-chain)");
266429
266459
  return;
266430
266460
  }
@@ -266602,6 +266632,7 @@ async function setUserProofOfPersonhoodStatus(clientWrapper, substrateAddress, s
266602
266632
  const displayName = label ? source_default.cyan(label) : "account";
266603
266633
  const checkSpinner = ora(`Checking current PoP status for ${displayName}`).start();
266604
266634
  try {
266635
+ await clientWrapper.ensureAccountMapped(substrateAddress, signer);
266605
266636
  const currentStatus = await getUserProofOfPersonhoodStatus(clientWrapper, substrateAddress, ownerAddress);
266606
266637
  checkSpinner.succeed("Current PoP status");
266607
266638
  console.log(source_default.gray(" current: ") + source_default.white(ProofOfPersonhoodStatus[currentStatus]));
@@ -266940,12 +266971,23 @@ async function prepareReadOnlyContext(options2) {
266940
266971
  };
266941
266972
  });
266942
266973
  const keypair3 = await step("Loading keypair", async () => createAccountFromSource(auth.source, auth.isKeyUri));
266974
+ await ensureAccountMappedWhenAuthenticated(clientWrapper, keypair3, auth.resolvedFrom);
266943
266975
  const evmAddress = await step("Resolving EVM address", async () => clientWrapper.getEvmAddress(keypair3.address));
266944
266976
  console.log(source_default.gray(`
266945
266977
  RPC: `) + source_default.white(rpc));
266946
266978
  console.log(source_default.gray(" Account: ") + source_default.white(keypair3.address));
266947
266979
  return { clientWrapper, account: { address: keypair3.address }, rpc, evmAddress };
266948
266980
  }
266981
+ async function ensureAccountMappedWhenAuthenticated(clientWrapper, keypair3, resolvedFrom) {
266982
+ if (resolvedFrom === "default")
266983
+ return;
266984
+ const signer = createSubstrateSigner(keypair3);
266985
+ try {
266986
+ await step("Ensuring account mapped", async () => clientWrapper.ensureAccountMapped(keypair3.address, signer));
266987
+ } catch (mapError) {
266988
+ console.log(source_default.yellow(` ⚠ Account mapping skipped: ${mapError instanceof Error ? mapError.message : String(mapError)}`));
266989
+ }
266990
+ }
266949
266991
  async function resolveRecipientByKind(clientWrapper, substrateAddress, destination) {
266950
266992
  const kind = classifyTransferDestination(destination);
266951
266993
  switch (kind) {
@@ -267198,29 +267240,37 @@ init_constants();
267198
267240
  init_contractInteractions();
267199
267241
  async function viewDomainText(clientWrapper, originSubstrateAddress, label, key, spinner) {
267200
267242
  const namehashNode = namehash(`${label}.dot`);
267243
+ const domain = `${label}.dot`;
267201
267244
  spinner.start("Querying registry");
267202
267245
  const recordExists = await performContractCall(clientWrapper, originSubstrateAddress, CONTRACTS.DOTNS_REGISTRY, DOTNS_REGISTRY_ABI, "recordExists", [namehashNode]);
267203
267246
  const ownerAddress = await performContractCall(clientWrapper, originSubstrateAddress, CONTRACTS.DOTNS_REGISTRY, DOTNS_REGISTRY_ABI, "owner", [namehashNode]);
267204
267247
  spinner.succeed("Registry read");
267205
267248
  console.log(source_default.gray(" registry: ") + source_default.white(CONTRACTS.DOTNS_REGISTRY));
267206
- console.log(source_default.gray(" domain: ") + source_default.cyan(`${label}.dot`));
267249
+ console.log(source_default.gray(" domain: ") + source_default.cyan(domain));
267207
267250
  console.log(source_default.gray(" node: ") + source_default.white(namehashNode));
267208
267251
  console.log(source_default.gray(" exists: ") + source_default.white(String(recordExists)));
267209
267252
  console.log(source_default.gray(" owner: ") + source_default.white(ownerAddress));
267210
267253
  console.log();
267211
267254
  if (!recordExists || ownerAddress === zeroAddress) {
267212
267255
  console.log(source_default.yellow(" status: Domain not registered"));
267213
- return;
267256
+ return { domain, key, exists: false, owner: null, value: null };
267214
267257
  }
267215
267258
  const value3 = await performContractCall(clientWrapper, originSubstrateAddress, CONTRACTS.DOTNS_CONTENT_RESOLVER, DOTNS_CONTENT_RESOLVER_ABI, "text", [namehashNode, key]);
267216
267259
  console.log(source_default.gray(" resolver: ") + source_default.white(CONTRACTS.DOTNS_CONTENT_RESOLVER));
267217
267260
  console.log(source_default.gray(" key: ") + source_default.white(key));
267218
267261
  console.log(source_default.gray(" value: ") + source_default.cyan(value3 || "(not set)"));
267219
- return value3;
267262
+ return {
267263
+ domain,
267264
+ key,
267265
+ exists: true,
267266
+ owner: ownerAddress,
267267
+ value: value3 === "" ? null : value3
267268
+ };
267220
267269
  }
267221
267270
  async function setDomainText(clientWrapper, originSubstrateAddress, signer, label, key, value3, spinner) {
267222
267271
  const namehashNode = namehash(`${label}.dot`);
267223
- console.log(source_default.gray(" domain: ") + source_default.cyan(`${label}.dot`));
267272
+ const domain = `${label}.dot`;
267273
+ console.log(source_default.gray(" domain: ") + source_default.cyan(domain));
267224
267274
  console.log(source_default.gray(" node: ") + source_default.white(namehashNode));
267225
267275
  console.log();
267226
267276
  const { exists: exists2, owner, caller } = await getResolverNodeInfo(clientWrapper, originSubstrateAddress, namehashNode);
@@ -267229,7 +267279,7 @@ async function setDomainText(clientWrapper, originSubstrateAddress, signer, labe
267229
267279
  console.log(source_default.gray(" caller: ") + source_default.white(caller));
267230
267280
  console.log();
267231
267281
  if (!exists2) {
267232
- throw new Error(`Domain ${label}.dot is not registered`);
267282
+ throw new Error(`Domain ${domain} is not registered`);
267233
267283
  }
267234
267284
  await requireResolverAuthorization(clientWrapper, originSubstrateAddress, owner, caller);
267235
267285
  console.log(source_default.gray(" status: ") + source_default.green("Ownership verified"));
@@ -267251,46 +267301,45 @@ async function setDomainText(clientWrapper, originSubstrateAddress, signer, labe
267251
267301
  const updatedValue = await performContractCall(clientWrapper, originSubstrateAddress, CONTRACTS.DOTNS_CONTENT_RESOLVER, DOTNS_CONTENT_RESOLVER_ABI, "text", [namehashNode, key]);
267252
267302
  console.log();
267253
267303
  console.log(source_default.gray(" new: ") + source_default.cyan(updatedValue));
267304
+ return {
267305
+ ok: true,
267306
+ domain,
267307
+ key,
267308
+ value: value3,
267309
+ txHash: transactionHash
267310
+ };
267254
267311
  }
267255
267312
 
267256
267313
  // src/cli/commands/text.ts
267257
- init_formatting();
267258
267314
  init_ora();
267259
267315
  function attachTextCommands(root) {
267260
267316
  const textCommand = root.command("text").description("Manage domain text records");
267261
267317
  addAuthOptions(textCommand);
267262
- const viewTextCommand = textCommand.command("view <name> <key>").description("View a domain text record");
267318
+ const viewTextCommand = textCommand.command("view <name> <key>").description("View a domain text record").option("--json", "Output result as JSON (suppresses all other output)", false);
267263
267319
  addAuthOptions(viewTextCommand).action(async (name10, key, options2, command) => {
267264
- const piped = !process.stdout.isTTY;
267265
- const origWrite = process.stdout.write.bind(process.stdout);
267266
- if (piped) {
267267
- console.log = console.error;
267268
- process.stdout.write = process.stderr.write.bind(process.stderr);
267269
- }
267320
+ const jsonOutput = getJsonFlag(command);
267270
267321
  try {
267271
267322
  const mergedOptions = getMergedOptions(command, options2);
267272
- const context = await prepareReadOnlyContext(mergedOptions);
267273
- console.error(source_default.bold(`
267323
+ const context = await maybeQuiet(jsonOutput, () => prepareReadOnlyContext(mergedOptions));
267324
+ if (!jsonOutput)
267325
+ console.log(source_default.bold(`
267274
267326
  ▶ Text View
267275
267327
  `));
267276
- const spinner = ora({ stream: process.stderr });
267277
- const value3 = await viewDomainText(context.clientWrapper, context.account.address, name10, key, spinner);
267278
- console.error(source_default.green(`
267328
+ const spinner = ora();
267329
+ const result = await maybeQuiet(jsonOutput, () => viewDomainText(context.clientWrapper, context.account.address, name10, key, spinner));
267330
+ if (!emitJsonResult(jsonOutput, result)) {
267331
+ console.log(source_default.green(`
267279
267332
  ✓ Complete
267280
267333
  `));
267281
- if (piped && value3 != null) {
267282
- origWrite(value3);
267283
267334
  }
267284
267335
  process.exit(0);
267285
267336
  } catch (error2) {
267286
- console.error(source_default.red(`
267287
- ✗ Error: ${formatErrorMessage(error2)}
267288
- `));
267289
- process.exit(1);
267337
+ handleCommandError(jsonOutput, error2);
267290
267338
  }
267291
267339
  });
267292
- const setTextCommand = textCommand.command("set <name> <key> [value]").description("Set a domain text record (reads from stdin if value omitted)");
267340
+ const setTextCommand = textCommand.command("set <name> <key> [value]").description("Set a domain text record (reads from stdin if value omitted)").option("--json", "Output result as JSON (suppresses all other output)", false);
267293
267341
  addAuthOptions(setTextCommand).action(async (name10, key, value3, options2, command) => {
267342
+ const jsonOutput = getJsonFlag(command);
267294
267343
  try {
267295
267344
  const mergedOptions = getMergedOptions(command, options2);
267296
267345
  if (!value3) {
@@ -267306,21 +267355,21 @@ function attachTextCommands(root) {
267306
267355
  if (mergedOptions.mnemonic && mergedOptions.keyUri) {
267307
267356
  throw new Error("Cannot specify both --mnemonic and --key-uri");
267308
267357
  }
267309
- const context = await prepareContext({ ...mergedOptions, useRevive: true });
267310
- console.log(source_default.bold(`
267358
+ const context = await maybeQuiet(jsonOutput, () => prepareContext({ ...mergedOptions, useRevive: true }));
267359
+ if (!jsonOutput)
267360
+ console.log(source_default.bold(`
267311
267361
  ▶ Text Set
267312
267362
  `));
267313
267363
  const spinner = ora();
267314
- await setDomainText(context.clientWrapper, context.substrateAddress, context.signer, name10, key, value3, spinner);
267315
- console.log(source_default.green(`
267364
+ const result = await maybeQuiet(jsonOutput, () => setDomainText(context.clientWrapper, context.substrateAddress, context.signer, name10, key, value3, spinner));
267365
+ if (!emitJsonResult(jsonOutput, result)) {
267366
+ console.log(source_default.green(`
267316
267367
  ✓ Complete
267317
267368
  `));
267369
+ }
267318
267370
  process.exit(0);
267319
267371
  } catch (error2) {
267320
- console.error(source_default.red(`
267321
- ✗ Error: ${formatErrorMessage(error2)}
267322
- `));
267323
- process.exit(1);
267372
+ handleCommandError(jsonOutput, error2);
267324
267373
  }
267325
267374
  });
267326
267375
  }
@@ -267664,7 +267713,7 @@ function attachAccountCommands(root) {
267664
267713
  });
267665
267714
  }
267666
267715
  // package.json
267667
- var version5 = "0.5.2";
267716
+ var version5 = "0.6.0";
267668
267717
 
267669
267718
  // src/cli/commands/store.ts
267670
267719
  init_source();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@parity/dotns-cli",
3
3
  "module": "index.ts",
4
- "version": "0.5.5",
4
+ "version": "0.6.0",
5
5
  "type": "module",
6
6
  "packageManager": "bun@1.2.6",
7
7
  "files": [