Skip to content

Commit

Permalink
Fix onboarding for custom RPCs (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentine1898 authored Jun 28, 2024
1 parent 8b5a177 commit 6b0cd40
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const SetGrpcEndpoint = () => {
</CardHeader>

<div className='mt-6'>
<GrpcEndpointForm submitButtonLabel='Next' onSuccess={onSuccess} />
<GrpcEndpointForm submitButtonLabel='Next' isOnboarding={true} onSuccess={onSuccess} />
</div>
</Card>
</FadeTransition>
Expand Down
6 changes: 5 additions & 1 deletion apps/extension/src/routes/popup/settings/settings-rpc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ export const SettingsRPC = () => {

return (
<SettingsScreen title='RPC' IconComponent={ShareGradientIcon}>
<GrpcEndpointForm submitButtonLabel={submitButtonLabel} onSuccess={onSuccess} />
<GrpcEndpointForm
submitButtonLabel={submitButtonLabel}
isOnboarding={false}
onSuccess={onSuccess}
/>
</SettingsScreen>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import { ChainIdOrError } from './chain-id-or-error';
*/
export const GrpcEndpointForm = ({
submitButtonLabel,
isOnboarding,
onSuccess,
}: {
submitButtonLabel: string;
isOnboarding: boolean;
onSuccess: () => void | Promise<void>;
}) => {
const {
Expand All @@ -30,7 +32,7 @@ export const GrpcEndpointForm = ({
isSubmitButtonEnabled,
isCustomGrpcEndpoint,
isValidationLoading,
} = useGrpcEndpointForm();
} = useGrpcEndpointForm(isOnboarding);
const customGrpcEndpointInput = useRef<HTMLInputElement | null>(null);

const handleSubmit = (e: FormEvent<HTMLFormElement>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const getRpcsFromRegistry = () => {
return rpcs.toSorted(randomSort);
};

export const useGrpcEndpointForm = () => {
export const useGrpcEndpointForm = (isOnboarding: boolean) => {
const grpcEndpoints = useMemo(() => getRpcsFromRegistry(), []);

// Get the rpc set in storage (if present)
Expand Down Expand Up @@ -105,7 +105,7 @@ export const useGrpcEndpointForm = () => {
setIsSubmitButtonEnabled(false);

// If the chain id has changed, our cache is invalid
if (chainIdChanged) {
if (!isOnboarding && chainIdChanged) {
const promiseWithResolvers = Promise.withResolvers<void>();
setConfirmChangedChainIdPromise(promiseWithResolvers);

Expand Down

0 comments on commit 6b0cd40

Please sign in to comment.