@tapforce/pod-bridge-sdk 1.1.8 → 1.1.10
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 +98 -74
- package/dist/clients/tracker/client.d.ts +24 -46
- package/dist/clients/tracker/client.js +109 -412
- package/dist/clients/tracker/pod-tracker.service.d.ts +59 -0
- package/dist/clients/tracker/pod-tracker.service.js +210 -0
- package/dist/clients/tracker/source-chain-tracker.service.d.ts +53 -0
- package/dist/clients/tracker/source-chain-tracker.service.js +152 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/libs/helpers/certificate.helper.d.ts +26 -0
- package/dist/libs/helpers/certificate.helper.js +55 -0
- package/dist/libs/helpers/index.d.ts +2 -0
- package/dist/libs/helpers/index.js +7 -0
- package/dist/libs/helpers/merkle.helper.d.ts +9 -0
- package/dist/libs/helpers/merkle.helper.js +48 -0
- package/dist/libs/types/pod-bridge.types.d.ts +23 -10
- package/dist/libs/types/pod-bridge.types.js +6 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Pod Bridge SDK
|
|
2
2
|
|
|
3
|
-
TypeScript SDK for interacting with
|
|
3
|
+
TypeScript SDK for interacting with Bridges between POD and other chains - enabling cross-chain token transfers between POD and other EVM chains (e.g., Sepolia).
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -34,8 +34,8 @@ pnpm add @tapforce/pod-bridge-sdk
|
|
|
34
34
|
|
|
35
35
|
```typescript
|
|
36
36
|
import {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
SourceChainToPodActionClient,
|
|
38
|
+
PodToSourceChainActionClient,
|
|
39
39
|
PodBridgeTrackerClient,
|
|
40
40
|
PodBridgeConfig
|
|
41
41
|
} from '@tapforce/pod-bridge-sdk';
|
|
@@ -47,13 +47,13 @@ Create a configuration object with source and destination chain details:
|
|
|
47
47
|
|
|
48
48
|
```typescript
|
|
49
49
|
const config: PodBridgeConfig = {
|
|
50
|
-
|
|
50
|
+
sourceChain: {
|
|
51
51
|
rpcUrl: 'https://sepolia.infura.io/v3/YOUR_KEY',
|
|
52
52
|
contractAddress: '0x...', // Source chain bridge contract
|
|
53
53
|
deploymentBlock: 9502541 // Optional: Start indexing from deployment block (avoids querying empty blocks)
|
|
54
54
|
},
|
|
55
55
|
pod: {
|
|
56
|
-
rpcUrl: 'https://
|
|
56
|
+
rpcUrl: 'https://rpc.v1.dev.pod.network',
|
|
57
57
|
contractAddress: '0x...', // Destination chain bridge contract
|
|
58
58
|
deploymentBlock: 0 // Optional: POD deployment block
|
|
59
59
|
}
|
|
@@ -66,30 +66,30 @@ const config: PodBridgeConfig = {
|
|
|
66
66
|
|
|
67
67
|
The SDK provides two action clients for different bridge directions:
|
|
68
68
|
|
|
69
|
-
- **`
|
|
70
|
-
- **`
|
|
69
|
+
- **`SourceChainToPodActionClient`**: For Source Chain → POD transfers (e.g., Sepolia → POD)
|
|
70
|
+
- **`PodToSourceChainActionClient`**: For POD → Source Chain transfers (e.g., POD → Sepolia)
|
|
71
71
|
|
|
72
72
|
#### Configuration for Action Clients
|
|
73
73
|
|
|
74
74
|
```typescript
|
|
75
75
|
const actionConfig = {
|
|
76
|
-
|
|
77
|
-
contractAddress: '0x...' //
|
|
76
|
+
sourceChain: {
|
|
77
|
+
contractAddress: '0x...' // Source chain bridge contract (e.g., Sepolia)
|
|
78
78
|
},
|
|
79
79
|
pod: {
|
|
80
80
|
contractAddress: '0x...' // POD chain bridge contract
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
-
const
|
|
85
|
-
const
|
|
84
|
+
const sourceChainToPodClient = new SourceChainToPodActionClient(actionConfig);
|
|
85
|
+
const podToSourceChainClient = new PodToSourceChainActionClient(actionConfig);
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
#### Deposit from
|
|
88
|
+
#### Deposit from Source Chain (e.g., Sepolia → POD)
|
|
89
89
|
|
|
90
90
|
```typescript
|
|
91
|
-
// Create unsigned transaction for ERC20 deposit on
|
|
92
|
-
const unsignedTx =
|
|
91
|
+
// Create unsigned transaction for ERC20 deposit on Source chain
|
|
92
|
+
const unsignedTx = sourceChainToPodClient.depositToken({
|
|
93
93
|
token: '0x...', // ERC20 token address
|
|
94
94
|
amount: '1000000000000000000', // Amount in wei (1 token with 18 decimals)
|
|
95
95
|
destinationWalletAddress: '0x...', // Recipient address on POD
|
|
@@ -97,7 +97,7 @@ const unsignedTx = bridgedToPodClient.depositToken({
|
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
// Deposit native tokens
|
|
100
|
-
const unsignedNativeTx =
|
|
100
|
+
const unsignedNativeTx = sourceChainToPodClient.depositNative({
|
|
101
101
|
amount: '1000000000000000000', // Amount in wei (1 ETH)
|
|
102
102
|
destinationWalletAddress: '0x...', // Recipient address on POD
|
|
103
103
|
from: '0x...' // Optional: sender address
|
|
@@ -107,13 +107,13 @@ const unsignedNativeTx = bridgedToPodClient.depositNative({
|
|
|
107
107
|
// const tx = await signer.sendTransaction(unsignedTx);
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
#### Claim on POD from
|
|
110
|
+
#### Claim on POD from Source Chain Deposits
|
|
111
111
|
|
|
112
|
-
For claiming on POD from
|
|
112
|
+
For claiming on POD from Source chain deposits, use block number-based claims:
|
|
113
113
|
|
|
114
114
|
```typescript
|
|
115
115
|
// Create unsigned claim transaction for ERC20 on POD
|
|
116
|
-
const unsignedTx =
|
|
116
|
+
const unsignedTx = sourceChainToPodClient.claimWithBlockNumber({
|
|
117
117
|
id: '123', // Request ID from deposit event
|
|
118
118
|
token: '0x...', // Token address on source chain
|
|
119
119
|
blockNumber: 12345678, // Block number of deposit on source chain
|
|
@@ -121,49 +121,49 @@ const unsignedTx = bridgedToPodClient.claimWithBlockNumber({
|
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
// For native tokens
|
|
124
|
-
const unsignedNativeTx =
|
|
124
|
+
const unsignedNativeTx = sourceChainToPodClient.claimNativeWithBlockNumber({
|
|
125
125
|
id: '123',
|
|
126
126
|
blockNumber: 12345678,
|
|
127
127
|
from: '0x...'
|
|
128
128
|
});
|
|
129
129
|
```
|
|
130
130
|
|
|
131
|
-
#### Deposit from POD (POD →
|
|
131
|
+
#### Deposit from POD (POD → Source Chain)
|
|
132
132
|
|
|
133
133
|
```typescript
|
|
134
134
|
// Create unsigned transaction for ERC20 deposit on POD
|
|
135
|
-
const unsignedTx =
|
|
135
|
+
const unsignedTx = podToSourceChainClient.depositToken({
|
|
136
136
|
token: '0x...', // ERC20 token address
|
|
137
137
|
amount: '1000000000000000000', // Amount in wei
|
|
138
|
-
destinationWalletAddress: '0x...', // Recipient address on
|
|
138
|
+
destinationWalletAddress: '0x...', // Recipient address on Source chain
|
|
139
139
|
from: '0x...' // Optional: sender address
|
|
140
140
|
});
|
|
141
141
|
|
|
142
142
|
// Deposit native tokens
|
|
143
|
-
const unsignedNativeTx =
|
|
143
|
+
const unsignedNativeTx = podToSourceChainClient.depositNative({
|
|
144
144
|
amount: '1000000000000000000',
|
|
145
145
|
destinationWalletAddress: '0x...',
|
|
146
146
|
from: '0x...'
|
|
147
147
|
});
|
|
148
148
|
```
|
|
149
149
|
|
|
150
|
-
#### Claim on
|
|
150
|
+
#### Claim on Source Chain from POD Deposits
|
|
151
151
|
|
|
152
|
-
For claiming on
|
|
152
|
+
For claiming on Source chain from POD deposits, use certificate-based claims. First, get the certified log from the POD deposit transaction:
|
|
153
153
|
|
|
154
154
|
```typescript
|
|
155
155
|
// Get certified log from POD deposit transaction
|
|
156
156
|
const depositTxHash = '0x...'; // Transaction hash of deposit on POD
|
|
157
157
|
const certifiedLog = await trackerClient.getDepositCertifiedLog(depositTxHash);
|
|
158
158
|
|
|
159
|
-
// Create unsigned claim transaction for ERC20 on
|
|
160
|
-
const unsignedTx =
|
|
159
|
+
// Create unsigned claim transaction for ERC20 on Source chain
|
|
160
|
+
const unsignedTx = podToSourceChainClient.claimWithCertificate({
|
|
161
161
|
certifiedLog,
|
|
162
162
|
from: '0x...' // Optional: claimer address
|
|
163
163
|
});
|
|
164
164
|
|
|
165
165
|
// For native tokens
|
|
166
|
-
const unsignedNativeTx =
|
|
166
|
+
const unsignedNativeTx = podToSourceChainClient.claimNativeWithCertificate({
|
|
167
167
|
certifiedLog,
|
|
168
168
|
from: '0x...'
|
|
169
169
|
});
|
|
@@ -188,13 +188,16 @@ const deposits = await trackerClient.getDepositsSentBy(
|
|
|
188
188
|
|
|
189
189
|
deposits.forEach(deposit => {
|
|
190
190
|
console.log(`Request ID: ${deposit.requestId}`);
|
|
191
|
-
console.log(`
|
|
192
|
-
console.log(`
|
|
193
|
-
console.log(`
|
|
191
|
+
console.log(`Deposit Chain: ${deposit.deposit.chain}`);
|
|
192
|
+
console.log(`From: ${deposit.deposit.from} -> To: ${deposit.deposit.to}`);
|
|
193
|
+
console.log(`Token: ${deposit.deposit.token}`);
|
|
194
|
+
console.log(`Amount: ${deposit.deposit.amount}`);
|
|
195
|
+
console.log(`Block: ${deposit.deposit.blockNumber}, Time: ${deposit.deposit.timestamp}`);
|
|
194
196
|
console.log(`Claimed: ${deposit.isClaimed}`);
|
|
195
|
-
if (deposit.isClaimed) {
|
|
196
|
-
console.log(`
|
|
197
|
-
console.log(`Claimed
|
|
197
|
+
if (deposit.isClaimed && deposit.claim) {
|
|
198
|
+
console.log(`Claim Chain: ${deposit.claim.chain}`);
|
|
199
|
+
console.log(`Claimed by: ${deposit.claim.claimer}`);
|
|
200
|
+
console.log(`Claimed tx: ${deposit.claim.txHash}`);
|
|
198
201
|
}
|
|
199
202
|
});
|
|
200
203
|
```
|
|
@@ -250,25 +253,25 @@ processedStatuses.forEach((isProcessed, index) => {
|
|
|
250
253
|
|
|
251
254
|
## API Reference
|
|
252
255
|
|
|
253
|
-
###
|
|
256
|
+
### SourceChainToPodActionClient
|
|
254
257
|
|
|
255
|
-
Handles transactions for
|
|
258
|
+
Handles transactions for Source Chain → POD direction.
|
|
256
259
|
|
|
257
260
|
#### Constructor
|
|
258
261
|
|
|
259
262
|
```typescript
|
|
260
|
-
new
|
|
263
|
+
new SourceChainToPodActionClient(config: PodBridgeActionsClientConfig)
|
|
261
264
|
```
|
|
262
265
|
|
|
263
266
|
#### Methods
|
|
264
267
|
|
|
265
|
-
- **`depositToken(args)`**: Create unsigned transaction for ERC20 deposit on
|
|
268
|
+
- **`depositToken(args)`**: Create unsigned transaction for ERC20 deposit on Source chain
|
|
266
269
|
- `token`: Token address
|
|
267
270
|
- `amount`: Amount in wei (string | bigint)
|
|
268
271
|
- `destinationWalletAddress`: Recipient address on POD
|
|
269
272
|
- `from?`: Optional sender address
|
|
270
273
|
|
|
271
|
-
- **`depositNative(args)`**: Create unsigned transaction for native token deposit on
|
|
274
|
+
- **`depositNative(args)`**: Create unsigned transaction for native token deposit on Source chain
|
|
272
275
|
- `amount`: Amount in wei (string | bigint)
|
|
273
276
|
- `destinationWalletAddress`: Recipient address on POD
|
|
274
277
|
- `from?`: Optional sender address
|
|
@@ -276,22 +279,22 @@ new BridgedToPodActionClient(config: PodBridgeActionsClientConfig)
|
|
|
276
279
|
- **`claimWithBlockNumber(args)`**: Create unsigned transaction for claiming on POD with block number
|
|
277
280
|
- `id`: Request ID
|
|
278
281
|
- `token`: Token address
|
|
279
|
-
- `blockNumber`: Block number of deposit on
|
|
282
|
+
- `blockNumber`: Block number of deposit on Source chain
|
|
280
283
|
- `from?`: Optional claimer address
|
|
281
284
|
|
|
282
285
|
- **`claimNativeWithBlockNumber(args)`**: Create unsigned transaction for claiming native tokens on POD with block number
|
|
283
286
|
- `id`: Request ID
|
|
284
|
-
- `blockNumber`: Block number of deposit on
|
|
287
|
+
- `blockNumber`: Block number of deposit on Source chain
|
|
285
288
|
- `from?`: Optional claimer address
|
|
286
289
|
|
|
287
|
-
###
|
|
290
|
+
### PodToSourceChainActionClient
|
|
288
291
|
|
|
289
|
-
Handles transactions for POD →
|
|
292
|
+
Handles transactions for POD → Source Chain direction.
|
|
290
293
|
|
|
291
294
|
#### Constructor
|
|
292
295
|
|
|
293
296
|
```typescript
|
|
294
|
-
new
|
|
297
|
+
new PodToSourceChainActionClient(config: PodBridgeActionsClientConfig)
|
|
295
298
|
```
|
|
296
299
|
|
|
297
300
|
#### Methods
|
|
@@ -299,19 +302,19 @@ new PodToBridgedActionClient(config: PodBridgeActionsClientConfig)
|
|
|
299
302
|
- **`depositToken(args)`**: Create unsigned transaction for ERC20 deposit on POD
|
|
300
303
|
- `token`: Token address
|
|
301
304
|
- `amount`: Amount in wei (string | bigint)
|
|
302
|
-
- `destinationWalletAddress`: Recipient address on
|
|
305
|
+
- `destinationWalletAddress`: Recipient address on Source chain
|
|
303
306
|
- `from?`: Optional sender address
|
|
304
307
|
|
|
305
308
|
- **`depositNative(args)`**: Create unsigned transaction for native token deposit on POD
|
|
306
309
|
- `amount`: Amount in wei (string | bigint)
|
|
307
|
-
- `destinationWalletAddress`: Recipient address on
|
|
310
|
+
- `destinationWalletAddress`: Recipient address on Source chain
|
|
308
311
|
- `from?`: Optional sender address
|
|
309
312
|
|
|
310
|
-
- **`claimWithCertificate(args)`**: Create unsigned transaction for claiming on
|
|
313
|
+
- **`claimWithCertificate(args)`**: Create unsigned transaction for claiming on Source chain with certificate
|
|
311
314
|
- `certifiedLog`: Certified log from POD certificate system
|
|
312
315
|
- `from?`: Optional claimer address
|
|
313
316
|
|
|
314
|
-
- **`claimNativeWithCertificate(args)`**: Create unsigned transaction for claiming native tokens on
|
|
317
|
+
- **`claimNativeWithCertificate(args)`**: Create unsigned transaction for claiming native tokens on Source chain with certificate
|
|
315
318
|
- `certifiedLog`: Certified log from POD certificate system
|
|
316
319
|
- `from?`: Optional claimer address
|
|
317
320
|
|
|
@@ -334,7 +337,7 @@ new PodToBridgedActionClient(config: PodBridgeActionsClientConfig)
|
|
|
334
337
|
- **`areRequestsProcessed(deposits)`**: Batch check if requests are processed
|
|
335
338
|
- Returns: `Promise<boolean[]>`
|
|
336
339
|
|
|
337
|
-
- **`getDepositCertifiedLog(txHash)`**: Get certified log for claiming on
|
|
340
|
+
- **`getDepositCertifiedLog(txHash)`**: Get certified log for claiming on Source chain from POD deposit
|
|
338
341
|
- `txHash`: Transaction hash of deposit on POD
|
|
339
342
|
- Returns: `Promise<CertifiedLog>` with attestations and merkle proof
|
|
340
343
|
|
|
@@ -343,19 +346,40 @@ new PodToBridgedActionClient(config: PodBridgeActionsClientConfig)
|
|
|
343
346
|
### BridgeRequest
|
|
344
347
|
|
|
345
348
|
```typescript
|
|
349
|
+
enum BridgeChain {
|
|
350
|
+
SOURCE_CHAIN = 'sourceChain',
|
|
351
|
+
POD = 'pod'
|
|
352
|
+
}
|
|
353
|
+
|
|
346
354
|
interface BridgeRequest {
|
|
347
355
|
requestId: string;
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
356
|
+
|
|
357
|
+
// Deposit information
|
|
358
|
+
deposit: {
|
|
359
|
+
chain: BridgeChain; // Which chain the deposit occurred on
|
|
360
|
+
txHash: string;
|
|
361
|
+
from: string; // Sender address
|
|
362
|
+
to: string; // Recipient address on destination chain
|
|
363
|
+
token: string; // Token address (or 0x0 for native)
|
|
364
|
+
amount: string; // Amount in wei
|
|
365
|
+
chainId: number;
|
|
366
|
+
blockNumber: number; // Block number (for POD, this is essentially a timestamp)
|
|
367
|
+
timestamp: number; // Unix timestamp
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
// Claim information (optional, only if claimed)
|
|
371
|
+
claim?: {
|
|
372
|
+
chain: BridgeChain; // Which chain the claim occurred on
|
|
373
|
+
txHash: string;
|
|
374
|
+
claimer: string; // Address that claimed
|
|
375
|
+
chainId: number;
|
|
376
|
+
blockNumber: number; // Block number (for POD, this is essentially a timestamp)
|
|
377
|
+
timestamp: number; // Unix timestamp
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
// Status
|
|
355
381
|
isClaimed: boolean;
|
|
356
|
-
|
|
357
|
-
claimedAt?: number;
|
|
358
|
-
claimedBy?: string;
|
|
382
|
+
isClaimable: boolean; // Can be claimed (finalized and not yet claimed)
|
|
359
383
|
}
|
|
360
384
|
```
|
|
361
385
|
|
|
@@ -401,12 +425,12 @@ interface CertifiedLog {
|
|
|
401
425
|
The SDK supports two bridge implementations:
|
|
402
426
|
|
|
403
427
|
1. **BridgeDepositWithdraw** (Certificate-based)
|
|
404
|
-
- Used for claiming on
|
|
428
|
+
- Used for claiming on Source chain from POD deposits
|
|
405
429
|
- Requires certified logs from POD's certificate system
|
|
406
430
|
- Methods: `claimWithCertificate`, `claimNativeWithCertificate`
|
|
407
431
|
|
|
408
432
|
2. **BridgeMintBurn** (Precompile-based)
|
|
409
|
-
- Used for claiming on POD from
|
|
433
|
+
- Used for claiming on POD from Source chain deposits
|
|
410
434
|
- Uses block number verification via precompiles
|
|
411
435
|
- Methods: `claimWithBlockNumber`, `claimNativeWithBlockNumber`
|
|
412
436
|
|
|
@@ -416,11 +440,11 @@ The SDK supports two bridge implementations:
|
|
|
416
440
|
|
|
417
441
|
```typescript
|
|
418
442
|
import { ethers } from 'ethers';
|
|
419
|
-
import {
|
|
443
|
+
import { SourceChainToPodActionClient, PodBridgeTrackerClient } from '@tapforce/pod-bridge-sdk';
|
|
420
444
|
|
|
421
445
|
// Setup
|
|
422
446
|
const trackerConfig = {
|
|
423
|
-
|
|
447
|
+
sourceChain: {
|
|
424
448
|
rpcUrl: 'https://sepolia.infura.io/v3/YOUR_KEY',
|
|
425
449
|
contractAddress: '0xSepoliaBridgeContract'
|
|
426
450
|
},
|
|
@@ -431,13 +455,13 @@ const trackerConfig = {
|
|
|
431
455
|
};
|
|
432
456
|
|
|
433
457
|
const actionConfig = {
|
|
434
|
-
|
|
458
|
+
sourceChain: { contractAddress: '0xSepoliaBridgeContract' },
|
|
435
459
|
pod: { contractAddress: '0xPodBridgeContract' }
|
|
436
460
|
};
|
|
437
461
|
|
|
438
|
-
const actionClient = new
|
|
462
|
+
const actionClient = new SourceChainToPodActionClient(actionConfig);
|
|
439
463
|
const trackerClient = new PodBridgeTrackerClient(trackerConfig);
|
|
440
|
-
const sepoliaProvider = new ethers.JsonRpcProvider(trackerConfig.
|
|
464
|
+
const sepoliaProvider = new ethers.JsonRpcProvider(trackerConfig.sourceChain.rpcUrl);
|
|
441
465
|
const sepoliaSigner = new ethers.Wallet('PRIVATE_KEY', sepoliaProvider);
|
|
442
466
|
|
|
443
467
|
// Step 1: Deposit tokens on Sepolia
|
|
@@ -456,15 +480,15 @@ const deposits = await trackerClient.getDepositsSentBy(await sepoliaSigner.getAd
|
|
|
456
480
|
const latestDeposit = deposits[0];
|
|
457
481
|
|
|
458
482
|
console.log(`Request ID: ${latestDeposit.requestId}`);
|
|
459
|
-
console.log(`Amount: ${ethers.formatEther(latestDeposit.amount)}`);
|
|
483
|
+
console.log(`Amount: ${ethers.formatEther(latestDeposit.deposit.amount)}`);
|
|
460
484
|
|
|
461
485
|
// Step 3: Wait for finality and claim on POD
|
|
462
486
|
const canClaim = await trackerClient.canBeClaimed(latestDeposit);
|
|
463
487
|
if (canClaim) {
|
|
464
488
|
const claimTx = actionClient.claimWithBlockNumber({
|
|
465
489
|
id: latestDeposit.requestId,
|
|
466
|
-
token: latestDeposit.token,
|
|
467
|
-
blockNumber: latestDeposit.blockNumber
|
|
490
|
+
token: latestDeposit.deposit.token,
|
|
491
|
+
blockNumber: latestDeposit.deposit.blockNumber
|
|
468
492
|
});
|
|
469
493
|
|
|
470
494
|
// Submit claim on POD
|
|
@@ -480,11 +504,11 @@ if (canClaim) {
|
|
|
480
504
|
|
|
481
505
|
```typescript
|
|
482
506
|
import { ethers } from 'ethers';
|
|
483
|
-
import {
|
|
507
|
+
import { PodToSourceChainActionClient, PodBridgeTrackerClient } from '@tapforce/pod-bridge-sdk';
|
|
484
508
|
|
|
485
509
|
// Setup
|
|
486
510
|
const trackerConfig = {
|
|
487
|
-
|
|
511
|
+
sourceChain: {
|
|
488
512
|
rpcUrl: 'https://sepolia.infura.io/v3/YOUR_KEY',
|
|
489
513
|
contractAddress: '0xSepoliaBridgeContract'
|
|
490
514
|
},
|
|
@@ -495,11 +519,11 @@ const trackerConfig = {
|
|
|
495
519
|
};
|
|
496
520
|
|
|
497
521
|
const actionConfig = {
|
|
498
|
-
|
|
522
|
+
sourceChain: { contractAddress: '0xSepoliaBridgeContract' },
|
|
499
523
|
pod: { contractAddress: '0xPodBridgeContract' }
|
|
500
524
|
};
|
|
501
525
|
|
|
502
|
-
const actionClient = new
|
|
526
|
+
const actionClient = new PodToSourceChainActionClient(actionConfig);
|
|
503
527
|
const trackerClient = new PodBridgeTrackerClient(trackerConfig);
|
|
504
528
|
const podProvider = new ethers.JsonRpcProvider(trackerConfig.pod.rpcUrl);
|
|
505
529
|
const podSigner = new ethers.Wallet('PRIVATE_KEY', podProvider);
|
|
@@ -524,7 +548,7 @@ const claimTx = actionClient.claimWithCertificate({
|
|
|
524
548
|
certifiedLog
|
|
525
549
|
});
|
|
526
550
|
|
|
527
|
-
const sepoliaProvider = new ethers.JsonRpcProvider(trackerConfig.
|
|
551
|
+
const sepoliaProvider = new ethers.JsonRpcProvider(trackerConfig.sourceChain.rpcUrl);
|
|
528
552
|
const sepoliaSigner = new ethers.Wallet('PRIVATE_KEY', sepoliaProvider);
|
|
529
553
|
const claim = await sepoliaSigner.sendTransaction(claimTx);
|
|
530
554
|
await claim.wait();
|
|
@@ -1,28 +1,39 @@
|
|
|
1
1
|
import { PodBridgeConfig, BridgeRequest, BridgeRequestWithType, CertifiedLog } from "../../libs/types/pod-bridge.types";
|
|
2
|
+
/**
|
|
3
|
+
* PodBridgeTrackerClient - Main orchestrator for bridge tracking
|
|
4
|
+
*
|
|
5
|
+
* This client coordinates between SourceChainTrackerService and PodTrackerService
|
|
6
|
+
* to provide a unified view of bridge activity across both chains.
|
|
7
|
+
*
|
|
8
|
+
* Bridge Architecture:
|
|
9
|
+
* - Source Chain (e.g., Sepolia): BridgeDepositWithdraw contract
|
|
10
|
+
* - Deposits lock tokens
|
|
11
|
+
* - Claims use POD certificates (requires attestations)
|
|
12
|
+
*
|
|
13
|
+
* - POD Chain: BridgeMintBurn contract
|
|
14
|
+
* - Deposits burn tokens (POD has instant finality - single block)
|
|
15
|
+
* - Claims use block number verification via precompiles
|
|
16
|
+
*/
|
|
2
17
|
export declare class PodBridgeTrackerClient {
|
|
3
|
-
private readonly
|
|
4
|
-
private readonly
|
|
5
|
-
private readonly podProvider;
|
|
6
|
-
private readonly bridgedBridge;
|
|
7
|
-
private readonly podBridge;
|
|
8
|
-
private readonly iface;
|
|
18
|
+
private readonly sourceChainTracker;
|
|
19
|
+
private readonly podTracker;
|
|
9
20
|
constructor(config: PodBridgeConfig);
|
|
10
21
|
/**
|
|
11
|
-
* Get all deposits SENT by an address
|
|
22
|
+
* Get all deposits SENT by an address from BOTH chains
|
|
12
23
|
* @param address The address that sent deposits
|
|
13
24
|
* @param fromBlock Starting block number (default: contract deployment block or 0)
|
|
14
25
|
* @returns Array of bridge requests sent by this address
|
|
15
26
|
*/
|
|
16
27
|
getDepositsSentBy(address: string, fromBlock?: number): Promise<BridgeRequest[]>;
|
|
17
28
|
/**
|
|
18
|
-
* Get all deposits RECEIVED by an address
|
|
29
|
+
* Get all deposits RECEIVED by an address from BOTH chains
|
|
19
30
|
* @param address The address that will receive deposits
|
|
20
31
|
* @param fromBlock Starting block number (default: contract deployment block or 0)
|
|
21
32
|
* @returns Array of bridge requests sent to this address
|
|
22
33
|
*/
|
|
23
34
|
getDepositsReceivedBy(address: string, fromBlock?: number): Promise<BridgeRequest[]>;
|
|
24
35
|
/**
|
|
25
|
-
* Get ALL deposits for an address (both sent and received)
|
|
36
|
+
* Get ALL deposits for an address (both sent and received) from BOTH chains
|
|
26
37
|
* @param address The address to check
|
|
27
38
|
* @param fromBlock Starting block number (default: contract deployment block or 0)
|
|
28
39
|
* @returns Array of bridge requests with type indicator
|
|
@@ -33,10 +44,11 @@ export declare class PodBridgeTrackerClient {
|
|
|
33
44
|
* @param deposit The bridge request to check
|
|
34
45
|
* @returns True if the deposit can be claimed
|
|
35
46
|
*/
|
|
36
|
-
canBeClaimed(deposit:
|
|
47
|
+
canBeClaimed(deposit: BridgeRequest): Promise<boolean>;
|
|
37
48
|
/**
|
|
38
49
|
* Batch check claim status for multiple deposits
|
|
39
|
-
*
|
|
50
|
+
* Claims are checked on the opposite chain from where the deposit was made
|
|
51
|
+
* @private
|
|
40
52
|
*/
|
|
41
53
|
private updateClaimStatus;
|
|
42
54
|
/**
|
|
@@ -45,45 +57,11 @@ export declare class PodBridgeTrackerClient {
|
|
|
45
57
|
* @returns Array of boolean values
|
|
46
58
|
*/
|
|
47
59
|
areRequestsProcessed(deposits: BridgeRequest[]): Promise<boolean[]>;
|
|
48
|
-
/**
|
|
49
|
-
* Compute the request hash (replicates Solidity's _hashRequest)
|
|
50
|
-
* @param id Request ID
|
|
51
|
-
* @param token Token address
|
|
52
|
-
* @param amount Amount in wei
|
|
53
|
-
* @param to Recipient address
|
|
54
|
-
* @returns Request hash
|
|
55
|
-
*/
|
|
56
|
-
private computeRequestHash;
|
|
57
60
|
/**
|
|
58
61
|
* Get certified log for a deposit transaction from POD
|
|
59
|
-
* This is required to claim tokens on
|
|
62
|
+
* This is required to claim tokens on Source Chain from POD deposits
|
|
60
63
|
* @param txHash Transaction hash of the deposit on POD
|
|
61
64
|
* @returns Certified log with attestations and merkle proof
|
|
62
65
|
*/
|
|
63
66
|
getDepositCertifiedLog(txHash: string): Promise<CertifiedLog>;
|
|
64
|
-
/**
|
|
65
|
-
* Compute receipt root hash
|
|
66
|
-
* @private
|
|
67
|
-
*/
|
|
68
|
-
private computeReceiptRoot;
|
|
69
|
-
/**
|
|
70
|
-
* Aggregate signatures from attestations
|
|
71
|
-
* @private
|
|
72
|
-
*/
|
|
73
|
-
private aggregateSignatures;
|
|
74
|
-
/**
|
|
75
|
-
* Hash a log entry
|
|
76
|
-
* @private
|
|
77
|
-
*/
|
|
78
|
-
private hashLog;
|
|
79
|
-
/**
|
|
80
|
-
* Hash a leaf for merkle tree
|
|
81
|
-
* @private
|
|
82
|
-
*/
|
|
83
|
-
private hashLeaf;
|
|
84
|
-
/**
|
|
85
|
-
* Generate merkle proof for a log at given index
|
|
86
|
-
* @private
|
|
87
|
-
*/
|
|
88
|
-
private generateMerkleProof;
|
|
89
67
|
}
|