diff --git a/packages/core/src/controllers/NetworkController.ts b/packages/core/src/controllers/NetworkController.ts index 5d711d689c..1aa13df2e9 100644 --- a/packages/core/src/controllers/NetworkController.ts +++ b/packages/core/src/controllers/NetworkController.ts @@ -23,6 +23,7 @@ export interface NetworkControllerState { caipNetwork?: CaipNetwork requestedCaipNetworks?: CaipNetwork[] approvedCaipNetworkIds?: CaipNetworkId[] + allowUnsupportedChain?: boolean } type StateKey = keyof NetworkControllerState @@ -56,7 +57,9 @@ export const NetworkController = { setCaipNetwork(caipNetwork: NetworkControllerState['caipNetwork']) { state.caipNetwork = caipNetwork PublicStateController.set({ selectedNetworkId: caipNetwork?.id }) - this.checkIfSupportedNetwork() + if (!this.state.allowUnsupportedChain) { + this.checkIfSupportedNetwork() + } }, setDefaultCaipNetwork(caipNetwork: NetworkControllerState['caipNetwork']) { @@ -69,6 +72,10 @@ export const NetworkController = { state.requestedCaipNetworks = requestedNetworks }, + setAllowUnsupportedChain(allowUnsupportedChain: NetworkControllerState['allowUnsupportedChain']) { + state.allowUnsupportedChain = allowUnsupportedChain + }, + getRequestedCaipNetworks() { const { approvedCaipNetworkIds, requestedCaipNetworks } = state diff --git a/packages/scaffold/src/client.ts b/packages/scaffold/src/client.ts index 502821f2d8..90862e2424 100644 --- a/packages/scaffold/src/client.ts +++ b/packages/scaffold/src/client.ts @@ -47,6 +47,7 @@ export interface LibraryOptions { enableAnalytics?: OptionsControllerState['enableAnalytics'] metadata?: OptionsControllerState['metadata'] enableOnramp?: OptionsControllerState['enableOnramp'] + allowUnsupportedChain?: NetworkControllerState['allowUnsupportedChain'] _sdkVersion: OptionsControllerState['sdkVersion'] } @@ -236,6 +237,10 @@ export class Web3ModalScaffold { if (options.enableOnramp) { OptionsController.setOnrampEnabled(Boolean(options.enableOnramp)) } + + if (options.allowUnsupportedChain) { + NetworkController.setAllowUnsupportedChain(options.allowUnsupportedChain) + } } private async initOrContinue() {