@tapforce/pod-bridge-sdk 1.1.16 → 1.2.1

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.
@@ -1,55 +1,57 @@
1
- import { UnsignedTransaction, CertifiedLog, PodBridgeActionsClientConfig } from "../../libs/types/pod-bridge.types";
1
+ import { UnsignedTransaction, ClaimProofData, PodBridgeActionsClientConfig } from "../../libs/types/pod-bridge.types";
2
+ /**
3
+ * PodToSourceChainActionClient - Handles Pod -> ETH bridging
4
+ *
5
+ * New architecture:
6
+ * - User deposits ERC20 tokens on Pod
7
+ * - Wait for TX receipt from Pod
8
+ * - User claims on ETH with aggregated validator signatures
9
+ * - Only ERC20 tokens supported (no native tokens)
10
+ *
11
+ * Important notes:
12
+ * - Token addresses on Pod and ETH are different (user deposits AAAA on Pod, claims BBBB on ETH)
13
+ * - committee_epoch is hardcoded to 0 for now
14
+ * - aggregated_signatures is concatenation of 65-byte ECDSA signatures (r,s,v)
15
+ * - proof is the deposit TX hash (subject to change in the future)
16
+ */
2
17
  export declare class PodToSourceChainActionClient {
3
18
  private readonly config;
4
- private readonly podIface;
5
- private readonly sourceChainIface;
19
+ private readonly iface;
6
20
  constructor(config: PodBridgeActionsClientConfig);
7
21
  /**
8
- * Create unsigned transaction for depositing ERC20 tokens from POD to Bridged chain
9
- * @param args.token Token address to deposit
22
+ * Create unsigned transaction for depositing ERC20 tokens from Pod to ETH
23
+ *
24
+ * After deposit:
25
+ * - Get the TX receipt from Pod
26
+ * - Call claim() on ETH with aggregated validator signatures
27
+ *
28
+ * Note: Native tokens are not supported. Only ERC20.
29
+ * Note: Token addresses differ between Pod and ETH chains.
30
+ *
31
+ * @param args.token Token address on Pod to deposit
10
32
  * @param args.amount Amount to deposit (in wei)
11
- * @param args.destinationWalletAddress Recipient address on destination chain
33
+ * @param args.destinationWalletAddress Recipient address on ETH
12
34
  * @param args.from Optional sender address
13
35
  * @returns Unsigned transaction template with encoded deposit call
14
36
  */
15
- depositToken(args: {
37
+ deposit(args: {
16
38
  token: string;
17
39
  amount: string | bigint;
18
40
  destinationWalletAddress: string;
19
41
  from?: string;
20
42
  }): UnsignedTransaction;
21
43
  /**
22
- * Create unsigned transaction for depositing native tokens from POD to Bridged chain
23
- * @param args.amount Amount to deposit (in wei) - also set as transaction value
24
- * @param args.destinationWalletAddress Recipient address on destination chain
25
- * @param args.from Optional sender address
26
- * @returns Unsigned transaction template with encoded depositNative call
27
- */
28
- depositNative(args: {
29
- amount: string | bigint;
30
- destinationWalletAddress: string;
31
- from?: string;
32
- }): UnsignedTransaction;
33
- /**
34
- * Create unsigned transaction for claiming ERC20 tokens on Source Chain (BridgeDepositWithdraw - with certificates)
35
- * Used for claiming ERC20 tokens on Source Chain from POD deposits
36
- * @param args.certifiedLog Certified log from POD certificate system
44
+ * Create unsigned transaction for claiming ERC20 tokens on ETH (source chain)
45
+ *
46
+ * This is called after depositing on Pod and getting the TX receipt.
47
+ * The aggregated_signatures must be recovered to 65-byte format (r,s,v).
48
+ *
49
+ * @param args.claimData Claim proof data with aggregated signatures
37
50
  * @param args.from Optional sender address
38
51
  * @returns Unsigned transaction template with encoded claim call
39
52
  */
40
- claimWithCertificate(args: {
41
- certifiedLog: CertifiedLog;
42
- from?: string;
43
- }): UnsignedTransaction;
44
- /**
45
- * Create unsigned transaction for claiming native tokens on Source Chain (BridgeDepositWithdraw - with certificates)
46
- * Used for claiming native tokens on Source Chain from POD deposits
47
- * @param args.certifiedLog Certified log from POD certificate system
48
- * @param args.from Optional sender address
49
- * @returns Unsigned transaction template with encoded claimNative call
50
- */
51
- claimNativeWithCertificate(args: {
52
- certifiedLog: CertifiedLog;
53
+ claim(args: {
54
+ claimData: ClaimProofData;
53
55
  from?: string;
54
56
  }): UnsignedTransaction;
55
57
  }
@@ -3,23 +3,44 @@ 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
+ * PodToSourceChainActionClient - Handles Pod -> ETH bridging
8
+ *
9
+ * New architecture:
10
+ * - User deposits ERC20 tokens on Pod
11
+ * - Wait for TX receipt from Pod
12
+ * - User claims on ETH with aggregated validator signatures
13
+ * - Only ERC20 tokens supported (no native tokens)
14
+ *
15
+ * Important notes:
16
+ * - Token addresses on Pod and ETH are different (user deposits AAAA on Pod, claims BBBB on ETH)
17
+ * - committee_epoch is hardcoded to 0 for now
18
+ * - aggregated_signatures is concatenation of 65-byte ECDSA signatures (r,s,v)
19
+ * - proof is the deposit TX hash (subject to change in the future)
20
+ */
7
21
  class PodToSourceChainActionClient {
8
22
  constructor(config) {
9
23
  this.config = config;
10
- this.podIface = new ethers_1.Interface(bridge_abi_1.POD_BRIDGE_ABI);
11
- this.sourceChainIface = new ethers_1.Interface(bridge_abi_1.SOURCE_CHAIN_BRIDGE_ABI);
24
+ this.iface = new ethers_1.Interface(bridge_abi_1.BRIDGE_ABI);
12
25
  }
13
26
  /**
14
- * Create unsigned transaction for depositing ERC20 tokens from POD to Bridged chain
15
- * @param args.token Token address to deposit
27
+ * Create unsigned transaction for depositing ERC20 tokens from Pod to ETH
28
+ *
29
+ * After deposit:
30
+ * - Get the TX receipt from Pod
31
+ * - Call claim() on ETH with aggregated validator signatures
32
+ *
33
+ * Note: Native tokens are not supported. Only ERC20.
34
+ * Note: Token addresses differ between Pod and ETH chains.
35
+ *
36
+ * @param args.token Token address on Pod to deposit
16
37
  * @param args.amount Amount to deposit (in wei)
17
- * @param args.destinationWalletAddress Recipient address on destination chain
38
+ * @param args.destinationWalletAddress Recipient address on ETH
18
39
  * @param args.from Optional sender address
19
40
  * @returns Unsigned transaction template with encoded deposit call
20
41
  */
21
- depositToken(args) {
22
- const data = this.podIface.encodeFunctionData('deposit', [
42
+ deposit(args) {
43
+ const data = this.iface.encodeFunctionData('deposit', [
23
44
  args.token,
24
45
  args.amount,
25
46
  args.destinationWalletAddress
@@ -28,57 +49,34 @@ class PodToSourceChainActionClient {
28
49
  to: this.config.pod.contractAddress,
29
50
  data,
30
51
  value: '0',
31
- from: args === null || args === void 0 ? void 0 : args.from
52
+ from: args?.from
32
53
  };
33
54
  }
34
55
  /**
35
- * Create unsigned transaction for depositing native tokens from POD to Bridged chain
36
- * @param args.amount Amount to deposit (in wei) - also set as transaction value
37
- * @param args.destinationWalletAddress Recipient address on destination chain
38
- * @param args.from Optional sender address
39
- * @returns Unsigned transaction template with encoded depositNative call
40
- */
41
- depositNative(args) {
42
- const data = this.podIface.encodeFunctionData('depositNative', [args.destinationWalletAddress]);
43
- return {
44
- to: this.config.pod.contractAddress,
45
- data,
46
- value: args.amount.toString(),
47
- from: args === null || args === void 0 ? void 0 : args.from
48
- };
49
- }
50
- /**
51
- * Create unsigned transaction for claiming ERC20 tokens on Source Chain (BridgeDepositWithdraw - with certificates)
52
- * Used for claiming ERC20 tokens on Source Chain from POD deposits
53
- * @param args.certifiedLog Certified log from POD certificate system
56
+ * Create unsigned transaction for claiming ERC20 tokens on ETH (source chain)
57
+ *
58
+ * This is called after depositing on Pod and getting the TX receipt.
59
+ * The aggregated_signatures must be recovered to 65-byte format (r,s,v).
60
+ *
61
+ * @param args.claimData Claim proof data with aggregated signatures
54
62
  * @param args.from Optional sender address
55
63
  * @returns Unsigned transaction template with encoded claim call
56
64
  */
57
- claimWithCertificate(args) {
58
- // Use source chain interface which has the certificate-based claim function
59
- const data = this.sourceChainIface.encodeFunctionData('claim', [args.certifiedLog]);
60
- return {
61
- to: this.config.sourceChain.contractAddress,
62
- data,
63
- value: '0',
64
- from: args === null || args === void 0 ? void 0 : args.from
65
- };
66
- }
67
- /**
68
- * Create unsigned transaction for claiming native tokens on Source Chain (BridgeDepositWithdraw - with certificates)
69
- * Used for claiming native tokens on Source Chain from POD deposits
70
- * @param args.certifiedLog Certified log from POD certificate system
71
- * @param args.from Optional sender address
72
- * @returns Unsigned transaction template with encoded claimNative call
73
- */
74
- claimNativeWithCertificate(args) {
75
- // Use source chain interface which has the certificate-based claimNative function
76
- const data = this.sourceChainIface.encodeFunctionData('claimNative', [(0, convert_certified_log_helper_1.convertFFICertifiedLog)(args.certifiedLog)]);
65
+ claim(args) {
66
+ const { ethTokenAddress, amount, to, committeeEpoch, aggregatedSignatures, depositTxHash } = args.claimData;
67
+ const data = this.iface.encodeFunctionData('claim', [
68
+ ethTokenAddress,
69
+ amount,
70
+ to,
71
+ committeeEpoch,
72
+ aggregatedSignatures,
73
+ depositTxHash
74
+ ]);
77
75
  return {
78
76
  to: this.config.sourceChain.contractAddress,
79
77
  data,
80
78
  value: '0',
81
- from: args === null || args === void 0 ? void 0 : args.from
79
+ from: args?.from
82
80
  };
83
81
  }
84
82
  }
@@ -1,64 +1,37 @@
1
1
  import { UnsignedTransaction, PodBridgeActionsClientConfig } from "../../libs/types/pod-bridge.types";
2
+ /**
3
+ * SourceChainToPodActionClient - Handles ETH -> Pod bridging
4
+ *
5
+ * New architecture:
6
+ * - User deposits ERC20 tokens on ETH (source chain)
7
+ * - Balance is automatically added on Pod (~15 min on Sepolia, instant on Anvil)
8
+ * - NO claim transaction needed on Pod side (auto-claim)
9
+ * - Only ERC20 tokens supported (wrap ETH to WETH first)
10
+ */
2
11
  export declare class SourceChainToPodActionClient {
3
12
  private readonly config;
4
13
  private readonly iface;
5
14
  constructor(config: PodBridgeActionsClientConfig);
6
15
  /**
7
- * Create unsigned transaction for depositing ERC20 tokens
8
- * @param args.token Token address to deposit
16
+ * Create unsigned transaction for depositing ERC20 tokens from ETH to Pod
17
+ *
18
+ * After deposit:
19
+ * - Wait for block finalization (~15 min on Sepolia, instant on Anvil)
20
+ * - Balance will be automatically added on Pod (no claim needed)
21
+ *
22
+ * Note: Native ETH is not supported. Wrap to WETH first.
23
+ * Note: Token addresses differ between ETH and Pod chains.
24
+ *
25
+ * @param args.token Token address on source chain (ETH) to deposit
9
26
  * @param args.amount Amount to deposit (in wei)
10
- * @param args.destinationWalletAddress Recipient address on destination chain
11
- * @param args.contractAddress Bridge contract address (source chain)
27
+ * @param args.destinationWalletAddress Recipient address on Pod
12
28
  * @param args.from Optional sender address
13
29
  * @returns Unsigned transaction template with encoded deposit call
14
30
  */
15
- depositToken(args: {
31
+ deposit(args: {
16
32
  token: string;
17
33
  amount: string | bigint;
18
34
  destinationWalletAddress: string;
19
35
  from?: string;
20
36
  }): UnsignedTransaction;
21
- /**
22
- * Create unsigned transaction for depositing native tokens (ETH)
23
- * @param args.amount Amount to deposit (in wei) - also set as transaction value
24
- * @param args.destinationWalletAddress Recipient address on destination chain
25
- * @param args.contractAddress Bridge contract address (source chain)
26
- * @param args.from Optional sender address
27
- * @returns Unsigned transaction template with encoded depositNative call
28
- */
29
- depositNative(args: {
30
- amount: string | bigint;
31
- destinationWalletAddress: string;
32
- from?: string;
33
- }): UnsignedTransaction;
34
- /**
35
- * Create unsigned transaction for claiming tokens (BridgeMintBurn - using precompiles)
36
- * Used for claiming on POD from Sepolia deposits
37
- * @param args.id Request ID from deposit event
38
- * @param args.token Token address that was deposited on source chain
39
- * @param args.blockNumber Block number of the deposit on source chain
40
- * @param args.contractAddress Bridge contract address (destination chain)
41
- * @param args.from Optional sender address
42
- * @returns Unsigned transaction template with encoded claim call
43
- */
44
- claimWithBlockNumber(args: {
45
- id: string | bigint;
46
- token: string;
47
- blockNumber: string | bigint | number;
48
- from?: string;
49
- }): UnsignedTransaction;
50
- /**
51
- * Create unsigned transaction for claiming native tokens (BridgeMintBurn - using precompiles)
52
- * Used for claiming native tokens on POD from Sepolia deposits
53
- * @param args.id Request ID from deposit event
54
- * @param args.blockNumber Block number of the deposit on source chain
55
- * @param args.contractAddress Bridge contract address (destination chain)
56
- * @param args.from Optional sender address
57
- * @returns Unsigned transaction template with encoded claimNative call
58
- */
59
- claimNativeWithBlockNumber(args: {
60
- id: string | bigint;
61
- blockNumber: string | bigint | number;
62
- from?: string;
63
- }): UnsignedTransaction;
64
37
  }
@@ -3,21 +3,37 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SourceChainToPodActionClient = void 0;
4
4
  const ethers_1 = require("ethers");
5
5
  const bridge_abi_1 = require("../../libs/abi/bridge.abi");
6
+ /**
7
+ * SourceChainToPodActionClient - Handles ETH -> Pod bridging
8
+ *
9
+ * New architecture:
10
+ * - User deposits ERC20 tokens on ETH (source chain)
11
+ * - Balance is automatically added on Pod (~15 min on Sepolia, instant on Anvil)
12
+ * - NO claim transaction needed on Pod side (auto-claim)
13
+ * - Only ERC20 tokens supported (wrap ETH to WETH first)
14
+ */
6
15
  class SourceChainToPodActionClient {
7
16
  constructor(config) {
8
17
  this.config = config;
9
- this.iface = new ethers_1.Interface(bridge_abi_1.POD_BRIDGE_ABI);
18
+ this.iface = new ethers_1.Interface(bridge_abi_1.BRIDGE_ABI);
10
19
  }
11
20
  /**
12
- * Create unsigned transaction for depositing ERC20 tokens
13
- * @param args.token Token address to deposit
21
+ * Create unsigned transaction for depositing ERC20 tokens from ETH to Pod
22
+ *
23
+ * After deposit:
24
+ * - Wait for block finalization (~15 min on Sepolia, instant on Anvil)
25
+ * - Balance will be automatically added on Pod (no claim needed)
26
+ *
27
+ * Note: Native ETH is not supported. Wrap to WETH first.
28
+ * Note: Token addresses differ between ETH and Pod chains.
29
+ *
30
+ * @param args.token Token address on source chain (ETH) to deposit
14
31
  * @param args.amount Amount to deposit (in wei)
15
- * @param args.destinationWalletAddress Recipient address on destination chain
16
- * @param args.contractAddress Bridge contract address (source chain)
32
+ * @param args.destinationWalletAddress Recipient address on Pod
17
33
  * @param args.from Optional sender address
18
34
  * @returns Unsigned transaction template with encoded deposit call
19
35
  */
20
- depositToken(args) {
36
+ deposit(args) {
21
37
  const data = this.iface.encodeFunctionData('deposit', [
22
38
  args.token,
23
39
  args.amount,
@@ -27,65 +43,7 @@ class SourceChainToPodActionClient {
27
43
  to: this.config.sourceChain.contractAddress,
28
44
  data,
29
45
  value: '0',
30
- from: args === null || args === void 0 ? void 0 : args.from
31
- };
32
- }
33
- /**
34
- * Create unsigned transaction for depositing native tokens (ETH)
35
- * @param args.amount Amount to deposit (in wei) - also set as transaction value
36
- * @param args.destinationWalletAddress Recipient address on destination chain
37
- * @param args.contractAddress Bridge contract address (source chain)
38
- * @param args.from Optional sender address
39
- * @returns Unsigned transaction template with encoded depositNative call
40
- */
41
- depositNative(args) {
42
- const data = this.iface.encodeFunctionData('depositNative', [args.destinationWalletAddress]);
43
- return {
44
- to: this.config.sourceChain.contractAddress,
45
- data,
46
- value: args.amount.toString(),
47
- from: args === null || args === void 0 ? void 0 : args.from
48
- };
49
- }
50
- /**
51
- * Create unsigned transaction for claiming tokens (BridgeMintBurn - using precompiles)
52
- * Used for claiming on POD from Sepolia deposits
53
- * @param args.id Request ID from deposit event
54
- * @param args.token Token address that was deposited on source chain
55
- * @param args.blockNumber Block number of the deposit on source chain
56
- * @param args.contractAddress Bridge contract address (destination chain)
57
- * @param args.from Optional sender address
58
- * @returns Unsigned transaction template with encoded claim call
59
- */
60
- claimWithBlockNumber(args) {
61
- const data = this.iface.encodeFunctionData('claim(uint256,address,uint256)', [
62
- args.id,
63
- args.token,
64
- args.blockNumber
65
- ]);
66
- return {
67
- to: this.config.pod.contractAddress,
68
- data,
69
- value: '0',
70
- from: args === null || args === void 0 ? void 0 : args.from
71
- };
72
- }
73
- /**
74
- * Create unsigned transaction for claiming native tokens (BridgeMintBurn - using precompiles)
75
- * Used for claiming native tokens on POD from Sepolia deposits
76
- * @param args.id Request ID from deposit event
77
- * @param args.blockNumber Block number of the deposit on source chain
78
- * @param args.contractAddress Bridge contract address (destination chain)
79
- * @param args.from Optional sender address
80
- * @returns Unsigned transaction template with encoded claimNative call
81
- */
82
- claimNativeWithBlockNumber(args) {
83
- const data = this.iface.encodeFunctionData('claimNative(uint256,uint256)', [args.id, args.blockNumber]);
84
- return {
85
- to: this.config.pod.contractAddress,
86
- data,
87
- value: '0',
88
- from: args === null || args === void 0 ? void 0 : args.from
46
+ from: args?.from
89
47
  };
90
48
  }
91
49
  }
@@ -6,13 +6,17 @@ import { PodBridgeConfig, BridgeRequest, BridgeRequestWithType } from "../../lib
6
6
  * to provide a unified view of bridge activity across both chains.
7
7
  *
8
8
  * Bridge Architecture:
9
- * - Source Chain (e.g., Sepolia): BridgeDepositWithdraw contract
10
- * - Deposits lock tokens
11
- * - Claims use POD certificates (requires attestations)
9
+ * - ETH -> Pod: deposits on ETH, AUTO-CLAIM on Pod (no claim needed)
10
+ * - Pod -> ETH: deposits on Pod, claims on ETH with aggregated validator signatures
11
+ * - Only ERC20 tokens supported (wrap ETH to WETH)
12
12
  *
13
- * - POD Chain: BridgeMintBurn contract
14
- * - Deposits burn tokens (POD has instant finality - single block)
15
- * - Claims use block number verification via precompiles
13
+ * Source Chain (e.g., Sepolia/ETH):
14
+ * - Deposits lock ERC20 tokens (ETH -> Pod direction)
15
+ * - Claims release ERC20 tokens with validator signatures (Pod -> ETH direction)
16
+ *
17
+ * POD Chain:
18
+ * - Auto-claim for ETH -> Pod deposits (instant finality)
19
+ * - Deposits for Pod -> ETH direction
16
20
  */
17
21
  export declare class PodBridgeTrackerClient {
18
22
  private readonly sourceChainTracker;
@@ -40,19 +44,33 @@ export declare class PodBridgeTrackerClient {
40
44
  */
41
45
  getAllDepositsFor(address: string, fromBlock?: number): Promise<BridgeRequestWithType[]>;
42
46
  /**
43
- * Check if deposits can be claimed (block finalized on source chain)
47
+ * Check if deposits can be claimed
48
+ *
49
+ * New architecture:
50
+ * - ETH -> Pod: AUTO-CLAIM on Pod, no manual claim needed (always returns false)
51
+ * - Pod -> ETH: Manual claim needed on ETH with aggregated signatures
52
+ *
44
53
  * @param deposit The bridge request to check
45
- * @returns True if the deposit can be claimed
54
+ * @returns True if the deposit can be manually claimed (only Pod -> ETH direction)
46
55
  */
47
56
  canBeClaimed(deposit: BridgeRequest): Promise<boolean>;
48
57
  /**
49
58
  * Batch check claim status for multiple deposits
50
- * Claims are checked on the opposite chain from where the deposit was made
59
+ *
60
+ * New architecture:
61
+ * - ETH -> Pod: AUTO-CLAIM on Pod (mark as claimed after finalization)
62
+ * - Pod -> ETH: Check claim events on Source Chain
63
+ *
51
64
  * @private
52
65
  */
53
66
  private updateClaimStatus;
54
67
  /**
55
68
  * Batch check if multiple requests have been processed on-chain
69
+ *
70
+ * New architecture:
71
+ * - ETH -> Pod: Auto-claimed after finalization
72
+ * - Pod -> ETH: Check claim events on Source Chain
73
+ *
56
74
  * @param deposits Array of deposits to check
57
75
  * @returns Array of boolean values
58
76
  */