@cogcoin/client 0.5.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.
- package/LICENSE +21 -0
- package/README.md +136 -0
- package/dist/app-paths.d.ts +38 -0
- package/dist/app-paths.js +121 -0
- package/dist/art/banner.txt +13 -0
- package/dist/art/scroll.txt +13 -0
- package/dist/art/train-car.txt +6 -0
- package/dist/art/train-smoke.txt +6 -0
- package/dist/art/train.txt +6 -0
- package/dist/bitcoind/bootstrap/chainstate.d.ts +4 -0
- package/dist/bitcoind/bootstrap/chainstate.js +13 -0
- package/dist/bitcoind/bootstrap/constants.d.ts +7 -0
- package/dist/bitcoind/bootstrap/constants.js +12 -0
- package/dist/bitcoind/bootstrap/controller.d.ts +29 -0
- package/dist/bitcoind/bootstrap/controller.js +101 -0
- package/dist/bitcoind/bootstrap/download.d.ts +2 -0
- package/dist/bitcoind/bootstrap/download.js +196 -0
- package/dist/bitcoind/bootstrap/headers.d.ts +13 -0
- package/dist/bitcoind/bootstrap/headers.js +61 -0
- package/dist/bitcoind/bootstrap/paths.d.ts +4 -0
- package/dist/bitcoind/bootstrap/paths.js +15 -0
- package/dist/bitcoind/bootstrap/snapshot-file.d.ts +7 -0
- package/dist/bitcoind/bootstrap/snapshot-file.js +42 -0
- package/dist/bitcoind/bootstrap/state.d.ts +40 -0
- package/dist/bitcoind/bootstrap/state.js +70 -0
- package/dist/bitcoind/bootstrap/types.d.ts +28 -0
- package/dist/bitcoind/bootstrap/types.js +1 -0
- package/dist/bitcoind/bootstrap.d.ts +8 -0
- package/dist/bitcoind/bootstrap.js +7 -0
- package/dist/bitcoind/client/factory.d.ts +3 -0
- package/dist/bitcoind/client/factory.js +57 -0
- package/dist/bitcoind/client/follow-block-times.d.ts +8 -0
- package/dist/bitcoind/client/follow-block-times.js +25 -0
- package/dist/bitcoind/client/follow-loop.d.ts +10 -0
- package/dist/bitcoind/client/follow-loop.js +57 -0
- package/dist/bitcoind/client/internal-types.d.ts +63 -0
- package/dist/bitcoind/client/internal-types.js +18 -0
- package/dist/bitcoind/client/managed-client.d.ts +20 -0
- package/dist/bitcoind/client/managed-client.js +197 -0
- package/dist/bitcoind/client/rate-tracker.d.ts +2 -0
- package/dist/bitcoind/client/rate-tracker.js +24 -0
- package/dist/bitcoind/client/sync-engine.d.ts +3 -0
- package/dist/bitcoind/client/sync-engine.js +143 -0
- package/dist/bitcoind/client.d.ts +1 -0
- package/dist/bitcoind/client.js +1 -0
- package/dist/bitcoind/errors.d.ts +1 -0
- package/dist/bitcoind/errors.js +49 -0
- package/dist/bitcoind/index.d.ts +2 -0
- package/dist/bitcoind/index.js +1 -0
- package/dist/bitcoind/indexer-daemon-main.d.ts +1 -0
- package/dist/bitcoind/indexer-daemon-main.js +472 -0
- package/dist/bitcoind/indexer-daemon.d.ts +107 -0
- package/dist/bitcoind/indexer-daemon.js +391 -0
- package/dist/bitcoind/node.d.ts +8 -0
- package/dist/bitcoind/node.js +219 -0
- package/dist/bitcoind/normalize.d.ts +3 -0
- package/dist/bitcoind/normalize.js +47 -0
- package/dist/bitcoind/progress/assets.d.ts +10 -0
- package/dist/bitcoind/progress/assets.js +90 -0
- package/dist/bitcoind/progress/constants.d.ts +48 -0
- package/dist/bitcoind/progress/constants.js +53 -0
- package/dist/bitcoind/progress/controller.d.ts +28 -0
- package/dist/bitcoind/progress/controller.js +188 -0
- package/dist/bitcoind/progress/follow-scene.d.ts +40 -0
- package/dist/bitcoind/progress/follow-scene.js +367 -0
- package/dist/bitcoind/progress/formatting.d.ts +23 -0
- package/dist/bitcoind/progress/formatting.js +227 -0
- package/dist/bitcoind/progress/quote-scene.d.ts +4 -0
- package/dist/bitcoind/progress/quote-scene.js +137 -0
- package/dist/bitcoind/progress/train-scene.d.ts +9 -0
- package/dist/bitcoind/progress/train-scene.js +92 -0
- package/dist/bitcoind/progress/tty-renderer.d.ts +18 -0
- package/dist/bitcoind/progress/tty-renderer.js +150 -0
- package/dist/bitcoind/progress.d.ts +7 -0
- package/dist/bitcoind/progress.js +7 -0
- package/dist/bitcoind/quotes.d.ts +24 -0
- package/dist/bitcoind/quotes.js +195 -0
- package/dist/bitcoind/rpc.d.ts +71 -0
- package/dist/bitcoind/rpc.js +322 -0
- package/dist/bitcoind/service-paths.d.ts +19 -0
- package/dist/bitcoind/service-paths.js +49 -0
- package/dist/bitcoind/service.d.ts +40 -0
- package/dist/bitcoind/service.js +735 -0
- package/dist/bitcoind/testing.d.ts +9 -0
- package/dist/bitcoind/testing.js +9 -0
- package/dist/bitcoind/types.d.ts +396 -0
- package/dist/bitcoind/types.js +3 -0
- package/dist/bytes.d.ts +9 -0
- package/dist/bytes.js +36 -0
- package/dist/cli/commands/follow.d.ts +2 -0
- package/dist/cli/commands/follow.js +43 -0
- package/dist/cli/commands/mining-admin.d.ts +2 -0
- package/dist/cli/commands/mining-admin.js +92 -0
- package/dist/cli/commands/mining-read.d.ts +2 -0
- package/dist/cli/commands/mining-read.js +173 -0
- package/dist/cli/commands/mining-runtime.d.ts +2 -0
- package/dist/cli/commands/mining-runtime.js +108 -0
- package/dist/cli/commands/status.d.ts +2 -0
- package/dist/cli/commands/status.js +31 -0
- package/dist/cli/commands/sync.d.ts +2 -0
- package/dist/cli/commands/sync.js +52 -0
- package/dist/cli/commands/wallet-admin.d.ts +2 -0
- package/dist/cli/commands/wallet-admin.js +175 -0
- package/dist/cli/commands/wallet-mutation.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation.js +681 -0
- package/dist/cli/commands/wallet-read.d.ts +2 -0
- package/dist/cli/commands/wallet-read.js +265 -0
- package/dist/cli/context.d.ts +3 -0
- package/dist/cli/context.js +75 -0
- package/dist/cli/io.d.ts +3 -0
- package/dist/cli/io.js +12 -0
- package/dist/cli/mining-format.d.ts +5 -0
- package/dist/cli/mining-format.js +156 -0
- package/dist/cli/mining-json.d.ts +49 -0
- package/dist/cli/mining-json.js +89 -0
- package/dist/cli/mutation-command-groups.d.ts +15 -0
- package/dist/cli/mutation-command-groups.js +71 -0
- package/dist/cli/mutation-json.d.ts +430 -0
- package/dist/cli/mutation-json.js +311 -0
- package/dist/cli/mutation-resolved-json.d.ts +124 -0
- package/dist/cli/mutation-resolved-json.js +129 -0
- package/dist/cli/mutation-success.d.ts +20 -0
- package/dist/cli/mutation-success.js +47 -0
- package/dist/cli/mutation-text-format.d.ts +22 -0
- package/dist/cli/mutation-text-format.js +171 -0
- package/dist/cli/mutation-text-write.d.ts +13 -0
- package/dist/cli/mutation-text-write.js +16 -0
- package/dist/cli/output.d.ts +185 -0
- package/dist/cli/output.js +1085 -0
- package/dist/cli/parse.d.ts +3 -0
- package/dist/cli/parse.js +971 -0
- package/dist/cli/preview-json.d.ts +416 -0
- package/dist/cli/preview-json.js +293 -0
- package/dist/cli/prompt.d.ts +3 -0
- package/dist/cli/prompt.js +33 -0
- package/dist/cli/read-json.d.ts +187 -0
- package/dist/cli/read-json.js +675 -0
- package/dist/cli/runner.d.ts +2 -0
- package/dist/cli/runner.js +129 -0
- package/dist/cli/signals.d.ts +3 -0
- package/dist/cli/signals.js +63 -0
- package/dist/cli/status-format.d.ts +2 -0
- package/dist/cli/status-format.js +48 -0
- package/dist/cli/types.d.ts +148 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/wallet-format.d.ts +29 -0
- package/dist/cli/wallet-format.js +637 -0
- package/dist/cli/workflow-hints.d.ts +13 -0
- package/dist/cli/workflow-hints.js +94 -0
- package/dist/cli-runner.d.ts +3 -0
- package/dist/cli-runner.js +3 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +6 -0
- package/dist/client/default-client.d.ts +11 -0
- package/dist/client/default-client.js +118 -0
- package/dist/client/factory.d.ts +2 -0
- package/dist/client/factory.js +15 -0
- package/dist/client/initialization.d.ts +6 -0
- package/dist/client/initialization.js +30 -0
- package/dist/client/persistence.d.ts +5 -0
- package/dist/client/persistence.js +28 -0
- package/dist/client/store-adapter.d.ts +3 -0
- package/dist/client/store-adapter.js +20 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/passive-status.d.ts +36 -0
- package/dist/passive-status.js +100 -0
- package/dist/sqlite/better-sqlite3.d.ts +26 -0
- package/dist/sqlite/better-sqlite3.js +4 -0
- package/dist/sqlite/checkpoints.d.ts +11 -0
- package/dist/sqlite/checkpoints.js +27 -0
- package/dist/sqlite/driver.d.ts +17 -0
- package/dist/sqlite/driver.js +98 -0
- package/dist/sqlite/index.d.ts +4 -0
- package/dist/sqlite/index.js +9 -0
- package/dist/sqlite/migrate.d.ts +2 -0
- package/dist/sqlite/migrate.js +37 -0
- package/dist/sqlite/store.d.ts +3 -0
- package/dist/sqlite/store.js +122 -0
- package/dist/sqlite/tip-meta.d.ts +26 -0
- package/dist/sqlite/tip-meta.js +97 -0
- package/dist/sqlite/types.d.ts +10 -0
- package/dist/sqlite/types.js +1 -0
- package/dist/types.d.ts +55 -0
- package/dist/types.js +1 -0
- package/dist/wallet/archive.d.ts +4 -0
- package/dist/wallet/archive.js +39 -0
- package/dist/wallet/cogop/constants.d.ts +32 -0
- package/dist/wallet/cogop/constants.js +32 -0
- package/dist/wallet/cogop/index.d.ts +32 -0
- package/dist/wallet/cogop/index.js +213 -0
- package/dist/wallet/cogop/numeric.d.ts +3 -0
- package/dist/wallet/cogop/numeric.js +24 -0
- package/dist/wallet/cogop/scriptpubkey.d.ts +2 -0
- package/dist/wallet/cogop/scriptpubkey.js +13 -0
- package/dist/wallet/cogop/validate-name.d.ts +2 -0
- package/dist/wallet/cogop/validate-name.js +18 -0
- package/dist/wallet/fs/atomic.d.ts +6 -0
- package/dist/wallet/fs/atomic.js +46 -0
- package/dist/wallet/fs/lock.d.ts +19 -0
- package/dist/wallet/fs/lock.js +61 -0
- package/dist/wallet/fs/status-file.d.ts +1 -0
- package/dist/wallet/fs/status-file.js +4 -0
- package/dist/wallet/lifecycle.d.ts +193 -0
- package/dist/wallet/lifecycle.js +1475 -0
- package/dist/wallet/material.d.ts +45 -0
- package/dist/wallet/material.js +118 -0
- package/dist/wallet/mining/config.d.ts +18 -0
- package/dist/wallet/mining/config.js +44 -0
- package/dist/wallet/mining/constants.d.ts +24 -0
- package/dist/wallet/mining/constants.js +24 -0
- package/dist/wallet/mining/control.d.ts +53 -0
- package/dist/wallet/mining/control.js +758 -0
- package/dist/wallet/mining/coordination.d.ts +40 -0
- package/dist/wallet/mining/coordination.js +121 -0
- package/dist/wallet/mining/hook-protocol.d.ts +47 -0
- package/dist/wallet/mining/hook-protocol.js +161 -0
- package/dist/wallet/mining/hook-runner.d.ts +1 -0
- package/dist/wallet/mining/hook-runner.js +52 -0
- package/dist/wallet/mining/hooks.d.ts +38 -0
- package/dist/wallet/mining/hooks.js +520 -0
- package/dist/wallet/mining/index.d.ts +8 -0
- package/dist/wallet/mining/index.js +6 -0
- package/dist/wallet/mining/runner.d.ts +155 -0
- package/dist/wallet/mining/runner.js +2574 -0
- package/dist/wallet/mining/runtime-artifacts.d.ts +17 -0
- package/dist/wallet/mining/runtime-artifacts.js +166 -0
- package/dist/wallet/mining/sentences.d.ts +23 -0
- package/dist/wallet/mining/sentences.js +281 -0
- package/dist/wallet/mining/state.d.ts +9 -0
- package/dist/wallet/mining/state.js +75 -0
- package/dist/wallet/mining/types.d.ts +141 -0
- package/dist/wallet/mining/types.js +1 -0
- package/dist/wallet/mining/visualizer.d.ts +19 -0
- package/dist/wallet/mining/visualizer.js +134 -0
- package/dist/wallet/mining/worker-main.d.ts +1 -0
- package/dist/wallet/mining/worker-main.js +17 -0
- package/dist/wallet/read/context.d.ts +20 -0
- package/dist/wallet/read/context.js +532 -0
- package/dist/wallet/read/filter.d.ts +9 -0
- package/dist/wallet/read/filter.js +42 -0
- package/dist/wallet/read/index.d.ts +4 -0
- package/dist/wallet/read/index.js +3 -0
- package/dist/wallet/read/project.d.ts +11 -0
- package/dist/wallet/read/project.js +300 -0
- package/dist/wallet/read/types.d.ts +144 -0
- package/dist/wallet/read/types.js +1 -0
- package/dist/wallet/runtime.d.ts +26 -0
- package/dist/wallet/runtime.js +28 -0
- package/dist/wallet/state/crypto.d.ts +31 -0
- package/dist/wallet/state/crypto.js +127 -0
- package/dist/wallet/state/provider.d.ts +37 -0
- package/dist/wallet/state/provider.js +312 -0
- package/dist/wallet/state/session.d.ts +12 -0
- package/dist/wallet/state/session.js +23 -0
- package/dist/wallet/state/storage.d.ts +19 -0
- package/dist/wallet/state/storage.js +55 -0
- package/dist/wallet/tx/anchor.d.ts +40 -0
- package/dist/wallet/tx/anchor.js +1210 -0
- package/dist/wallet/tx/cog.d.ts +92 -0
- package/dist/wallet/tx/cog.js +1055 -0
- package/dist/wallet/tx/common.d.ts +89 -0
- package/dist/wallet/tx/common.js +156 -0
- package/dist/wallet/tx/confirm.d.ts +15 -0
- package/dist/wallet/tx/confirm.js +24 -0
- package/dist/wallet/tx/domain-admin.d.ts +105 -0
- package/dist/wallet/tx/domain-admin.js +869 -0
- package/dist/wallet/tx/domain-market.d.ts +112 -0
- package/dist/wallet/tx/domain-market.js +1365 -0
- package/dist/wallet/tx/field.d.ts +101 -0
- package/dist/wallet/tx/field.js +1853 -0
- package/dist/wallet/tx/identity-selector.d.ts +12 -0
- package/dist/wallet/tx/identity-selector.js +52 -0
- package/dist/wallet/tx/index.d.ts +7 -0
- package/dist/wallet/tx/index.js +7 -0
- package/dist/wallet/tx/journal.d.ts +5 -0
- package/dist/wallet/tx/journal.js +31 -0
- package/dist/wallet/tx/register.d.ts +68 -0
- package/dist/wallet/tx/register.js +952 -0
- package/dist/wallet/tx/reputation.d.ts +72 -0
- package/dist/wallet/tx/reputation.js +693 -0
- package/dist/wallet/tx/targets.d.ts +7 -0
- package/dist/wallet/tx/targets.js +122 -0
- package/dist/wallet/types.d.ts +249 -0
- package/dist/wallet/types.js +1 -0
- package/dist/writing_quotes.json +1654 -0
- package/package.json +78 -0
|
@@ -0,0 +1,681 @@
|
|
|
1
|
+
import { parseCogAmountToCogtoshi, } from "../../wallet/tx/index.js";
|
|
2
|
+
import { buildAnchorMutationData, buildCogMutationData, buildDomainAdminMutationData, buildDomainMarketMutationData, buildFieldMutationData, buildRegisterMutationData, buildReputationMutationData, } from "../mutation-json.js";
|
|
3
|
+
import { buildAnchorPreviewData, buildCogPreviewData, buildDomainAdminPreviewData, buildDomainMarketPreviewData, buildFieldPreviewData, buildRegisterPreviewData, buildReputationPreviewData, } from "../preview-json.js";
|
|
4
|
+
import { isAnchorMutationCommand, isBuyMutationCommand, isClaimMutationCommand, isReclaimMutationCommand, isRegisterMutationCommand, isReputationMutationCommand, isSellOrUnsellMutationCommand, isSendMutationCommand, isTransferMutationCommand, isUnsellMutationCommand, isWalletMutationCommand, } from "../mutation-command-groups.js";
|
|
5
|
+
import { commandMutationNextSteps, workflowMutationNextSteps, writeMutationCommandSuccess, } from "../mutation-success.js";
|
|
6
|
+
import { writeLine } from "../io.js";
|
|
7
|
+
import { formatBuyBuyerSummary, formatBuySellerSummary, formatBuySettlementSummary, formatCogClaimPath, formatCogSenderSummary, formatDomainAdminEffect, formatDomainAdminPayloadSummary, formatDomainAdminSenderSummary, formatDomainAdminTargetSummary, formatDomainMarketEconomicEffect, formatDomainMarketRecipientSummary, formatDomainMarketSenderSummary, formatFieldEffect, formatFieldPath, formatFieldSenderSummary, formatFieldValueSummary, formatRegisterEconomicEffect, formatRegisterSenderSummary, formatReputationEffect, formatReputationReviewSummary, formatReputationSenderSummary, } from "../mutation-text-format.js";
|
|
8
|
+
import { createTerminalPrompter } from "../prompt.js";
|
|
9
|
+
import { writeHandledCliError } from "../output.js";
|
|
10
|
+
import { getAnchorNextSteps, getRegisterNextSteps, } from "../workflow-hints.js";
|
|
11
|
+
function createFieldValueSource(parsed) {
|
|
12
|
+
if (parsed.endpointText !== null) {
|
|
13
|
+
return { kind: "text", value: parsed.endpointText };
|
|
14
|
+
}
|
|
15
|
+
if (parsed.endpointJson !== null) {
|
|
16
|
+
return { kind: "json", value: parsed.endpointJson };
|
|
17
|
+
}
|
|
18
|
+
if (parsed.endpointBytes !== null) {
|
|
19
|
+
return { kind: "bytes", value: parsed.endpointBytes };
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
kind: "raw",
|
|
23
|
+
format: parsed.fieldFormat,
|
|
24
|
+
value: parsed.fieldValue,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function createCommandPrompter(parsed, context) {
|
|
28
|
+
return parsed.outputMode !== "text"
|
|
29
|
+
? createTerminalPrompter(context.stdin, context.stderr)
|
|
30
|
+
: context.createPrompter();
|
|
31
|
+
}
|
|
32
|
+
export async function runWalletMutationCommand(parsed, context) {
|
|
33
|
+
try {
|
|
34
|
+
if (!isWalletMutationCommand(parsed.command)) {
|
|
35
|
+
writeLine(context.stderr, `wallet mutation command not implemented: ${parsed.command}`);
|
|
36
|
+
return 1;
|
|
37
|
+
}
|
|
38
|
+
const dataDir = parsed.dataDir ?? context.resolveDefaultBitcoindDataDir();
|
|
39
|
+
const dbPath = parsed.dbPath ?? context.resolveDefaultClientDatabasePath();
|
|
40
|
+
const prompter = createCommandPrompter(parsed, context);
|
|
41
|
+
if (isAnchorMutationCommand(parsed.command)) {
|
|
42
|
+
const result = await context.anchorDomain({
|
|
43
|
+
domainName: parsed.args[0],
|
|
44
|
+
foundingMessageText: parsed.anchorMessage,
|
|
45
|
+
dataDir,
|
|
46
|
+
databasePath: dbPath,
|
|
47
|
+
provider: context.walletSecretProvider,
|
|
48
|
+
prompter,
|
|
49
|
+
});
|
|
50
|
+
const nextSteps = getAnchorNextSteps(result.domainName);
|
|
51
|
+
return writeMutationCommandSuccess(parsed, context, {
|
|
52
|
+
data: buildAnchorMutationData(result, {
|
|
53
|
+
foundingMessageText: parsed.anchorMessage,
|
|
54
|
+
}),
|
|
55
|
+
previewData: buildAnchorPreviewData(result, {
|
|
56
|
+
foundingMessageText: parsed.anchorMessage,
|
|
57
|
+
}),
|
|
58
|
+
reusedExisting: result.reusedExisting,
|
|
59
|
+
reusedMessage: "The existing anchor family was reconciled instead of creating a duplicate.",
|
|
60
|
+
nextSteps: workflowMutationNextSteps(nextSteps),
|
|
61
|
+
text: {
|
|
62
|
+
heading: "Anchor family submitted.",
|
|
63
|
+
fields: [
|
|
64
|
+
{ label: "Domain", value: result.domainName },
|
|
65
|
+
{ label: "Dedicated index", value: String(result.dedicatedIndex) },
|
|
66
|
+
{ label: "Status", value: result.status },
|
|
67
|
+
{ label: "Tx1", value: result.tx1Txid },
|
|
68
|
+
{ label: "Tx2", value: result.tx2Txid },
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (isRegisterMutationCommand(parsed.command)) {
|
|
74
|
+
const result = await context.registerDomain({
|
|
75
|
+
domainName: parsed.args[0],
|
|
76
|
+
dataDir,
|
|
77
|
+
databasePath: dbPath,
|
|
78
|
+
forceRace: parsed.forceRace,
|
|
79
|
+
fromIdentity: parsed.fromIdentity,
|
|
80
|
+
provider: context.walletSecretProvider,
|
|
81
|
+
prompter,
|
|
82
|
+
assumeYes: parsed.assumeYes,
|
|
83
|
+
});
|
|
84
|
+
const nextSteps = getRegisterNextSteps(result.domainName, result.registerKind);
|
|
85
|
+
return writeMutationCommandSuccess(parsed, context, {
|
|
86
|
+
data: buildRegisterMutationData(result, {
|
|
87
|
+
forceRace: parsed.forceRace,
|
|
88
|
+
fromIdentity: parsed.fromIdentity,
|
|
89
|
+
}),
|
|
90
|
+
previewData: buildRegisterPreviewData(result, {
|
|
91
|
+
forceRace: parsed.forceRace,
|
|
92
|
+
fromIdentity: parsed.fromIdentity,
|
|
93
|
+
}),
|
|
94
|
+
reusedExisting: result.reusedExisting,
|
|
95
|
+
reusedMessage: "The existing pending registration was reconciled instead of creating a duplicate.",
|
|
96
|
+
nextSteps: workflowMutationNextSteps(nextSteps),
|
|
97
|
+
text: {
|
|
98
|
+
heading: "Registration submitted.",
|
|
99
|
+
fields: [
|
|
100
|
+
{ label: "Domain", value: result.domainName },
|
|
101
|
+
{ label: "Path", value: result.resolved.path },
|
|
102
|
+
{ label: "Parent", value: result.resolved.parentDomainName ?? "", when: result.resolved.parentDomainName !== null },
|
|
103
|
+
{ label: "Sender", value: formatRegisterSenderSummary(result) },
|
|
104
|
+
{ label: "Economic effect", value: formatRegisterEconomicEffect(result) },
|
|
105
|
+
{ label: "Status", value: result.status },
|
|
106
|
+
{ label: "Txid", value: result.txid },
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (isTransferMutationCommand(parsed.command)) {
|
|
112
|
+
const result = await context.transferDomain({
|
|
113
|
+
domainName: parsed.args[0],
|
|
114
|
+
target: parsed.transferTarget,
|
|
115
|
+
dataDir,
|
|
116
|
+
databasePath: dbPath,
|
|
117
|
+
provider: context.walletSecretProvider,
|
|
118
|
+
prompter,
|
|
119
|
+
assumeYes: parsed.assumeYes,
|
|
120
|
+
});
|
|
121
|
+
return writeMutationCommandSuccess(parsed, context, {
|
|
122
|
+
data: buildDomainMarketMutationData(result, {
|
|
123
|
+
commandKind: "transfer",
|
|
124
|
+
}),
|
|
125
|
+
previewData: buildDomainMarketPreviewData(result, {
|
|
126
|
+
commandKind: "transfer",
|
|
127
|
+
}),
|
|
128
|
+
reusedExisting: result.reusedExisting,
|
|
129
|
+
reusedMessage: "The existing pending transfer was reconciled instead of creating a duplicate.",
|
|
130
|
+
nextSteps: commandMutationNextSteps(`cogcoin show ${result.domainName}`),
|
|
131
|
+
text: {
|
|
132
|
+
heading: "Transfer submitted.",
|
|
133
|
+
fields: [
|
|
134
|
+
{ label: "Domain", value: result.domainName },
|
|
135
|
+
{ label: "Sender", value: formatDomainMarketSenderSummary(result) },
|
|
136
|
+
{ label: "Recipient", value: formatDomainMarketRecipientSummary(result) },
|
|
137
|
+
{ label: "Economic effect", value: formatDomainMarketEconomicEffect(result) },
|
|
138
|
+
{ label: "Status", value: result.status },
|
|
139
|
+
{ label: "Txid", value: result.txid },
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
if (isSellOrUnsellMutationCommand(parsed.command)) {
|
|
145
|
+
const listedPriceCogtoshi = isUnsellMutationCommand(parsed.command)
|
|
146
|
+
? 0n
|
|
147
|
+
: parseCogAmountToCogtoshi(parsed.args[1]);
|
|
148
|
+
const result = await context.sellDomain({
|
|
149
|
+
domainName: parsed.args[0],
|
|
150
|
+
listedPriceCogtoshi,
|
|
151
|
+
dataDir,
|
|
152
|
+
databasePath: dbPath,
|
|
153
|
+
provider: context.walletSecretProvider,
|
|
154
|
+
prompter,
|
|
155
|
+
assumeYes: parsed.assumeYes,
|
|
156
|
+
});
|
|
157
|
+
return writeMutationCommandSuccess(parsed, context, {
|
|
158
|
+
data: buildDomainMarketMutationData(result, {
|
|
159
|
+
commandKind: result.listedPriceCogtoshi === 0n ? "unsell" : "sell",
|
|
160
|
+
}),
|
|
161
|
+
previewData: buildDomainMarketPreviewData(result, {
|
|
162
|
+
commandKind: result.listedPriceCogtoshi === 0n ? "unsell" : "sell",
|
|
163
|
+
}),
|
|
164
|
+
reusedExisting: result.reusedExisting,
|
|
165
|
+
reusedMessage: "The existing pending listing mutation was reconciled instead of creating a duplicate.",
|
|
166
|
+
nextSteps: commandMutationNextSteps(`cogcoin show ${result.domainName}`),
|
|
167
|
+
text: {
|
|
168
|
+
heading: result.listedPriceCogtoshi === 0n ? "Listing cancellation submitted." : "Listing submitted.",
|
|
169
|
+
fields: [
|
|
170
|
+
{ label: "Domain", value: result.domainName },
|
|
171
|
+
{ label: "Sender", value: formatDomainMarketSenderSummary(result) },
|
|
172
|
+
{ label: "Price", value: `${result.listedPriceCogtoshi?.toString() ?? "0"} cogtoshi` },
|
|
173
|
+
{ label: "Economic effect", value: formatDomainMarketEconomicEffect(result) },
|
|
174
|
+
{ label: "Status", value: result.status },
|
|
175
|
+
{ label: "Txid", value: result.txid },
|
|
176
|
+
],
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
if (parsed.command === "domain-endpoint-set" || parsed.command === "domain-endpoint-clear") {
|
|
181
|
+
const result = parsed.command === "domain-endpoint-set"
|
|
182
|
+
? await context.setDomainEndpoint({
|
|
183
|
+
domainName: parsed.args[0],
|
|
184
|
+
source: parsed.endpointText !== null
|
|
185
|
+
? { kind: "text", value: parsed.endpointText }
|
|
186
|
+
: parsed.endpointJson !== null
|
|
187
|
+
? { kind: "json", value: parsed.endpointJson }
|
|
188
|
+
: { kind: "bytes", value: parsed.endpointBytes },
|
|
189
|
+
dataDir,
|
|
190
|
+
databasePath: dbPath,
|
|
191
|
+
provider: context.walletSecretProvider,
|
|
192
|
+
prompter,
|
|
193
|
+
assumeYes: parsed.assumeYes,
|
|
194
|
+
})
|
|
195
|
+
: await context.clearDomainEndpoint({
|
|
196
|
+
domainName: parsed.args[0],
|
|
197
|
+
dataDir,
|
|
198
|
+
databasePath: dbPath,
|
|
199
|
+
provider: context.walletSecretProvider,
|
|
200
|
+
prompter,
|
|
201
|
+
assumeYes: parsed.assumeYes,
|
|
202
|
+
});
|
|
203
|
+
return writeMutationCommandSuccess(parsed, context, {
|
|
204
|
+
data: buildDomainAdminMutationData(result, {
|
|
205
|
+
commandKind: parsed.command,
|
|
206
|
+
}),
|
|
207
|
+
previewData: buildDomainAdminPreviewData(result, {
|
|
208
|
+
commandKind: parsed.command,
|
|
209
|
+
}),
|
|
210
|
+
reusedExisting: result.reusedExisting,
|
|
211
|
+
reusedMessage: "The existing pending endpoint mutation was reconciled instead of creating a duplicate.",
|
|
212
|
+
nextSteps: commandMutationNextSteps(`cogcoin show ${result.domainName}`),
|
|
213
|
+
text: {
|
|
214
|
+
heading: parsed.command === "domain-endpoint-set" ? "Endpoint update submitted." : "Endpoint clear submitted.",
|
|
215
|
+
fields: [
|
|
216
|
+
{ label: "Domain", value: result.domainName },
|
|
217
|
+
{ label: "Sender", value: formatDomainAdminSenderSummary(result) },
|
|
218
|
+
{ label: "Payload", value: formatDomainAdminPayloadSummary(result) },
|
|
219
|
+
{ label: "Effect", value: formatDomainAdminEffect(result) },
|
|
220
|
+
{ label: "Status", value: result.status },
|
|
221
|
+
{ label: "Txid", value: result.txid },
|
|
222
|
+
],
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
if (parsed.command === "domain-delegate-set" || parsed.command === "domain-delegate-clear") {
|
|
227
|
+
const result = parsed.command === "domain-delegate-set"
|
|
228
|
+
? await context.setDomainDelegate({
|
|
229
|
+
domainName: parsed.args[0],
|
|
230
|
+
target: parsed.args[1],
|
|
231
|
+
dataDir,
|
|
232
|
+
databasePath: dbPath,
|
|
233
|
+
provider: context.walletSecretProvider,
|
|
234
|
+
prompter,
|
|
235
|
+
assumeYes: parsed.assumeYes,
|
|
236
|
+
})
|
|
237
|
+
: await context.clearDomainDelegate({
|
|
238
|
+
domainName: parsed.args[0],
|
|
239
|
+
dataDir,
|
|
240
|
+
databasePath: dbPath,
|
|
241
|
+
provider: context.walletSecretProvider,
|
|
242
|
+
prompter,
|
|
243
|
+
assumeYes: parsed.assumeYes,
|
|
244
|
+
});
|
|
245
|
+
return writeMutationCommandSuccess(parsed, context, {
|
|
246
|
+
data: buildDomainAdminMutationData(result, {
|
|
247
|
+
commandKind: parsed.command,
|
|
248
|
+
}),
|
|
249
|
+
previewData: buildDomainAdminPreviewData(result, {
|
|
250
|
+
commandKind: parsed.command,
|
|
251
|
+
}),
|
|
252
|
+
reusedExisting: result.reusedExisting,
|
|
253
|
+
reusedMessage: "The existing pending delegate mutation was reconciled instead of creating a duplicate.",
|
|
254
|
+
nextSteps: commandMutationNextSteps(`cogcoin show ${result.domainName}`),
|
|
255
|
+
text: {
|
|
256
|
+
heading: parsed.command === "domain-delegate-set" ? "Delegate update submitted." : "Delegate clear submitted.",
|
|
257
|
+
fields: [
|
|
258
|
+
{ label: "Domain", value: result.domainName },
|
|
259
|
+
{ label: "Sender", value: formatDomainAdminSenderSummary(result) },
|
|
260
|
+
{ label: "Target", value: formatDomainAdminTargetSummary(result) },
|
|
261
|
+
{ label: "Effect", value: formatDomainAdminEffect(result) },
|
|
262
|
+
{ label: "Status", value: result.status },
|
|
263
|
+
{ label: "Txid", value: result.txid },
|
|
264
|
+
],
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
if (parsed.command === "domain-miner-set" || parsed.command === "domain-miner-clear") {
|
|
269
|
+
const result = parsed.command === "domain-miner-set"
|
|
270
|
+
? await context.setDomainMiner({
|
|
271
|
+
domainName: parsed.args[0],
|
|
272
|
+
target: parsed.args[1],
|
|
273
|
+
dataDir,
|
|
274
|
+
databasePath: dbPath,
|
|
275
|
+
provider: context.walletSecretProvider,
|
|
276
|
+
prompter,
|
|
277
|
+
assumeYes: parsed.assumeYes,
|
|
278
|
+
})
|
|
279
|
+
: await context.clearDomainMiner({
|
|
280
|
+
domainName: parsed.args[0],
|
|
281
|
+
dataDir,
|
|
282
|
+
databasePath: dbPath,
|
|
283
|
+
provider: context.walletSecretProvider,
|
|
284
|
+
prompter,
|
|
285
|
+
assumeYes: parsed.assumeYes,
|
|
286
|
+
});
|
|
287
|
+
return writeMutationCommandSuccess(parsed, context, {
|
|
288
|
+
data: buildDomainAdminMutationData(result, {
|
|
289
|
+
commandKind: parsed.command,
|
|
290
|
+
}),
|
|
291
|
+
previewData: buildDomainAdminPreviewData(result, {
|
|
292
|
+
commandKind: parsed.command,
|
|
293
|
+
}),
|
|
294
|
+
reusedExisting: result.reusedExisting,
|
|
295
|
+
reusedMessage: "The existing pending miner mutation was reconciled instead of creating a duplicate.",
|
|
296
|
+
nextSteps: commandMutationNextSteps(`cogcoin show ${result.domainName}`),
|
|
297
|
+
text: {
|
|
298
|
+
heading: parsed.command === "domain-miner-set" ? "Miner update submitted." : "Miner clear submitted.",
|
|
299
|
+
fields: [
|
|
300
|
+
{ label: "Domain", value: result.domainName },
|
|
301
|
+
{ label: "Sender", value: formatDomainAdminSenderSummary(result) },
|
|
302
|
+
{ label: "Target", value: formatDomainAdminTargetSummary(result) },
|
|
303
|
+
{ label: "Effect", value: formatDomainAdminEffect(result) },
|
|
304
|
+
{ label: "Status", value: result.status },
|
|
305
|
+
{ label: "Txid", value: result.txid },
|
|
306
|
+
],
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
if (parsed.command === "domain-canonical") {
|
|
311
|
+
const result = await context.setDomainCanonical({
|
|
312
|
+
domainName: parsed.args[0],
|
|
313
|
+
dataDir,
|
|
314
|
+
databasePath: dbPath,
|
|
315
|
+
provider: context.walletSecretProvider,
|
|
316
|
+
prompter,
|
|
317
|
+
assumeYes: parsed.assumeYes,
|
|
318
|
+
});
|
|
319
|
+
return writeMutationCommandSuccess(parsed, context, {
|
|
320
|
+
data: buildDomainAdminMutationData(result, {
|
|
321
|
+
commandKind: "domain-canonical",
|
|
322
|
+
}),
|
|
323
|
+
previewData: buildDomainAdminPreviewData(result, {
|
|
324
|
+
commandKind: "domain-canonical",
|
|
325
|
+
}),
|
|
326
|
+
reusedExisting: result.reusedExisting,
|
|
327
|
+
reusedMessage: "The existing pending canonical mutation was reconciled instead of creating a duplicate.",
|
|
328
|
+
nextSteps: commandMutationNextSteps(`cogcoin show ${result.domainName}`),
|
|
329
|
+
text: {
|
|
330
|
+
heading: "Canonical update submitted.",
|
|
331
|
+
fields: [
|
|
332
|
+
{ label: "Domain", value: result.domainName },
|
|
333
|
+
{ label: "Sender", value: formatDomainAdminSenderSummary(result) },
|
|
334
|
+
{ label: "Effect", value: formatDomainAdminEffect(result) },
|
|
335
|
+
{ label: "Status", value: result.status },
|
|
336
|
+
{ label: "Txid", value: result.txid },
|
|
337
|
+
],
|
|
338
|
+
},
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
if (parsed.command === "field-create") {
|
|
342
|
+
const result = await context.createField({
|
|
343
|
+
domainName: parsed.args[0],
|
|
344
|
+
fieldName: parsed.args[1],
|
|
345
|
+
permanent: parsed.fieldPermanent,
|
|
346
|
+
source: (parsed.endpointText !== null
|
|
347
|
+
|| parsed.endpointJson !== null
|
|
348
|
+
|| parsed.endpointBytes !== null
|
|
349
|
+
|| parsed.fieldFormat !== null)
|
|
350
|
+
? createFieldValueSource(parsed)
|
|
351
|
+
: null,
|
|
352
|
+
dataDir,
|
|
353
|
+
databasePath: dbPath,
|
|
354
|
+
provider: context.walletSecretProvider,
|
|
355
|
+
prompter,
|
|
356
|
+
assumeYes: parsed.assumeYes,
|
|
357
|
+
});
|
|
358
|
+
return writeMutationCommandSuccess(parsed, context, {
|
|
359
|
+
data: buildFieldMutationData(result),
|
|
360
|
+
previewData: buildFieldPreviewData(result),
|
|
361
|
+
reusedExisting: result.reusedExisting,
|
|
362
|
+
reusedMessage: result.family
|
|
363
|
+
? "The existing pending field family was reconciled instead of creating a duplicate."
|
|
364
|
+
: "The existing pending field creation was reconciled instead of creating a duplicate.",
|
|
365
|
+
nextSteps: commandMutationNextSteps(`cogcoin field show ${result.domainName} ${result.fieldName}`),
|
|
366
|
+
text: {
|
|
367
|
+
heading: result.family ? "Field create+write family submitted." : "Field creation submitted.",
|
|
368
|
+
fields: [
|
|
369
|
+
{ label: "Domain", value: result.domainName },
|
|
370
|
+
{ label: "Field", value: result.fieldName },
|
|
371
|
+
{ label: "Sender", value: formatFieldSenderSummary(result) },
|
|
372
|
+
{ label: "Path", value: formatFieldPath(result) },
|
|
373
|
+
{ label: "Value", value: formatFieldValueSummary(result), when: result.resolved?.value !== null && result.resolved?.value !== undefined },
|
|
374
|
+
{ label: "Effect", value: formatFieldEffect(result) },
|
|
375
|
+
{ label: "Status", value: result.status },
|
|
376
|
+
{ label: "Tx1", value: result.tx1Txid ?? "unknown", when: result.family },
|
|
377
|
+
{ label: "Tx2", value: result.tx2Txid ?? "unknown", when: result.family },
|
|
378
|
+
{ label: "Txid", value: result.txid, when: !result.family },
|
|
379
|
+
],
|
|
380
|
+
},
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
if (parsed.command === "field-set") {
|
|
384
|
+
const result = await context.setField({
|
|
385
|
+
domainName: parsed.args[0],
|
|
386
|
+
fieldName: parsed.args[1],
|
|
387
|
+
source: createFieldValueSource(parsed),
|
|
388
|
+
dataDir,
|
|
389
|
+
databasePath: dbPath,
|
|
390
|
+
provider: context.walletSecretProvider,
|
|
391
|
+
prompter,
|
|
392
|
+
assumeYes: parsed.assumeYes,
|
|
393
|
+
});
|
|
394
|
+
return writeMutationCommandSuccess(parsed, context, {
|
|
395
|
+
data: buildFieldMutationData(result),
|
|
396
|
+
previewData: buildFieldPreviewData(result),
|
|
397
|
+
reusedExisting: result.reusedExisting,
|
|
398
|
+
reusedMessage: "The existing pending field update was reconciled instead of creating a duplicate.",
|
|
399
|
+
nextSteps: commandMutationNextSteps(`cogcoin field show ${result.domainName} ${result.fieldName}`),
|
|
400
|
+
text: {
|
|
401
|
+
heading: "Field update submitted.",
|
|
402
|
+
fields: [
|
|
403
|
+
{ label: "Domain", value: result.domainName },
|
|
404
|
+
{ label: "Field", value: result.fieldName },
|
|
405
|
+
{ label: "Sender", value: formatFieldSenderSummary(result) },
|
|
406
|
+
{ label: "Value", value: formatFieldValueSummary(result) },
|
|
407
|
+
{ label: "Effect", value: formatFieldEffect(result) },
|
|
408
|
+
{ label: "Status", value: result.status },
|
|
409
|
+
{ label: "Txid", value: result.txid },
|
|
410
|
+
],
|
|
411
|
+
},
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
if (parsed.command === "field-clear") {
|
|
415
|
+
const result = await context.clearField({
|
|
416
|
+
domainName: parsed.args[0],
|
|
417
|
+
fieldName: parsed.args[1],
|
|
418
|
+
dataDir,
|
|
419
|
+
databasePath: dbPath,
|
|
420
|
+
provider: context.walletSecretProvider,
|
|
421
|
+
prompter,
|
|
422
|
+
assumeYes: parsed.assumeYes,
|
|
423
|
+
});
|
|
424
|
+
return writeMutationCommandSuccess(parsed, context, {
|
|
425
|
+
data: buildFieldMutationData(result),
|
|
426
|
+
previewData: buildFieldPreviewData(result),
|
|
427
|
+
reusedExisting: result.reusedExisting,
|
|
428
|
+
reusedMessage: "The existing pending field clear was reconciled instead of creating a duplicate.",
|
|
429
|
+
nextSteps: commandMutationNextSteps(`cogcoin field show ${result.domainName} ${result.fieldName}`),
|
|
430
|
+
text: {
|
|
431
|
+
heading: "Field clear submitted.",
|
|
432
|
+
fields: [
|
|
433
|
+
{ label: "Domain", value: result.domainName },
|
|
434
|
+
{ label: "Field", value: result.fieldName },
|
|
435
|
+
{ label: "Sender", value: formatFieldSenderSummary(result) },
|
|
436
|
+
{ label: "Effect", value: formatFieldEffect(result) },
|
|
437
|
+
{ label: "Status", value: result.status },
|
|
438
|
+
{ label: "Txid", value: result.txid },
|
|
439
|
+
],
|
|
440
|
+
},
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
if (isSendMutationCommand(parsed.command)) {
|
|
444
|
+
const result = await context.sendCog({
|
|
445
|
+
amountCogtoshi: parseCogAmountToCogtoshi(parsed.args[0]),
|
|
446
|
+
target: parsed.transferTarget,
|
|
447
|
+
fromIdentity: parsed.fromIdentity,
|
|
448
|
+
dataDir,
|
|
449
|
+
databasePath: dbPath,
|
|
450
|
+
provider: context.walletSecretProvider,
|
|
451
|
+
prompter,
|
|
452
|
+
assumeYes: parsed.assumeYes,
|
|
453
|
+
});
|
|
454
|
+
return writeMutationCommandSuccess(parsed, context, {
|
|
455
|
+
data: buildCogMutationData(result, {
|
|
456
|
+
commandKind: "send",
|
|
457
|
+
fromIdentity: parsed.fromIdentity,
|
|
458
|
+
}),
|
|
459
|
+
previewData: buildCogPreviewData(result, {
|
|
460
|
+
commandKind: "send",
|
|
461
|
+
fromIdentity: parsed.fromIdentity,
|
|
462
|
+
}),
|
|
463
|
+
reusedExisting: result.reusedExisting,
|
|
464
|
+
reusedMessage: "The existing pending COG transfer was reconciled instead of creating a duplicate.",
|
|
465
|
+
nextSteps: commandMutationNextSteps("cogcoin balance"),
|
|
466
|
+
text: {
|
|
467
|
+
heading: "COG transfer submitted.",
|
|
468
|
+
fields: [
|
|
469
|
+
{ label: "Sender", value: formatCogSenderSummary(result) },
|
|
470
|
+
{ label: "Amount", value: `${result.amountCogtoshi?.toString() ?? "unknown"} cogtoshi` },
|
|
471
|
+
{ label: "Recipient", value: result.recipientScriptPubKeyHex === null || result.recipientScriptPubKeyHex === undefined ? "unknown" : `spk:${result.recipientScriptPubKeyHex}` },
|
|
472
|
+
{ label: "Status", value: result.status },
|
|
473
|
+
{ label: "Txid", value: result.txid },
|
|
474
|
+
],
|
|
475
|
+
},
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
if (parsed.command === "cog-lock") {
|
|
479
|
+
const result = await context.lockCogToDomain({
|
|
480
|
+
amountCogtoshi: parseCogAmountToCogtoshi(parsed.args[0]),
|
|
481
|
+
recipientDomainName: parsed.lockRecipientDomain,
|
|
482
|
+
fromIdentity: parsed.fromIdentity,
|
|
483
|
+
timeoutBlocksOrDuration: parsed.unlockFor,
|
|
484
|
+
timeoutHeight: parsed.untilHeight === null ? null : Number.parseInt(parsed.untilHeight, 10),
|
|
485
|
+
conditionHex: parsed.conditionHex,
|
|
486
|
+
dataDir,
|
|
487
|
+
databasePath: dbPath,
|
|
488
|
+
provider: context.walletSecretProvider,
|
|
489
|
+
prompter,
|
|
490
|
+
assumeYes: parsed.assumeYes,
|
|
491
|
+
});
|
|
492
|
+
return writeMutationCommandSuccess(parsed, context, {
|
|
493
|
+
data: buildCogMutationData(result, {
|
|
494
|
+
commandKind: "cog-lock",
|
|
495
|
+
fromIdentity: parsed.fromIdentity,
|
|
496
|
+
timeoutBlocksOrDuration: parsed.unlockFor,
|
|
497
|
+
timeoutHeight: parsed.untilHeight,
|
|
498
|
+
conditionHex: parsed.conditionHex,
|
|
499
|
+
}),
|
|
500
|
+
previewData: buildCogPreviewData(result, {
|
|
501
|
+
commandKind: "cog-lock",
|
|
502
|
+
fromIdentity: parsed.fromIdentity,
|
|
503
|
+
timeoutBlocksOrDuration: parsed.unlockFor,
|
|
504
|
+
timeoutHeight: parsed.untilHeight,
|
|
505
|
+
conditionHex: parsed.conditionHex,
|
|
506
|
+
}),
|
|
507
|
+
reusedExisting: result.reusedExisting,
|
|
508
|
+
reusedMessage: "The existing pending lock was reconciled instead of creating a duplicate.",
|
|
509
|
+
nextSteps: commandMutationNextSteps("cogcoin locks"),
|
|
510
|
+
text: {
|
|
511
|
+
heading: "COG lock submitted.",
|
|
512
|
+
fields: [
|
|
513
|
+
{ label: "Sender", value: formatCogSenderSummary(result) },
|
|
514
|
+
{ label: "Amount", value: `${result.amountCogtoshi?.toString() ?? "unknown"} cogtoshi` },
|
|
515
|
+
{ label: "Recipient domain", value: result.recipientDomainName ?? "unknown" },
|
|
516
|
+
{ label: "Status", value: result.status },
|
|
517
|
+
{ label: "Txid", value: result.txid },
|
|
518
|
+
],
|
|
519
|
+
},
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
if (isClaimMutationCommand(parsed.command)) {
|
|
523
|
+
const result = await context.claimCogLock({
|
|
524
|
+
lockId: Number.parseInt(parsed.args[0], 10),
|
|
525
|
+
preimageHex: parsed.preimageHex,
|
|
526
|
+
dataDir,
|
|
527
|
+
databasePath: dbPath,
|
|
528
|
+
provider: context.walletSecretProvider,
|
|
529
|
+
prompter,
|
|
530
|
+
});
|
|
531
|
+
return writeMutationCommandSuccess(parsed, context, {
|
|
532
|
+
data: buildCogMutationData(result, {
|
|
533
|
+
commandKind: "claim",
|
|
534
|
+
fromIdentity: null,
|
|
535
|
+
}),
|
|
536
|
+
previewData: buildCogPreviewData(result, {
|
|
537
|
+
commandKind: "claim",
|
|
538
|
+
fromIdentity: null,
|
|
539
|
+
}),
|
|
540
|
+
reusedExisting: result.reusedExisting,
|
|
541
|
+
reusedMessage: "The existing pending claim was reconciled instead of creating a duplicate.",
|
|
542
|
+
nextSteps: commandMutationNextSteps("cogcoin locks --claimable"),
|
|
543
|
+
text: {
|
|
544
|
+
heading: "Lock claim submitted.",
|
|
545
|
+
fields: [
|
|
546
|
+
{ label: "Lock", value: String(result.lockId ?? "unknown") },
|
|
547
|
+
{ label: "Path", value: formatCogClaimPath(result) },
|
|
548
|
+
{ label: "Sender", value: formatCogSenderSummary(result) },
|
|
549
|
+
{ label: "Amount", value: `${result.amountCogtoshi?.toString() ?? "unknown"} cogtoshi` },
|
|
550
|
+
{ label: "Status", value: result.status },
|
|
551
|
+
{ label: "Txid", value: result.txid },
|
|
552
|
+
],
|
|
553
|
+
},
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
if (isReclaimMutationCommand(parsed.command)) {
|
|
557
|
+
const result = await context.reclaimCogLock({
|
|
558
|
+
lockId: Number.parseInt(parsed.args[0], 10),
|
|
559
|
+
dataDir,
|
|
560
|
+
databasePath: dbPath,
|
|
561
|
+
provider: context.walletSecretProvider,
|
|
562
|
+
prompter,
|
|
563
|
+
});
|
|
564
|
+
return writeMutationCommandSuccess(parsed, context, {
|
|
565
|
+
data: buildCogMutationData(result, {
|
|
566
|
+
commandKind: "reclaim",
|
|
567
|
+
fromIdentity: null,
|
|
568
|
+
}),
|
|
569
|
+
previewData: buildCogPreviewData(result, {
|
|
570
|
+
commandKind: "reclaim",
|
|
571
|
+
fromIdentity: null,
|
|
572
|
+
}),
|
|
573
|
+
reusedExisting: result.reusedExisting,
|
|
574
|
+
reusedMessage: "The existing pending reclaim was reconciled instead of creating a duplicate.",
|
|
575
|
+
nextSteps: commandMutationNextSteps("cogcoin locks --reclaimable"),
|
|
576
|
+
text: {
|
|
577
|
+
heading: "Lock reclaim submitted.",
|
|
578
|
+
fields: [
|
|
579
|
+
{ label: "Lock", value: String(result.lockId ?? "unknown") },
|
|
580
|
+
{ label: "Path", value: formatCogClaimPath(result) },
|
|
581
|
+
{ label: "Sender", value: formatCogSenderSummary(result) },
|
|
582
|
+
{ label: "Amount", value: `${result.amountCogtoshi?.toString() ?? "unknown"} cogtoshi` },
|
|
583
|
+
{ label: "Status", value: result.status },
|
|
584
|
+
{ label: "Txid", value: result.txid },
|
|
585
|
+
],
|
|
586
|
+
},
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
if (isReputationMutationCommand(parsed.command)) {
|
|
590
|
+
const result = parsed.command === "rep-give"
|
|
591
|
+
? await context.giveReputation({
|
|
592
|
+
sourceDomainName: parsed.args[0],
|
|
593
|
+
targetDomainName: parsed.args[1],
|
|
594
|
+
amountCogtoshi: parseCogAmountToCogtoshi(parsed.args[2]),
|
|
595
|
+
reviewText: parsed.reviewText,
|
|
596
|
+
dataDir,
|
|
597
|
+
databasePath: dbPath,
|
|
598
|
+
provider: context.walletSecretProvider,
|
|
599
|
+
prompter,
|
|
600
|
+
assumeYes: parsed.assumeYes,
|
|
601
|
+
})
|
|
602
|
+
: await context.revokeReputation({
|
|
603
|
+
sourceDomainName: parsed.args[0],
|
|
604
|
+
targetDomainName: parsed.args[1],
|
|
605
|
+
amountCogtoshi: parseCogAmountToCogtoshi(parsed.args[2]),
|
|
606
|
+
reviewText: parsed.reviewText,
|
|
607
|
+
dataDir,
|
|
608
|
+
databasePath: dbPath,
|
|
609
|
+
provider: context.walletSecretProvider,
|
|
610
|
+
prompter,
|
|
611
|
+
assumeYes: parsed.assumeYes,
|
|
612
|
+
});
|
|
613
|
+
return writeMutationCommandSuccess(parsed, context, {
|
|
614
|
+
data: buildReputationMutationData(result),
|
|
615
|
+
previewData: buildReputationPreviewData(result),
|
|
616
|
+
reusedExisting: result.reusedExisting,
|
|
617
|
+
reusedMessage: "The existing pending reputation mutation was reconciled instead of creating a duplicate.",
|
|
618
|
+
nextSteps: commandMutationNextSteps(`cogcoin show ${result.targetDomainName}`),
|
|
619
|
+
text: {
|
|
620
|
+
heading: parsed.command === "rep-give" ? "Reputation support submitted." : "Reputation revoke submitted.",
|
|
621
|
+
fields: [
|
|
622
|
+
{ label: "Source domain", value: result.sourceDomainName },
|
|
623
|
+
{ label: "Target domain", value: result.targetDomainName },
|
|
624
|
+
{ label: "Sender", value: formatReputationSenderSummary(result) },
|
|
625
|
+
{ label: "Amount", value: `${result.amountCogtoshi.toString()} cogtoshi` },
|
|
626
|
+
{ label: "Review", value: formatReputationReviewSummary(result) },
|
|
627
|
+
{ label: "Effect", value: formatReputationEffect(result) },
|
|
628
|
+
{ label: "Status", value: result.status },
|
|
629
|
+
{ label: "Txid", value: result.txid },
|
|
630
|
+
],
|
|
631
|
+
},
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
if (isBuyMutationCommand(parsed.command)) {
|
|
635
|
+
const result = await context.buyDomain({
|
|
636
|
+
domainName: parsed.args[0],
|
|
637
|
+
fromIdentity: parsed.fromIdentity,
|
|
638
|
+
dataDir,
|
|
639
|
+
databasePath: dbPath,
|
|
640
|
+
provider: context.walletSecretProvider,
|
|
641
|
+
prompter,
|
|
642
|
+
assumeYes: parsed.assumeYes,
|
|
643
|
+
});
|
|
644
|
+
return writeMutationCommandSuccess(parsed, context, {
|
|
645
|
+
data: buildDomainMarketMutationData(result, {
|
|
646
|
+
commandKind: "buy",
|
|
647
|
+
fromIdentity: parsed.fromIdentity,
|
|
648
|
+
}),
|
|
649
|
+
previewData: buildDomainMarketPreviewData(result, {
|
|
650
|
+
commandKind: "buy",
|
|
651
|
+
fromIdentity: parsed.fromIdentity,
|
|
652
|
+
}),
|
|
653
|
+
reusedExisting: result.reusedExisting,
|
|
654
|
+
reusedMessage: "The existing pending purchase was reconciled instead of creating a duplicate.",
|
|
655
|
+
nextSteps: commandMutationNextSteps(`cogcoin show ${result.domainName}`),
|
|
656
|
+
text: {
|
|
657
|
+
heading: "Purchase submitted.",
|
|
658
|
+
fields: [
|
|
659
|
+
{ label: "Domain", value: result.domainName },
|
|
660
|
+
{ label: "Buyer", value: formatBuyBuyerSummary(result) },
|
|
661
|
+
{ label: "Seller", value: formatBuySellerSummary(result) },
|
|
662
|
+
{ label: "Price", value: `${result.listedPriceCogtoshi?.toString() ?? "unknown"} cogtoshi` },
|
|
663
|
+
{ label: "Settlement", value: formatBuySettlementSummary() },
|
|
664
|
+
{ label: "Status", value: result.status },
|
|
665
|
+
{ label: "Txid", value: result.txid },
|
|
666
|
+
],
|
|
667
|
+
},
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
writeLine(context.stderr, `wallet mutation command not implemented: ${parsed.command}`);
|
|
671
|
+
return 1;
|
|
672
|
+
}
|
|
673
|
+
catch (error) {
|
|
674
|
+
return writeHandledCliError({
|
|
675
|
+
parsed,
|
|
676
|
+
stdout: context.stdout,
|
|
677
|
+
stderr: context.stderr,
|
|
678
|
+
error,
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
}
|