Skip to content

Commit

Permalink
Merge branch 'V4' into refactor/loading-state-in-useweb3modalstate-hook
Browse files Browse the repository at this point in the history
  • Loading branch information
tomiir authored Feb 29, 2024
2 parents 696032b + d612339 commit f3a8420
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/core/src/controllers/NetworkController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface NetworkControllerState {
caipNetwork?: CaipNetwork
requestedCaipNetworks?: CaipNetwork[]
approvedCaipNetworkIds?: CaipNetworkId[]
allowUnsupportedChain?: boolean
}

type StateKey = keyof NetworkControllerState
Expand Down Expand Up @@ -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']) {
Expand All @@ -69,6 +72,10 @@ export const NetworkController = {
state.requestedCaipNetworks = requestedNetworks
},

setAllowUnsupportedChain(allowUnsupportedChain: NetworkControllerState['allowUnsupportedChain']) {
state.allowUnsupportedChain = allowUnsupportedChain
},

getRequestedCaipNetworks() {
const { approvedCaipNetworkIds, requestedCaipNetworks } = state

Expand Down
5 changes: 5 additions & 0 deletions packages/scaffold/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export interface LibraryOptions {
enableAnalytics?: OptionsControllerState['enableAnalytics']
metadata?: OptionsControllerState['metadata']
enableOnramp?: OptionsControllerState['enableOnramp']
allowUnsupportedChain?: NetworkControllerState['allowUnsupportedChain']
_sdkVersion: OptionsControllerState['sdkVersion']
}

Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit f3a8420

Please sign in to comment.