Skip to content

Commit

Permalink
prioritize usdc alt fees
Browse files Browse the repository at this point in the history
  • Loading branch information
TalDerei committed Jan 17, 2025
1 parent 51a83df commit 8e2f22b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/storage/src/indexed-db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,17 @@ export class IndexedDb implements IndexedDbInterface {

async getAltGasPrices(): Promise<GasPrices[]> {
const allGasPrices = await this.db.getAll('GAS_PRICES');
const usdcPriorityAssetId = 'drPksQaBNYwSOzgfkGOEdrd4kEDkeALeh58Ps+7cjQs=';

// Retrieve gas prices from the database and prioritize USDC as the preferred asset.
return allGasPrices
.map(gp => GasPrices.fromJson(gp))
.filter(gp => !gp.assetId?.equals(this.stakingTokenAssetId));
.filter(gp => !gp.assetId?.equals(this.stakingTokenAssetId))
.sort(
(a, b) =>
(uint8ArrayToBase64(a.assetId?.inner!) === usdcPriorityAssetId ? -1 : 0) -

Check failure on line 483 in packages/storage/src/indexed-db/index.ts

View workflow job for this annotation

GitHub Actions / Lint

Forbidden non-null assertion

Check failure on line 483 in packages/storage/src/indexed-db/index.ts

View workflow job for this annotation

GitHub Actions / Lint

Optional chain expressions can return undefined by design - using a non-null assertion is unsafe and wrong
(uint8ArrayToBase64(b.assetId?.inner!) === usdcPriorityAssetId ? -1 : 0),

Check failure on line 484 in packages/storage/src/indexed-db/index.ts

View workflow job for this annotation

GitHub Actions / Lint

Forbidden non-null assertion

Check failure on line 484 in packages/storage/src/indexed-db/index.ts

View workflow job for this annotation

GitHub Actions / Lint

Optional chain expressions can return undefined by design - using a non-null assertion is unsafe and wrong
);
}

async saveGasPrices(value: Required<PlainMessage<GasPrices>>): Promise<void> {
Expand Down

0 comments on commit 8e2f22b

Please sign in to comment.