Skip to content

Commit 879e855

Browse files
Fix AllowanceView crash due to paymaster interpret refetch (#671)
1 parent bfef47e commit 879e855

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/ui/components/address-action/TransactionConfirmationView/TransactionConfirmationView.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ export function TransactionConfirmationView({
5050
}) {
5151
const { preferences, query } = usePreferences();
5252

53+
// TODO:
54+
// Refactor:
55+
// refactor to a single hook that can interpret both regular
56+
// and paymaster transactions
5357
const txInterpretQuery = useTxInterpretQuery({
5458
transaction,
5559
eligibilityQuery,

src/ui/components/address-action/TransactionSimulation/TransactionSimulation.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,14 @@ export function TransactionSimulation({
144144

145145
const { preferences } = usePreferences();
146146
const source = preferences?.testnetMode?.on ? 'testnet' : 'mainnet';
147+
// TODO:
148+
// Refactor:
149+
// This must be called on the same level as `txInterpretQuery`
150+
// in TransactionConfirmationView
147151
const paymasterTxInterpretQuery = useQuery({
148152
enabled: Boolean(network?.supports_simulations) && paymasterEligible,
149153
suspense: false,
154+
keepPreviousData: true,
150155
queryKey: ['interpret/typedData', client, currency, transaction, source],
151156
queryKeyHashFn: (queryKey) => {
152157
const key = queryKey.map((x) => (x instanceof Client ? x.url : x));

src/ui/pages/SendTransaction/SendTransaction.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,10 @@ function SendTransactionContent({
605605

606606
const paymasterTxInterpretQuery = useQuery({
607607
enabled: Boolean(network?.supports_simulations) && paymasterEligible,
608+
// Both paymasterTxInterpretQuery and txInterpret query must behave the same
609+
// and keepPreviousData. Failing to do this currently may break AllowanceView
610+
// component because we will pass a nullish requestedAllowanceQuantityBase during refetch
611+
keepPreviousData: true,
608612
suspense: false,
609613
queryKey: [
610614
'interpret/typedData',

0 commit comments

Comments
 (0)