@tapforce/pod-bridge-sdk 1.1.4 → 1.1.6

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.
@@ -37,7 +37,6 @@ export declare class PodBridgeTrackerClient {
37
37
  /**
38
38
  * Batch check claim status for multiple deposits
39
39
  * @param deposits Array of deposits to check
40
- * @param fromBlock Starting block to query claims from
41
40
  */
42
41
  private updateClaimStatus;
43
42
  /**
@@ -66,7 +66,8 @@ class PodBridgeTrackerClient {
66
66
  to: parsed.args.to,
67
67
  token: parsed.args.token,
68
68
  amount: parsed.args.amount.toString(),
69
- isClaimed: false
69
+ isClaimed: false,
70
+ isClaimable: false
70
71
  });
71
72
  }
72
73
  }
@@ -86,7 +87,8 @@ class PodBridgeTrackerClient {
86
87
  to: parsed.args.to,
87
88
  token: ethers_1.ethers.ZeroAddress, // Native token
88
89
  amount: parsed.args.amount.toString(),
89
- isClaimed: false
90
+ isClaimed: false,
91
+ isClaimable: false
90
92
  });
91
93
  }
92
94
  }
@@ -142,7 +144,8 @@ class PodBridgeTrackerClient {
142
144
  to: parsed.args.to,
143
145
  token: parsed.args.token,
144
146
  amount: parsed.args.amount.toString(),
145
- isClaimed: false
147
+ isClaimed: false,
148
+ isClaimable: false
146
149
  });
147
150
  }
148
151
  }
@@ -162,7 +165,8 @@ class PodBridgeTrackerClient {
162
165
  to: parsed.args.to,
163
166
  token: ethers_1.ethers.ZeroAddress,
164
167
  amount: parsed.args.amount.toString(),
165
- isClaimed: false
168
+ isClaimed: false,
169
+ isClaimable: false
166
170
  });
167
171
  }
168
172
  }
@@ -224,41 +228,41 @@ class PodBridgeTrackerClient {
224
228
  /**
225
229
  * Batch check claim status for multiple deposits
226
230
  * @param deposits Array of deposits to check
227
- * @param fromBlock Starting block to query claims from
228
231
  */
229
- async updateClaimStatus(deposits, fromBlock) {
230
- var _a;
232
+ async updateClaimStatus(deposits) {
231
233
  if (deposits.length === 0) {
232
234
  return;
233
235
  }
234
236
  console.log('updateClaimStatus');
235
237
  try {
236
- const startBlock = (_a = fromBlock !== null && fromBlock !== void 0 ? fromBlock : this.config.pod.deploymentBlock) !== null && _a !== void 0 ? _a : 0;
237
- const currentBlock = await this.podProvider.getBlockNumber();
238
- const BLOCK_BATCH_SIZE = 10000;
238
+ // Get unique recipient addresses from deposits
239
+ const uniqueRecipients = [...new Set(deposits.map(d => d.to))];
240
+ console.log('Querying claims for recipients:', uniqueRecipients);
241
+ // Get claim events from destination chain (POD) filtered by recipient addresses
242
+ // Note: POD uses timestamps instead of traditional blocks
239
243
  const allClaimLogs = [];
240
244
  const allClaimNativeLogs = [];
241
- // Get claim events from destination chain in batches
242
- const claimFilter = this.podBridge.filters.Claim();
243
- const claimNativeFilter = this.podBridge.filters.ClaimNative();
244
- for (let start = startBlock; start <= currentBlock; start += BLOCK_BATCH_SIZE) {
245
- const end = Math.min(start + BLOCK_BATCH_SIZE - 1, currentBlock);
246
- console.log('updateClaimStatus', start, end);
245
+ // Query claims for each unique recipient
246
+ for (const recipient of uniqueRecipients) {
247
+ const claimFilter = this.podBridge.filters.Claim(null, // id - any
248
+ null, // claimer - any
249
+ recipient // to - filter by recipient
250
+ );
251
+ const claimNativeFilter = this.podBridge.filters.ClaimNative(null, // id - any
252
+ null, // claimer - any
253
+ recipient // to - filter by recipient
254
+ );
247
255
  const [claimLogs, claimNativeLogs] = await Promise.all([
248
- this.podBridge.queryFilter(claimFilter, start, end),
249
- this.podBridge.queryFilter(claimNativeFilter, start, end)
256
+ this.podBridge.queryFilter(claimFilter),
257
+ this.podBridge.queryFilter(claimNativeFilter)
250
258
  ]);
251
- console.log('claimLogs', claimLogs);
252
- console.log('claimNativeLogs', claimNativeLogs);
253
259
  allClaimLogs.push(...claimLogs);
254
260
  allClaimNativeLogs.push(...claimNativeLogs);
255
- // Add small delay to avoid rate limiting
256
- if (start + BLOCK_BATCH_SIZE <= currentBlock) {
257
- await new Promise(resolve => setTimeout(resolve, 100));
258
- }
259
261
  }
260
262
  const claimLogs = allClaimLogs;
261
263
  const claimNativeLogs = allClaimNativeLogs;
264
+ console.log('claimLogs', claimLogs);
265
+ console.log('claimNativeLogs', claimNativeLogs);
262
266
  // Create a map of claimed request IDs
263
267
  const claimedMap = new Map();
264
268
  for (const log of [...claimLogs, ...claimNativeLogs]) {
@@ -274,6 +278,9 @@ class PodBridgeTrackerClient {
274
278
  });
275
279
  }
276
280
  }
281
+ // Get current block to check finalization
282
+ const currentBlock = await this.bridgedProvider.getBlockNumber();
283
+ const finalizedBlock = currentBlock - 15; // ~15 minutes on Sepolia
277
284
  // Update deposit status
278
285
  for (const deposit of deposits) {
279
286
  const claimInfo = claimedMap.get(deposit.requestId);
@@ -283,10 +290,23 @@ class PodBridgeTrackerClient {
283
290
  deposit.claimedAt = claimInfo.timestamp;
284
291
  deposit.claimedBy = claimInfo.claimer;
285
292
  }
293
+ // Check if deposit is claimable (finalized and not claimed)
294
+ deposit.isClaimable = deposit.blockNumber <= finalizedBlock && !deposit.isClaimed;
286
295
  }
287
296
  }
288
297
  catch (error) {
289
298
  console.error('Error checking claim status:', error);
299
+ // Fallback: Still calculate isClaimable based on finalization even if claim check fails
300
+ try {
301
+ const currentBlock = await this.bridgedProvider.getBlockNumber();
302
+ const finalizedBlock = currentBlock - 15;
303
+ for (const deposit of deposits) {
304
+ deposit.isClaimable = deposit.blockNumber <= finalizedBlock && !deposit.isClaimed;
305
+ }
306
+ }
307
+ catch (fallbackError) {
308
+ console.error('Error calculating isClaimable:', fallbackError);
309
+ }
290
310
  }
291
311
  }
292
312
  /**
@@ -30,6 +30,7 @@ export interface BridgeRequest {
30
30
  token: string;
31
31
  amount: string;
32
32
  isClaimed: boolean;
33
+ isClaimable: boolean;
33
34
  claimedTxHash?: string;
34
35
  claimedAt?: number;
35
36
  claimedBy?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapforce/pod-bridge-sdk",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "SDK for interacting with Bridges between pod and other chains",
5
5
  "keywords": [
6
6
  "pod",