@tapforce/pod-bridge-sdk 1.0.3 → 1.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 +142 -87
- package/dist/clients/action/{client.d.ts → bridged-to-pod-client.d.ts} +4 -31
- package/dist/clients/action/{client.js → bridged-to-pod-client.js} +9 -42
- package/dist/clients/action/pod-to-bridged-client.d.ts +54 -0
- package/dist/clients/action/pod-to-bridged-client.js +81 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +7 -5
- package/dist/libs/types/pod-bridge.types.d.ts +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,7 +34,8 @@ pnpm add @tapforce/pod-bridge-sdk
|
|
|
34
34
|
|
|
35
35
|
```typescript
|
|
36
36
|
import {
|
|
37
|
-
|
|
37
|
+
BridgedToPodActionClient,
|
|
38
|
+
PodToBridgedActionClient,
|
|
38
39
|
PodBridgeTrackerClient,
|
|
39
40
|
PodBridgeConfig
|
|
40
41
|
} from '@tapforce/pod-bridge-sdk';
|
|
@@ -59,86 +60,109 @@ const config: PodBridgeConfig = {
|
|
|
59
60
|
|
|
60
61
|
## Usage
|
|
61
62
|
|
|
62
|
-
### 1. Action
|
|
63
|
+
### 1. Action Clients - Creating Transactions
|
|
63
64
|
|
|
64
|
-
The
|
|
65
|
+
The SDK provides two action clients for different bridge directions:
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
- **`BridgedToPodActionClient`**: For Bridged → POD transfers (e.g., Sepolia → POD)
|
|
68
|
+
- **`PodToBridgedActionClient`**: For POD → Bridged transfers (e.g., POD → Sepolia)
|
|
69
|
+
|
|
70
|
+
#### Configuration for Action Clients
|
|
67
71
|
|
|
68
72
|
```typescript
|
|
69
|
-
const
|
|
73
|
+
const actionConfig = {
|
|
74
|
+
bridged: {
|
|
75
|
+
contractAddress: '0x...' // Bridged chain bridge contract (e.g., Sepolia)
|
|
76
|
+
},
|
|
77
|
+
pod: {
|
|
78
|
+
contractAddress: '0x...' // POD chain bridge contract
|
|
79
|
+
}
|
|
80
|
+
};
|
|
70
81
|
|
|
71
|
-
|
|
72
|
-
const
|
|
82
|
+
const bridgedToPodClient = new BridgedToPodActionClient(actionConfig);
|
|
83
|
+
const podToBridgedClient = new PodToBridgedActionClient(actionConfig);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
#### Deposit from Bridged Chain (e.g., Sepolia → POD)
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
// Create unsigned transaction for ERC20 deposit on Bridged chain
|
|
90
|
+
const unsignedTx = bridgedToPodClient.depositToken({
|
|
73
91
|
token: '0x...', // ERC20 token address
|
|
74
92
|
amount: '1000000000000000000', // Amount in wei (1 token with 18 decimals)
|
|
75
|
-
|
|
76
|
-
contractAddress: config.source.contractAddress,
|
|
93
|
+
destinationWalletAddress: '0x...', // Recipient address on POD
|
|
77
94
|
from: '0x...' // Optional: sender address
|
|
78
95
|
});
|
|
79
96
|
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
#### Deposit Native Tokens (ETH)
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
// Create unsigned transaction for native token deposit
|
|
88
|
-
const unsignedTx = actionClient.depositNative({
|
|
97
|
+
// Deposit native tokens
|
|
98
|
+
const unsignedNativeTx = bridgedToPodClient.depositNative({
|
|
89
99
|
amount: '1000000000000000000', // Amount in wei (1 ETH)
|
|
90
|
-
|
|
91
|
-
contractAddress: config.source.contractAddress,
|
|
100
|
+
destinationWalletAddress: '0x...', // Recipient address on POD
|
|
92
101
|
from: '0x...' // Optional: sender address
|
|
93
102
|
});
|
|
94
103
|
|
|
95
|
-
// Sign and send transaction
|
|
104
|
+
// Sign and send transaction using your wallet/provider
|
|
96
105
|
// const tx = await signer.sendTransaction(unsignedTx);
|
|
97
106
|
```
|
|
98
107
|
|
|
99
|
-
#### Claim
|
|
108
|
+
#### Claim on POD from Bridged Chain Deposits
|
|
100
109
|
|
|
101
|
-
For claiming on
|
|
110
|
+
For claiming on POD from Bridged chain deposits, use block number-based claims:
|
|
102
111
|
|
|
103
112
|
```typescript
|
|
104
|
-
//
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
//
|
|
109
|
-
const unsignedTx = actionClient.claimWithCertificate({
|
|
110
|
-
certifiedLog,
|
|
111
|
-
contractAddress: config.bridged.contractAddress, // Sepolia bridge contract
|
|
113
|
+
// Create unsigned claim transaction for ERC20 on POD
|
|
114
|
+
const unsignedTx = bridgedToPodClient.claimWithBlockNumber({
|
|
115
|
+
id: '123', // Request ID from deposit event
|
|
116
|
+
token: '0x...', // Token address on source chain
|
|
117
|
+
blockNumber: 12345678, // Block number of deposit on source chain
|
|
112
118
|
from: '0x...' // Optional: claimer address
|
|
113
119
|
});
|
|
114
120
|
|
|
115
121
|
// For native tokens
|
|
116
|
-
const unsignedNativeTx =
|
|
117
|
-
|
|
118
|
-
|
|
122
|
+
const unsignedNativeTx = bridgedToPodClient.claimNativeWithBlockNumber({
|
|
123
|
+
id: '123',
|
|
124
|
+
blockNumber: 12345678,
|
|
119
125
|
from: '0x...'
|
|
120
126
|
});
|
|
121
127
|
```
|
|
122
128
|
|
|
123
|
-
####
|
|
129
|
+
#### Deposit from POD (POD → Bridged Chain)
|
|
124
130
|
|
|
125
|
-
|
|
131
|
+
```typescript
|
|
132
|
+
// Create unsigned transaction for ERC20 deposit on POD
|
|
133
|
+
const unsignedTx = podToBridgedClient.depositToken({
|
|
134
|
+
token: '0x...', // ERC20 token address
|
|
135
|
+
amount: '1000000000000000000', // Amount in wei
|
|
136
|
+
destinationWalletAddress: '0x...', // Recipient address on Bridged chain
|
|
137
|
+
from: '0x...' // Optional: sender address
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// Deposit native tokens
|
|
141
|
+
const unsignedNativeTx = podToBridgedClient.depositNative({
|
|
142
|
+
amount: '1000000000000000000',
|
|
143
|
+
destinationWalletAddress: '0x...',
|
|
144
|
+
from: '0x...'
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
#### Claim on Bridged Chain from POD Deposits
|
|
149
|
+
|
|
150
|
+
For claiming on Bridged chain from POD deposits, use certificate-based claims. First, get the certified log from the POD deposit transaction:
|
|
126
151
|
|
|
127
152
|
```typescript
|
|
128
|
-
//
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
153
|
+
// Get certified log from POD deposit transaction
|
|
154
|
+
const depositTxHash = '0x...'; // Transaction hash of deposit on POD
|
|
155
|
+
const certifiedLog = await trackerClient.getDepositCertifiedLog(depositTxHash);
|
|
156
|
+
|
|
157
|
+
// Create unsigned claim transaction for ERC20 on Bridged chain
|
|
158
|
+
const unsignedTx = podToBridgedClient.claimWithCertificate({
|
|
159
|
+
certifiedLog,
|
|
134
160
|
from: '0x...' // Optional: claimer address
|
|
135
161
|
});
|
|
136
162
|
|
|
137
163
|
// For native tokens
|
|
138
|
-
const unsignedNativeTx =
|
|
139
|
-
|
|
140
|
-
blockNumber: 12345678,
|
|
141
|
-
contractAddress: config.destination.contractAddress,
|
|
164
|
+
const unsignedNativeTx = podToBridgedClient.claimNativeWithCertificate({
|
|
165
|
+
certifiedLog,
|
|
142
166
|
from: '0x...'
|
|
143
167
|
});
|
|
144
168
|
```
|
|
@@ -224,44 +248,69 @@ processedStatuses.forEach((isProcessed, index) => {
|
|
|
224
248
|
|
|
225
249
|
## API Reference
|
|
226
250
|
|
|
227
|
-
###
|
|
251
|
+
### BridgedToPodActionClient
|
|
252
|
+
|
|
253
|
+
Handles transactions for Bridged → POD direction.
|
|
254
|
+
|
|
255
|
+
#### Constructor
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
new BridgedToPodActionClient(config: PodBridgeActionsClientConfig)
|
|
259
|
+
```
|
|
228
260
|
|
|
229
261
|
#### Methods
|
|
230
262
|
|
|
231
|
-
- **`depositToken(args)`**: Create unsigned transaction for ERC20 deposit
|
|
263
|
+
- **`depositToken(args)`**: Create unsigned transaction for ERC20 deposit on Bridged chain
|
|
232
264
|
- `token`: Token address
|
|
233
265
|
- `amount`: Amount in wei (string | bigint)
|
|
234
|
-
- `
|
|
235
|
-
- `contractAddress`: Bridge contract address
|
|
266
|
+
- `destinationWalletAddress`: Recipient address on POD
|
|
236
267
|
- `from?`: Optional sender address
|
|
237
268
|
|
|
238
|
-
- **`depositNative(args)`**: Create unsigned transaction for native token deposit
|
|
269
|
+
- **`depositNative(args)`**: Create unsigned transaction for native token deposit on Bridged chain
|
|
239
270
|
- `amount`: Amount in wei (string | bigint)
|
|
240
|
-
- `
|
|
241
|
-
- `contractAddress`: Bridge contract address
|
|
271
|
+
- `destinationWalletAddress`: Recipient address on POD
|
|
242
272
|
- `from?`: Optional sender address
|
|
243
273
|
|
|
244
|
-
- **`
|
|
245
|
-
- `
|
|
246
|
-
- `
|
|
274
|
+
- **`claimWithBlockNumber(args)`**: Create unsigned transaction for claiming on POD with block number
|
|
275
|
+
- `id`: Request ID
|
|
276
|
+
- `token`: Token address
|
|
277
|
+
- `blockNumber`: Block number of deposit on Bridged chain
|
|
247
278
|
- `from?`: Optional claimer address
|
|
248
279
|
|
|
249
|
-
- **`
|
|
250
|
-
- `
|
|
251
|
-
- `
|
|
280
|
+
- **`claimNativeWithBlockNumber(args)`**: Create unsigned transaction for claiming native tokens on POD with block number
|
|
281
|
+
- `id`: Request ID
|
|
282
|
+
- `blockNumber`: Block number of deposit on Bridged chain
|
|
252
283
|
- `from?`: Optional claimer address
|
|
253
284
|
|
|
254
|
-
|
|
255
|
-
|
|
285
|
+
### PodToBridgedActionClient
|
|
286
|
+
|
|
287
|
+
Handles transactions for POD → Bridged direction.
|
|
288
|
+
|
|
289
|
+
#### Constructor
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
new PodToBridgedActionClient(config: PodBridgeActionsClientConfig)
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
#### Methods
|
|
296
|
+
|
|
297
|
+
- **`depositToken(args)`**: Create unsigned transaction for ERC20 deposit on POD
|
|
256
298
|
- `token`: Token address
|
|
257
|
-
- `
|
|
258
|
-
- `
|
|
299
|
+
- `amount`: Amount in wei (string | bigint)
|
|
300
|
+
- `destinationWalletAddress`: Recipient address on Bridged chain
|
|
301
|
+
- `from?`: Optional sender address
|
|
302
|
+
|
|
303
|
+
- **`depositNative(args)`**: Create unsigned transaction for native token deposit on POD
|
|
304
|
+
- `amount`: Amount in wei (string | bigint)
|
|
305
|
+
- `destinationWalletAddress`: Recipient address on Bridged chain
|
|
306
|
+
- `from?`: Optional sender address
|
|
307
|
+
|
|
308
|
+
- **`claimWithCertificate(args)`**: Create unsigned transaction for claiming on Bridged chain with certificate
|
|
309
|
+
- `certifiedLog`: Certified log from POD certificate system
|
|
259
310
|
- `from?`: Optional claimer address
|
|
260
311
|
|
|
261
|
-
- **`
|
|
262
|
-
- `
|
|
263
|
-
- `blockNumber`: Block number of deposit
|
|
264
|
-
- `contractAddress`: Bridge contract address
|
|
312
|
+
- **`claimNativeWithCertificate(args)`**: Create unsigned transaction for claiming native tokens on Bridged chain with certificate
|
|
313
|
+
- `certifiedLog`: Certified log from POD certificate system
|
|
265
314
|
- `from?`: Optional claimer address
|
|
266
315
|
|
|
267
316
|
### PodBridgeTrackerClient
|
|
@@ -365,10 +414,10 @@ The SDK supports two bridge implementations:
|
|
|
365
414
|
|
|
366
415
|
```typescript
|
|
367
416
|
import { ethers } from 'ethers';
|
|
368
|
-
import {
|
|
417
|
+
import { BridgedToPodActionClient, PodBridgeTrackerClient } from '@tapforce/pod-bridge-sdk';
|
|
369
418
|
|
|
370
419
|
// Setup
|
|
371
|
-
const
|
|
420
|
+
const trackerConfig = {
|
|
372
421
|
bridged: {
|
|
373
422
|
rpcUrl: 'https://sepolia.infura.io/v3/YOUR_KEY',
|
|
374
423
|
contractAddress: '0xSepoliaBridgeContract'
|
|
@@ -379,17 +428,21 @@ const config = {
|
|
|
379
428
|
}
|
|
380
429
|
};
|
|
381
430
|
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
431
|
+
const actionConfig = {
|
|
432
|
+
bridged: { contractAddress: '0xSepoliaBridgeContract' },
|
|
433
|
+
pod: { contractAddress: '0xPodBridgeContract' }
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
const actionClient = new BridgedToPodActionClient(actionConfig);
|
|
437
|
+
const trackerClient = new PodBridgeTrackerClient(trackerConfig);
|
|
438
|
+
const sepoliaProvider = new ethers.JsonRpcProvider(trackerConfig.bridged.rpcUrl);
|
|
385
439
|
const sepoliaSigner = new ethers.Wallet('PRIVATE_KEY', sepoliaProvider);
|
|
386
440
|
|
|
387
441
|
// Step 1: Deposit tokens on Sepolia
|
|
388
442
|
const depositTx = actionClient.depositToken({
|
|
389
443
|
token: '0xTokenAddress',
|
|
390
444
|
amount: ethers.parseEther('10').toString(),
|
|
391
|
-
destinationWalletAddress: await sepoliaSigner.getAddress()
|
|
392
|
-
contractAddress: config.bridged.contractAddress
|
|
445
|
+
destinationWalletAddress: await sepoliaSigner.getAddress()
|
|
393
446
|
});
|
|
394
447
|
|
|
395
448
|
const tx = await sepoliaSigner.sendTransaction(depositTx);
|
|
@@ -409,12 +462,11 @@ if (canClaim) {
|
|
|
409
462
|
const claimTx = actionClient.claimWithBlockNumber({
|
|
410
463
|
id: latestDeposit.requestId,
|
|
411
464
|
token: latestDeposit.token,
|
|
412
|
-
blockNumber: latestDeposit.blockNumber
|
|
413
|
-
contractAddress: config.pod.contractAddress
|
|
465
|
+
blockNumber: latestDeposit.blockNumber
|
|
414
466
|
});
|
|
415
467
|
|
|
416
468
|
// Submit claim on POD
|
|
417
|
-
const podProvider = new ethers.JsonRpcProvider(
|
|
469
|
+
const podProvider = new ethers.JsonRpcProvider(trackerConfig.pod.rpcUrl);
|
|
418
470
|
const podSigner = new ethers.Wallet('PRIVATE_KEY', podProvider);
|
|
419
471
|
const claim = await podSigner.sendTransaction(claimTx);
|
|
420
472
|
await claim.wait();
|
|
@@ -426,10 +478,10 @@ if (canClaim) {
|
|
|
426
478
|
|
|
427
479
|
```typescript
|
|
428
480
|
import { ethers } from 'ethers';
|
|
429
|
-
import {
|
|
481
|
+
import { PodToBridgedActionClient, PodBridgeTrackerClient } from '@tapforce/pod-bridge-sdk';
|
|
430
482
|
|
|
431
483
|
// Setup
|
|
432
|
-
const
|
|
484
|
+
const trackerConfig = {
|
|
433
485
|
bridged: {
|
|
434
486
|
rpcUrl: 'https://sepolia.infura.io/v3/YOUR_KEY',
|
|
435
487
|
contractAddress: '0xSepoliaBridgeContract'
|
|
@@ -440,17 +492,21 @@ const config = {
|
|
|
440
492
|
}
|
|
441
493
|
};
|
|
442
494
|
|
|
443
|
-
const
|
|
444
|
-
|
|
445
|
-
|
|
495
|
+
const actionConfig = {
|
|
496
|
+
bridged: { contractAddress: '0xSepoliaBridgeContract' },
|
|
497
|
+
pod: { contractAddress: '0xPodBridgeContract' }
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
const actionClient = new PodToBridgedActionClient(actionConfig);
|
|
501
|
+
const trackerClient = new PodBridgeTrackerClient(trackerConfig);
|
|
502
|
+
const podProvider = new ethers.JsonRpcProvider(trackerConfig.pod.rpcUrl);
|
|
446
503
|
const podSigner = new ethers.Wallet('PRIVATE_KEY', podProvider);
|
|
447
504
|
|
|
448
505
|
// Step 1: Deposit tokens on POD
|
|
449
506
|
const depositTx = actionClient.depositToken({
|
|
450
507
|
token: '0xTokenAddress',
|
|
451
508
|
amount: ethers.parseEther('10').toString(),
|
|
452
|
-
destinationWalletAddress: await podSigner.getAddress()
|
|
453
|
-
contractAddress: config.pod.contractAddress
|
|
509
|
+
destinationWalletAddress: await podSigner.getAddress()
|
|
454
510
|
});
|
|
455
511
|
|
|
456
512
|
const tx = await podSigner.sendTransaction(depositTx);
|
|
@@ -463,11 +519,10 @@ console.log('Got certified log with attestations');
|
|
|
463
519
|
|
|
464
520
|
// Step 3: Claim on Sepolia using certified log
|
|
465
521
|
const claimTx = actionClient.claimWithCertificate({
|
|
466
|
-
certifiedLog
|
|
467
|
-
contractAddress: config.bridged.contractAddress
|
|
522
|
+
certifiedLog
|
|
468
523
|
});
|
|
469
524
|
|
|
470
|
-
const sepoliaProvider = new ethers.JsonRpcProvider(
|
|
525
|
+
const sepoliaProvider = new ethers.JsonRpcProvider(trackerConfig.bridged.rpcUrl);
|
|
471
526
|
const sepoliaSigner = new ethers.Wallet('PRIVATE_KEY', sepoliaProvider);
|
|
472
527
|
const claim = await sepoliaSigner.sendTransaction(claimTx);
|
|
473
528
|
await claim.wait();
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { UnsignedTransaction,
|
|
2
|
-
export declare class
|
|
1
|
+
import { UnsignedTransaction, PodBridgeActionsClientConfig } from "../../libs/types/pod-bridge.types";
|
|
2
|
+
export declare class BridgedToPodActionClient {
|
|
3
|
+
private readonly config;
|
|
3
4
|
private readonly iface;
|
|
4
|
-
constructor();
|
|
5
|
+
constructor(config: PodBridgeActionsClientConfig);
|
|
5
6
|
/**
|
|
6
7
|
* Create unsigned transaction for depositing ERC20 tokens
|
|
7
8
|
* @param args.token Token address to deposit
|
|
@@ -15,7 +16,6 @@ export declare class PodBridgeActionClient {
|
|
|
15
16
|
token: string;
|
|
16
17
|
amount: string | bigint;
|
|
17
18
|
destinationWalletAddress: string;
|
|
18
|
-
contractAddress: string;
|
|
19
19
|
from?: string;
|
|
20
20
|
}): UnsignedTransaction;
|
|
21
21
|
/**
|
|
@@ -29,33 +29,6 @@ export declare class PodBridgeActionClient {
|
|
|
29
29
|
depositNative(args: {
|
|
30
30
|
amount: string | bigint;
|
|
31
31
|
destinationWalletAddress: string;
|
|
32
|
-
contractAddress: string;
|
|
33
|
-
from?: string;
|
|
34
|
-
}): UnsignedTransaction;
|
|
35
|
-
/**
|
|
36
|
-
* Create unsigned transaction for claiming tokens (BridgeDepositWithdraw - with certificates)
|
|
37
|
-
* Used for claiming on Sepolia from POD deposits
|
|
38
|
-
* @param args.certifiedLog Certified log from POD certificate system
|
|
39
|
-
* @param args.contractAddress Bridge contract address (destination chain)
|
|
40
|
-
* @param args.from Optional sender address
|
|
41
|
-
* @returns Unsigned transaction template with encoded claim call
|
|
42
|
-
*/
|
|
43
|
-
claimWithCertificate(args: {
|
|
44
|
-
certifiedLog: CertifiedLog;
|
|
45
|
-
contractAddress: string;
|
|
46
|
-
from?: string;
|
|
47
|
-
}): UnsignedTransaction;
|
|
48
|
-
/**
|
|
49
|
-
* Create unsigned transaction for claiming native tokens (BridgeDepositWithdraw - with certificates)
|
|
50
|
-
* Used for claiming native tokens on Sepolia from POD deposits
|
|
51
|
-
* @param args.certifiedLog Certified log from POD certificate system
|
|
52
|
-
* @param args.contractAddress Bridge contract address (destination chain)
|
|
53
|
-
* @param args.from Optional sender address
|
|
54
|
-
* @returns Unsigned transaction template with encoded claimNative call
|
|
55
|
-
*/
|
|
56
|
-
claimNativeWithCertificate(args: {
|
|
57
|
-
certifiedLog: CertifiedLog;
|
|
58
|
-
contractAddress: string;
|
|
59
32
|
from?: string;
|
|
60
33
|
}): UnsignedTransaction;
|
|
61
34
|
/**
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.BridgedToPodActionClient = void 0;
|
|
4
4
|
const ethers_1 = require("ethers");
|
|
5
5
|
const bridge_abi_1 = require("../../libs/abi/bridge.abi");
|
|
6
|
-
class
|
|
7
|
-
constructor() {
|
|
6
|
+
class BridgedToPodActionClient {
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.config = config;
|
|
8
9
|
this.iface = new ethers_1.Interface(bridge_abi_1.POD_BRIDGE_ABI);
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
@@ -23,7 +24,7 @@ class PodBridgeActionClient {
|
|
|
23
24
|
args.destinationWalletAddress
|
|
24
25
|
]);
|
|
25
26
|
return {
|
|
26
|
-
to:
|
|
27
|
+
to: this.config.bridged.contractAddress,
|
|
27
28
|
data,
|
|
28
29
|
value: '0',
|
|
29
30
|
from: args === null || args === void 0 ? void 0 : args.from
|
|
@@ -40,46 +41,12 @@ class PodBridgeActionClient {
|
|
|
40
41
|
depositNative(args) {
|
|
41
42
|
const data = this.iface.encodeFunctionData('depositNative', [args.destinationWalletAddress]);
|
|
42
43
|
return {
|
|
43
|
-
to:
|
|
44
|
+
to: this.config.bridged.contractAddress,
|
|
44
45
|
data,
|
|
45
46
|
value: args.amount.toString(),
|
|
46
47
|
from: args === null || args === void 0 ? void 0 : args.from
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Create unsigned transaction for claiming tokens (BridgeDepositWithdraw - with certificates)
|
|
51
|
-
* Used for claiming on Sepolia from POD deposits
|
|
52
|
-
* @param args.certifiedLog Certified log from POD certificate system
|
|
53
|
-
* @param args.contractAddress Bridge contract address (destination chain)
|
|
54
|
-
* @param args.from Optional sender address
|
|
55
|
-
* @returns Unsigned transaction template with encoded claim call
|
|
56
|
-
*/
|
|
57
|
-
claimWithCertificate(args) {
|
|
58
|
-
const data = this.iface.encodeFunctionData('claim', [args.certifiedLog]);
|
|
59
|
-
return {
|
|
60
|
-
to: args.contractAddress,
|
|
61
|
-
data,
|
|
62
|
-
value: '0',
|
|
63
|
-
from: args === null || args === void 0 ? void 0 : args.from
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Create unsigned transaction for claiming native tokens (BridgeDepositWithdraw - with certificates)
|
|
68
|
-
* Used for claiming native tokens on Sepolia from POD deposits
|
|
69
|
-
* @param args.certifiedLog Certified log from POD certificate system
|
|
70
|
-
* @param args.contractAddress Bridge contract address (destination chain)
|
|
71
|
-
* @param args.from Optional sender address
|
|
72
|
-
* @returns Unsigned transaction template with encoded claimNative call
|
|
73
|
-
*/
|
|
74
|
-
claimNativeWithCertificate(args) {
|
|
75
|
-
const data = this.iface.encodeFunctionData('claimNative', [args.certifiedLog]);
|
|
76
|
-
return {
|
|
77
|
-
to: args.contractAddress,
|
|
78
|
-
data,
|
|
79
|
-
value: '0',
|
|
80
|
-
from: args === null || args === void 0 ? void 0 : args.from
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
50
|
/**
|
|
84
51
|
* Create unsigned transaction for claiming tokens (BridgeMintBurn - using precompiles)
|
|
85
52
|
* Used for claiming on POD from Sepolia deposits
|
|
@@ -97,7 +64,7 @@ class PodBridgeActionClient {
|
|
|
97
64
|
args.blockNumber
|
|
98
65
|
]);
|
|
99
66
|
return {
|
|
100
|
-
to:
|
|
67
|
+
to: this.config.pod.contractAddress,
|
|
101
68
|
data,
|
|
102
69
|
value: '0',
|
|
103
70
|
from: args === null || args === void 0 ? void 0 : args.from
|
|
@@ -115,11 +82,11 @@ class PodBridgeActionClient {
|
|
|
115
82
|
claimNativeWithBlockNumber(args) {
|
|
116
83
|
const data = this.iface.encodeFunctionData('claimNative(uint256,uint256)', [args.id, args.blockNumber]);
|
|
117
84
|
return {
|
|
118
|
-
to:
|
|
85
|
+
to: this.config.pod.contractAddress,
|
|
119
86
|
data,
|
|
120
87
|
value: '0',
|
|
121
88
|
from: args === null || args === void 0 ? void 0 : args.from
|
|
122
89
|
};
|
|
123
90
|
}
|
|
124
91
|
}
|
|
125
|
-
exports.
|
|
92
|
+
exports.BridgedToPodActionClient = BridgedToPodActionClient;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { UnsignedTransaction, CertifiedLog, PodBridgeActionsClientConfig } from "../../libs/types/pod-bridge.types";
|
|
2
|
+
export declare class PodToBridgedActionClient {
|
|
3
|
+
private readonly config;
|
|
4
|
+
private readonly iface;
|
|
5
|
+
constructor(config: PodBridgeActionsClientConfig);
|
|
6
|
+
/**
|
|
7
|
+
* Create unsigned transaction for depositing ERC20 tokens from POD to Bridged chain
|
|
8
|
+
* @param args.token Token address to deposit
|
|
9
|
+
* @param args.amount Amount to deposit (in wei)
|
|
10
|
+
* @param args.destinationWalletAddress Recipient address on destination chain
|
|
11
|
+
* @param args.from Optional sender address
|
|
12
|
+
* @returns Unsigned transaction template with encoded deposit call
|
|
13
|
+
*/
|
|
14
|
+
depositToken(args: {
|
|
15
|
+
token: string;
|
|
16
|
+
amount: string | bigint;
|
|
17
|
+
destinationWalletAddress: string;
|
|
18
|
+
from?: string;
|
|
19
|
+
}): UnsignedTransaction;
|
|
20
|
+
/**
|
|
21
|
+
* Create unsigned transaction for depositing native tokens from POD to Bridged chain
|
|
22
|
+
* @param args.amount Amount to deposit (in wei) - also set as transaction value
|
|
23
|
+
* @param args.destinationWalletAddress Recipient address on destination chain
|
|
24
|
+
* @param args.from Optional sender address
|
|
25
|
+
* @returns Unsigned transaction template with encoded depositNative call
|
|
26
|
+
*/
|
|
27
|
+
depositNative(args: {
|
|
28
|
+
amount: string | bigint;
|
|
29
|
+
destinationWalletAddress: string;
|
|
30
|
+
from?: string;
|
|
31
|
+
}): UnsignedTransaction;
|
|
32
|
+
/**
|
|
33
|
+
* Create unsigned transaction for claiming tokens on Bridged chain (BridgeDepositWithdraw - with certificates)
|
|
34
|
+
* Used for claiming on Bridged chain from POD deposits
|
|
35
|
+
* @param args.certifiedLog Certified log from POD certificate system
|
|
36
|
+
* @param args.from Optional sender address
|
|
37
|
+
* @returns Unsigned transaction template with encoded claim call
|
|
38
|
+
*/
|
|
39
|
+
claimWithCertificate(args: {
|
|
40
|
+
certifiedLog: CertifiedLog;
|
|
41
|
+
from?: string;
|
|
42
|
+
}): UnsignedTransaction;
|
|
43
|
+
/**
|
|
44
|
+
* Create unsigned transaction for claiming native tokens on Bridged chain (BridgeDepositWithdraw - with certificates)
|
|
45
|
+
* Used for claiming native tokens on Bridged chain from POD deposits
|
|
46
|
+
* @param args.certifiedLog Certified log from POD certificate system
|
|
47
|
+
* @param args.from Optional sender address
|
|
48
|
+
* @returns Unsigned transaction template with encoded claimNative call
|
|
49
|
+
*/
|
|
50
|
+
claimNativeWithCertificate(args: {
|
|
51
|
+
certifiedLog: CertifiedLog;
|
|
52
|
+
from?: string;
|
|
53
|
+
}): UnsignedTransaction;
|
|
54
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PodToBridgedActionClient = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const bridge_abi_1 = require("../../libs/abi/bridge.abi");
|
|
6
|
+
class PodToBridgedActionClient {
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.config = config;
|
|
9
|
+
this.iface = new ethers_1.Interface(bridge_abi_1.POD_BRIDGE_ABI);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Create unsigned transaction for depositing ERC20 tokens from POD to Bridged chain
|
|
13
|
+
* @param args.token Token address to deposit
|
|
14
|
+
* @param args.amount Amount to deposit (in wei)
|
|
15
|
+
* @param args.destinationWalletAddress Recipient address on destination chain
|
|
16
|
+
* @param args.from Optional sender address
|
|
17
|
+
* @returns Unsigned transaction template with encoded deposit call
|
|
18
|
+
*/
|
|
19
|
+
depositToken(args) {
|
|
20
|
+
const data = this.iface.encodeFunctionData('deposit', [
|
|
21
|
+
args.token,
|
|
22
|
+
args.amount,
|
|
23
|
+
args.destinationWalletAddress
|
|
24
|
+
]);
|
|
25
|
+
return {
|
|
26
|
+
to: this.config.pod.contractAddress,
|
|
27
|
+
data,
|
|
28
|
+
value: '0',
|
|
29
|
+
from: args === null || args === void 0 ? void 0 : args.from
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create unsigned transaction for depositing native tokens from POD to Bridged chain
|
|
34
|
+
* @param args.amount Amount to deposit (in wei) - also set as transaction value
|
|
35
|
+
* @param args.destinationWalletAddress Recipient address on destination chain
|
|
36
|
+
* @param args.from Optional sender address
|
|
37
|
+
* @returns Unsigned transaction template with encoded depositNative call
|
|
38
|
+
*/
|
|
39
|
+
depositNative(args) {
|
|
40
|
+
const data = this.iface.encodeFunctionData('depositNative', [args.destinationWalletAddress]);
|
|
41
|
+
return {
|
|
42
|
+
to: this.config.pod.contractAddress,
|
|
43
|
+
data,
|
|
44
|
+
value: args.amount.toString(),
|
|
45
|
+
from: args === null || args === void 0 ? void 0 : args.from
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create unsigned transaction for claiming tokens on Bridged chain (BridgeDepositWithdraw - with certificates)
|
|
50
|
+
* Used for claiming on Bridged chain from POD deposits
|
|
51
|
+
* @param args.certifiedLog Certified log from POD certificate system
|
|
52
|
+
* @param args.from Optional sender address
|
|
53
|
+
* @returns Unsigned transaction template with encoded claim call
|
|
54
|
+
*/
|
|
55
|
+
claimWithCertificate(args) {
|
|
56
|
+
const data = this.iface.encodeFunctionData('claim', [args.certifiedLog]);
|
|
57
|
+
return {
|
|
58
|
+
to: this.config.bridged.contractAddress,
|
|
59
|
+
data,
|
|
60
|
+
value: '0',
|
|
61
|
+
from: args === null || args === void 0 ? void 0 : args.from
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Create unsigned transaction for claiming native tokens on Bridged chain (BridgeDepositWithdraw - with certificates)
|
|
66
|
+
* Used for claiming native tokens on Bridged chain from POD deposits
|
|
67
|
+
* @param args.certifiedLog Certified log from POD certificate system
|
|
68
|
+
* @param args.from Optional sender address
|
|
69
|
+
* @returns Unsigned transaction template with encoded claimNative call
|
|
70
|
+
*/
|
|
71
|
+
claimNativeWithCertificate(args) {
|
|
72
|
+
const data = this.iface.encodeFunctionData('claimNative', [args.certifiedLog]);
|
|
73
|
+
return {
|
|
74
|
+
to: this.config.bridged.contractAddress,
|
|
75
|
+
data,
|
|
76
|
+
value: '0',
|
|
77
|
+
from: args === null || args === void 0 ? void 0 : args.from
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.PodToBridgedActionClient = PodToBridgedActionClient;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { PodToBridgedActionClient } from './clients/action/pod-to-bridged-client';
|
|
2
|
+
export { BridgedToPodActionClient } from './clients/action/bridged-to-pod-client';
|
|
2
3
|
export { PodBridgeTrackerClient } from './clients/tracker/client';
|
|
3
4
|
export { POD_BRIDGE_ABI } from './libs/abi/bridge.abi';
|
|
4
5
|
export { PodBridgeConfig, BridgeRequest, BridgeRequestWithType, DepositType, UnsignedTransaction, CertifiedLog, PodAttestation, PodMetadata, PodTransactionReceipt, } from './libs/types/pod-bridge.types';
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DepositType = exports.POD_BRIDGE_ABI = exports.PodBridgeTrackerClient = exports.
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
var
|
|
7
|
-
Object.defineProperty(exports, "
|
|
3
|
+
exports.DepositType = exports.POD_BRIDGE_ABI = exports.PodBridgeTrackerClient = exports.BridgedToPodActionClient = exports.PodToBridgedActionClient = void 0;
|
|
4
|
+
var pod_to_bridged_client_1 = require("./clients/action/pod-to-bridged-client");
|
|
5
|
+
Object.defineProperty(exports, "PodToBridgedActionClient", { enumerable: true, get: function () { return pod_to_bridged_client_1.PodToBridgedActionClient; } });
|
|
6
|
+
var bridged_to_pod_client_1 = require("./clients/action/bridged-to-pod-client");
|
|
7
|
+
Object.defineProperty(exports, "BridgedToPodActionClient", { enumerable: true, get: function () { return bridged_to_pod_client_1.BridgedToPodActionClient; } });
|
|
8
|
+
var client_1 = require("./clients/tracker/client");
|
|
9
|
+
Object.defineProperty(exports, "PodBridgeTrackerClient", { enumerable: true, get: function () { return client_1.PodBridgeTrackerClient; } });
|
|
8
10
|
var bridge_abi_1 = require("./libs/abi/bridge.abi");
|
|
9
11
|
Object.defineProperty(exports, "POD_BRIDGE_ABI", { enumerable: true, get: function () { return bridge_abi_1.POD_BRIDGE_ABI; } });
|
|
10
12
|
var pod_bridge_types_1 = require("./libs/types/pod-bridge.types");
|
|
@@ -11,6 +11,14 @@ export interface PodBridgeConfig {
|
|
|
11
11
|
bridged: PodBridgeChainConfig;
|
|
12
12
|
pod: PodBridgeChainConfig;
|
|
13
13
|
}
|
|
14
|
+
export interface PodBridgeActionsClientConfig {
|
|
15
|
+
bridged: {
|
|
16
|
+
contractAddress: string;
|
|
17
|
+
};
|
|
18
|
+
pod: {
|
|
19
|
+
contractAddress: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
14
22
|
export interface BridgeRequest {
|
|
15
23
|
requestId: string;
|
|
16
24
|
blockNumber: number;
|