Skip to content

Commit

Permalink
fix: chain dependant providers
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenixVS committed Jul 10, 2024
1 parent a3cf4b9 commit 23cd2a8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ dist
node_modules
.DS_Store
.env
.env.production
.idea
.next
out
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/controllers/OnRampController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type OnRampProvider = {
name: OnRampProviderOption
feeRange: string
url: string
supportedChains: string[]
}

export interface OnRampControllerState {
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/utils/ConstantsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ export const ONRAMP_PROVIDERS = [
label: 'Coinbase',
name: 'coinbase',
feeRange: '1-2%',
url: ''
url: '',
supportedChains: ['evm']
},
{
label: 'Meld.io',
name: 'meld',
feeRange: '1-2%',
url: 'https://meldcrypto.com/?publicKey=WXETMsajb7XcQBm7mcxAab:q3MtzJpiEMtXVNXsqYkAnAaBkgStybGVtZ'
url: 'https://meldcrypto.com/?publicKey=WXETMsajb7XcQBm7mcxAab:q3MtzJpiEMtXVNXsqYkAnAaBkgStybGVtZ',
supportedChains: ['evm', 'solana']
}
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
RouterController,
NetworkController,
BlockchainApiController,
EventsController
EventsController,
ChainController
} from '@web3modal/core'
import { customElement } from '@web3modal/ui'
import { LitElement, html } from 'lit'
Expand Down Expand Up @@ -61,15 +62,15 @@ export class W3mOnRampProvidersView extends LitElement {

// -- Private ------------------------------------------- //
private onRampProvidersTemplate() {
return this.providers.map(
return this.providers.filter(provider => provider.supportedChains.includes(ChainController.state.activeChain ?? 'evm')).map(
provider => html`
<w3m-onramp-provider-item
label=${provider.label}
name=${provider.name}
feeRange=${provider.feeRange}
@click=${() => {
this.onClickProvider(provider)
}}
this.onClickProvider(provider)
}}
?disabled=${!provider.url}
></w3m-onramp-provider-item>
`
Expand Down Expand Up @@ -106,7 +107,7 @@ export class W3mOnRampProvidersView extends LitElement {

const defaultNetwork =
ConstantsUtil.WC_COINBASE_PAY_SDK_CHAIN_NAME_MAP[
network.name as CoinbasePaySDKChainNameValues
network.name as CoinbasePaySDKChainNameValues
] ?? ConstantsUtil.WC_COINBASE_PAY_SDK_FALLBACK_CHAIN

const purchaseCurrency = OnRampController.state.purchaseCurrency
Expand Down

0 comments on commit 23cd2a8

Please sign in to comment.