@tapforce/pod-bridge-sdk 1.1.13 → 1.1.15

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 CHANGED
@@ -9,6 +9,7 @@ TypeScript SDK for interacting with Bridges between POD and other chains - enabl
9
9
  - ✅ **Claim Status Tracking**: Monitor claim status and finality of bridge requests
10
10
  - 📝 **Transaction Building**: Generate unsigned transactions ready for signing
11
11
  - 🔐 **Type-Safe**: Full TypeScript support with comprehensive type definitions
12
+ - 🔗 **Dual Architecture Support**: Handles both certificate-based (Source Chain) and precompile-based (POD) claim verification
12
13
 
13
14
  ## Installation
14
15
 
@@ -37,7 +38,9 @@ import {
37
38
  SourceChainToPodActionClient,
38
39
  PodToSourceChainActionClient,
39
40
  PodBridgeTrackerClient,
40
- PodBridgeConfig
41
+ PodBridgeConfig,
42
+ POD_BRIDGE_ABI,
43
+ SOURCE_CHAIN_BRIDGE_ABI
41
44
  } from '@tapforce/pod-bridge-sdk';
42
45
  ```
43
46
 
@@ -149,12 +152,25 @@ const unsignedNativeTx = podToSourceChainClient.depositNative({
149
152
 
150
153
  #### Claim on Source Chain from POD Deposits
151
154
 
152
- For claiming on Source chain from POD deposits, use certificate-based claims. First, get the certified log from the POD deposit transaction:
155
+ For claiming on Source chain from POD deposits, use certificate-based claims. You'll need to get the certified log from an external indexer service:
153
156
 
154
157
  ```typescript
158
+ import { PodIndexerHttpClient } from '@tapforce/pod-indexer-sdk';
159
+
160
+ // Initialize the POD indexer client
161
+ const indexerClient = new PodIndexerHttpClient({
162
+ apiUrl: 'YOUR_INDEXER_API_URL',
163
+ apiKey: 'YOUR_INDEXER_API_KEY'
164
+ });
165
+
155
166
  // Get certified log from POD deposit transaction
156
- const depositTxHash = '0x...'; // Transaction hash of deposit on POD
157
- const certifiedLog = await trackerClient.getDepositCertifiedLog(depositTxHash);
167
+ const certifiedLogResponse = await indexerClient.getBridgeCertifiedLog({
168
+ transactionHash: '0x...', // Transaction hash of deposit on POD
169
+ bridgeContractAddress: config.pod.contractAddress,
170
+ rpcUrl: config.pod.rpcUrl
171
+ });
172
+
173
+ const certifiedLog = certifiedLogResponse.result;
158
174
 
159
175
  // Create unsigned claim transaction for ERC20 on Source chain
160
176
  const unsignedTx = podToSourceChainClient.claimWithCertificate({
@@ -337,9 +353,36 @@ new PodToSourceChainActionClient(config: PodBridgeActionsClientConfig)
337
353
  - **`areRequestsProcessed(deposits)`**: Batch check if requests are processed
338
354
  - Returns: `Promise<boolean[]>`
339
355
 
340
- - **`getDepositCertifiedLog(txHash)`**: Get certified log for claiming on Source chain from POD deposit
341
- - `txHash`: Transaction hash of deposit on POD
342
- - Returns: `Promise<CertifiedLog>` with attestations and merkle proof
356
+ ## ABIs
357
+
358
+ The SDK exports two separate ABIs for the different bridge contract types:
359
+
360
+ ### POD_BRIDGE_ABI
361
+
362
+ Used for the **BridgeMintBurn** contract on POD Chain:
363
+ - Deposit functions: `deposit()`, `depositNative()`
364
+ - Claim functions: `claim(uint256 id, address token, uint256 blockNumber)`, `claimNative(uint256 id, uint256 blockNumber)`
365
+ - Claims use block number verification via POD precompiles
366
+ - Events: `Deposit`, `DepositNative`, `Claim`, `ClaimNative`
367
+
368
+ ### SOURCE_CHAIN_BRIDGE_ABI
369
+
370
+ Used for the **BridgeDepositWithdraw** contract on Source Chain (e.g., Sepolia):
371
+ - Deposit functions: `deposit()`, `depositNative()`
372
+ - Claim functions: `claim(CertifiedLog)`, `claimNative(CertifiedLog)`
373
+ - Claims use POD certificate system with attestations and merkle proofs
374
+ - Events: `Deposit`, `DepositNative`, `Claim`, `ClaimNative`
375
+
376
+ Both are exported from the package and can be used with ethers.js:
377
+
378
+ ```typescript
379
+ import { POD_BRIDGE_ABI, SOURCE_CHAIN_BRIDGE_ABI } from '@tapforce/pod-bridge-sdk';
380
+ import { ethers } from 'ethers';
381
+
382
+ // Create contract interface
383
+ const podBridge = new ethers.Contract(podAddress, POD_BRIDGE_ABI, provider);
384
+ const sourceChainBridge = new ethers.Contract(sepoliaAddress, SOURCE_CHAIN_BRIDGE_ABI, provider);
385
+ ```
343
386
 
344
387
  ## Types
345
388
 
@@ -405,13 +448,13 @@ interface CertifiedLog {
405
448
  topics: string[];
406
449
  data: string;
407
450
  };
408
- logIndex: bigint | string;
451
+ log_index: bigint | string;
409
452
  certificate: {
410
453
  leaf: string;
411
- certifiedReceipt: {
412
- receiptRoot: string;
413
- aggregateSignature: string;
414
- sortedAttestationTimestamps: bigint[] | string[];
454
+ certified_receipt: {
455
+ receipt_root: string;
456
+ aggregate_signature: string;
457
+ sorted_attestation_timestamps: bigint[] | string[];
415
458
  };
416
459
  proof: {
417
460
  path: string[];
@@ -424,15 +467,19 @@ interface CertifiedLog {
424
467
 
425
468
  The SDK supports two bridge implementations:
426
469
 
427
- 1. **BridgeDepositWithdraw** (Certificate-based)
470
+ 1. **BridgeDepositWithdraw** (Certificate-based) - Source Chain
428
471
  - Used for claiming on Source chain from POD deposits
429
- - Requires certified logs from POD's certificate system
472
+ - Requires certified logs from POD's certificate system via indexer
473
+ - Uses `SOURCE_CHAIN_BRIDGE_ABI`
430
474
  - Methods: `claimWithCertificate`, `claimNativeWithCertificate`
475
+ - Certified logs include attestations, receipt root, aggregate signatures, and merkle proofs
431
476
 
432
- 2. **BridgeMintBurn** (Precompile-based)
477
+ 2. **BridgeMintBurn** (Precompile-based) - POD Chain
433
478
  - Used for claiming on POD from Source chain deposits
434
- - Uses block number verification via precompiles
479
+ - Uses block number verification via POD precompiles
480
+ - Uses `POD_BRIDGE_ABI`
435
481
  - Methods: `claimWithBlockNumber`, `claimNativeWithBlockNumber`
482
+ - POD has instant finality (single-block architecture)
436
483
 
437
484
  ## Examples
438
485
 
@@ -505,6 +552,7 @@ if (canClaim) {
505
552
  ```typescript
506
553
  import { ethers } from 'ethers';
507
554
  import { PodToSourceChainActionClient, PodBridgeTrackerClient } from '@tapforce/pod-bridge-sdk';
555
+ import { PodIndexerHttpClient } from '@tapforce/pod-indexer-sdk';
508
556
 
509
557
  // Setup
510
558
  const trackerConfig = {
@@ -528,6 +576,12 @@ const trackerClient = new PodBridgeTrackerClient(trackerConfig);
528
576
  const podProvider = new ethers.JsonRpcProvider(trackerConfig.pod.rpcUrl);
529
577
  const podSigner = new ethers.Wallet('PRIVATE_KEY', podProvider);
530
578
 
579
+ // Initialize indexer client for getting certified logs
580
+ const indexerClient = new PodIndexerHttpClient({
581
+ apiUrl: 'YOUR_INDEXER_API_URL',
582
+ apiKey: 'YOUR_INDEXER_API_KEY'
583
+ });
584
+
531
585
  // Step 1: Deposit tokens on POD
532
586
  const depositTx = actionClient.depositToken({
533
587
  token: '0xTokenAddress',
@@ -539,13 +593,23 @@ const tx = await podSigner.sendTransaction(depositTx);
539
593
  const receipt = await tx.wait();
540
594
  console.log(`Deposit tx on POD: ${tx.hash}`);
541
595
 
542
- // Step 2: Get certified log from POD transaction
543
- const certifiedLog = await trackerClient.getDepositCertifiedLog(tx.hash);
596
+ // Step 2: Get certified log from POD transaction using indexer
597
+ const certifiedLogResponse = await indexerClient.getBridgeCertifiedLog({
598
+ transactionHash: tx.hash,
599
+ bridgeContractAddress: trackerConfig.pod.contractAddress,
600
+ rpcUrl: trackerConfig.pod.rpcUrl
601
+ });
602
+
603
+ const certifiedLog = certifiedLogResponse.result;
604
+ if (!certifiedLog) {
605
+ throw new Error('Certified log not found');
606
+ }
544
607
  console.log('Got certified log with attestations');
545
608
 
546
609
  // Step 3: Claim on Sepolia using certified log
547
610
  const claimTx = actionClient.claimWithCertificate({
548
- certifiedLog
611
+ certifiedLog,
612
+ from: await podSigner.getAddress()
549
613
  });
550
614
 
551
615
  const sepoliaProvider = new ethers.JsonRpcProvider(trackerConfig.sourceChain.rpcUrl);
@@ -574,6 +638,16 @@ npm run clean
574
638
  - **ethers**: ^6.15.0 - Ethereum library for interacting with contracts
575
639
  - **typescript**: ^5.8.3 - TypeScript support
576
640
 
641
+ ### External Dependencies for Claims
642
+
643
+ To claim tokens on Source Chain from POD deposits, you'll need:
644
+
645
+ - **@tapforce/pod-indexer-sdk**: For retrieving certified logs from POD transactions
646
+
647
+ ```bash
648
+ npm install @tapforce/pod-indexer-sdk
649
+ ```
650
+
577
651
  ## License
578
652
 
579
653
  ISC
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PodToSourceChainActionClient = void 0;
4
4
  const ethers_1 = require("ethers");
5
5
  const bridge_abi_1 = require("../../libs/abi/bridge.abi");
6
+ const convert_certified_log_helper_1 = require("../../libs/helpers/convert-certified-log.helper");
6
7
  class PodToSourceChainActionClient {
7
8
  constructor(config) {
8
9
  this.config = config;
@@ -72,7 +73,7 @@ class PodToSourceChainActionClient {
72
73
  */
73
74
  claimNativeWithCertificate(args) {
74
75
  // Use source chain interface which has the certificate-based claimNative function
75
- const data = this.sourceChainIface.encodeFunctionData('claimNative', [args.certifiedLog]);
76
+ const data = this.sourceChainIface.encodeFunctionData('claimNative', [(0, convert_certified_log_helper_1.convertFFICertifiedLog)(args.certifiedLog)]);
76
77
  return {
77
78
  to: this.config.sourceChain.contractAddress,
78
79
  data,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapforce/pod-bridge-sdk",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "description": "SDK for interacting with Bridges between pod and other chains",
5
5
  "keywords": [
6
6
  "pod",