@spirobel/monero-wallet-api 0.5.5 → 0.6.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 (78) hide show
  1. package/dist/actionlog/actionLogOpened.d.ts +96 -1
  2. package/dist/actionlog/actionLogOpened.js +386 -1
  3. package/dist/actionlog/actionLogTypes.d.ts +114 -0
  4. package/dist/actionlog/actionLogTypes.js +198 -0
  5. package/dist/actionlog/backend/idbBackend.d.ts +13 -0
  6. package/dist/actionlog/backend/idbBackend.js +109 -0
  7. package/dist/actionlog/backend/jsonlBackend.d.ts +19 -0
  8. package/dist/actionlog/backend/jsonlBackend.js +110 -0
  9. package/dist/actionlog/backend/memoryBackend.d.ts +11 -0
  10. package/dist/actionlog/backend/memoryBackend.js +31 -0
  11. package/dist/actionlog/backend/sqliteBackend.d.ts +14 -0
  12. package/dist/actionlog/backend/sqliteBackend.js +96 -0
  13. package/dist/actionlog/backend.d.ts +12 -0
  14. package/dist/actionlog/backend.js +1 -0
  15. package/dist/actionlog/idbBackend.d.ts +19 -0
  16. package/dist/actionlog/idbBackend.js +98 -0
  17. package/dist/actionlog/jsonlBackend.d.ts +19 -0
  18. package/dist/actionlog/jsonlBackend.js +75 -0
  19. package/dist/actionlog/memoryBackend.d.ts +14 -0
  20. package/dist/actionlog/memoryBackend.js +38 -0
  21. package/dist/actionlog/openMaps.d.ts +11 -0
  22. package/dist/actionlog/openMaps.js +32 -0
  23. package/dist/actionlog/sqliteBackend.d.ts +18 -0
  24. package/dist/actionlog/sqliteBackend.js +105 -0
  25. package/dist/actionlog/toolContext.d.ts +36 -0
  26. package/dist/actionlog/toolContext.js +1 -0
  27. package/dist/actionlog/types.d.ts +62 -0
  28. package/dist/actionlog/types.js +62 -0
  29. package/dist/api.d.ts +4 -0
  30. package/dist/api.js +3 -0
  31. package/dist/scanning-syncing/blocksbuffer/blocksbufferCoordination.js +2 -2
  32. package/dist/scanning-syncing/connectionStatus.d.ts +2 -0
  33. package/dist/scanning-syncing/connectionStatus.js +36 -1
  34. package/dist/scanning-syncing/connectionStatusOpened.d.ts +1 -1
  35. package/dist/scanning-syncing/connectionStatusOpened.js +2 -11
  36. package/dist/scanning-syncing/scanresult/scanCache.d.ts +5 -1
  37. package/dist/scanning-syncing/scanresult/scanCache.js +11 -2
  38. package/dist/scanning-syncing/scanresult/scanCacheOpened.d.ts +46 -1
  39. package/dist/scanning-syncing/scanresult/scanCacheOpened.js +317 -39
  40. package/dist/scanning-syncing/scanresult/scanCoordination.d.ts +1 -0
  41. package/dist/scanning-syncing/scanresult/scanCoordination.js +40 -4
  42. package/dist/scanning-syncing/scanresult/scanResult.js +17 -12
  43. package/dist/scanning-syncing/scanresult/scanStats.js +8 -5
  44. package/dist/scanning-syncing/worker-entrypoints/worker.js +1 -1
  45. package/dist/tools/calls/001.d.ts +20 -0
  46. package/dist/tools/calls/001.js +236 -0
  47. package/dist/tools/calls/002-content.d.ts +46 -0
  48. package/dist/tools/calls/002-content.js +135 -0
  49. package/dist/tools/calls/002-fail-cleanup.d.ts +27 -0
  50. package/dist/tools/calls/002-fail-cleanup.js +60 -0
  51. package/dist/tools/calls/002.d.ts +64 -0
  52. package/dist/tools/calls/002.js +353 -0
  53. package/dist/tools/content.d.ts +22 -0
  54. package/dist/tools/content.js +41 -0
  55. package/dist/tools/counterparty.d.ts +3 -0
  56. package/dist/tools/counterparty.js +1 -0
  57. package/dist/tools/download-public-suffix.d.ts +1 -0
  58. package/dist/tools/download-public-suffix.js +20 -0
  59. package/dist/tools/globals.d.ts +196 -0
  60. package/dist/tools/globals.js +14 -0
  61. package/dist/tools/monero-tools-content.d.ts +29 -0
  62. package/dist/tools/monero-tools-content.js +80 -0
  63. package/dist/tools/monero-tools.d.ts +27 -52
  64. package/dist/tools/monero-tools.js +127 -222
  65. package/dist/tools/public-suffix-list.d.ts +1 -0
  66. package/dist/tools/public-suffix-list.js +10336 -0
  67. package/dist/tools/runtimeMessages.d.ts +4 -0
  68. package/dist/tools/runtimeMessages.js +18 -0
  69. package/dist/tools/toolActionLogContext.d.ts +33 -0
  70. package/dist/tools/toolActionLogContext.js +1 -0
  71. package/dist/tools/toolArm.d.ts +47 -0
  72. package/dist/tools/toolArm.js +1 -0
  73. package/dist/tools/ui.d.ts +2 -0
  74. package/dist/tools/ui.js +1 -0
  75. package/dist/tools/worker.d.ts +1 -0
  76. package/dist/tools/worker.js +1 -0
  77. package/dist/wasm-processing/wasmFile.js +2 -2
  78. package/package.json +8 -1
@@ -13,7 +13,42 @@ export function applyWalletScanProgress(cs, progress) {
13
13
  if (progress.eta !== undefined) {
14
14
  cs.sync.eta = progress.eta;
15
15
  }
16
- cs.sync.timestamp = new Date().toISOString();
16
+ const now = new Date().toISOString();
17
+ cs.sync.timestamp = now;
18
+ // finished batch is a heartbeat so buffer-full catch-up does not look dead
19
+ if (cs.last_packet) {
20
+ cs.last_packet.timestamp = now;
21
+ }
22
+ }
23
+ // idle tip: ok packet has daemon height but no work item wrote sync yet
24
+ export function applyLastPacket(cs, packet) {
25
+ cs.last_packet = packet;
26
+ if (packet.status === "OK" && typeof packet.daemon_height === "number") {
27
+ cs.sync.daemon_height = packet.daemon_height;
28
+ if (!cs.sync.current_scan_height) {
29
+ cs.sync.current_scan_height = packet.daemon_height;
30
+ }
31
+ }
32
+ }
33
+ export function isConnectedFromStatus(cs) {
34
+ if (!cs?.last_packet)
35
+ return false;
36
+ const { status, timestamp } = cs.last_packet;
37
+ // fetch paused on purpose while cpu drains the buffer. not a drop.
38
+ if (status === "blocks_buffer_full")
39
+ return true;
40
+ if (status !== "OK")
41
+ return false;
42
+ // catching up: slow get_blocks_bin is not a drop. 10s rule is for tip idle only.
43
+ const behind = cs.sync.daemon_height > 0 &&
44
+ cs.sync.current_scan_height > 0 &&
45
+ cs.sync.daemon_height - cs.sync.current_scan_height > 100;
46
+ if (behind)
47
+ return true;
48
+ if (!timestamp)
49
+ return false;
50
+ const age = Date.now() - new Date(timestamp).getTime();
51
+ return age >= 0 && age <= 10_000;
17
52
  }
18
53
  export const DEFAULT_CONNECTION_STATUS_PREFIX = "ConnectionStatus-";
19
54
  export function msToHHMM(ms) {
@@ -1,4 +1,4 @@
1
- import { type ConnectionStatus } from "../api";
1
+ import { type ConnectionStatus } from "./connectionStatus";
2
2
  export declare class ConnectionStatusOpened {
3
3
  private _onChange?;
4
4
  private _timer;
@@ -1,4 +1,4 @@
1
- import { readConnectionStatusFile, connectionStatusFilePath, } from "../api";
1
+ import { readConnectionStatusFile, connectionStatusFilePath, isConnectedFromStatus, } from "./connectionStatus";
2
2
  export class ConnectionStatusOpened {
3
3
  _onChange;
4
4
  _timer;
@@ -27,16 +27,7 @@ export class ConnectionStatusOpened {
27
27
  return this._cached;
28
28
  }
29
29
  get isConnected() {
30
- const cs = this._cached;
31
- if (!cs?.last_packet)
32
- return false;
33
- const { status, timestamp } = cs.last_packet;
34
- if (status !== "OK" && status !== "blocks_buffer_full")
35
- return false;
36
- if (!timestamp)
37
- return false;
38
- const age = Date.now() - new Date(timestamp).getTime();
39
- return age >= 0 && age <= 10_000;
30
+ return isConnectedFromStatus(this._cached);
40
31
  }
41
32
  get daemonHeight() {
42
33
  return this._cached?.sync?.daemon_height;
@@ -20,6 +20,7 @@ export declare function lastRangeThrows(ranges: CacheRange[]): CacheRange;
20
20
  export declare function mergeRanges(ranges: CacheRange[]): CacheRange[];
21
21
  export declare const findRange: (ranges: CacheRange[], value: number) => CacheRange | null;
22
22
  export declare function findRangeThrows(ranges: CacheRange[], value: number): CacheRange;
23
+ export declare function currentScanHeightFromRanges(ranges: CacheRange[], start_height: number): number;
23
24
  export type CacheRange = {
24
25
  start: number;
25
26
  end: number;
@@ -67,6 +68,9 @@ export type TxLog = {
67
68
  feeEstimate?: FeeEstimateResponse;
68
69
  sendResult?: SendRawTransactionResult;
69
70
  error?: string;
71
+ invocationId?: string;
72
+ signed_tx?: string;
73
+ hidden_on_send_plate?: boolean;
70
74
  };
71
75
  export type ChangeReason = "spent" | "added" | "ownspend" | "reorged" | "reorged_spent" | "burned";
72
76
  export type ChangedOutput = {
@@ -95,4 +99,4 @@ export interface HasPrimaryAddress {
95
99
  primary_address: string;
96
100
  }
97
101
  export declare function handleScanError(error: unknown): void;
98
- export declare function isConnectionError(error: unknown): true | undefined;
102
+ export declare function isConnectionError(error: unknown): boolean;
@@ -158,6 +158,10 @@ export function findRangeThrows(ranges, value) {
158
158
  throw new Error(`range not found for value: ${value}`);
159
159
  return range;
160
160
  }
161
+ // end of the range that contains start_height. miss means we scan from start
162
+ export function currentScanHeightFromRanges(ranges, start_height) {
163
+ return findRange(ranges, start_height)?.end ?? start_height ?? 0;
164
+ }
161
165
  export function handleScanError(error) {
162
166
  // treat errno 0 code "ConnectionRefused" as non fatal outcome, and rethrow,
163
167
  // so that UI can be informed after catching it higher up
@@ -185,10 +189,15 @@ export function isConnectionError(error) {
185
189
  if (error &&
186
190
  typeof error === "object" &&
187
191
  (("code" in error && error.code === "ConnectionRefused") ||
188
- ("errno" in error && error.errno === 0))) {
192
+ ("errno" in error && error.errno === 0) ||
193
+ ("message" in error &&
194
+ typeof error.message === "string" &&
195
+ (error.message.includes("Failed to fetch") ||
196
+ error.message.includes("ERR_INTERNET_DISCONNECTED") ||
197
+ error.message.includes("NetworkError"))))) {
189
198
  return true;
190
199
  }
191
200
  else {
192
- false;
201
+ return false;
193
202
  }
194
203
  }
@@ -1,6 +1,7 @@
1
1
  import { ViewPair, type FeeEstimateResponse, type Output, type SendRawTransactionResult } from "../../api";
2
2
  import { type Payment } from "../../send-functionality/inputSelection";
3
3
  import { ConnectionStatusOpened } from "../connectionStatusOpened";
4
+ import { ActionLogOpened, type ActionLogBackendKind, type ExtensionMessageBus } from "../../actionlog/actionLogOpened";
4
5
  import type { LogSetting, PossibleLogs } from "../../io/logging";
5
6
  import { type CacheChangedCallback, type CacheChangedCallbackParameters, type ScanCache, type Subaddress, type TxLog } from "./scanCache";
6
7
  import { type FoundTransaction, type PrePendingTx } from "./scanStats";
@@ -19,6 +20,7 @@ export type CreateTransactionParams = {
19
20
  payments: Payment[];
20
21
  inputs?: Output[];
21
22
  no_fee_circuit_breaker?: boolean;
23
+ invocationId?: string;
22
24
  };
23
25
  export declare class ScanCacheOpened {
24
26
  private _scanSettings;
@@ -101,6 +103,23 @@ export declare class ScanCacheOpened {
101
103
  get subaddresses(): Subaddress[];
102
104
  get tx_logs(): TxLog[];
103
105
  makeSignSendTransaction(params: CreateTransactionParams): Promise<SendRawTransactionResult>;
106
+ private outputsForIndexes;
107
+ makeSignSend(params: {
108
+ payments: Payment[];
109
+ input_indexes: string[];
110
+ }): Promise<SendRawTransactionResult>;
111
+ sweepSignSend(params: {
112
+ address: string;
113
+ input_indexes: string[];
114
+ }): Promise<SendRawTransactionResult>;
115
+ rebroadcastTx(txLogIndex: number): Promise<SendRawTransactionResult>;
116
+ get failed_txs(): {
117
+ index: number;
118
+ txlog: TxLog;
119
+ inputs: Output[];
120
+ }[];
121
+ private recordSend;
122
+ dismissSendPlate(): Promise<void>;
104
123
  /**
105
124
  * makeStandardTransaction
106
125
  */
@@ -182,9 +201,14 @@ export type ManyScanCachesOpenedCreateOptions = {
182
201
  logs?: LogSetting;
183
202
  logs_include?: PossibleLogs[];
184
203
  logs_exclude?: PossibleLogs[];
204
+ actionLogPath?: string;
205
+ actionLogBackend?: ActionLogBackendKind;
206
+ onActionLogChange?: (() => void) | null;
207
+ extensionMessageBus?: ExtensionMessageBus;
185
208
  };
186
209
  export declare class ManyScanCachesOpened {
187
210
  readonly connectionStatusOpened: ConnectionStatusOpened;
211
+ readonly actionLogOpened: ActionLogOpened;
188
212
  private _scanSettings;
189
213
  private _options;
190
214
  get start_height(): number | null;
@@ -195,6 +219,27 @@ export declare class ManyScanCachesOpened {
195
219
  stopWorker(): Promise<void>;
196
220
  dumpWorkerHeaps(dir?: string): Promise<string[]>;
197
221
  changeNodeUrl(node_url: string): Promise<void>;
222
+ private walletByAddress;
223
+ makeSignSend(params: {
224
+ primary_address: string;
225
+ payments: {
226
+ address: string;
227
+ amount: string;
228
+ }[];
229
+ input_indexes: string[];
230
+ }): Promise<SendRawTransactionResult | undefined>;
231
+ sweepSignSend(params: {
232
+ primary_address: string;
233
+ address: string;
234
+ input_indexes: string[];
235
+ }): Promise<SendRawTransactionResult | undefined>;
236
+ rebroadcastTx(params: {
237
+ primary_address: string;
238
+ tx_log_index: number;
239
+ }): Promise<SendRawTransactionResult | undefined>;
240
+ dismissSendPlate(params: {
241
+ primary_address: string;
242
+ }): Promise<void>;
198
243
  get merchant_confirmations(): number | null | undefined;
199
244
  get cpu_worker_count(): number | undefined;
200
245
  get logs(): LogSetting | undefined;
@@ -206,7 +251,7 @@ export declare class ManyScanCachesOpened {
206
251
  unwatchConnectionStatus(): void;
207
252
  setMerchantConfirmations(merchant_confirmations: number | null): Promise<void>;
208
253
  setCpuWorkerCount(cpu_worker_count: number | undefined): Promise<void>;
209
- setLogSettings(logs?: LogSetting | null, logs_include?: PossibleLogs[] | null, logs_exclude?: PossibleLogs[] | null): Promise<void>;
254
+ setLogSettings(logs?: LogSetting | null, logs_include?: string[] | null, logs_exclude?: string[] | null): Promise<void>;
210
255
  setWalletName(primary_address: string, name?: string): Promise<void>;
211
256
  setWalletSlot(primary_address: string, slot?: number): Promise<void>;
212
257
  changeStartHeight(start_height: number | null): Promise<void>;