Skip to content

Commit

Permalink
Merge branch 'main' into refactor/wc-set-uri-single-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
zoruka authored Jan 20, 2025
2 parents a073c4d + 1370e40 commit 8da7395
Show file tree
Hide file tree
Showing 35 changed files with 1,030 additions and 345 deletions.
23 changes: 23 additions & 0 deletions .changeset/nine-chicken-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@reown/appkit': patch
'@reown/appkit-core': patch
'@reown/appkit-adapter-bitcoin': patch
'@reown/appkit-adapter-ethers': patch
'@reown/appkit-adapter-ethers5': patch
'@reown/appkit-adapter-solana': patch
'@reown/appkit-adapter-wagmi': patch
'@reown/appkit-utils': patch
'@reown/appkit-cdn': patch
'@reown/appkit-cli': patch
'@reown/appkit-common': patch
'@reown/appkit-experimental': patch
'@reown/appkit-polyfills': patch
'@reown/appkit-scaffold-ui': patch
'@reown/appkit-siwe': patch
'@reown/appkit-siwx': patch
'@reown/appkit-ui': patch
'@reown/appkit-wallet': patch
'@reown/appkit-wallet-button': patch
---

Refactors AppKit client to handle syncBalance call for unsupported networks as expected
23 changes: 23 additions & 0 deletions .changeset/selfish-rivers-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@reown/appkit-adapter-wagmi': patch
'@reown/appkit-adapter-bitcoin': patch
'@reown/appkit-adapter-ethers': patch
'@reown/appkit-adapter-ethers5': patch
'@reown/appkit-adapter-solana': patch
'@reown/appkit': patch
'@reown/appkit-utils': patch
'@reown/appkit-cdn': patch
'@reown/appkit-cli': patch
'@reown/appkit-common': patch
'@reown/appkit-core': patch
'@reown/appkit-experimental': patch
'@reown/appkit-polyfills': patch
'@reown/appkit-scaffold-ui': patch
'@reown/appkit-siwe': patch
'@reown/appkit-siwx': patch
'@reown/appkit-ui': patch
'@reown/appkit-wallet': patch
'@reown/appkit-wallet-button': patch
---

Fixed an issue where `walletProvider` from the `useAppKitProvider` hook was `undefined` when the wallet was connected. This issue occurred only when using wagmi adapter.
23 changes: 23 additions & 0 deletions .changeset/serious-ravens-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@reown/appkit-siwx': patch
'@reown/appkit-adapter-bitcoin': patch
'@reown/appkit-adapter-ethers': patch
'@reown/appkit-adapter-ethers5': patch
'@reown/appkit-adapter-solana': patch
'@reown/appkit-adapter-wagmi': patch
'@reown/appkit': patch
'@reown/appkit-utils': patch
'@reown/appkit-cdn': patch
'@reown/appkit-cli': patch
'@reown/appkit-common': patch
'@reown/appkit-core': patch
'@reown/appkit-experimental': patch
'@reown/appkit-polyfills': patch
'@reown/appkit-scaffold-ui': patch
'@reown/appkit-siwe': patch
'@reown/appkit-ui': patch
'@reown/appkit-wallet': patch
'@reown/appkit-wallet-button': patch
---

Fixes issue where 1CA session would not be found because of non-cased addresses mismatching.'
23 changes: 23 additions & 0 deletions .changeset/sweet-sloths-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@reown/appkit-scaffold-ui': patch
'@reown/appkit-adapter-bitcoin': patch
'@reown/appkit-adapter-ethers': patch
'@reown/appkit-adapter-ethers5': patch
'@reown/appkit-adapter-solana': patch
'@reown/appkit-adapter-wagmi': patch
'@reown/appkit': patch
'@reown/appkit-utils': patch
'@reown/appkit-cdn': patch
'@reown/appkit-cli': patch
'@reown/appkit-common': patch
'@reown/appkit-core': patch
'@reown/appkit-experimental': patch
'@reown/appkit-polyfills': patch
'@reown/appkit-siwe': patch
'@reown/appkit-siwx': patch
'@reown/appkit-ui': patch
'@reown/appkit-wallet': patch
'@reown/appkit-wallet-button': patch
---

Removes duplicated all wallets button on AppKit Basic
23 changes: 23 additions & 0 deletions .changeset/thin-bananas-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@reown/appkit-scaffold-ui': patch
'@reown/appkit-core': patch
'@reown/appkit-adapter-bitcoin': patch
'@reown/appkit-adapter-ethers': patch
'@reown/appkit-adapter-ethers5': patch
'@reown/appkit-adapter-solana': patch
'@reown/appkit-adapter-wagmi': patch
'@reown/appkit': patch
'@reown/appkit-utils': patch
'@reown/appkit-cdn': patch
'@reown/appkit-cli': patch
'@reown/appkit-common': patch
'@reown/appkit-experimental': patch
'@reown/appkit-polyfills': patch
'@reown/appkit-siwe': patch
'@reown/appkit-siwx': patch
'@reown/appkit-ui': patch
'@reown/appkit-wallet': patch
'@reown/appkit-wallet-button': patch
---

Fixes issue where onramp and activity were enabled in non-supported networks'
2 changes: 1 addition & 1 deletion apps/builder/providers/appkit-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (!projectId) {
const metadata = {
name: 'AppKit Builder',
description: 'The full stack toolkit to build onchain app UX',
url: 'https://github.com/0xonerb/next-reown-appkit-ssr', // origin must match your domain & subdomain
url: window?.origin || 'https://demo.reown.com', // origin must match your domain & subdomain
icons: ['https://avatars.githubusercontent.com/u/179229932']
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function Ethers5WriteContractTest() {
const signer = provider.getSigner(address)
const contract = new ethers.Contract(donutAddress, abi, signer)
// @ts-expect-error ethers types are correct
const tx = await contract.purchase(1, { value: ethers.parseEther('0.0001') })
const tx = await contract.purchase(1, { value: ethers.parseEther('0.00001') })
toast({
title: 'Success',
description: tx.hash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function EthersWriteContractTest() {
const signer = new JsonRpcSigner(provider, address)
const contract = new ethers.Contract(donutAddress, abi, signer)
// @ts-expect-error ethers types are correct
const tx = await contract.purchase(1, { value: ethers.parseEther('0.0001') })
const tx = await contract.purchase(1, { value: ethers.parseEther('0.00001') })
toast({
title: 'Success',
description: tx.hash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function ConnectedTestContent({
const purchaseDonutCallDataExecution = [
{
to: donutContractaddress as `0x${string}`,
value: parseEther('0.0001'),
value: parseEther('0.00001'),
data: purchaseDonutCallData
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function ConnectedTestContent({
const purchaseDonutCallDataExecution = [
{
to: donutContractaddress as `0x${string}`,
value: parseEther('0.0001'),
value: parseEther('0.00001'),
data: purchaseDonutCallData
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import { useSendCalls } from 'wagmi/experimental'
import { useAppKitAccount } from '@reown/appkit/react'

import { useWagmiAvailableCapabilities } from '../../hooks/useWagmiActiveCapabilities'
import { abi as donutContractAbi, address as donutContractaddress } from '../../utils/DonutContract'
import {
abi as donutContractAbi,
donutContractSupportedChains,
donutContractSupportedChainsName,
address as donutContractaddress
} from '../../utils/DonutContract'
import { EIP_5792_RPC_METHODS, WALLET_CAPABILITIES } from '../../utils/EIP5792Utils'
import { useChakraToast } from '../Toast'

Expand All @@ -20,7 +25,7 @@ const purchaseDonutCallData = encodeFunctionData({

const TEST_TX = {
to: donutContractaddress as `0x${string}`,
value: parseEther('0.0001'),
value: parseEther('0.00001'),
data: purchaseDonutCallData
}

Expand All @@ -38,16 +43,33 @@ const BICONOMY_PAYMASTER_CONTEXT = {
}

export function WagmiSendCallsWithPaymasterServiceTest() {
const { provider, supportedChains, supportedChainsName, currentChainsInfo, supported } =
useWagmiAvailableCapabilities({
capability: WALLET_CAPABILITIES.PAYMASTER_SERVICE,
method: EIP_5792_RPC_METHODS.WALLET_SEND_CALLS
})
const {
provider,
supportedChains: capabilitySupportedChains,
currentChainsInfo,
supported
} = useWagmiAvailableCapabilities({
capability: WALLET_CAPABILITIES.PAYMASTER_SERVICE,
method: EIP_5792_RPC_METHODS.WALLET_SEND_CALLS
})

const { address } = useAppKitAccount()
const { status } = useAccount()

const isConnected = status === 'connected'
const isFeatureSupported = useMemo(
() =>
currentChainsInfo &&
donutContractSupportedChains.some(chain => chain.id === currentChainsInfo.chainId),
[currentChainsInfo]
)

const doWalletSupportCapability = useMemo(
() =>
currentChainsInfo &&
capabilitySupportedChains.some(chain => chain.chainId === currentChainsInfo.chainId),
[capabilitySupportedChains]
)

if (!isConnected || !provider || !address) {
return (
Expand All @@ -65,18 +87,18 @@ export function WagmiSendCallsWithPaymasterServiceTest() {
)
}

if (supportedChains.length === 0) {
if (!isFeatureSupported) {
return (
<Text fontSize="md" color="yellow">
Account does not support paymaster service feature
Switch to {donutContractSupportedChainsName} to test this feature
</Text>
)
}

if (!currentChainsInfo) {
if (!doWalletSupportCapability) {
return (
<Text fontSize="md" color="yellow">
Switch to {supportedChainsName} to test this feature
Account does not support paymaster service feature on {currentChainsInfo?.chainName}
</Text>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function AvailableTestContent({ accountAddress }: { accountAddress: string | und
abi,
address,
functionName: 'purchase',
value: parseEther('0.0001'),
value: parseEther('0.00001'),
args: [1],
query: {
enabled: false
Expand Down
10 changes: 9 additions & 1 deletion apps/laboratory/src/utils/DonutContract.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { base, baseSepolia, optimism, sepolia } from 'viem/chains'

export const abi = [
{
inputs: [
Expand Down Expand Up @@ -70,4 +72,10 @@ export const abi = [
}
]

export const address = '0x2E65BAfA07238666c3b239E94F32DaD3cDD6498D'
export const address = '0x59d6578C1D8FEb2f892f68D4f76f98511F831c6F'

// Deployed on sepolia, base-seoplia, base-mainnet, optimism-mainnet.
export const donutContractSupportedChains = [sepolia, baseSepolia, base, optimism]
export const donutContractSupportedChainsName = donutContractSupportedChains
.map(chain => chain.name)
.join(', ')
11 changes: 8 additions & 3 deletions packages/adapters/wagmi/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ export class WagmiAdapter extends AdapterBlueprint {
return formatUnits(params.value, params.decimals)
}

private addWagmiConnector(connector: Connector, options: AppKitOptions) {
private async addWagmiConnector(connector: Connector, options: AppKitOptions) {
/*
* We don't need to set auth connector or walletConnect connector
* from wagmi since we already set it in chain adapter blueprint
Expand All @@ -422,6 +422,8 @@ export class WagmiAdapter extends AdapterBlueprint {
return
}

const provider = (await connector.getProvider().catch(() => undefined)) as Provider | undefined

this.addConnector({
id: connector.id,
explorerId: PresetsUtil.ConnectorExplorerIds[connector.id],
Expand All @@ -433,17 +435,20 @@ export class WagmiAdapter extends AdapterBlueprint {
connector.id === CommonConstantsUtil.CONNECTOR_ID.INJECTED
? undefined
: { rdns: connector.id },
provider,
chain: this.namespace as ChainNamespace,
chains: []
})
}

public syncConnectors(options: AppKitOptions, appKit: AppKit) {
public async syncConnectors(options: AppKitOptions, appKit: AppKit) {
// Add wagmi connectors
this.addWagmiConnectors(options, appKit)

// Add current wagmi connectors to chain adapter blueprint
this.wagmiConfig.connectors.forEach(connector => this.addWagmiConnector(connector, options))
await Promise.all(
this.wagmiConfig.connectors.map(connector => this.addWagmiConnector(connector, options))
)

/*
* Watch for new connectors. This is needed because some EIP6963
Expand Down
47 changes: 44 additions & 3 deletions packages/adapters/wagmi/src/tests/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ const mockCaipNetworks = CaipNetworksUtil.extendCaipNetworks(mockNetworks, {
const mockWagmiConfig = {
connectors: [
{
id: 'test-connector'
id: 'test-connector',
getProvider() {
return Promise.resolve({ connect: vi.fn(), request: vi.fn() })
}
}
],
_internal: {
Expand Down Expand Up @@ -101,10 +104,13 @@ describe('WagmiAdapter', () => {
expect(adapter.namespace).toBe('eip155')
})

it('should set wagmi connectors', () => {
it('should set wagmi connectors', async () => {
vi.spyOn(wagmiCore, 'watchConnectors').mockImplementation(vi.fn())

adapter.syncConnectors({ networks: [mainnet], projectId: 'YOUR_PROJECT_ID' }, mockAppKit)
await adapter.syncConnectors(
{ networks: [mainnet], projectId: 'YOUR_PROJECT_ID' },
mockAppKit
)

expect(adapter.connectors).toStrictEqual([
{
Expand All @@ -115,6 +121,10 @@ describe('WagmiAdapter', () => {
imageId: undefined,
imageUrl: undefined,
info: { rdns: 'test-connector' },
provider: {
connect: expect.any(Function),
request: expect.any(Function)
},
name: undefined,
type: 'EXTERNAL'
}
Expand Down Expand Up @@ -156,6 +166,37 @@ describe('WagmiAdapter', () => {
`https://cloudflare-eth.com`
)
})

it('should add connector with provider', async () => {
const mockConnector = {
id: 'injected',
name: 'Injected Wallet',
type: 'injected',
getProvider() {
return Promise.resolve({ connect: vi.fn(), request: vi.fn() })
}
} as unknown as wagmiCore.Connector

await (adapter as any).addWagmiConnector(mockConnector)

expect(adapter.connectors).toStrictEqual([
{
chain: 'eip155',
chains: [],
explorerId: undefined,
id: 'injected',
imageId: '07ba87ed-43aa-4adf-4540-9e6a2b9cae00',
imageUrl: undefined,
info: undefined,
name: 'Browser Wallet',
provider: {
connect: expect.any(Function),
request: expect.any(Function)
},
type: 'INJECTED'
}
])
})
})

describe('WagmiAdapter - signMessage', () => {
Expand Down
Loading

0 comments on commit 8da7395

Please sign in to comment.