Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: pass wagmi params to createConfig method #3324

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .changeset/old-llamas-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@reown/appkit-adapter-wagmi': patch
'@apps/demo': patch
'@apps/gallery': patch
'@reown/appkit-adapter-ethers': patch
'@reown/appkit-adapter-ethers5': patch
'@reown/appkit-adapter-polkadot': patch
'@reown/appkit-adapter-solana': patch
'@reown/appkit': patch
'@reown/appkit-utils': patch
'@reown/appkit-cdn': 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
---

Passes Wagmi adapter params to createConfig method
1 change: 1 addition & 0 deletions packages/adapters/wagmi/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class WagmiAdapter extends AdapterBlueprint {
})
this.namespace = CommonConstantsUtil.CHAIN.EVM
this.createConfig({
...configParams,
networks: CaipNetworksUtil.extendCaipNetworks(configParams.networks, {
projectId: configParams.projectId,
customNetworkImageUrls: {}
Expand Down
39 changes: 38 additions & 1 deletion packages/adapters/wagmi/src/tests/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import {
getEnsAddress as wagmiGetEnsAddress,
writeContract as wagmiWriteContract,
waitForTransactionReceipt,
getAccount
getAccount,
createConfig
} from '@wagmi/core'
import { mainnet } from '@wagmi/core/chains'
import { CaipNetworksUtil } from '@reown/appkit-utils'
import type UniversalProvider from '@walletconnect/universal-provider'
import type { HttpTransport } from 'viem'

vi.mock('@wagmi/core', async () => {
const actual = await vi.importActual('@wagmi/core')
Expand Down Expand Up @@ -108,6 +110,41 @@ describe('WagmiAdapter', () => {

expect(injectedConnector?.info).toBeUndefined()
})

it('should pass WagmiAdapter constructor params to createConfig', () => {
new WagmiAdapter({
networks: mockNetworks,
projectId: mockProjectId,
ssr: true
})

expect(vi.mocked(createConfig)).toHaveBeenCalledWith(
expect.objectContaining({
chains: expect.any(Array),
projectId: mockProjectId,
ssr: true
})
)
})

it('should merge provided transports with default network transports', () => {
const mockCustomTransport = {} as HttpTransport
const mockTransports = { 1: mockCustomTransport }

new WagmiAdapter({
networks: mockNetworks,
projectId: mockProjectId,
transports: mockTransports
})

expect(vi.mocked(createConfig)).toHaveBeenCalledWith(
expect.objectContaining({
transports: expect.objectContaining({
1: mockCustomTransport
})
})
)
})
})

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