@shieldedtech/moth-wallet 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/README.md +62 -0
  2. package/dist/contract/args-parser.d.ts +29 -0
  3. package/dist/contract/args-parser.d.ts.map +1 -0
  4. package/dist/contract/args-parser.js +123 -0
  5. package/dist/contract/args-parser.js.map +1 -0
  6. package/dist/contract/artifact-loader.d.ts +26 -0
  7. package/dist/contract/artifact-loader.d.ts.map +1 -0
  8. package/dist/contract/artifact-loader.js +129 -0
  9. package/dist/contract/artifact-loader.js.map +1 -0
  10. package/dist/contract/call.d.ts +32 -0
  11. package/dist/contract/call.d.ts.map +1 -0
  12. package/dist/contract/call.js +245 -0
  13. package/dist/contract/call.js.map +1 -0
  14. package/dist/contract/deploy.d.ts +36 -0
  15. package/dist/contract/deploy.d.ts.map +1 -0
  16. package/dist/contract/deploy.js +388 -0
  17. package/dist/contract/deploy.js.map +1 -0
  18. package/dist/contract/fungible-token.d.ts +40 -0
  19. package/dist/contract/fungible-token.d.ts.map +1 -0
  20. package/dist/contract/fungible-token.js +88 -0
  21. package/dist/contract/fungible-token.js.map +1 -0
  22. package/dist/contract/initial-private-state.d.ts +18 -0
  23. package/dist/contract/initial-private-state.d.ts.map +1 -0
  24. package/dist/contract/initial-private-state.js +44 -0
  25. package/dist/contract/initial-private-state.js.map +1 -0
  26. package/dist/contract/maintenance.d.ts +72 -0
  27. package/dist/contract/maintenance.d.ts.map +1 -0
  28. package/dist/contract/maintenance.js +430 -0
  29. package/dist/contract/maintenance.js.map +1 -0
  30. package/dist/contract/state.d.ts +16 -0
  31. package/dist/contract/state.d.ts.map +1 -0
  32. package/dist/contract/state.js +18 -0
  33. package/dist/contract/state.js.map +1 -0
  34. package/dist/contract/witness-loader.d.ts +3 -0
  35. package/dist/contract/witness-loader.d.ts.map +1 -0
  36. package/dist/contract/witness-loader.js +27 -0
  37. package/dist/contract/witness-loader.js.map +1 -0
  38. package/dist/daemon/api-keys.d.ts +66 -0
  39. package/dist/daemon/api-keys.d.ts.map +1 -0
  40. package/dist/daemon/api-keys.js +222 -0
  41. package/dist/daemon/api-keys.js.map +1 -0
  42. package/dist/daemon/audit-log.d.ts +65 -0
  43. package/dist/daemon/audit-log.d.ts.map +1 -0
  44. package/dist/daemon/audit-log.js +73 -0
  45. package/dist/daemon/audit-log.js.map +1 -0
  46. package/dist/daemon/client.d.ts +63 -0
  47. package/dist/daemon/client.d.ts.map +1 -0
  48. package/dist/daemon/client.js +214 -0
  49. package/dist/daemon/client.js.map +1 -0
  50. package/dist/daemon/confirmation-queue.d.ts +46 -0
  51. package/dist/daemon/confirmation-queue.d.ts.map +1 -0
  52. package/dist/daemon/confirmation-queue.js +92 -0
  53. package/dist/daemon/confirmation-queue.js.map +1 -0
  54. package/dist/daemon/index.d.ts +23 -0
  55. package/dist/daemon/index.d.ts.map +1 -0
  56. package/dist/daemon/index.js +26 -0
  57. package/dist/daemon/index.js.map +1 -0
  58. package/dist/daemon/protocol.d.ts +40 -0
  59. package/dist/daemon/protocol.d.ts.map +1 -0
  60. package/dist/daemon/protocol.js +104 -0
  61. package/dist/daemon/protocol.js.map +1 -0
  62. package/dist/daemon/server.d.ts +158 -0
  63. package/dist/daemon/server.d.ts.map +1 -0
  64. package/dist/daemon/server.js +297 -0
  65. package/dist/daemon/server.js.map +1 -0
  66. package/dist/daemon/wallet-handlers.d.ts +37 -0
  67. package/dist/daemon/wallet-handlers.d.ts.map +1 -0
  68. package/dist/daemon/wallet-handlers.js +533 -0
  69. package/dist/daemon/wallet-handlers.js.map +1 -0
  70. package/dist/daemon/wallet-rpc-parsers.d.ts +14 -0
  71. package/dist/daemon/wallet-rpc-parsers.d.ts.map +1 -0
  72. package/dist/daemon/wallet-rpc-parsers.js +259 -0
  73. package/dist/daemon/wallet-rpc-parsers.js.map +1 -0
  74. package/dist/daemon/wallet-rpc-types.d.ts +138 -0
  75. package/dist/daemon/wallet-rpc-types.d.ts.map +1 -0
  76. package/dist/daemon/wallet-rpc-types.js +11 -0
  77. package/dist/daemon/wallet-rpc-types.js.map +1 -0
  78. package/dist/diagnostics/fs-timing-store.d.ts +29 -0
  79. package/dist/diagnostics/fs-timing-store.d.ts.map +1 -0
  80. package/dist/diagnostics/fs-timing-store.js +81 -0
  81. package/dist/diagnostics/fs-timing-store.js.map +1 -0
  82. package/dist/diagnostics/timings.d.ts +64 -0
  83. package/dist/diagnostics/timings.d.ts.map +1 -0
  84. package/dist/diagnostics/timings.js +100 -0
  85. package/dist/diagnostics/timings.js.map +1 -0
  86. package/dist/index.d.ts +37 -0
  87. package/dist/index.d.ts.map +1 -0
  88. package/dist/index.js +47 -0
  89. package/dist/index.js.map +1 -0
  90. package/dist/network/indexer-client.d.ts +66 -0
  91. package/dist/network/indexer-client.d.ts.map +1 -0
  92. package/dist/network/indexer-client.js +112 -0
  93. package/dist/network/indexer-client.js.map +1 -0
  94. package/dist/network/node-client.d.ts +27 -0
  95. package/dist/network/node-client.d.ts.map +1 -0
  96. package/dist/network/node-client.js +94 -0
  97. package/dist/network/node-client.js.map +1 -0
  98. package/dist/proof/client.d.ts +15 -0
  99. package/dist/proof/client.d.ts.map +1 -0
  100. package/dist/proof/client.js +77 -0
  101. package/dist/proof/client.js.map +1 -0
  102. package/dist/proof/provider.d.ts +12 -0
  103. package/dist/proof/provider.d.ts.map +1 -0
  104. package/dist/proof/provider.js +96 -0
  105. package/dist/proof/provider.js.map +1 -0
  106. package/dist/providers/index.d.ts +2 -0
  107. package/dist/providers/index.d.ts.map +1 -0
  108. package/dist/providers/index.js +2 -0
  109. package/dist/providers/index.js.map +1 -0
  110. package/dist/providers/midnight-provider.d.ts +11 -0
  111. package/dist/providers/midnight-provider.d.ts.map +1 -0
  112. package/dist/providers/midnight-provider.js +30 -0
  113. package/dist/providers/midnight-provider.js.map +1 -0
  114. package/dist/storage/adapter.d.ts +8 -0
  115. package/dist/storage/adapter.d.ts.map +1 -0
  116. package/dist/storage/adapter.js +2 -0
  117. package/dist/storage/adapter.js.map +1 -0
  118. package/dist/storage/fs-adapter.d.ts +14 -0
  119. package/dist/storage/fs-adapter.d.ts.map +1 -0
  120. package/dist/storage/fs-adapter.js +126 -0
  121. package/dist/storage/fs-adapter.js.map +1 -0
  122. package/dist/storage/safe-path.d.ts +13 -0
  123. package/dist/storage/safe-path.d.ts.map +1 -0
  124. package/dist/storage/safe-path.js +35 -0
  125. package/dist/storage/safe-path.js.map +1 -0
  126. package/dist/sync/activity.d.ts +53 -0
  127. package/dist/sync/activity.d.ts.map +1 -0
  128. package/dist/sync/activity.js +92 -0
  129. package/dist/sync/activity.js.map +1 -0
  130. package/dist/sync/dust-registration-estimate.d.ts +54 -0
  131. package/dist/sync/dust-registration-estimate.d.ts.map +1 -0
  132. package/dist/sync/dust-registration-estimate.js +103 -0
  133. package/dist/sync/dust-registration-estimate.js.map +1 -0
  134. package/dist/sync/node-sync-store.d.ts +10 -0
  135. package/dist/sync/node-sync-store.d.ts.map +1 -0
  136. package/dist/sync/node-sync-store.js +42 -0
  137. package/dist/sync/node-sync-store.js.map +1 -0
  138. package/dist/sync/operations.d.ts +138 -0
  139. package/dist/sync/operations.d.ts.map +1 -0
  140. package/dist/sync/operations.js +395 -0
  141. package/dist/sync/operations.js.map +1 -0
  142. package/dist/sync/preseed-parts.d.ts +18 -0
  143. package/dist/sync/preseed-parts.d.ts.map +1 -0
  144. package/dist/sync/preseed-parts.js +33 -0
  145. package/dist/sync/preseed-parts.js.map +1 -0
  146. package/dist/sync/preseed.d.ts +95 -0
  147. package/dist/sync/preseed.d.ts.map +1 -0
  148. package/dist/sync/preseed.js +365 -0
  149. package/dist/sync/preseed.js.map +1 -0
  150. package/dist/sync/progress.d.ts +45 -0
  151. package/dist/sync/progress.d.ts.map +1 -0
  152. package/dist/sync/progress.js +51 -0
  153. package/dist/sync/progress.js.map +1 -0
  154. package/dist/sync/sdk-dedup.d.ts +53 -0
  155. package/dist/sync/sdk-dedup.d.ts.map +1 -0
  156. package/dist/sync/sdk-dedup.js +134 -0
  157. package/dist/sync/sdk-dedup.js.map +1 -0
  158. package/dist/sync/sync-store.d.ts +33 -0
  159. package/dist/sync/sync-store.d.ts.map +1 -0
  160. package/dist/sync/sync-store.js +45 -0
  161. package/dist/sync/sync-store.js.map +1 -0
  162. package/dist/sync/wallet-sync.d.ts +153 -0
  163. package/dist/sync/wallet-sync.d.ts.map +1 -0
  164. package/dist/sync/wallet-sync.js +943 -0
  165. package/dist/sync/wallet-sync.js.map +1 -0
  166. package/dist/types/errors.d.ts +18 -0
  167. package/dist/types/errors.d.ts.map +1 -0
  168. package/dist/types/errors.js +33 -0
  169. package/dist/types/errors.js.map +1 -0
  170. package/dist/types/exit-codes.d.ts +8 -0
  171. package/dist/types/exit-codes.d.ts.map +1 -0
  172. package/dist/types/exit-codes.js +7 -0
  173. package/dist/types/exit-codes.js.map +1 -0
  174. package/dist/types/index.d.ts +6 -0
  175. package/dist/types/index.d.ts.map +1 -0
  176. package/dist/types/index.js +3 -0
  177. package/dist/types/index.js.map +1 -0
  178. package/dist/types/network.d.ts +65 -0
  179. package/dist/types/network.d.ts.map +1 -0
  180. package/dist/types/network.js +108 -0
  181. package/dist/types/network.js.map +1 -0
  182. package/dist/types/tokens.d.ts +3 -0
  183. package/dist/types/tokens.d.ts.map +1 -0
  184. package/dist/types/tokens.js +11 -0
  185. package/dist/types/tokens.js.map +1 -0
  186. package/dist/types/transaction.d.ts +13 -0
  187. package/dist/types/transaction.d.ts.map +1 -0
  188. package/dist/types/transaction.js +2 -0
  189. package/dist/types/transaction.js.map +1 -0
  190. package/dist/types/wallet.d.ts +82 -0
  191. package/dist/types/wallet.d.ts.map +1 -0
  192. package/dist/types/wallet.js +2 -0
  193. package/dist/types/wallet.js.map +1 -0
  194. package/dist/wallet/address-validate.d.ts +7 -0
  195. package/dist/wallet/address-validate.d.ts.map +1 -0
  196. package/dist/wallet/address-validate.js +28 -0
  197. package/dist/wallet/address-validate.js.map +1 -0
  198. package/dist/wallet/address.d.ts +32 -0
  199. package/dist/wallet/address.d.ts.map +1 -0
  200. package/dist/wallet/address.js +107 -0
  201. package/dist/wallet/address.js.map +1 -0
  202. package/dist/wallet/app-secret.d.ts +15 -0
  203. package/dist/wallet/app-secret.d.ts.map +1 -0
  204. package/dist/wallet/app-secret.js +45 -0
  205. package/dist/wallet/app-secret.js.map +1 -0
  206. package/dist/wallet/balance-format.d.ts +12 -0
  207. package/dist/wallet/balance-format.d.ts.map +1 -0
  208. package/dist/wallet/balance-format.js +51 -0
  209. package/dist/wallet/balance-format.js.map +1 -0
  210. package/dist/wallet/batch-transfer.d.ts +36 -0
  211. package/dist/wallet/batch-transfer.d.ts.map +1 -0
  212. package/dist/wallet/batch-transfer.js +93 -0
  213. package/dist/wallet/batch-transfer.js.map +1 -0
  214. package/dist/wallet/keystore.d.ts +16 -0
  215. package/dist/wallet/keystore.d.ts.map +1 -0
  216. package/dist/wallet/keystore.js +76 -0
  217. package/dist/wallet/keystore.js.map +1 -0
  218. package/dist/wallet/manager.d.ts +77 -0
  219. package/dist/wallet/manager.d.ts.map +1 -0
  220. package/dist/wallet/manager.js +474 -0
  221. package/dist/wallet/manager.js.map +1 -0
  222. package/dist/wallet/mnemonic.d.ts +5 -0
  223. package/dist/wallet/mnemonic.d.ts.map +1 -0
  224. package/dist/wallet/mnemonic.js +28 -0
  225. package/dist/wallet/mnemonic.js.map +1 -0
  226. package/dist/wallet/sign-message.d.ts +20 -0
  227. package/dist/wallet/sign-message.d.ts.map +1 -0
  228. package/dist/wallet/sign-message.js +58 -0
  229. package/dist/wallet/sign-message.js.map +1 -0
  230. package/package.json +55 -0
@@ -0,0 +1,259 @@
1
+ // Wire-format parsers for every wallet daemon verb. Every handler runs
2
+ // its raw `unknown` params through one of these before doing anything
3
+ // else — the daemon should never see an invalid payload past this
4
+ // layer.
5
+ //
6
+ // Reject path: throw DaemonProtocolError with INVALID_PARAMS and a
7
+ // human-readable field name. The server-side dispatcher (server.ts)
8
+ // preserves the code on the wire so clients see INVALID_INPUT, not
9
+ // INTERNAL_ERROR.
10
+ import { DaemonProtocolError } from './protocol.js';
11
+ // ─────────────────────────────────────────────────────────────────────
12
+ // Shared helpers
13
+ // ─────────────────────────────────────────────────────────────────────
14
+ function parseOptionalString(value, fieldName) {
15
+ if (value === undefined || value === null)
16
+ return undefined;
17
+ if (typeof value !== 'string') {
18
+ throw new DaemonProtocolError('INVALID_PARAMS', `${fieldName} must be a string`);
19
+ }
20
+ return value;
21
+ }
22
+ function parseOptionalStringArray(value, fieldName) {
23
+ if (value === undefined || value === null)
24
+ return undefined;
25
+ if (!Array.isArray(value) || !value.every((d) => typeof d === 'string')) {
26
+ throw new DaemonProtocolError('INVALID_PARAMS', `${fieldName} must be an array of strings`);
27
+ }
28
+ return value;
29
+ }
30
+ function requirePositiveTimeoutSec(raw, fieldName) {
31
+ if (raw === undefined)
32
+ return undefined;
33
+ if (typeof raw !== 'number' || !Number.isFinite(raw) || raw <= 0) {
34
+ throw new DaemonProtocolError('INVALID_PARAMS', `${fieldName} must be a positive number`);
35
+ }
36
+ return raw;
37
+ }
38
+ /** Truncate a hex string to <prefix>…<suffix>. */
39
+ export function shortenHex(hex) {
40
+ if (hex.length <= 14)
41
+ return hex;
42
+ return `${hex.slice(0, 8)}…${hex.slice(-4)}`;
43
+ }
44
+ /** Truncate a bech32m-style address. */
45
+ export function shortenAddress(addr) {
46
+ if (addr.length <= 16)
47
+ return addr;
48
+ return `${addr.slice(0, 10)}…${addr.slice(-6)}`;
49
+ }
50
+ // ─────────────────────────────────────────────────────────────────────
51
+ // submitTransaction
52
+ // ─────────────────────────────────────────────────────────────────────
53
+ export function parseSubmitTransactionParams(raw) {
54
+ if (!raw || typeof raw !== 'object') {
55
+ throw new DaemonProtocolError('INVALID_PARAMS', 'submitTransaction params must be an object');
56
+ }
57
+ const p = raw;
58
+ if (typeof p.hex !== 'string' || p.hex.length === 0) {
59
+ throw new DaemonProtocolError('INVALID_PARAMS', 'submitTransaction.hex must be a non-empty hex string');
60
+ }
61
+ if (!/^[0-9a-fA-F]*$/.test(p.hex) || p.hex.length % 2 !== 0) {
62
+ throw new DaemonProtocolError('INVALID_PARAMS', 'submitTransaction.hex must be even-length hex');
63
+ }
64
+ const summary = typeof p.summary === 'string' ? p.summary : undefined;
65
+ const details = parseOptionalStringArray(p.details, 'submitTransaction.details');
66
+ return { hex: p.hex, summary, details };
67
+ }
68
+ // ─────────────────────────────────────────────────────────────────────
69
+ // transferTokens
70
+ // ─────────────────────────────────────────────────────────────────────
71
+ export function parseTransferTokensParams(raw) {
72
+ if (!raw || typeof raw !== 'object') {
73
+ throw new DaemonProtocolError('INVALID_PARAMS', 'transferTokens params must be an object');
74
+ }
75
+ const p = raw;
76
+ if (p.type !== 'shielded' && p.type !== 'unshielded') {
77
+ throw new DaemonProtocolError('INVALID_PARAMS', "transferTokens.type must be 'shielded' or 'unshielded'");
78
+ }
79
+ if (typeof p.tokenId !== 'string' || !/^[0-9a-fA-F]{64}$/.test(p.tokenId)) {
80
+ throw new DaemonProtocolError('INVALID_PARAMS', 'transferTokens.tokenId must be a 64-char hex string');
81
+ }
82
+ if (typeof p.amount !== 'string' || !/^\d+$/.test(p.amount)) {
83
+ throw new DaemonProtocolError('INVALID_PARAMS', 'transferTokens.amount must be a non-negative decimal string');
84
+ }
85
+ let amountBig;
86
+ try {
87
+ amountBig = BigInt(p.amount);
88
+ }
89
+ catch {
90
+ throw new DaemonProtocolError('INVALID_PARAMS', 'transferTokens.amount must be parseable as bigint');
91
+ }
92
+ if (amountBig <= 0n) {
93
+ throw new DaemonProtocolError('INVALID_PARAMS', 'transferTokens.amount must be greater than zero');
94
+ }
95
+ if (typeof p.to !== 'string' || p.to.length === 0) {
96
+ throw new DaemonProtocolError('INVALID_PARAMS', 'transferTokens.to must be a non-empty bech32m address string');
97
+ }
98
+ return {
99
+ type: p.type,
100
+ tokenId: p.tokenId.toLowerCase(),
101
+ amount: p.amount,
102
+ to: p.to,
103
+ summary: typeof p.summary === 'string' ? p.summary : undefined,
104
+ details: parseOptionalStringArray(p.details, 'transferTokens.details'),
105
+ };
106
+ }
107
+ // ─────────────────────────────────────────────────────────────────────
108
+ // callCircuit
109
+ // ─────────────────────────────────────────────────────────────────────
110
+ export function parseCallCircuitParams(raw) {
111
+ if (!raw || typeof raw !== 'object') {
112
+ throw new DaemonProtocolError('INVALID_PARAMS', 'callCircuit params must be an object');
113
+ }
114
+ const p = raw;
115
+ if (typeof p.contractAddress !== 'string' || p.contractAddress.length === 0) {
116
+ throw new DaemonProtocolError('INVALID_PARAMS', 'callCircuit.contractAddress must be a non-empty bech32m string');
117
+ }
118
+ if (typeof p.circuitName !== 'string' || p.circuitName.length === 0) {
119
+ throw new DaemonProtocolError('INVALID_PARAMS', 'callCircuit.circuitName must be a non-empty string');
120
+ }
121
+ if (typeof p.artifactPath !== 'string' || p.artifactPath.length === 0) {
122
+ throw new DaemonProtocolError('INVALID_PARAMS', 'callCircuit.artifactPath must be a non-empty path string');
123
+ }
124
+ return {
125
+ contractAddress: p.contractAddress,
126
+ circuitName: p.circuitName,
127
+ args: parseOptionalString(p.args, 'callCircuit.args'),
128
+ artifactPath: p.artifactPath,
129
+ witnessesPath: parseOptionalString(p.witnessesPath, 'callCircuit.witnessesPath'),
130
+ projectDir: parseOptionalString(p.projectDir, 'callCircuit.projectDir'),
131
+ timeoutSec: requirePositiveTimeoutSec(p.timeoutSec, 'callCircuit.timeoutSec'),
132
+ summary: typeof p.summary === 'string' ? p.summary : undefined,
133
+ details: parseOptionalStringArray(p.details, 'callCircuit.details'),
134
+ };
135
+ }
136
+ // ─────────────────────────────────────────────────────────────────────
137
+ // deployContract
138
+ // ─────────────────────────────────────────────────────────────────────
139
+ export function parseDeployContractParams(raw) {
140
+ if (!raw || typeof raw !== 'object') {
141
+ throw new DaemonProtocolError('INVALID_PARAMS', 'deployContract params must be an object');
142
+ }
143
+ const p = raw;
144
+ if (typeof p.artifactPath !== 'string' || p.artifactPath.length === 0) {
145
+ throw new DaemonProtocolError('INVALID_PARAMS', 'deployContract.artifactPath must be a non-empty path string');
146
+ }
147
+ return {
148
+ artifactPath: p.artifactPath,
149
+ witnessesPath: parseOptionalString(p.witnessesPath, 'deployContract.witnessesPath'),
150
+ projectDir: parseOptionalString(p.projectDir, 'deployContract.projectDir'),
151
+ timeoutSec: requirePositiveTimeoutSec(p.timeoutSec, 'deployContract.timeoutSec'),
152
+ args: parseOptionalString(p.args, 'deployContract.args'),
153
+ privateState: parseOptionalString(p.privateState, 'deployContract.privateState'),
154
+ summary: typeof p.summary === 'string' ? p.summary : undefined,
155
+ details: parseOptionalStringArray(p.details, 'deployContract.details'),
156
+ };
157
+ }
158
+ // ─────────────────────────────────────────────────────────────────────
159
+ // dustRegister / dustDeregister
160
+ // ─────────────────────────────────────────────────────────────────────
161
+ export function parseDustRegisterParams(raw) {
162
+ if (raw === null || raw === undefined)
163
+ return {};
164
+ if (typeof raw !== 'object') {
165
+ throw new DaemonProtocolError('INVALID_PARAMS', 'dustRegister params must be an object or omitted');
166
+ }
167
+ const p = raw;
168
+ const receiver = parseOptionalString(p.receiver, 'dustRegister.receiver');
169
+ if (receiver !== undefined && receiver.length === 0) {
170
+ throw new DaemonProtocolError('INVALID_PARAMS', 'dustRegister.receiver must be a non-empty bech32m string');
171
+ }
172
+ return {
173
+ receiver,
174
+ summary: typeof p.summary === 'string' ? p.summary : undefined,
175
+ details: parseOptionalStringArray(p.details, 'dustRegister.details'),
176
+ };
177
+ }
178
+ export function parseDustDeregisterParams(raw) {
179
+ if (raw === null || raw === undefined)
180
+ return {};
181
+ if (typeof raw !== 'object') {
182
+ throw new DaemonProtocolError('INVALID_PARAMS', 'dustDeregister params must be an object or omitted');
183
+ }
184
+ const p = raw;
185
+ return {
186
+ summary: typeof p.summary === 'string' ? p.summary : undefined,
187
+ details: parseOptionalStringArray(p.details, 'dustDeregister.details'),
188
+ };
189
+ }
190
+ // ─────────────────────────────────────────────────────────────────────
191
+ // insertVerifierKey / insertVerifierKeysBatch
192
+ // ─────────────────────────────────────────────────────────────────────
193
+ export function parseInsertVerifierKeyParams(raw) {
194
+ if (!raw || typeof raw !== 'object') {
195
+ throw new DaemonProtocolError('INVALID_PARAMS', 'insertVerifierKey params must be an object');
196
+ }
197
+ const p = raw;
198
+ if (typeof p.contractAddress !== 'string' || p.contractAddress.length === 0) {
199
+ throw new DaemonProtocolError('INVALID_PARAMS', 'insertVerifierKey.contractAddress must be a non-empty bech32m string');
200
+ }
201
+ if (typeof p.circuitId !== 'string' || p.circuitId.length === 0) {
202
+ throw new DaemonProtocolError('INVALID_PARAMS', 'insertVerifierKey.circuitId must be a non-empty string');
203
+ }
204
+ if (typeof p.verifierKeyPath !== 'string' || p.verifierKeyPath.length === 0) {
205
+ throw new DaemonProtocolError('INVALID_PARAMS', 'insertVerifierKey.verifierKeyPath must be a non-empty path string');
206
+ }
207
+ if (typeof p.artifactPath !== 'string' || p.artifactPath.length === 0) {
208
+ throw new DaemonProtocolError('INVALID_PARAMS', 'insertVerifierKey.artifactPath must be a non-empty path string');
209
+ }
210
+ return {
211
+ contractAddress: p.contractAddress,
212
+ circuitId: p.circuitId,
213
+ verifierKeyPath: p.verifierKeyPath,
214
+ artifactPath: p.artifactPath,
215
+ projectDir: parseOptionalString(p.projectDir, 'insertVerifierKey.projectDir'),
216
+ timeoutSec: requirePositiveTimeoutSec(p.timeoutSec, 'insertVerifierKey.timeoutSec'),
217
+ summary: typeof p.summary === 'string' ? p.summary : undefined,
218
+ details: parseOptionalStringArray(p.details, 'insertVerifierKey.details'),
219
+ };
220
+ }
221
+ export function parseInsertVerifierKeysBatchParams(raw) {
222
+ if (!raw || typeof raw !== 'object') {
223
+ throw new DaemonProtocolError('INVALID_PARAMS', 'insertVerifierKeysBatch params must be an object');
224
+ }
225
+ const p = raw;
226
+ if (typeof p.contractAddress !== 'string' || p.contractAddress.length === 0) {
227
+ throw new DaemonProtocolError('INVALID_PARAMS', 'insertVerifierKeysBatch.contractAddress must be a non-empty bech32m string');
228
+ }
229
+ if (typeof p.artifactPath !== 'string' || p.artifactPath.length === 0) {
230
+ throw new DaemonProtocolError('INVALID_PARAMS', 'insertVerifierKeysBatch.artifactPath must be a non-empty path string');
231
+ }
232
+ if (!Array.isArray(p.entries) || p.entries.length === 0) {
233
+ throw new DaemonProtocolError('INVALID_PARAMS', 'insertVerifierKeysBatch.entries must be a non-empty array');
234
+ }
235
+ const entries = p.entries.map((entry, i) => {
236
+ if (!entry || typeof entry !== 'object') {
237
+ throw new DaemonProtocolError('INVALID_PARAMS', `insertVerifierKeysBatch.entries[${i}] must be an object`);
238
+ }
239
+ const e = entry;
240
+ if (typeof e.circuitId !== 'string' || e.circuitId.length === 0) {
241
+ throw new DaemonProtocolError('INVALID_PARAMS', `insertVerifierKeysBatch.entries[${i}].circuitId must be a non-empty string`);
242
+ }
243
+ if (typeof e.verifierKeyPath !== 'string' || e.verifierKeyPath.length === 0) {
244
+ throw new DaemonProtocolError('INVALID_PARAMS', `insertVerifierKeysBatch.entries[${i}].verifierKeyPath must be a non-empty path string`);
245
+ }
246
+ return { circuitId: e.circuitId, verifierKeyPath: e.verifierKeyPath };
247
+ });
248
+ return {
249
+ contractAddress: p.contractAddress,
250
+ artifactPath: p.artifactPath,
251
+ entries,
252
+ projectDir: parseOptionalString(p.projectDir, 'insertVerifierKeysBatch.projectDir'),
253
+ skipExisting: p.skipExisting === undefined ? undefined : !!p.skipExisting,
254
+ timeoutSec: requirePositiveTimeoutSec(p.timeoutSec, 'insertVerifierKeysBatch.timeoutSec'),
255
+ summary: typeof p.summary === 'string' ? p.summary : undefined,
256
+ details: parseOptionalStringArray(p.details, 'insertVerifierKeysBatch.details'),
257
+ };
258
+ }
259
+ //# sourceMappingURL=wallet-rpc-parsers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet-rpc-parsers.js","sourceRoot":"","sources":["../../src/daemon/wallet-rpc-parsers.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,sEAAsE;AACt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,EAAE,mCAAmC,CAAC,wCAAwC,CAAC,CAAC;QAChI,CAAC;QACD,IAAI,OAAO,CAAC,CAAC,eAAe,KAAK,QAAQ,IAAI,CAAC,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5E,MAAM,IAAI,mBAAmB,CAAC,gBAAgB,EAAE,mCAAmC,CAAC,mDAAmD,CAAC,CAAC;QAC3I,CAAC;QACD,OAAO,EAAC,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC,eAAe,EAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IACH,OAAO;QACL,eAAe,EAAE,CAAC,CAAC,eAAe;QAClC,YAAY,EAAE,CAAC,CAAC,YAAY;QAC5B,OAAO;QACP,UAAU,EAAE,mBAAmB,CAAC,CAAC,CAAC,UAAU,EAAE,oCAAoC,CAAC;QACnF,YAAY,EAAE,CAAC,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY;QACzE,UAAU,EAAE,yBAAyB,CAAC,CAAC,CAAC,UAAU,EAAE,oCAAoC,CAAC;QACzF,OAAO,EAAE,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;QAC9D,OAAO,EAAE,wBAAwB,CAAC,CAAC,CAAC,OAAO,EAAE,iCAAiC,CAAC;KAChF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,138 @@
1
+ import type { SyncProgress, TransactionResult } from '../index.js';
2
+ export type DaemonGetStateResult = {
3
+ readonly ready: boolean;
4
+ readonly walletName?: string;
5
+ readonly networkId?: string;
6
+ readonly synced?: boolean;
7
+ readonly syncProgress?: SyncProgress;
8
+ readonly balances?: {
9
+ readonly shielded: Record<string, string>;
10
+ readonly unshielded: Record<string, string>;
11
+ readonly dust: string;
12
+ };
13
+ };
14
+ export type DaemonSubmitTransactionParams = {
15
+ /** Hex-encoded FinalizedTransaction (output of tx.serialize()). */
16
+ readonly hex: string;
17
+ readonly summary?: string;
18
+ readonly details?: readonly string[];
19
+ };
20
+ export type DaemonSubmitTransactionResult = {
21
+ readonly txId: string;
22
+ };
23
+ export type DaemonTransferTokensParams = {
24
+ readonly type: 'shielded' | 'unshielded';
25
+ /** 64-char hex token id. NIGHT is '0' * 64. */
26
+ readonly tokenId: string;
27
+ /** Raw decimal amount in the token's smallest unit. */
28
+ readonly amount: string;
29
+ readonly to: string;
30
+ readonly summary?: string;
31
+ readonly details?: readonly string[];
32
+ };
33
+ export type DaemonTransferTokensResult = {
34
+ readonly txId: string;
35
+ };
36
+ export type DaemonCallCircuitParams = {
37
+ readonly contractAddress: string;
38
+ readonly circuitName: string;
39
+ /** Raw args string. Daemon parses via parseArgs (accepts JSON inline
40
+ * or '@file.json' from the daemon-host filesystem). */
41
+ readonly args?: string;
42
+ readonly artifactPath: string;
43
+ readonly witnessesPath?: string;
44
+ readonly projectDir?: string;
45
+ readonly timeoutSec?: number;
46
+ readonly summary?: string;
47
+ readonly details?: readonly string[];
48
+ };
49
+ export type DaemonCallCircuitResult = {
50
+ readonly txHash: string;
51
+ readonly status: TransactionResult['status'];
52
+ readonly blockHash: string | null;
53
+ readonly blockHeight: number | null;
54
+ readonly contractAddress: string | null;
55
+ readonly fees: TransactionResult['fees'];
56
+ };
57
+ export type DaemonDeployContractParams = {
58
+ readonly artifactPath: string;
59
+ readonly witnessesPath?: string;
60
+ readonly projectDir?: string;
61
+ readonly timeoutSec?: number;
62
+ /** Constructor arguments as JSON or @file.json (same convention as `deploy --args`). */
63
+ readonly args?: string;
64
+ /** Initial private state as JSON or @file.json (same convention as `deploy --private-state`). */
65
+ readonly privateState?: string;
66
+ readonly summary?: string;
67
+ readonly details?: readonly string[];
68
+ };
69
+ export type DaemonDeployContractResult = {
70
+ readonly txHash: string;
71
+ readonly status: TransactionResult['status'];
72
+ readonly blockHash: string | null;
73
+ readonly blockHeight: number | null;
74
+ readonly contractAddress: string | null;
75
+ readonly fees: TransactionResult['fees'];
76
+ };
77
+ export type DaemonDustRegisterParams = {
78
+ readonly receiver?: string;
79
+ readonly summary?: string;
80
+ readonly details?: readonly string[];
81
+ };
82
+ export type DaemonDustRegisterResult = {
83
+ readonly txId: string | null;
84
+ readonly registered: boolean;
85
+ };
86
+ export type DaemonDustDeregisterParams = {
87
+ readonly summary?: string;
88
+ readonly details?: readonly string[];
89
+ };
90
+ export type DaemonDustDeregisterResult = {
91
+ readonly txId: string;
92
+ };
93
+ export type DaemonInsertVerifierKeyParams = {
94
+ readonly contractAddress: string;
95
+ readonly circuitId: string;
96
+ readonly verifierKeyPath: string;
97
+ readonly artifactPath: string;
98
+ readonly projectDir?: string;
99
+ readonly timeoutSec?: number;
100
+ readonly summary?: string;
101
+ readonly details?: readonly string[];
102
+ };
103
+ export type DaemonInsertVerifierKeyResult = {
104
+ readonly txHash: string;
105
+ readonly status: TransactionResult['status'];
106
+ readonly blockHash: string | null;
107
+ readonly blockHeight: number | null;
108
+ readonly contractAddress: string | null;
109
+ readonly fees: TransactionResult['fees'];
110
+ };
111
+ export type DaemonInsertVerifierKeysBatchParams = {
112
+ readonly contractAddress: string;
113
+ readonly entries: ReadonlyArray<{
114
+ readonly circuitId: string;
115
+ readonly verifierKeyPath: string;
116
+ }>;
117
+ readonly artifactPath: string;
118
+ readonly projectDir?: string;
119
+ readonly skipExisting?: boolean;
120
+ readonly timeoutSec?: number;
121
+ readonly summary?: string;
122
+ readonly details?: readonly string[];
123
+ };
124
+ export type DaemonInsertVerifierKeysBatchResult = {
125
+ readonly contractAddress: string;
126
+ readonly total: number;
127
+ readonly inserted: number;
128
+ readonly skipped: number;
129
+ readonly failed: number;
130
+ readonly entries: ReadonlyArray<{
131
+ readonly circuitId: string;
132
+ readonly status: 'inserted' | 'skipped-existing' | 'failed';
133
+ readonly txHash?: string;
134
+ readonly blockHeight?: number | null;
135
+ readonly error?: string;
136
+ }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,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG;IAChD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;QAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,kBAAkB,GAAG,QAAQ,CAAC;QAC5D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACrC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC,CAAC;CACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ // Wire-format types for every wallet daemon verb. Lives in core so
2
+ // both the TUI host (packages/tui/src/hooks/useDaemonHost.ts) and the
3
+ // headless host (packages/cli/src/commands/daemon/serve.ts) — and any
4
+ // future client that imports the SDK — share one source of truth.
5
+ //
6
+ // All bigint fields cross the JSON boundary as decimal strings. All
7
+ // host-filesystem paths are resolved client-side before they hit the
8
+ // daemon — the daemon does its own resolvePath on receipt for the
9
+ // modal display, but treats the incoming string as authoritative.
10
+ export {};
11
+ //# sourceMappingURL=wallet-rpc-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet-rpc-types.js","sourceRoot":"","sources":["../../src/daemon/wallet-rpc-types.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,sEAAsE;AACtE,sEAAsE;AACtE,kEAAkE;AAClE,EAAE;AACF,oEAAoE;AACpE,qEAAqE;AACrE,kEAAkE;AAClE,kEAAkE"}
@@ -0,0 +1,29 @@
1
+ import type { TimingEntry, TimingStore } from './timings.js';
2
+ /**
3
+ * File-backed timings, one JSON document.
4
+ *
5
+ * A single document rather than an append-only log because the recorder already
6
+ * bounds history to its newest N entries: appending would need a compaction step
7
+ * to honour that, and the file is a few hundred KB at the cap. Rewriting it is
8
+ * cheaper than the phases being measured, which is the only budget that matters.
9
+ *
10
+ * Reads degrade to empty rather than throwing. A timings file that has been
11
+ * hand-edited, truncated by a kill, or written by an older shape must not stop a
12
+ * wallet from starting — losing a diagnostic is always preferable to blocking the
13
+ * thing it diagnoses.
14
+ */
15
+ export declare class FilesystemTimingStore implements TimingStore {
16
+ private readonly path;
17
+ constructor(path?: string);
18
+ private load;
19
+ private save;
20
+ isEnabled(): Promise<boolean>;
21
+ setEnabled(on: boolean): Promise<void>;
22
+ read(): Promise<TimingEntry[]>;
23
+ write(entries: TimingEntry[]): Promise<void>;
24
+ /** Drops the entries and the file, but NOT the enabled flag — clearing a
25
+ * timeline mid-run is how you isolate one phase, and silently switching
26
+ * recording off would lose whatever came next. */
27
+ clear(): Promise<void>;
28
+ }
29
+ //# sourceMappingURL=fs-timing-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-timing-store.d.ts","sourceRoot":"","sources":["../../src/diagnostics/fs-timing-store.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAC,WAAW,EAAE,WAAW,EAAC,MAAM,cAAc,CAAC;AAW3D;;;;;;;;;;;;GAYG;AACH,qBAAa,qBAAsB,YAAW,WAAW;IACvD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;gBAElB,IAAI,GAAE,MAAqB;YAIzB,IAAI;YAeJ,IAAI;IAKZ,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAI7B,UAAU,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAMtC,IAAI,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAI9B,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMlD;;uDAEmD;IAC7C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAS7B"}
@@ -0,0 +1,81 @@
1
+ // Node-side persistence for the phase-timings recorder: the CLI, TUI and daemon.
2
+ //
3
+ // Node-only, and deliberately in its own module rather than beside the recorder,
4
+ // so a browser bundle importing diagnostics/timings.js never pulls node:fs in.
5
+ // Same split as storage/adapter.ts (isomorphic) versus storage/fs-adapter.ts
6
+ // (node) — see those files for the established convention.
7
+ import { readFile, writeFile, unlink, mkdir } from 'node:fs/promises';
8
+ import { join, dirname } from 'node:path';
9
+ import { homedir } from 'node:os';
10
+ const DEFAULT_PATH = join(homedir(), '.moth', 'timings.json');
11
+ const EMPTY = { enabled: false, entries: [] };
12
+ /**
13
+ * File-backed timings, one JSON document.
14
+ *
15
+ * A single document rather than an append-only log because the recorder already
16
+ * bounds history to its newest N entries: appending would need a compaction step
17
+ * to honour that, and the file is a few hundred KB at the cap. Rewriting it is
18
+ * cheaper than the phases being measured, which is the only budget that matters.
19
+ *
20
+ * Reads degrade to empty rather than throwing. A timings file that has been
21
+ * hand-edited, truncated by a kill, or written by an older shape must not stop a
22
+ * wallet from starting — losing a diagnostic is always preferable to blocking the
23
+ * thing it diagnoses.
24
+ */
25
+ export class FilesystemTimingStore {
26
+ path;
27
+ constructor(path = DEFAULT_PATH) {
28
+ this.path = path;
29
+ }
30
+ async load() {
31
+ try {
32
+ const parsed = JSON.parse(await readFile(this.path, 'utf8'));
33
+ if (parsed === null || typeof parsed !== 'object')
34
+ return { ...EMPTY };
35
+ const file = parsed;
36
+ return {
37
+ enabled: file.enabled === true,
38
+ entries: Array.isArray(file.entries) ? file.entries : [],
39
+ };
40
+ }
41
+ catch {
42
+ // Missing, unreadable, or not JSON — all mean "nothing recorded yet".
43
+ return { ...EMPTY };
44
+ }
45
+ }
46
+ async save(file) {
47
+ await mkdir(dirname(this.path), { recursive: true });
48
+ await writeFile(this.path, JSON.stringify(file, null, 2), 'utf8');
49
+ }
50
+ async isEnabled() {
51
+ return (await this.load()).enabled;
52
+ }
53
+ async setEnabled(on) {
54
+ const file = await this.load();
55
+ file.enabled = on;
56
+ await this.save(file);
57
+ }
58
+ async read() {
59
+ return (await this.load()).entries;
60
+ }
61
+ async write(entries) {
62
+ const file = await this.load();
63
+ file.entries = entries;
64
+ await this.save(file);
65
+ }
66
+ /** Drops the entries and the file, but NOT the enabled flag — clearing a
67
+ * timeline mid-run is how you isolate one phase, and silently switching
68
+ * recording off would lose whatever came next. */
69
+ async clear() {
70
+ const enabled = await this.isEnabled();
71
+ try {
72
+ await unlink(this.path);
73
+ }
74
+ catch {
75
+ /* already gone */
76
+ }
77
+ if (enabled)
78
+ await this.save({ enabled: true, entries: [] });
79
+ }
80
+ }
81
+ //# sourceMappingURL=fs-timing-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-timing-store.js","sourceRoot":"","sources":["../../src/diagnostics/fs-timing-store.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,EAAE;AACF,iFAAiF;AACjF,+EAA+E;AAC/E,6EAA6E;AAC7E,2DAA2D;AAE3D,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAC,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAC,IAAI,EAAE,OAAO,EAAC,MAAM,WAAW,CAAC;AACxC,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAGhC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,EAA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,EAAE,CAAC,CAAC,OAAO,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EAAW;QAC1B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAAsB;QAChC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED;;uDAEmD;IACnD,KAAK,CAAC,KAAK;QACT,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACvC,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,kBAAkB;QACpB,CAAC;QACD,IAAI,OAAO;YAAE,MAAM,IAAI,CAAC,IAAI,CAAC,EAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAC,CAAC,CAAC;IAC7D,CAAC;CACF"}
@@ -0,0 +1,64 @@
1
+ /** One stamped phase boundary. */
2
+ export interface TimingEntry {
3
+ /** Epoch ms. */
4
+ at: number;
5
+ /** ms since the previous entry — the cost of the phase that just ended. */
6
+ deltaMs: number;
7
+ /** Phase label: a sync message, a tx stage, or an explicit marker. */
8
+ label: string;
9
+ /** Where it came from, so a reader can group one stream into runs. */
10
+ source: TimingSource;
11
+ /** Optional numbers a label cannot carry (state sizes, applied/total). A
12
+ * duration without the size it scaled with is uninterpretable. */
13
+ detail?: Record<string, number | string>;
14
+ }
15
+ export type TimingSource = 'sync' | 'tx' | 'marker';
16
+ /**
17
+ * Persistence for the recorder. Deliberately tiny: four operations, all async,
18
+ * none of which the recorder assumes anything about beyond "it might fail".
19
+ *
20
+ * Implementations must survive process/worker restarts if they want to be useful
21
+ * — the interesting runs (unlock, first sync, an hour-long reference build) span
22
+ * teardown — but that is a property of the store, not a requirement of this
23
+ * interface.
24
+ */
25
+ export interface TimingStore {
26
+ isEnabled(): Promise<boolean>;
27
+ setEnabled(on: boolean): Promise<void>;
28
+ read(): Promise<TimingEntry[]>;
29
+ write(entries: TimingEntry[]): Promise<void>;
30
+ clear(): Promise<void>;
31
+ }
32
+ /** Oldest entries are dropped past this. Bounded so an always-on session cannot
33
+ * grow storage without limit; ~500 is several unlock+sync runs. */
34
+ export declare const DEFAULT_MAX_ENTRIES = 500;
35
+ export interface TimingRecorder {
36
+ /** Append one stamped phase. No-op when disabled, so call sites need no guard. */
37
+ record(source: TimingSource, label: string, detail?: TimingEntry['detail']): Promise<void>;
38
+ isEnabled(): Promise<boolean>;
39
+ setEnabled(on: boolean): Promise<void>;
40
+ list(): Promise<TimingEntry[]>;
41
+ clear(): Promise<void>;
42
+ }
43
+ /**
44
+ * Build a recorder over any store.
45
+ *
46
+ * `now` is injectable so the arithmetic is testable without faking the clock
47
+ * globally; it defaults to Date.now.
48
+ *
49
+ * Every method is best-effort by design: a failed read or write must never
50
+ * disturb the thing being measured, and an instrument that can break the wallet
51
+ * is worse than no instrument. That is why `record` swallows everything rather
52
+ * than propagating — callers stamp phases on hot paths and cannot be asked to
53
+ * wrap each one.
54
+ */
55
+ export declare function createTimingRecorder(store: TimingStore, options?: {
56
+ maxEntries?: number;
57
+ now?: () => number;
58
+ }): TimingRecorder;
59
+ /**
60
+ * In-memory store. For tests, and for a short-lived process that only wants the
61
+ * timeline it prints at exit.
62
+ */
63
+ export declare function createMemoryTimingStore(initiallyEnabled?: boolean): TimingStore;
64
+ //# sourceMappingURL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