@veil-cash/sdk 0.3.0 → 0.4.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 +10 -54
- package/dist/cli/index.cjs +18 -71
- package/dist/index.cjs +2 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -58
- package/dist/index.d.ts +6 -58
- package/dist/index.js +3 -58
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/abi.ts +0 -12
- package/src/addresses.ts +2 -13
- package/src/cli/commands/balance.ts +2 -2
- package/src/cli/commands/deposit.ts +4 -8
- package/src/cli/commands/init.ts +7 -0
- package/src/cli/commands/private-balance.ts +1 -1
- package/src/cli/commands/queue-balance.ts +1 -1
- package/src/cli/commands/transfer.ts +3 -3
- package/src/cli/commands/withdraw.ts +2 -2
- package/src/deposit.ts +1 -70
- package/src/index.ts +0 -2
- package/src/relay.ts +2 -2
- package/src/types.ts +2 -5
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
SDK and CLI for interacting with [Veil Cash](https://veil.cash) privacy pools on Base.
|
|
8
8
|
|
|
9
|
-
Generate keypairs, register, deposit, withdraw, transfer, and merge ETH
|
|
9
|
+
Generate keypairs, register, deposit, withdraw, transfer, and merge ETH and USDC privately.
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
@@ -29,7 +29,6 @@ npm install -g @veil-cash/sdk
|
|
|
29
29
|
|-------|----------|---------------|
|
|
30
30
|
| ETH | 18 | Native ETH (via WETH) |
|
|
31
31
|
| USDC | 6 | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` |
|
|
32
|
-
| cbBTC | 8 | `0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf` |
|
|
33
32
|
|
|
34
33
|
## CLI Quick Start
|
|
35
34
|
|
|
@@ -46,20 +45,17 @@ veil register
|
|
|
46
45
|
# 4. Check your setup
|
|
47
46
|
veil status
|
|
48
47
|
|
|
49
|
-
# 5. Deposit (ETH
|
|
48
|
+
# 5. Deposit (ETH or USDC)
|
|
50
49
|
veil deposit ETH 0.1
|
|
51
50
|
veil deposit USDC 100
|
|
52
|
-
veil deposit CBBTC 0.001
|
|
53
51
|
|
|
54
52
|
# 6. Check your balance
|
|
55
53
|
veil balance # ETH pool (default)
|
|
56
54
|
veil balance --pool usdc # USDC pool
|
|
57
|
-
veil balance --pool cbbtc # cbBTC pool
|
|
58
55
|
|
|
59
56
|
# 7. Withdraw to any address
|
|
60
57
|
veil withdraw ETH 0.05 0xRecipientAddress
|
|
61
58
|
veil withdraw USDC 50 0xRecipientAddress
|
|
62
|
-
veil withdraw CBBTC 0.0005 0xRecipientAddress
|
|
63
59
|
|
|
64
60
|
# 8. Transfer privately to another registered user
|
|
65
61
|
veil transfer ETH 0.02 0xRecipientAddress
|
|
@@ -144,12 +140,11 @@ If already registered with the same key, the command exits successfully. If regi
|
|
|
144
140
|
|
|
145
141
|
### `veil deposit <asset> <amount>`
|
|
146
142
|
|
|
147
|
-
Deposit ETH
|
|
143
|
+
Deposit ETH or USDC into the privacy pool. For USDC, the CLI automatically handles ERC20 approval before depositing.
|
|
148
144
|
|
|
149
145
|
```bash
|
|
150
146
|
veil deposit ETH 0.1 # Deposit ETH
|
|
151
147
|
veil deposit USDC 100 # Approve + deposit USDC
|
|
152
|
-
veil deposit CBBTC 0.001 # Approve + deposit cbBTC
|
|
153
148
|
veil deposit ETH 0.1 --unsigned # Unsigned payload for agents
|
|
154
149
|
veil deposit ETH 0.1 --quiet # Suppress progress output
|
|
155
150
|
```
|
|
@@ -173,7 +168,6 @@ Show both queue and private balances.
|
|
|
173
168
|
```bash
|
|
174
169
|
veil balance # ETH pool (default)
|
|
175
170
|
veil balance --pool usdc # USDC pool
|
|
176
|
-
veil balance --pool cbbtc # cbBTC pool
|
|
177
171
|
veil balance --quiet # Suppress progress output
|
|
178
172
|
```
|
|
179
173
|
|
|
@@ -213,7 +207,6 @@ Withdraw from the privacy pool to any public address.
|
|
|
213
207
|
```bash
|
|
214
208
|
veil withdraw ETH 0.05 0xRecipientAddress
|
|
215
209
|
veil withdraw USDC 50 0xRecipientAddress
|
|
216
|
-
veil withdraw CBBTC 0.0005 0xRecipientAddress
|
|
217
210
|
veil withdraw ETH 0.05 0xRecipientAddress --quiet
|
|
218
211
|
```
|
|
219
212
|
|
|
@@ -236,7 +229,6 @@ Transfer privately to another registered Veil user.
|
|
|
236
229
|
```bash
|
|
237
230
|
veil transfer ETH 0.02 0xRecipientAddress
|
|
238
231
|
veil transfer USDC 25 0xRecipientAddress
|
|
239
|
-
veil transfer CBBTC 0.0002 0xRecipientAddress
|
|
240
232
|
veil transfer ETH 0.02 0xRecipientAddress --quiet
|
|
241
233
|
```
|
|
242
234
|
|
|
@@ -260,7 +252,6 @@ Consolidate multiple small UTXOs into one (self-transfer).
|
|
|
260
252
|
```bash
|
|
261
253
|
veil merge ETH 0.1 # Merge ETH UTXOs totaling 0.1 ETH
|
|
262
254
|
veil merge USDC 100 # Merge USDC UTXOs
|
|
263
|
-
veil merge CBBTC 0.001 # Merge cbBTC UTXOs
|
|
264
255
|
veil merge ETH 0.1 --quiet
|
|
265
256
|
```
|
|
266
257
|
|
|
@@ -329,7 +320,6 @@ All CLI commands output JSON with standardized error codes:
|
|
|
329
320
|
import {
|
|
330
321
|
Keypair, buildRegisterTx, buildDepositETHTx,
|
|
331
322
|
buildDepositUSDCTx, buildApproveUSDCTx,
|
|
332
|
-
buildDepositCBBTCTx, buildApproveCBBTCTx,
|
|
333
323
|
withdraw, transfer,
|
|
334
324
|
} from '@veil-cash/sdk';
|
|
335
325
|
import { createWalletClient, http } from 'viem';
|
|
@@ -369,21 +359,12 @@ const usdcTx = buildDepositUSDCTx({
|
|
|
369
359
|
});
|
|
370
360
|
await client.sendTransaction(usdcTx);
|
|
371
361
|
|
|
372
|
-
// 4c. Deposit cbBTC (approve first)
|
|
373
|
-
const approveCbbtcTx = buildApproveCBBTCTx({ amount: '0.001' });
|
|
374
|
-
await client.sendTransaction(approveCbbtcTx);
|
|
375
|
-
const cbbtcTx = buildDepositCBBTCTx({
|
|
376
|
-
depositKey: keypair.depositKey(),
|
|
377
|
-
amount: '0.001',
|
|
378
|
-
});
|
|
379
|
-
await client.sendTransaction(cbbtcTx);
|
|
380
|
-
|
|
381
362
|
// 5. Withdraw (sent via relayer, no wallet signing needed)
|
|
382
363
|
const withdrawResult = await withdraw({
|
|
383
364
|
amount: '0.05',
|
|
384
365
|
recipient: '0xRecipientAddress',
|
|
385
366
|
keypair,
|
|
386
|
-
pool: 'eth', // 'eth' | 'usdc'
|
|
367
|
+
pool: 'eth', // 'eth' | 'usdc' (default: 'eth')
|
|
387
368
|
});
|
|
388
369
|
|
|
389
370
|
// 6. Transfer privately
|
|
@@ -391,7 +372,7 @@ const transferResult = await transfer({
|
|
|
391
372
|
amount: '0.02',
|
|
392
373
|
recipientAddress: '0xRecipientAddress',
|
|
393
374
|
senderKeypair: keypair,
|
|
394
|
-
pool: 'eth', // 'eth' | 'usdc'
|
|
375
|
+
pool: 'eth', // 'eth' | 'usdc' (default: 'eth')
|
|
395
376
|
});
|
|
396
377
|
```
|
|
397
378
|
|
|
@@ -434,7 +415,6 @@ keypair.privkey; // '0x...'
|
|
|
434
415
|
import {
|
|
435
416
|
buildRegisterTx, buildChangeDepositKeyTx, buildDepositETHTx, buildDepositTx,
|
|
436
417
|
buildDepositUSDCTx, buildApproveUSDCTx,
|
|
437
|
-
buildDepositCBBTCTx, buildApproveCBBTCTx,
|
|
438
418
|
} from '@veil-cash/sdk';
|
|
439
419
|
|
|
440
420
|
// Register deposit key (first time)
|
|
@@ -459,24 +439,17 @@ const depositUsdcTx = buildDepositUSDCTx({
|
|
|
459
439
|
amount: '100',
|
|
460
440
|
});
|
|
461
441
|
|
|
462
|
-
// Deposit cbBTC (approve + deposit)
|
|
463
|
-
const approveCbbtcTx = buildApproveCBBTCTx({ amount: '0.001' });
|
|
464
|
-
const depositCbbtcTx = buildDepositCBBTCTx({
|
|
465
|
-
depositKey: keypair.depositKey(),
|
|
466
|
-
amount: '0.001',
|
|
467
|
-
});
|
|
468
|
-
|
|
469
442
|
// Generic builder (routes by token)
|
|
470
443
|
const tx = buildDepositTx({
|
|
471
444
|
depositKey: keypair.depositKey(),
|
|
472
445
|
amount: '0.1',
|
|
473
|
-
token: 'ETH', // 'ETH' | 'USDC'
|
|
446
|
+
token: 'ETH', // 'ETH' | 'USDC'
|
|
474
447
|
});
|
|
475
448
|
```
|
|
476
449
|
|
|
477
450
|
### Withdraw & Transfer
|
|
478
451
|
|
|
479
|
-
All withdraw, transfer, and merge functions accept an optional `pool` parameter (`'eth'` | `'usdc'`
|
|
452
|
+
All withdraw, transfer, and merge functions accept an optional `pool` parameter (`'eth'` | `'usdc'`), defaulting to `'eth'`.
|
|
480
453
|
|
|
481
454
|
```typescript
|
|
482
455
|
import { withdraw, transfer, mergeUtxos } from '@veil-cash/sdk';
|
|
@@ -498,14 +471,6 @@ const withdrawUsdc = await withdraw({
|
|
|
498
471
|
pool: 'usdc',
|
|
499
472
|
});
|
|
500
473
|
|
|
501
|
-
// Transfer cbBTC to another registered user
|
|
502
|
-
const transferResult = await transfer({
|
|
503
|
-
amount: '0.0002',
|
|
504
|
-
recipientAddress: '0xRecipientAddress',
|
|
505
|
-
senderKeypair: keypair,
|
|
506
|
-
pool: 'cbbtc',
|
|
507
|
-
});
|
|
508
|
-
|
|
509
474
|
// Merge UTXOs (consolidate small balances)
|
|
510
475
|
const mergeResult = await mergeUtxos({
|
|
511
476
|
amount: '0.1',
|
|
@@ -516,7 +481,7 @@ const mergeResult = await mergeUtxos({
|
|
|
516
481
|
|
|
517
482
|
### Balance Queries
|
|
518
483
|
|
|
519
|
-
Balance functions accept an optional `pool` parameter (`'eth'` | `'usdc'`
|
|
484
|
+
Balance functions accept an optional `pool` parameter (`'eth'` | `'usdc'`), defaulting to `'eth'`.
|
|
520
485
|
|
|
521
486
|
```typescript
|
|
522
487
|
import { getQueueBalance, getPrivateBalance } from '@veil-cash/sdk';
|
|
@@ -533,11 +498,6 @@ const privateBalance = await getPrivateBalance({
|
|
|
533
498
|
pool: 'usdc',
|
|
534
499
|
});
|
|
535
500
|
|
|
536
|
-
// Check cbBTC private balance
|
|
537
|
-
const btcBalance = await getPrivateBalance({
|
|
538
|
-
keypair,
|
|
539
|
-
pool: 'cbbtc',
|
|
540
|
-
});
|
|
541
501
|
```
|
|
542
502
|
|
|
543
503
|
### Addresses
|
|
@@ -549,13 +509,10 @@ const addresses = getAddresses();
|
|
|
549
509
|
console.log(addresses.entry); // Entry contract
|
|
550
510
|
console.log(addresses.ethPool); // ETH pool
|
|
551
511
|
console.log(addresses.usdcPool); // USDC pool
|
|
552
|
-
console.log(addresses.cbbtcPool); // cbBTC pool
|
|
553
512
|
|
|
554
513
|
// Helper functions to resolve by pool name
|
|
555
514
|
console.log(getPoolAddress('eth')); // ETH pool address
|
|
556
515
|
console.log(getPoolAddress('usdc')); // USDC pool address
|
|
557
|
-
console.log(getPoolAddress('cbbtc')); // cbBTC pool address
|
|
558
|
-
console.log(getQueueAddress('cbbtc')); // cbBTC queue address
|
|
559
516
|
```
|
|
560
517
|
|
|
561
518
|
## For AI Agents
|
|
@@ -574,7 +531,6 @@ veil init --json
|
|
|
574
531
|
veil register --unsigned --address 0x...
|
|
575
532
|
veil deposit ETH 0.1 --unsigned
|
|
576
533
|
veil deposit USDC 100 --unsigned # Outputs approve + deposit payloads
|
|
577
|
-
veil deposit CBBTC 0.001 --unsigned
|
|
578
534
|
|
|
579
535
|
# Suppress progress output for clean JSON
|
|
580
536
|
veil balance --quiet
|
|
@@ -650,7 +606,7 @@ const result = await withdraw({
|
|
|
650
606
|
amount: '0.05',
|
|
651
607
|
recipient: '0xRecipient',
|
|
652
608
|
keypair,
|
|
653
|
-
pool: 'eth', // 'eth' | 'usdc'
|
|
609
|
+
pool: 'eth', // 'eth' | 'usdc'
|
|
654
610
|
});
|
|
655
611
|
// → { success, transactionHash, blockNumber }
|
|
656
612
|
```
|
|
@@ -660,7 +616,7 @@ const result = await withdraw({
|
|
|
660
616
|
1. **Generate Keypair**: Run `veil init` to create and save your Veil keypair
|
|
661
617
|
2. **Register**: Run `veil register` to link your deposit key on-chain (one-time)
|
|
662
618
|
3. **Check Status**: Run `veil status` to verify your setup
|
|
663
|
-
4. **Deposit**: Run `veil deposit <asset> <amount>` (e.g., `veil deposit ETH 0.1`, `veil deposit USDC 100
|
|
619
|
+
4. **Deposit**: Run `veil deposit <asset> <amount>` (e.g., `veil deposit ETH 0.1`, `veil deposit USDC 100`)
|
|
664
620
|
5. **Wait**: The Veil deposit engine processes your deposit
|
|
665
621
|
6. **Done**: Your deposit is accepted into the privacy pool
|
|
666
622
|
|
package/dist/cli/index.cjs
CHANGED
|
@@ -4253,12 +4253,15 @@ function createInitCommand() {
|
|
|
4253
4253
|
}
|
|
4254
4254
|
return new Keypair();
|
|
4255
4255
|
}
|
|
4256
|
+
const derivation = options.signMessage ? "wallet-signature" : options.signature ? "provided-signature" : "random";
|
|
4256
4257
|
const derivationLabel = options.signMessage ? "Derived Veil keypair from wallet signature" : options.signature ? "Derived Veil keypair from provided signature" : "Generated new Veil keypair";
|
|
4257
4258
|
if (options.json) {
|
|
4258
4259
|
const kp2 = await createKp();
|
|
4259
4260
|
console.log(JSON.stringify({
|
|
4260
4261
|
veilKey: kp2.privkey,
|
|
4261
|
-
|
|
4262
|
+
veilPrivateKey: kp2.privkey,
|
|
4263
|
+
depositKey: kp2.depositKey(),
|
|
4264
|
+
derivation
|
|
4262
4265
|
}, null, 2));
|
|
4263
4266
|
process.exit(0);
|
|
4264
4267
|
return;
|
|
@@ -4335,9 +4338,6 @@ var ADDRESSES = {
|
|
|
4335
4338
|
usdcPool: "0x5c50d58E49C59d112680c187De2Bf989d2a91242",
|
|
4336
4339
|
usdcQueue: "0x5530241b24504bF05C9a22e95A1F5458888e6a9B",
|
|
4337
4340
|
usdcToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
4338
|
-
cbbtcPool: "0x51A021da774b4bBB59B47f7CB4ccd631337680BA",
|
|
4339
|
-
cbbtcQueue: "0x977741CaDF8D1431c4816C0993D32b02094cD35C",
|
|
4340
|
-
cbbtcToken: "0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
|
|
4341
4341
|
chainId: 8453,
|
|
4342
4342
|
relayUrl: "https://veil-relay.up.railway.app"
|
|
4343
4343
|
};
|
|
@@ -4353,12 +4353,6 @@ var POOL_CONFIG = {
|
|
|
4353
4353
|
displayDecimals: 2,
|
|
4354
4354
|
symbol: "USDC",
|
|
4355
4355
|
name: "USD Coin"
|
|
4356
|
-
},
|
|
4357
|
-
cbbtc: {
|
|
4358
|
-
decimals: 8,
|
|
4359
|
-
displayDecimals: 6,
|
|
4360
|
-
symbol: "cbBTC",
|
|
4361
|
-
name: "Coinbase Bitcoin"
|
|
4362
4356
|
}
|
|
4363
4357
|
};
|
|
4364
4358
|
function getAddresses() {
|
|
@@ -4371,8 +4365,6 @@ function getPoolAddress(pool) {
|
|
|
4371
4365
|
return addresses.ethPool;
|
|
4372
4366
|
case "usdc":
|
|
4373
4367
|
return addresses.usdcPool;
|
|
4374
|
-
case "cbbtc":
|
|
4375
|
-
return addresses.cbbtcPool;
|
|
4376
4368
|
default:
|
|
4377
4369
|
throw new Error(`Unknown pool: ${pool}`);
|
|
4378
4370
|
}
|
|
@@ -4384,8 +4376,6 @@ function getQueueAddress(pool) {
|
|
|
4384
4376
|
return addresses.ethQueue;
|
|
4385
4377
|
case "usdc":
|
|
4386
4378
|
return addresses.usdcQueue;
|
|
4387
|
-
case "cbbtc":
|
|
4388
|
-
return addresses.cbbtcQueue;
|
|
4389
4379
|
default:
|
|
4390
4380
|
throw new Error(`Unknown pool: ${pool}`);
|
|
4391
4381
|
}
|
|
@@ -4487,17 +4477,6 @@ var ENTRY_ABI = [
|
|
|
4487
4477
|
stateMutability: "nonpayable",
|
|
4488
4478
|
type: "function"
|
|
4489
4479
|
},
|
|
4490
|
-
// Queue cbBTC deposit
|
|
4491
|
-
{
|
|
4492
|
-
inputs: [
|
|
4493
|
-
{ name: "_amount", type: "uint256" },
|
|
4494
|
-
{ name: "_depositKey", type: "bytes" }
|
|
4495
|
-
],
|
|
4496
|
-
name: "queueBTC",
|
|
4497
|
-
outputs: [],
|
|
4498
|
-
stateMutability: "nonpayable",
|
|
4499
|
-
type: "function"
|
|
4500
|
-
},
|
|
4501
4480
|
// Read deposit keys
|
|
4502
4481
|
{
|
|
4503
4482
|
inputs: [{ name: "", type: "address" }],
|
|
@@ -5096,34 +5075,6 @@ function buildDepositUSDCTx(options) {
|
|
|
5096
5075
|
data
|
|
5097
5076
|
};
|
|
5098
5077
|
}
|
|
5099
|
-
function buildApproveCBBTCTx(options) {
|
|
5100
|
-
const { amount } = options;
|
|
5101
|
-
const addresses = getAddresses();
|
|
5102
|
-
const amountWei = viem.parseUnits(amount, POOL_CONFIG.cbbtc.decimals);
|
|
5103
|
-
const data = viem.encodeFunctionData({
|
|
5104
|
-
abi: ERC20_ABI,
|
|
5105
|
-
functionName: "approve",
|
|
5106
|
-
args: [addresses.entry, amountWei]
|
|
5107
|
-
});
|
|
5108
|
-
return {
|
|
5109
|
-
to: addresses.cbbtcToken,
|
|
5110
|
-
data
|
|
5111
|
-
};
|
|
5112
|
-
}
|
|
5113
|
-
function buildDepositCBBTCTx(options) {
|
|
5114
|
-
const { depositKey, amount } = options;
|
|
5115
|
-
const addresses = getAddresses();
|
|
5116
|
-
const amountWei = viem.parseUnits(amount, POOL_CONFIG.cbbtc.decimals);
|
|
5117
|
-
const data = viem.encodeFunctionData({
|
|
5118
|
-
abi: ENTRY_ABI,
|
|
5119
|
-
functionName: "queueBTC",
|
|
5120
|
-
args: [amountWei, depositKey]
|
|
5121
|
-
});
|
|
5122
|
-
return {
|
|
5123
|
-
to: addresses.entry,
|
|
5124
|
-
data
|
|
5125
|
-
};
|
|
5126
|
-
}
|
|
5127
5078
|
function createWallet(config) {
|
|
5128
5079
|
const { privateKey, rpcUrl } = config;
|
|
5129
5080
|
const account = accounts.privateKeyToAccount(privateKey);
|
|
@@ -5455,21 +5406,20 @@ Use --force to change your deposit key on-chain.`);
|
|
|
5455
5406
|
var DEPOSIT_FEE_PERCENT = 0.3;
|
|
5456
5407
|
var MINIMUM_DEPOSITS = {
|
|
5457
5408
|
ETH: 0.01,
|
|
5458
|
-
USDC: 10
|
|
5459
|
-
CBBTC: 1e-4
|
|
5409
|
+
USDC: 10
|
|
5460
5410
|
};
|
|
5461
5411
|
function getMinimumWithFee(asset) {
|
|
5462
5412
|
const min = MINIMUM_DEPOSITS[asset] || 0;
|
|
5463
5413
|
return min / (1 - DEPOSIT_FEE_PERCENT / 100);
|
|
5464
5414
|
}
|
|
5465
|
-
var SUPPORTED_ASSETS = ["ETH", "USDC"
|
|
5415
|
+
var SUPPORTED_ASSETS = ["ETH", "USDC"];
|
|
5466
5416
|
function progress(msg, quiet) {
|
|
5467
5417
|
if (!quiet) {
|
|
5468
5418
|
process.stderr.write(`\r\x1B[K${msg}`);
|
|
5469
5419
|
}
|
|
5470
5420
|
}
|
|
5471
5421
|
function createDepositCommand() {
|
|
5472
|
-
const deposit = new Command("deposit").description("Deposit ETH
|
|
5422
|
+
const deposit = new Command("deposit").description("Deposit ETH or USDC into Veil").argument("<asset>", "Asset to deposit (ETH or USDC)").argument("<amount>", "Amount to deposit (e.g., 0.1)").option("--deposit-key <key>", "Your Veil deposit key (or set DEPOSIT_KEY env)").option("--wallet-key <key>", "Ethereum wallet key for signing (or set WALLET_KEY env)").option("--rpc-url <url>", "RPC URL (or set RPC_URL env)").option("--unsigned", "Output unsigned transaction payload (Bankr-compatible format)").option("--quiet", "Suppress progress output").action(async (asset, amount, options) => {
|
|
5473
5423
|
try {
|
|
5474
5424
|
const assetUpper = asset.toUpperCase();
|
|
5475
5425
|
if (!SUPPORTED_ASSETS.includes(assetUpper)) {
|
|
@@ -5494,9 +5444,6 @@ function createDepositCommand() {
|
|
|
5494
5444
|
if (assetUpper === "USDC") {
|
|
5495
5445
|
approveTx = buildApproveUSDCTx({ amount });
|
|
5496
5446
|
tx = buildDepositUSDCTx({ depositKey, amount });
|
|
5497
|
-
} else if (assetUpper === "CBBTC") {
|
|
5498
|
-
approveTx = buildApproveCBBTCTx({ amount });
|
|
5499
|
-
tx = buildDepositCBBTCTx({ depositKey, amount });
|
|
5500
5447
|
} else {
|
|
5501
5448
|
tx = buildDepositETHTx({ depositKey, amount });
|
|
5502
5449
|
}
|
|
@@ -5781,7 +5728,7 @@ async function getPrivateBalance(options) {
|
|
|
5781
5728
|
utxos: utxoInfos
|
|
5782
5729
|
};
|
|
5783
5730
|
}
|
|
5784
|
-
var SUPPORTED_POOLS = ["eth", "usdc"
|
|
5731
|
+
var SUPPORTED_POOLS = ["eth", "usdc"];
|
|
5785
5732
|
async function fetchPoolBalance(pool, address, keypair, rpcUrl, onProgress) {
|
|
5786
5733
|
const poolConfig = POOL_CONFIG[pool];
|
|
5787
5734
|
const poolProgress = onProgress ? (stage, detail) => onProgress(`[${pool.toUpperCase()}] ${stage}`, detail) : void 0;
|
|
@@ -5830,7 +5777,7 @@ async function fetchPoolBalance(pool, address, keypair, rpcUrl, onProgress) {
|
|
|
5830
5777
|
return result;
|
|
5831
5778
|
}
|
|
5832
5779
|
function createBalanceCommand() {
|
|
5833
|
-
const balance = new Command("balance").description("Show queue and private balances (all pools by default)").option("--pool <pool>", "Pool to check (eth, usdc,
|
|
5780
|
+
const balance = new Command("balance").description("Show queue and private balances (all pools by default)").option("--pool <pool>", "Pool to check (eth, usdc, or all)", "all").option("--wallet-key <key>", "Ethereum wallet key (or set WALLET_KEY env)").option("--address <address>", "Address to check (or derived from wallet key)").option("--veil-key <key>", "Veil private key (or set VEIL_KEY env)").option("--rpc-url <url>", "RPC URL (or set RPC_URL env)").option("--quiet", "Suppress progress output").action(async (options) => {
|
|
5834
5781
|
try {
|
|
5835
5782
|
const poolArg = (options.pool || "all").toLowerCase();
|
|
5836
5783
|
if (poolArg !== "all" && !SUPPORTED_POOLS.includes(poolArg)) {
|
|
@@ -5888,7 +5835,7 @@ function createBalanceCommand() {
|
|
|
5888
5835
|
|
|
5889
5836
|
// src/cli/commands/queue-balance.ts
|
|
5890
5837
|
function createQueueBalanceCommand() {
|
|
5891
|
-
const balance = new Command("queue-balance").description("Show queue balance and pending deposits").option("--pool <pool>", "Pool to check (eth
|
|
5838
|
+
const balance = new Command("queue-balance").description("Show queue balance and pending deposits").option("--pool <pool>", "Pool to check (eth or usdc)", "eth").option("--wallet-key <key>", "Ethereum wallet key (or set WALLET_KEY env)").option("--address <address>", "Address to check (or derived from wallet key)").option("--rpc-url <url>", "RPC URL (or set RPC_URL env)").option("--quiet", "Suppress progress output").action(async (options) => {
|
|
5892
5839
|
try {
|
|
5893
5840
|
const pool = (options.pool || "eth").toLowerCase();
|
|
5894
5841
|
let address;
|
|
@@ -5923,7 +5870,7 @@ function createQueueBalanceCommand() {
|
|
|
5923
5870
|
|
|
5924
5871
|
// src/cli/commands/private-balance.ts
|
|
5925
5872
|
function createPrivateBalanceCommand() {
|
|
5926
|
-
const privateBalance = new Command("private-balance").description("Show private balance (requires VEIL_KEY)").option("--pool <pool>", "Pool to check (eth
|
|
5873
|
+
const privateBalance = new Command("private-balance").description("Show private balance (requires VEIL_KEY)").option("--pool <pool>", "Pool to check (eth or usdc)", "eth").option("--veil-key <key>", "Veil private key (or set VEIL_KEY env)").option("--rpc-url <url>", "RPC URL (or set RPC_URL env)").option("--show-utxos", "Show individual UTXO details").option("--quiet", "Suppress progress output").action(async (options) => {
|
|
5927
5874
|
try {
|
|
5928
5875
|
const pool = (options.pool || "eth").toLowerCase();
|
|
5929
5876
|
const veilKey = options.veilKey || process.env.VEIL_KEY;
|
|
@@ -6179,8 +6126,8 @@ async function submitRelay(options) {
|
|
|
6179
6126
|
if (type !== "withdraw" && type !== "transfer") {
|
|
6180
6127
|
throw new RelayError('Invalid type. Must be "withdraw" or "transfer"', 400);
|
|
6181
6128
|
}
|
|
6182
|
-
if (pool !== "eth" && pool !== "usdc"
|
|
6183
|
-
throw new RelayError('Invalid pool. Must be "eth"
|
|
6129
|
+
if (pool !== "eth" && pool !== "usdc") {
|
|
6130
|
+
throw new RelayError('Invalid pool. Must be "eth" or "usdc"', 400);
|
|
6184
6131
|
}
|
|
6185
6132
|
if (!proofArgs || !extData) {
|
|
6186
6133
|
throw new RelayError("Missing proofArgs or extData", 400);
|
|
@@ -6385,14 +6332,14 @@ async function withdraw(options) {
|
|
|
6385
6332
|
}
|
|
6386
6333
|
|
|
6387
6334
|
// src/cli/commands/withdraw.ts
|
|
6388
|
-
var SUPPORTED_ASSETS2 = ["ETH", "USDC"
|
|
6335
|
+
var SUPPORTED_ASSETS2 = ["ETH", "USDC"];
|
|
6389
6336
|
function progress2(msg, quiet) {
|
|
6390
6337
|
if (!quiet) {
|
|
6391
6338
|
process.stderr.write(`\r\x1B[K${msg}`);
|
|
6392
6339
|
}
|
|
6393
6340
|
}
|
|
6394
6341
|
function createWithdrawCommand() {
|
|
6395
|
-
const withdrawCmd = new Command("withdraw").description("Withdraw from private pool to a public address").argument("<asset>", "Asset to withdraw (ETH
|
|
6342
|
+
const withdrawCmd = new Command("withdraw").description("Withdraw from private pool to a public address").argument("<asset>", "Asset to withdraw (ETH or USDC)").argument("<amount>", "Amount to withdraw (e.g., 0.1)").argument("<recipient>", "Recipient address (e.g., 0x...)").option("--veil-key <key>", "Veil private key (or set VEIL_KEY env)").option("--rpc-url <url>", "RPC URL (or set RPC_URL env)").option("--quiet", "Suppress progress output").action(async (asset, amount, recipient, options) => {
|
|
6396
6343
|
try {
|
|
6397
6344
|
const assetUpper = asset.toUpperCase();
|
|
6398
6345
|
if (!SUPPORTED_ASSETS2.includes(assetUpper)) {
|
|
@@ -6713,14 +6660,14 @@ async function mergeUtxos(options) {
|
|
|
6713
6660
|
}
|
|
6714
6661
|
|
|
6715
6662
|
// src/cli/commands/transfer.ts
|
|
6716
|
-
var SUPPORTED_ASSETS3 = ["ETH", "USDC"
|
|
6663
|
+
var SUPPORTED_ASSETS3 = ["ETH", "USDC"];
|
|
6717
6664
|
function progress3(msg, quiet) {
|
|
6718
6665
|
if (!quiet) {
|
|
6719
6666
|
process.stderr.write(`\r\x1B[K${msg}`);
|
|
6720
6667
|
}
|
|
6721
6668
|
}
|
|
6722
6669
|
function createTransferCommand() {
|
|
6723
|
-
const transferCmd = new Command("transfer").description("Transfer privately within the pool to another registered address").argument("<asset>", "Asset to transfer (ETH
|
|
6670
|
+
const transferCmd = new Command("transfer").description("Transfer privately within the pool to another registered address").argument("<asset>", "Asset to transfer (ETH or USDC)").argument("<amount>", "Amount to transfer (e.g., 0.1)").argument("<recipient>", "Recipient address (must be registered)").option("--veil-key <key>", "Veil private key (or set VEIL_KEY env)").option("--rpc-url <url>", "RPC URL (or set RPC_URL env)").option("--quiet", "Suppress progress output").action(async (asset, amount, recipient, options) => {
|
|
6724
6671
|
try {
|
|
6725
6672
|
const assetUpper = asset.toUpperCase();
|
|
6726
6673
|
if (!SUPPORTED_ASSETS3.includes(assetUpper)) {
|
|
@@ -6768,7 +6715,7 @@ function createTransferCommand() {
|
|
|
6768
6715
|
return transferCmd;
|
|
6769
6716
|
}
|
|
6770
6717
|
function createMergeCommand() {
|
|
6771
|
-
const mergeCmd = new Command("merge").description("Merge UTXOs by self-transfer (consolidate small UTXOs)").argument("<asset>", "Asset to merge (ETH
|
|
6718
|
+
const mergeCmd = new Command("merge").description("Merge UTXOs by self-transfer (consolidate small UTXOs)").argument("<asset>", "Asset to merge (ETH or USDC)").argument("<amount>", "Amount to merge (e.g., 0.5)").option("--veil-key <key>", "Veil private key (or set VEIL_KEY env)").option("--rpc-url <url>", "RPC URL (or set RPC_URL env)").option("--quiet", "Suppress progress output").action(async (asset, amount, options) => {
|
|
6772
6719
|
try {
|
|
6773
6720
|
const assetUpper = asset.toUpperCase();
|
|
6774
6721
|
if (!SUPPORTED_ASSETS3.includes(assetUpper)) {
|
package/dist/index.cjs
CHANGED
|
@@ -375,9 +375,6 @@ var ADDRESSES = {
|
|
|
375
375
|
usdcPool: "0x5c50d58E49C59d112680c187De2Bf989d2a91242",
|
|
376
376
|
usdcQueue: "0x5530241b24504bF05C9a22e95A1F5458888e6a9B",
|
|
377
377
|
usdcToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
378
|
-
cbbtcPool: "0x51A021da774b4bBB59B47f7CB4ccd631337680BA",
|
|
379
|
-
cbbtcQueue: "0x977741CaDF8D1431c4816C0993D32b02094cD35C",
|
|
380
|
-
cbbtcToken: "0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
|
|
381
378
|
chainId: 8453,
|
|
382
379
|
relayUrl: "https://veil-relay.up.railway.app"
|
|
383
380
|
};
|
|
@@ -393,12 +390,6 @@ var POOL_CONFIG = {
|
|
|
393
390
|
displayDecimals: 2,
|
|
394
391
|
symbol: "USDC",
|
|
395
392
|
name: "USD Coin"
|
|
396
|
-
},
|
|
397
|
-
cbbtc: {
|
|
398
|
-
decimals: 8,
|
|
399
|
-
displayDecimals: 6,
|
|
400
|
-
symbol: "cbBTC",
|
|
401
|
-
name: "Coinbase Bitcoin"
|
|
402
393
|
}
|
|
403
394
|
};
|
|
404
395
|
function getAddresses() {
|
|
@@ -411,8 +402,6 @@ function getPoolAddress(pool) {
|
|
|
411
402
|
return addresses.ethPool;
|
|
412
403
|
case "usdc":
|
|
413
404
|
return addresses.usdcPool;
|
|
414
|
-
case "cbbtc":
|
|
415
|
-
return addresses.cbbtcPool;
|
|
416
405
|
default:
|
|
417
406
|
throw new Error(`Unknown pool: ${pool}`);
|
|
418
407
|
}
|
|
@@ -424,8 +413,6 @@ function getQueueAddress(pool) {
|
|
|
424
413
|
return addresses.ethQueue;
|
|
425
414
|
case "usdc":
|
|
426
415
|
return addresses.usdcQueue;
|
|
427
|
-
case "cbbtc":
|
|
428
|
-
return addresses.cbbtcQueue;
|
|
429
416
|
default:
|
|
430
417
|
throw new Error(`Unknown pool: ${pool}`);
|
|
431
418
|
}
|
|
@@ -527,17 +514,6 @@ var ENTRY_ABI = [
|
|
|
527
514
|
stateMutability: "nonpayable",
|
|
528
515
|
type: "function"
|
|
529
516
|
},
|
|
530
|
-
// Queue cbBTC deposit
|
|
531
|
-
{
|
|
532
|
-
inputs: [
|
|
533
|
-
{ name: "_amount", type: "uint256" },
|
|
534
|
-
{ name: "_depositKey", type: "bytes" }
|
|
535
|
-
],
|
|
536
|
-
name: "queueBTC",
|
|
537
|
-
outputs: [],
|
|
538
|
-
stateMutability: "nonpayable",
|
|
539
|
-
type: "function"
|
|
540
|
-
},
|
|
541
517
|
// Read deposit keys
|
|
542
518
|
{
|
|
543
519
|
inputs: [{ name: "", type: "address" }],
|
|
@@ -1136,42 +1112,11 @@ function buildDepositUSDCTx(options) {
|
|
|
1136
1112
|
data
|
|
1137
1113
|
};
|
|
1138
1114
|
}
|
|
1139
|
-
function buildApproveCBBTCTx(options) {
|
|
1140
|
-
const { amount } = options;
|
|
1141
|
-
const addresses = getAddresses();
|
|
1142
|
-
const amountWei = viem.parseUnits(amount, POOL_CONFIG.cbbtc.decimals);
|
|
1143
|
-
const data = viem.encodeFunctionData({
|
|
1144
|
-
abi: ERC20_ABI,
|
|
1145
|
-
functionName: "approve",
|
|
1146
|
-
args: [addresses.entry, amountWei]
|
|
1147
|
-
});
|
|
1148
|
-
return {
|
|
1149
|
-
to: addresses.cbbtcToken,
|
|
1150
|
-
data
|
|
1151
|
-
};
|
|
1152
|
-
}
|
|
1153
|
-
function buildDepositCBBTCTx(options) {
|
|
1154
|
-
const { depositKey, amount } = options;
|
|
1155
|
-
const addresses = getAddresses();
|
|
1156
|
-
const amountWei = viem.parseUnits(amount, POOL_CONFIG.cbbtc.decimals);
|
|
1157
|
-
const data = viem.encodeFunctionData({
|
|
1158
|
-
abi: ENTRY_ABI,
|
|
1159
|
-
functionName: "queueBTC",
|
|
1160
|
-
args: [amountWei, depositKey]
|
|
1161
|
-
});
|
|
1162
|
-
return {
|
|
1163
|
-
to: addresses.entry,
|
|
1164
|
-
data
|
|
1165
|
-
};
|
|
1166
|
-
}
|
|
1167
1115
|
function buildDepositTx(options) {
|
|
1168
1116
|
const { token = "ETH", ...rest } = options;
|
|
1169
1117
|
if (token === "USDC") {
|
|
1170
1118
|
return buildDepositUSDCTx(rest);
|
|
1171
1119
|
}
|
|
1172
|
-
if (token === "CBBTC") {
|
|
1173
|
-
return buildDepositCBBTCTx(rest);
|
|
1174
|
-
}
|
|
1175
1120
|
return buildDepositETHTx(rest);
|
|
1176
1121
|
}
|
|
1177
1122
|
var DEPOSIT_STATUS_MAP = {
|
|
@@ -1555,8 +1500,8 @@ async function submitRelay(options) {
|
|
|
1555
1500
|
if (type !== "withdraw" && type !== "transfer") {
|
|
1556
1501
|
throw new RelayError('Invalid type. Must be "withdraw" or "transfer"', 400);
|
|
1557
1502
|
}
|
|
1558
|
-
if (pool !== "eth" && pool !== "usdc"
|
|
1559
|
-
throw new RelayError('Invalid pool. Must be "eth"
|
|
1503
|
+
if (pool !== "eth" && pool !== "usdc") {
|
|
1504
|
+
throw new RelayError('Invalid pool. Must be "eth" or "usdc"', 400);
|
|
1560
1505
|
}
|
|
1561
1506
|
if (!proofArgs || !extData) {
|
|
1562
1507
|
throw new RelayError("Missing proofArgs or extData", 400);
|
|
@@ -2054,10 +1999,8 @@ exports.QUEUE_ABI = QUEUE_ABI;
|
|
|
2054
1999
|
exports.RelayError = RelayError;
|
|
2055
2000
|
exports.Utxo = Utxo;
|
|
2056
2001
|
exports.VEIL_SIGNED_MESSAGE = VEIL_SIGNED_MESSAGE;
|
|
2057
|
-
exports.buildApproveCBBTCTx = buildApproveCBBTCTx;
|
|
2058
2002
|
exports.buildApproveUSDCTx = buildApproveUSDCTx;
|
|
2059
2003
|
exports.buildChangeDepositKeyTx = buildChangeDepositKeyTx;
|
|
2060
|
-
exports.buildDepositCBBTCTx = buildDepositCBBTCTx;
|
|
2061
2004
|
exports.buildDepositETHTx = buildDepositETHTx;
|
|
2062
2005
|
exports.buildDepositTx = buildDepositTx;
|
|
2063
2006
|
exports.buildDepositUSDCTx = buildDepositUSDCTx;
|