Skip to content

Commit 27f3f81

Browse files
feat: adjust refresh options on completed and evm wallet connector
1 parent db4e352 commit 27f3f81

File tree

17 files changed

+359
-425
lines changed

17 files changed

+359
-425
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.6-beta.3",
17-
"@rozoai/intent-pay": "0.1.5-beta.4",
16+
"@rozoai/intent-common": "workspace:*",
17+
"@rozoai/intent-pay": "workspace:*",
1818
"@tanstack/react-query": "^5.51.11",
1919
"@types/react-syntax-highlighter": "^15.5.13",
2020
"@wagmi/core": "^2.22.0",

examples/nextjs-app/src/app/basic/providers.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export function Providers(props: { children: ReactNode }) {
2020
return (
2121
<WagmiProvider config={rozoPayConfig}>
2222
<QueryClientProvider client={queryClient}>
23-
<RozoPayProvider debugMode>{props.children}</RozoPayProvider>
23+
<RozoPayProvider debugMode mode="dark">
24+
{props.children}
25+
</RozoPayProvider>
2426
</QueryClientProvider>
2527
</WagmiProvider>
2628
);

packages/connectkit/bundle-analysis.html

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

packages/connectkit/package.json

Lines changed: 1 addition & 1 deletion
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.5-beta.4",
4+
"version": "0.1.5-beta.8",
55
"author": "RozoAI",
66
"homepage": "https://github.com/RozoAI/intent-pay",
77
"license": "BSD-2-Clause",

packages/connectkit/src/assets/icons.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,27 @@ export const TickIcon = ({ ...props }) => {
141141
);
142142
};
143143

144+
export const BadgeCheckIcon = ({ ...props }) => {
145+
return (
146+
<svg
147+
xmlns="http://www.w3.org/2000/svg"
148+
width="24"
149+
height="24"
150+
viewBox="0 0 24 24"
151+
fill="none"
152+
stroke="currentColor"
153+
strokeWidth="2"
154+
strokeLinecap="round"
155+
strokeLinejoin="round"
156+
className="lucide lucide-badge-check-icon lucide-badge-check"
157+
{...props}
158+
>
159+
<path d="M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z" />
160+
<path d="m9 12 2 2 4-4" />
161+
</svg>
162+
);
163+
};
164+
144165
export const LoadingCircleIcon = ({ ...props }) => {
145166
return (
146167
<svg

packages/connectkit/src/components/Common/ConnectorList/index.tsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,25 @@ const ConnectorItem = ({
130130
const meta = { event: "connector-list-click", walletId: wallet.id };
131131

132132
// Desktop multi-chain wallet flow: prompt for chain selection.
133-
if (wallet.solanaConnectorName && !isMobile) {
134-
const supportsEvm = wallet.connector?.name != null;
135-
136-
if (supportsEvm) {
137-
context.paymentState.setSelectedWallet(wallet);
138-
context.setRoute(ROUTES.SELECT_WALLET_CHAIN, meta);
139-
return;
133+
if (!isMobile) {
134+
if (wallet.solanaConnectorName) {
135+
const supportsEvm = wallet.connector?.name != null;
136+
137+
if (supportsEvm) {
138+
context.paymentState.setSelectedWallet(wallet);
139+
context.setRoute(ROUTES.SELECT_WALLET_CHAIN, meta);
140+
return;
141+
} else {
142+
context.setSolanaConnector(wallet.solanaConnectorName);
143+
context.setRoute(ROUTES.SOLANA_CONNECTOR, meta);
144+
return;
145+
}
140146
} else {
141-
context.setSolanaConnector(wallet.solanaConnectorName);
142-
context.setRoute(ROUTES.SOLANA_CONNECTOR, meta);
147+
// EVM-only wallet: clear selectedChainId to show all available tokens
148+
context.paymentState.setSelectedChainId(undefined);
149+
context.setPendingConnectorId(wallet.id);
150+
// Explicitly set chainId to null to indicate we want all chains, not just the current one
151+
context.setRoute(ROUTES.CONNECT, { ...meta, chainId: null });
143152
return;
144153
}
145154
}

packages/connectkit/src/components/DaimoPayModal/index.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,12 @@ export const RozoPayModal: React.FC<{
324324
if (isEthConnected) {
325325
paymentState.setTokenMode("evm");
326326
// Preserve chainId from routeMeta if it exists (from SelectWalletChain),
327+
// If chainId is explicitly null, don't use fallback to current chain ID (show all chains)
327328
// otherwise use the current chain ID
328-
const chainId = context.routeMeta?.chainId ?? chain?.id;
329+
const chainId =
330+
context.routeMeta?.chainId === null
331+
? undefined
332+
: context.routeMeta?.chainId ?? chain?.id;
329333
context.setRoute(ROUTES.SELECT_TOKEN, {
330334
event: "connected",
331335
walletId: connector?.id,
@@ -339,9 +343,15 @@ export const RozoPayModal: React.FC<{
339343

340344
// Extract chainId from routeMeta when navigating to SELECT_TOKEN
341345
useEffect(() => {
342-
if (context.route === ROUTES.SELECT_TOKEN && context.routeMeta?.chainId) {
343-
const chainId = context.routeMeta.chainId as number;
344-
setSelectedChainId(chainId);
346+
if (context.route === ROUTES.SELECT_TOKEN) {
347+
// Only set selectedChainId if chainId is explicitly provided and not null/undefined
348+
if (context.routeMeta?.chainId != null) {
349+
const chainId = context.routeMeta.chainId as number;
350+
setSelectedChainId(chainId);
351+
} else {
352+
// Explicitly clear selectedChainId to show all available tokens
353+
setSelectedChainId(undefined);
354+
}
345355
} else if (
346356
context.route !== ROUTES.SELECT_TOKEN &&
347357
context.route !== ROUTES.SELECT_WALLET_CHAIN

packages/connectkit/src/components/Pages/Confirmation/index.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import {
2020
} from "@rozoai/intent-common";
2121
import { motion } from "framer-motion";
2222
import {
23+
BadgeCheckIcon,
2324
ExternalLinkIcon,
2425
LoadingCircleIcon,
25-
TickIcon,
2626
} from "../../../assets/icons";
2727
import defaultTheme from "../../../constants/defaultTheme";
2828
import {
@@ -468,8 +468,8 @@ const Confirmation: React.FC = () => {
468468
>
469469
<AnimationContainer>
470470
<InsetContainer>
471-
<Spinner $status={done} />
472-
<SuccessIcon $status={done} />
471+
{!done && <Spinner $status={done} />}
472+
{done && <SuccessIcon $status={done} />}
473473
</InsetContainer>
474474
</AnimationContainer>
475475

@@ -568,9 +568,9 @@ const AnimationContainer = styled(motion.div)`
568568
const InsetContainer = styled(motion.div)`
569569
position: absolute;
570570
overflow: hidden;
571-
inset: 6px;
571+
inset: 0;
572572
border-radius: 50px;
573-
background: var(--ck-body-background);
573+
// background: var(--ck-body-background);
574574
display: flex;
575575
align-items: center;
576576
justify-content: center;
@@ -581,12 +581,13 @@ const InsetContainer = styled(motion.div)`
581581
}
582582
`;
583583

584-
const SuccessIcon = styled(TickIcon)<{ $status: boolean }>`
585-
color: var(--ck-body-color-valid);
584+
const SuccessIcon = styled(BadgeCheckIcon)<{ $status: boolean }>`
586585
transition: all 0.2s ease-in-out;
587586
position: absolute;
588587
opacity: ${(props) => (props.$status ? 1 : 0)};
589588
transform: ${(props) => (props.$status ? "scale(1)" : "scale(0.5)")};
589+
fill: #0052ff;
590+
stroke: #ffffff;
590591
`;
591592

592593
const Spinner = styled(LoadingCircleIcon)<{ $status: boolean }>`

packages/connectkit/src/components/Pages/PayWithToken/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ enum PayState {
2828
const PayWithToken: React.FC = () => {
2929
const walletChainId = useChainId();
3030
const { triggerResize, paymentState, setRoute, log } = usePayContext();
31-
const { payWithToken, selectedTokenOption } = paymentState;
31+
const { payWithToken, selectedTokenOption, walletPaymentOptions } =
32+
paymentState;
3233
const { switchChainAsync } = useSwitchChain();
3334
const {
3435
store,
@@ -118,6 +119,10 @@ const PayWithToken: React.FC = () => {
118119
setTimeout(() => {
119120
setRoute(ROUTES.CONFIRMATION, { event: "wait-pay-with-token" });
120121
}, 200);
122+
// Refresh wallet payment options after 1 second to prevent stale balances
123+
setTimeout(() => {
124+
walletPaymentOptions.refreshOptions();
125+
}, 2000);
121126
} else {
122127
setPayState(PayState.RequestFailed);
123128
}
@@ -143,6 +148,10 @@ const PayWithToken: React.FC = () => {
143148
event: "wait-pay-with-token",
144149
});
145150
}, 200);
151+
// Refresh wallet payment options after 1 second to prevent stale balances
152+
setTimeout(() => {
153+
walletPaymentOptions.refreshOptions();
154+
}, 2000);
146155
} else {
147156
setPayState(PayState.RequestFailed);
148157
}

packages/connectkit/src/components/Pages/SelectToken/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ function InsufficientBalance({
170170
gap: 16,
171171
}}
172172
>
173-
<ModalH1>Insufficient balance.</ModalH1>
173+
<ModalH1>Insufficient balance</ModalH1>
174174
<Button
175175
variant="secondary"
176176
onClick={handleRefresh}

0 commit comments

Comments
 (0)