@cogcoin/client 0.5.15 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/README.md +80 -25
  2. package/dist/app-paths.d.ts +5 -6
  3. package/dist/app-paths.js +8 -16
  4. package/dist/art/balance.txt +10 -0
  5. package/dist/art/welcome.txt +16 -0
  6. package/dist/bitcoind/bootstrap/controller.d.ts +1 -0
  7. package/dist/bitcoind/bootstrap/controller.js +53 -1
  8. package/dist/bitcoind/client/follow-block-times.d.ts +1 -0
  9. package/dist/bitcoind/client/follow-block-times.js +1 -1
  10. package/dist/bitcoind/client/internal-types.d.ts +7 -3
  11. package/dist/bitcoind/client/managed-client.d.ts +4 -2
  12. package/dist/bitcoind/client/managed-client.js +14 -0
  13. package/dist/bitcoind/client/sync-engine.js +72 -11
  14. package/dist/bitcoind/hash-order.d.ts +4 -0
  15. package/dist/bitcoind/hash-order.js +13 -0
  16. package/dist/bitcoind/indexer-daemon-main.js +11 -3
  17. package/dist/bitcoind/normalize.js +3 -2
  18. package/dist/bitcoind/processing-start-height.d.ts +5 -0
  19. package/dist/bitcoind/processing-start-height.js +7 -0
  20. package/dist/bitcoind/progress/constants.d.ts +4 -0
  21. package/dist/bitcoind/progress/constants.js +4 -0
  22. package/dist/bitcoind/progress/controller.d.ts +2 -1
  23. package/dist/bitcoind/progress/controller.js +3 -3
  24. package/dist/bitcoind/progress/follow-scene.d.ts +6 -2
  25. package/dist/bitcoind/progress/follow-scene.js +29 -6
  26. package/dist/bitcoind/progress/formatting.d.ts +1 -0
  27. package/dist/bitcoind/progress/formatting.js +6 -0
  28. package/dist/bitcoind/progress/train-scene.js +37 -18
  29. package/dist/bitcoind/progress/tty-renderer.d.ts +6 -1
  30. package/dist/bitcoind/progress/tty-renderer.js +8 -4
  31. package/dist/bitcoind/rpc.d.ts +2 -1
  32. package/dist/bitcoind/rpc.js +3 -0
  33. package/dist/bitcoind/types.d.ts +6 -0
  34. package/dist/bytes.d.ts +1 -0
  35. package/dist/bytes.js +3 -0
  36. package/dist/cli/art.d.ts +2 -0
  37. package/dist/cli/art.js +37 -0
  38. package/dist/cli/commands/client-admin.d.ts +2 -0
  39. package/dist/cli/commands/client-admin.js +91 -0
  40. package/dist/cli/commands/follow.js +0 -2
  41. package/dist/cli/commands/mining-admin.js +6 -47
  42. package/dist/cli/commands/mining-read.js +11 -50
  43. package/dist/cli/commands/mining-runtime.js +142 -5
  44. package/dist/cli/commands/service-runtime.js +0 -2
  45. package/dist/cli/commands/status.js +8 -2
  46. package/dist/cli/commands/sync.js +49 -92
  47. package/dist/cli/commands/wallet-admin.js +142 -136
  48. package/dist/cli/commands/wallet-mutation.js +91 -79
  49. package/dist/cli/commands/wallet-read.js +15 -18
  50. package/dist/cli/context.js +5 -14
  51. package/dist/cli/mining-format.d.ts +0 -1
  52. package/dist/cli/mining-format.js +5 -37
  53. package/dist/cli/mining-json.d.ts +0 -18
  54. package/dist/cli/mining-json.js +0 -35
  55. package/dist/cli/mutation-command-groups.d.ts +1 -2
  56. package/dist/cli/mutation-command-groups.js +0 -5
  57. package/dist/cli/mutation-json.d.ts +24 -145
  58. package/dist/cli/mutation-json.js +30 -136
  59. package/dist/cli/mutation-resolved-json.d.ts +0 -7
  60. package/dist/cli/mutation-resolved-json.js +4 -10
  61. package/dist/cli/mutation-success.d.ts +2 -0
  62. package/dist/cli/mutation-success.js +11 -1
  63. package/dist/cli/mutation-text-format.js +1 -3
  64. package/dist/cli/output.d.ts +1 -1
  65. package/dist/cli/output.js +254 -231
  66. package/dist/cli/parse.d.ts +1 -1
  67. package/dist/cli/parse.js +93 -122
  68. package/dist/cli/preview-json.d.ts +17 -120
  69. package/dist/cli/preview-json.js +14 -97
  70. package/dist/cli/prompt.js +8 -13
  71. package/dist/cli/read-json.d.ts +15 -37
  72. package/dist/cli/read-json.js +44 -140
  73. package/dist/cli/runner.js +10 -13
  74. package/dist/cli/sync-progress.d.ts +6 -0
  75. package/dist/cli/sync-progress.js +91 -0
  76. package/dist/cli/types.d.ts +9 -17
  77. package/dist/cli/types.js +0 -2
  78. package/dist/cli/wallet-format.d.ts +1 -0
  79. package/dist/cli/wallet-format.js +208 -144
  80. package/dist/cli/workflow-hints.d.ts +3 -3
  81. package/dist/cli/workflow-hints.js +11 -8
  82. package/dist/client/default-client.d.ts +3 -1
  83. package/dist/client/default-client.js +45 -2
  84. package/dist/client/factory.js +1 -1
  85. package/dist/client/initialization.js +23 -0
  86. package/dist/client/persistence.js +5 -5
  87. package/dist/client/store-adapter.js +1 -0
  88. package/dist/sqlite/checkpoints.d.ts +1 -0
  89. package/dist/sqlite/checkpoints.js +7 -0
  90. package/dist/sqlite/store.js +14 -1
  91. package/dist/types.d.ts +1 -0
  92. package/dist/wallet/coin-control.d.ts +41 -12
  93. package/dist/wallet/coin-control.js +100 -428
  94. package/dist/wallet/descriptor-normalization.d.ts +1 -3
  95. package/dist/wallet/descriptor-normalization.js +0 -16
  96. package/dist/wallet/lifecycle.d.ts +7 -99
  97. package/dist/wallet/lifecycle.js +513 -968
  98. package/dist/wallet/managed-core-wallet.d.ts +13 -0
  99. package/dist/wallet/managed-core-wallet.js +20 -0
  100. package/dist/wallet/mining/constants.d.ts +5 -12
  101. package/dist/wallet/mining/constants.js +5 -12
  102. package/dist/wallet/mining/control.d.ts +1 -13
  103. package/dist/wallet/mining/control.js +45 -349
  104. package/dist/wallet/mining/index.d.ts +4 -5
  105. package/dist/wallet/mining/index.js +2 -3
  106. package/dist/wallet/mining/runner.d.ts +123 -13
  107. package/dist/wallet/mining/runner.js +899 -511
  108. package/dist/wallet/mining/runtime-artifacts.js +23 -3
  109. package/dist/wallet/mining/sentence-protocol.d.ts +44 -0
  110. package/dist/wallet/mining/sentence-protocol.js +123 -0
  111. package/dist/wallet/mining/sentences.d.ts +4 -8
  112. package/dist/wallet/mining/sentences.js +3 -52
  113. package/dist/wallet/mining/state.d.ts +11 -6
  114. package/dist/wallet/mining/state.js +7 -6
  115. package/dist/wallet/mining/types.d.ts +2 -30
  116. package/dist/wallet/mining/visualizer.d.ts +31 -3
  117. package/dist/wallet/mining/visualizer.js +135 -13
  118. package/dist/wallet/read/context.d.ts +0 -2
  119. package/dist/wallet/read/context.js +119 -140
  120. package/dist/wallet/read/filter.js +2 -11
  121. package/dist/wallet/read/index.d.ts +1 -1
  122. package/dist/wallet/read/project.js +24 -77
  123. package/dist/wallet/read/types.d.ts +10 -25
  124. package/dist/wallet/reset.d.ts +0 -1
  125. package/dist/wallet/reset.js +60 -138
  126. package/dist/wallet/root-resolution.d.ts +1 -5
  127. package/dist/wallet/root-resolution.js +0 -18
  128. package/dist/wallet/runtime.d.ts +0 -6
  129. package/dist/wallet/runtime.js +0 -8
  130. package/dist/wallet/state/client-password-agent.js +208 -0
  131. package/dist/wallet/state/client-password.d.ts +65 -0
  132. package/dist/wallet/state/client-password.js +952 -0
  133. package/dist/wallet/state/crypto.d.ts +1 -20
  134. package/dist/wallet/state/crypto.js +0 -63
  135. package/dist/wallet/state/provider.d.ts +23 -11
  136. package/dist/wallet/state/provider.js +248 -290
  137. package/dist/wallet/state/storage.d.ts +2 -2
  138. package/dist/wallet/state/storage.js +48 -16
  139. package/dist/wallet/tx/anchor.d.ts +3 -28
  140. package/dist/wallet/tx/anchor.js +349 -1250
  141. package/dist/wallet/tx/bitcoin-transfer.d.ts +35 -0
  142. package/dist/wallet/tx/bitcoin-transfer.js +200 -0
  143. package/dist/wallet/tx/cog.d.ts +5 -1
  144. package/dist/wallet/tx/cog.js +149 -185
  145. package/dist/wallet/tx/common.d.ts +61 -8
  146. package/dist/wallet/tx/common.js +266 -146
  147. package/dist/wallet/tx/domain-admin.d.ts +3 -1
  148. package/dist/wallet/tx/domain-admin.js +61 -99
  149. package/dist/wallet/tx/domain-market.d.ts +5 -1
  150. package/dist/wallet/tx/domain-market.js +221 -228
  151. package/dist/wallet/tx/field.d.ts +4 -10
  152. package/dist/wallet/tx/field.js +83 -924
  153. package/dist/wallet/tx/identity-selector.d.ts +9 -3
  154. package/dist/wallet/tx/identity-selector.js +17 -35
  155. package/dist/wallet/tx/index.d.ts +3 -1
  156. package/dist/wallet/tx/index.js +2 -1
  157. package/dist/wallet/tx/register.d.ts +3 -1
  158. package/dist/wallet/tx/register.js +62 -220
  159. package/dist/wallet/tx/reputation.d.ts +3 -1
  160. package/dist/wallet/tx/reputation.js +58 -95
  161. package/dist/wallet/types.d.ts +8 -122
  162. package/package.json +5 -5
  163. package/dist/wallet/archive.d.ts +0 -4
  164. package/dist/wallet/archive.js +0 -41
  165. package/dist/wallet/mining/hook-protocol.d.ts +0 -47
  166. package/dist/wallet/mining/hook-protocol.js +0 -161
  167. package/dist/wallet/mining/hook-runner.js +0 -52
  168. package/dist/wallet/mining/hooks.d.ts +0 -38
  169. package/dist/wallet/mining/hooks.js +0 -520
  170. package/dist/wallet/state/explicit-lock.d.ts +0 -4
  171. package/dist/wallet/state/explicit-lock.js +0 -19
  172. package/dist/wallet/state/session.d.ts +0 -12
  173. package/dist/wallet/state/session.js +0 -23
  174. /package/dist/wallet/{mining/hook-runner.d.ts → state/client-password-agent.d.ts} +0 -0
@@ -16,23 +16,7 @@ export function buildSingleTxMutationData(options) {
16
16
  intentFingerprintHex: options.intentFingerprintHex ?? null,
17
17
  },
18
18
  transaction: normalizeTxSummary(options.txid, options.wtxid),
19
- intent: options.intent,
20
- };
21
- }
22
- export function buildFamilyMutationData(options) {
23
- return {
24
- resultType: "family-mutation",
25
- family: {
26
- kind: options.familyKind,
27
- localStatus: options.familyStatus,
28
- reusedExisting: options.reusedExisting,
29
- currentStep: options.currentStep ?? null,
30
- intentFingerprintHex: options.intentFingerprintHex ?? null,
31
- },
32
- transactions: {
33
- tx1: normalizeTxSummary(options.tx1Txid, options.tx1Wtxid),
34
- tx2: normalizeTxSummary(options.tx2Txid, options.tx2Wtxid),
35
- },
19
+ fees: options.fees,
36
20
  intent: options.intent,
37
21
  };
38
22
  }
@@ -57,6 +41,22 @@ export function buildOperationData(options) {
57
41
  state: options.state ?? null,
58
42
  };
59
43
  }
44
+ export function buildBitcoinTransferData(result) {
45
+ return buildOperationData({
46
+ kind: "bitcoin-transfer",
47
+ state: null,
48
+ operation: {
49
+ amountSats: result.amountSats.toString(),
50
+ feeSats: result.feeSats.toString(),
51
+ senderAddress: result.senderAddress,
52
+ recipientAddress: result.recipientAddress,
53
+ recipientScriptPubKeyHex: result.recipientScriptPubKeyHex,
54
+ changeAddress: result.changeAddress,
55
+ txid: result.txid,
56
+ wtxid: result.wtxid,
57
+ },
58
+ });
59
+ }
60
60
  export function buildRegisterMutationData(result, options) {
61
61
  return {
62
62
  ...buildSingleTxMutationData({
@@ -64,11 +64,11 @@ export function buildRegisterMutationData(result, options) {
64
64
  localStatus: result.status,
65
65
  txid: result.txid,
66
66
  reusedExisting: result.reusedExisting,
67
+ fees: result.fees,
67
68
  intent: {
68
69
  domainName: result.domainName,
69
70
  registerKind: result.registerKind,
70
71
  forceRace: options.forceRace,
71
- fromIdentitySelector: options.fromIdentity,
72
72
  },
73
73
  }),
74
74
  resolved: buildRegisterResolvedJson(result),
@@ -80,14 +80,12 @@ export function buildDomainMarketMutationData(result, options) {
80
80
  listedPriceCogtoshi: decimalOrNull(result.listedPriceCogtoshi),
81
81
  recipientScriptPubKeyHex: result.recipientScriptPubKeyHex ?? null,
82
82
  };
83
- if (options.commandKind === "buy") {
84
- intent.fromIdentitySelector = options.fromIdentity ?? null;
85
- }
86
83
  const data = buildSingleTxMutationData({
87
84
  kind: options.commandKind,
88
85
  localStatus: result.status,
89
86
  txid: result.txid,
90
87
  reusedExisting: result.reusedExisting,
88
+ fees: result.fees,
91
89
  intent,
92
90
  journalKind: result.kind,
93
91
  });
@@ -108,12 +106,12 @@ export function buildCogMutationData(result, options) {
108
106
  localStatus: result.status,
109
107
  txid: result.txid,
110
108
  reusedExisting: result.reusedExisting,
109
+ fees: result.fees,
111
110
  intent: {
112
111
  amountCogtoshi: decimalOrNull(result.amountCogtoshi),
113
112
  recipientScriptPubKeyHex: result.recipientScriptPubKeyHex ?? null,
114
113
  recipientDomainName: result.recipientDomainName ?? null,
115
114
  lockId: result.lockId ?? null,
116
- fromIdentitySelector: options.fromIdentity,
117
115
  timeoutBlocksOrDuration: options.timeoutBlocksOrDuration ?? null,
118
116
  timeoutHeight: options.timeoutHeight ?? null,
119
117
  conditionHex: options.conditionHex ?? null,
@@ -126,50 +124,18 @@ export function buildCogMutationData(result, options) {
126
124
  };
127
125
  }
128
126
  export function buildAnchorMutationData(result, options) {
129
- return buildFamilyMutationData({
130
- familyKind: "anchor",
131
- familyStatus: result.status,
127
+ return buildSingleTxMutationData({
128
+ kind: "anchor",
129
+ localStatus: result.status,
130
+ txid: result.txid,
132
131
  reusedExisting: result.reusedExisting,
133
- currentStep: result.status === "confirmed" ? "confirmed" : "submitted",
134
- tx1Txid: result.tx1Txid,
135
- tx2Txid: result.tx2Txid,
132
+ fees: result.fees,
136
133
  intent: {
137
134
  domainName: result.domainName,
138
- dedicatedIndex: result.dedicatedIndex,
139
135
  foundingMessageIncluded: options.foundingMessageText !== null,
140
136
  },
141
137
  });
142
138
  }
143
- export function buildAnchorClearMutationData(result) {
144
- const before = result.cleared
145
- ? {
146
- localAnchorIntent: "reserved",
147
- dedicatedIndex: result.releasedDedicatedIndex,
148
- familyStatus: result.previousFamilyStatus,
149
- familyStep: result.previousFamilyStep,
150
- }
151
- : null;
152
- const after = result.cleared
153
- ? {
154
- localAnchorIntent: "none",
155
- dedicatedIndex: null,
156
- familyStatus: "canceled",
157
- familyStep: result.previousFamilyStep,
158
- }
159
- : null;
160
- return buildStateChangeData({
161
- kind: "anchor-clear",
162
- state: {
163
- domainName: result.domainName,
164
- cleared: result.cleared,
165
- previousFamilyStatus: result.previousFamilyStatus,
166
- previousFamilyStep: result.previousFamilyStep,
167
- releasedDedicatedIndex: result.releasedDedicatedIndex,
168
- },
169
- before,
170
- after,
171
- });
172
- }
173
139
  export function buildResetMutationData(result) {
174
140
  return buildOperationData({
175
141
  kind: "reset",
@@ -222,6 +188,7 @@ export function buildDomainAdminMutationData(result, options) {
222
188
  localStatus: result.status,
223
189
  txid: result.txid,
224
190
  reusedExisting: result.reusedExisting,
191
+ fees: result.fees,
225
192
  intent: {
226
193
  domainName: result.domainName,
227
194
  recipientScriptPubKeyHex: result.recipientScriptPubKeyHex ?? null,
@@ -238,32 +205,13 @@ export function buildDomainAdminMutationData(result, options) {
238
205
  };
239
206
  }
240
207
  export function buildFieldMutationData(result) {
241
- if (result.family) {
242
- return {
243
- ...buildFamilyMutationData({
244
- familyKind: "field",
245
- familyStatus: result.status,
246
- reusedExisting: result.reusedExisting,
247
- currentStep: result.status === "confirmed" ? "confirmed" : "submitted",
248
- tx1Txid: result.tx1Txid ?? null,
249
- tx2Txid: result.tx2Txid ?? null,
250
- intent: {
251
- domainName: result.domainName,
252
- fieldName: result.fieldName,
253
- expectedFieldId: result.fieldId,
254
- permanent: result.permanent,
255
- format: result.format,
256
- },
257
- }),
258
- resolved: buildFieldResolvedJson(result),
259
- };
260
- }
261
208
  return {
262
209
  ...buildSingleTxMutationData({
263
210
  kind: result.kind,
264
211
  localStatus: result.status,
265
212
  txid: result.txid,
266
213
  reusedExisting: result.reusedExisting,
214
+ fees: result.fees,
267
215
  intent: {
268
216
  domainName: result.domainName,
269
217
  fieldName: result.fieldName,
@@ -281,6 +229,7 @@ export function buildReputationMutationData(result) {
281
229
  localStatus: result.status,
282
230
  txid: result.txid,
283
231
  reusedExisting: result.reusedExisting,
232
+ fees: result.fees,
284
233
  intent: {
285
234
  sourceDomainName: result.sourceDomainName,
286
235
  targetDomainName: result.targetDomainName,
@@ -293,24 +242,13 @@ export function buildReputationMutationData(result) {
293
242
  resolved: buildReputationResolvedJson(result),
294
243
  };
295
244
  }
296
- export function buildWalletLockMutationData(result) {
297
- const after = {
298
- walletRootId: result.walletRootId,
299
- locked: true,
300
- };
301
- return buildStateChangeData({
302
- kind: "wallet-lock",
303
- state: after,
304
- after,
305
- });
306
- }
307
245
  export function buildInitMutationData(result) {
308
246
  const after = {
309
247
  seedName: "main",
248
+ passwordAction: result.passwordAction,
249
+ walletAction: result.walletAction,
310
250
  walletRootId: result.walletRootId,
311
251
  fundingAddress: result.fundingAddress,
312
- unlockUntilUnixMs: result.unlockUntilUnixMs,
313
- locked: false,
314
252
  };
315
253
  return buildStateChangeData({
316
254
  kind: "init",
@@ -324,8 +262,6 @@ export function buildRestoreMutationData(result) {
324
262
  seedName: result.seedName ?? null,
325
263
  walletRootId: result.walletRootId,
326
264
  fundingAddress: result.fundingAddress,
327
- unlockUntilUnixMs: result.unlockUntilUnixMs,
328
- locked: false,
329
265
  };
330
266
  return buildStateChangeData({
331
267
  kind: "restore",
@@ -333,48 +269,6 @@ export function buildRestoreMutationData(result) {
333
269
  after,
334
270
  });
335
271
  }
336
- export function buildUnlockMutationData(result) {
337
- const after = {
338
- walletRootId: result.state.walletRootId,
339
- locked: false,
340
- unlockUntilUnixMs: result.unlockUntilUnixMs,
341
- fundingAddress: result.state.funding.address,
342
- source: result.source,
343
- };
344
- return buildStateChangeData({
345
- kind: "unlock",
346
- state: after,
347
- after,
348
- });
349
- }
350
- export function buildWalletExportMutationData(result) {
351
- const state = {
352
- walletRootId: result.walletRootId,
353
- archivePath: result.archivePath,
354
- };
355
- return buildOperationData({
356
- kind: "wallet-export",
357
- state,
358
- operation: {
359
- walletRootId: result.walletRootId,
360
- archivePath: result.archivePath,
361
- exportMode: "trusted-quiescent",
362
- },
363
- });
364
- }
365
- export function buildWalletImportMutationData(result) {
366
- const after = {
367
- walletRootId: result.walletRootId,
368
- archivePath: result.archivePath,
369
- fundingAddress: result.fundingAddress,
370
- unlockUntilUnixMs: result.unlockUntilUnixMs,
371
- };
372
- return buildStateChangeData({
373
- kind: "wallet-import",
374
- state: after,
375
- after,
376
- });
377
- }
378
272
  export function buildRepairMutationData(result) {
379
273
  const after = {
380
274
  walletRootId: result.walletRootId,
@@ -94,15 +94,8 @@ export declare function buildFieldResolvedJson(result: FieldMutationResult): {
94
94
  byteLength: number;
95
95
  } | null;
96
96
  effect: {
97
- kind: "create-and-initialize-field";
98
- tx1BurnCogtoshi: "100";
99
- tx2AdditionalBurnCogtoshi: "1";
100
- burnCogtoshi?: undefined;
101
- } | {
102
97
  kind: "create-empty-field" | "write-field-value" | "clear-field-value";
103
98
  burnCogtoshi: "0" | "1" | "100";
104
- tx1BurnCogtoshi?: undefined;
105
- tx2AdditionalBurnCogtoshi?: undefined;
106
99
  };
107
100
  } | null;
108
101
  export declare function buildReputationResolvedJson(result: ReputationMutationResult): {
@@ -98,16 +98,10 @@ export function buildFieldResolvedJson(result) {
98
98
  format: result.resolved.value.format,
99
99
  byteLength: result.resolved.value.byteLength,
100
100
  },
101
- effect: result.resolved.effect.kind === "create-and-initialize-field"
102
- ? {
103
- kind: result.resolved.effect.kind,
104
- tx1BurnCogtoshi: result.resolved.effect.tx1BurnCogtoshi,
105
- tx2AdditionalBurnCogtoshi: result.resolved.effect.tx2AdditionalBurnCogtoshi,
106
- }
107
- : {
108
- kind: result.resolved.effect.kind,
109
- burnCogtoshi: result.resolved.effect.burnCogtoshi,
110
- },
101
+ effect: {
102
+ kind: result.resolved.effect.kind,
103
+ burnCogtoshi: result.resolved.effect.burnCogtoshi,
104
+ },
111
105
  };
112
106
  }
113
107
  export function buildReputationResolvedJson(result) {
@@ -1,3 +1,4 @@
1
+ import { type WalletMutationFeeSummary } from "../wallet/tx/common.js";
1
2
  import { type MutationTextField } from "./mutation-text-write.js";
2
3
  import type { ParsedCliArgs, RequiredCliRunnerContext } from "./types.js";
3
4
  export interface MutationSuccessNextSteps {
@@ -11,6 +12,7 @@ export declare function writeMutationCommandSuccess(parsed: ParsedCliArgs, conte
11
12
  previewData?: unknown;
12
13
  reusedExisting: boolean;
13
14
  reusedMessage: string;
15
+ fees?: WalletMutationFeeSummary | null;
14
16
  interactive?: boolean;
15
17
  explorerTxid?: string | null;
16
18
  nextSteps: MutationSuccessNextSteps;
@@ -1,3 +1,4 @@
1
+ import { formatSatVb, } from "../wallet/tx/common.js";
1
2
  import { createPreviewSuccessEnvelope, createMutationSuccessEnvelope, describeCanonicalCommand, resolvePreviewJsonSchema, resolveStableMutationJsonSchema, writeJsonValue, } from "./output.js";
2
3
  import { writeMutationTextResult, } from "./mutation-text-write.js";
3
4
  import { formatNextStepLines } from "./workflow-hints.js";
@@ -19,6 +20,15 @@ function mutationOutcome(reusedExisting) {
19
20
  function reuseExplanation(reusedExisting, message) {
20
21
  return reusedExisting ? [message] : [];
21
22
  }
23
+ function feeFields(fees) {
24
+ if (fees == null) {
25
+ return [];
26
+ }
27
+ return [
28
+ { label: "Fee rate", value: `${formatSatVb(fees.feeRateSatVb)} sat/vB` },
29
+ { label: "Fee", value: `${fees.feeSats} sats`, when: fees.feeSats !== null },
30
+ ];
31
+ }
22
32
  export function writeMutationCommandSuccess(parsed, context, options) {
23
33
  if (parsed.outputMode === "preview-json") {
24
34
  writeJsonValue(context.stdout, createPreviewSuccessEnvelope(resolvePreviewJsonSchema(parsed), describeCanonicalCommand(parsed), options.outcome ?? mutationOutcome(options.reusedExisting), options.previewData ?? options.data, {
@@ -38,7 +48,7 @@ export function writeMutationCommandSuccess(parsed, context, options) {
38
48
  }
39
49
  writeMutationTextResult(context.stdout, {
40
50
  heading: options.text.heading,
41
- fields: options.text.fields,
51
+ fields: [...options.text.fields, ...feeFields(options.fees)],
42
52
  reusedExisting: options.reusedExisting,
43
53
  reusedMessage: options.reusedMessage,
44
54
  trailerLines: options.nextSteps.text,
@@ -6,7 +6,7 @@ export function formatRegisterEconomicEffect(result) {
6
6
  if (result.resolved.economicEffect.kind === "treasury-payment") {
7
7
  return `send ${result.resolved.economicEffect.amount.toString()} sats to the Cogcoin treasury`;
8
8
  }
9
- return `burn ${formatCogAmount(result.resolved.economicEffect.amount)} from the parent-owner identity`;
9
+ return `burn ${formatCogAmount(result.resolved.economicEffect.amount)} from the parent owner`;
10
10
  }
11
11
  export function formatBuyBuyerSummary(result) {
12
12
  if (result.resolvedBuyer === null || result.resolvedBuyer === undefined) {
@@ -130,8 +130,6 @@ export function formatFieldEffect(result) {
130
130
  switch (effect.kind) {
131
131
  case "create-empty-field":
132
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
133
  case "write-field-value":
136
134
  return `burn ${effect.burnCogtoshi} cogtoshi to write the field value`;
137
135
  case "clear-field-value":
@@ -163,7 +163,7 @@ export declare function classifyCliError(error: unknown): {
163
163
  message: string;
164
164
  };
165
165
  export declare function formatCliTextError(error: unknown): string[] | null;
166
- export declare function createCliErrorPresentation(errorCode: string, fallbackMessage: string): {
166
+ export declare function createCliErrorPresentation(errorCode: string, fallbackMessage: string, error?: unknown): {
167
167
  what: string;
168
168
  why: string | null;
169
169
  next: string | null;