Skip to content

Commit

Permalink
Merge branch 'V4' into fix/relay-region
Browse files Browse the repository at this point in the history
  • Loading branch information
tomiir authored Jun 11, 2024
2 parents 820a21b + 9eae98e commit 89d89be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/core/src/controllers/OptionsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface OptionsControllerState {
metadata?: Metadata
enableOnramp?: boolean
enableWalletFeatures?: boolean
disableAppend?: boolean
}

type StateKey = keyof OptionsControllerState
Expand Down Expand Up @@ -99,6 +100,10 @@ export const OptionsController = {
state.enableWalletFeatures = enableWalletFeatures
},

setDisableAppend(disableAppend: OptionsControllerState['disableAppend']) {
state.disableAppend = disableAppend
},

getSnapshot() {
return snapshot(state)
}
Expand Down
9 changes: 8 additions & 1 deletion packages/scaffold/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface LibraryOptions {
metadata?: OptionsControllerState['metadata']
enableOnramp?: OptionsControllerState['enableOnramp']
enableWalletFeatures?: OptionsControllerState['enableWalletFeatures']
disableAppend?: OptionsControllerState['disableAppend']
allowUnsupportedChain?: NetworkControllerState['allowUnsupportedChain']
_sdkVersion: OptionsControllerState['sdkVersion']
}
Expand Down Expand Up @@ -307,6 +308,10 @@ export class Web3ModalScaffold {
OptionsController.setWalletFeaturesEnabled(Boolean(options.enableWalletFeatures))
}

if (options.disableAppend) {
OptionsController.setDisableAppend(Boolean(options.disableAppend))
}

if (options.allowUnsupportedChain) {
NetworkController.setAllowUnsupportedChain(options.allowUnsupportedChain)
}
Expand All @@ -326,7 +331,9 @@ export class Web3ModalScaffold {
this.initPromise = new Promise<void>(async resolve => {
await Promise.all([import('@web3modal/ui'), import('./modal/w3m-modal/index.js')])
const modal = document.createElement('w3m-modal')
document.body.insertAdjacentElement('beforeend', modal)
if (!OptionsController.state.disableAppend) {
document.body.insertAdjacentElement('beforeend', modal)
}
resolve()
})
}
Expand Down

0 comments on commit 89d89be

Please sign in to comment.