Skip to content

Commit 07a879d

Browse files
committed
update chain selectors
1 parent 0d7728e commit 07a879d

File tree

3 files changed

+66
-22
lines changed

3 files changed

+66
-22
lines changed

apps/dashboard/src/@/components/blocks/NetworkSelectors.tsx

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,18 @@ export function MultiNetworkSelector(props: {
2929
client: ThirdwebClient;
3030
chainIds?: number[];
3131
}) {
32-
let { allChains, idToChain } = useAllChainsData();
33-
34-
if (props.chainIds && props.chainIds.length > 0) {
35-
allChains = allChains.filter((chain) =>
36-
props.chainIds?.includes(chain.chainId),
37-
);
38-
}
32+
const { allChains, idToChain } = useAllChainsData();
3933

4034
const options = useMemo(() => {
41-
let sortedChains = allChains;
35+
let chains = allChains.filter((chain) => chain.status !== "deprecated");
36+
37+
if (props.chainIds && props.chainIds.length > 0) {
38+
chains = allChains.filter((chain) =>
39+
props.chainIds?.includes(chain.chainId),
40+
);
41+
}
42+
43+
let sortedChains = chains;
4244

4345
if (props.priorityChains) {
4446
const priorityChainsSet = new Set();
@@ -69,7 +71,13 @@ export function MultiNetworkSelector(props: {
6971
value: String(chain.chainId),
7072
};
7173
});
72-
}, [allChains, props.priorityChains, idToChain, props.hideTestnets]);
74+
}, [
75+
allChains,
76+
props.priorityChains,
77+
idToChain,
78+
props.hideTestnets,
79+
props.chainIds,
80+
]);
7381

7482
const searchFn = useCallback(
7583
(option: Option, searchValue: string) => {
@@ -155,16 +163,38 @@ export function SingleNetworkSelector(props: {
155163
disableDeprecated?: boolean;
156164
placeholder?: string;
157165
client: ThirdwebClient;
166+
priorityChains?: number[];
158167
}) {
159168
const { allChains, idToChain } = useAllChainsData();
160169

161170
const chainsToShow = useMemo(() => {
162171
let chains = allChains;
163172

173+
chains = chains.filter((chain) => chain.status !== "deprecated");
174+
164175
if (props.disableTestnets) {
165176
chains = chains.filter((chain) => !chain.testnet);
166177
}
167178

179+
if (props.priorityChains) {
180+
const priorityChainsSet = new Set();
181+
for (const chainId of props.priorityChains || []) {
182+
priorityChainsSet.add(chainId);
183+
}
184+
185+
const priorityChains = (props.priorityChains || [])
186+
.map((chainId) => {
187+
return idToChain.get(chainId);
188+
})
189+
.filter((v) => !!v);
190+
191+
const otherChains = allChains.filter(
192+
(chain) => !priorityChainsSet.has(chain.chainId),
193+
);
194+
195+
chains = [...priorityChains, ...otherChains];
196+
}
197+
168198
if (props.chainIds) {
169199
const chainIdSet = new Set(props.chainIds);
170200
chains = chains.filter((chain) => chainIdSet.has(chain.chainId));
@@ -180,6 +210,8 @@ export function SingleNetworkSelector(props: {
180210
props.chainIds,
181211
props.disableTestnets,
182212
props.disableDeprecated,
213+
props.priorityChains,
214+
idToChain,
183215
]);
184216

185217
const options = useMemo(() => {

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/distribution/token-distribution.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function TokenDistributionFieldset(props: {
5050
title="Coin Distribution"
5151
>
5252
<div>
53-
<div className="space-y-6 p-4 md:px-6 md:py-6">
53+
<div className="p-4 md:px-6 md:py-6">
5454
<FormFieldSetup
5555
errorMessage={form.formState.errors.supply?.message}
5656
htmlFor={supplyId}
@@ -65,18 +65,6 @@ export function TokenDistributionFieldset(props: {
6565
</span>
6666
</div>
6767
</FormFieldSetup>
68-
69-
<div className="flex flex-col gap-3">
70-
<TokenDistributionBarChart
71-
distributionFormValues={form.watch()}
72-
/>
73-
74-
{distributionError && (
75-
<div className="text-destructive-text text-sm">
76-
{distributionError}
77-
</div>
78-
)}
79-
</div>
8068
</div>
8169

8270
<TokenSaleSection
@@ -86,6 +74,18 @@ export function TokenDistributionFieldset(props: {
8674
/>
8775

8876
<TokenAirdropSection client={props.client} form={form} />
77+
78+
<div className="flex flex-col gap-3 p-4 py-6 md:px-6 md:py-6 border-t border-dashed">
79+
<TokenDistributionBarChart
80+
distributionFormValues={form.watch()}
81+
/>
82+
83+
{distributionError && (
84+
<div className="text-destructive-text text-sm">
85+
{distributionError}
86+
</div>
87+
)}
88+
</div>
8989
</div>
9090
</StepCard>
9191
</form>

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/token-info/token-info-fieldset.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@ export function TokenInfoFieldset(props: {
9797
>
9898
<ClientOnly ssr={<Skeleton className="h-10" />}>
9999
<SingleNetworkSelector
100+
priorityChains={[
101+
8453, // base
102+
84532, // base sepolia
103+
1, // ethereum
104+
56, // bnb smart chain mainnet (bsc)
105+
42161, // arbitrum one mainnet
106+
43114, // avalanche mainnet
107+
146, // sonic
108+
137, // polygon
109+
80094, // berachain mainnet
110+
10, // optimism
111+
]}
100112
chainId={Number(form.watch("chain"))}
101113
className="bg-background"
102114
client={props.client}

0 commit comments

Comments
 (0)