@ravenhouse/compliant-bridge 0.1.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 +262 -0
- package/dist/index.cjs +815 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +524 -0
- package/dist/index.d.ts +524 -0
- package/dist/index.js +774 -0
- package/dist/index.js.map +1 -0
- package/package.json +67 -0
package/README.md
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# @ravenhouse/compliant-bridge
|
|
2
|
+
|
|
3
|
+
Headless SDK for Aztec-Ethereum compliant bridging with ZK Passport verification.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Framework-agnostic (works with React, Vue, vanilla JS, etc.)
|
|
8
|
+
- Pre-configured networks (devnet, sandbox, testnet)
|
|
9
|
+
- ZK Passport identity verification integration
|
|
10
|
+
- Type-safe TypeScript API
|
|
11
|
+
- L1 → L2 token bridging
|
|
12
|
+
- Comprehensive token management
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @ravenhouse/compliant-bridge
|
|
18
|
+
# or
|
|
19
|
+
bun add @ravenhouse/compliant-bridge
|
|
20
|
+
# or
|
|
21
|
+
yarn add @ravenhouse/compliant-bridge
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { CompliantBridge, networks } from '@ravenhouse/compliant-bridge';
|
|
28
|
+
|
|
29
|
+
// Initialize the SDK
|
|
30
|
+
const bridge = new CompliantBridge({
|
|
31
|
+
network: networks.devnet,
|
|
32
|
+
l1Wallet: myEthereumWallet, // Your L1 wallet client (Wagmi/viem)
|
|
33
|
+
l2Wallet: myAztecWallet, // Your L2 wallet client (Aztec/Azguard)
|
|
34
|
+
backendApiUrl: 'https://api.ravenhouse.xyz'
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Get supported tokens
|
|
38
|
+
const tokens = bridge.getSupportedTokens();
|
|
39
|
+
const rht = bridge.getToken('RHT');
|
|
40
|
+
|
|
41
|
+
// Execute L1 → L2 bridge
|
|
42
|
+
const result = await bridge.bridgeL1ToL2({
|
|
43
|
+
token: rht,
|
|
44
|
+
amount: '100.5',
|
|
45
|
+
isPrivate: true,
|
|
46
|
+
onStep: (step) => {
|
|
47
|
+
console.log(`${step.label}: ${step.status}`);
|
|
48
|
+
if (step.explorerUrl) {
|
|
49
|
+
console.log(`View transaction: ${step.explorerUrl}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
console.log('Bridge result:', result);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## API Reference
|
|
58
|
+
|
|
59
|
+
### CompliantBridge
|
|
60
|
+
|
|
61
|
+
Main SDK class for bridge operations.
|
|
62
|
+
|
|
63
|
+
#### Constructor
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
new CompliantBridge(config: BridgeConfig)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Parameters:**
|
|
70
|
+
- `network`: Network configuration (devnet, sandbox, or testnet)
|
|
71
|
+
- `l1Wallet`: L1 wallet client (Ethereum/Wagmi)
|
|
72
|
+
- `l2Wallet`: L2 wallet client (Aztec/Azguard)
|
|
73
|
+
- `backendApiUrl`: Backend API URL for verification
|
|
74
|
+
- `logger?`: Optional logger instance
|
|
75
|
+
- `timeouts?`: Optional timeout configuration
|
|
76
|
+
|
|
77
|
+
#### Methods
|
|
78
|
+
|
|
79
|
+
##### `bridgeL1ToL2(params: L1ToL2Params): Promise<BridgeResult>`
|
|
80
|
+
|
|
81
|
+
Bridge tokens from L1 (Ethereum) to L2 (Aztec).
|
|
82
|
+
|
|
83
|
+
**Parameters:**
|
|
84
|
+
- `token`: Token to bridge
|
|
85
|
+
- `amount`: Amount to bridge (decimal string, e.g., "100.5")
|
|
86
|
+
- `isPrivate`: Whether to bridge privately
|
|
87
|
+
- `onStep?`: Callback for step progress updates
|
|
88
|
+
|
|
89
|
+
**Returns:** `Promise<BridgeResult>`
|
|
90
|
+
|
|
91
|
+
##### `getSupportedTokens(): TokenConfig[]`
|
|
92
|
+
|
|
93
|
+
Get all supported tokens for the current network.
|
|
94
|
+
|
|
95
|
+
##### `getToken(symbol: string): TokenConfig | undefined`
|
|
96
|
+
|
|
97
|
+
Get a specific token by symbol.
|
|
98
|
+
|
|
99
|
+
### BridgeResult
|
|
100
|
+
|
|
101
|
+
Result of a bridge operation.
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
interface BridgeResult {
|
|
105
|
+
success: boolean;
|
|
106
|
+
direction: 'l1-to-l2' | 'l2-to-l1';
|
|
107
|
+
amount: string;
|
|
108
|
+
symbol: string;
|
|
109
|
+
finalTxHash?: string;
|
|
110
|
+
explorerUrl?: string;
|
|
111
|
+
message: string;
|
|
112
|
+
steps: BridgeStep[];
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### TokenConfig
|
|
117
|
+
|
|
118
|
+
Token configuration.
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
interface TokenConfig {
|
|
122
|
+
symbol: string;
|
|
123
|
+
name: string;
|
|
124
|
+
decimals: number;
|
|
125
|
+
icon?: string;
|
|
126
|
+
isNative?: boolean;
|
|
127
|
+
l1: {
|
|
128
|
+
tokenAddress: string | null;
|
|
129
|
+
portalAddress: string;
|
|
130
|
+
feeAssetHandlerAddress: string;
|
|
131
|
+
};
|
|
132
|
+
l2: {
|
|
133
|
+
tokenAddress: string;
|
|
134
|
+
bridgeAddress: string;
|
|
135
|
+
dripper?: string;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### IdentityVerifier
|
|
141
|
+
|
|
142
|
+
Check and manage user verification status.
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
const verifier = bridge.verifier;
|
|
146
|
+
|
|
147
|
+
// Check if user is verified
|
|
148
|
+
const status = await verifier.checkStatus(aztecAddress);
|
|
149
|
+
console.log(status.isVerified); // boolean
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Supported Networks
|
|
153
|
+
|
|
154
|
+
- **devnet**: Aztec devnet with Sepolia L1
|
|
155
|
+
- **sandbox**: Local development environment
|
|
156
|
+
- **testnet**: Aztec testnet with Sepolia L1
|
|
157
|
+
|
|
158
|
+
## Supported Tokens
|
|
159
|
+
|
|
160
|
+
- **RHT**: Raven House Test token
|
|
161
|
+
- **ETH**: Ethereum (bridged as WETH)
|
|
162
|
+
|
|
163
|
+
## Wallet Integration
|
|
164
|
+
|
|
165
|
+
### L1 Wallet (Ethereum/Wagmi)
|
|
166
|
+
|
|
167
|
+
Your L1 wallet client must implement:
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
interface L1WalletClient {
|
|
171
|
+
account: { address: string };
|
|
172
|
+
extend(actions: any): L1WalletClient;
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Example with Wagmi:**
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
import { useWalletClient } from 'wagmi';
|
|
180
|
+
|
|
181
|
+
function useCompliantBridge() {
|
|
182
|
+
const { data: walletClient } = useWalletClient();
|
|
183
|
+
|
|
184
|
+
const bridge = useMemo(() => {
|
|
185
|
+
if (!walletClient) return null;
|
|
186
|
+
|
|
187
|
+
return new CompliantBridge({
|
|
188
|
+
network: networks.devnet,
|
|
189
|
+
l1Wallet: walletClient,
|
|
190
|
+
l2Wallet: myAztecWallet,
|
|
191
|
+
backendApiUrl: 'https://api.ravenhouse.xyz'
|
|
192
|
+
});
|
|
193
|
+
}, [walletClient]);
|
|
194
|
+
|
|
195
|
+
return bridge;
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### L2 Wallet (Aztec/Azguard)
|
|
200
|
+
|
|
201
|
+
Your L2 wallet client must implement:
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
interface L2WalletClient {
|
|
205
|
+
request(method: string, params: any): Promise<any>;
|
|
206
|
+
account: string;
|
|
207
|
+
sessionId: string;
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Example with Azguard:**
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
const l2Wallet = {
|
|
215
|
+
account: aztecAccountAddress,
|
|
216
|
+
sessionId: aztecSessionId,
|
|
217
|
+
request: (method, params) => azguardClient.request(method, params)
|
|
218
|
+
};
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Error Handling
|
|
222
|
+
|
|
223
|
+
The SDK provides specific error types:
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
import {
|
|
227
|
+
BridgeError,
|
|
228
|
+
VerificationError,
|
|
229
|
+
WalletError,
|
|
230
|
+
TokenError,
|
|
231
|
+
NetworkError,
|
|
232
|
+
TransactionError
|
|
233
|
+
} from '@ravenhouse/compliant-bridge';
|
|
234
|
+
|
|
235
|
+
try {
|
|
236
|
+
const result = await bridge.bridgeL1ToL2({ ... });
|
|
237
|
+
} catch (error) {
|
|
238
|
+
if (error instanceof TokenError) {
|
|
239
|
+
console.error('Token error:', error.message);
|
|
240
|
+
} else if (error instanceof WalletError) {
|
|
241
|
+
console.error('Wallet error:', error.message);
|
|
242
|
+
} else if (error instanceof BridgeError) {
|
|
243
|
+
console.error('Bridge error:', error.message);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Examples
|
|
249
|
+
|
|
250
|
+
See the `examples/` directory for complete integration examples with different frameworks.
|
|
251
|
+
|
|
252
|
+
## License
|
|
253
|
+
|
|
254
|
+
MIT
|
|
255
|
+
|
|
256
|
+
## Contributing
|
|
257
|
+
|
|
258
|
+
Contributions are welcome! Please open an issue or submit a pull request.
|
|
259
|
+
|
|
260
|
+
## Support
|
|
261
|
+
|
|
262
|
+
For issues and questions, please use the GitHub issue tracker.
|