@continuumdao/ctm-mpc-defi 0.2.60 → 0.2.62
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.
- package/dist/agent/catalog.cjs +67 -17
- package/dist/agent/catalog.cjs.map +1 -1
- package/dist/agent/catalog.d.ts +134 -7
- package/dist/agent/catalog.js +66 -18
- package/dist/agent/catalog.js.map +1 -1
- package/dist/agent/skills/railgun/SKILL.md +14 -5
- package/dist/protocols/evm/railgun/index.cjs +1341 -167
- package/dist/protocols/evm/railgun/index.cjs.map +1 -1
- package/dist/protocols/evm/railgun/index.d.ts +139 -4
- package/dist/protocols/evm/railgun/index.js +1317 -170
- package/dist/protocols/evm/railgun/index.js.map +1 -1
- package/package.json +4 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Address } from 'viem';
|
|
2
|
-
import { TXIDVersion, NetworkName, TransactionGasDetails } from '@railgun-community/shared-models';
|
|
2
|
+
import { TXIDVersion, NetworkName, TransactionGasDetails, RailgunBalancesEvent } from '@railgun-community/shared-models';
|
|
3
3
|
|
|
4
4
|
/** Aligns with app NonEvmChainType + 'evm'. Extend as mpc-auth adds chains. */
|
|
5
5
|
type ChainCategory = 'evm' | 'solana' | 'near' | 'sui' | 'ton' | 'stellar';
|
|
@@ -226,8 +226,8 @@ type AllowanceReader = (args: {
|
|
|
226
226
|
}) => Promise<bigint>;
|
|
227
227
|
declare function setRailgunPopulateShieldForTests(fn: PopulateShield | null): void;
|
|
228
228
|
declare function setRailgunAllowanceReaderForTests(fn: AllowanceReader | null): void;
|
|
229
|
-
/** Railgun hashes the 65-byte personal_sign.
|
|
230
|
-
declare function shieldPrivateKeyFromSignature(signature: string):
|
|
229
|
+
/** Railgun hashes the 65-byte personal_sign. The node often returns r||s without the recovery byte. */
|
|
230
|
+
declare function shieldPrivateKeyFromSignature(signature: string, executorAddress?: string): Promise<`0x${string}`>;
|
|
231
231
|
declare function buildEvmMultisignBodyWethUnwrap(args: {
|
|
232
232
|
keyGen: KeyGenSubset;
|
|
233
233
|
executorAddress: Address | string;
|
|
@@ -249,8 +249,66 @@ type RailgunPrivateActionArgs = {
|
|
|
249
249
|
amountWei: string;
|
|
250
250
|
recipientAddress: string;
|
|
251
251
|
memoText?: string;
|
|
252
|
+
onBroadcasterSearch?: () => void;
|
|
253
|
+
onBroadcasterNote?: (note: string) => void;
|
|
252
254
|
onProofProgress?: (progress: number) => void;
|
|
255
|
+
onProofStatusRefresh?: () => void;
|
|
256
|
+
broadcasterAddress?: string;
|
|
257
|
+
broadcasterFeesId?: string;
|
|
253
258
|
};
|
|
259
|
+
/** Railgun replaces the note-check text with a short sentence. Keep the required amount and balance when they are still attached. */
|
|
260
|
+
declare function railgunDetailedError(err: unknown): string;
|
|
261
|
+
/** The broadcaster accepted the proof request and asked for a fresh proof-of-innocence status. */
|
|
262
|
+
declare function broadcasterAskedToRefreshProofStatus(err: unknown): boolean;
|
|
263
|
+
declare function broadcasterRefusedForGas(err: unknown): boolean;
|
|
264
|
+
/** A fee message can take about a minute to arrive after the spending-wallet sync. */
|
|
265
|
+
declare const BROADCASTER_PROOF_WAIT_MS: number;
|
|
266
|
+
/** Same margin the Waku client uses before it treats a fee as expired. */
|
|
267
|
+
declare const BROADCASTER_FEE_MIN_REMAINING_MS = 40000;
|
|
268
|
+
declare function broadcasterFeeStillValid(expiration: number, now?: number): boolean;
|
|
269
|
+
type RailgunBroadcasterChoice = {
|
|
270
|
+
feesId: string;
|
|
271
|
+
railgunAddress: string;
|
|
272
|
+
feeWei: string;
|
|
273
|
+
ratio: string | null;
|
|
274
|
+
coversGas: boolean;
|
|
275
|
+
reliability: number;
|
|
276
|
+
expiration: number;
|
|
277
|
+
tokenDecimals: number;
|
|
278
|
+
};
|
|
279
|
+
declare function listRailgunBroadcasters(args: {
|
|
280
|
+
chainId: number;
|
|
281
|
+
rpcUrl: string;
|
|
282
|
+
chainDetail: EvmChainDetail;
|
|
283
|
+
tokenAddress: string;
|
|
284
|
+
kind: string;
|
|
285
|
+
}): Promise<RailgunBroadcasterChoice[]>;
|
|
286
|
+
declare function quoteRailgunBroadcasterFee(args: {
|
|
287
|
+
kind: 'transfer' | 'unshield';
|
|
288
|
+
chainId: number;
|
|
289
|
+
rpcUrl: string;
|
|
290
|
+
chainDetail: EvmChainDetail;
|
|
291
|
+
tokenAddress: string;
|
|
292
|
+
amountWei: string;
|
|
293
|
+
recipientAddress: string;
|
|
294
|
+
memoText?: string;
|
|
295
|
+
walletId: string;
|
|
296
|
+
encryptionKey: string;
|
|
297
|
+
}): Promise<{
|
|
298
|
+
feeWei: string;
|
|
299
|
+
tokenAddress: string;
|
|
300
|
+
}>;
|
|
301
|
+
/** Broadcaster fee from the live fee rate and chain gas. A view-only wallet cannot run the proof estimate. */
|
|
302
|
+
declare function quoteRailgunBroadcasterFeeRate(args: {
|
|
303
|
+
kind: 'transfer' | 'unshield';
|
|
304
|
+
chainId: number;
|
|
305
|
+
rpcUrl: string;
|
|
306
|
+
chainDetail: EvmChainDetail;
|
|
307
|
+
tokenAddress: string;
|
|
308
|
+
}): Promise<{
|
|
309
|
+
feeWei: string;
|
|
310
|
+
tokenAddress: string;
|
|
311
|
+
}>;
|
|
254
312
|
declare function railgunPrivateTransfer(args: RailgunPrivateActionArgs): Promise<{
|
|
255
313
|
txHash: string;
|
|
256
314
|
}>;
|
|
@@ -258,6 +316,36 @@ declare function railgunUnshield(args: RailgunPrivateActionArgs): Promise<{
|
|
|
258
316
|
txHash: string;
|
|
259
317
|
}>;
|
|
260
318
|
|
|
319
|
+
type RailgunFeeKind = 'shield' | 'transfer' | 'unshield';
|
|
320
|
+
type RailgunFeeQuote = {
|
|
321
|
+
kind: RailgunFeeKind;
|
|
322
|
+
amountWei: string;
|
|
323
|
+
protocolFeeBasisPoints: string;
|
|
324
|
+
protocolFeeWei: string;
|
|
325
|
+
receivedWei: string;
|
|
326
|
+
broadcasterFeeWei: string;
|
|
327
|
+
broadcasterTokenAddress: string;
|
|
328
|
+
totalDebitWei: string;
|
|
329
|
+
broadcasterError?: string;
|
|
330
|
+
};
|
|
331
|
+
declare function railgunProtocolFee(amount: bigint, basisPoints: bigint): {
|
|
332
|
+
fee: bigint;
|
|
333
|
+
received: bigint;
|
|
334
|
+
};
|
|
335
|
+
declare function clearRailgunFeeCache(): void;
|
|
336
|
+
declare function quoteRailgunFee(args: {
|
|
337
|
+
kind: RailgunFeeKind;
|
|
338
|
+
chainId: number;
|
|
339
|
+
rpcUrl: string;
|
|
340
|
+
chainDetail?: EvmChainDetail;
|
|
341
|
+
tokenAddress: string;
|
|
342
|
+
amountWei: string;
|
|
343
|
+
recipientAddress?: string;
|
|
344
|
+
memoText?: string;
|
|
345
|
+
walletId?: string;
|
|
346
|
+
encryptionKey?: string;
|
|
347
|
+
}): Promise<RailgunFeeQuote>;
|
|
348
|
+
|
|
261
349
|
declare function createRailgunBrowserWallet(args: {
|
|
262
350
|
encryptionKey: string;
|
|
263
351
|
mnemonic: string;
|
|
@@ -272,25 +360,72 @@ declare function openRailgunViewOnlyWallet(args: {
|
|
|
272
360
|
encryptionKey: string;
|
|
273
361
|
shareableViewingKey: string;
|
|
274
362
|
chainId: number;
|
|
363
|
+
keyGenId?: string;
|
|
275
364
|
}): Promise<{
|
|
276
365
|
walletId: string;
|
|
277
366
|
railgunAddress: string;
|
|
278
367
|
}>;
|
|
279
368
|
declare function discardRailgunWallet(walletId: string): Promise<void>;
|
|
280
369
|
declare function railgunAddressIsValid(address: string): Promise<boolean>;
|
|
370
|
+
declare function recordRailgunWalletBalance(event: RailgunBalancesEvent): void;
|
|
371
|
+
declare function railgunWalletBalanceSnapshot(walletId: string, chainId: number): RailgunPrivateBalanceRow[];
|
|
372
|
+
declare function clearRailgunWalletBalances(): void;
|
|
281
373
|
/** History sync emits Complete on the merkletree callback. It does not emit the wallet event awaitWalletScan waits for. */
|
|
282
374
|
declare function utxoScanTerminalStatus(scanStatus: string): 'done' | 'failed' | 'pending';
|
|
375
|
+
/** After the note scan reports 100%, wait this long for the spendable-note check, then save the balances already decrypted. */
|
|
376
|
+
declare const RAILGUN_TXID_WAIT_AFTER_NOTES_MS = 45000;
|
|
377
|
+
/** After the history walk, sync blocks that were mined while it was running. A shield in that gap is otherwise left out. */
|
|
378
|
+
declare const RAILGUN_CATCH_UP_MS = 120000;
|
|
379
|
+
/** The first merkletree walk can take much longer than the catch-up window. Give up only when progress itself stops. */
|
|
380
|
+
declare const RAILGUN_MERKLETREE_STALL_MS: number;
|
|
381
|
+
declare const RAILGUN_SCAN_BEHIND_NOTE = "The shielded balance is saved. The newest blocks did not finish syncing, so a shield that just landed may be missing until the next scan.";
|
|
382
|
+
declare const RAILGUN_SCAN_STOPPED_NOTE = "The note scan stopped before it reached the latest block. The shielded balance is unchanged until a scan finishes.";
|
|
383
|
+
/** A catch-up timer that expires while leaves are still arriving has not finished the tree. */
|
|
384
|
+
declare function merkletreeScanStillRunning(args: {
|
|
385
|
+
sawProgress: boolean;
|
|
386
|
+
notesFinished: boolean;
|
|
387
|
+
terminal: 'done' | 'failed' | 'pending';
|
|
388
|
+
}): boolean;
|
|
389
|
+
declare function railgunScanRecord(merkletree: 'done' | 'failed', balanceCount: number, caughtUp: boolean): {
|
|
390
|
+
scanStatus: RailgunScanStatus;
|
|
391
|
+
notes: string;
|
|
392
|
+
};
|
|
393
|
+
declare function balancesToKeepAfterNoteScan(decrypted: RailgunPrivateBalanceRow[], afterRefresh: RailgunPrivateBalanceRow[], previous: RailgunPrivateBalanceRow[]): RailgunPrivateBalanceRow[];
|
|
394
|
+
declare const RAILGUN_SPEND_SCAN_STOPPED = "The spending wallet did not finish scanning private notes.";
|
|
395
|
+
/**
|
|
396
|
+
* History complete is emitted at 100% after this wallet's notes are decrypted.
|
|
397
|
+
* The decrypt-complete wallet event is deferred until after that, so 100% is the
|
|
398
|
+
* signal to build the proof. Give up only when leaves stop arriving before then.
|
|
399
|
+
*/
|
|
400
|
+
declare function spendingScanReadyAfterHistory(progress: number, scanStatus: string): boolean;
|
|
401
|
+
declare function spendingNoteScanGaveUp(args: {
|
|
402
|
+
walletReady: boolean;
|
|
403
|
+
sawProgress: boolean;
|
|
404
|
+
notesFinished: boolean;
|
|
405
|
+
msSinceProgress: number;
|
|
406
|
+
msWaitingForDecrypt: number | null;
|
|
407
|
+
}): boolean;
|
|
408
|
+
/** Decrypt this spending wallet's notes before a proof. A view-only scan does not fill this wallet. */
|
|
409
|
+
declare function scanSpendingWalletNotes(args: {
|
|
410
|
+
chainId: number;
|
|
411
|
+
rpcUrl: string;
|
|
412
|
+
walletId: string;
|
|
413
|
+
onProgress?: (progress: number) => void;
|
|
414
|
+
}): Promise<void>;
|
|
283
415
|
declare function scanRailgunPrivateBalances(args: {
|
|
284
416
|
chainId: number;
|
|
285
417
|
rpcUrl: string;
|
|
286
418
|
walletId: string;
|
|
287
419
|
onProgress?: (progress: number) => void;
|
|
420
|
+
onBalances?: (balances: RailgunPrivateBalanceRow[]) => void;
|
|
288
421
|
}): Promise<{
|
|
289
422
|
scanStatus: RailgunScanStatus;
|
|
290
423
|
balances: RailgunPrivateBalanceRow[];
|
|
424
|
+
settled: boolean;
|
|
425
|
+
notes: string;
|
|
291
426
|
}>;
|
|
292
427
|
|
|
293
428
|
declare const RAILGUN_PROTOCOL_ID = "railgun";
|
|
294
429
|
declare const railgunProtocolModule: ProtocolModule;
|
|
295
430
|
|
|
296
|
-
export { RAILGUN_CTM_DISABLED_MESSAGE, RAILGUN_CTM_ENABLED, RAILGUN_POPULAR_ASSET_LIMIT, RAILGUN_PROTOCOL_ID, RAILGUN_WALLET_LOCKED_MESSAGE, type RailgunNetworkRow, type RailgunNetworkSource, type RailgunPrivateActionArgs, type RailgunPrivateBalanceRow, type RailgunPrivateBalanceSnapshot, type RailgunScanStatus, type RailgunShieldArgs, type RailgunWalletSession, type ShieldCommitmentLike, assertRailgunCtmAllowed, buildEvmMultisignBodyRailgunShield, buildEvmMultisignBodyWethUnwrap, clearRailgunNetworkCache, clearRailgunPopularAssetCache, clearRailgunPrivateBalanceSnapshots, commitmentsFromShieldIndex, createRailgunBrowserWallet, discardRailgunWallet, getRailgunWalletSession, loadRailgunNetworks, loadRailgunPopularAssets, loadRailgunSupportedChainIds, openRailgunViewOnlyWallet, publishRailgunPrivateBalanceSnapshot, railgunAddressIsValid, railgunFetchPopularAssets, railgunFetchPrivateBalances, railgunFetchPrivateBalancesSummary, railgunNetworkByChainId, railgunPrivateTransfer, railgunProtocolModule, railgunShareableViewingKey, railgunUnshield, rankPopularShieldTokens, readRailgunPrivateBalanceSnapshot, requireRailgunWalletSession, scanRailgunPrivateBalances, selectRailgunNetworks, setRailgunAllowanceReaderForTests, setRailgunPopulateShieldForTests, setRailgunShieldLogReaderForTests, setRailgunWalletSession, shieldIndexEndpoint, shieldPrivateKeyFromSignature, unlockRailgunBrowserWallet, utxoScanTerminalStatus };
|
|
431
|
+
export { BROADCASTER_FEE_MIN_REMAINING_MS, BROADCASTER_PROOF_WAIT_MS, RAILGUN_CATCH_UP_MS, RAILGUN_CTM_DISABLED_MESSAGE, RAILGUN_CTM_ENABLED, RAILGUN_MERKLETREE_STALL_MS, RAILGUN_POPULAR_ASSET_LIMIT, RAILGUN_PROTOCOL_ID, RAILGUN_SCAN_BEHIND_NOTE, RAILGUN_SCAN_STOPPED_NOTE, RAILGUN_SPEND_SCAN_STOPPED, RAILGUN_TXID_WAIT_AFTER_NOTES_MS, RAILGUN_WALLET_LOCKED_MESSAGE, type RailgunBroadcasterChoice, type RailgunFeeKind, type RailgunFeeQuote, type RailgunNetworkRow, type RailgunNetworkSource, type RailgunPrivateActionArgs, type RailgunPrivateBalanceRow, type RailgunPrivateBalanceSnapshot, type RailgunScanStatus, type RailgunShieldArgs, type RailgunWalletSession, type ShieldCommitmentLike, assertRailgunCtmAllowed, balancesToKeepAfterNoteScan, broadcasterAskedToRefreshProofStatus, broadcasterFeeStillValid, broadcasterRefusedForGas, buildEvmMultisignBodyRailgunShield, buildEvmMultisignBodyWethUnwrap, clearRailgunFeeCache, clearRailgunNetworkCache, clearRailgunPopularAssetCache, clearRailgunPrivateBalanceSnapshots, clearRailgunWalletBalances, commitmentsFromShieldIndex, createRailgunBrowserWallet, discardRailgunWallet, getRailgunWalletSession, listRailgunBroadcasters, loadRailgunNetworks, loadRailgunPopularAssets, loadRailgunSupportedChainIds, merkletreeScanStillRunning, openRailgunViewOnlyWallet, publishRailgunPrivateBalanceSnapshot, quoteRailgunBroadcasterFee, quoteRailgunBroadcasterFeeRate, quoteRailgunFee, railgunAddressIsValid, railgunDetailedError, railgunFetchPopularAssets, railgunFetchPrivateBalances, railgunFetchPrivateBalancesSummary, railgunNetworkByChainId, railgunPrivateTransfer, railgunProtocolFee, railgunProtocolModule, railgunScanRecord, railgunShareableViewingKey, railgunUnshield, railgunWalletBalanceSnapshot, rankPopularShieldTokens, readRailgunPrivateBalanceSnapshot, recordRailgunWalletBalance, requireRailgunWalletSession, scanRailgunPrivateBalances, scanSpendingWalletNotes, selectRailgunNetworks, setRailgunAllowanceReaderForTests, setRailgunPopulateShieldForTests, setRailgunShieldLogReaderForTests, setRailgunWalletSession, shieldIndexEndpoint, shieldPrivateKeyFromSignature, spendingNoteScanGaveUp, spendingScanReadyAfterHistory, unlockRailgunBrowserWallet, utxoScanTerminalStatus };
|