Skip to content

Commit

Permalink
chore: use walletconnect.org (#2360)
Browse files Browse the repository at this point in the history
Co-authored-by: Enes <[email protected]>
  • Loading branch information
tomiir and enesozturk authored Jun 10, 2024
1 parent c3f5e74 commit 7317367
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 56 deletions.
2 changes: 1 addition & 1 deletion apps/laboratory/src/utils/ChainsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const solana = {
name: 'Solana',
currency: 'SOL',
explorerUrl: 'https://solscan.io',
rpcUrl: 'https://rpc.walletconnect.com/v1'
rpcUrl: 'https://rpc.walletconnect.org/v1'
}

export const solanaTestnet = {
Expand Down
4 changes: 1 addition & 3 deletions apps/laboratory/src/utils/SignatureUtil.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { createPublicClient, http } from 'viem'

function getTransport({ chainId }: { chainId: number }) {
const RPC_URL = 'https://rpc.walletconnect.com'

return http(
`${RPC_URL}/v1/?chainId=eip155:${chainId}&projectId=${process.env['NEXT_PUBLIC_PROJECT_ID']}`
`https://rpc.walletconnect.org/v1/?chainId=eip155:${chainId}&projectId=${process.env['NEXT_PUBLIC_PROJECT_ID']}`
)
}

Expand Down
5 changes: 4 additions & 1 deletion packages/common/src/utils/ConstantsUtil.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export const ConstantsUtil = {
WC_NAME_SUFFIX: '.wcn.id',
WC_NAMES_ALLOWED_DOMAINS: ['walletconnect.com']
WC_NAMES_ALLOWED_DOMAINS: ['walletconnect.com'],
BLOCKCHAIN_API_RPC_URL: 'https://rpc.walletconnect.org',
PULSE_API_URL: 'https://pulse.walletconnect.org',
W3M_API_URL: 'https://api.web3modal.org'
}
24 changes: 4 additions & 20 deletions packages/core/src/utils/CoreHelperUtil.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Balance } from '@web3modal/common'
import { ConstantsUtil as CommonConstants } from '@web3modal/common'
import { ConstantsUtil } from './ConstantsUtil.js'
import type { CaipAddress, LinkingRecord, CaipNetwork } from './TypeUtil.js'

Expand Down Expand Up @@ -174,33 +175,16 @@ export const CoreHelperUtil = {
}
},

isRestrictedRegion() {
try {
const { timeZone } = new Intl.DateTimeFormat().resolvedOptions()
const capTimeZone = timeZone.toUpperCase()

return ConstantsUtil.RESTRICTED_TIMEZONES.includes(capTimeZone)
} catch {
return false
}
},

getApiUrl() {
return CoreHelperUtil.isRestrictedRegion()
? 'https://api.web3modal.org'
: 'https://api.web3modal.com'
return CommonConstants.W3M_API_URL
},

getBlockchainApiUrl() {
return CoreHelperUtil.isRestrictedRegion()
? 'https://rpc.walletconnect.org'
: 'https://rpc.walletconnect.com'
return CommonConstants.BLOCKCHAIN_API_RPC_URL
},

getAnalyticsUrl() {
return CoreHelperUtil.isRestrictedRegion()
? 'https://pulse.walletconnect.org'
: 'https://pulse.walletconnect.com'
return CommonConstants.PULSE_API_URL
},

getUUID() {
Expand Down
2 changes: 1 addition & 1 deletion packages/solana/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export class Web3Modal extends Web3ModalScaffold {

this.walletAdapters = createWalletAdapters(chain?.chainId)
this.WalletConnectConnector = new WalletConnectConnector({
relayerRegion: 'wss://relay.walletconnect.com',
relayerRegion: 'wss://relay.walletconnect.org',
metadata,
chains,
qrcode: true
Expand Down
4 changes: 3 additions & 1 deletion packages/solana/src/utils/chains.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { ConstantsUtil } from '@web3modal/common'

export const solana = {
chainId: '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
name: 'Solana',
currency: 'SOL',
explorerUrl: 'https://solscan.io',
rpcUrl: 'https://rpc.walletconnect.com/v1'
rpcUrl: `${ConstantsUtil.BLOCKCHAIN_API_RPC_URL}/v1`
}

export const solanaTestnet = {
Expand Down
3 changes: 2 additions & 1 deletion packages/solana/src/utils/scaffold/SolanaConstantsUtil.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PublicKey } from '@solana/web3.js'
import { ConstantsUtil } from '@web3modal/common'

/**
* Request methods to the solana RPC.
Expand Down Expand Up @@ -30,6 +31,6 @@ export const SolConstantsUtil = {
name: 'Solana',
currency: 'SOL',
explorerUrl: 'https://solscan.io',
rpcUrl: 'https://rpc.walletconnect.com/v1'
rpcUrl: `${ConstantsUtil.BLOCKCHAIN_API_RPC_URL}/v1`
}
}
3 changes: 2 additions & 1 deletion packages/solana/src/utils/scaffold/SolanaHelpersUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PresetsUtil } from '@web3modal/scaffold-utils'
import { ConstantsUtil } from '@web3modal/common'

import { SolConstantsUtil } from './SolanaConstantsUtil.js'

Expand All @@ -7,7 +8,7 @@ import type { Chain, Provider } from './SolanaTypesUtil.js'

export const SolHelpersUtil = {
detectRpcUrl(chain: Chain, projectId: string) {
if (chain.rpcUrl.includes('rpc.walletconnect.com/')) {
if (chain.rpcUrl.includes(new URL(ConstantsUtil.BLOCKCHAIN_API_RPC_URL).hostname)) {
return `${chain.rpcUrl}?chainId=solana:${chain.chainId}&projectId=${projectId}`
}

Expand Down
3 changes: 2 additions & 1 deletion packages/wallet/src/W3mFrame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import { SECURE_SITE_SDK, W3mFrameConstants } from './W3mFrameConstants.js'
import { W3mFrameSchema } from './W3mFrameSchema.js'
import { W3mFrameHelpers } from './W3mFrameHelpers.js'
import type { W3mFrameTypes } from './W3mFrameTypes.js'
import { ConstantsUtil } from '@web3modal/common'

// -- Sdk --------------------------------------------------------------------
export class W3mFrame {
private iframe: HTMLIFrameElement | null = null

private projectId: string

private rpcUrl = W3mFrameHelpers.getBlockchainApiUrl()
private rpcUrl = ConstantsUtil.BLOCKCHAIN_API_RPC_URL

public frameLoadPromise: Promise<void>

Expand Down
26 changes: 0 additions & 26 deletions packages/wallet/src/W3mFrameHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,9 @@ import {
import type { W3mFrameTypes } from './W3mFrameTypes.js'
import { RegexUtil } from './RegexUtil.js'

const RESTRICTED_TIMEZONES = [
'ASIA/SHANGHAI',
'ASIA/URUMQI',
'ASIA/CHONGQING',
'ASIA/HARBIN',
'ASIA/KASHGAR',
'ASIA/MACAU',
'ASIA/HONG_KONG',
'ASIA/MACAO',
'ASIA/BEIJING',
'ASIA/HARBIN'
]

const EMAIL_MINIMUM_TIMEOUT = 30 * 1000

export const W3mFrameHelpers = {
getBlockchainApiUrl() {
try {
const { timeZone } = new Intl.DateTimeFormat().resolvedOptions()
const capTimeZone = timeZone.toUpperCase()

return RESTRICTED_TIMEZONES.includes(capTimeZone)
? 'https://rpc.walletconnect.org'
: 'https://rpc.walletconnect.com'
} catch {
return false
}
},

checkIfAllowedToTriggerEmail() {
const lastEmailLoginTime = W3mFrameStorage.get(W3mFrameConstants.LAST_EMAIL_LOGIN_TIME)
if (lastEmailLoginTime) {
Expand Down

0 comments on commit 7317367

Please sign in to comment.