From a27df69fd352c9dd8bd25ca704b91580ba0eb017 Mon Sep 17 00:00:00 2001 From: enesozturk Date: Wed, 3 Jan 2024 19:27:00 +0300 Subject: [PATCH] chore: update cbpay configs --- packages/core/src/utils/ConstantsUtil.ts | 9 +++++++++ .../src/views/w3m-onramp-providers-view/index.ts | 11 +++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/core/src/utils/ConstantsUtil.ts b/packages/core/src/utils/ConstantsUtil.ts index f837937c20..d29926cb33 100644 --- a/packages/core/src/utils/ConstantsUtil.ts +++ b/packages/core/src/utils/ConstantsUtil.ts @@ -42,6 +42,15 @@ export const ConstantsUtil = { * Network name to Coinbase Pay SDK chain name map object * @see supported chain names on Coinbase for Pay SDK: https://github.com/coinbase/cbpay-js/blob/d4bda2c05c4d5917c8db6a05476b603546046394/src/types/onramp.ts */ + WC_COINBASE_PAY_SDK_CHAINS: [ + 'ethereum', + 'arbitrum', + 'polygon', + 'avalanche-c-chain', + 'optimism', + 'celo' + ], + WC_COINBASE_PAY_SDK_CHAIN_NAME_MAP: { Ethereum: 'ethereum', 'Arbitrum One': 'arbitrum', diff --git a/packages/scaffold/src/views/w3m-onramp-providers-view/index.ts b/packages/scaffold/src/views/w3m-onramp-providers-view/index.ts index 6c1cc8cb18..b201932d3d 100644 --- a/packages/scaffold/src/views/w3m-onramp-providers-view/index.ts +++ b/packages/scaffold/src/views/w3m-onramp-providers-view/index.ts @@ -4,7 +4,8 @@ import { ConstantsUtil, OnRampController, type OnRampProvider, - RouterController + RouterController, + NetworkController } from '@web3modal/core' import { customElement } from '@web3modal/ui' import { LitElement, html } from 'lit' @@ -68,15 +69,21 @@ export class W3mOnRampProvidersView extends LitElement { private getCoinbaseOnRampURL() { const address = AccountController.state.address + const network = NetworkController.state.caipNetwork if (!address) { throw new Error('No address found') } + if (!network) { + throw new Error('No network found') + } + return generateOnRampURL({ appId: ConstantsUtil.WC_COINBASE_ONRAMP_APP_ID, + defaultNetwork: network.name, destinationWallets: [ - { address, blockchains: ['ethereum', 'avalanche-c-chain', 'polygon'], assets: ['USDC'] } + { address, blockchains: ConstantsUtil.WC_COINBASE_PAY_SDK_CHAINS, assets: ['USDC'] } ], partnerUserId: address })