Skip to content

Commit

Permalink
Merge branch 'main' into refactor/solana-network-syncing
Browse files Browse the repository at this point in the history
  • Loading branch information
zoruka authored Sep 18, 2024
2 parents 276e6b4 + ee2c818 commit 484cefa
Show file tree
Hide file tree
Showing 14 changed files with 215 additions and 588 deletions.
1 change: 0 additions & 1 deletion apps/laboratory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
"@tanstack/react-query": "5.24.8",
"@wagmi/connectors": "5.1.9",
"@wagmi/core": "2.13.4",
"@walletconnect/ethereum-provider": "2.16.1",
"@walletconnect/universal-provider": "2.16.1",
"@walletconnect/utils": "2.16.1",
"@reown/appkit": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
useAppKitProvider,
type Provider
} from '@reown/appkit/react'
import { EthereumProvider } from '@walletconnect/ethereum-provider'
import { UniversalProvider } from '@walletconnect/universal-provider'
import { useChakraToast } from '../Toast'
import { ethers } from 'ethers5'
import { W3mFrameProvider } from '@reown/appkit-wallet'
Expand Down Expand Up @@ -59,9 +59,9 @@ export function Ethers5GetCallsStatusTest() {
if (walletProvider instanceof W3mFrameProvider) {
return true
}
if (walletProvider instanceof EthereumProvider) {
if (walletProvider instanceof UniversalProvider) {
return Boolean(
walletProvider?.signer?.session?.namespaces?.['eip155']?.methods?.includes(
walletProvider?.session?.namespaces?.['eip155']?.methods?.includes(
EIP_5792_RPC_METHODS.WALLET_GET_CALLS_STATUS
)
)
Expand Down
6 changes: 3 additions & 3 deletions apps/laboratory/src/components/Ethers/Ethers5ModalInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'
import { useAppKitAccount, useAppKitNetwork, useAppKitProvider } from '@reown/appkit/react'
import EthereumProvider from '@walletconnect/ethereum-provider'
import UniversalProvider from '@walletconnect/universal-provider'

import { AppKitInfo } from '../AppKitInfo'

Expand All @@ -10,11 +10,11 @@ export function Ethers5ModalInfo() {

const { chainId } = useAppKitNetwork()
const { isConnected, address } = useAppKitAccount()
const { walletProvider, walletProviderType } = useAppKitProvider<EthereumProvider>('eip155')
const { walletProvider, walletProviderType } = useAppKitProvider<UniversalProvider>('eip155')

async function getClientId() {
if (walletProviderType === 'walletConnect') {
return await walletProvider?.signer?.client?.core?.crypto?.getClientId()
return await walletProvider?.client?.core?.crypto?.getClientId()
}

return undefined
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button, Stack, Text, Spacer, Heading } from '@chakra-ui/react'
import { useState, useEffect } from 'react'
import { useAppKitAccount, useAppKitProvider, useAppKitNetwork } from '@reown/appkit/react'
import { EthereumProvider } from '@walletconnect/ethereum-provider'
import { UniversalProvider } from '@walletconnect/universal-provider'
import { useChakraToast } from '../Toast'
import type { Address } from 'viem'
import type { Provider as RawProvider } from '@reown/appkit'
Expand All @@ -14,7 +14,7 @@ import {
} from '../../utils/EIP5792Utils'
import { W3mFrameProvider } from '@reown/appkit-wallet'

type Provider = W3mFrameProvider | Awaited<ReturnType<(typeof EthereumProvider)['init']>>
type Provider = W3mFrameProvider | Awaited<ReturnType<(typeof UniversalProvider)['init']>>

export function Ethers5SendCallsTest() {
const [loading, setLoading] = useState(false)
Expand Down Expand Up @@ -102,9 +102,9 @@ export function Ethers5SendCallsTest() {
if (walletProvider instanceof W3mFrameProvider) {
return true
}
if (walletProvider instanceof EthereumProvider) {
if (walletProvider instanceof UniversalProvider) {
return Boolean(
walletProvider?.signer?.session?.namespaces?.['eip155']?.methods?.includes(
walletProvider?.session?.namespaces?.['eip155']?.methods?.includes(
EIP_5792_RPC_METHODS.WALLET_SEND_CALLS
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
useAppKitProvider,
type Provider
} from '@reown/appkit/react'
import { EthereumProvider } from '@walletconnect/ethereum-provider'
import { UniversalProvider } from '@walletconnect/universal-provider'
import { useChakraToast } from '../Toast'
import { parseGwei } from 'viem'
import { vitalikEthAddress } from '../../utils/DataUtil'
Expand Down Expand Up @@ -34,7 +34,7 @@ export function Ethers5SendCallsWithPaymasterServiceTest() {
useEffect(() => {
if (
address &&
(walletProvider instanceof EthereumProvider || walletProvider instanceof W3mFrameProvider)
(walletProvider instanceof UniversalProvider || walletProvider instanceof W3mFrameProvider)
) {
getCapabilitySupportedChainInfo(
WALLET_CAPABILITIES.PAYMASTER_SERVICE,
Expand Down Expand Up @@ -111,9 +111,9 @@ export function Ethers5SendCallsWithPaymasterServiceTest() {

function isSendCallsSupported(): boolean {
// We are currently checking capabilities above. We should use those capabilities instead of this check.
if (walletProvider instanceof EthereumProvider) {
if (walletProvider instanceof UniversalProvider) {
return Boolean(
walletProvider?.signer?.session?.namespaces?.['eip155']?.methods?.includes(
walletProvider?.session?.namespaces['eip155']?.methods?.includes(
EIP_5792_RPC_METHODS.WALLET_SEND_CALLS
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
useAppKitProvider,
type Provider
} from '@reown/appkit/react'
import { EthereumProvider } from '@walletconnect/ethereum-provider'
import { UniversalProvider } from '@walletconnect/universal-provider'
import { useChakraToast } from '../Toast'
import { BrowserProvider } from 'ethers'
import { W3mFrameProvider } from '@reown/appkit-wallet'
Expand Down Expand Up @@ -58,9 +58,9 @@ export function EthersGetCallsStatusTest() {
if (walletProvider instanceof W3mFrameProvider) {
return true
}
if (walletProvider instanceof EthereumProvider) {
if (walletProvider instanceof UniversalProvider) {
return Boolean(
walletProvider?.signer?.session?.namespaces?.['eip155']?.methods?.includes(
walletProvider?.session?.namespaces?.['eip155']?.methods?.includes(
EIP_5792_RPC_METHODS.WALLET_GET_CALLS_STATUS
)
)
Expand Down
6 changes: 3 additions & 3 deletions apps/laboratory/src/components/Ethers/EthersModalInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'
import { useAppKitAccount, useAppKitNetwork, useAppKitProvider } from '@reown/appkit/react'
import EthereumProvider from '@walletconnect/ethereum-provider'
import UniversalProvider from '@walletconnect/universal-provider'

import { AppKitInfo } from '../AppKitInfo'

Expand All @@ -9,11 +9,11 @@ export function EthersModalInfo() {
const [clientId, setClientId] = React.useState<string | undefined>(undefined)
const { isConnected, address } = useAppKitAccount()
const { chainId } = useAppKitNetwork()
const { walletProvider, walletProviderType } = useAppKitProvider<EthereumProvider>('eip155')
const { walletProvider, walletProviderType } = useAppKitProvider<UniversalProvider>('eip155')

async function getClientId() {
if (walletProviderType === 'walletConnect') {
return await walletProvider?.signer?.client?.core?.crypto?.getClientId()
return await walletProvider?.client?.core?.crypto?.getClientId()
}

return undefined
Expand Down
11 changes: 5 additions & 6 deletions apps/laboratory/src/components/Ethers/EthersSendCallsTest.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button, Stack, Text, Spacer, Heading } from '@chakra-ui/react'
import { useState, useEffect } from 'react'
import { useAppKitAccount, useAppKitNetwork, useAppKitProvider } from '@reown/appkit/react'
import { EthereumProvider } from '@walletconnect/ethereum-provider'
import { UniversalProvider } from '@walletconnect/universal-provider'
import { useChakraToast } from '../Toast'
import type { Address } from 'viem'
import { vitalikEthAddress } from '../../utils/DataUtil'
Expand All @@ -12,8 +12,7 @@ import {
getCapabilitySupportedChainInfo
} from '../../utils/EIP5792Utils'
import { W3mFrameProvider } from '@reown/appkit-wallet'

type Provider = W3mFrameProvider | Awaited<ReturnType<(typeof EthereumProvider)['init']>>
type Provider = W3mFrameProvider | Awaited<ReturnType<(typeof UniversalProvider)['init']>>

export function EthersSendCallsTest() {
const [loading, setLoading] = useState(false)
Expand All @@ -33,7 +32,7 @@ export function EthersSendCallsTest() {
if (address && walletProvider) {
getCapabilitySupportedChainInfo(
WALLET_CAPABILITIES.ATOMIC_BATCH,
walletProvider as Provider,
walletProvider as unknown as Provider,
address
).then(capabilities => setAtomicBatchSupportedChains(capabilities))
} else {
Expand Down Expand Up @@ -100,9 +99,9 @@ export function EthersSendCallsTest() {
if (walletProvider instanceof W3mFrameProvider) {
return true
}
if (walletProvider instanceof EthereumProvider) {
if (walletProvider instanceof UniversalProvider) {
return Boolean(
walletProvider?.signer?.session?.namespaces?.['eip155']?.methods?.includes(
walletProvider?.session?.namespaces?.['eip155']?.methods?.includes(
EIP_5792_RPC_METHODS.WALLET_SEND_CALLS
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button, Stack, Text, Input, Tooltip } from '@chakra-ui/react'
import { useState, useEffect } from 'react'
import { useAppKitAccount, useAppKitNetwork, useAppKitProvider } from '@reown/appkit/react'
import { EthereumProvider } from '@walletconnect/ethereum-provider'
import { UniversalProvider } from '@walletconnect/universal-provider'
import { useChakraToast } from '../Toast'
import { parseGwei } from 'viem'
import { vitalikEthAddress } from '../../utils/DataUtil'
Expand Down Expand Up @@ -29,7 +29,7 @@ export function EthersSendCallsWithPaymasterServiceTest() {
useEffect(() => {
if (
address &&
(walletProvider instanceof EthereumProvider || walletProvider instanceof W3mFrameProvider)
(walletProvider instanceof UniversalProvider || walletProvider instanceof W3mFrameProvider)
) {
getCapabilitySupportedChainInfo(
WALLET_CAPABILITIES.PAYMASTER_SERVICE,
Expand Down Expand Up @@ -106,9 +106,9 @@ export function EthersSendCallsWithPaymasterServiceTest() {

function isSendCallsSupported(): boolean {
// We are currently checking capabilities above. We should use those capabilities instead of this check.
if (walletProvider instanceof EthereumProvider) {
if (walletProvider instanceof UniversalProvider) {
return Boolean(
walletProvider?.signer?.session?.namespaces?.['eip155']?.methods?.includes(
walletProvider?.session?.namespaces?.['eip155']?.methods?.includes(
EIP_5792_RPC_METHODS.WALLET_SEND_CALLS
)
)
Expand Down
6 changes: 3 additions & 3 deletions apps/laboratory/src/components/Wagmi/WagmiModalInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react'
import EthereumProvider from '@walletconnect/ethereum-provider'
import UniversalProvider from '@walletconnect/universal-provider'

import { useAccount } from 'wagmi'
import { AppKitInfo } from '../AppKitInfo'
Expand All @@ -13,9 +13,9 @@ export function WagmiModalInfo() {
async function getClientId() {
if (connector?.type === 'walletConnect') {
const provider = await connector?.getProvider?.()
const ethereumProvider = provider as EthereumProvider
const ethereumProvider = provider as UniversalProvider

return ethereumProvider?.signer?.client?.core?.crypto?.getClientId()
return ethereumProvider.client?.core?.crypto?.getClientId()
}

return null
Expand Down
6 changes: 3 additions & 3 deletions apps/laboratory/src/hooks/useWagmiActiveCapabilities.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EthereumProvider } from '@walletconnect/ethereum-provider'
import { UniversalProvider } from '@walletconnect/universal-provider'
import { useAccount, type Connector } from 'wagmi'
import { useState, useEffect, useMemo } from 'react'
import { type Address, type WalletCapabilities } from 'viem'
Expand All @@ -17,7 +17,7 @@ type UseWagmiAvailableCapabilitiesParams = {
method: string
}

export type Provider = Awaited<ReturnType<(typeof EthereumProvider)['init']>> | W3mFrameProvider
export type Provider = Awaited<ReturnType<(typeof UniversalProvider)['init']>> | W3mFrameProvider

export function useWagmiAvailableCapabilities({
capability,
Expand Down Expand Up @@ -85,7 +85,7 @@ export function useWagmiAvailableCapabilities({
return supportedMethods.includes(method)
}

return Boolean(provider?.signer?.session?.namespaces?.['eip155']?.methods?.includes(method))
return Boolean(provider?.session?.namespaces?.['eip155']?.methods?.includes(method))
}

useEffect(() => {
Expand Down
8 changes: 4 additions & 4 deletions apps/laboratory/src/utils/EIP5792Utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EthereumProvider } from '@walletconnect/ethereum-provider'
import { UniversalProvider } from '@walletconnect/universal-provider'
import { getChain } from './NetworksUtil'
import { parseJSON } from './CommonUtils'
import { fromHex, type WalletCapabilities } from 'viem'
Expand Down Expand Up @@ -58,9 +58,9 @@ export function convertCapabilitiesToRecord(

export function getProviderCachedCapabilities(
address: string,
provider: Awaited<ReturnType<(typeof EthereumProvider)['init']>>
provider: Awaited<ReturnType<(typeof UniversalProvider)['init']>>
) {
const walletCapabilitiesString = provider.signer?.session?.sessionProperties?.['capabilities']
const walletCapabilitiesString = provider?.session?.sessionProperties?.['capabilities']
if (!walletCapabilitiesString) {
return undefined
}
Expand All @@ -75,7 +75,7 @@ export function getProviderCachedCapabilities(

export async function getCapabilitySupportedChainInfo(
capability: string,
provider: Awaited<ReturnType<(typeof EthereumProvider)['init']>> | W3mFrameProvider,
provider: Awaited<ReturnType<(typeof UniversalProvider)['init']>> | W3mFrameProvider,
address: string
): Promise<
{
Expand Down
Loading

0 comments on commit 484cefa

Please sign in to comment.