@veil-cash/sdk 0.2.0 → 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.
- package/README.md +218 -41
- package/dist/cli/index.cjs +507 -130
- package/dist/index.cjs +214 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +172 -4
- package/dist/index.d.ts +172 -4
- package/dist/index.js +210 -32
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/abi.ts +30 -0
- package/src/addresses.ts +40 -1
- package/src/balance.ts +22 -15
- package/src/cli/commands/balance.ts +114 -54
- package/src/cli/commands/deposit.ts +76 -33
- package/src/cli/commands/init.ts +45 -8
- package/src/cli/commands/private-balance.ts +6 -1
- package/src/cli/commands/queue-balance.ts +5 -1
- package/src/cli/commands/register.ts +47 -12
- package/src/cli/commands/transfer.ts +23 -10
- package/src/cli/commands/withdraw.ts +13 -5
- package/src/cli/index.ts +1 -1
- package/src/deposit.ts +106 -1
- package/src/index.ts +8 -2
- package/src/keypair.ts +79 -0
- package/src/relay.ts +2 -2
- package/src/transfer.ts +14 -11
- package/src/types.ts +9 -2
- package/src/withdraw.ts +7 -6
package/dist/index.d.cts
CHANGED
|
@@ -79,7 +79,7 @@ declare class Utxo {
|
|
|
79
79
|
/**
|
|
80
80
|
* Supported tokens
|
|
81
81
|
*/
|
|
82
|
-
type Token = 'ETH' | 'USDC';
|
|
82
|
+
type Token = 'ETH' | 'USDC' | 'CBBTC';
|
|
83
83
|
/**
|
|
84
84
|
* Encrypted message format (x25519-xsalsa20-poly1305)
|
|
85
85
|
*/
|
|
@@ -99,6 +99,9 @@ interface NetworkAddresses {
|
|
|
99
99
|
usdcPool: `0x${string}`;
|
|
100
100
|
usdcQueue: `0x${string}`;
|
|
101
101
|
usdcToken: `0x${string}`;
|
|
102
|
+
cbbtcPool: `0x${string}`;
|
|
103
|
+
cbbtcQueue: `0x${string}`;
|
|
104
|
+
cbbtcToken: `0x${string}`;
|
|
102
105
|
chainId: number;
|
|
103
106
|
relayUrl: string;
|
|
104
107
|
}
|
|
@@ -177,7 +180,7 @@ interface PrivateBalanceResult {
|
|
|
177
180
|
/**
|
|
178
181
|
* Pool type for relay operations
|
|
179
182
|
*/
|
|
180
|
-
type RelayPool = 'eth' | 'usdc';
|
|
183
|
+
type RelayPool = 'eth' | 'usdc' | 'cbbtc';
|
|
181
184
|
/**
|
|
182
185
|
* Type of relay transaction
|
|
183
186
|
*/
|
|
@@ -269,6 +272,8 @@ interface BuildWithdrawProofOptions {
|
|
|
269
272
|
recipient: `0x${string}`;
|
|
270
273
|
/** User's keypair for signing */
|
|
271
274
|
keypair: Keypair;
|
|
275
|
+
/** Pool to withdraw from (default: 'eth') */
|
|
276
|
+
pool?: RelayPool;
|
|
272
277
|
/** Optional RPC URL */
|
|
273
278
|
rpcUrl?: string;
|
|
274
279
|
/** Progress callback */
|
|
@@ -284,6 +289,8 @@ interface BuildTransferProofOptions {
|
|
|
284
289
|
recipientAddress: `0x${string}`;
|
|
285
290
|
/** Sender's keypair */
|
|
286
291
|
senderKeypair: Keypair;
|
|
292
|
+
/** Pool to transfer in (default: 'eth') */
|
|
293
|
+
pool?: RelayPool;
|
|
287
294
|
/** Optional RPC URL */
|
|
288
295
|
rpcUrl?: string;
|
|
289
296
|
/** Progress callback */
|
|
@@ -351,6 +358,16 @@ interface UtxoSelectionResult {
|
|
|
351
358
|
* Generates and manages keypairs for Veil deposits
|
|
352
359
|
*/
|
|
353
360
|
|
|
361
|
+
/**
|
|
362
|
+
* Canonical message signed by a wallet to derive a Veil keypair.
|
|
363
|
+
* Must match the frontend's SIGNED_MESSAGE in data/wallet/config.ts.
|
|
364
|
+
*/
|
|
365
|
+
declare const VEIL_SIGNED_MESSAGE = "Sign this message to create your Veil Wallet private key. This will be used to decrypt your balances. Ensure you are signing this message on the Veil Cash website.";
|
|
366
|
+
/**
|
|
367
|
+
* Any async function that performs EIP-191 personal_sign and returns a 0x-prefixed signature.
|
|
368
|
+
* Used with Keypair.fromSigner() to support external signing services.
|
|
369
|
+
*/
|
|
370
|
+
type MessageSigner = (message: string) => Promise<string>;
|
|
354
371
|
/**
|
|
355
372
|
* Pack encrypted message into hex string
|
|
356
373
|
*/
|
|
@@ -410,6 +427,59 @@ declare class Keypair {
|
|
|
410
427
|
* @returns Keypair instance (privkey will be null)
|
|
411
428
|
*/
|
|
412
429
|
static fromString(str: string): Keypair;
|
|
430
|
+
/**
|
|
431
|
+
* Derive a Keypair from an EIP-191 personal_sign signature.
|
|
432
|
+
* The private key is keccak256(signature) -- matching the frontend derivation.
|
|
433
|
+
*
|
|
434
|
+
* @param signature - Raw ECDSA signature (0x-prefixed, 132 hex chars)
|
|
435
|
+
* @returns Keypair derived from the signature
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* ```typescript
|
|
439
|
+
* const keypair = Keypair.fromSignature(signature);
|
|
440
|
+
* ```
|
|
441
|
+
*/
|
|
442
|
+
static fromSignature(signature: string): Keypair;
|
|
443
|
+
/**
|
|
444
|
+
* Derive a Keypair from an Ethereum wallet private key.
|
|
445
|
+
* Signs VEIL_SIGNED_MESSAGE with the wallet, then derives via keccak256(signature).
|
|
446
|
+
* Produces the same keypair as the frontend for the same wallet.
|
|
447
|
+
*
|
|
448
|
+
* @param walletPrivateKey - Ethereum EOA private key (0x-prefixed)
|
|
449
|
+
* @returns Promise resolving to the derived Keypair
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* ```typescript
|
|
453
|
+
* const keypair = await Keypair.fromWalletKey('0xYOUR_WALLET_PRIVATE_KEY');
|
|
454
|
+
* console.log(keypair.depositKey()); // Same as frontend login with this wallet
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
457
|
+
static fromWalletKey(walletPrivateKey: `0x${string}`): Promise<Keypair>;
|
|
458
|
+
/**
|
|
459
|
+
* Derive a Keypair using any external signer that supports personal_sign (EIP-191).
|
|
460
|
+
* The signer function receives VEIL_SIGNED_MESSAGE and must return a 0x-prefixed signature.
|
|
461
|
+
* Works with any signing backend: Bankr, MPC wallets, custodial services, hardware wallets, etc.
|
|
462
|
+
*
|
|
463
|
+
* @param signer - Async function that signs a message and returns a 0x-prefixed signature
|
|
464
|
+
* @returns Promise resolving to the derived Keypair
|
|
465
|
+
*
|
|
466
|
+
* @example
|
|
467
|
+
* ```typescript
|
|
468
|
+
* // With Bankr
|
|
469
|
+
* const keypair = await Keypair.fromSigner(async (message) => {
|
|
470
|
+
* const res = await fetch('https://api.bankr.bot/agent/sign', {
|
|
471
|
+
* method: 'POST',
|
|
472
|
+
* headers: { 'X-API-Key': apiKey, 'Content-Type': 'application/json' },
|
|
473
|
+
* body: JSON.stringify({ signatureType: 'personal_sign', message }),
|
|
474
|
+
* });
|
|
475
|
+
* return (await res.json()).signature;
|
|
476
|
+
* });
|
|
477
|
+
*
|
|
478
|
+
* // With any custom signer
|
|
479
|
+
* const keypair = await Keypair.fromSigner(async (msg) => myService.personalSign(msg));
|
|
480
|
+
* ```
|
|
481
|
+
*/
|
|
482
|
+
static fromSigner(signer: MessageSigner): Promise<Keypair>;
|
|
413
483
|
/**
|
|
414
484
|
* Sign a message using the private key
|
|
415
485
|
* @param commitment - Commitment hash
|
|
@@ -452,6 +522,22 @@ declare class Keypair {
|
|
|
452
522
|
* ```
|
|
453
523
|
*/
|
|
454
524
|
declare function buildRegisterTx(depositKey: string, ownerAddress: `0x${string}`): TransactionData;
|
|
525
|
+
/**
|
|
526
|
+
* Build a transaction to change an existing deposit key
|
|
527
|
+
* The caller must already be registered on-chain
|
|
528
|
+
*
|
|
529
|
+
* @param depositKey - New deposit key from Keypair.depositKey()
|
|
530
|
+
* @param ownerAddress - Address that owns the current deposit key (must be msg.sender)
|
|
531
|
+
* @returns Transaction data to send
|
|
532
|
+
*
|
|
533
|
+
* @example
|
|
534
|
+
* ```typescript
|
|
535
|
+
* const newKeypair = await Keypair.fromWalletKey('0x...');
|
|
536
|
+
* const tx = buildChangeDepositKeyTx(newKeypair.depositKey(), '0x...');
|
|
537
|
+
* // Send tx using your wallet
|
|
538
|
+
* ```
|
|
539
|
+
*/
|
|
540
|
+
declare function buildChangeDepositKeyTx(depositKey: string, ownerAddress: `0x${string}`): TransactionData;
|
|
455
541
|
/**
|
|
456
542
|
* Build a transaction to deposit ETH
|
|
457
543
|
*
|
|
@@ -498,7 +584,31 @@ declare function buildDepositUSDCTx(options: {
|
|
|
498
584
|
amount: string;
|
|
499
585
|
}): TransactionData;
|
|
500
586
|
/**
|
|
501
|
-
* Build a
|
|
587
|
+
* Build a transaction to approve cbBTC for deposit
|
|
588
|
+
* Must be called before depositCBBTC if allowance is insufficient
|
|
589
|
+
*
|
|
590
|
+
* @param options - Approval options
|
|
591
|
+
* @param options.amount - Amount to approve (human readable, e.g., '0.5')
|
|
592
|
+
* @returns Transaction data
|
|
593
|
+
*/
|
|
594
|
+
declare function buildApproveCBBTCTx(options: {
|
|
595
|
+
amount: string;
|
|
596
|
+
}): TransactionData;
|
|
597
|
+
/**
|
|
598
|
+
* Build a transaction to deposit cbBTC
|
|
599
|
+
* Note: You must approve cbBTC first using buildApproveCBBTCTx
|
|
600
|
+
*
|
|
601
|
+
* @param options - Deposit options
|
|
602
|
+
* @param options.depositKey - Deposit key from Keypair.depositKey()
|
|
603
|
+
* @param options.amount - Amount to deposit (human readable, e.g., '0.5')
|
|
604
|
+
* @returns Transaction data
|
|
605
|
+
*/
|
|
606
|
+
declare function buildDepositCBBTCTx(options: {
|
|
607
|
+
depositKey: string;
|
|
608
|
+
amount: string;
|
|
609
|
+
}): TransactionData;
|
|
610
|
+
/**
|
|
611
|
+
* Build a deposit transaction (ETH, USDC, or cbBTC)
|
|
502
612
|
* Convenience function that routes to the correct builder
|
|
503
613
|
*
|
|
504
614
|
* @param options - Deposit options
|
|
@@ -519,6 +629,13 @@ declare function buildDepositUSDCTx(options: {
|
|
|
519
629
|
* amount: '100',
|
|
520
630
|
* token: 'USDC',
|
|
521
631
|
* });
|
|
632
|
+
*
|
|
633
|
+
* // cbBTC deposit (remember to approve first!)
|
|
634
|
+
* const cbbtcTx = buildDepositTx({
|
|
635
|
+
* depositKey: keypair.depositKey(),
|
|
636
|
+
* amount: '0.5',
|
|
637
|
+
* token: 'CBBTC',
|
|
638
|
+
* });
|
|
522
639
|
* ```
|
|
523
640
|
*/
|
|
524
641
|
declare function buildDepositTx(options: {
|
|
@@ -550,6 +667,7 @@ type ProgressCallback = (stage: string, detail?: string) => void;
|
|
|
550
667
|
* ```typescript
|
|
551
668
|
* const result = await getQueueBalance({
|
|
552
669
|
* address: '0x...',
|
|
670
|
+
* pool: 'eth',
|
|
553
671
|
* onProgress: (stage, detail) => console.log(stage, detail),
|
|
554
672
|
* });
|
|
555
673
|
*
|
|
@@ -559,6 +677,7 @@ type ProgressCallback = (stage: string, detail?: string) => void;
|
|
|
559
677
|
*/
|
|
560
678
|
declare function getQueueBalance(options: {
|
|
561
679
|
address: `0x${string}`;
|
|
680
|
+
pool?: RelayPool;
|
|
562
681
|
rpcUrl?: string;
|
|
563
682
|
onProgress?: ProgressCallback;
|
|
564
683
|
}): Promise<QueueBalanceResult>;
|
|
@@ -577,6 +696,7 @@ declare function getQueueBalance(options: {
|
|
|
577
696
|
* const keypair = new Keypair(process.env.VEIL_KEY);
|
|
578
697
|
* const result = await getPrivateBalance({
|
|
579
698
|
* keypair,
|
|
699
|
+
* pool: 'eth',
|
|
580
700
|
* onProgress: (stage, detail) => console.log(stage, detail),
|
|
581
701
|
* });
|
|
582
702
|
*
|
|
@@ -586,6 +706,7 @@ declare function getQueueBalance(options: {
|
|
|
586
706
|
*/
|
|
587
707
|
declare function getPrivateBalance(options: {
|
|
588
708
|
keypair: Keypair;
|
|
709
|
+
pool?: RelayPool;
|
|
589
710
|
rpcUrl?: string;
|
|
590
711
|
onProgress?: ProgressCallback;
|
|
591
712
|
}): Promise<PrivateBalanceResult>;
|
|
@@ -737,6 +858,7 @@ declare function transfer(options: BuildTransferProofOptions): Promise<TransferR
|
|
|
737
858
|
declare function mergeUtxos(options: {
|
|
738
859
|
amount: string;
|
|
739
860
|
keypair: Keypair;
|
|
861
|
+
pool?: RelayPool;
|
|
740
862
|
rpcUrl?: string;
|
|
741
863
|
onProgress?: (stage: string, detail?: string) => void;
|
|
742
864
|
}): Promise<TransferResult>;
|
|
@@ -943,12 +1065,30 @@ declare const POOL_CONFIG: {
|
|
|
943
1065
|
readonly symbol: "USDC";
|
|
944
1066
|
readonly name: "USD Coin";
|
|
945
1067
|
};
|
|
1068
|
+
readonly cbbtc: {
|
|
1069
|
+
readonly decimals: 8;
|
|
1070
|
+
readonly displayDecimals: 6;
|
|
1071
|
+
readonly symbol: "cbBTC";
|
|
1072
|
+
readonly name: "Coinbase Bitcoin";
|
|
1073
|
+
};
|
|
946
1074
|
};
|
|
947
1075
|
/**
|
|
948
1076
|
* Get contract addresses
|
|
949
1077
|
* @returns Contract addresses for Base mainnet
|
|
950
1078
|
*/
|
|
951
1079
|
declare function getAddresses(): NetworkAddresses;
|
|
1080
|
+
/**
|
|
1081
|
+
* Get the pool contract address for a given pool
|
|
1082
|
+
* @param pool - Pool identifier ('eth', 'usdc', or 'cbbtc')
|
|
1083
|
+
* @returns Pool contract address
|
|
1084
|
+
*/
|
|
1085
|
+
declare function getPoolAddress(pool: RelayPool): `0x${string}`;
|
|
1086
|
+
/**
|
|
1087
|
+
* Get the queue contract address for a given pool
|
|
1088
|
+
* @param pool - Pool identifier ('eth', 'usdc', or 'cbbtc')
|
|
1089
|
+
* @returns Queue contract address
|
|
1090
|
+
*/
|
|
1091
|
+
declare function getQueueAddress(pool: RelayPool): `0x${string}`;
|
|
952
1092
|
/**
|
|
953
1093
|
* Get Relay URL
|
|
954
1094
|
* @returns Relay URL for Base mainnet
|
|
@@ -1188,6 +1328,22 @@ declare const ENTRY_ABI: readonly [{
|
|
|
1188
1328
|
readonly outputs: readonly [];
|
|
1189
1329
|
readonly stateMutability: "nonpayable";
|
|
1190
1330
|
readonly type: "function";
|
|
1331
|
+
}, {
|
|
1332
|
+
readonly inputs: readonly [{
|
|
1333
|
+
readonly components: readonly [{
|
|
1334
|
+
readonly name: "owner";
|
|
1335
|
+
readonly type: "address";
|
|
1336
|
+
}, {
|
|
1337
|
+
readonly name: "depositKey";
|
|
1338
|
+
readonly type: "bytes";
|
|
1339
|
+
}];
|
|
1340
|
+
readonly name: "_account";
|
|
1341
|
+
readonly type: "tuple";
|
|
1342
|
+
}];
|
|
1343
|
+
readonly name: "changeDepositKey";
|
|
1344
|
+
readonly outputs: readonly [];
|
|
1345
|
+
readonly stateMutability: "nonpayable";
|
|
1346
|
+
readonly type: "function";
|
|
1191
1347
|
}, {
|
|
1192
1348
|
readonly inputs: readonly [{
|
|
1193
1349
|
readonly name: "_depositKey";
|
|
@@ -1209,6 +1365,18 @@ declare const ENTRY_ABI: readonly [{
|
|
|
1209
1365
|
readonly outputs: readonly [];
|
|
1210
1366
|
readonly stateMutability: "nonpayable";
|
|
1211
1367
|
readonly type: "function";
|
|
1368
|
+
}, {
|
|
1369
|
+
readonly inputs: readonly [{
|
|
1370
|
+
readonly name: "_amount";
|
|
1371
|
+
readonly type: "uint256";
|
|
1372
|
+
}, {
|
|
1373
|
+
readonly name: "_depositKey";
|
|
1374
|
+
readonly type: "bytes";
|
|
1375
|
+
}];
|
|
1376
|
+
readonly name: "queueBTC";
|
|
1377
|
+
readonly outputs: readonly [];
|
|
1378
|
+
readonly stateMutability: "nonpayable";
|
|
1379
|
+
readonly type: "function";
|
|
1212
1380
|
}, {
|
|
1213
1381
|
readonly inputs: readonly [{
|
|
1214
1382
|
readonly name: "";
|
|
@@ -2096,4 +2264,4 @@ declare function getExtDataHash(extData: ExtDataInput): bigint;
|
|
|
2096
2264
|
*/
|
|
2097
2265
|
declare function shuffle<T>(array: T[]): T[];
|
|
2098
2266
|
|
|
2099
|
-
export { ADDRESSES, type BuildTransferProofOptions, type BuildWithdrawProofOptions, CIRCUIT_CONFIG, type DepositTxOptions, ENTRY_ABI, ERC20_ABI, type EncryptedMessage, type ExtData, type ExtDataInput, FIELD_SIZE, Keypair, MERKLE_TREE_HEIGHT, type NetworkAddresses, POOL_ABI, POOL_CONFIG, type PendingDeposit, type PoolConfig, type PrepareTransactionParams, type PrivateBalanceResult, type ProgressCallback, type ProofArgs, type ProofBuildResult, type ProofInput, QUEUE_ABI, type QueueBalanceResult, type RegisterTxOptions, RelayError, type RelayErrorResponse, type RelayExtData, type RelayMetadata, type RelayPool, type RelayProofArgs, type RelayRequest, type RelayResponse, type RelayType, type SubmitRelayOptions, type Token, type TransactionData, type TransactionResult, type TransferResult, Utxo, type UtxoInfo, type UtxoParams, type UtxoSelectionResult, type WithdrawResult, buildApproveUSDCTx, buildDepositETHTx, buildDepositTx, buildDepositUSDCTx, buildMerkleTree, buildRegisterTx, buildTransferProof, buildWithdrawProof, checkRecipientRegistration, checkRelayHealth, getAddresses, getExtDataHash, getMerklePath, getPrivateBalance, getQueueBalance, getRelayInfo, getRelayUrl, mergeUtxos, packEncryptedMessage, poseidonHash, poseidonHash2, prepareTransaction, prove, randomBN, selectCircuit, selectUtxosForWithdraw, shuffle, submitRelay, toBuffer, toFixedHex, transfer, unpackEncryptedMessage, withdraw };
|
|
2267
|
+
export { ADDRESSES, type BuildTransferProofOptions, type BuildWithdrawProofOptions, CIRCUIT_CONFIG, type DepositTxOptions, ENTRY_ABI, ERC20_ABI, type EncryptedMessage, type ExtData, type ExtDataInput, FIELD_SIZE, Keypair, MERKLE_TREE_HEIGHT, type MessageSigner, type NetworkAddresses, POOL_ABI, POOL_CONFIG, type PendingDeposit, type PoolConfig, type PrepareTransactionParams, type PrivateBalanceResult, type ProgressCallback, type ProofArgs, type ProofBuildResult, type ProofInput, QUEUE_ABI, type QueueBalanceResult, type RegisterTxOptions, RelayError, type RelayErrorResponse, type RelayExtData, type RelayMetadata, type RelayPool, type RelayProofArgs, type RelayRequest, type RelayResponse, type RelayType, type SubmitRelayOptions, type Token, type TransactionData, type TransactionResult, type TransferResult, Utxo, type UtxoInfo, type UtxoParams, type UtxoSelectionResult, VEIL_SIGNED_MESSAGE, type WithdrawResult, buildApproveCBBTCTx, buildApproveUSDCTx, buildChangeDepositKeyTx, buildDepositCBBTCTx, buildDepositETHTx, buildDepositTx, buildDepositUSDCTx, buildMerkleTree, buildRegisterTx, buildTransferProof, buildWithdrawProof, checkRecipientRegistration, checkRelayHealth, getAddresses, getExtDataHash, getMerklePath, getPoolAddress, getPrivateBalance, getQueueAddress, getQueueBalance, getRelayInfo, getRelayUrl, mergeUtxos, packEncryptedMessage, poseidonHash, poseidonHash2, prepareTransaction, prove, randomBN, selectCircuit, selectUtxosForWithdraw, shuffle, submitRelay, toBuffer, toFixedHex, transfer, unpackEncryptedMessage, withdraw };
|
package/dist/index.d.ts
CHANGED
|
@@ -79,7 +79,7 @@ declare class Utxo {
|
|
|
79
79
|
/**
|
|
80
80
|
* Supported tokens
|
|
81
81
|
*/
|
|
82
|
-
type Token = 'ETH' | 'USDC';
|
|
82
|
+
type Token = 'ETH' | 'USDC' | 'CBBTC';
|
|
83
83
|
/**
|
|
84
84
|
* Encrypted message format (x25519-xsalsa20-poly1305)
|
|
85
85
|
*/
|
|
@@ -99,6 +99,9 @@ interface NetworkAddresses {
|
|
|
99
99
|
usdcPool: `0x${string}`;
|
|
100
100
|
usdcQueue: `0x${string}`;
|
|
101
101
|
usdcToken: `0x${string}`;
|
|
102
|
+
cbbtcPool: `0x${string}`;
|
|
103
|
+
cbbtcQueue: `0x${string}`;
|
|
104
|
+
cbbtcToken: `0x${string}`;
|
|
102
105
|
chainId: number;
|
|
103
106
|
relayUrl: string;
|
|
104
107
|
}
|
|
@@ -177,7 +180,7 @@ interface PrivateBalanceResult {
|
|
|
177
180
|
/**
|
|
178
181
|
* Pool type for relay operations
|
|
179
182
|
*/
|
|
180
|
-
type RelayPool = 'eth' | 'usdc';
|
|
183
|
+
type RelayPool = 'eth' | 'usdc' | 'cbbtc';
|
|
181
184
|
/**
|
|
182
185
|
* Type of relay transaction
|
|
183
186
|
*/
|
|
@@ -269,6 +272,8 @@ interface BuildWithdrawProofOptions {
|
|
|
269
272
|
recipient: `0x${string}`;
|
|
270
273
|
/** User's keypair for signing */
|
|
271
274
|
keypair: Keypair;
|
|
275
|
+
/** Pool to withdraw from (default: 'eth') */
|
|
276
|
+
pool?: RelayPool;
|
|
272
277
|
/** Optional RPC URL */
|
|
273
278
|
rpcUrl?: string;
|
|
274
279
|
/** Progress callback */
|
|
@@ -284,6 +289,8 @@ interface BuildTransferProofOptions {
|
|
|
284
289
|
recipientAddress: `0x${string}`;
|
|
285
290
|
/** Sender's keypair */
|
|
286
291
|
senderKeypair: Keypair;
|
|
292
|
+
/** Pool to transfer in (default: 'eth') */
|
|
293
|
+
pool?: RelayPool;
|
|
287
294
|
/** Optional RPC URL */
|
|
288
295
|
rpcUrl?: string;
|
|
289
296
|
/** Progress callback */
|
|
@@ -351,6 +358,16 @@ interface UtxoSelectionResult {
|
|
|
351
358
|
* Generates and manages keypairs for Veil deposits
|
|
352
359
|
*/
|
|
353
360
|
|
|
361
|
+
/**
|
|
362
|
+
* Canonical message signed by a wallet to derive a Veil keypair.
|
|
363
|
+
* Must match the frontend's SIGNED_MESSAGE in data/wallet/config.ts.
|
|
364
|
+
*/
|
|
365
|
+
declare const VEIL_SIGNED_MESSAGE = "Sign this message to create your Veil Wallet private key. This will be used to decrypt your balances. Ensure you are signing this message on the Veil Cash website.";
|
|
366
|
+
/**
|
|
367
|
+
* Any async function that performs EIP-191 personal_sign and returns a 0x-prefixed signature.
|
|
368
|
+
* Used with Keypair.fromSigner() to support external signing services.
|
|
369
|
+
*/
|
|
370
|
+
type MessageSigner = (message: string) => Promise<string>;
|
|
354
371
|
/**
|
|
355
372
|
* Pack encrypted message into hex string
|
|
356
373
|
*/
|
|
@@ -410,6 +427,59 @@ declare class Keypair {
|
|
|
410
427
|
* @returns Keypair instance (privkey will be null)
|
|
411
428
|
*/
|
|
412
429
|
static fromString(str: string): Keypair;
|
|
430
|
+
/**
|
|
431
|
+
* Derive a Keypair from an EIP-191 personal_sign signature.
|
|
432
|
+
* The private key is keccak256(signature) -- matching the frontend derivation.
|
|
433
|
+
*
|
|
434
|
+
* @param signature - Raw ECDSA signature (0x-prefixed, 132 hex chars)
|
|
435
|
+
* @returns Keypair derived from the signature
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* ```typescript
|
|
439
|
+
* const keypair = Keypair.fromSignature(signature);
|
|
440
|
+
* ```
|
|
441
|
+
*/
|
|
442
|
+
static fromSignature(signature: string): Keypair;
|
|
443
|
+
/**
|
|
444
|
+
* Derive a Keypair from an Ethereum wallet private key.
|
|
445
|
+
* Signs VEIL_SIGNED_MESSAGE with the wallet, then derives via keccak256(signature).
|
|
446
|
+
* Produces the same keypair as the frontend for the same wallet.
|
|
447
|
+
*
|
|
448
|
+
* @param walletPrivateKey - Ethereum EOA private key (0x-prefixed)
|
|
449
|
+
* @returns Promise resolving to the derived Keypair
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* ```typescript
|
|
453
|
+
* const keypair = await Keypair.fromWalletKey('0xYOUR_WALLET_PRIVATE_KEY');
|
|
454
|
+
* console.log(keypair.depositKey()); // Same as frontend login with this wallet
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
457
|
+
static fromWalletKey(walletPrivateKey: `0x${string}`): Promise<Keypair>;
|
|
458
|
+
/**
|
|
459
|
+
* Derive a Keypair using any external signer that supports personal_sign (EIP-191).
|
|
460
|
+
* The signer function receives VEIL_SIGNED_MESSAGE and must return a 0x-prefixed signature.
|
|
461
|
+
* Works with any signing backend: Bankr, MPC wallets, custodial services, hardware wallets, etc.
|
|
462
|
+
*
|
|
463
|
+
* @param signer - Async function that signs a message and returns a 0x-prefixed signature
|
|
464
|
+
* @returns Promise resolving to the derived Keypair
|
|
465
|
+
*
|
|
466
|
+
* @example
|
|
467
|
+
* ```typescript
|
|
468
|
+
* // With Bankr
|
|
469
|
+
* const keypair = await Keypair.fromSigner(async (message) => {
|
|
470
|
+
* const res = await fetch('https://api.bankr.bot/agent/sign', {
|
|
471
|
+
* method: 'POST',
|
|
472
|
+
* headers: { 'X-API-Key': apiKey, 'Content-Type': 'application/json' },
|
|
473
|
+
* body: JSON.stringify({ signatureType: 'personal_sign', message }),
|
|
474
|
+
* });
|
|
475
|
+
* return (await res.json()).signature;
|
|
476
|
+
* });
|
|
477
|
+
*
|
|
478
|
+
* // With any custom signer
|
|
479
|
+
* const keypair = await Keypair.fromSigner(async (msg) => myService.personalSign(msg));
|
|
480
|
+
* ```
|
|
481
|
+
*/
|
|
482
|
+
static fromSigner(signer: MessageSigner): Promise<Keypair>;
|
|
413
483
|
/**
|
|
414
484
|
* Sign a message using the private key
|
|
415
485
|
* @param commitment - Commitment hash
|
|
@@ -452,6 +522,22 @@ declare class Keypair {
|
|
|
452
522
|
* ```
|
|
453
523
|
*/
|
|
454
524
|
declare function buildRegisterTx(depositKey: string, ownerAddress: `0x${string}`): TransactionData;
|
|
525
|
+
/**
|
|
526
|
+
* Build a transaction to change an existing deposit key
|
|
527
|
+
* The caller must already be registered on-chain
|
|
528
|
+
*
|
|
529
|
+
* @param depositKey - New deposit key from Keypair.depositKey()
|
|
530
|
+
* @param ownerAddress - Address that owns the current deposit key (must be msg.sender)
|
|
531
|
+
* @returns Transaction data to send
|
|
532
|
+
*
|
|
533
|
+
* @example
|
|
534
|
+
* ```typescript
|
|
535
|
+
* const newKeypair = await Keypair.fromWalletKey('0x...');
|
|
536
|
+
* const tx = buildChangeDepositKeyTx(newKeypair.depositKey(), '0x...');
|
|
537
|
+
* // Send tx using your wallet
|
|
538
|
+
* ```
|
|
539
|
+
*/
|
|
540
|
+
declare function buildChangeDepositKeyTx(depositKey: string, ownerAddress: `0x${string}`): TransactionData;
|
|
455
541
|
/**
|
|
456
542
|
* Build a transaction to deposit ETH
|
|
457
543
|
*
|
|
@@ -498,7 +584,31 @@ declare function buildDepositUSDCTx(options: {
|
|
|
498
584
|
amount: string;
|
|
499
585
|
}): TransactionData;
|
|
500
586
|
/**
|
|
501
|
-
* Build a
|
|
587
|
+
* Build a transaction to approve cbBTC for deposit
|
|
588
|
+
* Must be called before depositCBBTC if allowance is insufficient
|
|
589
|
+
*
|
|
590
|
+
* @param options - Approval options
|
|
591
|
+
* @param options.amount - Amount to approve (human readable, e.g., '0.5')
|
|
592
|
+
* @returns Transaction data
|
|
593
|
+
*/
|
|
594
|
+
declare function buildApproveCBBTCTx(options: {
|
|
595
|
+
amount: string;
|
|
596
|
+
}): TransactionData;
|
|
597
|
+
/**
|
|
598
|
+
* Build a transaction to deposit cbBTC
|
|
599
|
+
* Note: You must approve cbBTC first using buildApproveCBBTCTx
|
|
600
|
+
*
|
|
601
|
+
* @param options - Deposit options
|
|
602
|
+
* @param options.depositKey - Deposit key from Keypair.depositKey()
|
|
603
|
+
* @param options.amount - Amount to deposit (human readable, e.g., '0.5')
|
|
604
|
+
* @returns Transaction data
|
|
605
|
+
*/
|
|
606
|
+
declare function buildDepositCBBTCTx(options: {
|
|
607
|
+
depositKey: string;
|
|
608
|
+
amount: string;
|
|
609
|
+
}): TransactionData;
|
|
610
|
+
/**
|
|
611
|
+
* Build a deposit transaction (ETH, USDC, or cbBTC)
|
|
502
612
|
* Convenience function that routes to the correct builder
|
|
503
613
|
*
|
|
504
614
|
* @param options - Deposit options
|
|
@@ -519,6 +629,13 @@ declare function buildDepositUSDCTx(options: {
|
|
|
519
629
|
* amount: '100',
|
|
520
630
|
* token: 'USDC',
|
|
521
631
|
* });
|
|
632
|
+
*
|
|
633
|
+
* // cbBTC deposit (remember to approve first!)
|
|
634
|
+
* const cbbtcTx = buildDepositTx({
|
|
635
|
+
* depositKey: keypair.depositKey(),
|
|
636
|
+
* amount: '0.5',
|
|
637
|
+
* token: 'CBBTC',
|
|
638
|
+
* });
|
|
522
639
|
* ```
|
|
523
640
|
*/
|
|
524
641
|
declare function buildDepositTx(options: {
|
|
@@ -550,6 +667,7 @@ type ProgressCallback = (stage: string, detail?: string) => void;
|
|
|
550
667
|
* ```typescript
|
|
551
668
|
* const result = await getQueueBalance({
|
|
552
669
|
* address: '0x...',
|
|
670
|
+
* pool: 'eth',
|
|
553
671
|
* onProgress: (stage, detail) => console.log(stage, detail),
|
|
554
672
|
* });
|
|
555
673
|
*
|
|
@@ -559,6 +677,7 @@ type ProgressCallback = (stage: string, detail?: string) => void;
|
|
|
559
677
|
*/
|
|
560
678
|
declare function getQueueBalance(options: {
|
|
561
679
|
address: `0x${string}`;
|
|
680
|
+
pool?: RelayPool;
|
|
562
681
|
rpcUrl?: string;
|
|
563
682
|
onProgress?: ProgressCallback;
|
|
564
683
|
}): Promise<QueueBalanceResult>;
|
|
@@ -577,6 +696,7 @@ declare function getQueueBalance(options: {
|
|
|
577
696
|
* const keypair = new Keypair(process.env.VEIL_KEY);
|
|
578
697
|
* const result = await getPrivateBalance({
|
|
579
698
|
* keypair,
|
|
699
|
+
* pool: 'eth',
|
|
580
700
|
* onProgress: (stage, detail) => console.log(stage, detail),
|
|
581
701
|
* });
|
|
582
702
|
*
|
|
@@ -586,6 +706,7 @@ declare function getQueueBalance(options: {
|
|
|
586
706
|
*/
|
|
587
707
|
declare function getPrivateBalance(options: {
|
|
588
708
|
keypair: Keypair;
|
|
709
|
+
pool?: RelayPool;
|
|
589
710
|
rpcUrl?: string;
|
|
590
711
|
onProgress?: ProgressCallback;
|
|
591
712
|
}): Promise<PrivateBalanceResult>;
|
|
@@ -737,6 +858,7 @@ declare function transfer(options: BuildTransferProofOptions): Promise<TransferR
|
|
|
737
858
|
declare function mergeUtxos(options: {
|
|
738
859
|
amount: string;
|
|
739
860
|
keypair: Keypair;
|
|
861
|
+
pool?: RelayPool;
|
|
740
862
|
rpcUrl?: string;
|
|
741
863
|
onProgress?: (stage: string, detail?: string) => void;
|
|
742
864
|
}): Promise<TransferResult>;
|
|
@@ -943,12 +1065,30 @@ declare const POOL_CONFIG: {
|
|
|
943
1065
|
readonly symbol: "USDC";
|
|
944
1066
|
readonly name: "USD Coin";
|
|
945
1067
|
};
|
|
1068
|
+
readonly cbbtc: {
|
|
1069
|
+
readonly decimals: 8;
|
|
1070
|
+
readonly displayDecimals: 6;
|
|
1071
|
+
readonly symbol: "cbBTC";
|
|
1072
|
+
readonly name: "Coinbase Bitcoin";
|
|
1073
|
+
};
|
|
946
1074
|
};
|
|
947
1075
|
/**
|
|
948
1076
|
* Get contract addresses
|
|
949
1077
|
* @returns Contract addresses for Base mainnet
|
|
950
1078
|
*/
|
|
951
1079
|
declare function getAddresses(): NetworkAddresses;
|
|
1080
|
+
/**
|
|
1081
|
+
* Get the pool contract address for a given pool
|
|
1082
|
+
* @param pool - Pool identifier ('eth', 'usdc', or 'cbbtc')
|
|
1083
|
+
* @returns Pool contract address
|
|
1084
|
+
*/
|
|
1085
|
+
declare function getPoolAddress(pool: RelayPool): `0x${string}`;
|
|
1086
|
+
/**
|
|
1087
|
+
* Get the queue contract address for a given pool
|
|
1088
|
+
* @param pool - Pool identifier ('eth', 'usdc', or 'cbbtc')
|
|
1089
|
+
* @returns Queue contract address
|
|
1090
|
+
*/
|
|
1091
|
+
declare function getQueueAddress(pool: RelayPool): `0x${string}`;
|
|
952
1092
|
/**
|
|
953
1093
|
* Get Relay URL
|
|
954
1094
|
* @returns Relay URL for Base mainnet
|
|
@@ -1188,6 +1328,22 @@ declare const ENTRY_ABI: readonly [{
|
|
|
1188
1328
|
readonly outputs: readonly [];
|
|
1189
1329
|
readonly stateMutability: "nonpayable";
|
|
1190
1330
|
readonly type: "function";
|
|
1331
|
+
}, {
|
|
1332
|
+
readonly inputs: readonly [{
|
|
1333
|
+
readonly components: readonly [{
|
|
1334
|
+
readonly name: "owner";
|
|
1335
|
+
readonly type: "address";
|
|
1336
|
+
}, {
|
|
1337
|
+
readonly name: "depositKey";
|
|
1338
|
+
readonly type: "bytes";
|
|
1339
|
+
}];
|
|
1340
|
+
readonly name: "_account";
|
|
1341
|
+
readonly type: "tuple";
|
|
1342
|
+
}];
|
|
1343
|
+
readonly name: "changeDepositKey";
|
|
1344
|
+
readonly outputs: readonly [];
|
|
1345
|
+
readonly stateMutability: "nonpayable";
|
|
1346
|
+
readonly type: "function";
|
|
1191
1347
|
}, {
|
|
1192
1348
|
readonly inputs: readonly [{
|
|
1193
1349
|
readonly name: "_depositKey";
|
|
@@ -1209,6 +1365,18 @@ declare const ENTRY_ABI: readonly [{
|
|
|
1209
1365
|
readonly outputs: readonly [];
|
|
1210
1366
|
readonly stateMutability: "nonpayable";
|
|
1211
1367
|
readonly type: "function";
|
|
1368
|
+
}, {
|
|
1369
|
+
readonly inputs: readonly [{
|
|
1370
|
+
readonly name: "_amount";
|
|
1371
|
+
readonly type: "uint256";
|
|
1372
|
+
}, {
|
|
1373
|
+
readonly name: "_depositKey";
|
|
1374
|
+
readonly type: "bytes";
|
|
1375
|
+
}];
|
|
1376
|
+
readonly name: "queueBTC";
|
|
1377
|
+
readonly outputs: readonly [];
|
|
1378
|
+
readonly stateMutability: "nonpayable";
|
|
1379
|
+
readonly type: "function";
|
|
1212
1380
|
}, {
|
|
1213
1381
|
readonly inputs: readonly [{
|
|
1214
1382
|
readonly name: "";
|
|
@@ -2096,4 +2264,4 @@ declare function getExtDataHash(extData: ExtDataInput): bigint;
|
|
|
2096
2264
|
*/
|
|
2097
2265
|
declare function shuffle<T>(array: T[]): T[];
|
|
2098
2266
|
|
|
2099
|
-
export { ADDRESSES, type BuildTransferProofOptions, type BuildWithdrawProofOptions, CIRCUIT_CONFIG, type DepositTxOptions, ENTRY_ABI, ERC20_ABI, type EncryptedMessage, type ExtData, type ExtDataInput, FIELD_SIZE, Keypair, MERKLE_TREE_HEIGHT, type NetworkAddresses, POOL_ABI, POOL_CONFIG, type PendingDeposit, type PoolConfig, type PrepareTransactionParams, type PrivateBalanceResult, type ProgressCallback, type ProofArgs, type ProofBuildResult, type ProofInput, QUEUE_ABI, type QueueBalanceResult, type RegisterTxOptions, RelayError, type RelayErrorResponse, type RelayExtData, type RelayMetadata, type RelayPool, type RelayProofArgs, type RelayRequest, type RelayResponse, type RelayType, type SubmitRelayOptions, type Token, type TransactionData, type TransactionResult, type TransferResult, Utxo, type UtxoInfo, type UtxoParams, type UtxoSelectionResult, type WithdrawResult, buildApproveUSDCTx, buildDepositETHTx, buildDepositTx, buildDepositUSDCTx, buildMerkleTree, buildRegisterTx, buildTransferProof, buildWithdrawProof, checkRecipientRegistration, checkRelayHealth, getAddresses, getExtDataHash, getMerklePath, getPrivateBalance, getQueueBalance, getRelayInfo, getRelayUrl, mergeUtxos, packEncryptedMessage, poseidonHash, poseidonHash2, prepareTransaction, prove, randomBN, selectCircuit, selectUtxosForWithdraw, shuffle, submitRelay, toBuffer, toFixedHex, transfer, unpackEncryptedMessage, withdraw };
|
|
2267
|
+
export { ADDRESSES, type BuildTransferProofOptions, type BuildWithdrawProofOptions, CIRCUIT_CONFIG, type DepositTxOptions, ENTRY_ABI, ERC20_ABI, type EncryptedMessage, type ExtData, type ExtDataInput, FIELD_SIZE, Keypair, MERKLE_TREE_HEIGHT, type MessageSigner, type NetworkAddresses, POOL_ABI, POOL_CONFIG, type PendingDeposit, type PoolConfig, type PrepareTransactionParams, type PrivateBalanceResult, type ProgressCallback, type ProofArgs, type ProofBuildResult, type ProofInput, QUEUE_ABI, type QueueBalanceResult, type RegisterTxOptions, RelayError, type RelayErrorResponse, type RelayExtData, type RelayMetadata, type RelayPool, type RelayProofArgs, type RelayRequest, type RelayResponse, type RelayType, type SubmitRelayOptions, type Token, type TransactionData, type TransactionResult, type TransferResult, Utxo, type UtxoInfo, type UtxoParams, type UtxoSelectionResult, VEIL_SIGNED_MESSAGE, type WithdrawResult, buildApproveCBBTCTx, buildApproveUSDCTx, buildChangeDepositKeyTx, buildDepositCBBTCTx, buildDepositETHTx, buildDepositTx, buildDepositUSDCTx, buildMerkleTree, buildRegisterTx, buildTransferProof, buildWithdrawProof, checkRecipientRegistration, checkRelayHealth, getAddresses, getExtDataHash, getMerklePath, getPoolAddress, getPrivateBalance, getQueueAddress, getQueueBalance, getRelayInfo, getRelayUrl, mergeUtxos, packEncryptedMessage, poseidonHash, poseidonHash2, prepareTransaction, prove, randomBN, selectCircuit, selectUtxosForWithdraw, shuffle, submitRelay, toBuffer, toFixedHex, transfer, unpackEncryptedMessage, withdraw };
|