Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix onboarding for custom RPCs #70

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading