Skip to content
This repository was archived by the owner on Feb 12, 2026. It is now read-only.

Commit ebb2d38

Browse files
fix: update selected rpc info if rpc setting is changed & fix bottom padding of transaction body
fix: update selected rpc info if rpc setting is changed & fix bottom padding of transaction body
1 parent 2f93223 commit ebb2d38

6 files changed

Lines changed: 57 additions & 27 deletions

File tree

src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const App: React.FC = () => {
4242
<Header />
4343
</Box>
4444

45-
<Flex mt="45px" h="94vh">
45+
<Flex mt="45px" pb="10px" h="calc(100vh - 60px)">
4646
<Box flex="2" overflow="scroll">
4747
{/* TODO it's Solana wallet button's fault, we need to replace it */}
4848
<Show below="md">

src/components/client/TransactionHeader.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
Tooltip,
1717
} from "@chakra-ui/react";
1818
import { useWallet } from "@solana/wallet-adapter-react";
19-
import React from "react";
19+
import React, { useEffect } from "react";
2020
import {
2121
FaCompress,
2222
FaEllipsisV,
@@ -26,7 +26,10 @@ import {
2626
FaPlay,
2727
FaShareAlt,
2828
} from "react-icons/fa";
29-
import { usePersistentStore } from "../../hooks/usePersistentStore";
29+
import {
30+
usePersistentStore,
31+
useShallowPersistentStore,
32+
} from "../../hooks/usePersistentStore";
3033
import { useSendWeb3Transaction } from "../../hooks/useSendWeb3Transaction";
3134
import {
3235
useShallowSessionStoreWithoutUndo,
@@ -49,6 +52,9 @@ export const TransactionHeader: React.FC<{
4952
const [transaction, rpcEndpoint, setSession] = useShallowSessionStoreWithUndo(
5053
(state) => [state.transaction, state.rpcEndpoint, state.set]
5154
);
55+
const rpcEndpoints = useShallowPersistentStore(
56+
(state) => state.appOptions.rpcEndpoints
57+
);
5258

5359
const { publicKey: walletPublicKey } = useWallet();
5460
const { send } = useSendWeb3Transaction({
@@ -86,6 +92,15 @@ export const TransactionHeader: React.FC<{
8692
});
8793
};
8894

95+
useEffect(() => {
96+
// when rpc endpoints setting change, update the current selected rpc
97+
if (rpcEndpoints.map.hasOwnProperty(rpcEndpoint.id)) {
98+
setSession((state) => {
99+
state.rpcEndpoint = rpcEndpoints.map[rpcEndpoint.id];
100+
});
101+
}
102+
}, [rpcEndpoints, rpcEndpoint, setSession]);
103+
89104
return (
90105
<>
91106
<Flex alignItems="center">

src/components/common/RpcEndpointMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const RpcEndpointMenu: React.FC<{
3333
);
3434

3535
return (
36-
<Menu>
36+
<Menu matchWidth={true}>
3737
<Tooltip label={endpoint.url}>
3838
<MenuButton
3939
as={Button}

src/components/options/fields/ChoiceOption.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const ChoiceOption: React.FC<{
2020
<FormLabel htmlFor={id} textAlign="right">
2121
{name}
2222
</FormLabel>
23-
<Menu id={id}>
23+
<Menu id={id} matchWidth={true}>
2424
<MenuButton as={Button} rightIcon={<ChevronDownIcon />}>
2525
{get().name}
2626
</MenuButton>

src/components/options/fields/RpcEndpointOption.tsx

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
import { DeleteIcon } from "@chakra-ui/icons";
1+
import { CheckIcon, ChevronDownIcon, DeleteIcon } from "@chakra-ui/icons";
22
import {
3+
Button,
34
Flex,
45
Grid,
56
Icon,
67
IconButton,
78
Input,
8-
Select,
9+
Menu,
10+
MenuButton,
11+
MenuItem,
12+
MenuList,
13+
Portal,
914
Tooltip,
1015
} from "@chakra-ui/react";
1116
import { WritableDraft } from "immer/dist/internal";
1217
import React, { useEffect, useState } from "react";
1318
import { FaEye, FaEyeSlash } from "react-icons/fa";
1419
import { usePersistentStore } from "../../../hooks/usePersistentStore";
15-
import { INetwork, IRpcEndpoint } from "../../../types/internal";
20+
import { IRpcEndpoint } from "../../../types/internal";
1621
import { removeFrom } from "../../../utils/sortable";
1722
import { RPC_NETWORK_OPTIONS } from "../../../utils/state";
1823
import { DragHandle } from "../../common/DragHandle";
@@ -78,24 +83,34 @@ export const RpcEndpointOption: React.FC<IRpcEndpoint> = ({
7883
}
7984
>
8085
<Flex mb="1">
81-
<Select
82-
minW="150px"
83-
maxW="130px"
84-
mr="1"
85-
isDisabled={!custom}
86-
value={network}
87-
onChange={(e) =>
88-
updateEndpoint((state) => {
89-
state.network = e.target.value as INetwork;
90-
})
91-
}
92-
>
93-
{RPC_NETWORK_OPTIONS.map((n) => (
94-
<option key={n} value={n}>
95-
{n}
96-
</option>
97-
))}
98-
</Select>
86+
<Menu>
87+
<MenuButton
88+
rightIcon={<ChevronDownIcon />}
89+
minW="150px"
90+
as={Button}
91+
disabled={!custom}
92+
mr="1"
93+
>
94+
{network}
95+
</MenuButton>
96+
<Portal>
97+
<MenuList minW="150px" mr="1" zIndex="modal">
98+
{RPC_NETWORK_OPTIONS.map((n) => (
99+
<MenuItem
100+
icon={network === n ? <CheckIcon /> : undefined}
101+
key={n}
102+
onClick={() => {
103+
updateEndpoint((state) => {
104+
state.network = n;
105+
});
106+
}}
107+
>
108+
{n}
109+
</MenuItem>
110+
))}
111+
</MenuList>
112+
</Portal>
113+
</Menu>
99114
<Input
100115
flex="1"
101116
mr="1"

src/components/palette/ImportTransaction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const ImportTransaction: React.FC = () => {
3535
return (
3636
<Grid>
3737
<Flex mb="1">
38-
<Menu>
38+
<Menu matchWidth={true}>
3939
<MenuButton flex="1" as={Button} size="sm">
4040
{IMPORT_TYPES[importType]} <ChevronDownIcon />
4141
</MenuButton>

0 commit comments

Comments
 (0)