@spirobel/monero-wallet-api 0.1.2 → 0.3.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 (67) hide show
  1. package/README.md +13 -1
  2. package/dist/api.d.ts +25 -53
  3. package/dist/api.js +23 -101
  4. package/dist/io/BunFileInterface.d.ts +32 -0
  5. package/dist/io/BunFileInterface.js +1 -0
  6. package/dist/io/atomicWrite.d.ts +2 -0
  7. package/dist/io/atomicWrite.js +10 -0
  8. package/dist/io/extension.d.ts +18 -0
  9. package/dist/io/extension.js +11 -0
  10. package/dist/io/indexedDB.d.ts +45 -0
  11. package/dist/io/indexedDB.js +221 -0
  12. package/dist/io/readDir.d.ts +1 -0
  13. package/dist/io/readDir.js +7 -0
  14. package/dist/io/sleep.d.ts +1 -0
  15. package/dist/io/sleep.js +1 -0
  16. package/dist/keypairs-seeds/keypairs.d.ts +29 -0
  17. package/dist/keypairs-seeds/keypairs.js +207 -0
  18. package/dist/keypairs-seeds/writeKeypairs.d.ts +11 -0
  19. package/dist/keypairs-seeds/writeKeypairs.js +75 -0
  20. package/dist/node-interaction/binaryEndpoints.d.ts +67 -10
  21. package/dist/node-interaction/binaryEndpoints.js +127 -53
  22. package/dist/node-interaction/jsonEndpoints.d.ts +249 -187
  23. package/dist/node-interaction/jsonEndpoints.js +287 -0
  24. package/dist/node-interaction/nodeUrl.d.ts +129 -0
  25. package/dist/node-interaction/nodeUrl.js +113 -0
  26. package/dist/scanning-syncing/backgroundWorker.d.ts +6 -0
  27. package/dist/scanning-syncing/backgroundWorker.js +56 -0
  28. package/dist/scanning-syncing/connectionStatus.d.ts +15 -0
  29. package/dist/scanning-syncing/connectionStatus.js +35 -0
  30. package/dist/scanning-syncing/openWallet.d.ts +28 -0
  31. package/dist/scanning-syncing/openWallet.js +57 -0
  32. package/dist/scanning-syncing/scanSettings.d.ts +96 -0
  33. package/dist/scanning-syncing/scanSettings.js +243 -0
  34. package/dist/scanning-syncing/scanresult/computeKeyImage.d.ts +3 -0
  35. package/dist/scanning-syncing/scanresult/computeKeyImage.js +21 -0
  36. package/dist/scanning-syncing/scanresult/getBlocksbinBuffer.d.ts +28 -0
  37. package/dist/scanning-syncing/scanresult/getBlocksbinBuffer.js +52 -0
  38. package/dist/scanning-syncing/scanresult/reorg.d.ts +14 -0
  39. package/dist/scanning-syncing/scanresult/reorg.js +78 -0
  40. package/dist/scanning-syncing/scanresult/scanCache.d.ts +84 -0
  41. package/dist/scanning-syncing/scanresult/scanCache.js +134 -0
  42. package/dist/scanning-syncing/scanresult/scanCacheOpened.d.ts +149 -0
  43. package/dist/scanning-syncing/scanresult/scanCacheOpened.js +648 -0
  44. package/dist/scanning-syncing/scanresult/scanResult.d.ts +64 -0
  45. package/dist/scanning-syncing/scanresult/scanResult.js +213 -0
  46. package/dist/scanning-syncing/scanresult/scanStats.d.ts +60 -0
  47. package/dist/scanning-syncing/scanresult/scanStats.js +273 -0
  48. package/dist/scanning-syncing/worker-entrypoints/worker.d.ts +1 -0
  49. package/dist/scanning-syncing/worker-entrypoints/worker.js +8 -0
  50. package/dist/scanning-syncing/worker-mains/worker.d.ts +1 -0
  51. package/dist/scanning-syncing/worker-mains/worker.js +7 -0
  52. package/dist/send-functionality/conversion.d.ts +4 -0
  53. package/dist/send-functionality/conversion.js +75 -0
  54. package/dist/send-functionality/inputSelection.d.ts +13 -0
  55. package/dist/send-functionality/inputSelection.js +8 -0
  56. package/dist/send-functionality/transactionBuilding.d.ts +51 -0
  57. package/dist/send-functionality/transactionBuilding.js +111 -0
  58. package/dist/tools/monero-tools.d.ts +46 -0
  59. package/dist/tools/monero-tools.js +165 -0
  60. package/dist/viewpair/ViewPair.d.ts +157 -0
  61. package/dist/viewpair/ViewPair.js +346 -0
  62. package/dist/wasm-processing/wasi.js +1 -2
  63. package/dist/wasm-processing/wasmFile.d.ts +1 -1
  64. package/dist/wasm-processing/wasmFile.js +2 -2
  65. package/dist/wasm-processing/wasmProcessor.d.ts +16 -4
  66. package/dist/wasm-processing/wasmProcessor.js +23 -7
  67. package/package.json +29 -6
@@ -1,8 +1,9 @@
1
1
  import { TinyWASI } from "./wasi";
2
+ export type FunctionCallMeta = {
3
+ function: string;
4
+ };
2
5
  export type MemoryCallback = (ptr: number, len: number) => void;
3
6
  export declare class WasmProcessor {
4
- tinywasi: TinyWASI;
5
- node_url: string;
6
7
  /**
7
8
  * This method is invoked whenever a Rust function expects an array or string parameter.
8
9
  * You should use `writeArray` or `writeString` within the function assigned to this callback
@@ -21,6 +22,15 @@ export declare class WasmProcessor {
21
22
  * @param len - The number of bytes to read starting from the specified `ptr`.
22
23
  */
23
24
  readFromWasmMemory: MemoryCallback;
25
+ /**
26
+ * This method is invoked whenever a Rust function wants to return an error json string.
27
+ * You should use `readString` within the function assigned to this callback
28
+ * to read the data from WebAssembly (Wasm) memory after the corresponding Wasm method has written it.
29
+ *
30
+ * @param ptr - The WebAssembly memory address from which the data should be read.
31
+ * @param len - The number of bytes to read starting from the specified `ptr`.
32
+ */
33
+ readErrorFromWasmMemory: MemoryCallback;
24
34
  /**
25
35
  * Writes an array of bytes to a specified offset in WebAssembly memory.
26
36
  *
@@ -59,7 +69,7 @@ export declare class WasmProcessor {
59
69
  *
60
70
  * @see {@link readFromWasmMemory}
61
71
  */
62
- readArray: (ptr: number, len: number) => Uint8Array;
72
+ readArray: (ptr: number, len: number) => Uint8Array<ArrayBuffer>;
63
73
  /**
64
74
  * Reads a string from a specified offset in WebAssembly memory.
65
75
  *
@@ -73,6 +83,8 @@ export declare class WasmProcessor {
73
83
  * @see {@link readFromWasmMemory}
74
84
  */
75
85
  readString: (ptr: number, len: number) => string;
76
- protected constructor(tinywasi: TinyWASI, node_url: string);
86
+ tinywasi: TinyWASI;
87
+ protected constructor();
77
88
  initWasmModule(): Promise<TinyWASI>;
89
+ static init(): Promise<WasmProcessor>;
78
90
  }
@@ -1,8 +1,6 @@
1
1
  import { TinyWASI } from "./wasi";
2
2
  import { monero_wallet_api_wasm } from "./wasmFile";
3
3
  export class WasmProcessor {
4
- tinywasi;
5
- node_url;
6
4
  /**
7
5
  * This method is invoked whenever a Rust function expects an array or string parameter.
8
6
  * You should use `writeArray` or `writeString` within the function assigned to this callback
@@ -21,6 +19,15 @@ export class WasmProcessor {
21
19
  * @param len - The number of bytes to read starting from the specified `ptr`.
22
20
  */
23
21
  readFromWasmMemory = (ptr, len) => { };
22
+ /**
23
+ * This method is invoked whenever a Rust function wants to return an error json string.
24
+ * You should use `readString` within the function assigned to this callback
25
+ * to read the data from WebAssembly (Wasm) memory after the corresponding Wasm method has written it.
26
+ *
27
+ * @param ptr - The WebAssembly memory address from which the data should be read.
28
+ * @param len - The number of bytes to read starting from the specified `ptr`.
29
+ */
30
+ readErrorFromWasmMemory = (ptr, len) => { };
24
31
  /**
25
32
  * Writes an array of bytes to a specified offset in WebAssembly memory.
26
33
  *
@@ -71,7 +78,10 @@ export class WasmProcessor {
71
78
  */
72
79
  readArray = (ptr, len) => {
73
80
  const memory = this.tinywasi.getMemory();
74
- return new Uint8Array(memory.buffer, ptr, len);
81
+ const original = new Uint8Array(memory.buffer, ptr, len);
82
+ const copy = new Uint8Array(len);
83
+ copy.set(original);
84
+ return copy;
75
85
  };
76
86
  /**
77
87
  * Reads a string from a specified offset in WebAssembly memory.
@@ -91,10 +101,8 @@ export class WasmProcessor {
91
101
  const str = decoder.decode(array);
92
102
  return str;
93
103
  };
94
- constructor(tinywasi, node_url) {
95
- this.tinywasi = tinywasi;
96
- this.node_url = node_url;
97
- }
104
+ tinywasi;
105
+ constructor() { }
98
106
  async initWasmModule() {
99
107
  const tinywasi = new TinyWASI();
100
108
  this.tinywasi = tinywasi;
@@ -106,6 +114,9 @@ export class WasmProcessor {
106
114
  output: (ptr, len) => {
107
115
  this.readFromWasmMemory(ptr, len);
108
116
  },
117
+ output_error: (ptr, len) => {
118
+ this.readErrorFromWasmMemory(ptr, len);
119
+ },
109
120
  },
110
121
  ...tinywasi.imports,
111
122
  };
@@ -113,4 +124,9 @@ export class WasmProcessor {
113
124
  tinywasi.initialize(instance);
114
125
  return tinywasi;
115
126
  }
127
+ static async init() {
128
+ const wasmProcessor = new WasmProcessor();
129
+ await wasmProcessor.initWasmModule();
130
+ return wasmProcessor;
131
+ }
116
132
  }
package/package.json CHANGED
@@ -5,26 +5,49 @@
5
5
  "type": "module",
6
6
  "main": "dist/api.js",
7
7
  "types": "dist/api.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/api.d.ts",
11
+ "import": "./dist/api.js"
12
+ },
13
+ "./tools": {
14
+ "types": "./dist/tools/monero-tools.d.ts",
15
+ "import": "./dist/tools/monero-tools.js"
16
+ }
17
+ },
8
18
  "publishConfig": {
9
19
  "access": "public"
10
20
  },
11
21
  "scripts": {
12
22
  "publish": "bun run build && bun run inlinesum && npm publish",
13
- "inline": "bun build scripts/wasmFile.ts --target=browser --outdir dist/wasm-processing",
14
- "sum": "cat dist/wasm-processing/wasmFile.js | sha256sum > checksum.txt",
15
- "inlinesum": "bun run inline && bun run sum",
23
+ "inlinewasm": "bun build templates/wasm/wasmFile.ts --target=browser --outdir dist/wasm-processing",
24
+ "sumwasm": "cat dist/wasm-processing/wasmFile.js | sha256sum > wasm_checksum.txt",
25
+ "inlinesumwasm": "bun run inlinewasm && bun run sumwasm",
26
+ "safewasm": "cp wallet-api/wasm-processing/wasmFile.ts wallet-api/wasm-processing/wasmFile.ts.backup",
27
+ "restorewasm": "mv wallet-api/wasm-processing/wasmFile.ts.backup wallet-api/wasm-processing/wasmFile.ts",
28
+ "inlineworker": "bun build templates/workers/worker.ts --target=browser --outdir dist/scanning-syncing/worker-entrypoints",
29
+ "sumworker": "cat dist/scanning-syncing/worker-entrypoints/worker.js | sha256sum > worker_checksum.txt",
30
+ "inlinesumworker": "bun run inlinesumwasm && bun run safewasm && bun run copydevwasm && bun run inlineworker && bun run sumworker && bun run restorewasm",
31
+ "inlinesum": "bun run inlinesumworker",
32
+ "safeworker": "cp wallet-api/scanning-syncing/worker-entrypoints/worker.ts wallet-api/scanning-syncing/worker-entrypoints/worker.ts.backup",
33
+ "restoreworker": "mv wallet-api/scanning-syncing/worker-entrypoints/worker.ts.backup wallet-api/scanning-syncing/worker-entrypoints/worker.ts",
34
+ "copydevworker": "cp dist/scanning-syncing/worker-entrypoints/worker.js wallet-api/scanning-syncing/worker-entrypoints/worker.ts",
35
+ "copydevwasm": "cp dist/wasm-processing/wasmFile.js wallet-api/wasm-processing/wasmFile.ts",
36
+ "copydev": "bun run safewasm && bun run safeworker && bun run copydevworker && bun run copydevwasm",
37
+ "restoredev": "bun run restorewasm && bun run restoreworker",
38
+ "refreshdev": "bun run restoredev && bun run inlinesum && bun run copydev",
16
39
  "build": "tsc",
17
40
  "clean": "rm -rf ./dist"
18
41
  },
19
42
  "files": ["dist"],
20
- "version": "0.1.2",
43
+ "version": "0.3.0",
21
44
  "devDependencies": {
22
45
  "@types/bun": "latest"
23
46
  },
24
47
  "peerDependencies": {
25
- "typescript": "^5.0.0"
48
+ "typescript": "5.9.3"
26
49
  },
27
50
  "dependencies": {
28
- "zod": "^3.24.1"
51
+ "zod": "4.3.6"
29
52
  }
30
53
  }