@deserialize/multi-vm-wallet 1.3.2 → 1.3.4

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 (99) hide show
  1. package/.claude/settings.local.json +2 -1
  2. package/dist/IChainWallet.d.ts +2 -0
  3. package/dist/IChainWallet.js.map +1 -1
  4. package/dist/constant.js +60 -16
  5. package/dist/constant.js.map +1 -1
  6. package/dist/evm/aa-service/index.d.ts +1 -1
  7. package/dist/evm/aa-service/index.js +1 -2
  8. package/dist/evm/aa-service/index.js.map +1 -1
  9. package/dist/evm/aa-service/lib/kernel-account.d.ts +1 -1
  10. package/dist/evm/aa-service/lib/kernel-account.js +22 -6
  11. package/dist/evm/aa-service/lib/kernel-account.js.map +1 -1
  12. package/dist/evm/aa-service/lib/session-keys.d.ts +14 -17
  13. package/dist/evm/aa-service/lib/session-keys.js +40 -58
  14. package/dist/evm/aa-service/lib/session-keys.js.map +1 -1
  15. package/dist/evm/aa-service/lib/type.d.ts +2 -1
  16. package/dist/evm/aa-service/lib/type.js.map +1 -1
  17. package/dist/evm/aa-service/services/account-abstraction.d.ts +3 -29
  18. package/dist/evm/aa-service/services/account-abstraction.js +3 -67
  19. package/dist/evm/aa-service/services/account-abstraction.js.map +1 -1
  20. package/dist/evm/aa-service/services/bundler.js +2 -1
  21. package/dist/evm/aa-service/services/bundler.js.map +1 -1
  22. package/dist/evm/evm.d.ts +163 -1
  23. package/dist/evm/evm.js +259 -0
  24. package/dist/evm/evm.js.map +1 -1
  25. package/dist/evm/smartWallet.d.ts +11 -43
  26. package/dist/evm/smartWallet.js +136 -116
  27. package/dist/evm/smartWallet.js.map +1 -1
  28. package/dist/evm/utils.js +0 -1
  29. package/dist/evm/utils.js.map +1 -1
  30. package/dist/index.d.ts +1 -0
  31. package/dist/index.js +1 -0
  32. package/dist/index.js.map +1 -1
  33. package/dist/price.d.ts +2 -0
  34. package/dist/price.js +33 -0
  35. package/dist/price.js.map +1 -0
  36. package/dist/price.types.d.ts +38 -0
  37. package/dist/price.types.js +4 -0
  38. package/dist/price.types.js.map +1 -0
  39. package/dist/privacy/artifact-manager.d.ts +117 -0
  40. package/dist/privacy/artifact-manager.js +251 -0
  41. package/dist/privacy/artifact-manager.js.map +1 -0
  42. package/dist/privacy/broadcaster-client.d.ts +166 -0
  43. package/dist/privacy/broadcaster-client.js +261 -0
  44. package/dist/privacy/broadcaster-client.js.map +1 -0
  45. package/dist/privacy/index.d.ts +34 -0
  46. package/dist/privacy/index.js +56 -0
  47. package/dist/privacy/index.js.map +1 -0
  48. package/dist/privacy/network-config.d.ts +57 -0
  49. package/dist/privacy/network-config.js +118 -0
  50. package/dist/privacy/network-config.js.map +1 -0
  51. package/dist/privacy/poi-helper.d.ts +161 -0
  52. package/dist/privacy/poi-helper.js +249 -0
  53. package/dist/privacy/poi-helper.js.map +1 -0
  54. package/dist/privacy/railgun-engine.d.ts +135 -0
  55. package/dist/privacy/railgun-engine.js +205 -0
  56. package/dist/privacy/railgun-engine.js.map +1 -0
  57. package/dist/privacy/railgun-privacy-wallet.d.ts +288 -0
  58. package/dist/privacy/railgun-privacy-wallet.js +539 -0
  59. package/dist/privacy/railgun-privacy-wallet.js.map +1 -0
  60. package/dist/privacy/types.d.ts +229 -0
  61. package/dist/privacy/types.js +26 -0
  62. package/dist/privacy/types.js.map +1 -0
  63. package/dist/savings/savings-manager.d.ts +126 -0
  64. package/dist/savings/savings-manager.js +234 -0
  65. package/dist/savings/savings-manager.js.map +1 -0
  66. package/dist/savings/smart-savings.d.ts +74 -0
  67. package/dist/savings/smart-savings.js +152 -0
  68. package/dist/savings/smart-savings.js.map +1 -0
  69. package/dist/savings/types.d.ts +125 -0
  70. package/dist/savings/types.js +9 -0
  71. package/dist/savings/types.js.map +1 -0
  72. package/dist/svm/svm.d.ts +18 -0
  73. package/dist/svm/svm.js +35 -0
  74. package/dist/svm/svm.js.map +1 -1
  75. package/dist/test.js +53 -15
  76. package/dist/test.js.map +1 -1
  77. package/dist/vm.d.ts +14 -0
  78. package/dist/vm.js.map +1 -1
  79. package/package.json +2 -1
  80. package/utils/IChainWallet.ts +2 -0
  81. package/utils/constant.ts +63 -16
  82. package/utils/evm/aa-service/index.ts +0 -1
  83. package/utils/evm/aa-service/lib/kernel-account.ts +23 -8
  84. package/utils/evm/aa-service/lib/session-keys.ts +58 -60
  85. package/utils/evm/aa-service/lib/type.ts +2 -1
  86. package/utils/evm/aa-service/services/account-abstraction.ts +10 -76
  87. package/utils/evm/aa-service/services/bundler.ts +2 -1
  88. package/utils/evm/evm.ts +317 -0
  89. package/utils/evm/smartWallet.ts +118 -128
  90. package/utils/evm/utils.ts +1 -1
  91. package/utils/index.ts +1 -0
  92. package/utils/price.ts +37 -0
  93. package/utils/price.types.ts +45 -0
  94. package/utils/savings/savings-manager.ts +271 -0
  95. package/utils/savings/smart-savings.ts +184 -0
  96. package/utils/savings/types.ts +135 -0
  97. package/utils/svm/svm.ts +43 -2
  98. package/utils/test.ts +84 -19
  99. package/utils/vm.ts +12 -1
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ /**
3
+ * RAILGUN Engine Singleton
4
+ *
5
+ * Manages the global RAILGUN privacy engine initialization.
6
+ * Must be initialized once before using any privacy features.
7
+ *
8
+ * STATELESS: Does not store configuration or state beyond initialization flag.
9
+ * Implementer controls when/how to initialize.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.RailgunEngine = void 0;
13
+ const wallet_1 = require("@railgun-community/wallet");
14
+ /**
15
+ * RAILGUN Engine Singleton
16
+ *
17
+ * Manages the global RAILGUN privacy engine initialization.
18
+ * Must be initialized once before using any privacy features.
19
+ *
20
+ * STATELESS: Does not store any configuration or state.
21
+ * Implementer controls when/how to initialize.
22
+ */
23
+ class RailgunEngine {
24
+ static initialized = false;
25
+ static config = null;
26
+ /**
27
+ * Initialize RAILGUN privacy engine
28
+ *
29
+ * This is a one-time setup that must be called before any privacy operations.
30
+ * Implementer provides database and artifact storage.
31
+ *
32
+ * @param config - Engine configuration
33
+ * @param preloadedArtifacts - Optional pre-downloaded circuits
34
+ *
35
+ * @throws Error if already initialized or if configuration is invalid
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * import LevelDB from 'level-js';
40
+ * import { ArtifactManager } from './artifact-manager';
41
+ *
42
+ * const db = new LevelDB('./railgun-data');
43
+ * const artifactStore = ArtifactManager.createArtifactStore(
44
+ * './artifacts',
45
+ * { readFile, writeFile, exists, mkdir }
46
+ * );
47
+ *
48
+ * await RailgunEngine.initialize({
49
+ * walletSource: 'mywallet',
50
+ * db,
51
+ * artifactStore,
52
+ * poiNodeURLs: ['https://ppoi-agg.horsewithsixlegs.xyz'],
53
+ * useNativeArtifacts: false,
54
+ * skipMerkletreeScans: false
55
+ * });
56
+ * ```
57
+ */
58
+ static async initialize(config, preloadedArtifacts) {
59
+ if (this.initialized) {
60
+ throw new Error('RAILGUN engine already initialized');
61
+ }
62
+ // Validate configuration
63
+ this.validateConfig(config);
64
+ // If preloaded artifacts provided, populate artifact store
65
+ if (preloadedArtifacts) {
66
+ await this.preloadArtifacts(config.artifactStore, preloadedArtifacts);
67
+ }
68
+ // Start RAILGUN engine
69
+ await (0, wallet_1.startRailgunEngine)(config.walletSource, config.db, config.shouldDebug ?? false, config.artifactStore, config.useNativeArtifacts ?? false, config.skipMerkletreeScans ?? false, config.poiNodeURLs, config.customPOILists ?? [], config.verboseScanLogging ?? false);
70
+ this.initialized = true;
71
+ this.config = config;
72
+ }
73
+ /**
74
+ * Shutdown RAILGUN engine
75
+ *
76
+ * Cleanup resources and stop the engine.
77
+ * After shutdown, initialize() must be called again to use privacy features.
78
+ */
79
+ static async shutdown() {
80
+ if (!this.initialized) {
81
+ return;
82
+ }
83
+ await (0, wallet_1.stopRailgunEngine)();
84
+ this.initialized = false;
85
+ this.config = null;
86
+ }
87
+ /**
88
+ * Check if engine is initialized
89
+ */
90
+ static isInitialized() {
91
+ return this.initialized;
92
+ }
93
+ /**
94
+ * Get current configuration (read-only)
95
+ * Returns null if not initialized
96
+ */
97
+ static getConfig() {
98
+ return this.config ? { ...this.config } : null;
99
+ }
100
+ /**
101
+ * Load network provider and RAILGUN contracts
102
+ *
103
+ * Must be called for each network before using it.
104
+ * Returns network fees.
105
+ *
106
+ * @param network - Network to load
107
+ * @param rpcProvider - ethers.js provider for the network
108
+ * @param pollingInterval - RPC polling interval in seconds (default: 10)
109
+ * @returns Network fees (shield, unshield, NFT in basis points)
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * import { JsonRpcProvider } from 'ethers';
114
+ * import { NetworkName } from '@railgun-community/shared-models';
115
+ *
116
+ * const provider = new JsonRpcProvider('https://eth-mainnet.g.alchemy.com/v2/...');
117
+ * const fees = await RailgunEngine.loadNetwork(
118
+ * NetworkName.Ethereum,
119
+ * provider
120
+ * );
121
+ *
122
+ * console.log(`Shield fee: ${fees.shield / 100}%`); // 0.25%
123
+ * ```
124
+ */
125
+ static async loadNetwork(network, rpcProvider, // ethers.Provider
126
+ pollingInterval = 10) {
127
+ this.ensureInitialized();
128
+ const feesSerialized = await (0, wallet_1.loadProvider)(rpcProvider, network, pollingInterval);
129
+ return {
130
+ shield: feesSerialized.deposit,
131
+ unshield: feesSerialized.withdraw,
132
+ nft: feesSerialized.nft,
133
+ };
134
+ }
135
+ /**
136
+ * Set balance update callback
137
+ *
138
+ * Called when private balances change for any wallet.
139
+ *
140
+ * @param callback - Function to call on balance updates
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * RailgunEngine.setOnBalanceUpdate((balances, walletID, network) => {
145
+ * console.log(`Wallet ${walletID} on ${network}:`, balances);
146
+ * updateUI(balances);
147
+ * });
148
+ * ```
149
+ */
150
+ static setOnBalanceUpdate(callback) {
151
+ this.ensureInitialized();
152
+ (0, wallet_1.setOnBalanceUpdateCallback)(callback);
153
+ }
154
+ /**
155
+ * Set merkletree scan progress callback
156
+ *
157
+ * Called during blockchain scanning for private transactions.
158
+ *
159
+ * @param callback - Function to call with scan progress
160
+ *
161
+ * @example
162
+ * ```typescript
163
+ * RailgunEngine.setOnScanProgress((progress, network) => {
164
+ * console.log(`Scanning ${network}: ${progress}%`);
165
+ * updateProgressBar(progress);
166
+ * });
167
+ * ```
168
+ */
169
+ static setOnScanProgress(callback) {
170
+ this.ensureInitialized();
171
+ (0, wallet_1.setOnMerkletreeScanCallback)(callback);
172
+ }
173
+ // ===== PRIVATE HELPERS =====
174
+ static ensureInitialized() {
175
+ if (!this.initialized) {
176
+ throw new Error('RAILGUN engine not initialized. Call RailgunEngine.initialize() first.');
177
+ }
178
+ }
179
+ static validateConfig(config) {
180
+ if (!config.walletSource || config.walletSource.length > 16) {
181
+ throw new Error('walletSource must be 1-16 characters');
182
+ }
183
+ if (config.walletSource !== config.walletSource.toLowerCase()) {
184
+ throw new Error('walletSource must be lowercase');
185
+ }
186
+ if (!config.db) {
187
+ throw new Error('db (LevelDB instance) is required');
188
+ }
189
+ if (!config.artifactStore) {
190
+ throw new Error('artifactStore is required');
191
+ }
192
+ if (!config.poiNodeURLs || config.poiNodeURLs.length === 0) {
193
+ throw new Error('At least one POI node URL is required');
194
+ }
195
+ }
196
+ static async preloadArtifacts(artifactStore, preloaded) {
197
+ for (const [path, content] of preloaded.artifacts.entries()) {
198
+ const dir = path.substring(0, path.lastIndexOf('/'));
199
+ const filename = path.substring(path.lastIndexOf('/') + 1);
200
+ await artifactStore.storeFile(dir, filename, content);
201
+ }
202
+ }
203
+ }
204
+ exports.RailgunEngine = RailgunEngine;
205
+ //# sourceMappingURL=railgun-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"railgun-engine.js","sourceRoot":"","sources":["../../utils/privacy/railgun-engine.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,sDAMmC;AAUnC;;;;;;;;GAQG;AACH,MAAa,aAAa;IAChB,MAAM,CAAC,WAAW,GAAY,KAAK,CAAC;IACpC,MAAM,CAAC,MAAM,GAA+B,IAAI,CAAC;IAEzD;;;;;;;;;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CAAC,YAAY,KAAK,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,CAAC;YAC9D,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC/C,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,KAAK,CAAC,gBAAgB,CACnC,aAAkB,EAClB,SAA6B;QAE7B,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;YAC5D,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;YACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YAE3D,MAAM,aAAa,CAAC,SAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;;AAjOH,sCAkOC"}
@@ -0,0 +1,288 @@
1
+ /**
2
+ * RAILGUN Privacy Wallet
3
+ *
4
+ * Core class for RAILGUN privacy operations:
5
+ * - Create/load private wallets
6
+ * - Shield (public → private)
7
+ * - Unshield (private → public)
8
+ * - Private transfers (private → private)
9
+ * - Query private balances
10
+ *
11
+ * STATELESS: Does not store wallet data.
12
+ * Implementer must store RailgunWalletInfo and manage encryption keys.
13
+ */
14
+ import { NetworkName } from '@railgun-community/shared-models';
15
+ import { RailgunWalletInfo, ShieldTransaction, UnshieldTransaction, PrivateTransferTransaction, ShieldOptions, UnshieldOptions, PrivateTransferOptions, PrivateBalance } from './types';
16
+ /**
17
+ * RAILGUN Privacy Wallet
18
+ *
19
+ * Provides privacy features for a single RAILGUN wallet.
20
+ * Wallets are encrypted and stored in the LevelDB database.
21
+ *
22
+ * STATELESS DESIGN:
23
+ * - Does NOT store wallet data internally
24
+ * - All operations require explicit parameters
25
+ * - Implementer manages RailgunWalletInfo storage
26
+ */
27
+ export declare class RailgunPrivacyWallet {
28
+ private railgunWalletID;
29
+ private railgunAddress;
30
+ /**
31
+ * Private constructor - use static create() or load() methods
32
+ */
33
+ private constructor();
34
+ /**
35
+ * Create a new RAILGUN wallet from mnemonic
36
+ *
37
+ * IMPORTANT: This creates an encrypted wallet in the LevelDB database.
38
+ * Returns RailgunWalletInfo that MUST be stored by implementer.
39
+ *
40
+ * @param encryptionKey - Key to encrypt wallet (derive from user password)
41
+ * @param mnemonic - BIP-39 mnemonic phrase
42
+ * @param creationBlockNumbers - Optional block numbers per chain for faster syncing
43
+ *
44
+ * @returns RailgunWalletInfo to store
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * import { Wallet } from 'ethers';
49
+ *
50
+ * const mnemonic = Wallet.createRandom().mnemonic.phrase;
51
+ * const encryptionKey = deriveKeyFromPassword(userPassword);
52
+ *
53
+ * const walletInfo = await RailgunPrivacyWallet.create(
54
+ * encryptionKey,
55
+ * mnemonic
56
+ * );
57
+ *
58
+ * // Implementer stores this
59
+ * await storage.save({
60
+ * railgunWalletID: walletInfo.railgunWalletID,
61
+ * railgunAddress: walletInfo.railgunAddress,
62
+ * viewingPrivateKey: encrypt(walletInfo.viewingPrivateKey),
63
+ * spendingPublicKey: walletInfo.spendingPublicKey
64
+ * });
65
+ * ```
66
+ */
67
+ static create(encryptionKey: string, mnemonic: string, creationBlockNumbers?: Record<string, number>): Promise<RailgunWalletInfo>;
68
+ /**
69
+ * Load existing RAILGUN wallet by ID
70
+ *
71
+ * Retrieves wallet from LevelDB database.
72
+ * Implementer must have stored railgunWalletID from create().
73
+ *
74
+ * @param encryptionKey - Same key used during creation
75
+ * @param railgunWalletID - Wallet ID from RailgunWalletInfo
76
+ *
77
+ * @returns RailgunPrivacyWallet instance
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * const stored = await storage.get(userId);
82
+ * const encryptionKey = deriveKeyFromPassword(userPassword);
83
+ *
84
+ * const wallet = await RailgunPrivacyWallet.load(
85
+ * encryptionKey,
86
+ * stored.railgunWalletID
87
+ * );
88
+ * ```
89
+ */
90
+ static load(encryptionKey: string, railgunWalletID: string): Promise<RailgunPrivacyWallet>;
91
+ /**
92
+ * Create RAILGUN wallet for specific BIP-44 account index
93
+ *
94
+ * Useful for linking privacy to savings pockets or account indices.
95
+ *
96
+ * @param encryptionKey - Encryption key
97
+ * @param mnemonic - BIP-39 mnemonic
98
+ * @param accountIndex - BIP-44 account index
99
+ * @param creationBlockNumbers - Optional block numbers
100
+ *
101
+ * @returns RailgunWalletInfo to store
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * // Create privacy wallet for savings account #1
106
+ * const walletInfo = await RailgunPrivacyWallet.createForAccount(
107
+ * encryptionKey,
108
+ * mnemonic,
109
+ * 1 // Same index as savings pocket
110
+ * );
111
+ * ```
112
+ */
113
+ static createForAccount(encryptionKey: string, mnemonic: string, accountIndex: number, creationBlockNumbers?: Record<string, number>): Promise<RailgunWalletInfo>;
114
+ /**
115
+ * Build shield transaction (ERC-20)
116
+ *
117
+ * Shields ERC-20 tokens from public address into this RAILGUN wallet.
118
+ * NO PROOF REQUIRED - direct contract interaction.
119
+ *
120
+ * Fees: 0.25% shield fee
121
+ * Standby: 1 hour on mainnet before spendable
122
+ *
123
+ * @param fromAddress - Public address sending tokens
124
+ * @param tokenAddress - ERC-20 contract address
125
+ * @param amount - Amount to shield (in smallest units)
126
+ * @param network - Network name
127
+ * @param options - Shield options
128
+ *
129
+ * @returns Shield transaction ready for broadcast
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * const shieldTx = await wallet.buildShield(
134
+ * publicAddress,
135
+ * USDC_ADDRESS,
136
+ * parseUnits("100", 6), // 100 USDC
137
+ * NetworkName.Ethereum
138
+ * );
139
+ *
140
+ * // Broadcast using standard wallet
141
+ * await publicWallet.sendTransaction(shieldTx);
142
+ * ```
143
+ */
144
+ buildShield(fromAddress: string, tokenAddress: string, amount: bigint, network: NetworkName, options?: ShieldOptions): Promise<ShieldTransaction>;
145
+ /**
146
+ * Build shield transaction (base token)
147
+ *
148
+ * Shields native token (ETH, MATIC, BNB) into RAILGUN.
149
+ *
150
+ * @param fromAddress - Public address
151
+ * @param amount - Amount to shield (in wei)
152
+ * @param network - Network name
153
+ * @param options - Shield options
154
+ *
155
+ * @returns Shield transaction
156
+ */
157
+ buildShieldBaseToken(fromAddress: string, amount: bigint, network: NetworkName, options?: ShieldOptions): Promise<ShieldTransaction>;
158
+ /**
159
+ * Build unshield transaction (ERC-20)
160
+ *
161
+ * Unshields ERC-20 tokens from RAILGUN to public address.
162
+ * REQUIRES PROOF GENERATION (20-30 seconds).
163
+ *
164
+ * Fees: 0.25% unshield fee
165
+ *
166
+ * @param toAddress - Public address to receive tokens
167
+ * @param tokenAddress - ERC-20 contract address
168
+ * @param amount - Amount to unshield
169
+ * @param network - Network name
170
+ * @param encryptionKey - Wallet encryption key
171
+ * @param options - Unshield options
172
+ *
173
+ * @returns Unshield transaction with proof
174
+ *
175
+ * @example
176
+ * ```typescript
177
+ * const unshieldTx = await wallet.buildUnshield(
178
+ * recipientAddress,
179
+ * USDC_ADDRESS,
180
+ * parseUnits("50", 6),
181
+ * NetworkName.Ethereum,
182
+ * encryptionKey,
183
+ * {
184
+ * onProgress: (p) => console.log(`Proof: ${p}%`)
185
+ * }
186
+ * );
187
+ *
188
+ * // Broadcast
189
+ * await wallet.sendTransaction(unshieldTx);
190
+ * ```
191
+ */
192
+ buildUnshield(toAddress: string, tokenAddress: string, amount: bigint, network: NetworkName, encryptionKey: string, options?: UnshieldOptions): Promise<UnshieldTransaction>;
193
+ /**
194
+ * Build private transfer transaction
195
+ *
196
+ * Transfers tokens from this RAILGUN wallet to another 0zk address.
197
+ * Fully encrypted - sender, receiver, amount all hidden.
198
+ * REQUIRES PROOF GENERATION (20-30 seconds).
199
+ *
200
+ * @param toRailgunAddress - Recipient's 0zk address
201
+ * @param tokenAddress - ERC-20 contract address
202
+ * @param amount - Amount to transfer
203
+ * @param network - Network name
204
+ * @param encryptionKey - Wallet encryption key
205
+ * @param options - Transfer options (broadcasterFee REQUIRED for anonymity)
206
+ *
207
+ * @returns Private transfer transaction with proof
208
+ *
209
+ * @example
210
+ * ```typescript
211
+ * const transferTx = await wallet.buildPrivateTransfer(
212
+ * "0zk1234...",
213
+ * USDC_ADDRESS,
214
+ * parseUnits("25", 6),
215
+ * NetworkName.Ethereum,
216
+ * encryptionKey,
217
+ * {
218
+ * broadcasterFee: {
219
+ * tokenAddress: USDC_ADDRESS,
220
+ * amount: parseUnits("0.1", 6)
221
+ * },
222
+ * onProgress: (p) => console.log(`${p}%`)
223
+ * }
224
+ * );
225
+ *
226
+ * // Submit via broadcaster for anonymity
227
+ * await broadcasterClient.submitTransaction(transferTx);
228
+ * ```
229
+ */
230
+ buildPrivateTransfer(toRailgunAddress: string, tokenAddress: string, amount: bigint, network: NetworkName, encryptionKey: string, options: PrivateTransferOptions): Promise<PrivateTransferTransaction>;
231
+ /**
232
+ * Scan blockchain for new private transactions
233
+ *
234
+ * Must be called before getBalances() to get latest data.
235
+ * Scans merkletree for encrypted notes belonging to this wallet.
236
+ *
237
+ * @param network - Network to scan
238
+ *
239
+ * @example
240
+ * ```typescript
241
+ * await wallet.scanTransactions(NetworkName.Ethereum);
242
+ * const balances = await wallet.getBalances(NetworkName.Ethereum);
243
+ * ```
244
+ */
245
+ scanTransactions(network: NetworkName): Promise<void>;
246
+ /**
247
+ * Get private balances for this wallet
248
+ *
249
+ * Returns balances grouped by POI bucket status.
250
+ * Call scanTransactions() first for latest data.
251
+ *
252
+ * @param network - Network to query
253
+ * @param tokenAddresses - Optional filter for specific tokens
254
+ *
255
+ * @returns Array of private balances
256
+ *
257
+ * @example
258
+ * ```typescript
259
+ * const balances = await wallet.getBalances(
260
+ * NetworkName.Ethereum,
261
+ * [USDC_ADDRESS, DAI_ADDRESS]
262
+ * );
263
+ *
264
+ * const spendable = balances.filter(b => b.bucket === BalanceBucket.Spendable);
265
+ * ```
266
+ */
267
+ getBalances(network: NetworkName, tokenAddresses?: string[]): Promise<PrivateBalance[]>;
268
+ /**
269
+ * Get balance for single token
270
+ *
271
+ * @param network - Network to query
272
+ * @param tokenAddress - Token contract address
273
+ *
274
+ * @returns Total balance across all buckets
275
+ */
276
+ getBalance(network: NetworkName, tokenAddress: string): Promise<bigint>;
277
+ /**
278
+ * Get spendable balance only
279
+ *
280
+ * @param network - Network to query
281
+ * @param tokenAddress - Token contract address
282
+ *
283
+ * @returns Spendable balance (excludes pending/blocked)
284
+ */
285
+ getSpendableBalance(network: NetworkName, tokenAddress: string): Promise<bigint>;
286
+ getRailgunAddress(): string;
287
+ getRailgunWalletID(): string;
288
+ }