@cogcoin/client 1.1.7 → 1.1.9
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/README.md +1 -1
- package/dist/bitcoind/service.js +1 -1
- package/dist/cli/commands/mining-read.js +1 -1
- package/dist/cli/commands/wallet-mutation/anchor.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/anchor.js +33 -0
- package/dist/cli/commands/wallet-mutation/bitcoin-transfer.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/bitcoin-transfer.js +32 -0
- package/dist/cli/commands/wallet-mutation/cog.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/cog.js +131 -0
- package/dist/cli/commands/wallet-mutation/context.d.ts +3 -0
- package/dist/cli/commands/wallet-mutation/context.js +18 -0
- package/dist/cli/commands/wallet-mutation/domain-admin.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/domain-admin.js +173 -0
- package/dist/cli/commands/wallet-mutation/domain-market.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/domain-market.js +107 -0
- package/dist/cli/commands/wallet-mutation/field.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/field.js +125 -0
- package/dist/cli/commands/wallet-mutation/register.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/register.js +38 -0
- package/dist/cli/commands/wallet-mutation/registry.d.ts +3 -0
- package/dist/cli/commands/wallet-mutation/registry.js +39 -0
- package/dist/cli/commands/wallet-mutation/reputation.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/reputation.js +57 -0
- package/dist/cli/commands/wallet-mutation/types.d.ts +32 -0
- package/dist/cli/commands/wallet-mutation/types.js +1 -0
- package/dist/cli/commands/wallet-mutation.js +13 -765
- package/dist/cli/commands/wallet-read.js +4 -4
- package/dist/cli/mutation-success.d.ts +0 -2
- package/dist/cli/output/classify.d.ts +7 -0
- package/dist/cli/output/classify.js +94 -0
- package/dist/cli/output/render.d.ts +2 -0
- package/dist/cli/output/render.js +13 -0
- package/dist/cli/output/rules/cli-surface.d.ts +2 -0
- package/dist/cli/output/rules/cli-surface.js +110 -0
- package/dist/cli/output/rules/generic.d.ts +2 -0
- package/dist/cli/output/rules/generic.js +13 -0
- package/dist/cli/output/rules/index.d.ts +2 -0
- package/dist/cli/output/rules/index.js +24 -0
- package/dist/cli/output/rules/mining-update.d.ts +2 -0
- package/dist/cli/output/rules/mining-update.js +68 -0
- package/dist/cli/output/rules/services.d.ts +2 -0
- package/dist/cli/output/rules/services.js +110 -0
- package/dist/cli/output/rules/wallet-admin.d.ts +2 -0
- package/dist/cli/output/rules/wallet-admin.js +224 -0
- package/dist/cli/output/rules/wallet-mutations.d.ts +2 -0
- package/dist/cli/output/rules/wallet-mutations.js +274 -0
- package/dist/cli/output/types.d.ts +16 -0
- package/dist/cli/output/types.js +1 -0
- package/dist/cli/output.d.ts +2 -168
- package/dist/cli/output.js +6 -989
- package/dist/cli/pagination.d.ts +15 -0
- package/dist/cli/pagination.js +16 -0
- package/dist/cli/recommendations.d.ts +4 -0
- package/dist/cli/recommendations.js +108 -0
- package/dist/cli/wallet-format/availability.d.ts +5 -0
- package/dist/cli/wallet-format/availability.js +96 -0
- package/dist/cli/wallet-format/balance.d.ts +2 -0
- package/dist/cli/wallet-format/balance.js +162 -0
- package/dist/cli/wallet-format/domains.d.ts +8 -0
- package/dist/cli/wallet-format/domains.js +84 -0
- package/dist/cli/wallet-format/fields.d.ts +6 -0
- package/dist/cli/wallet-format/fields.js +61 -0
- package/dist/cli/wallet-format/identity.d.ts +5 -0
- package/dist/cli/wallet-format/identity.js +19 -0
- package/dist/cli/wallet-format/locks.d.ts +7 -0
- package/dist/cli/wallet-format/locks.js +52 -0
- package/dist/cli/wallet-format/overview.d.ts +2 -0
- package/dist/cli/wallet-format/overview.js +122 -0
- package/dist/cli/wallet-format/pending.d.ts +13 -0
- package/dist/cli/wallet-format/pending.js +101 -0
- package/dist/cli/wallet-format/shared.d.ts +7 -0
- package/dist/cli/wallet-format/shared.js +31 -0
- package/dist/cli/wallet-format/status.d.ts +3 -0
- package/dist/cli/wallet-format/status.js +27 -0
- package/dist/cli/wallet-format.d.ts +8 -30
- package/dist/cli/wallet-format.js +8 -830
- package/dist/cli/wallet-read-helpers.d.ts +6 -0
- package/dist/cli/wallet-read-helpers.js +17 -0
- package/dist/wallet/mining/candidate.d.ts +1 -1
- package/dist/wallet/mining/candidate.js +3 -3
- package/dist/wallet/mining/constants.d.ts +2 -2
- package/dist/wallet/mining/constants.js +2 -2
- package/dist/wallet/mining/engine-state.js +10 -0
- package/dist/wallet/mining/sentence-protocol.d.ts +2 -2
- package/dist/wallet/mining/sentences.js +8 -8
- package/dist/wallet/mining/visualizer-sync.js +79 -15
- package/dist/wallet/read/context.js +1 -1
- package/dist/wallet/reset/artifacts.d.ts +16 -0
- package/dist/wallet/reset/artifacts.js +141 -0
- package/dist/wallet/reset/execution.d.ts +38 -0
- package/dist/wallet/reset/execution.js +458 -0
- package/dist/wallet/reset/preflight.d.ts +7 -0
- package/dist/wallet/reset/preflight.js +116 -0
- package/dist/wallet/reset/preview.d.ts +2 -0
- package/dist/wallet/reset/preview.js +50 -0
- package/dist/wallet/reset/process-cleanup.d.ts +12 -0
- package/dist/wallet/reset/process-cleanup.js +179 -0
- package/dist/wallet/reset/types.d.ts +189 -0
- package/dist/wallet/reset/types.js +1 -0
- package/dist/wallet/reset.d.ts +4 -119
- package/dist/wallet/reset.js +4 -882
- package/dist/wallet/tx/anchor/confirm.d.ts +15 -0
- package/dist/wallet/tx/anchor/confirm.js +60 -0
- package/dist/wallet/tx/anchor/draft.d.ts +39 -0
- package/dist/wallet/tx/anchor/draft.js +167 -0
- package/dist/wallet/tx/anchor/index.d.ts +5 -0
- package/dist/wallet/tx/anchor/index.js +148 -0
- package/dist/wallet/tx/anchor/intent.d.ts +61 -0
- package/dist/wallet/tx/anchor/intent.js +101 -0
- package/dist/wallet/tx/anchor/plan.d.ts +3 -0
- package/dist/wallet/tx/anchor/plan.js +18 -0
- package/dist/wallet/tx/anchor/result.d.ts +25 -0
- package/dist/wallet/tx/anchor/result.js +20 -0
- package/dist/wallet/tx/anchor.d.ts +1 -39
- package/dist/wallet/tx/anchor.js +1 -494
- package/dist/wallet/tx/bitcoin-transfer/confirm.d.ts +7 -0
- package/dist/wallet/tx/bitcoin-transfer/confirm.js +11 -0
- package/dist/wallet/tx/bitcoin-transfer/index.d.ts +5 -0
- package/dist/wallet/tx/bitcoin-transfer/index.js +112 -0
- package/dist/wallet/tx/bitcoin-transfer/intent.d.ts +52 -0
- package/dist/wallet/tx/bitcoin-transfer/intent.js +74 -0
- package/dist/wallet/tx/bitcoin-transfer/plan.d.ts +5 -0
- package/dist/wallet/tx/bitcoin-transfer/plan.js +21 -0
- package/dist/wallet/tx/bitcoin-transfer/result.d.ts +19 -0
- package/dist/wallet/tx/bitcoin-transfer/result.js +16 -0
- package/dist/wallet/tx/bitcoin-transfer.d.ts +1 -35
- package/dist/wallet/tx/bitcoin-transfer.js +1 -200
- package/dist/wallet/tx/cog/confirm.d.ts +13 -0
- package/dist/wallet/tx/cog/confirm.js +59 -0
- package/dist/wallet/tx/cog/draft.d.ts +20 -0
- package/dist/wallet/tx/cog/draft.js +114 -0
- package/dist/wallet/tx/cog/index.d.ts +6 -0
- package/dist/wallet/tx/cog/index.js +117 -0
- package/dist/wallet/tx/cog/intent.d.ts +30 -0
- package/dist/wallet/tx/cog/intent.js +169 -0
- package/dist/wallet/tx/cog/plan.d.ts +19 -0
- package/dist/wallet/tx/cog/plan.js +65 -0
- package/dist/wallet/tx/cog/result.d.ts +27 -0
- package/dist/wallet/tx/cog/result.js +28 -0
- package/dist/wallet/tx/cog/types.d.ts +186 -0
- package/dist/wallet/tx/cog/types.js +2 -0
- package/dist/wallet/tx/cog/variants/claim.d.ts +3 -0
- package/dist/wallet/tx/cog/variants/claim.js +92 -0
- package/dist/wallet/tx/cog/variants/lock.d.ts +2 -0
- package/dist/wallet/tx/cog/variants/lock.js +102 -0
- package/dist/wallet/tx/cog/variants/send.d.ts +2 -0
- package/dist/wallet/tx/cog/variants/send.js +77 -0
- package/dist/wallet/tx/cog.d.ts +1 -96
- package/dist/wallet/tx/cog.js +1 -824
- package/dist/wallet/tx/common.d.ts +14 -199
- package/dist/wallet/tx/common.js +10 -493
- package/dist/wallet/tx/domain-admin/confirm.d.ts +17 -0
- package/dist/wallet/tx/domain-admin/confirm.js +58 -0
- package/dist/wallet/tx/domain-admin/draft.d.ts +20 -0
- package/dist/wallet/tx/domain-admin/draft.js +161 -0
- package/dist/wallet/tx/domain-admin/index.d.ts +9 -0
- package/dist/wallet/tx/domain-admin/index.js +150 -0
- package/dist/wallet/tx/domain-admin/intent.d.ts +12 -0
- package/dist/wallet/tx/domain-admin/intent.js +61 -0
- package/dist/wallet/tx/domain-admin/plan.d.ts +19 -0
- package/dist/wallet/tx/domain-admin/plan.js +64 -0
- package/dist/wallet/tx/domain-admin/result.d.ts +19 -0
- package/dist/wallet/tx/domain-admin/result.js +33 -0
- package/dist/wallet/tx/domain-admin/types.d.ts +162 -0
- package/dist/wallet/tx/domain-admin/types.js +1 -0
- package/dist/wallet/tx/domain-admin/variants/canonical.d.ts +2 -0
- package/dist/wallet/tx/domain-admin/variants/canonical.js +22 -0
- package/dist/wallet/tx/domain-admin/variants/delegate.d.ts +3 -0
- package/dist/wallet/tx/domain-admin/variants/delegate.js +60 -0
- package/dist/wallet/tx/domain-admin/variants/endpoint.d.ts +3 -0
- package/dist/wallet/tx/domain-admin/variants/endpoint.js +102 -0
- package/dist/wallet/tx/domain-admin/variants/miner.d.ts +3 -0
- package/dist/wallet/tx/domain-admin/variants/miner.js +59 -0
- package/dist/wallet/tx/domain-admin.d.ts +1 -107
- package/dist/wallet/tx/domain-admin.js +1 -729
- package/dist/wallet/tx/domain-market/confirm.d.ts +6 -0
- package/dist/wallet/tx/domain-market/confirm.js +52 -0
- package/dist/wallet/tx/domain-market/draft.d.ts +43 -0
- package/dist/wallet/tx/domain-market/draft.js +286 -0
- package/dist/wallet/tx/domain-market/index.d.ts +6 -0
- package/dist/wallet/tx/domain-market/index.js +145 -0
- package/dist/wallet/tx/domain-market/intent.d.ts +15 -0
- package/dist/wallet/tx/domain-market/intent.js +131 -0
- package/dist/wallet/tx/domain-market/plan.d.ts +31 -0
- package/dist/wallet/tx/domain-market/plan.js +98 -0
- package/dist/wallet/tx/domain-market/result.d.ts +45 -0
- package/dist/wallet/tx/domain-market/result.js +88 -0
- package/dist/wallet/tx/domain-market/types.d.ts +221 -0
- package/dist/wallet/tx/domain-market/types.js +1 -0
- package/dist/wallet/tx/domain-market/variants/buy.d.ts +2 -0
- package/dist/wallet/tx/domain-market/variants/buy.js +103 -0
- package/dist/wallet/tx/domain-market/variants/sell.d.ts +2 -0
- package/dist/wallet/tx/domain-market/variants/sell.js +91 -0
- package/dist/wallet/tx/domain-market/variants/transfer.d.ts +2 -0
- package/dist/wallet/tx/domain-market/variants/transfer.js +105 -0
- package/dist/wallet/tx/domain-market.d.ts +1 -116
- package/dist/wallet/tx/domain-market.js +1 -1078
- package/dist/wallet/tx/draft-build.d.ts +60 -0
- package/dist/wallet/tx/draft-build.js +127 -0
- package/dist/wallet/tx/executor.d.ts +6 -40
- package/dist/wallet/tx/executor.js +6 -100
- package/dist/wallet/tx/fee.d.ts +30 -0
- package/dist/wallet/tx/fee.js +98 -0
- package/dist/wallet/tx/field/confirm.d.ts +11 -0
- package/dist/wallet/tx/field/confirm.js +19 -0
- package/dist/wallet/tx/field/draft.d.ts +23 -0
- package/dist/wallet/tx/field/draft.js +202 -0
- package/dist/wallet/tx/field/index.d.ts +5 -0
- package/dist/wallet/tx/field/index.js +140 -0
- package/dist/wallet/tx/field/intent.d.ts +5 -0
- package/dist/wallet/tx/field/intent.js +50 -0
- package/dist/wallet/tx/field/plan.d.ts +20 -0
- package/dist/wallet/tx/field/plan.js +65 -0
- package/dist/wallet/tx/field/result.d.ts +29 -0
- package/dist/wallet/tx/field/result.js +103 -0
- package/dist/wallet/tx/field/types.d.ts +163 -0
- package/dist/wallet/tx/field/types.js +1 -0
- package/dist/wallet/tx/field/variants/clear.d.ts +2 -0
- package/dist/wallet/tx/field/variants/clear.js +60 -0
- package/dist/wallet/tx/field/variants/create.d.ts +2 -0
- package/dist/wallet/tx/field/variants/create.js +67 -0
- package/dist/wallet/tx/field/variants/set.d.ts +2 -0
- package/dist/wallet/tx/field/variants/set.js +195 -0
- package/dist/wallet/tx/field.d.ts +1 -95
- package/dist/wallet/tx/field.js +1 -920
- package/dist/wallet/tx/mining-preemption.d.ts +6 -0
- package/dist/wallet/tx/mining-preemption.js +7 -0
- package/dist/wallet/tx/primitives.d.ts +13 -0
- package/dist/wallet/tx/primitives.js +42 -0
- package/dist/wallet/tx/psbt-assert.d.ts +14 -0
- package/dist/wallet/tx/psbt-assert.js +39 -0
- package/dist/wallet/tx/publish.d.ts +37 -0
- package/dist/wallet/tx/publish.js +88 -0
- package/dist/wallet/tx/readiness.d.ts +7 -0
- package/dist/wallet/tx/readiness.js +61 -0
- package/dist/wallet/tx/reconcile.d.ts +24 -0
- package/dist/wallet/tx/reconcile.js +72 -0
- package/dist/wallet/tx/register/confirm.d.ts +6 -0
- package/dist/wallet/tx/register/confirm.js +66 -0
- package/dist/wallet/tx/register/draft.d.ts +42 -0
- package/dist/wallet/tx/register/draft.js +181 -0
- package/dist/wallet/tx/register/index.d.ts +6 -0
- package/dist/wallet/tx/register/index.js +158 -0
- package/dist/wallet/tx/register/intent.d.ts +74 -0
- package/dist/wallet/tx/register/intent.js +119 -0
- package/dist/wallet/tx/register/plan.d.ts +43 -0
- package/dist/wallet/tx/register/plan.js +168 -0
- package/dist/wallet/tx/register/result.d.ts +78 -0
- package/dist/wallet/tx/register/result.js +41 -0
- package/dist/wallet/tx/register.d.ts +1 -70
- package/dist/wallet/tx/register.js +1 -681
- package/dist/wallet/tx/reputation/confirm.d.ts +11 -0
- package/dist/wallet/tx/reputation/confirm.js +51 -0
- package/dist/wallet/tx/reputation/draft.d.ts +20 -0
- package/dist/wallet/tx/reputation/draft.js +130 -0
- package/dist/wallet/tx/reputation/index.d.ts +4 -0
- package/dist/wallet/tx/reputation/index.js +162 -0
- package/dist/wallet/tx/reputation/intent.d.ts +36 -0
- package/dist/wallet/tx/reputation/intent.js +157 -0
- package/dist/wallet/tx/reputation/plan.d.ts +19 -0
- package/dist/wallet/tx/reputation/plan.js +64 -0
- package/dist/wallet/tx/reputation/result.d.ts +21 -0
- package/dist/wallet/tx/reputation/result.js +31 -0
- package/dist/wallet/tx/reputation/types.d.ts +130 -0
- package/dist/wallet/tx/reputation/types.js +1 -0
- package/dist/wallet/tx/reputation.d.ts +1 -74
- package/dist/wallet/tx/reputation.js +1 -556
- package/dist/wallet/tx/signing.d.ts +18 -0
- package/dist/wallet/tx/signing.js +31 -0
- package/dist/wallet/tx/state-persist.d.ts +27 -0
- package/dist/wallet/tx/state-persist.js +54 -0
- package/dist/wallet/tx/types.d.ts +44 -0
- package/dist/wallet/tx/types.js +1 -0
- package/package.json +1 -1
- package/dist/cli/mining-json.d.ts +0 -20
- package/dist/cli/mining-json.js +0 -46
- package/dist/cli/mutation-json.d.ts +0 -325
- package/dist/cli/mutation-json.js +0 -269
- package/dist/cli/mutation-resolved-json.d.ts +0 -117
- package/dist/cli/mutation-resolved-json.js +0 -123
- package/dist/cli/preview-json.d.ts +0 -319
- package/dist/cli/preview-json.js +0 -254
- package/dist/cli/read-json.d.ts +0 -190
- package/dist/cli/read-json.js +0 -627
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ListPage {
|
|
2
|
+
limit: number | null;
|
|
3
|
+
returned: number;
|
|
4
|
+
truncated: boolean;
|
|
5
|
+
moreAvailable: boolean | null;
|
|
6
|
+
totalKnown: number | null;
|
|
7
|
+
}
|
|
8
|
+
export declare function normalizeListPage<T>(items: readonly T[], options: {
|
|
9
|
+
limit: number | null;
|
|
10
|
+
all: boolean;
|
|
11
|
+
defaultLimit: number;
|
|
12
|
+
}): {
|
|
13
|
+
items: T[];
|
|
14
|
+
page: ListPage;
|
|
15
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function normalizeListPage(items, options) {
|
|
2
|
+
const totalKnown = items.length;
|
|
3
|
+
const appliedLimit = options.all ? null : (options.limit ?? options.defaultLimit);
|
|
4
|
+
const pagedItems = appliedLimit === null ? [...items] : items.slice(0, appliedLimit);
|
|
5
|
+
const truncated = appliedLimit !== null && totalKnown > appliedLimit;
|
|
6
|
+
return {
|
|
7
|
+
items: pagedItems,
|
|
8
|
+
page: {
|
|
9
|
+
limit: appliedLimit,
|
|
10
|
+
returned: pagedItems.length,
|
|
11
|
+
truncated,
|
|
12
|
+
moreAvailable: truncated,
|
|
13
|
+
totalKnown,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WalletReadContext } from "../wallet/read/index.js";
|
|
2
|
+
export declare function getRepairRecommendation(context: WalletReadContext): string | null;
|
|
3
|
+
export declare function getClientUnlockRecommendation(context: WalletReadContext): string | null;
|
|
4
|
+
export declare function getMutationRecommendation(context: WalletReadContext): string | null;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
export function getRepairRecommendation(context) {
|
|
2
|
+
if (context.localState.clientPasswordReadiness === "setup-required"
|
|
3
|
+
|| context.localState.clientPasswordReadiness === "migration-required") {
|
|
4
|
+
return "Run `cogcoin init` to configure the client password and migrate local wallet secrets.";
|
|
5
|
+
}
|
|
6
|
+
if (context.localState.unlockRequired) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
if (context.localState.availability === "uninitialized") {
|
|
10
|
+
return "Run `cogcoin init` to create or restore a wallet.";
|
|
11
|
+
}
|
|
12
|
+
if (context.localState.availability === "local-state-corrupt") {
|
|
13
|
+
return "Run `cogcoin repair` to recover local wallet state.";
|
|
14
|
+
}
|
|
15
|
+
if (context.bitcoind.health === "service-version-mismatch"
|
|
16
|
+
|| context.bitcoind.health === "wallet-root-mismatch"
|
|
17
|
+
|| context.bitcoind.health === "runtime-mismatch"
|
|
18
|
+
|| context.bitcoind.health === "replica-missing"
|
|
19
|
+
|| context.bitcoind.health === "replica-mismatch"
|
|
20
|
+
|| context.bitcoind.health === "failed") {
|
|
21
|
+
return "Run `cogcoin repair` to recover the managed bitcoind service and Core wallet replica.";
|
|
22
|
+
}
|
|
23
|
+
if (context.indexer.health === "failed"
|
|
24
|
+
|| context.indexer.health === "schema-mismatch"
|
|
25
|
+
|| context.indexer.health === "service-version-mismatch"
|
|
26
|
+
|| context.indexer.health === "wallet-root-mismatch") {
|
|
27
|
+
return "Run `cogcoin repair` to recover the managed indexer daemon and local indexer artifacts.";
|
|
28
|
+
}
|
|
29
|
+
if (context.localState.state?.miningState.state === "repair-required"
|
|
30
|
+
|| (context.localState.state?.pendingMutations ?? []).some((mutation) => mutation.status === "repair-required")) {
|
|
31
|
+
return "Run `cogcoin repair` before relying on local wallet state.";
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
export function getClientUnlockRecommendation(context) {
|
|
36
|
+
if (context.localState.unlockRequired) {
|
|
37
|
+
return "Rerun this command in an interactive terminal so Cogcoin can prompt for the client password.";
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
export function getMutationRecommendation(context) {
|
|
42
|
+
const pendingMutations = context.localState.state?.pendingMutations ?? [];
|
|
43
|
+
const unresolved = pendingMutations.find((mutation) => mutation.status === "broadcast-unknown" || mutation.status === "repair-required");
|
|
44
|
+
if (unresolved === undefined) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
if (unresolved.status === "repair-required") {
|
|
48
|
+
return "Run `cogcoin repair` before starting another mutation.";
|
|
49
|
+
}
|
|
50
|
+
if (unresolved.kind === "register") {
|
|
51
|
+
return `Rerun \`cogcoin register ${unresolved.domainName}\` to reconcile the pending registration, or run \`cogcoin repair\` if it remains unresolved.`;
|
|
52
|
+
}
|
|
53
|
+
if (unresolved.kind === "anchor") {
|
|
54
|
+
return `Rerun \`cogcoin anchor ${unresolved.domainName}\` to reconcile the pending anchor, or run \`cogcoin repair\` if it remains unresolved.`;
|
|
55
|
+
}
|
|
56
|
+
if (unresolved.kind === "transfer") {
|
|
57
|
+
return `Rerun \`cogcoin transfer ${unresolved.domainName}\` with the same target to reconcile the pending transfer, or run \`cogcoin repair\` if it remains unresolved.`;
|
|
58
|
+
}
|
|
59
|
+
if (unresolved.kind === "sell") {
|
|
60
|
+
const command = unresolved.priceCogtoshi === 0n ? "unsell" : "sell";
|
|
61
|
+
return `Rerun \`cogcoin ${command} ${unresolved.domainName}\` to reconcile the pending listing change, or run \`cogcoin repair\` if it remains unresolved.`;
|
|
62
|
+
}
|
|
63
|
+
if (unresolved.kind === "buy") {
|
|
64
|
+
return `Rerun \`cogcoin buy ${unresolved.domainName}\` to reconcile the pending purchase, or run \`cogcoin repair\` if it remains unresolved.`;
|
|
65
|
+
}
|
|
66
|
+
if (unresolved.kind === "endpoint") {
|
|
67
|
+
return unresolved.endpointValueHex === ""
|
|
68
|
+
? `Rerun \`cogcoin domain endpoint clear ${unresolved.domainName}\` to reconcile the pending endpoint clear, or run \`cogcoin repair\` if it remains unresolved.`
|
|
69
|
+
: `Rerun \`cogcoin domain endpoint set ${unresolved.domainName} ...\` to reconcile the pending endpoint update, or run \`cogcoin repair\` if it remains unresolved.`;
|
|
70
|
+
}
|
|
71
|
+
if (unresolved.kind === "delegate") {
|
|
72
|
+
return unresolved.recipientScriptPubKeyHex === null
|
|
73
|
+
? `Rerun \`cogcoin domain delegate clear ${unresolved.domainName}\` to reconcile the pending delegate clear, or run \`cogcoin repair\` if it remains unresolved.`
|
|
74
|
+
: `Rerun \`cogcoin domain delegate set ${unresolved.domainName} ...\` to reconcile the pending delegate update, or run \`cogcoin repair\` if it remains unresolved.`;
|
|
75
|
+
}
|
|
76
|
+
if (unresolved.kind === "miner") {
|
|
77
|
+
return unresolved.recipientScriptPubKeyHex === null
|
|
78
|
+
? `Rerun \`cogcoin domain miner clear ${unresolved.domainName}\` to reconcile the pending miner clear, or run \`cogcoin repair\` if it remains unresolved.`
|
|
79
|
+
: `Rerun \`cogcoin domain miner set ${unresolved.domainName} ...\` to reconcile the pending miner update, or run \`cogcoin repair\` if it remains unresolved.`;
|
|
80
|
+
}
|
|
81
|
+
if (unresolved.kind === "canonical") {
|
|
82
|
+
return `Rerun \`cogcoin domain canonical ${unresolved.domainName}\` to reconcile the pending canonical update, or run \`cogcoin repair\` if it remains unresolved.`;
|
|
83
|
+
}
|
|
84
|
+
if (unresolved.kind === "field-create") {
|
|
85
|
+
return `Rerun \`cogcoin field create ${unresolved.domainName} ${unresolved.fieldName} ...\` to reconcile the pending field creation, or run \`cogcoin repair\` if it remains unresolved.`;
|
|
86
|
+
}
|
|
87
|
+
if (unresolved.kind === "field-set") {
|
|
88
|
+
return `Rerun \`cogcoin field set ${unresolved.domainName} ${unresolved.fieldName} ...\` to reconcile the pending field update, or run \`cogcoin repair\` if it remains unresolved.`;
|
|
89
|
+
}
|
|
90
|
+
if (unresolved.kind === "field-clear") {
|
|
91
|
+
return `Rerun \`cogcoin field clear ${unresolved.domainName} ${unresolved.fieldName}\` to reconcile the pending field clear, or run \`cogcoin repair\` if it remains unresolved.`;
|
|
92
|
+
}
|
|
93
|
+
if (unresolved.kind === "rep-give") {
|
|
94
|
+
return `Rerun \`cogcoin rep give ${unresolved.domainName} ${unresolved.recipientDomainName ?? "..."} ...\` to reconcile the pending reputation support, or run \`cogcoin repair\` if it remains unresolved.`;
|
|
95
|
+
}
|
|
96
|
+
if (unresolved.kind === "rep-revoke") {
|
|
97
|
+
return `Rerun \`cogcoin rep revoke ${unresolved.domainName} ${unresolved.recipientDomainName ?? "..."} ...\` to reconcile the pending reputation revoke, or run \`cogcoin repair\` if it remains unresolved.`;
|
|
98
|
+
}
|
|
99
|
+
if (unresolved.kind === "send") {
|
|
100
|
+
return "Rerun the same `cogcoin send ...` command to reconcile the pending transfer, or run `cogcoin repair` if it remains unresolved.";
|
|
101
|
+
}
|
|
102
|
+
if (unresolved.kind === "lock") {
|
|
103
|
+
return "Rerun the same `cogcoin cog lock ...` command to reconcile the pending lock, or run `cogcoin repair` if it remains unresolved.";
|
|
104
|
+
}
|
|
105
|
+
return unresolved.preimageHex === "0000000000000000000000000000000000000000000000000000000000000000"
|
|
106
|
+
? "Rerun the same `cogcoin reclaim ...` command to reconcile the pending reclaim, or run `cogcoin repair` if it remains unresolved."
|
|
107
|
+
: "Rerun the same `cogcoin claim ...` command to reconcile the pending claim, or run `cogcoin repair` if it remains unresolved.";
|
|
108
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { WalletReadContext } from "../../wallet/read/index.js";
|
|
2
|
+
export declare function resolveWalletRootLabel(context: WalletReadContext): string;
|
|
3
|
+
export declare function appendServiceSummary(lines: string[], context: WalletReadContext): void;
|
|
4
|
+
export declare function appendWalletAvailability(lines: string[], context: WalletReadContext): void;
|
|
5
|
+
export declare function getOverviewNextStep(context: WalletReadContext): string | null;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { formatMiningSummaryLine } from "../mining-format.js";
|
|
2
|
+
import { getClientUnlockRecommendation, getMutationRecommendation, getRepairRecommendation, } from "../recommendations.js";
|
|
3
|
+
import { getBootstrapSyncNextStep } from "../workflow-hints.js";
|
|
4
|
+
import { formatIndexerTruthSource, formatMaybe, formatServiceHealth, } from "./shared.js";
|
|
5
|
+
export function resolveWalletRootLabel(context) {
|
|
6
|
+
return context.model?.walletRootId
|
|
7
|
+
?? context.localState.walletRootId
|
|
8
|
+
?? context.nodeStatus?.walletRootId
|
|
9
|
+
?? "none";
|
|
10
|
+
}
|
|
11
|
+
export function appendServiceSummary(lines, context) {
|
|
12
|
+
lines.push(`Managed bitcoind: ${formatServiceHealth(context.bitcoind.health)}`);
|
|
13
|
+
if (context.bitcoind.message !== null) {
|
|
14
|
+
lines.push(`Managed bitcoind note: ${context.bitcoind.message}`);
|
|
15
|
+
}
|
|
16
|
+
lines.push(`Bitcoin service: ${formatServiceHealth(context.nodeHealth)}`);
|
|
17
|
+
if (context.nodeStatus !== null) {
|
|
18
|
+
lines.push(`Bitcoin best height: ${formatMaybe(context.nodeStatus.nodeBestHeight)}`);
|
|
19
|
+
lines.push(`Bitcoin headers: ${formatMaybe(context.nodeStatus.nodeHeaderHeight)}`);
|
|
20
|
+
}
|
|
21
|
+
if (context.nodeMessage !== null) {
|
|
22
|
+
lines.push(`Bitcoin note: ${context.nodeMessage}`);
|
|
23
|
+
}
|
|
24
|
+
lines.push(`Indexer service: ${formatServiceHealth(context.indexer.health)}`);
|
|
25
|
+
lines.push(`Indexer truth source: ${formatIndexerTruthSource(context.indexer.source)}`);
|
|
26
|
+
if (context.indexer.daemonInstanceId !== null) {
|
|
27
|
+
lines.push(`Indexer daemon instance: ${context.indexer.daemonInstanceId}`);
|
|
28
|
+
}
|
|
29
|
+
if (context.indexer.snapshotSeq !== null) {
|
|
30
|
+
lines.push(`Indexer snapshot sequence: ${context.indexer.snapshotSeq}`);
|
|
31
|
+
}
|
|
32
|
+
if (context.indexer.status?.reorgDepth !== null && context.indexer.status?.reorgDepth !== undefined) {
|
|
33
|
+
lines.push(`Indexer reorg depth: ${context.indexer.status.reorgDepth}`);
|
|
34
|
+
}
|
|
35
|
+
if (context.indexer.snapshotTip !== null) {
|
|
36
|
+
lines.push(`Indexer tip height: ${context.indexer.snapshotTip.height}`);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
lines.push("Indexer tip height: unavailable");
|
|
40
|
+
}
|
|
41
|
+
if (context.indexer.message !== null) {
|
|
42
|
+
lines.push(`Indexer note: ${context.indexer.message}`);
|
|
43
|
+
}
|
|
44
|
+
if (context.mining !== undefined) {
|
|
45
|
+
lines.push(`Mining: ${formatMiningSummaryLine(context.mining)}`);
|
|
46
|
+
if (context.mining.runtime.note !== null) {
|
|
47
|
+
lines.push(`Mining note: ${context.mining.runtime.note}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export function appendWalletAvailability(lines, context) {
|
|
52
|
+
lines.push(`Wallet state: ${context.localState.availability}`);
|
|
53
|
+
lines.push(`Wallet root: ${resolveWalletRootLabel(context)}`);
|
|
54
|
+
if (context.localState.message !== null) {
|
|
55
|
+
lines.push(`Wallet note: ${context.localState.message}`);
|
|
56
|
+
}
|
|
57
|
+
const nodeStatus = context.nodeStatus;
|
|
58
|
+
const replica = nodeStatus?.walletReplica ?? null;
|
|
59
|
+
if (replica !== null) {
|
|
60
|
+
lines.push(`Managed Core wallet: ${replica.proofStatus ?? "not-proven"}`);
|
|
61
|
+
}
|
|
62
|
+
if (nodeStatus?.walletReplicaMessage) {
|
|
63
|
+
lines.push(`Managed Core note: ${nodeStatus.walletReplicaMessage}`);
|
|
64
|
+
}
|
|
65
|
+
const repairRecommendation = getRepairRecommendation(context);
|
|
66
|
+
if (repairRecommendation !== null) {
|
|
67
|
+
lines.push(`Recommended next step: ${repairRecommendation}`);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const clientUnlockRecommendation = getClientUnlockRecommendation(context);
|
|
71
|
+
if (clientUnlockRecommendation !== null) {
|
|
72
|
+
lines.push(`Recommended next step: ${clientUnlockRecommendation}`);
|
|
73
|
+
}
|
|
74
|
+
else if (getBootstrapSyncNextStep(context) !== null) {
|
|
75
|
+
lines.push("Recommended next step: Run `cogcoin sync` to bootstrap assumeutxo and the managed Bitcoin/indexer state.");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const mutationRecommendation = getMutationRecommendation(context);
|
|
79
|
+
if (mutationRecommendation !== null) {
|
|
80
|
+
lines.push(`Mutation note: ${mutationRecommendation}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export function getOverviewNextStep(context) {
|
|
84
|
+
const repairRecommendation = getRepairRecommendation(context);
|
|
85
|
+
if (repairRecommendation !== null) {
|
|
86
|
+
return repairRecommendation;
|
|
87
|
+
}
|
|
88
|
+
const clientUnlockRecommendation = getClientUnlockRecommendation(context);
|
|
89
|
+
if (clientUnlockRecommendation !== null) {
|
|
90
|
+
return clientUnlockRecommendation;
|
|
91
|
+
}
|
|
92
|
+
if (getBootstrapSyncNextStep(context) !== null) {
|
|
93
|
+
return "Run `cogcoin sync` to bootstrap assumeutxo and the managed Bitcoin/indexer state.";
|
|
94
|
+
}
|
|
95
|
+
return getMutationRecommendation(context);
|
|
96
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { getBalance } from "@cogcoin/indexer/queries";
|
|
2
|
+
import { isRootDomainName } from "../../wallet/read/index.js";
|
|
3
|
+
import { loadBalanceArtText } from "../art.js";
|
|
4
|
+
import { formatNextStepLines, getFundingQuickstartGuidance, } from "../workflow-hints.js";
|
|
5
|
+
import { appendWalletAvailability } from "./availability.js";
|
|
6
|
+
import { formatBitcoinAmount, formatCogAmount, formatServiceHealth, } from "./shared.js";
|
|
7
|
+
const BALANCE_QUICKSTART_THRESHOLD_SATS = 150000n;
|
|
8
|
+
const BALANCE_BUY_ROOT_THRESHOLD_SATS = 100000n;
|
|
9
|
+
const BALANCE_MINING_THRESHOLD_SATS = 10000n;
|
|
10
|
+
function renderBalanceArtLine(templateLine, label, value) {
|
|
11
|
+
const labelIndex = templateLine.indexOf(label);
|
|
12
|
+
if (labelIndex === -1) {
|
|
13
|
+
throw new Error(`balance_art_label_missing_${label}`);
|
|
14
|
+
}
|
|
15
|
+
const fieldStart = labelIndex + label.length;
|
|
16
|
+
const borderIndex = Math.max(templateLine.lastIndexOf("│"), templateLine.lastIndexOf("|"));
|
|
17
|
+
if (borderIndex <= fieldStart) {
|
|
18
|
+
throw new Error(`balance_art_field_invalid_${label}`);
|
|
19
|
+
}
|
|
20
|
+
const fieldWidth = borderIndex - fieldStart;
|
|
21
|
+
const fieldValue = value.slice(0, fieldWidth).padEnd(fieldWidth, " ");
|
|
22
|
+
const rendered = `${templateLine.slice(0, fieldStart)}${fieldValue}${templateLine.slice(borderIndex)}`;
|
|
23
|
+
if (rendered.length !== templateLine.length) {
|
|
24
|
+
throw new Error(`balance_art_render_width_invalid_${label}`);
|
|
25
|
+
}
|
|
26
|
+
return rendered;
|
|
27
|
+
}
|
|
28
|
+
function renderBalanceArtCard(context) {
|
|
29
|
+
const templateLines = loadBalanceArtText().split("\n");
|
|
30
|
+
const fundingAddress = context.model.walletAddress ?? "unavailable";
|
|
31
|
+
const spendableCog = getBalance(context.snapshot.state, new Uint8Array(Buffer.from(context.model.walletScriptPubKeyHex, "hex")));
|
|
32
|
+
return templateLines.map((line) => {
|
|
33
|
+
if (line.includes("Funding address:")) {
|
|
34
|
+
return renderBalanceArtLine(line, "Funding address:", ` ${fundingAddress}`);
|
|
35
|
+
}
|
|
36
|
+
if (line.includes("Bitcoin Balance:")) {
|
|
37
|
+
return renderBalanceArtLine(line, "Bitcoin Balance:", ` ${formatBitcoinAmount(context.fundingSpendableSats ?? null)}`);
|
|
38
|
+
}
|
|
39
|
+
if (line.includes("Cogcoin Balance:")) {
|
|
40
|
+
return renderBalanceArtLine(line, "Cogcoin Balance:", ` ${formatCogAmount(spendableCog)}`);
|
|
41
|
+
}
|
|
42
|
+
if (line.includes("mempool.space/address/")) {
|
|
43
|
+
return renderBalanceArtLine(line, "mempool.space/address/", fundingAddress);
|
|
44
|
+
}
|
|
45
|
+
return line;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function hasRegisteredOrAnchoredDomain(model) {
|
|
49
|
+
return model.domains.some((domain) => domain.localRelationship === "local"
|
|
50
|
+
&& (domain.chainStatus === "registered-unanchored" || domain.chainStatus === "anchored"));
|
|
51
|
+
}
|
|
52
|
+
function listBalanceDomainsByStatus(model, status) {
|
|
53
|
+
return model.domains
|
|
54
|
+
.filter((domain) => domain.localRelationship === "local" && domain.chainStatus === status)
|
|
55
|
+
.sort((left, right) => left.name.localeCompare(right.name));
|
|
56
|
+
}
|
|
57
|
+
function shouldShowBalanceQuickstart(context) {
|
|
58
|
+
return context.fundingSpendableSats !== null
|
|
59
|
+
&& context.fundingSpendableSats < BALANCE_QUICKSTART_THRESHOLD_SATS
|
|
60
|
+
&& !hasRegisteredOrAnchoredDomain(context.model);
|
|
61
|
+
}
|
|
62
|
+
function formatBalanceDomainSection(title, icon, domains, emptyLabel) {
|
|
63
|
+
const domainItems = domains.map((domain) => `${icon} ${domain.name}`);
|
|
64
|
+
const wrappedDomainLines = [];
|
|
65
|
+
let currentLine = "";
|
|
66
|
+
for (const item of domainItems) {
|
|
67
|
+
const candidate = currentLine.length === 0 ? item : `${currentLine}, ${item}`;
|
|
68
|
+
if (candidate.length <= 80) {
|
|
69
|
+
currentLine = candidate;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (currentLine.length > 0) {
|
|
73
|
+
wrappedDomainLines.push(currentLine);
|
|
74
|
+
}
|
|
75
|
+
currentLine = item;
|
|
76
|
+
}
|
|
77
|
+
if (currentLine.length > 0) {
|
|
78
|
+
wrappedDomainLines.push(currentLine);
|
|
79
|
+
}
|
|
80
|
+
return [
|
|
81
|
+
title,
|
|
82
|
+
...(domains.length === 0
|
|
83
|
+
? [emptyLabel]
|
|
84
|
+
: wrappedDomainLines),
|
|
85
|
+
];
|
|
86
|
+
}
|
|
87
|
+
function getBalanceNextSteps(context) {
|
|
88
|
+
const anchoredDomains = listBalanceDomainsByStatus(context.model, "anchored");
|
|
89
|
+
const anchoredRootDomains = anchoredDomains.filter((domain) => isRootDomainName(domain.name));
|
|
90
|
+
const unanchoredDomains = listBalanceDomainsByStatus(context.model, "registered-unanchored");
|
|
91
|
+
if (anchoredRootDomains.length > 0) {
|
|
92
|
+
if (context.fundingSpendableSats !== null && context.fundingSpendableSats < BALANCE_MINING_THRESHOLD_SATS) {
|
|
93
|
+
return [`Transfer BTC to ${context.model.walletAddress ?? "this wallet address"} so your anchored root domain can keep mining.`];
|
|
94
|
+
}
|
|
95
|
+
if (context.fundingSpendableSats !== null && context.fundingSpendableSats > BALANCE_MINING_THRESHOLD_SATS) {
|
|
96
|
+
if (context.mining?.provider.status === "missing") {
|
|
97
|
+
return ["Run `cogcoin mine setup` to configure your mining provider."];
|
|
98
|
+
}
|
|
99
|
+
return ["Run `cogcoin mine` to start mining with your anchored root domain."];
|
|
100
|
+
}
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
if (unanchoredDomains.length > 0) {
|
|
104
|
+
return [`Run \`cogcoin anchor ${unanchoredDomains[0].name}\` to anchor your unanchored domain.`];
|
|
105
|
+
}
|
|
106
|
+
if (context.fundingSpendableSats !== null && context.fundingSpendableSats > BALANCE_BUY_ROOT_THRESHOLD_SATS) {
|
|
107
|
+
return ["Buy a 6+ character root domain with `cogcoin register <root>`."];
|
|
108
|
+
}
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
function listPendingBalanceLines(context) {
|
|
112
|
+
const lines = [];
|
|
113
|
+
for (const mutation of (context.localState.state?.pendingMutations ?? [])
|
|
114
|
+
.filter((entry) => (entry.kind === "send" || entry.kind === "lock" || entry.kind === "claim")
|
|
115
|
+
&& entry.status !== "confirmed"
|
|
116
|
+
&& entry.status !== "canceled")) {
|
|
117
|
+
const label = mutation.kind === "claim" && mutation.preimageHex === "0000000000000000000000000000000000000000000000000000000000000000"
|
|
118
|
+
? "reclaim"
|
|
119
|
+
: mutation.kind;
|
|
120
|
+
lines.push(`Pending: ${label} ${mutation.status}${mutation.amountCogtoshi === null || mutation.amountCogtoshi === undefined ? "" : ` ${formatCogAmount(mutation.amountCogtoshi)}`}`);
|
|
121
|
+
}
|
|
122
|
+
return lines;
|
|
123
|
+
}
|
|
124
|
+
function formatReadyBalanceReport(context) {
|
|
125
|
+
const anchoredDomains = listBalanceDomainsByStatus(context.model, "anchored");
|
|
126
|
+
const unanchoredDomains = listBalanceDomainsByStatus(context.model, "registered-unanchored");
|
|
127
|
+
const nextStepLines = formatNextStepLines(getBalanceNextSteps(context));
|
|
128
|
+
const lines = [
|
|
129
|
+
"",
|
|
130
|
+
...renderBalanceArtCard(context),
|
|
131
|
+
"",
|
|
132
|
+
...formatBalanceDomainSection("Anchored Domains", "⌂", anchoredDomains, "--- No anchored domains ---"),
|
|
133
|
+
"",
|
|
134
|
+
...formatBalanceDomainSection("Unanchored Domains", "~", unanchoredDomains, "--- No unanchored domains ---"),
|
|
135
|
+
];
|
|
136
|
+
if (shouldShowBalanceQuickstart(context)) {
|
|
137
|
+
lines.push("");
|
|
138
|
+
lines.push(`Quickstart: ${getFundingQuickstartGuidance()}`);
|
|
139
|
+
}
|
|
140
|
+
if (nextStepLines.length > 0) {
|
|
141
|
+
lines.push("");
|
|
142
|
+
lines.push(...nextStepLines);
|
|
143
|
+
}
|
|
144
|
+
const pendingLines = listPendingBalanceLines(context);
|
|
145
|
+
if (pendingLines.length > 0) {
|
|
146
|
+
lines.push("");
|
|
147
|
+
lines.push(...pendingLines);
|
|
148
|
+
}
|
|
149
|
+
return lines.join("\n");
|
|
150
|
+
}
|
|
151
|
+
export function formatBalanceReport(context) {
|
|
152
|
+
const lines = ["COG Balance"];
|
|
153
|
+
if (context.model === null) {
|
|
154
|
+
appendWalletAvailability(lines, context);
|
|
155
|
+
return lines.join("\n");
|
|
156
|
+
}
|
|
157
|
+
if (context.snapshot === null) {
|
|
158
|
+
lines.push(`Indexer-backed balances are unavailable while the indexer is ${formatServiceHealth(context.indexer.health)}.`);
|
|
159
|
+
return lines.join("\n");
|
|
160
|
+
}
|
|
161
|
+
return formatReadyBalanceReport(context);
|
|
162
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WalletDomainView, WalletReadContext } from "../../wallet/read/index.js";
|
|
2
|
+
export declare function formatDomainsReport(context: WalletReadContext, options?: {
|
|
3
|
+
limit?: number | null;
|
|
4
|
+
all?: boolean;
|
|
5
|
+
domains?: WalletDomainView[] | null;
|
|
6
|
+
activeFilters?: string[];
|
|
7
|
+
}): string;
|
|
8
|
+
export declare function formatDomainReport(context: WalletReadContext, domainName: string): string;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { findWalletDomain } from "../../wallet/read/index.js";
|
|
2
|
+
import { appendWalletAvailability } from "./availability.js";
|
|
3
|
+
import { formatCogAmount, formatMaybe, formatServiceHealth, } from "./shared.js";
|
|
4
|
+
import { formatPendingMutationDomainLabel, listPendingDomainMutations, listPendingDomainShowMutations, listPendingFieldMutations, } from "./pending.js";
|
|
5
|
+
export function formatDomainsReport(context, options = {}) {
|
|
6
|
+
const lines = ["Domains"];
|
|
7
|
+
if (context.model === null) {
|
|
8
|
+
appendWalletAvailability(lines, context);
|
|
9
|
+
return lines.join("\n");
|
|
10
|
+
}
|
|
11
|
+
const visibleDomains = options.domains ?? context.model.domains;
|
|
12
|
+
if (visibleDomains.length === 0) {
|
|
13
|
+
if ((options.activeFilters?.length ?? 0) > 0) {
|
|
14
|
+
lines.push(`No locally related domains matched the active filters (${options.activeFilters.join(", ")}).`);
|
|
15
|
+
return lines.join("\n");
|
|
16
|
+
}
|
|
17
|
+
lines.push("No locally related domains.");
|
|
18
|
+
return lines.join("\n");
|
|
19
|
+
}
|
|
20
|
+
const renderedDomains = options.all || options.limit === null || options.limit === undefined
|
|
21
|
+
? visibleDomains
|
|
22
|
+
: visibleDomains.slice(0, options.limit);
|
|
23
|
+
for (const domain of renderedDomains) {
|
|
24
|
+
const pending = listPendingDomainMutations(context, domain.name);
|
|
25
|
+
const pendingFieldMutations = listPendingFieldMutations(context, domain.name);
|
|
26
|
+
const pendingText = pending.length === 0
|
|
27
|
+
? ""
|
|
28
|
+
: ` pending ${pending.map((mutation) => mutation.kind === "sell" && mutation.priceCogtoshi === 0n
|
|
29
|
+
? `unsell:${mutation.status}`
|
|
30
|
+
: mutation.kind === "endpoint" && mutation.endpointValueHex === ""
|
|
31
|
+
? `endpoint-clear:${mutation.status}`
|
|
32
|
+
: mutation.kind === "delegate" && mutation.recipientScriptPubKeyHex === null
|
|
33
|
+
? `delegate-clear:${mutation.status}`
|
|
34
|
+
: mutation.kind === "miner" && mutation.recipientScriptPubKeyHex === null
|
|
35
|
+
? `miner-clear:${mutation.status}`
|
|
36
|
+
: `${mutation.kind}:${mutation.status}`).join(",")}`;
|
|
37
|
+
const pendingFieldsText = pendingFieldMutations.length === 0
|
|
38
|
+
? ""
|
|
39
|
+
: ` field-pending ${pendingFieldMutations.map((mutation) => `${mutation.fieldName}:${mutation.kind}:${mutation.status}`).join(",")}`;
|
|
40
|
+
lines.push(`${domain.name} ${domain.chainStatus} ${domain.localRelationship} owner ${domain.ownerAddress ?? domain.ownerScriptPubKeyHex ?? "unknown"} fields ${formatMaybe(domain.fieldCount)}${pendingText}${pendingFieldsText}`);
|
|
41
|
+
}
|
|
42
|
+
if (!options.all && options.limit !== null && options.limit !== undefined && visibleDomains.length > options.limit) {
|
|
43
|
+
lines.push(`Showing first ${renderedDomains.length} of ${visibleDomains.length}. Use --limit <n> or --all for more.`);
|
|
44
|
+
}
|
|
45
|
+
return lines.join("\n");
|
|
46
|
+
}
|
|
47
|
+
export function formatDomainReport(context, domainName) {
|
|
48
|
+
const lines = [`Domain: ${domainName}`];
|
|
49
|
+
if (context.snapshot === null && context.model?.domains.find((domain) => domain.name === domainName) === undefined) {
|
|
50
|
+
lines.push(`Domain state is unavailable while the indexer is ${formatServiceHealth(context.indexer.health)}.`);
|
|
51
|
+
return lines.join("\n");
|
|
52
|
+
}
|
|
53
|
+
const view = findWalletDomain(context, domainName);
|
|
54
|
+
if (view === null) {
|
|
55
|
+
lines.push("Domain not found.");
|
|
56
|
+
return lines.join("\n");
|
|
57
|
+
}
|
|
58
|
+
lines.push(`Domain ID: ${formatMaybe(view.domain.domainId)}`);
|
|
59
|
+
lines.push(`Anchored: ${view.domain.anchored === null ? "unknown" : (view.domain.anchored ? "yes" : "no")}`);
|
|
60
|
+
lines.push(`Owner: ${view.domain.ownerAddress ?? view.domain.ownerScriptPubKeyHex ?? "unknown"}`);
|
|
61
|
+
lines.push(`Local relationship: ${view.localRelationship}`);
|
|
62
|
+
lines.push(`Listing price: ${view.domain.listingPriceCogtoshi === null ? "none" : formatCogAmount(view.domain.listingPriceCogtoshi)}`);
|
|
63
|
+
lines.push(`Field count: ${formatMaybe(view.domain.fieldCount)}`);
|
|
64
|
+
if (view.domain.selfStakeCogtoshi !== null
|
|
65
|
+
|| view.domain.supportedStakeCogtoshi !== null
|
|
66
|
+
|| view.domain.totalSupportedCogtoshi !== null
|
|
67
|
+
|| view.domain.totalRevokedCogtoshi !== null) {
|
|
68
|
+
lines.push(`Reputation self-stake: ${view.domain.selfStakeCogtoshi === null ? "unavailable" : formatCogAmount(view.domain.selfStakeCogtoshi)}`);
|
|
69
|
+
lines.push(`Reputation supported stake: ${view.domain.supportedStakeCogtoshi === null ? "unavailable" : formatCogAmount(view.domain.supportedStakeCogtoshi)}`);
|
|
70
|
+
lines.push(`Reputation total supported: ${view.domain.totalSupportedCogtoshi === null ? "unavailable" : formatCogAmount(view.domain.totalSupportedCogtoshi)}`);
|
|
71
|
+
lines.push(`Reputation total revoked: ${view.domain.totalRevokedCogtoshi === null ? "unavailable" : formatCogAmount(view.domain.totalRevokedCogtoshi)}`);
|
|
72
|
+
}
|
|
73
|
+
lines.push(`Delegate: ${view.domain.delegateScriptPubKeyHex ?? "none"}`);
|
|
74
|
+
lines.push(`Designated miner: ${view.domain.minerScriptPubKeyHex ?? "none"}`);
|
|
75
|
+
lines.push(`Endpoint: ${view.domain.endpointText ?? "none"}`);
|
|
76
|
+
lines.push(`Founding message: ${view.domain.foundingMessageText ?? "none"}`);
|
|
77
|
+
for (const mutation of listPendingDomainShowMutations(context, domainName)) {
|
|
78
|
+
lines.push(`Pending mutation: ${formatPendingMutationDomainLabel(mutation)} ${mutation.status}`);
|
|
79
|
+
}
|
|
80
|
+
for (const mutation of listPendingFieldMutations(context, domainName)) {
|
|
81
|
+
lines.push(`Pending field mutation: ${mutation.fieldName ?? "unknown"} ${mutation.kind} ${mutation.status}`);
|
|
82
|
+
}
|
|
83
|
+
return lines.join("\n");
|
|
84
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { WalletReadContext } from "../../wallet/read/index.js";
|
|
2
|
+
export declare function formatFieldsReport(context: WalletReadContext, domainName: string, options?: {
|
|
3
|
+
limit?: number | null;
|
|
4
|
+
all?: boolean;
|
|
5
|
+
}): string;
|
|
6
|
+
export declare function formatFieldReport(context: WalletReadContext, domainName: string, fieldName: string): string;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { findDomainField, formatFieldFormat, listDomainFields, } from "../../wallet/read/index.js";
|
|
2
|
+
import { formatServiceHealth } from "./shared.js";
|
|
3
|
+
import { listPendingFieldMutations } from "./pending.js";
|
|
4
|
+
function renderFieldLine(field) {
|
|
5
|
+
return `${field.name} id ${field.fieldId} ${field.permanent ? "permanent" : "mutable"} ${field.hasValue ? formatFieldFormat(field.format) : "empty"} ${field.preview ?? "(no value)"}`;
|
|
6
|
+
}
|
|
7
|
+
export function formatFieldsReport(context, domainName, options = {}) {
|
|
8
|
+
const lines = [`Fields: ${domainName}`];
|
|
9
|
+
if (context.snapshot === null) {
|
|
10
|
+
lines.push(`Field state is unavailable while the indexer is ${formatServiceHealth(context.indexer.health)}.`);
|
|
11
|
+
return lines.join("\n");
|
|
12
|
+
}
|
|
13
|
+
const fields = listDomainFields(context, domainName);
|
|
14
|
+
if (fields === null) {
|
|
15
|
+
lines.push("Domain not found.");
|
|
16
|
+
return lines.join("\n");
|
|
17
|
+
}
|
|
18
|
+
const renderedFields = options.all || options.limit === null || options.limit === undefined
|
|
19
|
+
? fields
|
|
20
|
+
: fields.slice(0, options.limit);
|
|
21
|
+
if (renderedFields.length === 0) {
|
|
22
|
+
lines.push("No fields found.");
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
for (const field of renderedFields) {
|
|
26
|
+
lines.push(renderFieldLine(field));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
for (const mutation of listPendingFieldMutations(context, domainName)) {
|
|
30
|
+
lines.push(`Pending field mutation: ${mutation.fieldName ?? "unknown"} ${mutation.kind} ${mutation.status}`);
|
|
31
|
+
}
|
|
32
|
+
if (!options.all && options.limit !== null && options.limit !== undefined && fields.length > options.limit) {
|
|
33
|
+
lines.push(`Showing first ${renderedFields.length} of ${fields.length}. Use --limit <n> or --all for more.`);
|
|
34
|
+
}
|
|
35
|
+
return lines.join("\n");
|
|
36
|
+
}
|
|
37
|
+
export function formatFieldReport(context, domainName, fieldName) {
|
|
38
|
+
const lines = [`Field: ${domainName}.${fieldName}`];
|
|
39
|
+
if (context.snapshot === null) {
|
|
40
|
+
lines.push(`Field state is unavailable while the indexer is ${formatServiceHealth(context.indexer.health)}.`);
|
|
41
|
+
return lines.join("\n");
|
|
42
|
+
}
|
|
43
|
+
const field = findDomainField(context, domainName, fieldName);
|
|
44
|
+
const pendingMutations = listPendingFieldMutations(context, domainName, fieldName);
|
|
45
|
+
if (field === null) {
|
|
46
|
+
lines.push("Field not found.");
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
lines.push(`Domain ID: ${field.domainId}`);
|
|
50
|
+
lines.push(`Field ID: ${field.fieldId}`);
|
|
51
|
+
lines.push(`Permanent: ${field.permanent ? "yes" : "no"}`);
|
|
52
|
+
lines.push(`Has value: ${field.hasValue ? "yes" : "no"}`);
|
|
53
|
+
lines.push(`Format: ${formatFieldFormat(field.format)}`);
|
|
54
|
+
lines.push(`Preview: ${field.preview ?? "(no value)"}`);
|
|
55
|
+
lines.push(`Raw value hex: ${field.rawValueHex ?? "none"}`);
|
|
56
|
+
}
|
|
57
|
+
for (const mutation of pendingMutations) {
|
|
58
|
+
lines.push(`Pending field mutation: ${mutation.kind} ${mutation.status}`);
|
|
59
|
+
}
|
|
60
|
+
return lines.join("\n");
|
|
61
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getBalance } from "@cogcoin/indexer/queries";
|
|
2
|
+
import { appendWalletAvailability } from "./availability.js";
|
|
3
|
+
import { formatCogAmount } from "./shared.js";
|
|
4
|
+
export function formatIdentityListReport(context, _options = {}) {
|
|
5
|
+
const lines = ["Wallet Address"];
|
|
6
|
+
if (context.model === null) {
|
|
7
|
+
appendWalletAvailability(lines, context);
|
|
8
|
+
return lines.join("\n");
|
|
9
|
+
}
|
|
10
|
+
const domains = context.model.domains
|
|
11
|
+
.filter((domain) => domain.localRelationship === "local")
|
|
12
|
+
.map((domain) => domain.name)
|
|
13
|
+
.sort();
|
|
14
|
+
const balance = context.snapshot === null
|
|
15
|
+
? null
|
|
16
|
+
: getBalance(context.snapshot.state, new Uint8Array(Buffer.from(context.model.walletScriptPubKeyHex, "hex")));
|
|
17
|
+
lines.push(`${context.model.walletAddress ?? `spk:${context.model.walletScriptPubKeyHex}`} balance ${balance === null ? "unavailable" : formatCogAmount(balance)} domains ${domains.length === 0 ? "none" : domains.join(", ")}`);
|
|
18
|
+
return lines.join("\n");
|
|
19
|
+
}
|