Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
Signed-off-by: bingyuyap <[email protected]>
  • Loading branch information
bingyuyap committed Aug 29, 2024
1 parent 89a4072 commit 0d27cd6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions watcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"@solana/spl-token": "^0.4.6",
"@solana/web3.js": "^1.73.0",
"@types/bn.js": "^5.1.0",
"@wormhole-foundation/example-liquidity-layer-definitions": "file:./sdk/wormhole-foundation-example-liquidity-layer-definitions-0.0.1.tgz",
"@wormhole-foundation/example-liquidity-layer-evm": "file:./sdk/wormhole-foundation-example-liquidity-layer-evm-0.0.1.tgz",
"@wormhole-foundation/example-liquidity-layer-definitions": "file:sdk/wormhole-foundation-example-liquidity-layer-definitions-0.0.1.tgz",
"@wormhole-foundation/example-liquidity-layer-evm": "file:sdk/wormhole-foundation-example-liquidity-layer-evm-0.0.1.tgz",
"@wormhole-foundation/example-liquidity-layer-solana": "file:sdk/wormhole-foundation-example-liquidity-layer-solana-0.0.1.tgz",
"@wormhole-foundation/wormhole-monitor-common": "^0.0.1",
"algosdk": "^2.4.0",
Expand Down
20 changes: 9 additions & 11 deletions watcher/src/watchers/FTSolanaWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class FTSolanaWatcher extends SolanaWatcher {

// Check if the last signature of this batch is the same as the current signature
// If it is, it means we are not progressing and should break the loop
// Index is 0 because `getSignaturesForAddress` returns the signatures in descending orderfetching info for blocks
// Index is 0 because `getSignaturesForAddress` returns the signatures in descending order
if (batchSignatures[0].signature === currSignature) {
this.logger.warn('No new signatures fetched, breaking the loop.');
break;
Expand Down Expand Up @@ -939,6 +939,7 @@ export class FTSolanaWatcher extends SolanaWatcher {

return auction;
}

async getDbLatestAuctionHistoryIndex(): Promise<bigint> {
if (!this.pg) {
this.logger.debug('No database connection, returning 0');
Expand All @@ -950,7 +951,7 @@ export class FTSolanaWatcher extends SolanaWatcher {
this.logger.info(`Latest auction history index: ${maxIndex}`);
return maxIndex;
} catch (error) {
this.logger.error('Failed to fetch the largest index from auction_history_mapping:', error);
this.logger.error(`Failed to fetch the largest index from auction_history_mapping: ${error}`);
throw new Error('Database query failed');
}
}
Expand All @@ -970,7 +971,7 @@ export class FTSolanaWatcher extends SolanaWatcher {
.first();
return result;
} catch (error) {
this.logger.error(`Error fetching auction history mapping for ${auction}:`, error);
this.logger.error(`Error fetching auction history mapping for ${auction}: ${error}`);
throw error;
}
}
Expand All @@ -989,7 +990,7 @@ export class FTSolanaWatcher extends SolanaWatcher {
.merge();
this.logger.info(`Saved ${mappings.length} auction history mappings.`);
} catch (error) {
this.logger.error('Error saving auction history mappings:', error);
this.logger.error(`Error saving auction history mappings: ${error}`);
throw error;
}
}
Expand All @@ -999,12 +1000,11 @@ export class FTSolanaWatcher extends SolanaWatcher {
this.logger.debug('No database connection, skipping saveFastTransfer');
return;
}
this.logger.debug(`Saving fast transfer ${fastTransfer.fast_vaa_hash}`);
try {
await this.pg('fast_transfers').insert(fastTransfer).onConflict('fast_vaa_id').merge();
this.logger.info(`Saved fast transfer ${fastTransfer.fast_vaa_hash}.`);
} catch (error) {
this.logger.error(`Error saving fast transfer ${fastTransfer.fast_vaa_hash}:`, error);
this.logger.error(`Error saving fast transfer ${fastTransfer.fast_vaa_hash}: ${error}`);
throw error;
}
}
Expand Down Expand Up @@ -1034,7 +1034,7 @@ export class FTSolanaWatcher extends SolanaWatcher {
await this.pg('fast_transfer_auctions').where(id).update(update);
this.logger.info(`Updated auction for fast vaa hash: ${id.fast_vaa_hash}.`);
} catch (error) {
this.logger.error(`Error updating auction ${id.fast_vaa_hash}:`, error);
this.logger.error(`Error updating auction ${id.fast_vaa_hash}: ${error}`);
throw error;
}
}
Expand All @@ -1053,8 +1053,7 @@ export class FTSolanaWatcher extends SolanaWatcher {
return result?.fast_vaa_hash || '';
} catch (error) {
this.logger.error(
`Error fetching Fast VAA hash for auction pubkey ${auctionPubkey.toBase58()}:`,
error
`Error fetching Fast VAA hash for auction pubkey ${auctionPubkey.toBase58()}: ${error}`
);
throw error;
}
Expand Down Expand Up @@ -1094,12 +1093,11 @@ export class FTSolanaWatcher extends SolanaWatcher {
this.logger.debug('No database connection, skipping saveAuctionLogs');
return;
}
this.logger.debug(`Attempting to save auction logs for ${auctionLogs.fast_vaa_hash}`);
try {
await this.pg('auction_logs').insert(auctionLogs);
this.logger.info(`Saved auction logs for ${auctionLogs.fast_vaa_hash}.`);
} catch (error) {
this.logger.error(`Error saving auction logs for ${auctionLogs.fast_vaa_hash}:`, error);
this.logger.error(`Error saving auction logs for ${auctionLogs.fast_vaa_hash}: ${error}`);
throw error;
}
}
Expand Down

0 comments on commit 0d27cd6

Please sign in to comment.