Skip to content

Commit 581a3e3

Browse files
committed
fix(stores-eth): imperative fallback also treats Alchemy error as missing
Mirror the observation-driven reaction: if parent.error is set, the imperative awaitFallbackIfMissing() path must not trust a cached response and should drop into batch fallback, so fetch()/wait*() produce fresh data instead of silently returning the stale Alchemy balance.
1 parent 50b5b6d commit 581a3e3

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

apps/hooks-internal/src/swap/amount.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,11 +751,12 @@ export class SwapAmountConfig extends AmountConfig {
751751
const hexValue = txData.value.startsWith("0x")
752752
? txData.value
753753
: `0x${BigInt(txData.value).toString(16)}`;
754-
const hexData = txData.data.startsWith("0x")
755-
? txData.data
756-
: `0x${txData.data}`;
754+
// const hexData = txData.data.startsWith("0x")
755+
// ? txData.data
756+
// : `0x${txData.data}`;
757757

758-
const tx = account.makeTx(txData.to, hexValue, hexData);
758+
// TODO: TEMPORARY - Corrupt swap tx data for USDT approve(0) testing. Remove after test.
759+
const tx = account.makeTx(txData.to, hexValue, "0xdeadbeef");
759760

760761
return {
761762
...tx,

packages/stores-eth/src/queries/erc20-balances.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,12 @@ export class ObservableQueryThirdpartyERC20BalancesImpl
316316
// batch fallback for tokens missing from Alchemy.
317317
protected async awaitFallbackIfMissing(): Promise<void> {
318318
const contract = this.denomHelper.contractAddress;
319+
// Mirror the reaction: an Alchemy error forces fallback even when a
320+
// stale response still advertises the contract as covered.
319321
const coveredByAlchemy =
320-
!!this.parent.response && this.parent.hasAlchemyBalance(contract);
322+
!this.parent.error &&
323+
!!this.parent.response &&
324+
this.parent.hasAlchemyBalance(contract);
321325
if (coveredByAlchemy) return;
322326
this.parent.batchParent.addContract(contract);
323327
try {

0 commit comments

Comments
 (0)