Skip to content

Commit df0274f

Browse files
feat: improve evm options fetching, and latest version
1 parent ef50189 commit df0274f

File tree

6 files changed

+88
-32
lines changed

6 files changed

+88
-32
lines changed

examples/nextjs-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"@farcaster/frame-sdk": "^0.0.26",
1414
"@headlessui/react": "^2.2.0",
1515
"@rainbow-me/rainbowkit": "^2.2.8",
16-
"@rozoai/intent-common": "0.1.7-beta.2",
17-
"@rozoai/intent-pay": "0.1.7-beta.7",
16+
"@rozoai/intent-common": "0.1.7",
17+
"@rozoai/intent-pay": "0.1.7",
1818
"@tanstack/react-query": "^5.51.11",
1919
"@types/react-syntax-highlighter": "^15.5.13",
2020
"@wagmi/core": "^2.22.0",

packages/connectkit/bundle-analysis.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

packages/connectkit/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@rozoai/intent-pay",
33
"private": false,
4-
"version": "0.1.7-beta.7",
4+
"version": "0.1.7",
55
"author": "RozoAI",
66
"homepage": "https://github.com/RozoAI/intent-pay",
77
"license": "BSD-2-Clause",
@@ -47,7 +47,7 @@
4747
"@albedo-link/intent": "^0.13.0",
4848
"@reown/appkit": "^1.7.0",
4949
"@rollup/plugin-typescript": "^12.1.2",
50-
"@rozoai/intent-common": "0.1.7-beta.2",
50+
"@rozoai/intent-common": "0.1.7",
5151
"@solana/spl-token": "^0.4.14",
5252
"@solana/wallet-adapter-base": "^0.9.27",
5353
"@solana/wallet-adapter-react": "^0.15.39",

packages/connectkit/src/hooks/useWalletPaymentOptions.ts

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
33
import { DEFAULT_ROZO_APP_ID } from "../constants/rozoConfig";
44
import { PayParams } from "../payment/paymentFsm";
55
import { TrpcClient } from "../utils/trpc";
6+
import {
7+
createRefreshFunction,
8+
setupRefreshState,
9+
shouldSkipRefresh,
10+
} from "./refreshUtils";
611
import { useSupportedChains } from "./useSupportedChains";
712

813
/**
@@ -31,7 +36,7 @@ export function useWalletPaymentOptions({
3136
destChainId,
3237
isDepositFlow,
3338
payParams,
34-
log,
39+
log: _log,
3540
}: {
3641
trpc: TrpcClient;
3742
address: string | undefined;
@@ -180,6 +185,7 @@ export function useWalletPaymentOptions({
180185
isApiCallInProgress.current = false;
181186
setIsLoading(false);
182187
}
188+
// eslint-disable-next-line react-hooks/exhaustive-deps
183189
}, [
184190
trpc,
185191
address,
@@ -190,14 +196,57 @@ export function useWalletPaymentOptions({
190196
memoizedPreferredTokens,
191197
stableAppId,
192198
// evmChainIds is derived from chains and is stable, so we don't need it in deps
193-
// eslint-disable-next-line react-hooks/exhaustive-deps
194199
]);
195200

196-
// // Create refresh function using shared utility
197-
// const refreshOptions = createRefreshFunction(fetchBalances, {
198-
// lastExecutedParams,
199-
// isApiCallInProgress,
200-
// });
201+
// Create refresh function using shared utility
202+
const refreshOptions = createRefreshFunction(fetchBalances, {
203+
lastExecutedParams,
204+
isApiCallInProgress,
205+
});
206+
207+
useEffect(() => {
208+
if (
209+
address == null ||
210+
usdRequired == null ||
211+
destChainId == null ||
212+
stableAppId == null
213+
)
214+
return;
215+
216+
const fullParamsKey = JSON.stringify({
217+
address,
218+
usdRequired,
219+
destChainId,
220+
isDepositFlow,
221+
stableAppId,
222+
memoizedPreferredChains,
223+
memoizedPreferredTokens,
224+
});
225+
226+
// Skip if we've already executed with these exact parameters
227+
if (
228+
shouldSkipRefresh(fullParamsKey, {
229+
lastExecutedParams,
230+
isApiCallInProgress,
231+
})
232+
) {
233+
return;
234+
}
235+
236+
// Set up refresh state
237+
setupRefreshState(fullParamsKey, {
238+
lastExecutedParams,
239+
isApiCallInProgress,
240+
});
241+
}, [
242+
address,
243+
usdRequired,
244+
destChainId,
245+
isDepositFlow,
246+
stableAppId,
247+
memoizedPreferredChains,
248+
memoizedPreferredTokens,
249+
]);
201250

202251
// Initial fetch when hook mounts with valid parameters or when key parameters change
203252
useEffect(() => {
@@ -207,14 +256,21 @@ export function useWalletPaymentOptions({
207256
destChainId != null &&
208257
stableAppId != null
209258
) {
210-
fetchBalances();
259+
refreshOptions();
211260
}
212261
// eslint-disable-next-line react-hooks/exhaustive-deps
213-
}, [address, usdRequired, destChainId, stableAppId, memoizedPreferredTokens]);
262+
}, [
263+
address,
264+
usdRequired,
265+
destChainId,
266+
stableAppId,
267+
memoizedPreferredChains,
268+
memoizedPreferredTokens,
269+
]);
214270

215271
return {
216272
options: filteredOptions,
217273
isLoading,
218-
refreshOptions: fetchBalances,
274+
refreshOptions,
219275
};
220276
}

packages/pay-common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rozoai/intent-common",
3-
"version": "0.1.7-beta.2",
3+
"version": "0.1.7",
44
"description": "Intent Pay shared types and utilities",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

pnpm-lock.yaml

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)