Skip to content

Commit 647fd63

Browse files
committed
feat: update default rpc
1 parent 99637d8 commit 647fd63

4 files changed

Lines changed: 32 additions & 5 deletions

File tree

‎anchor-counter/app/src/App.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const App: React.FC = () => {
4444
return params.get('mode') === 'private';
4545
});
4646
const [isInitializingEr, setIsInitializingEr] = useState<boolean>(false);
47+
const [isLoading, setIsLoading] = useState<boolean>(true);
4748
const counterProgramClient = useRef<Program | null>(null);
4849
const counterSubscriptionId = useRef<number | null>(null);
4950
const ephemeralCounterSubscriptionId = useRef<number | null>(null);
@@ -132,6 +133,7 @@ const App: React.FC = () => {
132133
setCounter(0);
133134
setEphemeralCounter(0);
134135
setIsDelegated(false);
136+
setIsLoading(true);
135137
};
136138
// eslint-disable-next-line react-hooks/exhaustive-deps
137139
}, [isPrivate]);
@@ -154,6 +156,7 @@ const App: React.FC = () => {
154156
setIsDelegated(!accountInfo.owner.equals(COUNTER_PROGRAM));
155157
await subscribeToCounter();
156158
}
159+
setIsLoading(false);
157160
}
158161

159162
// 2. ER connection (skip if already initialized or program client missing)
@@ -462,6 +465,7 @@ const App: React.FC = () => {
462465
ind={Number(0)}
463466
updateSquares={(index: string | number) => updateCounter(Number(index))}
464467
clsName={isDelegated ? '' : counter.toString()}
468+
loading={isLoading}
465469
/>
466470
<Square
467471
key="1"
@@ -474,6 +478,7 @@ const App: React.FC = () => {
474478
<div className="placeholder-hint">click to count</div>
475479
</>
476480
) : undefined}
481+
loading={isLoading}
477482
/>
478483
</div>
479484

‎anchor-counter/app/src/components/Square.tsx‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,32 @@ type SquareProps = {
77
updateSquares?: (index: number | string) => void;
88
clsName?: string;
99
placeholder?: React.ReactNode;
10+
loading?: boolean;
1011
};
1112

12-
const Square: React.FC<SquareProps> = ({ ind, updateSquares, clsName, placeholder }) => {
13+
const Square: React.FC<SquareProps> = ({ ind, updateSquares, clsName, placeholder, loading }) => {
1314
const handleClick = () => {
15+
if (loading) return;
1416
if (updateSquares && ind !== undefined) {
1517
updateSquares(ind);
1618
}
1719
};
18-
const showPlaceholder = !clsName && !!placeholder;
20+
const showPlaceholder = !loading && !clsName && !!placeholder;
21+
const classes = [
22+
'square',
23+
showPlaceholder ? 'square-placeholder' : '',
24+
loading ? 'square-loading' : '',
25+
].filter(Boolean).join(' ');
1926
return (
2027
<motion.div
2128
initial={{ scale: 0 }}
2229
animate={{ scale: 1 }}
23-
className={`square${showPlaceholder ? ' square-placeholder' : ''}`}
30+
className={classes}
2431
onClick={handleClick}
2532
>
26-
{clsName ? (
33+
{loading ? (
34+
<div className="square-spinner" aria-label="loading" />
35+
) : clsName ? (
2736
<motion.span
2837
initial={{ scale: 0 }}
2938
animate={{ scale: 1 }}

‎anchor-counter/app/src/components/Wallet.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class SimpleProvider implements Provider {
2525
}
2626

2727
export const Wallet: FC<WalletProps> = ({ app }) => {
28-
const endpoint = process.env.REACT_APP_PROVIDER_ENDPOINT || "https://rpc.magicblock.app/devnet"
28+
const endpoint = process.env.REACT_APP_PROVIDER_ENDPOINT || "https://api.devnet.solana.com"
2929

3030
const wallets = useMemo(() => [
3131
new PhantomWalletAdapter(),

‎anchor-counter/app/src/index.css‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,19 @@ body {
8787
transform: scale(1.03);
8888
}
8989

90+
.square.square-loading {
91+
cursor: default;
92+
}
93+
94+
.square .square-spinner {
95+
width: 28px;
96+
height: 28px;
97+
border: 3px solid rgba(238, 238, 238, 0.15);
98+
border-radius: 50%;
99+
border-left-color: rgba(238, 238, 238, 0.7);
100+
animation: spin 1s linear infinite;
101+
}
102+
90103
.square .placeholder {
91104
display: flex;
92105
flex-direction: column;

0 commit comments

Comments
 (0)