@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,171 @@
|
|
|
1
|
+
import { formatCogAmount } from "../wallet/tx/common.js";
|
|
2
|
+
export function formatRegisterSenderSummary(result) {
|
|
3
|
+
return `${result.resolved.sender.selector} (${result.resolved.sender.address})`;
|
|
4
|
+
}
|
|
5
|
+
export function formatRegisterEconomicEffect(result) {
|
|
6
|
+
if (result.resolved.economicEffect.kind === "treasury-payment") {
|
|
7
|
+
return `send ${result.resolved.economicEffect.amount.toString()} sats to the Cogcoin treasury`;
|
|
8
|
+
}
|
|
9
|
+
return `burn ${formatCogAmount(result.resolved.economicEffect.amount)} from the parent-owner identity`;
|
|
10
|
+
}
|
|
11
|
+
export function formatBuyBuyerSummary(result) {
|
|
12
|
+
if (result.resolvedBuyer === null || result.resolvedBuyer === undefined) {
|
|
13
|
+
return "unknown";
|
|
14
|
+
}
|
|
15
|
+
return `${result.resolvedBuyer.selector} (${result.resolvedBuyer.address})`;
|
|
16
|
+
}
|
|
17
|
+
export function formatBuySellerSummary(result) {
|
|
18
|
+
if (result.resolvedSeller === null || result.resolvedSeller === undefined) {
|
|
19
|
+
return "unknown";
|
|
20
|
+
}
|
|
21
|
+
return result.resolvedSeller.address ?? `spk:${result.resolvedSeller.scriptPubKeyHex}`;
|
|
22
|
+
}
|
|
23
|
+
export function formatBuySettlementSummary() {
|
|
24
|
+
return "entirely in COG state; no BTC seller output";
|
|
25
|
+
}
|
|
26
|
+
export function formatDomainMarketSenderSummary(result) {
|
|
27
|
+
if (result.resolved === null || result.resolved === undefined) {
|
|
28
|
+
return "unknown";
|
|
29
|
+
}
|
|
30
|
+
return `${result.resolved.sender.selector} (${result.resolved.sender.address})`;
|
|
31
|
+
}
|
|
32
|
+
export function formatDomainMarketRecipientSummary(result) {
|
|
33
|
+
const recipient = result.resolved?.recipient;
|
|
34
|
+
if (recipient !== null && recipient !== undefined) {
|
|
35
|
+
return recipient.address ?? `spk:${recipient.scriptPubKeyHex}`;
|
|
36
|
+
}
|
|
37
|
+
if (result.recipientScriptPubKeyHex === null || result.recipientScriptPubKeyHex === undefined) {
|
|
38
|
+
return "unknown";
|
|
39
|
+
}
|
|
40
|
+
return `spk:${result.recipientScriptPubKeyHex}`;
|
|
41
|
+
}
|
|
42
|
+
export function formatDomainMarketEconomicEffect(result) {
|
|
43
|
+
const economicEffect = result.resolved?.economicEffect;
|
|
44
|
+
if (economicEffect === null || economicEffect === undefined) {
|
|
45
|
+
return "unknown";
|
|
46
|
+
}
|
|
47
|
+
if (economicEffect.kind === "ownership-transfer") {
|
|
48
|
+
return economicEffect.clearsListing
|
|
49
|
+
? "transfer domain ownership and clear any active listing"
|
|
50
|
+
: "transfer domain ownership";
|
|
51
|
+
}
|
|
52
|
+
if (economicEffect.kind === "listing-set") {
|
|
53
|
+
return `set the listing price to ${economicEffect.listedPriceCogtoshi} cogtoshi in COG state`;
|
|
54
|
+
}
|
|
55
|
+
return "clear the active listing in COG state";
|
|
56
|
+
}
|
|
57
|
+
export function formatDomainAdminSenderSummary(result) {
|
|
58
|
+
if (result.resolved === null || result.resolved === undefined) {
|
|
59
|
+
return "unknown";
|
|
60
|
+
}
|
|
61
|
+
return `${result.resolved.sender.selector} (${result.resolved.sender.address})`;
|
|
62
|
+
}
|
|
63
|
+
export function formatDomainAdminTargetSummary(result) {
|
|
64
|
+
if (result.resolved?.target !== null && result.resolved?.target !== undefined) {
|
|
65
|
+
return result.resolved.target.address ?? `spk:${result.resolved.target.scriptPubKeyHex}`;
|
|
66
|
+
}
|
|
67
|
+
if (result.recipientScriptPubKeyHex === null) {
|
|
68
|
+
return "clear";
|
|
69
|
+
}
|
|
70
|
+
if (result.recipientScriptPubKeyHex === undefined) {
|
|
71
|
+
return "none";
|
|
72
|
+
}
|
|
73
|
+
return `spk:${result.recipientScriptPubKeyHex}`;
|
|
74
|
+
}
|
|
75
|
+
export function formatDomainAdminEffect(result) {
|
|
76
|
+
const effect = result.resolved?.effect;
|
|
77
|
+
if (effect === null || effect === undefined) {
|
|
78
|
+
return "unknown";
|
|
79
|
+
}
|
|
80
|
+
switch (effect.kind) {
|
|
81
|
+
case "endpoint-set":
|
|
82
|
+
return `set the endpoint payload to ${effect.byteLength} bytes`;
|
|
83
|
+
case "endpoint-clear":
|
|
84
|
+
return "clear the endpoint payload";
|
|
85
|
+
case "delegate-set":
|
|
86
|
+
return "set the delegate target";
|
|
87
|
+
case "delegate-clear":
|
|
88
|
+
return "clear the delegate target";
|
|
89
|
+
case "miner-set":
|
|
90
|
+
return "set the designated miner target";
|
|
91
|
+
case "miner-clear":
|
|
92
|
+
return "clear the designated miner target";
|
|
93
|
+
case "canonicalize-owner":
|
|
94
|
+
return "canonicalize the current anchored owner";
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export function formatDomainAdminPayloadSummary(result) {
|
|
98
|
+
const effect = result.resolved?.effect;
|
|
99
|
+
if (effect?.kind === "endpoint-set") {
|
|
100
|
+
return `${effect.byteLength} bytes`;
|
|
101
|
+
}
|
|
102
|
+
if (effect?.kind === "endpoint-clear") {
|
|
103
|
+
return "clear";
|
|
104
|
+
}
|
|
105
|
+
if (result.endpointValueHex === null || result.endpointValueHex === undefined) {
|
|
106
|
+
return "none";
|
|
107
|
+
}
|
|
108
|
+
return result.endpointValueHex === "" ? "clear" : `${result.endpointValueHex.length / 2} bytes`;
|
|
109
|
+
}
|
|
110
|
+
export function formatFieldSenderSummary(result) {
|
|
111
|
+
if (result.resolved === null || result.resolved === undefined) {
|
|
112
|
+
return "unknown";
|
|
113
|
+
}
|
|
114
|
+
return `${result.resolved.sender.selector} (${result.resolved.sender.address})`;
|
|
115
|
+
}
|
|
116
|
+
export function formatFieldPath(result) {
|
|
117
|
+
return result.resolved?.path ?? "unknown";
|
|
118
|
+
}
|
|
119
|
+
export function formatFieldValueSummary(result) {
|
|
120
|
+
if (result.resolved?.value !== null && result.resolved?.value !== undefined) {
|
|
121
|
+
return `format ${result.resolved.value.format}, ${result.resolved.value.byteLength} bytes`;
|
|
122
|
+
}
|
|
123
|
+
return "none";
|
|
124
|
+
}
|
|
125
|
+
export function formatFieldEffect(result) {
|
|
126
|
+
const effect = result.resolved?.effect;
|
|
127
|
+
if (effect === null || effect === undefined) {
|
|
128
|
+
return "unknown";
|
|
129
|
+
}
|
|
130
|
+
switch (effect.kind) {
|
|
131
|
+
case "create-empty-field":
|
|
132
|
+
return `burn ${effect.burnCogtoshi} cogtoshi to create an empty field`;
|
|
133
|
+
case "create-and-initialize-field":
|
|
134
|
+
return `burn ${effect.tx1BurnCogtoshi} cogtoshi in Tx1 and ${effect.tx2AdditionalBurnCogtoshi} additional cogtoshi in Tx2`;
|
|
135
|
+
case "write-field-value":
|
|
136
|
+
return `burn ${effect.burnCogtoshi} cogtoshi to write the field value`;
|
|
137
|
+
case "clear-field-value":
|
|
138
|
+
return "clear the field value with no additional COG burn";
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export function formatCogSenderSummary(result) {
|
|
142
|
+
return `${result.resolved.sender.selector} (${result.resolved.sender.address})`;
|
|
143
|
+
}
|
|
144
|
+
export function formatCogClaimPath(result) {
|
|
145
|
+
return result.resolved.claimPath ?? "unknown";
|
|
146
|
+
}
|
|
147
|
+
export function formatReputationSenderSummary(result) {
|
|
148
|
+
if (result.resolved === null || result.resolved === undefined) {
|
|
149
|
+
return "unknown";
|
|
150
|
+
}
|
|
151
|
+
return `${result.resolved.sender.selector} (${result.resolved.sender.address})`;
|
|
152
|
+
}
|
|
153
|
+
export function formatReputationReviewSummary(result) {
|
|
154
|
+
if (result.resolved === null || result.resolved === undefined) {
|
|
155
|
+
return result.reviewIncluded ? "included" : "none";
|
|
156
|
+
}
|
|
157
|
+
if (!result.resolved.review.included || result.resolved.review.byteLength === null) {
|
|
158
|
+
return "none";
|
|
159
|
+
}
|
|
160
|
+
return `included (${result.resolved.review.byteLength} bytes)`;
|
|
161
|
+
}
|
|
162
|
+
export function formatReputationEffect(result) {
|
|
163
|
+
const effect = result.resolved?.effect;
|
|
164
|
+
if (effect === null || effect === undefined) {
|
|
165
|
+
return "unknown";
|
|
166
|
+
}
|
|
167
|
+
if (effect.kind === "give-support") {
|
|
168
|
+
return `burn ${effect.burnCogtoshi} cogtoshi to publish support`;
|
|
169
|
+
}
|
|
170
|
+
return `revoke visible support with no refund of the previously burned ${effect.burnCogtoshi} cogtoshi`;
|
|
171
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { WritableLike } from "./types.js";
|
|
2
|
+
export interface MutationTextField {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
when?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function writeMutationTextResult(stream: WritableLike, options: {
|
|
8
|
+
heading: string;
|
|
9
|
+
fields: MutationTextField[];
|
|
10
|
+
reusedExisting?: boolean;
|
|
11
|
+
reusedMessage?: string;
|
|
12
|
+
trailerLines?: string[];
|
|
13
|
+
}): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { writeLine } from "./io.js";
|
|
2
|
+
export function writeMutationTextResult(stream, options) {
|
|
3
|
+
writeLine(stream, options.heading);
|
|
4
|
+
for (const field of options.fields) {
|
|
5
|
+
if (field.when === false) {
|
|
6
|
+
continue;
|
|
7
|
+
}
|
|
8
|
+
writeLine(stream, `${field.label}: ${field.value}`);
|
|
9
|
+
}
|
|
10
|
+
if (options.reusedExisting === true && options.reusedMessage !== undefined) {
|
|
11
|
+
writeLine(stream, options.reusedMessage);
|
|
12
|
+
}
|
|
13
|
+
for (const line of options.trailerLines ?? []) {
|
|
14
|
+
writeLine(stream, line);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import type { CommandName, OutputMode, ParsedCliArgs, WritableLike } from "./types.js";
|
|
2
|
+
export interface JsonAvailabilityEntry {
|
|
3
|
+
available: boolean;
|
|
4
|
+
stale: boolean;
|
|
5
|
+
reason: string | null;
|
|
6
|
+
state?: string | null;
|
|
7
|
+
source?: string | null;
|
|
8
|
+
operatorValidationState?: string | null;
|
|
9
|
+
cooldownActive?: boolean | null;
|
|
10
|
+
publishState?: string | null;
|
|
11
|
+
replicaStatus?: string | null;
|
|
12
|
+
serviceApiVersion?: string | null;
|
|
13
|
+
binaryVersion?: string | null;
|
|
14
|
+
buildId?: string | null;
|
|
15
|
+
serviceInstanceId?: string | null;
|
|
16
|
+
processId?: number | null;
|
|
17
|
+
walletRootId?: string | null;
|
|
18
|
+
chain?: string | null;
|
|
19
|
+
dataDir?: string | null;
|
|
20
|
+
runtimeRoot?: string | null;
|
|
21
|
+
startedAtUnixMs?: number | null;
|
|
22
|
+
updatedAtUnixMs?: number | null;
|
|
23
|
+
schemaVersion?: string | null;
|
|
24
|
+
daemonInstanceId?: string | null;
|
|
25
|
+
snapshotSeq?: string | null;
|
|
26
|
+
heartbeatAtUnixMs?: number | null;
|
|
27
|
+
openedAtUnixMs?: number | null;
|
|
28
|
+
activeSnapshotCount?: number | null;
|
|
29
|
+
backlogBlocks?: number | null;
|
|
30
|
+
reorgDepth?: number | null;
|
|
31
|
+
lastError?: string | null;
|
|
32
|
+
appliedTipHeight?: number | null;
|
|
33
|
+
appliedTipHash?: string | null;
|
|
34
|
+
coreBestHeight?: number | null;
|
|
35
|
+
coreBestHash?: string | null;
|
|
36
|
+
}
|
|
37
|
+
export interface JsonPage {
|
|
38
|
+
limit: number | null;
|
|
39
|
+
returned: number;
|
|
40
|
+
truncated: boolean;
|
|
41
|
+
moreAvailable: boolean | null;
|
|
42
|
+
totalKnown: number | null;
|
|
43
|
+
}
|
|
44
|
+
export interface StableJsonEnvelopeBase {
|
|
45
|
+
schema: string;
|
|
46
|
+
command: string;
|
|
47
|
+
generatedAtUnixMs: number;
|
|
48
|
+
warnings: string[];
|
|
49
|
+
explanations: string[];
|
|
50
|
+
nextSteps: string[];
|
|
51
|
+
}
|
|
52
|
+
export interface StableJsonSuccessEnvelope<T> extends StableJsonEnvelopeBase {
|
|
53
|
+
ok: true;
|
|
54
|
+
data: T;
|
|
55
|
+
}
|
|
56
|
+
export interface StableJsonErrorEnvelope extends StableJsonEnvelopeBase {
|
|
57
|
+
ok: false;
|
|
58
|
+
error: {
|
|
59
|
+
code: string;
|
|
60
|
+
message: string;
|
|
61
|
+
details: Record<string, unknown>;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export interface MutationJsonEnvelopeBase {
|
|
65
|
+
schema: string;
|
|
66
|
+
ok: boolean;
|
|
67
|
+
command: string;
|
|
68
|
+
generatedAtUnixMs: number;
|
|
69
|
+
outcome: string;
|
|
70
|
+
warnings: string[];
|
|
71
|
+
explanations: string[];
|
|
72
|
+
nextSteps: string[];
|
|
73
|
+
}
|
|
74
|
+
export interface MutationJsonSuccessEnvelope<T> extends MutationJsonEnvelopeBase {
|
|
75
|
+
ok: true;
|
|
76
|
+
data: T;
|
|
77
|
+
}
|
|
78
|
+
export interface MutationJsonErrorEnvelope extends MutationJsonEnvelopeBase {
|
|
79
|
+
ok: false;
|
|
80
|
+
error: {
|
|
81
|
+
code: string;
|
|
82
|
+
message: string;
|
|
83
|
+
details: Record<string, unknown>;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export interface PreviewJsonEnvelopeBase {
|
|
87
|
+
schema: string;
|
|
88
|
+
ok: boolean;
|
|
89
|
+
command: string;
|
|
90
|
+
generatedAtUnixMs: number;
|
|
91
|
+
outcome: string;
|
|
92
|
+
warnings: string[];
|
|
93
|
+
explanations: string[];
|
|
94
|
+
nextSteps: string[];
|
|
95
|
+
}
|
|
96
|
+
export interface PreviewJsonSuccessEnvelope<T> extends PreviewJsonEnvelopeBase {
|
|
97
|
+
ok: true;
|
|
98
|
+
data: T;
|
|
99
|
+
}
|
|
100
|
+
export interface PreviewJsonErrorEnvelope extends PreviewJsonEnvelopeBase {
|
|
101
|
+
ok: false;
|
|
102
|
+
error: {
|
|
103
|
+
code: string;
|
|
104
|
+
message: string;
|
|
105
|
+
details: Record<string, unknown>;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export declare function writeJsonValue(stream: WritableLike, value: unknown): void;
|
|
109
|
+
export declare function isStructuredOutputMode(mode: OutputMode): boolean;
|
|
110
|
+
export declare function createSuccessEnvelope<T>(schema: string, command: string, data: T, options?: {
|
|
111
|
+
warnings?: string[];
|
|
112
|
+
explanations?: string[];
|
|
113
|
+
nextSteps?: string[];
|
|
114
|
+
generatedAtUnixMs?: number;
|
|
115
|
+
}): StableJsonSuccessEnvelope<T>;
|
|
116
|
+
export declare function createErrorEnvelope(schema: string, command: string, errorCode: string, message: string, options?: {
|
|
117
|
+
warnings?: string[];
|
|
118
|
+
explanations?: string[];
|
|
119
|
+
nextSteps?: string[];
|
|
120
|
+
details?: Record<string, unknown>;
|
|
121
|
+
generatedAtUnixMs?: number;
|
|
122
|
+
}): StableJsonErrorEnvelope;
|
|
123
|
+
export declare function createPreviewSuccessEnvelope<T>(schema: string, command: string, outcome: string, data: T, options?: {
|
|
124
|
+
warnings?: string[];
|
|
125
|
+
explanations?: string[];
|
|
126
|
+
nextSteps?: string[];
|
|
127
|
+
generatedAtUnixMs?: number;
|
|
128
|
+
}): PreviewJsonSuccessEnvelope<T>;
|
|
129
|
+
export declare function createMutationSuccessEnvelope<T>(schema: string, command: string, outcome: string, data: T, options?: {
|
|
130
|
+
warnings?: string[];
|
|
131
|
+
explanations?: string[];
|
|
132
|
+
nextSteps?: string[];
|
|
133
|
+
generatedAtUnixMs?: number;
|
|
134
|
+
}): MutationJsonSuccessEnvelope<T>;
|
|
135
|
+
export declare function createPreviewErrorEnvelope(schema: string, command: string, errorCode: string, message: string, options?: {
|
|
136
|
+
outcome?: string;
|
|
137
|
+
warnings?: string[];
|
|
138
|
+
explanations?: string[];
|
|
139
|
+
nextSteps?: string[];
|
|
140
|
+
details?: Record<string, unknown>;
|
|
141
|
+
generatedAtUnixMs?: number;
|
|
142
|
+
}): PreviewJsonErrorEnvelope;
|
|
143
|
+
export declare function createMutationErrorEnvelope(schema: string, command: string, errorCode: string, message: string, options?: {
|
|
144
|
+
outcome?: string;
|
|
145
|
+
warnings?: string[];
|
|
146
|
+
explanations?: string[];
|
|
147
|
+
nextSteps?: string[];
|
|
148
|
+
details?: Record<string, unknown>;
|
|
149
|
+
generatedAtUnixMs?: number;
|
|
150
|
+
}): MutationJsonErrorEnvelope;
|
|
151
|
+
export declare function normalizeListPage<T>(items: readonly T[], options: {
|
|
152
|
+
limit: number | null;
|
|
153
|
+
all: boolean;
|
|
154
|
+
defaultLimit: number;
|
|
155
|
+
}): {
|
|
156
|
+
items: T[];
|
|
157
|
+
page: JsonPage;
|
|
158
|
+
};
|
|
159
|
+
export declare function createTruncationNote(page: JsonPage): string | null;
|
|
160
|
+
export declare function classifyCliError(error: unknown): {
|
|
161
|
+
exitCode: number;
|
|
162
|
+
errorCode: string;
|
|
163
|
+
message: string;
|
|
164
|
+
};
|
|
165
|
+
export declare function formatCliTextError(error: unknown): string[] | null;
|
|
166
|
+
export declare function createCliErrorPresentation(errorCode: string, fallbackMessage: string): {
|
|
167
|
+
what: string;
|
|
168
|
+
why: string | null;
|
|
169
|
+
next: string | null;
|
|
170
|
+
} | null;
|
|
171
|
+
export declare function describeCanonicalCommand(parsed: ParsedCliArgs): string;
|
|
172
|
+
export declare function inferOutputMode(argv: readonly string[]): OutputMode;
|
|
173
|
+
export declare function resolveStableJsonSchema(parsed: ParsedCliArgs): string | null;
|
|
174
|
+
export declare function resolveStableMutationJsonSchema(parsed: ParsedCliArgs): string | null;
|
|
175
|
+
export declare function resolveStableMiningControlJsonSchema(parsed: ParsedCliArgs): string | null;
|
|
176
|
+
export declare function resolvePreviewJsonSchema(parsed: ParsedCliArgs): string | null;
|
|
177
|
+
export declare function isJsonOutputSupportedCommand(command: CommandName | null): boolean;
|
|
178
|
+
export declare function isPreviewJsonOutputSupportedCommand(command: CommandName | null): boolean;
|
|
179
|
+
export declare function createCommandJsonErrorEnvelope(parsed: ParsedCliArgs, error: unknown): StableJsonErrorEnvelope | MutationJsonErrorEnvelope | PreviewJsonErrorEnvelope;
|
|
180
|
+
export declare function writeHandledCliError(options: {
|
|
181
|
+
parsed: ParsedCliArgs;
|
|
182
|
+
stdout: WritableLike;
|
|
183
|
+
stderr: WritableLike;
|
|
184
|
+
error: unknown;
|
|
185
|
+
}): number;
|