@veil-cash/sdk 0.5.0 → 0.6.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 +31 -2
- package/SDK.md +55 -1
- package/dist/cli/index.cjs +806 -22
- package/dist/index.cjs +554 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +486 -1
- package/dist/index.d.ts +486 -1
- package/dist/index.js +537 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/abi.ts +172 -0
- package/src/addresses.ts +14 -0
- package/src/cli/commands/subaccount.ts +354 -0
- package/src/cli/errors.ts +4 -0
- package/src/cli/index.ts +5 -1
- package/src/cli/wallet.ts +2 -2
- package/src/index.ts +35 -0
- package/src/relay.ts +36 -24
- package/src/subaccount.ts +476 -0
- package/src/types.ts +134 -0
package/README.md
CHANGED
|
@@ -8,6 +8,8 @@ SDK and CLI for interacting with [Veil Cash](https://veil.cash) privacy pools on
|
|
|
8
8
|
|
|
9
9
|
Generate keypairs, register, deposit, withdraw, transfer, and merge ETH and USDC privately.
|
|
10
10
|
|
|
11
|
+
`0.6.0` adds SDK-first subaccount support for deterministic slot derivation, forwarder status, relay-backed deploy/sweep, and direct recovery.
|
|
12
|
+
|
|
11
13
|
## Installation
|
|
12
14
|
|
|
13
15
|
```bash
|
|
@@ -76,9 +78,17 @@ veil withdraw ETH 0.05 0xRecipientAddress
|
|
|
76
78
|
veil transfer ETH 0.02 0xRecipientAddress
|
|
77
79
|
veil merge ETH 0.1
|
|
78
80
|
|
|
79
|
-
# 8.
|
|
81
|
+
# 8. Work with subaccounts
|
|
82
|
+
veil subaccount derive --slot 0
|
|
83
|
+
veil subaccount status --slot 0
|
|
84
|
+
veil subaccount deploy --slot 0
|
|
85
|
+
veil subaccount sweep --slot 0 --asset eth
|
|
86
|
+
veil subaccount recover --slot 0 --asset usdc --to 0xRecipientAddress --amount 25
|
|
87
|
+
|
|
88
|
+
# 9. Use JSON or unsigned modes when you need automation
|
|
80
89
|
veil status --json
|
|
81
90
|
veil deposit ETH 0.1 --unsigned
|
|
91
|
+
veil subaccount status --slot 0 --json
|
|
82
92
|
```
|
|
83
93
|
|
|
84
94
|
## CLI Tasks
|
|
@@ -188,6 +198,24 @@ veil merge USDC 100
|
|
|
188
198
|
veil merge ETH 0.1 --json
|
|
189
199
|
```
|
|
190
200
|
|
|
201
|
+
### Subaccounts
|
|
202
|
+
|
|
203
|
+
Subaccounts are deterministic child slots derived from your main `VEIL_KEY`:
|
|
204
|
+
|
|
205
|
+
`root key -> slot -> child key -> child deposit key -> forwarder`
|
|
206
|
+
|
|
207
|
+
Base mainnet only. Deploy and sweep are relay-backed. Status reports the forwarder wallet and queue state only, not private pool attribution after queued funds are accepted. Recovery is for assets still sitting on the forwarder after refund or rejection, and is submitted directly on-chain by your CLI gas payer.
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
veil subaccount derive --slot 0
|
|
211
|
+
veil subaccount status --slot 0
|
|
212
|
+
veil subaccount address --slot 0
|
|
213
|
+
veil subaccount deploy --slot 0
|
|
214
|
+
veil subaccount sweep --slot 0 --asset eth
|
|
215
|
+
veil subaccount recover --slot 0 --asset usdc --to 0xRecipientAddress --amount 25
|
|
216
|
+
veil subaccount status --slot 0 --json
|
|
217
|
+
```
|
|
218
|
+
|
|
191
219
|
## Environment Variables
|
|
192
220
|
|
|
193
221
|
The CLI uses two config files:
|
|
@@ -206,7 +234,7 @@ The CLI uses two config files:
|
|
|
206
234
|
| `WALLET_KEY` | Ethereum wallet private key (for signing transactions) |
|
|
207
235
|
| `SIGNER_ADDRESS` | Ethereum address for unsigned/query flows when signing is handled externally |
|
|
208
236
|
| `RPC_URL` | Base RPC URL (optional, defaults to public RPC) |
|
|
209
|
-
| `RELAY_URL` | Override relay base URL for relayed CLI operations and status checks |
|
|
237
|
+
| `RELAY_URL` | Override relay base URL for relayed CLI operations, subaccount deploy/sweep, and status checks |
|
|
210
238
|
|
|
211
239
|
`WALLET_KEY` and `SIGNER_ADDRESS` are mutually exclusive. Use `WALLET_KEY` for commands that sign transactions, and `SIGNER_ADDRESS` for address-only agent flows like `status`, `balance`, and `register --unsigned`.
|
|
212
240
|
|
|
@@ -231,6 +259,7 @@ Commands print human-readable success output by default. Errors are standardized
|
|
|
231
259
|
| `DEPOSIT_KEY_MISSING` | DEPOSIT_KEY not provided |
|
|
232
260
|
| `CONFIG_CONFLICT` | Conflicting CLI env vars provided |
|
|
233
261
|
| `INVALID_ADDRESS` | Invalid Ethereum address format |
|
|
262
|
+
| `INVALID_SLOT` | Invalid subaccount slot format |
|
|
234
263
|
| `INVALID_AMOUNT` | Invalid or below minimum amount |
|
|
235
264
|
| `INSUFFICIENT_BALANCE` | Not enough ETH balance |
|
|
236
265
|
| `USER_NOT_REGISTERED` | Recipient not registered in Veil |
|
package/SDK.md
CHANGED
|
@@ -10,7 +10,7 @@ If you are looking for the CLI first-run flow, go back to the main [README](./RE
|
|
|
10
10
|
import {
|
|
11
11
|
Keypair, buildRegisterTx, buildDepositETHTx,
|
|
12
12
|
buildDepositUSDCTx, buildApproveUSDCTx,
|
|
13
|
-
withdraw, transfer,
|
|
13
|
+
withdraw, transfer, getSubaccountStatus,
|
|
14
14
|
} from '@veil-cash/sdk';
|
|
15
15
|
import { createWalletClient, http } from 'viem';
|
|
16
16
|
import { base } from 'viem/chains';
|
|
@@ -65,6 +65,13 @@ const transferResult = await transfer({
|
|
|
65
65
|
pool: 'eth', // 'eth' | 'usdc' (default: 'eth')
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
+
// 7. Inspect a deterministic subaccount slot
|
|
69
|
+
const subaccount = await getSubaccountStatus({
|
|
70
|
+
rootPrivateKey: keypair.privkey as `0x${string}`,
|
|
71
|
+
slot: 0,
|
|
72
|
+
});
|
|
73
|
+
console.log(subaccount.slot.forwarderAddress);
|
|
74
|
+
|
|
68
75
|
```
|
|
69
76
|
|
|
70
77
|
## SDK API Reference
|
|
@@ -190,6 +197,53 @@ const privateBalance = await getPrivateBalance({
|
|
|
190
197
|
});
|
|
191
198
|
```
|
|
192
199
|
|
|
200
|
+
### Subaccounts
|
|
201
|
+
|
|
202
|
+
Subaccounts are deterministic child slots derived from your main Veil key:
|
|
203
|
+
|
|
204
|
+
`root key -> slot -> child key -> child deposit key -> forwarder`
|
|
205
|
+
|
|
206
|
+
Base mainnet only. Status shows the forwarder wallet and queue state only. Deploy and sweep are relay-backed. Recovery signs a forwarder withdraw request with the child key and returns a direct transaction for your gas payer to submit.
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
import {
|
|
210
|
+
deriveSubaccountSlot,
|
|
211
|
+
getSubaccountStatus,
|
|
212
|
+
deploySubaccountForwarder,
|
|
213
|
+
sweepSubaccountForwarder,
|
|
214
|
+
buildSubaccountRecoveryTx,
|
|
215
|
+
} from '@veil-cash/sdk';
|
|
216
|
+
|
|
217
|
+
const slot = await deriveSubaccountSlot({
|
|
218
|
+
rootPrivateKey: veilKey,
|
|
219
|
+
slot: 0,
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
const status = await getSubaccountStatus({
|
|
223
|
+
rootPrivateKey: veilKey,
|
|
224
|
+
slot: 0,
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
await deploySubaccountForwarder({
|
|
228
|
+
rootPrivateKey: veilKey,
|
|
229
|
+
slot: 0,
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
await sweepSubaccountForwarder({
|
|
233
|
+
forwarderAddress: slot.forwarderAddress,
|
|
234
|
+
asset: 'eth',
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
const recovery = await buildSubaccountRecoveryTx({
|
|
238
|
+
rootPrivateKey: veilKey,
|
|
239
|
+
slot: 0,
|
|
240
|
+
asset: 'usdc',
|
|
241
|
+
to: '0xRecipientAddress',
|
|
242
|
+
amount: '25',
|
|
243
|
+
});
|
|
244
|
+
// Send recovery.transaction with your wallet client
|
|
245
|
+
```
|
|
246
|
+
|
|
193
247
|
### Addresses
|
|
194
248
|
|
|
195
249
|
```typescript
|