├── site ├── react │ ├── guides │ │ └── testing.md │ └── api │ │ ├── transports │ │ ├── http.md │ │ ├── custom.md │ │ ├── fallback.md │ │ ├── webSocket.md │ │ └── unstable_connector.md │ │ ├── utilities │ │ ├── serialize.md │ │ ├── deserialize.md │ │ ├── normalizeChainId.md │ │ └── cookieToInitialState.md │ │ ├── connectors │ │ ├── coinbaseWallet.md │ │ ├── mock.md │ │ ├── porto.md │ │ ├── safe.md │ │ ├── baseAccount.md │ │ ├── walletConnect.md │ │ ├── gemini.md │ │ ├── injected.md │ │ └── metaMask.md │ │ ├── createStorage.md │ │ ├── createConfig.md │ │ ├── errors.md │ │ ├── hooks.md │ │ └── connectors.md ├── core │ ├── guides │ │ ├── testing.md │ │ └── faq.md │ └── api │ │ ├── transports │ │ ├── http.md │ │ ├── custom.md │ │ ├── fallback.md │ │ ├── webSocket.md │ │ └── unstable_connector.md │ │ ├── utilities │ │ ├── serialize.md │ │ ├── deserialize.md │ │ ├── normalizeChainId.md │ │ └── cookieToInitialState.md │ │ ├── connectors │ │ ├── coinbaseWallet.md │ │ ├── mock.md │ │ ├── porto.md │ │ ├── safe.md │ │ ├── baseAccount.md │ │ ├── walletConnect.md │ │ ├── gemini.md │ │ ├── injected.md │ │ └── metaMask.md │ │ ├── createStorage.md │ │ ├── errors.md │ │ ├── createConfig.md │ │ ├── actions │ │ ├── getAccount.md │ │ ├── getChains.md │ │ ├── getConnections.md │ │ └── getConnectors.md │ │ ├── actions.md │ │ ├── createConnector.md │ │ ├── chains.md │ │ └── connectors.md ├── public │ ├── og.png │ └── browsers │ │ ├── edge.png │ │ ├── chrome.png │ │ ├── opera.png │ │ ├── safari.png │ │ └── firefox.png ├── snippets │ ├── vue │ │ ├── App.vue │ │ ├── config.ts │ │ ├── main.ts │ │ └── config-chain-properties.ts │ ├── react │ │ ├── config.ts │ │ ├── config-chain-properties.ts │ │ └── app.tsx │ ├── core │ │ ├── config.ts │ │ └── config-chain-properties.ts │ ├── typedData.ts │ ├── abi-read.ts │ ├── abi-event.ts │ └── abi-write.ts ├── vue │ ├── api │ │ ├── transports │ │ │ ├── http.md │ │ │ ├── custom.md │ │ │ ├── fallback.md │ │ │ ├── webSocket.md │ │ │ └── unstable_connector.md │ │ ├── utilities │ │ │ ├── serialize.md │ │ │ └── deserialize.md │ │ ├── errors.md │ │ ├── connectors │ │ │ ├── coinbaseWallet.md │ │ │ ├── mock.md │ │ │ ├── safe.md │ │ │ ├── gemini.md │ │ │ ├── porto.md │ │ │ ├── baseAccount.md │ │ │ ├── walletConnect.md │ │ │ ├── injected.md │ │ │ └── metaMask.md │ │ ├── createStorage.md │ │ ├── createConfig.md │ │ ├── composables.md │ │ ├── composables │ │ │ └── useConfig.md │ │ ├── connectors.md │ │ └── Nuxt.md │ └── guides │ │ └── faq.md ├── components │ └── Browsers.vue ├── .vitepress │ └── theme │ │ └── components │ │ ├── HomeBanner.vue │ │ └── Banner.vue ├── shared │ ├── mutation-imports.md │ └── query-imports.md ├── tsconfig.json └── cli │ └── api │ └── commands │ └── init.md ├── packages ├── cli │ ├── src │ │ ├── version.ts │ │ ├── plugins │ │ │ └── __fixtures__ │ │ │ │ ├── hardhat │ │ │ │ ├── hardhat.config.js │ │ │ │ ├── package.json │ │ │ │ ├── .gitignore │ │ │ │ └── contracts │ │ │ │ │ ├── Foo.sol │ │ │ │ │ └── Counter.sol │ │ │ │ └── foundry │ │ │ │ ├── .gitignore │ │ │ │ ├── foundry.toml │ │ │ │ └── src │ │ │ │ ├── Foo.sol │ │ │ │ └── Counter.sol │ │ ├── exports │ │ │ ├── index.test-d.ts │ │ │ ├── config.ts │ │ │ ├── config.test.ts │ │ │ ├── index.test.ts │ │ │ ├── index.ts │ │ │ └── plugins.test.ts │ │ ├── utils │ │ │ ├── format.test.ts │ │ │ ├── format.ts │ │ │ ├── packages.test.ts │ │ │ └── resolveConfig.ts │ │ └── types.ts │ ├── tsconfig.json │ ├── tsconfig.build.json │ ├── README.md │ └── types │ │ └── fixturez.d.ts ├── vue │ ├── src │ │ ├── version.ts │ │ ├── utils │ │ │ ├── getVersion.ts │ │ │ ├── getVersion.test.ts │ │ │ └── updateState.ts │ │ ├── exports │ │ │ ├── nuxt.ts │ │ │ ├── nuxt.test.ts │ │ │ ├── internal.ts │ │ │ ├── chains.ts │ │ │ ├── actions.ts │ │ │ ├── connectors.ts │ │ │ ├── actions │ │ │ │ └── experimental.ts │ │ │ ├── connectors.test.ts │ │ │ └── query.ts │ │ ├── nuxt │ │ │ └── runtime │ │ │ │ └── composables.ts │ │ ├── composables │ │ │ ├── useTransaction.test-d.ts │ │ │ ├── useEstimateGas.test-d.ts │ │ │ ├── useBalance.test-d.ts │ │ │ ├── useTransactionReceipt.test-d.ts │ │ │ ├── useChainId.test-d.ts │ │ │ ├── useWaitForTransactionReceipt.test-d.ts │ │ │ ├── useBytecode.test-d.ts │ │ │ ├── useChains.test.ts │ │ │ ├── useConnectorClient.test-d.ts │ │ │ ├── useConfig.test-d.ts │ │ │ ├── useConnections.test.ts │ │ │ ├── useChainId.test.ts │ │ │ └── useAccount.test.ts │ │ └── errors │ │ │ └── base.ts │ ├── tsconfig.json │ ├── tsconfig.build.json │ ├── test │ │ └── setup.ts │ └── README.md ├── core │ ├── src │ │ ├── version.ts │ │ ├── types │ │ │ ├── unit.ts │ │ │ ├── register.ts │ │ │ └── properties.ts │ │ ├── utils │ │ │ ├── getVersion.ts │ │ │ ├── getVersion.test.ts │ │ │ ├── getUnit.ts │ │ │ ├── getUnit.test.ts │ │ │ ├── uid.ts │ │ │ ├── deserialize.ts │ │ │ ├── normalizeChainId.ts │ │ │ └── extractRpcUrls.ts │ │ ├── actions │ │ │ ├── getBlockNumber.test.ts │ │ │ ├── getConnectors.test.ts │ │ │ ├── codegen │ │ │ │ └── createWriteContract.test.ts │ │ │ ├── getEnsAvatar.test.ts │ │ │ ├── getEnsText.test.ts │ │ │ ├── getEnsName.test.ts │ │ │ ├── getEnsAddress.test.ts │ │ │ ├── getChainId.test.ts │ │ │ ├── getChainId.ts │ │ │ ├── getEnsResolver.test.ts │ │ │ ├── getClient.test.ts │ │ │ ├── getPublicClient.test.ts │ │ │ ├── watchClient.test-d.ts │ │ │ ├── getChains.test.ts │ │ │ ├── estimateFeesPerGas.test.ts │ │ │ ├── watchPublicClient.test-d.ts │ │ │ ├── getChains.test-d.ts │ │ │ ├── getProof.test.ts │ │ │ ├── estimateMaxPriorityFeePerGas.test.ts │ │ │ ├── getConnections.test.ts │ │ │ ├── watchClient.test.ts │ │ │ ├── watchPublicClient.test.ts │ │ │ ├── watchAsset.test.ts │ │ │ ├── getGasPrice.test.ts │ │ │ ├── watchChainId.test.ts │ │ │ ├── watchChainId.ts │ │ │ ├── getConnections.ts │ │ │ └── watchBlocks.test.ts │ │ ├── transports │ │ │ └── fallback.ts │ │ ├── exports │ │ │ ├── internal.test.ts │ │ │ ├── chains.ts │ │ │ └── codegen.test.ts │ │ ├── query │ │ │ ├── connect.test.ts │ │ │ ├── reconnect.test.ts │ │ │ ├── sendCalls.test.ts │ │ │ ├── disconnect.test.ts │ │ │ ├── watchAsset.test.ts │ │ │ ├── signMessage.test.ts │ │ │ ├── switchChain.test.ts │ │ │ ├── sendCallsSync.test.ts │ │ │ ├── signTypedData.test.ts │ │ │ ├── switchAccount.test.ts │ │ │ ├── writeContract.test.ts │ │ │ ├── deployContract.test.ts │ │ │ ├── sendTransaction.test.ts │ │ │ ├── showCallsStatus.test.ts │ │ │ ├── sendTransactionSync.test.ts │ │ │ ├── utils.test.ts │ │ │ ├── readContract.test-d.ts │ │ │ ├── waitForTransactionReceipt.test.ts │ │ │ ├── getCallsStatus.test.ts │ │ │ ├── waitForCallsStatus.test.ts │ │ │ ├── estimateGas.test.ts │ │ │ └── readContract.test.ts │ │ ├── experimental │ │ │ └── query │ │ │ │ └── writeContracts.test.ts │ │ ├── createEmitter.test.ts │ │ └── errors │ │ │ └── connector.test.ts │ ├── test │ │ └── setup.ts │ ├── tsconfig.json │ ├── tsconfig.build.json │ └── README.md ├── create-wagmi │ ├── templates │ │ ├── next │ │ │ ├── _npmrc │ │ │ ├── _env.local │ │ │ ├── next.config.js │ │ │ ├── README.md │ │ │ ├── next-env.d.ts │ │ │ ├── _gitignore │ │ │ ├── src │ │ │ │ └── app │ │ │ │ │ └── globals.css │ │ │ └── tsconfig.json │ │ ├── vite-react │ │ │ ├── _env.local │ │ │ ├── _npmrc │ │ │ ├── src │ │ │ │ ├── vite-env.d.ts │ │ │ │ ├── index.css │ │ │ │ └── wagmi.ts │ │ │ ├── README.md │ │ │ ├── vite.config.ts │ │ │ ├── tsconfig.node.json │ │ │ ├── index.html │ │ │ ├── _gitignore │ │ │ ├── package.json │ │ │ └── tsconfig.json │ │ ├── vite-vue │ │ │ ├── _env.local │ │ │ ├── _npmrc │ │ │ ├── src │ │ │ │ ├── vite-env.d.ts │ │ │ │ ├── App.vue │ │ │ │ ├── main.ts │ │ │ │ ├── components │ │ │ │ │ ├── Connect.vue │ │ │ │ │ └── Account.vue │ │ │ │ └── style.css │ │ │ ├── README.md │ │ │ ├── vite.config.ts │ │ │ ├── tsconfig.node.json │ │ │ ├── index.html │ │ │ ├── _gitignore │ │ │ └── package.json │ │ ├── nuxt │ │ │ ├── _npmrc │ │ │ ├── _env.local │ │ │ ├── server │ │ │ │ └── tsconfig.json │ │ │ ├── tsconfig.json │ │ │ ├── nuxt.config.ts │ │ │ ├── _gitignore │ │ │ ├── plugins │ │ │ │ └── wagmi.ts │ │ │ ├── components │ │ │ │ ├── Connect.vue │ │ │ │ └── Account.vue │ │ │ ├── package.json │ │ │ └── app.vue │ │ └── vite-vanilla │ │ │ ├── _env.local │ │ │ ├── _npmrc │ │ │ ├── src │ │ │ ├── vite-env.d.ts │ │ │ ├── wagmi.ts │ │ │ └── style.css │ │ │ ├── index.html │ │ │ ├── _gitignore │ │ │ ├── package.json │ │ │ └── tsconfig.json │ ├── src │ │ ├── version.ts │ │ └── index.test-d.ts │ ├── tsconfig.json │ ├── tsconfig.build.json │ └── README.md ├── react │ ├── src │ │ ├── version.ts │ │ ├── utils │ │ │ ├── getVersion.ts │ │ │ └── getVersion.test.ts │ │ ├── exports │ │ │ ├── internal.ts │ │ │ ├── chains.ts │ │ │ ├── actions.ts │ │ │ ├── connectors.ts │ │ │ ├── actions │ │ │ │ └── experimental.ts │ │ │ ├── connectors.test.ts │ │ │ ├── codegen.test.ts │ │ │ └── query.ts │ │ ├── hooks │ │ │ ├── useToken.test-d.ts │ │ │ ├── useBalance.test-d.ts │ │ │ ├── useGasPrice.test-d.ts │ │ │ ├── useTransaction.test-d.ts │ │ │ ├── useVerifyMessage.test-d.ts │ │ │ ├── useEstimateGas.test-d.ts │ │ │ ├── useFeeHistory.test-d.ts │ │ │ ├── useBytecode.test-d.ts │ │ │ ├── useStorageAt.test-d.ts │ │ │ ├── useTransactionCount.test-d.ts │ │ │ ├── useCall.test-d.ts │ │ │ ├── useProof.test-d.ts │ │ │ ├── useBlockTransactionCount.test-d.ts │ │ │ ├── useTransactionReceipt.test-d.ts │ │ │ ├── useTransactionConfirmations.test-d.ts │ │ │ ├── useChainId.test-d.ts │ │ │ ├── useWaitForTransactionReceipt.test-d.ts │ │ │ ├── useEstimateMaxPriorityFeePerGas.test-d.ts │ │ │ ├── useWalletClient.test-d.ts │ │ │ ├── useConnectorClient.test-d.ts │ │ │ ├── useConfig.test-d.ts │ │ │ ├── useEstimateFeesPerGas.test.ts │ │ │ └── useConfig.test.ts │ │ └── errors │ │ │ ├── base.ts │ │ │ ├── context.test.ts │ │ │ └── context.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ ├── README.md │ └── test │ │ └── setup.ts ├── connectors │ ├── src │ │ ├── version.ts │ │ ├── porto.test.ts │ │ ├── metaMask.test.ts │ │ ├── baseAccount.test.ts │ │ ├── exports │ │ │ └── index.test.ts │ │ ├── coinbaseWallet.test.ts │ │ └── gemini.test.ts │ ├── tsconfig.json │ ├── tsconfig.build.json │ └── README.md ├── test │ ├── tsconfig.json │ ├── src │ │ ├── regex.ts │ │ ├── exports │ │ │ ├── index.test-d.ts │ │ │ ├── index.ts │ │ │ └── index.test.ts │ │ ├── setup.ts │ │ └── vite-env.d.ts │ └── tsconfig.build.json └── register-tests │ ├── react │ ├── tsconfig.json │ ├── package.json │ └── src │ │ ├── useChains.test-d.ts │ │ ├── useChainId.test-d.ts │ │ ├── useAccount.test-d.ts │ │ └── useConfig.test-d.ts │ └── vue │ ├── tsconfig.json │ ├── package.json │ └── src │ ├── useChains.test-d.ts │ ├── useChainId.test-d.ts │ ├── useAccount.test-d.ts │ ├── useConfig.test-d.ts │ └── config.ts ├── playgrounds ├── nuxt │ ├── tsconfig.json │ ├── server │ │ └── tsconfig.json │ ├── public │ │ └── favicon.ico │ ├── nuxt.config.ts │ ├── .gitignore │ ├── plugins │ │ └── wagmi.ts │ ├── package.json │ ├── components │ │ ├── Connect.vue │ │ └── Account.vue │ └── app.vue ├── vite-core │ ├── src │ │ ├── vite-env.d.ts │ │ ├── main.tsx │ │ └── index.css │ ├── vite.config.ts │ ├── tsconfig.node.json │ ├── index.html │ ├── .gitignore │ └── package.json ├── vite-react │ ├── src │ │ ├── vite-env.d.ts │ │ └── index.css │ ├── public │ │ └── manifest.json │ ├── vite.config.ts │ ├── tsconfig.node.json │ ├── index.html │ ├── .gitignore │ └── wagmi.config.ts ├── vite-vue │ ├── src │ │ ├── vite-env.d.ts │ │ ├── components │ │ │ ├── Client.vue │ │ │ ├── Balance.vue │ │ │ ├── ConnectorClient.vue │ │ │ ├── ReadContract.vue │ │ │ ├── Connections.vue │ │ │ ├── BlockNumber.vue │ │ │ ├── Connect.vue │ │ │ ├── Account.vue │ │ │ ├── SwitchChain.vue │ │ │ └── SwitchAccount.vue │ │ ├── main.ts │ │ └── style.css │ ├── vite.config.ts │ ├── tsconfig.node.json │ ├── .gitignore │ ├── index.html │ ├── package.json │ └── tsconfig.json └── next │ ├── next.config.mjs │ ├── .gitignore │ ├── src │ └── app │ │ ├── globals.css │ │ └── providers.tsx │ └── tsconfig.json ├── .github ├── CONTRIBUTING.md ├── SECURITY.md ├── dependabot.yml ├── CODEOWNERS └── ISSUE_TEMPLATE │ └── config.yml ├── .npmrc ├── .vscode ├── extensions.json ├── workspace.code-workspace └── settings.json ├── tsconfig.json ├── FUNDING.json ├── .changeset ├── config.json └── README.md ├── docs └── base-network-setup.md └── patches └── prool.patch /site/react/guides/testing.md: -------------------------------------------------------------------------------- 1 | # Testing 2 | 3 | -------------------------------------------------------------------------------- /site/core/guides/testing.md: -------------------------------------------------------------------------------- 1 | # Testing 2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/cli/src/version.ts: -------------------------------------------------------------------------------- 1 | export const version = '2.7.1' 2 | -------------------------------------------------------------------------------- /packages/vue/src/version.ts: -------------------------------------------------------------------------------- 1 | export const version = '0.3.2' 2 | -------------------------------------------------------------------------------- /packages/core/src/version.ts: -------------------------------------------------------------------------------- 1 | export const version = '2.22.1' 2 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/next/_npmrc: -------------------------------------------------------------------------------- 1 | legacy-peer-deps = true -------------------------------------------------------------------------------- /packages/react/src/version.ts: -------------------------------------------------------------------------------- 1 | export const version = '2.19.2' 2 | -------------------------------------------------------------------------------- /packages/connectors/src/version.ts: -------------------------------------------------------------------------------- 1 | export const version = '6.1.3' 2 | -------------------------------------------------------------------------------- /packages/create-wagmi/src/version.ts: -------------------------------------------------------------------------------- 1 | export const version = '2.0.15' 2 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-react/_env.local: -------------------------------------------------------------------------------- 1 | VITE_WC_PROJECT_ID= -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-react/_npmrc: -------------------------------------------------------------------------------- 1 | legacy-peer-deps = true -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vue/_env.local: -------------------------------------------------------------------------------- 1 | VITE_WC_PROJECT_ID= -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vue/_npmrc: -------------------------------------------------------------------------------- 1 | legacy-peer-deps = true -------------------------------------------------------------------------------- /packages/create-wagmi/templates/nuxt/_npmrc: -------------------------------------------------------------------------------- 1 | legacy-peer-deps = true 2 | 3 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vanilla/_env.local: -------------------------------------------------------------------------------- 1 | VITE_WC_PROJECT_ID= -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vanilla/_npmrc: -------------------------------------------------------------------------------- 1 | legacy-peer-deps = true -------------------------------------------------------------------------------- /playgrounds/nuxt/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.nuxt/tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /playgrounds/vite-core/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /playgrounds/vite-react/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /playgrounds/vite-vue/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /packages/core/src/types/unit.ts: -------------------------------------------------------------------------------- 1 | export type Unit = 'ether' | 'gwei' | 'wei' | number 2 | -------------------------------------------------------------------------------- /site/public/og.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/wagmi/HEAD/site/public/og.png -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | [View Contributing Guide on wagmi.sh](https://wagmi.sh/dev/contributing) -------------------------------------------------------------------------------- /playgrounds/nuxt/server/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../.nuxt/tsconfig.server.json" 3 | } 4 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/next/_env.local: -------------------------------------------------------------------------------- 1 | NEXT_PUBLIC_WC_PROJECT_ID= 2 | NEXT_TELEMETRY_DISABLED=1 -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-react/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vue/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /site/snippets/vue/App.vue: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vanilla/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /site/public/browsers/edge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/wagmi/HEAD/site/public/browsers/edge.png -------------------------------------------------------------------------------- /packages/create-wagmi/templates/nuxt/_env.local: -------------------------------------------------------------------------------- 1 | NUXT_PUBLIC_WC_PROJECT_ID= 2 | NUXT_TELEMETRY_DISABLED=1 3 | 4 | -------------------------------------------------------------------------------- /site/public/browsers/chrome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/wagmi/HEAD/site/public/browsers/chrome.png -------------------------------------------------------------------------------- /site/public/browsers/opera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/wagmi/HEAD/site/public/browsers/opera.png -------------------------------------------------------------------------------- /site/public/browsers/safari.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/wagmi/HEAD/site/public/browsers/safari.png -------------------------------------------------------------------------------- /packages/cli/src/plugins/__fixtures__/hardhat/hardhat.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | solidity: '0.8.17', 3 | } 4 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/nuxt/server/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../.nuxt/tsconfig.server.json" 3 | } 4 | -------------------------------------------------------------------------------- /site/public/browsers/firefox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/wagmi/HEAD/site/public/browsers/firefox.png -------------------------------------------------------------------------------- /playgrounds/nuxt/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/wagmi/HEAD/playgrounds/nuxt/public/favicon.ico -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | Contact [dev@wevm.dev](mailto:dev@wevm.dev). 6 | 7 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | auto-install-peers=false 2 | enable-pre-post-scripts=true 3 | link-workspace-packages=deep 4 | strict-peer-dependencies=false 5 | -------------------------------------------------------------------------------- /packages/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.build.json", 3 | "include": ["src/**/*.ts"], 4 | "exclude": [] 5 | } 6 | -------------------------------------------------------------------------------- /packages/connectors/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.build.json", 3 | "include": ["src/**/*.ts"], 4 | "exclude": [] 5 | } 6 | -------------------------------------------------------------------------------- /packages/create-wagmi/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.build.json", 3 | "include": ["src/**/*.ts"], 4 | "exclude": [] 5 | } 6 | -------------------------------------------------------------------------------- /packages/react/src/utils/getVersion.ts: -------------------------------------------------------------------------------- 1 | import { version } from '../version.js' 2 | 3 | export const getVersion = () => `wagmi@${version}` 4 | -------------------------------------------------------------------------------- /packages/core/src/utils/getVersion.ts: -------------------------------------------------------------------------------- 1 | import { version } from '../version.js' 2 | 3 | export const getVersion = () => `@wagmi/core@${version}` 4 | -------------------------------------------------------------------------------- /packages/core/test/setup.ts: -------------------------------------------------------------------------------- 1 | import { vi } from 'vitest' 2 | 3 | vi.mock('../src/version.ts', () => { 4 | return { version: 'x.y.z' } 5 | }) 6 | -------------------------------------------------------------------------------- /packages/vue/src/utils/getVersion.ts: -------------------------------------------------------------------------------- 1 | import { version } from '../version.js' 2 | 3 | export const getVersion = () => `@wagmi/vue@${version}` 4 | -------------------------------------------------------------------------------- /packages/core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.build.json", 3 | "include": ["src/**/*.ts", "test/**/*.ts"], 4 | "exclude": [] 5 | } 6 | -------------------------------------------------------------------------------- /packages/test/src/regex.ts: -------------------------------------------------------------------------------- 1 | export const addressRegex = /^0x([A-Fa-f0-9]{40})$/ 2 | 3 | export const transactionHashRegex = /^0x([A-Fa-f0-9]{64})$/ 4 | -------------------------------------------------------------------------------- /packages/vue/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.build.json", 3 | "include": ["src/**/*.ts", "test/**/*.ts"], 4 | "exclude": [] 5 | } 6 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "biomejs.biome", 4 | "orta.vscode-twoslash-queries", 5 | "Vue.volar" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /packages/register-tests/react/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.base.json", 3 | "include": ["src/**/*.ts"], 4 | "exclude": [] 5 | } 6 | -------------------------------------------------------------------------------- /packages/register-tests/vue/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.base.json", 3 | "include": ["src/**/*.ts"], 4 | "exclude": [] 5 | } 6 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/next/next.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = {} 3 | 4 | module.exports = nextConfig 5 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/nuxt/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | // https://nuxt.com/docs/guide/concepts/typescript 3 | "extends": "./.nuxt/tsconfig.json" 4 | } 5 | -------------------------------------------------------------------------------- /playgrounds/vite-react/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vite-react", 3 | "description": "vite-react playground", 4 | "iconPath": "favicon.ico" 5 | } 6 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: 'github-actions' 4 | directory: '/' 5 | schedule: 6 | interval: 'monthly' 7 | -------------------------------------------------------------------------------- /packages/cli/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.build.json", 3 | "include": ["src/**/*.ts", "test/**/*.ts", "types/**/*.d.ts"], 4 | "exclude": [] 5 | } 6 | -------------------------------------------------------------------------------- /packages/vue/src/exports/nuxt.ts: -------------------------------------------------------------------------------- 1 | import { wagmiModule } from '../nuxt/module.js' 2 | 3 | export type { WagmiModuleOptions } from '../nuxt/module.js' 4 | export default wagmiModule 5 | -------------------------------------------------------------------------------- /packages/cli/src/plugins/__fixtures__/hardhat/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hardhat-fixture", 3 | "private": true, 4 | "devDependencies": { 5 | "hardhat": "^2.22.3" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/next/README.md: -------------------------------------------------------------------------------- 1 | This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-wagmi`](https://github.com/wevm/wagmi/tree/main/packages/create-wagmi). 2 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vue/README.md: -------------------------------------------------------------------------------- 1 | This is a [Vite](https://vitejs.dev) project bootstrapped with [`create-wagmi`](https://github.com/wevm/wagmi/tree/main/packages/create-wagmi). 2 | -------------------------------------------------------------------------------- /packages/cli/src/plugins/__fixtures__/hardhat/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .env 3 | coverage 4 | coverage.json 5 | typechain 6 | typechain-types 7 | 8 | # Hardhat files 9 | cache 10 | artifacts -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-react/README.md: -------------------------------------------------------------------------------- 1 | This is a [Vite](https://vitejs.dev) project bootstrapped with [`create-wagmi`](https://github.com/wevm/wagmi/tree/main/packages/create-wagmi). 2 | -------------------------------------------------------------------------------- /site/react/api/transports/http.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: http 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/vue/api/transports/http.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: http 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/core/api/transports/http.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: http 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/react/api/transports/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: custom 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/core/api/transports/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: custom 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/react/api/transports/fallback.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: fallback 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/react/api/utilities/serialize.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: serialize 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/vue/api/transports/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: custom 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/core/api/transports/fallback.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: fallback 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/core/api/utilities/serialize.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: serialize 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/react/api/transports/webSocket.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: webSocket 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/react/api/utilities/deserialize.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: deserialize 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/vue/api/transports/fallback.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: fallback 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/vue/api/transports/webSocket.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: webSocket 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/vue/api/utilities/serialize.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: serialize 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/cli/src/exports/index.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf } from 'vitest' 2 | 3 | // noop test because vitest typecheck fails unless each workspace project has type test 4 | expectTypeOf(1).toEqualTypeOf() 5 | -------------------------------------------------------------------------------- /playgrounds/vite-vue/vite.config.ts: -------------------------------------------------------------------------------- 1 | import vue from '@vitejs/plugin-vue' 2 | import { defineConfig } from 'vite' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [vue()], 7 | }) 8 | -------------------------------------------------------------------------------- /site/core/api/transports/webSocket.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: webSocket 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/core/api/utilities/deserialize.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: deserialize 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/react/api/connectors/coinbaseWallet.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | -------------------------------------------------------------------------------- /site/vue/api/utilities/deserialize.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: deserialize 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/create-wagmi/src/index.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf } from 'vitest' 2 | 3 | // noop test because vitest typecheck fails unless each workspace project has type test 4 | expectTypeOf(1).toEqualTypeOf() 5 | -------------------------------------------------------------------------------- /packages/test/src/exports/index.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf } from 'vitest' 2 | 3 | // noop test because vitest typecheck fails unless each workspace project has type test 4 | expectTypeOf(1).toEqualTypeOf() 5 | -------------------------------------------------------------------------------- /packages/vue/src/nuxt/runtime/composables.ts: -------------------------------------------------------------------------------- 1 | // biome-ignore lint/performance/noBarrelFile: entrypoint module 2 | // biome-ignore lint/performance/noReExportAll: entrypoint module 3 | export * from '../../exports/index.js' 4 | -------------------------------------------------------------------------------- /playgrounds/vite-core/vite.config.ts: -------------------------------------------------------------------------------- 1 | import react from '@vitejs/plugin-react' 2 | import { defineConfig } from 'vite' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | }) 8 | -------------------------------------------------------------------------------- /playgrounds/vite-react/vite.config.ts: -------------------------------------------------------------------------------- 1 | import react from '@vitejs/plugin-react' 2 | import { defineConfig } from 'vite' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | }) 8 | -------------------------------------------------------------------------------- /site/core/api/connectors/coinbaseWallet.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | -------------------------------------------------------------------------------- /site/vue/api/errors.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | # Errors 7 | 8 | Error classes used by Wagmi. 9 | 10 | -------------------------------------------------------------------------------- /packages/create-wagmi/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "include": ["src/**/*.ts"], 4 | "exclude": ["src/**/*.test.ts"], 5 | "compilerOptions": { 6 | "sourceMap": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /site/react/api/createStorage.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: createStorage 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /site/react/api/utilities/normalizeChainId.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: normalizeChainId 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/vue/api/connectors/coinbaseWallet.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | -------------------------------------------------------------------------------- /site/core/api/createStorage.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: createStorage 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /site/core/api/utilities/normalizeChainId.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: normalizeChainId 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/vue/api/createStorage.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: createStorage 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.base.json", 3 | "include": ["scripts/**/*.ts", "vitest.config.ts"], 4 | "exclude": [], 5 | "compilerOptions": { 6 | "types": ["@vitest/browser/providers/playwright"] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vue/vite.config.ts: -------------------------------------------------------------------------------- 1 | import vue from '@vitejs/plugin-vue' 2 | import { defineConfig } from 'vite' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [vue()], 7 | }) 8 | -------------------------------------------------------------------------------- /site/core/api/errors.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | # Errors 7 | 8 | Error classes used by Wagmi. 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /packages/core/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "include": ["src/**/*.ts"], 4 | "exclude": ["src/**/*.test.ts", "src/**/*.test-d.ts"], 5 | "compilerOptions": { 6 | "sourceMap": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-react/vite.config.ts: -------------------------------------------------------------------------------- 1 | import react from '@vitejs/plugin-react' 2 | import { defineConfig } from 'vite' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | }) 8 | -------------------------------------------------------------------------------- /packages/react/src/utils/getVersion.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest' 2 | 3 | import { getVersion } from './getVersion.js' 4 | 5 | test('default', () => { 6 | expect(getVersion()).toMatchInlineSnapshot(`"wagmi@x.y.z"`) 7 | }) 8 | -------------------------------------------------------------------------------- /packages/react/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "include": ["src/**/*.ts"], 4 | "exclude": ["src/**/*.test.ts", "src/**/*.test-d.ts"], 5 | "compilerOptions": { 6 | "sourceMap": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/react/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.build.json", 3 | "compilerOptions": { 4 | "jsx": "preserve" 5 | }, 6 | "include": ["src/**/*.ts", "src/**/*.tsx", "test/**/*.ts", "test/**/*.tsx"], 7 | "exclude": [] 8 | } 9 | -------------------------------------------------------------------------------- /packages/test/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "include": ["src/**/*.ts"], 4 | "exclude": ["src/**/*.test.ts", "src/**/*.test-d.ts"], 5 | "compilerOptions": { 6 | "sourceMap": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/vue/src/utils/getVersion.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest' 2 | 3 | import { getVersion } from './getVersion.js' 4 | 5 | test('default', () => { 6 | expect(getVersion()).toMatchInlineSnapshot(`"@wagmi/vue@x.y.z"`) 7 | }) 8 | -------------------------------------------------------------------------------- /packages/vue/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "include": ["src/**/*.ts"], 4 | "exclude": ["src/**/*.test.ts", "src/**/*.test-d.ts"], 5 | "compilerOptions": { 6 | "sourceMap": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /site/react/api/utilities/cookieToInitialState.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: cookieToInitialState 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/connectors/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "include": ["src/**/*.ts"], 4 | "exclude": ["src/**/*.test.ts", "src/**/*.test-d.ts"], 5 | "compilerOptions": { 6 | "sourceMap": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/core/src/utils/getVersion.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest' 2 | 3 | import { getVersion } from './getVersion.js' 4 | 5 | test('default', () => { 6 | expect(getVersion()).toMatchInlineSnapshot(`"@wagmi/core@x.y.z"`) 7 | }) 8 | -------------------------------------------------------------------------------- /site/core/api/utilities/cookieToInitialState.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: cookieToInitialState 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/cli/src/plugins/__fixtures__/foundry/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiler files 2 | cache/ 3 | out/ 4 | 5 | # Ignores development broadcast logs 6 | !/broadcast 7 | /broadcast/*/31337/ 8 | /broadcast/**/dry-run/ 9 | 10 | # Dotenv file 11 | .env 12 | -------------------------------------------------------------------------------- /packages/vue/test/setup.ts: -------------------------------------------------------------------------------- 1 | import { vi } from 'vitest' 2 | 3 | // Make dates stable across runs 4 | Date.now = vi.fn(() => new Date(Date.UTC(2023, 1, 1)).valueOf()) 5 | 6 | vi.mock('../src/version.ts', () => { 7 | return { version: 'x.y.z' } 8 | }) 9 | -------------------------------------------------------------------------------- /site/react/api/connectors/mock.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: mock 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /site/react/api/connectors/porto.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: porto 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /site/react/api/connectors/safe.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: safe 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /playgrounds/nuxt/nuxt.config.ts: -------------------------------------------------------------------------------- 1 | import { defineNuxtConfig } from 'nuxt/config' 2 | 3 | // https://nuxt.com/docs/api/configuration/nuxt-config 4 | export default defineNuxtConfig({ 5 | devtools: { enabled: true }, 6 | modules: ['@wagmi/vue/nuxt'], 7 | }) 8 | -------------------------------------------------------------------------------- /site/core/api/connectors/mock.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: mock 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /site/core/api/connectors/porto.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: porto 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /site/core/api/connectors/safe.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: safe 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /site/vue/api/connectors/mock.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: mock 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /site/vue/api/connectors/safe.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: safe 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/cli/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "include": ["src/**/*.ts"], 4 | "exclude": ["src/**/*.test.ts"], 5 | "compilerOptions": { 6 | "sourceMap": true, 7 | "types": ["@types/node"] 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /site/vue/api/connectors/gemini.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: gemini 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /site/vue/api/connectors/porto.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: porto 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /site/vue/guides/faq.md: -------------------------------------------------------------------------------- 1 | 4 | 5 | # FAQ / Troubleshooting 6 | 7 | Collection of frequently asked questions with ideas on how to troubleshoot and resolve them. 8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/cli/src/plugins/__fixtures__/foundry/foundry.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | libs = ['lib'] 3 | out = 'out' 4 | solc = '0.8.13' 5 | src = 'src' 6 | 7 | # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options 8 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/next/next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | // NOTE: This file should not be edited 5 | // see https://nextjs.org/docs/basic-features/typescript for more information. 6 | -------------------------------------------------------------------------------- /site/core/guides/faq.md: -------------------------------------------------------------------------------- 1 | 4 | 5 | # FAQ / Troubleshooting 6 | 7 | Collection of frequently asked questions with ideas on how to troubleshoot and resolve them. 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/react/api/transports/unstable_connector.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: unstable_connector 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /site/vue/api/transports/unstable_connector.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: unstable_connector 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /FUNDING.json: -------------------------------------------------------------------------------- 1 | { 2 | "drips": { 3 | "ethereum": { 4 | "ownedBy": "0xd2135CfB216b74109775236E36d4b433F1DF507B" 5 | } 6 | }, 7 | "opRetro": { 8 | "projectId": "0xc0615947773148cbc340b175fb9afc98dbb4e0acd31d018b1ee41a5538785abf" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/core/README.md: -------------------------------------------------------------------------------- 1 | # @wagmi/core 2 | 3 | VanillaJS library for Ethereum 4 | 5 | ## Installation 6 | 7 | ```bash 8 | pnpm add @wagmi/core viem 9 | ``` 10 | 11 | ## Documentation 12 | 13 | For documentation and guides, visit [wagmi.sh](https://wagmi.sh). 14 | -------------------------------------------------------------------------------- /site/core/api/transports/unstable_connector.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: unstable_connector 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /site/react/api/connectors/baseAccount.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: baseAccount 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/cli/README.md: -------------------------------------------------------------------------------- 1 | # @wagmi/cli 2 | 3 | Manage and generate code from Ethereum ABIs 4 | 5 | ## Installation 6 | 7 | ```bash 8 | pnpm add @wagmi/cli 9 | ``` 10 | 11 | ## Documentation 12 | 13 | For documentation and guides, visit [wagmi.sh](https://wagmi.sh). 14 | -------------------------------------------------------------------------------- /packages/cli/src/plugins/__fixtures__/foundry/src/Foo.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | contract Foo { 5 | string public bar; 6 | 7 | function setFoo(string memory baz) public { 8 | bar = baz; 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /packages/cli/src/plugins/__fixtures__/hardhat/contracts/Foo.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | contract Foo { 5 | string public bar; 6 | 7 | function setFoo(string memory baz) public { 8 | bar = baz; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/nuxt/nuxt.config.ts: -------------------------------------------------------------------------------- 1 | import { defineNuxtConfig } from 'nuxt/config' 2 | 3 | // https://nuxt.com/docs/api/configuration/nuxt-config 4 | export default defineNuxtConfig({ 5 | devtools: { enabled: true }, 6 | modules: ['@wagmi/vue/nuxt'], 7 | }) 8 | -------------------------------------------------------------------------------- /packages/react/README.md: -------------------------------------------------------------------------------- 1 | # wagmi 2 | 3 | React Hooks for Ethereum 4 | 5 | ## Installation 6 | 7 | ```bash 8 | pnpm add wagmi viem @tanstack/react-query 9 | ``` 10 | 11 | ## Documentation 12 | 13 | For documentation and guides, visit [wagmi.sh](https://wagmi.sh). 14 | -------------------------------------------------------------------------------- /packages/vue/src/exports/nuxt.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest' 2 | 3 | import * as nuxt from './nuxt.js' 4 | 5 | test('exports', () => { 6 | expect(Object.keys(nuxt)).toMatchInlineSnapshot(` 7 | [ 8 | "default", 9 | ] 10 | `) 11 | }) 12 | -------------------------------------------------------------------------------- /site/core/api/connectors/baseAccount.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: baseAccount 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /site/react/api/connectors/walletConnect.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: walletConnect 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /site/vue/api/connectors/baseAccount.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: baseAccount 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /site/core/api/connectors/walletConnect.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: walletConnect 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /site/react/api/createConfig.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: createConfig 3 | --- 4 | 5 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /site/core/api/createConfig.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: createConfig 3 | --- 4 | 5 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /site/react/api/connectors/gemini.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: gemini 3 | --- 4 | 5 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /site/vue/api/connectors/walletConnect.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: walletConnect 3 | --- 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /site/vue/api/createConfig.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: createConfig 3 | --- 4 | 5 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /packages/cli/src/exports/config.ts: -------------------------------------------------------------------------------- 1 | // biome-ignore lint/performance/noBarrelFile: entrypoint module 2 | export { 3 | type Config, 4 | type Contract, 5 | type ContractConfig, 6 | defaultConfig, 7 | defineConfig, 8 | type Plugin, 9 | type Watch, 10 | } from '../config.js' 11 | -------------------------------------------------------------------------------- /packages/vue/README.md: -------------------------------------------------------------------------------- 1 | # @wagmi/vue 2 | 3 | Vue Composables for Ethereum 4 | 5 | ## Installation 6 | 7 | ```bash 8 | pnpm add @wagmi/vue viem @tanstack/vue-query 9 | ``` 10 | 11 | ## Documentation 12 | 13 | For documentation and guides, visit [wagmi.sh](https://wagmi.sh). 14 | 15 | -------------------------------------------------------------------------------- /site/core/api/connectors/gemini.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: gemini 3 | --- 4 | 5 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /site/react/api/connectors/injected.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: injected 3 | --- 4 | 5 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /site/react/api/connectors/metaMask.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: metaMask 3 | --- 4 | 5 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /site/core/api/connectors/injected.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: injected 3 | --- 4 | 5 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /site/core/api/connectors/metaMask.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: metaMask 3 | --- 4 | 5 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /site/vue/api/connectors/injected.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: injected 3 | --- 4 | 5 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /site/vue/api/connectors/metaMask.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: metaMask 3 | --- 4 | 5 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /packages/core/src/actions/getBlockNumber.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { getBlockNumber } from './getBlockNumber.js' 5 | 6 | test('default', async () => { 7 | await expect(getBlockNumber(config)).resolves.toBeDefined() 8 | }) 9 | -------------------------------------------------------------------------------- /packages/core/src/utils/getUnit.ts: -------------------------------------------------------------------------------- 1 | import { weiUnits } from 'viem' 2 | 3 | import type { Unit } from '../types/unit.js' 4 | 5 | export function getUnit(unit: Unit) { 6 | if (typeof unit === 'number') return unit 7 | if (unit === 'wei') return 0 8 | return Math.abs(weiUnits[unit]) 9 | } 10 | -------------------------------------------------------------------------------- /playgrounds/vite-core/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true 8 | }, 9 | "include": ["vite.config.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /playgrounds/vite-react/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true 8 | }, 9 | "include": ["vite.config.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/connectors/README.md: -------------------------------------------------------------------------------- 1 | # @wagmi/connectors 2 | 3 | Collection of connectors for Wagmi 4 | 5 | ## Installation 6 | 7 | ```bash 8 | pnpm add @wagmi/connectors @wagmi/core viem 9 | ``` 10 | 11 | ## Documentation 12 | 13 | For documentation and guides, visit [wagmi.sh](https://wagmi.sh). 14 | -------------------------------------------------------------------------------- /site/components/Browsers.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site/snippets/react/config.ts: -------------------------------------------------------------------------------- 1 | import { createConfig, http } from 'wagmi' 2 | import { mainnet, sepolia } from 'wagmi/chains' 3 | 4 | export const config = createConfig({ 5 | chains: [mainnet, sepolia], 6 | transports: { 7 | [mainnet.id]: http(), 8 | [sepolia.id]: http(), 9 | }, 10 | }) 11 | -------------------------------------------------------------------------------- /packages/cli/src/exports/config.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest' 2 | 3 | import * as Exports from './config.js' 4 | 5 | test('exports', () => { 6 | expect(Object.keys(Exports)).toMatchInlineSnapshot(` 7 | [ 8 | "defaultConfig", 9 | "defineConfig", 10 | ] 11 | `) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/vue/src/exports/internal.ts: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Types 3 | //////////////////////////////////////////////////////////////////////////////// 4 | 5 | export type { 6 | ConfigParameter, 7 | QueryParameter, 8 | } from '../types/properties.js' 9 | -------------------------------------------------------------------------------- /site/snippets/vue/config.ts: -------------------------------------------------------------------------------- 1 | import { createConfig, http } from '@wagmi/vue' 2 | import { mainnet, sepolia } from '@wagmi/vue/chains' 3 | 4 | export const config = createConfig({ 5 | chains: [mainnet, sepolia], 6 | transports: { 7 | [mainnet.id]: http(), 8 | [sepolia.id]: http(), 9 | }, 10 | }) 11 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-react/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true 8 | }, 9 | "include": ["vite.config.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/react/src/exports/internal.ts: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Types 3 | //////////////////////////////////////////////////////////////////////////////// 4 | 5 | export type { 6 | ConfigParameter, 7 | QueryParameter, 8 | } from '../types/properties.js' 9 | -------------------------------------------------------------------------------- /playgrounds/vite-vue/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true, 8 | "strict": true 9 | }, 10 | "include": ["vite.config.ts"] 11 | } 12 | -------------------------------------------------------------------------------- /site/snippets/core/config.ts: -------------------------------------------------------------------------------- 1 | import { createConfig, http } from '@wagmi/core' 2 | import { mainnet, sepolia } from '@wagmi/core/chains' 3 | 4 | export const config = createConfig({ 5 | chains: [mainnet, sepolia], 6 | transports: { 7 | [mainnet.id]: http(), 8 | [sepolia.id]: http(), 9 | }, 10 | }) 11 | -------------------------------------------------------------------------------- /.vscode/workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "name": "docs", 5 | "path": "../docs" 6 | }, 7 | { 8 | "name": "packages", 9 | "path": "../packages" 10 | }, 11 | { 12 | "name": "playgrounds", 13 | "path": "../playgrounds" 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /packages/test/src/setup.ts: -------------------------------------------------------------------------------- 1 | import { afterAll } from 'vitest' 2 | 3 | import { testClient } from './clients.js' 4 | 5 | afterAll(async () => { 6 | // If you are using a fork, you can reset your anvil instance to the initial fork block. 7 | await Promise.all(Object.values(testClient).map((client) => client.restart())) 8 | }) 9 | -------------------------------------------------------------------------------- /packages/cli/src/utils/format.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest' 2 | 3 | import { format } from './format.js' 4 | 5 | test('formats code', async () => { 6 | await expect( 7 | format(`const foo = "bar"`), 8 | ).resolves.toMatchInlineSnapshot(` 9 | "const foo = 'bar' 10 | " 11 | `) 12 | }) 13 | -------------------------------------------------------------------------------- /playgrounds/nuxt/.gitignore: -------------------------------------------------------------------------------- 1 | # Nuxt dev/build outputs 2 | .output 3 | .data 4 | .nuxt 5 | .nitro 6 | .cache 7 | dist 8 | 9 | # Node dependencies 10 | node_modules 11 | 12 | # Logs 13 | logs 14 | *.log 15 | 16 | # Misc 17 | .DS_Store 18 | .fleet 19 | .idea 20 | 21 | # Local env files 22 | .env 23 | .env.* 24 | !.env.example 25 | -------------------------------------------------------------------------------- /playgrounds/vite-vue/src/components/Client.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | Client 9 | 10 | 11 | View 12 | {{ client }} 13 | 14 | 15 | -------------------------------------------------------------------------------- /packages/cli/src/types.ts: -------------------------------------------------------------------------------- 1 | export type Compute = { [key in keyof type]: type[key] } & unknown 2 | 3 | export type MaybeArray = T | T[] 4 | 5 | export type MaybePromise = T | Promise 6 | 7 | export type RequiredBy = Required< 8 | Pick 9 | > & 10 | Omit 11 | -------------------------------------------------------------------------------- /packages/core/src/transports/fallback.ts: -------------------------------------------------------------------------------- 1 | import { fallback as viem_fallback } from 'viem' 2 | 3 | import type { Transport } from '../createConfig.js' 4 | 5 | export function fallback( 6 | transports: Transport[], 7 | config?: Parameters[1], 8 | ) { 9 | return viem_fallback(transports, config) 10 | } 11 | -------------------------------------------------------------------------------- /packages/core/src/types/register.ts: -------------------------------------------------------------------------------- 1 | import type { Config } from '../createConfig.js' 2 | 3 | // biome-ignore lint/suspicious/noEmptyInterface: using 4 | export interface Register {} 5 | export type ResolvedRegister = { 6 | config: Register extends { config: infer config extends Config } 7 | ? config 8 | : Config 9 | } 10 | -------------------------------------------------------------------------------- /packages/core/src/utils/getUnit.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest' 2 | 3 | import { getUnit } from './getUnit.js' 4 | 5 | test('default', () => { 6 | expect(getUnit(1)).toMatchInlineSnapshot('1') 7 | expect(getUnit('wei')).toMatchInlineSnapshot('0') 8 | expect(getUnit('ether')).toMatchInlineSnapshot('18') 9 | }) 10 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vue/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true, 8 | "strict": true 9 | }, 10 | "include": ["vite.config.ts"] 11 | } 12 | -------------------------------------------------------------------------------- /packages/register-tests/vue/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-register", 3 | "private": true, 4 | "type": "module", 5 | "scripts": { 6 | "check:types": "tsc --noEmit" 7 | }, 8 | "dependencies": { 9 | "@tanstack/vue-query": "catalog:", 10 | "@wagmi/vue": "workspace:*", 11 | "vue": "catalog:" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/cli/src/exports/index.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest' 2 | 3 | import * as Exports from './index.js' 4 | 5 | test('exports', () => { 6 | expect(Object.keys(Exports)).toMatchInlineSnapshot(` 7 | [ 8 | "defineConfig", 9 | "logger", 10 | "loadEnv", 11 | "version", 12 | ] 13 | `) 14 | }) 15 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/nuxt/_gitignore: -------------------------------------------------------------------------------- 1 | # Nuxt dev/build outputs 2 | .output 3 | .data 4 | .nuxt 5 | .nitro 6 | .cache 7 | dist 8 | 9 | # Node dependencies 10 | node_modules 11 | 12 | # Logs 13 | logs 14 | *.log 15 | 16 | # Misc 17 | .DS_Store 18 | .fleet 19 | .idea 20 | 21 | # Local env files 22 | .env 23 | .env.* 24 | !.env.example 25 | -------------------------------------------------------------------------------- /playgrounds/vite-vue/src/components/Balance.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | Balance 10 | 11 | Balance: {{ balance?.formatted }} 12 | 13 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | @tmm @jxom 2 | 3 | /packages/connectors/src/gemini @mikelxc 4 | /packages/connectors/src/metaMask @ecp4224 @omridan159 @abretonc7s @elefantel @BjornGunnarsson @EdouardBougon 5 | /packages/connectors/src/safe @DaniSomoza @dasanra @mikhailxyz @yagopv 6 | /packages/connectors/src/walletConnect @ganchoradkov @glitch-txs @ignaciosantise @tomiir 7 | -------------------------------------------------------------------------------- /packages/connectors/src/porto.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { porto } from './porto.js' 5 | 6 | test('setup', () => { 7 | const connectorFn = porto() 8 | const connector = config._internal.connectors.setup(connectorFn) 9 | expect(connector.name).toEqual('Porto') 10 | }) 11 | -------------------------------------------------------------------------------- /packages/core/src/actions/getConnectors.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { getConnectors } from './getConnectors.js' 5 | 6 | test('default', () => { 7 | expect(getConnectors(config)).toEqual(config.connectors) 8 | expect(getConnectors(config)).toEqual(config.connectors) 9 | }) 10 | -------------------------------------------------------------------------------- /packages/react/test/setup.ts: -------------------------------------------------------------------------------- 1 | import { vi } from 'vitest' 2 | 3 | // Make dates stable across runs 4 | Date.now = vi.fn(() => new Date(Date.UTC(2023, 1, 1)).valueOf()) 5 | 6 | vi.mock('../src/version.ts', () => { 7 | return { version: 'x.y.z' } 8 | }) 9 | 10 | vi.mock('../../core/src/version.ts', () => { 11 | return { version: 'x.y.z' } 12 | }) 13 | -------------------------------------------------------------------------------- /packages/cli/src/plugins/__fixtures__/foundry/src/Counter.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | contract Counter { 5 | uint256 public number; 6 | 7 | function setNumber(uint256 newNumber) public { 8 | number = newNumber; 9 | } 10 | 11 | function increment() public { 12 | number++; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/test/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | interface ImportMetaEnv { 4 | readonly VITE_MAINNET_FORK_URL?: string | undefined 5 | readonly VITE_OPTIMISM_FORK_URL?: string | undefined 6 | readonly VITE_WC_PROJECT_ID?: string | undefined 7 | } 8 | 9 | interface ImportMeta { 10 | readonly env: ImportMetaEnv 11 | } 12 | -------------------------------------------------------------------------------- /packages/cli/src/plugins/__fixtures__/hardhat/contracts/Counter.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | contract Counter { 5 | uint256 public number; 6 | 7 | function setNumber(uint256 newNumber) public { 8 | number = newNumber; 9 | } 10 | 11 | function increment() public { 12 | number++; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /site/snippets/core/config-chain-properties.ts: -------------------------------------------------------------------------------- 1 | import { createConfig, http } from '@wagmi/core' 2 | import { base, celo, mainnet } from '@wagmi/core/chains' 3 | 4 | export const config = createConfig({ 5 | chains: [base, celo, mainnet], 6 | transports: { 7 | [base.id]: http(), 8 | [celo.id]: http(), 9 | [mainnet.id]: http(), 10 | }, 11 | }) 12 | -------------------------------------------------------------------------------- /packages/connectors/src/metaMask.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { metaMask } from './metaMask.js' 5 | 6 | test('setup', () => { 7 | const connectorFn = metaMask() 8 | const connector = config._internal.connectors.setup(connectorFn) 9 | expect(connector.name).toEqual('MetaMask') 10 | }) 11 | -------------------------------------------------------------------------------- /packages/core/src/actions/codegen/createWriteContract.test.ts: -------------------------------------------------------------------------------- 1 | import { abi } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { createWriteContract } from './createWriteContract.js' 5 | 6 | test('default', () => { 7 | const writeErc20 = createWriteContract({ 8 | abi: abi.erc20, 9 | }) 10 | expect(writeErc20).toBeDefined() 11 | }) 12 | -------------------------------------------------------------------------------- /packages/core/src/exports/internal.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest' 2 | 3 | import * as internal from './internal.js' 4 | 5 | test('exports', () => { 6 | expect(Object.keys(internal)).toMatchInlineSnapshot(` 7 | [ 8 | "watchChains", 9 | "createEmitter", 10 | "Emitter", 11 | "deepEqual", 12 | "uid", 13 | ] 14 | `) 15 | }) 16 | -------------------------------------------------------------------------------- /playgrounds/vite-core/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Vite Core 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /playgrounds/vite-react/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Vite React 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /playgrounds/vite-vue/src/components/ConnectorClient.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | Connector Client 9 | 10 | 11 | View 12 | {{ connectorClient }} 13 | 14 | 15 | -------------------------------------------------------------------------------- /packages/core/src/exports/chains.ts: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // viem/chains 3 | //////////////////////////////////////////////////////////////////////////////// 4 | 5 | // biome-ignore lint/performance/noBarrelFile: entrypoint module 6 | // biome-ignore lint/performance/noReExportAll: entrypoint module 7 | export * from 'viem/chains' 8 | -------------------------------------------------------------------------------- /packages/react/src/exports/chains.ts: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // viem/chains 3 | //////////////////////////////////////////////////////////////////////////////// 4 | 5 | // biome-ignore lint/performance/noBarrelFile: entrypoint module 6 | // biome-ignore lint/performance/noReExportAll: entrypoint module 7 | export * from 'viem/chains' 8 | -------------------------------------------------------------------------------- /packages/vue/src/exports/chains.ts: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // viem/chains 3 | //////////////////////////////////////////////////////////////////////////////// 4 | 5 | // biome-ignore lint/performance/noBarrelFile: entrypoint module 6 | // biome-ignore lint/performance/noReExportAll: entrypoint module 7 | export * from 'viem/chains' 8 | -------------------------------------------------------------------------------- /packages/vue/src/utils/updateState.ts: -------------------------------------------------------------------------------- 1 | // Credit: https://github.com/TanStack/query/blob/01ce023826b81e6c41e354f27691f65c9725af67/packages/vue-query/src/utils.ts#L11-L18 2 | 3 | export function updateState( 4 | state: Record, 5 | update: Record, 6 | ): void { 7 | for (const key of Object.keys(state)) { 8 | state[key] = update[key] 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useToken.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf, test } from 'vitest' 2 | 3 | import { useToken } from './useToken.js' 4 | 5 | test('select data', () => { 6 | const result = useToken({ 7 | query: { 8 | select(data) { 9 | return data?.name 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /playgrounds/vite-core/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /playgrounds/vite-vue/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /packages/core/src/actions/getEnsAvatar.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { getEnsAvatar } from './getEnsAvatar.js' 5 | 6 | test.skip('default', async () => { 7 | await expect( 8 | getEnsAvatar(config, { 9 | name: 'wevm.eth', 10 | }), 11 | ).resolves.toMatchInlineSnapshot('"https://euc.li/wevm.eth"') 12 | }) 13 | -------------------------------------------------------------------------------- /packages/core/src/actions/getEnsText.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { getEnsText } from './getEnsText.js' 5 | 6 | test('default', async () => { 7 | await expect( 8 | getEnsText(config, { 9 | name: 'wevm.eth', 10 | key: 'com.twitter', 11 | }), 12 | ).resolves.toMatchInlineSnapshot('"wevm_dev"') 13 | }) 14 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-react/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Create Wagmi 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vanilla/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Create Wagmi 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vue/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Create Wagmi 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /site/snippets/typedData.ts: -------------------------------------------------------------------------------- 1 | import type { TypedData } from 'viem' 2 | 3 | export const types = { 4 | Person: [ 5 | { name: 'name', type: 'string' }, 6 | { name: 'wallet', type: 'address' }, 7 | ], 8 | Mail: [ 9 | { name: 'from', type: 'Person' }, 10 | { name: 'to', type: 'Person' }, 11 | { name: 'contents', type: 'string' }, 12 | ], 13 | } as const satisfies TypedData 14 | -------------------------------------------------------------------------------- /packages/connectors/src/baseAccount.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { baseAccount } from './baseAccount.js' 5 | 6 | test('setup', () => { 7 | const connectorFn = baseAccount({ appName: 'wagmi' }) 8 | const connector = config._internal.connectors.setup(connectorFn) 9 | expect(connector.name).toEqual('Base Account') 10 | }) 11 | -------------------------------------------------------------------------------- /packages/core/src/exports/codegen.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest' 2 | 3 | import * as codegen from './codegen.js' 4 | 5 | test('exports', () => { 6 | expect(Object.keys(codegen)).toMatchInlineSnapshot(` 7 | [ 8 | "createReadContract", 9 | "createSimulateContract", 10 | "createWatchContractEvent", 11 | "createWriteContract", 12 | ] 13 | `) 14 | }) 15 | -------------------------------------------------------------------------------- /packages/react/src/exports/actions.ts: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // @wagmi/core/actions 3 | //////////////////////////////////////////////////////////////////////////////// 4 | 5 | // biome-ignore lint/performance/noBarrelFile: entrypoint module 6 | // biome-ignore lint/performance/noReExportAll: entrypoint module 7 | export * from '@wagmi/core/actions' 8 | -------------------------------------------------------------------------------- /packages/react/src/exports/connectors.ts: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // @wagmi/connectors 3 | //////////////////////////////////////////////////////////////////////////////// 4 | 5 | // biome-ignore lint/performance/noBarrelFile: entrypoint module 6 | // biome-ignore lint/performance/noReExportAll: entrypoint module 7 | export * from '@wagmi/connectors' 8 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useBalance.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf, test } from 'vitest' 2 | 3 | import { useBalance } from './useBalance.js' 4 | 5 | test('select data', () => { 6 | const result = useBalance({ 7 | query: { 8 | select(data) { 9 | return data?.value 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /packages/vue/src/exports/actions.ts: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // @wagmi/core/actions 3 | //////////////////////////////////////////////////////////////////////////////// 4 | 5 | // biome-ignore lint/performance/noBarrelFile: entrypoint module 6 | // biome-ignore lint/performance/noReExportAll: entrypoint module 7 | export * from '@wagmi/core/actions' 8 | -------------------------------------------------------------------------------- /packages/vue/src/exports/connectors.ts: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // @wagmi/connectors 3 | //////////////////////////////////////////////////////////////////////////////// 4 | 5 | // biome-ignore lint/performance/noBarrelFile: entrypoint module 6 | // biome-ignore lint/performance/noReExportAll: entrypoint module 7 | export * from '@wagmi/connectors' 8 | -------------------------------------------------------------------------------- /packages/core/src/actions/getEnsName.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { getEnsName } from './getEnsName.js' 5 | 6 | test('default', async () => { 7 | await expect( 8 | getEnsName(config, { 9 | address: '0xd2135CfB216b74109775236E36d4b433F1DF507B', 10 | }), 11 | ).resolves.toMatchInlineSnapshot('"wevm.eth"') 12 | }) 13 | -------------------------------------------------------------------------------- /packages/create-wagmi/README.md: -------------------------------------------------------------------------------- 1 | # create-wagmi 2 | 3 | Get up and running quickly with [Wagmi](https://wagmi.sh) by using the `create-wagmi` CLI. 4 | 5 | ## Installation 6 | 7 | ```bash 8 | npm create wagmi 9 | # or 10 | pnpm create wagmi 11 | # or 12 | yarn create wagmi 13 | ``` 14 | 15 | ## Documentation 16 | 17 | For documentation and guides, visit [wagmi.sh](https://wagmi.sh/cli/create-wagmi). 18 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useGasPrice.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf, test } from 'vitest' 2 | 3 | import { useGasPrice } from './useGasPrice.js' 4 | 5 | test('select data', () => { 6 | const result = useGasPrice({ 7 | query: { 8 | select(data) { 9 | return data?.toString() 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /packages/core/src/actions/getEnsAddress.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { getEnsAddress } from './getEnsAddress.js' 5 | 6 | test('default', async () => { 7 | await expect( 8 | getEnsAddress(config, { name: 'wevm.eth' }), 9 | ).resolves.toMatchInlineSnapshot( 10 | '"0xd2135CfB216b74109775236E36d4b433F1DF507B"', 11 | ) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-react/_gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vue/_gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /packages/register-tests/react/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-register", 3 | "private": true, 4 | "type": "module", 5 | "scripts": { 6 | "check:types": "tsc --noEmit" 7 | }, 8 | "dependencies": { 9 | "@tanstack/react-query": "catalog:", 10 | "react": "catalog:", 11 | "wagmi": "workspace:*" 12 | }, 13 | "devDependencies": { 14 | "@types/react": "catalog:" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /playgrounds/nuxt/plugins/wagmi.ts: -------------------------------------------------------------------------------- 1 | import { VueQueryPlugin } from '@tanstack/vue-query' 2 | import { WagmiPlugin } from '@wagmi/vue' 3 | import { defineNuxtPlugin } from 'nuxt/app' 4 | 5 | import { config } from '../wagmi' 6 | 7 | // TODO: Move to @wagmi/vue/nuxt nitro plugin 8 | export default defineNuxtPlugin((nuxtApp) => { 9 | nuxtApp.vueApp.use(WagmiPlugin, { config }).use(VueQueryPlugin, {}) 10 | }) 11 | -------------------------------------------------------------------------------- /packages/core/src/actions/getChainId.test.ts: -------------------------------------------------------------------------------- 1 | import { chain, config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { getChainId } from './getChainId.js' 5 | 6 | test('default', async () => { 7 | expect(getChainId(config)).toEqual(chain.mainnet.id) 8 | config.setState((x) => ({ ...x, chainId: chain.mainnet2.id })) 9 | expect(getChainId(config)).toEqual(chain.mainnet2.id) 10 | }) 11 | -------------------------------------------------------------------------------- /packages/core/src/actions/getChainId.ts: -------------------------------------------------------------------------------- 1 | import type { Config } from '../createConfig.js' 2 | 3 | export type GetChainIdReturnType = 4 | config['chains'][number]['id'] 5 | 6 | /** https://wagmi.sh/core/api/actions/getChainId */ 7 | export function getChainId( 8 | config: config, 9 | ): GetChainIdReturnType { 10 | return config.state.chainId 11 | } 12 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vanilla/_gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useTransaction.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf, test } from 'vitest' 2 | 3 | import { useTransaction } from './useTransaction.js' 4 | 5 | test('select data', () => { 6 | const result = useTransaction({ 7 | query: { 8 | select(data) { 9 | return data?.nonce 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useVerifyMessage.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf, test } from 'vitest' 2 | 3 | import { useVerifyMessage } from './useVerifyMessage.js' 4 | 5 | test('select data', () => { 6 | const result = useVerifyMessage({ 7 | query: { 8 | select(data) { 9 | return data 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /packages/core/src/query/connect.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { connectMutationOptions } from './connect.js' 5 | 6 | test('default', () => { 7 | expect(connectMutationOptions(config)).toMatchInlineSnapshot(` 8 | { 9 | "mutationFn": [Function], 10 | "mutationKey": [ 11 | "connect", 12 | ], 13 | } 14 | `) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useEstimateGas.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf, test } from 'vitest' 2 | 3 | import { useEstimateGas } from './useEstimateGas.js' 4 | 5 | test('select data', () => { 6 | const result = useEstimateGas({ 7 | query: { 8 | select(data) { 9 | return data.toString() 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useFeeHistory.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf, test } from 'vitest' 2 | 3 | import { useFeeHistory } from './useFeeHistory.js' 4 | 5 | test('select data', () => { 6 | const result = useFeeHistory({ 7 | query: { 8 | select(data) { 9 | return data.gasUsedRatio 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /playgrounds/vite-react/.gitignore: -------------------------------------------------------------------------------- 1 | src/generated.ts 2 | 3 | # Logs 4 | logs 5 | *.log 6 | npm-debug.log* 7 | yarn-debug.log* 8 | yarn-error.log* 9 | pnpm-debug.log* 10 | lerna-debug.log* 11 | 12 | node_modules 13 | dist 14 | dist-ssr 15 | *.local 16 | 17 | # Editor directories and files 18 | .vscode/* 19 | !.vscode/extensions.json 20 | .idea 21 | .DS_Store 22 | *.suo 23 | *.ntvs* 24 | *.njsproj 25 | *.sln 26 | *.sw? 27 | -------------------------------------------------------------------------------- /packages/core/src/utils/uid.ts: -------------------------------------------------------------------------------- 1 | const size = 256 2 | let index = size 3 | let buffer: string 4 | 5 | export function uid(length = 11) { 6 | if (!buffer || index + length > size * 2) { 7 | buffer = '' 8 | index = 0 9 | for (let i = 0; i < size; i++) { 10 | buffer += ((256 + Math.random() * 256) | 0).toString(16).substring(1) 11 | } 12 | } 13 | return buffer.substring(index, index++ + length) 14 | } 15 | -------------------------------------------------------------------------------- /packages/react/src/exports/actions/experimental.ts: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // @wagmi/core/experimental 3 | //////////////////////////////////////////////////////////////////////////////// 4 | 5 | // biome-ignore lint/performance/noBarrelFile: entrypoint module 6 | // biome-ignore lint/performance/noReExportAll: entrypoint module 7 | export * from '@wagmi/core/experimental' 8 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useBytecode.test-d.ts: -------------------------------------------------------------------------------- 1 | import type { Hex } from 'viem' 2 | import { expectTypeOf, test } from 'vitest' 3 | import { useBytecode } from './useBytecode.js' 4 | 5 | test('select data', () => { 6 | const result = useBytecode({ 7 | query: { 8 | select(data) { 9 | return data 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useStorageAt.test-d.ts: -------------------------------------------------------------------------------- 1 | import type { Hex } from 'viem' 2 | import { expectTypeOf, test } from 'vitest' 3 | import { useStorageAt } from './useStorageAt.js' 4 | 5 | test('select data', () => { 6 | const result = useStorageAt({ 7 | query: { 8 | select(data) { 9 | return data 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useTransactionCount.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf, test } from 'vitest' 2 | 3 | import { useTransactionCount } from './useTransactionCount.js' 4 | 5 | test('select data', () => { 6 | const result = useTransactionCount({ 7 | query: { 8 | select(data) { 9 | return data 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /packages/vue/src/composables/useTransaction.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf, test } from 'vitest' 2 | 3 | import { useTransaction } from './useTransaction.js' 4 | 5 | test('select data', () => { 6 | const result = useTransaction({ 7 | query: { 8 | select(data) { 9 | return data?.nonce 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data.value).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /packages/vue/src/exports/actions/experimental.ts: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // @wagmi/core/experimental 3 | //////////////////////////////////////////////////////////////////////////////// 4 | 5 | // biome-ignore lint/performance/noBarrelFile: entrypoint module 6 | // biome-ignore lint/performance/noReExportAll: entrypoint module 7 | export * from '@wagmi/core/experimental' 8 | -------------------------------------------------------------------------------- /packages/core/src/query/reconnect.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { reconnectMutationOptions } from './reconnect.js' 5 | 6 | test('default', () => { 7 | expect(reconnectMutationOptions(config)).toMatchInlineSnapshot(` 8 | { 9 | "mutationFn": [Function], 10 | "mutationKey": [ 11 | "reconnect", 12 | ], 13 | } 14 | `) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/core/src/query/sendCalls.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { sendCallsMutationOptions } from './sendCalls.js' 5 | 6 | test('default', () => { 7 | expect(sendCallsMutationOptions(config)).toMatchInlineSnapshot(` 8 | { 9 | "mutationFn": [Function], 10 | "mutationKey": [ 11 | "sendCalls", 12 | ], 13 | } 14 | `) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/nuxt/plugins/wagmi.ts: -------------------------------------------------------------------------------- 1 | import { VueQueryPlugin } from '@tanstack/vue-query' 2 | import { WagmiPlugin } from '@wagmi/vue' 3 | import { defineNuxtPlugin } from 'nuxt/app' 4 | 5 | import { config } from '../wagmi' 6 | 7 | // TODO: Move to @wagmi/vue/nuxt nitro plugin 8 | export default defineNuxtPlugin((nuxtApp) => { 9 | nuxtApp.vueApp.use(WagmiPlugin, { config }).use(VueQueryPlugin, {}) 10 | }) 11 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useCall.test-d.ts: -------------------------------------------------------------------------------- 1 | import type { CallReturnType } from 'viem' 2 | import { expectTypeOf, test } from 'vitest' 3 | import { useCall } from './useCall.js' 4 | 5 | test('select data', () => { 6 | const result = useCall({ 7 | query: { 8 | select(data) { 9 | return data 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /packages/vue/src/composables/useEstimateGas.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf, test } from 'vitest' 2 | 3 | import { useEstimateGas } from './useEstimateGas.js' 4 | 5 | test('select data', () => { 6 | const result = useEstimateGas({ 7 | query: { 8 | select(data) { 9 | return data.toString() 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data.value).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /site/snippets/vue/main.ts: -------------------------------------------------------------------------------- 1 | import { QueryClient, VueQueryPlugin } from '@tanstack/vue-query' 2 | import { WagmiPlugin } from '@wagmi/vue' 3 | import { createApp } from 'vue' 4 | 5 | import App from './App.vue' 6 | import { config } from './config' 7 | 8 | export const queryClient = new QueryClient() 9 | 10 | createApp(App) 11 | .use(WagmiPlugin, { config }) 12 | .use(VueQueryPlugin, { queryClient }) 13 | .mount('#app') 14 | -------------------------------------------------------------------------------- /packages/core/src/actions/getEnsResolver.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { getEnsResolver } from './getEnsResolver.js' 5 | 6 | test('default', async () => { 7 | await expect( 8 | getEnsResolver(config, { 9 | name: 'wevm.eth', 10 | }), 11 | ).resolves.toMatchInlineSnapshot( 12 | '"0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41"', 13 | ) 14 | }) 15 | -------------------------------------------------------------------------------- /packages/core/src/query/disconnect.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { disconnectMutationOptions } from './disconnect.js' 5 | 6 | test('default', () => { 7 | expect(disconnectMutationOptions(config)).toMatchInlineSnapshot(` 8 | { 9 | "mutationFn": [Function], 10 | "mutationKey": [ 11 | "disconnect", 12 | ], 13 | } 14 | `) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/core/src/query/watchAsset.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { watchAssetMutationOptions } from './watchAsset.js' 5 | 6 | test('default', () => { 7 | expect(watchAssetMutationOptions(config)).toMatchInlineSnapshot(` 8 | { 9 | "mutationFn": [Function], 10 | "mutationKey": [ 11 | "watchAsset", 12 | ], 13 | } 14 | `) 15 | }) 16 | -------------------------------------------------------------------------------- /playgrounds/vite-vue/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite Vue 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /site/.vitepress/theme/components/HomeBanner.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | Looking for the 1.x docs? Check out 1.x.wagmi.sh. 4 | 5 | 6 | 7 | 13 | 14 | -------------------------------------------------------------------------------- /packages/core/src/query/signMessage.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { signMessageMutationOptions } from './signMessage.js' 5 | 6 | test('default', () => { 7 | expect(signMessageMutationOptions(config)).toMatchInlineSnapshot(` 8 | { 9 | "mutationFn": [Function], 10 | "mutationKey": [ 11 | "signMessage", 12 | ], 13 | } 14 | `) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/core/src/query/switchChain.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { switchChainMutationOptions } from './switchChain.js' 5 | 6 | test('default', () => { 7 | expect(switchChainMutationOptions(config)).toMatchInlineSnapshot(` 8 | { 9 | "mutationFn": [Function], 10 | "mutationKey": [ 11 | "switchChain", 12 | ], 13 | } 14 | `) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/core/src/utils/deserialize.ts: -------------------------------------------------------------------------------- 1 | type Reviver = (key: string, value: any) => any 2 | 3 | export function deserialize(value: string, reviver?: Reviver): type { 4 | return JSON.parse(value, (key, value_) => { 5 | let value = value_ 6 | if (value?.__type === 'bigint') value = BigInt(value.value) 7 | if (value?.__type === 'Map') value = new Map(value.value) 8 | return reviver?.(key, value) ?? value 9 | }) 10 | } 11 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useProof.test-d.ts: -------------------------------------------------------------------------------- 1 | import type { GetProofReturnType } from 'viem' 2 | import { expectTypeOf, test } from 'vitest' 3 | import { useProof } from './useProof.js' 4 | 5 | test('select data', () => { 6 | const result = useProof({ 7 | query: { 8 | select(data) { 9 | return data 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /packages/cli/src/exports/index.ts: -------------------------------------------------------------------------------- 1 | // biome-ignore lint/performance/noBarrelFile: entrypoint module 2 | export { 3 | type Config, 4 | type ContractConfig, 5 | defineConfig, 6 | type Plugin, 7 | } from '../config.js' 8 | 9 | // biome-ignore lint/performance/noReExportAll: entrypoint module 10 | export * as logger from '../logger.js' 11 | 12 | export { loadEnv } from '../utils/loadEnv.js' 13 | 14 | export { version } from '../version.js' 15 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useBlockTransactionCount.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf, test } from 'vitest' 2 | 3 | import { useBlockTransactionCount } from './useBlockTransactionCount.js' 4 | 5 | test('select data', () => { 6 | const result = useBlockTransactionCount({ 7 | query: { 8 | select(data) { 9 | return data 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /site/react/api/errors.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | # Errors 7 | 8 | Error classes used by Wagmi. 9 | 10 | 11 | 12 | ## React 13 | 14 | ### WagmiProviderNotFoundError 15 | 16 | When a Wagmi hook is used outside of a [`WagmiProvider`](/react/api/WagmiProvider). 17 | 18 | ```ts 19 | import { WagmiProviderNotFoundError } from 'wagmi' 20 | ``` -------------------------------------------------------------------------------- /site/shared/mutation-imports.md: -------------------------------------------------------------------------------- 1 | 8 | 9 | ## TanStack Query 10 | 11 | ```ts-vue 12 | import { 13 | type {{typeName}}Data, 14 | type {{typeName}}Variables, 15 | type {{typeName}}Mutate, 16 | type {{typeName}}MutateAsync, 17 | {{actionName}}MutationOptions, 18 | } from '{{packageName}}/query' 19 | ``` -------------------------------------------------------------------------------- /site/snippets/abi-read.ts: -------------------------------------------------------------------------------- 1 | export const abi = [ 2 | { 3 | type: 'function', 4 | name: 'balanceOf', 5 | stateMutability: 'view', 6 | inputs: [{ name: 'account', type: 'address' }], 7 | outputs: [{ type: 'uint256' }], 8 | }, 9 | { 10 | type: 'function', 11 | name: 'totalSupply', 12 | stateMutability: 'view', 13 | inputs: [], 14 | outputs: [{ name: 'supply', type: 'uint256' }], 15 | }, 16 | ] as const 17 | -------------------------------------------------------------------------------- /packages/core/src/query/sendCallsSync.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { sendCallsSyncMutationOptions } from './sendCallsSync.js' 5 | 6 | test('default', () => { 7 | expect(sendCallsSyncMutationOptions(config)).toMatchInlineSnapshot(` 8 | { 9 | "mutationFn": [Function], 10 | "mutationKey": [ 11 | "sendCallsSync", 12 | ], 13 | } 14 | `) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/core/src/query/signTypedData.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { signTypedDataMutationOptions } from './signTypedData.js' 5 | 6 | test('default', () => { 7 | expect(signTypedDataMutationOptions(config)).toMatchInlineSnapshot(` 8 | { 9 | "mutationFn": [Function], 10 | "mutationKey": [ 11 | "signTypedData", 12 | ], 13 | } 14 | `) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/core/src/query/switchAccount.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { switchAccountMutationOptions } from './switchAccount.js' 5 | 6 | test('default', () => { 7 | expect(switchAccountMutationOptions(config)).toMatchInlineSnapshot(` 8 | { 9 | "mutationFn": [Function], 10 | "mutationKey": [ 11 | "switchAccount", 12 | ], 13 | } 14 | `) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/core/src/query/writeContract.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { writeContractMutationOptions } from './writeContract.js' 5 | 6 | test('default', () => { 7 | expect(writeContractMutationOptions(config)).toMatchInlineSnapshot(` 8 | { 9 | "mutationFn": [Function], 10 | "mutationKey": [ 11 | "writeContract", 12 | ], 13 | } 14 | `) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useTransactionReceipt.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf, test } from 'vitest' 2 | 3 | import { useTransactionReceipt } from './useTransactionReceipt.js' 4 | 5 | test('select data', () => { 6 | const result = useTransactionReceipt({ 7 | query: { 8 | select(data) { 9 | return data?.blockNumber 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /packages/vue/src/composables/useBalance.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf, test } from 'vitest' 2 | import type { Ref } from 'vue' 3 | 4 | import { useBalance } from './useBalance.js' 5 | 6 | test('select data', () => { 7 | const result = useBalance({ 8 | query: { 9 | select(data) { 10 | return data?.value 11 | }, 12 | }, 13 | }) 14 | expectTypeOf(result.data).toEqualTypeOf | Ref>() 15 | }) 16 | -------------------------------------------------------------------------------- /playgrounds/vite-core/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom/client' 3 | import './index.css' 4 | 5 | import { Buffer } from 'buffer' 6 | 7 | // `@coinbase-wallet/sdk` uses `Buffer` 8 | globalThis.Buffer = Buffer 9 | 10 | import App from './App.tsx' 11 | 12 | ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( 13 | 14 | 15 | , 16 | ) 17 | -------------------------------------------------------------------------------- /packages/cli/types/fixturez.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'fixturez' { 2 | interface FixturezOpts { 3 | glob?: string 4 | cleanup?: boolean 5 | root?: string 6 | } 7 | 8 | interface Fixturez { 9 | find(basename: string): string 10 | copy(basename: string): string 11 | temp(): string 12 | cleanup(): void 13 | } 14 | 15 | function fixturez(dirname: string, opts?: FixturezOpts): Fixturez 16 | 17 | export = fixturez 18 | } 19 | -------------------------------------------------------------------------------- /packages/core/src/query/deployContract.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { deployContractMutationOptions } from './deployContract.js' 5 | 6 | test('default', () => { 7 | expect(deployContractMutationOptions(config)).toMatchInlineSnapshot(` 8 | { 9 | "mutationFn": [Function], 10 | "mutationKey": [ 11 | "deployContract", 12 | ], 13 | } 14 | `) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/vue/src/errors/base.ts: -------------------------------------------------------------------------------- 1 | import { BaseError as CoreError } from '@wagmi/core' 2 | 3 | import { getVersion } from '../utils/getVersion.js' 4 | 5 | export type BaseErrorType = BaseError & { name: 'WagmiError' } 6 | export class BaseError extends CoreError { 7 | override name = 'WagmiError' 8 | override get docsBaseUrl() { 9 | return 'https://wagmi.sh/vue' 10 | } 11 | override get version() { 12 | return getVersion() 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/core/src/actions/getClient.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { getClient } from './getClient.js' 5 | 6 | test('default', () => { 7 | expect(getClient(config)).toBeDefined() 8 | }) 9 | 10 | test('behavior: unconfigured chain', () => { 11 | expect( 12 | getClient(config, { 13 | // @ts-expect-error 14 | chainId: 123456, 15 | }), 16 | ).toBeUndefined() 17 | }) 18 | -------------------------------------------------------------------------------- /packages/core/src/query/sendTransaction.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { sendTransactionMutationOptions } from './sendTransaction.js' 5 | 6 | test('default', () => { 7 | expect(sendTransactionMutationOptions(config)).toMatchInlineSnapshot(` 8 | { 9 | "mutationFn": [Function], 10 | "mutationKey": [ 11 | "sendTransaction", 12 | ], 13 | } 14 | `) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/core/src/query/showCallsStatus.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { showCallsStatusMutationOptions } from './showCallsStatus.js' 5 | 6 | test('default', () => { 7 | expect(showCallsStatusMutationOptions(config)).toMatchInlineSnapshot(` 8 | { 9 | "mutationFn": [Function], 10 | "mutationKey": [ 11 | "showCallsStatus", 12 | ], 13 | } 14 | `) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/react/src/errors/base.ts: -------------------------------------------------------------------------------- 1 | import { BaseError as CoreError } from '@wagmi/core' 2 | 3 | import { getVersion } from '../utils/getVersion.js' 4 | 5 | export type BaseErrorType = BaseError & { name: 'WagmiError' } 6 | export class BaseError extends CoreError { 7 | override name = 'WagmiError' 8 | override get docsBaseUrl() { 9 | return 'https://wagmi.sh/react' 10 | } 11 | override get version() { 12 | return getVersion() 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useTransactionConfirmations.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf, test } from 'vitest' 2 | 3 | import { useTransactionConfirmations } from './useTransactionConfirmations.js' 4 | 5 | test('select data', () => { 6 | const result = useTransactionConfirmations({ 7 | query: { 8 | select(data) { 9 | return data 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /packages/register-tests/react/src/useChains.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf, test } from 'vitest' 2 | import { useChains } from 'wagmi' 3 | import type { Chain, celo, optimism } from 'wagmi/chains' 4 | 5 | test('default', () => { 6 | const chains = useChains() 7 | 8 | expectTypeOf(chains[0]).toEqualTypeOf() 9 | expectTypeOf(chains[2]).toEqualTypeOf() 10 | expectTypeOf(chains[5]).toEqualTypeOf() 11 | }) 12 | -------------------------------------------------------------------------------- /packages/vue/src/composables/useTransactionReceipt.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf, test } from 'vitest' 2 | 3 | import { useTransactionReceipt } from './useTransactionReceipt.js' 4 | 5 | test('select data', () => { 6 | const result = useTransactionReceipt({ 7 | query: { 8 | select(data) { 9 | return data?.blockNumber 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data.value).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /site/snippets/react/config-chain-properties.ts: -------------------------------------------------------------------------------- 1 | import { createConfig, http } from 'wagmi' 2 | import { base, celo, mainnet } from 'wagmi/chains' 3 | 4 | export const config = createConfig({ 5 | chains: [base, celo, mainnet], 6 | transports: { 7 | [base.id]: http(), 8 | [celo.id]: http(), 9 | [mainnet.id]: http(), 10 | }, 11 | }) 12 | 13 | declare module 'wagmi' { 14 | interface Register { 15 | config: typeof config 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/core/src/experimental/query/writeContracts.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { writeContractsMutationOptions } from './writeContracts.js' 5 | 6 | test('default', () => { 7 | expect(writeContractsMutationOptions(config)).toMatchInlineSnapshot(` 8 | { 9 | "mutationFn": [Function], 10 | "mutationKey": [ 11 | "writeContracts", 12 | ], 13 | } 14 | `) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/react/src/errors/context.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest' 2 | 3 | import { WagmiProviderNotFoundError } from './context.js' 4 | 5 | test('WagmiProviderNotFoundError', () => { 6 | expect(new WagmiProviderNotFoundError()).toMatchInlineSnapshot(` 7 | [WagmiProviderNotFoundError: \`useConfig\` must be used within \`WagmiProvider\`. 8 | 9 | Docs: https://wagmi.sh/react/api/WagmiProvider.html 10 | Version: wagmi@x.y.z] 11 | `) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useChainId.test-d.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expectTypeOf, test } from 'vitest' 3 | 4 | import { useChainId } from './useChainId.js' 5 | 6 | test('default', () => { 7 | const chainId = useChainId() 8 | expectTypeOf(chainId).toEqualTypeOf() 9 | }) 10 | 11 | test('parameters: config', () => { 12 | const chainId = useChainId({ config }) 13 | expectTypeOf(chainId).toEqualTypeOf<1 | 456 | 10>() 14 | }) 15 | -------------------------------------------------------------------------------- /site/snippets/vue/config-chain-properties.ts: -------------------------------------------------------------------------------- 1 | import { createConfig, http } from '@wagmi/vue' 2 | import { base, celo, mainnet } from '@wagmi/vue/chains' 3 | 4 | export const config = createConfig({ 5 | chains: [base, celo, mainnet], 6 | transports: { 7 | [base.id]: http(), 8 | [celo.id]: http(), 9 | [mainnet.id]: http(), 10 | }, 11 | }) 12 | 13 | declare module '@wagmi/vue' { 14 | interface Register { 15 | config: typeof config 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useWaitForTransactionReceipt.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf, test } from 'vitest' 2 | 3 | import { useWaitForTransactionReceipt } from './useWaitForTransactionReceipt.js' 4 | 5 | test('select data', () => { 6 | const result = useWaitForTransactionReceipt({ 7 | query: { 8 | select(data) { 9 | return data?.blockNumber 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /site/shared/query-imports.md: -------------------------------------------------------------------------------- 1 | 8 | 9 | ## TanStack Query 10 | 11 | ```ts-vue 12 | import { 13 | type {{typeName}}Data, 14 | type {{typeName}}Options, 15 | type {{typeName}}QueryFnData, 16 | type {{typeName}}QueryKey, 17 | {{actionName}}QueryKey, 18 | {{actionName}}QueryOptions, 19 | } from '{{packageName}}/query' 20 | ``` -------------------------------------------------------------------------------- /packages/core/src/query/sendTransactionSync.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { sendTransactionSyncMutationOptions } from './sendTransactionSync.js' 5 | 6 | test('default', () => { 7 | expect(sendTransactionSyncMutationOptions(config)).toMatchInlineSnapshot(` 8 | { 9 | "mutationFn": [Function], 10 | "mutationKey": [ 11 | "sendTransactionSync", 12 | ], 13 | } 14 | `) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/react/src/errors/context.ts: -------------------------------------------------------------------------------- 1 | import { BaseError } from './base.js' 2 | 3 | export type WagmiProviderNotFoundErrorType = WagmiProviderNotFoundError & { 4 | name: 'WagmiProviderNotFoundError' 5 | } 6 | export class WagmiProviderNotFoundError extends BaseError { 7 | override name = 'WagmiProviderNotFoundError' 8 | constructor() { 9 | super('`useConfig` must be used within `WagmiProvider`.', { 10 | docsPath: '/api/WagmiProvider', 11 | }) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useEstimateMaxPriorityFeePerGas.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf, test } from 'vitest' 2 | import { useEstimateMaxPriorityFeePerGas } from './useEstimateMaxPriorityFeePerGas.js' 3 | 4 | test('select data', () => { 5 | const result = useEstimateMaxPriorityFeePerGas({ 6 | query: { 7 | select(data) { 8 | return data.toString() 9 | }, 10 | }, 11 | }) 12 | expectTypeOf(result.data).toEqualTypeOf() 13 | }) 14 | -------------------------------------------------------------------------------- /packages/vue/src/composables/useChainId.test-d.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expectTypeOf, test } from 'vitest' 3 | 4 | import { useChainId } from './useChainId.js' 5 | 6 | test('default', () => { 7 | const chainId = useChainId() 8 | expectTypeOf(chainId.value).toEqualTypeOf() 9 | }) 10 | 11 | test('parameters: config', () => { 12 | const chainId = useChainId({ config }) 13 | expectTypeOf(chainId.value).toEqualTypeOf<1 | 456 | 10>() 14 | }) 15 | -------------------------------------------------------------------------------- /packages/vue/src/composables/useWaitForTransactionReceipt.test-d.ts: -------------------------------------------------------------------------------- 1 | import { expectTypeOf, test } from 'vitest' 2 | 3 | import { useWaitForTransactionReceipt } from './useWaitForTransactionReceipt.js' 4 | 5 | test('select data', () => { 6 | const result = useWaitForTransactionReceipt({ 7 | query: { 8 | select(data) { 9 | return data?.blockNumber 10 | }, 11 | }, 12 | }) 13 | expectTypeOf(result.data.value).toEqualTypeOf() 14 | }) 15 | -------------------------------------------------------------------------------- /packages/core/src/actions/getPublicClient.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { getPublicClient } from './getPublicClient.js' 5 | 6 | test('default', () => { 7 | expect(getPublicClient(config)).toBeDefined() 8 | }) 9 | 10 | test('behavior: unconfigured chain', () => { 11 | expect( 12 | getPublicClient(config, { 13 | // @ts-expect-error 14 | chainId: 123456, 15 | }), 16 | ).toBeUndefined() 17 | }) 18 | -------------------------------------------------------------------------------- /packages/core/src/actions/watchClient.test-d.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expectTypeOf, test } from 'vitest' 3 | 4 | import { watchClient } from './watchClient.js' 5 | 6 | test('default', () => { 7 | watchClient(config, { 8 | onChange(client) { 9 | expectTypeOf(client.chain).toEqualTypeOf< 10 | (typeof config)['chains'][number] 11 | >() 12 | expectTypeOf(client.transport.type).toEqualTypeOf<'http'>() 13 | }, 14 | }) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/register-tests/vue/src/useChains.test-d.ts: -------------------------------------------------------------------------------- 1 | import { useChains } from '@wagmi/vue' 2 | import type { Chain, celo, optimism } from '@wagmi/vue/chains' 3 | import { expectTypeOf, test } from 'vitest' 4 | 5 | test('default', () => { 6 | const chains = useChains() 7 | 8 | expectTypeOf(chains.value[0]).toEqualTypeOf() 9 | expectTypeOf(chains.value[2]).toEqualTypeOf() 10 | expectTypeOf(chains.value[5]).toEqualTypeOf() 11 | }) 12 | -------------------------------------------------------------------------------- /packages/cli/src/utils/format.ts: -------------------------------------------------------------------------------- 1 | import prettier from 'prettier' 2 | 3 | export async function format(content: string) { 4 | const config = await prettier.resolveConfig(process.cwd()) 5 | return prettier.format(content, { 6 | arrowParens: 'always', 7 | endOfLine: 'lf', 8 | parser: 'typescript', 9 | printWidth: 80, 10 | semi: false, 11 | singleQuote: true, 12 | tabWidth: 2, 13 | trailingComma: 'all', 14 | ...config, 15 | plugins: [], 16 | }) 17 | } 18 | -------------------------------------------------------------------------------- /packages/connectors/src/exports/index.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest' 2 | 3 | import * as connectors from './index.js' 4 | 5 | test('exports', () => { 6 | expect(Object.keys(connectors)).toMatchInlineSnapshot(` 7 | [ 8 | "injected", 9 | "mock", 10 | "baseAccount", 11 | "coinbaseWallet", 12 | "gemini", 13 | "metaMask", 14 | "porto", 15 | "safe", 16 | "version", 17 | "walletConnect", 18 | ] 19 | `) 20 | }) 21 | -------------------------------------------------------------------------------- /packages/core/src/actions/getChains.test.ts: -------------------------------------------------------------------------------- 1 | import { chain, config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { getChains } from './getChains.js' 5 | 6 | test('default', async () => { 7 | expect(getChains(config)).toEqual([ 8 | chain.mainnet, 9 | chain.mainnet2, 10 | chain.optimism, 11 | ]) 12 | config._internal.chains.setState([chain.mainnet, chain.mainnet2]) 13 | expect(getChains(config)).toEqual([chain.mainnet, chain.mainnet2]) 14 | }) 15 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vue/src/App.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /packages/vue/src/exports/connectors.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest' 2 | 3 | import * as connectors from './connectors.js' 4 | 5 | test('exports', () => { 6 | expect(Object.keys(connectors)).toMatchInlineSnapshot(` 7 | [ 8 | "injected", 9 | "mock", 10 | "baseAccount", 11 | "coinbaseWallet", 12 | "gemini", 13 | "metaMask", 14 | "porto", 15 | "safe", 16 | "version", 17 | "walletConnect", 18 | ] 19 | `) 20 | }) 21 | -------------------------------------------------------------------------------- /packages/core/src/actions/estimateFeesPerGas.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { estimateFeesPerGas } from './estimateFeesPerGas.js' 5 | 6 | test('default', async () => { 7 | const result = await estimateFeesPerGas(config) 8 | expect(Object.keys(result)).toMatchInlineSnapshot(` 9 | [ 10 | "formatted", 11 | "gasPrice", 12 | "maxFeePerGas", 13 | "maxPriorityFeePerGas", 14 | ] 15 | `) 16 | }) 17 | -------------------------------------------------------------------------------- /packages/react/src/exports/connectors.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest' 2 | 3 | import * as connectors from './connectors.js' 4 | 5 | test('exports', () => { 6 | expect(Object.keys(connectors)).toMatchInlineSnapshot(` 7 | [ 8 | "baseAccount", 9 | "coinbaseWallet", 10 | "gemini", 11 | "injected", 12 | "metaMask", 13 | "mock", 14 | "porto", 15 | "safe", 16 | "version", 17 | "walletConnect", 18 | ] 19 | `) 20 | }) 21 | -------------------------------------------------------------------------------- /packages/core/src/query/utils.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest' 2 | 3 | import { structuralSharing } from './utils.js' 4 | 5 | test('structuralSharing', () => { 6 | expect( 7 | structuralSharing({ foo: 'bar' }, { foo: 'bar' }), 8 | ).toMatchInlineSnapshot(` 9 | { 10 | "foo": "bar", 11 | } 12 | `) 13 | expect( 14 | structuralSharing({ foo: 'bar' }, { foo: 'baz' }), 15 | ).toMatchInlineSnapshot(` 16 | { 17 | "foo": "baz", 18 | } 19 | `) 20 | }) 21 | -------------------------------------------------------------------------------- /packages/vue/src/composables/useBytecode.test-d.ts: -------------------------------------------------------------------------------- 1 | import type { Hex } from 'viem' 2 | import { expectTypeOf, test } from 'vitest' 3 | 4 | import { useBytecode } from './useBytecode.js' 5 | 6 | test('select data', () => { 7 | const result = useBytecode({ 8 | query: { 9 | select(data) { 10 | expectTypeOf(data).toEqualTypeOf() 11 | return data 12 | }, 13 | }, 14 | }) 15 | expectTypeOf(result.data.value).toEqualTypeOf() 16 | }) 17 | -------------------------------------------------------------------------------- /playgrounds/vite-vue/src/components/ReadContract.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | Read Contract 14 | 15 | Balance: {{ balance?.toString() }} 16 | 17 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useWalletClient.test-d.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expectTypeOf, test } from 'vitest' 3 | 4 | import { useWalletClient } from './useWalletClient.js' 5 | 6 | test('parameters: config', async () => { 7 | const client = useWalletClient({ config }) 8 | expectTypeOf(client.data?.chain?.id!).toEqualTypeOf<1 | 456 | 10>() 9 | 10 | const client2 = useWalletClient({ config, chainId: 1 }) 11 | expectTypeOf(client2.data?.chain?.id!).toEqualTypeOf<1>() 12 | }) 13 | -------------------------------------------------------------------------------- /site/snippets/react/app.tsx: -------------------------------------------------------------------------------- 1 | import { QueryClient, QueryClientProvider } from '@tanstack/react-query' 2 | import * as React from 'react' 3 | import { WagmiProvider } from 'wagmi' 4 | import { config } from './config' 5 | 6 | export const queryClient = new QueryClient() 7 | 8 | export function App() { 9 | return ( 10 | 11 | 12 | {/** ... */} 13 | 14 | 15 | ) 16 | } 17 | -------------------------------------------------------------------------------- /packages/core/src/actions/watchPublicClient.test-d.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expectTypeOf, test } from 'vitest' 3 | 4 | import { watchPublicClient } from './watchPublicClient.js' 5 | 6 | test('default', () => { 7 | watchPublicClient(config, { 8 | onChange(client) { 9 | expectTypeOf(client.chain).toEqualTypeOf< 10 | (typeof config)['chains'][number] 11 | >() 12 | expectTypeOf(client.transport.type).toEqualTypeOf<'http'>() 13 | }, 14 | }) 15 | }) 16 | -------------------------------------------------------------------------------- /playgrounds/vite-vue/src/main.ts: -------------------------------------------------------------------------------- 1 | import { VueQueryPlugin } from '@tanstack/vue-query' 2 | import { WagmiPlugin } from '@wagmi/vue' 3 | import { Buffer } from 'buffer' 4 | import { createApp } from 'vue' 5 | 6 | // `@coinbase-wallet/sdk` uses `Buffer` 7 | globalThis.Buffer = Buffer 8 | 9 | import App from './App.vue' 10 | import './style.css' 11 | import { config } from './wagmi' 12 | 13 | const app = createApp(App) 14 | 15 | app.use(WagmiPlugin, { config }).use(VueQueryPlugin, {}) 16 | 17 | app.mount('#app') 18 | -------------------------------------------------------------------------------- /packages/core/src/actions/getChains.test-d.ts: -------------------------------------------------------------------------------- 1 | import { type chain, config } from '@wagmi/test' 2 | import type { Chain } from 'viem' 3 | import { expectTypeOf, test } from 'vitest' 4 | 5 | import { getChains } from './getChains.js' 6 | 7 | test('default', async () => { 8 | const chains = getChains(config) 9 | expectTypeOf(chains[0]).toEqualTypeOf() 10 | expectTypeOf(chains[2]).toEqualTypeOf() 11 | expectTypeOf(chains[3]).toEqualTypeOf() 12 | }) 13 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useConnectorClient.test-d.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expectTypeOf, test } from 'vitest' 3 | 4 | import { useConnectorClient } from './useConnectorClient.js' 5 | 6 | test('parameters: config', async () => { 7 | const client = useConnectorClient({ config }) 8 | expectTypeOf(client.data?.chain?.id!).toEqualTypeOf<1 | 456 | 10>() 9 | 10 | const client2 = useConnectorClient({ config, chainId: 1 }) 11 | expectTypeOf(client2.data?.chain?.id!).toEqualTypeOf<1>() 12 | }) 13 | -------------------------------------------------------------------------------- /packages/core/src/query/readContract.test-d.ts: -------------------------------------------------------------------------------- 1 | import { abi, config } from '@wagmi/test' 2 | import { expectTypeOf, test } from 'vitest' 3 | 4 | import { readContractQueryOptions } from './readContract.js' 5 | 6 | test('default', async () => { 7 | const options = readContractQueryOptions(config, { 8 | address: '0x', 9 | abi: abi.erc20, 10 | functionName: 'balanceOf', 11 | args: ['0x'], 12 | }) 13 | const result = await options.queryFn({} as any) 14 | expectTypeOf(result).toEqualTypeOf() 15 | }) 16 | -------------------------------------------------------------------------------- /packages/register-tests/react/src/useChainId.test-d.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expectTypeOf, test } from 'vitest' 3 | import { useChainId } from 'wagmi' 4 | 5 | import type { ChainId } from './config.js' 6 | 7 | test('default', async () => { 8 | const chainId = useChainId() 9 | expectTypeOf(chainId).toEqualTypeOf() 10 | }) 11 | 12 | test('parameters: config', async () => { 13 | const chainId = useChainId({ config }) 14 | expectTypeOf(chainId).toEqualTypeOf<1 | 456 | 10>() 15 | }) 16 | -------------------------------------------------------------------------------- /packages/cli/src/exports/plugins.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest' 2 | 3 | import * as Exports from './plugins.js' 4 | 5 | test('exports', () => { 6 | expect(Object.keys(Exports)).toMatchInlineSnapshot(` 7 | [ 8 | "actions", 9 | "blockExplorer", 10 | "etherscan", 11 | "fetch", 12 | "foundry", 13 | "foundryDefaultExcludes", 14 | "hardhat", 15 | "hardhatDefaultExcludes", 16 | "react", 17 | "routescan", 18 | "sourcify", 19 | ] 20 | `) 21 | }) 22 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vue/src/main.ts: -------------------------------------------------------------------------------- 1 | import { VueQueryPlugin } from '@tanstack/vue-query' 2 | import { WagmiPlugin } from '@wagmi/vue' 3 | import { Buffer } from 'buffer' 4 | import { createApp } from 'vue' 5 | 6 | // `@coinbase-wallet/sdk` uses `Buffer` 7 | globalThis.Buffer = Buffer 8 | 9 | import App from './App.vue' 10 | import './style.css' 11 | import { config } from './wagmi' 12 | 13 | const app = createApp(App) 14 | 15 | app.use(WagmiPlugin, { config }).use(VueQueryPlugin, {}) 16 | 17 | app.mount('#app') 18 | -------------------------------------------------------------------------------- /playgrounds/next/next.config.mjs: -------------------------------------------------------------------------------- 1 | import bundleAnalyzer from '@next/bundle-analyzer' 2 | 3 | const withBundleAnalyzer = bundleAnalyzer({ 4 | enabled: process.env.ANALYZE === 'true', 5 | }) 6 | 7 | /** @type {import('next').NextConfig} */ 8 | const nextConfig = { 9 | experimental: { 10 | externalDir: true, 11 | }, 12 | webpack(config) { 13 | config.resolve.extensionAlias = { 14 | '.js': ['.js', '.ts'], 15 | } 16 | return config 17 | }, 18 | } 19 | 20 | export default withBundleAnalyzer(nextConfig) 21 | -------------------------------------------------------------------------------- /playgrounds/nuxt/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nuxt-app", 3 | "private": true, 4 | "type": "module", 5 | "scripts": { 6 | "build": "nuxt build", 7 | "dev": "nuxt dev", 8 | "generate": "nuxt generate", 9 | "preview": "nuxt preview", 10 | "_postinstall": "nuxt prepare" 11 | }, 12 | "dependencies": { 13 | "@tanstack/vue-query": ">=5.45.0", 14 | "@wagmi/vue": "workspace:*", 15 | "nuxt": "^3.19.2", 16 | "viem": "2.*", 17 | "vue": ">=3.4.21", 18 | "vue-router": "^4.3.2" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@3.0.5/schema.json", 3 | "changelog": [ 4 | "@svitejs/changesets-changelog-github-compact", 5 | { "repo": "wevm/wagmi" } 6 | ], 7 | "commit": false, 8 | "access": "public", 9 | "fixed": [], 10 | "linked": [], 11 | "baseBranch": "main", 12 | "updateInternalDependencies": "minor", 13 | "ignore": [ 14 | "*-register", 15 | "@wagmi/test", 16 | "site", 17 | "next-app", 18 | "nuxt-app", 19 | "vite-*" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /packages/core/src/query/waitForTransactionReceipt.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { waitForTransactionReceiptQueryOptions } from './waitForTransactionReceipt.js' 5 | 6 | test('default', () => { 7 | expect( 8 | waitForTransactionReceiptQueryOptions(config, {}), 9 | ).toMatchInlineSnapshot(` 10 | { 11 | "queryFn": [Function], 12 | "queryKey": [ 13 | "waitForTransactionReceipt", 14 | {}, 15 | ], 16 | } 17 | `) 18 | }) 19 | -------------------------------------------------------------------------------- /packages/vue/src/composables/useChains.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { renderComposable } from '@wagmi/test/vue' 3 | import { celo } from 'viem/chains' 4 | import { expect, test } from 'vitest' 5 | 6 | import { useChains } from './useChains.js' 7 | 8 | test('default', async () => { 9 | const [chains] = renderComposable(() => useChains()) 10 | 11 | expect(chains.value.length).toBe(3) 12 | 13 | config._internal.chains.setState((x) => [...x, celo]) 14 | 15 | expect(chains.value.length).toBe(4) 16 | }) 17 | -------------------------------------------------------------------------------- /playgrounds/vite-react/wagmi.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from '@wagmi/cli' 2 | import { foundry, hardhat } from '@wagmi/cli/plugins' 3 | 4 | export default defineConfig({ 5 | out: 'src/generated.ts', 6 | contracts: [], 7 | plugins: [ 8 | foundry({ 9 | namePrefix: 'foundry', 10 | project: '../../packages/cli/src/plugins/__fixtures__/foundry', 11 | }), 12 | hardhat({ 13 | namePrefix: 'hardhat', 14 | project: '../../packages/cli/src/plugins/__fixtures__/hardhat', 15 | }), 16 | ], 17 | }) 18 | -------------------------------------------------------------------------------- /.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works 4 | with multi-package repos, or single-package repos to help you version and publish your code. You can 5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets) 6 | 7 | We have a quick list of common questions to get you started engaging with this project in 8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 9 | -------------------------------------------------------------------------------- /packages/core/src/actions/getProof.test.ts: -------------------------------------------------------------------------------- 1 | import { chain, config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { getProof } from './getProof.js' 5 | 6 | test.skip('default', async () => { 7 | await expect( 8 | getProof(config, { 9 | chainId: chain.optimism.id, 10 | address: '0x4200000000000000000000000000000000000016', 11 | storageKeys: [ 12 | '0x4a932049252365b3eedbc5190e18949f2ec11f39d3bef2d259764799a1b27d99', 13 | ], 14 | }), 15 | ).resolves.toBeDefined() 16 | }) 17 | -------------------------------------------------------------------------------- /packages/register-tests/vue/src/useChainId.test-d.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { useChainId } from '@wagmi/vue' 3 | import { expectTypeOf, test } from 'vitest' 4 | 5 | import type { ChainId } from './config.js' 6 | 7 | test('default', async () => { 8 | const chainId = useChainId() 9 | expectTypeOf(chainId.value).toEqualTypeOf() 10 | }) 11 | 12 | test('parameters: config', async () => { 13 | const chainId = useChainId({ config }) 14 | expectTypeOf(chainId.value).toEqualTypeOf<1 | 456 | 10>() 15 | }) 16 | -------------------------------------------------------------------------------- /packages/vue/src/composables/useConnectorClient.test-d.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expectTypeOf, test } from 'vitest' 3 | 4 | import { useConnectorClient } from './useConnectorClient.js' 5 | 6 | test('parameters: config', async () => { 7 | const client = useConnectorClient({ config }) 8 | expectTypeOf(client.data?.value?.chain?.id!).toEqualTypeOf<1 | 456 | 10>() 9 | 10 | const client2 = useConnectorClient({ config, chainId: 1 }) 11 | expectTypeOf(client2.data?.value?.chain?.id!).toEqualTypeOf<1>() 12 | }) 13 | -------------------------------------------------------------------------------- /playgrounds/vite-vue/src/components/Connections.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | Connections 9 | 10 | 11 | connector {{ connection.connector.name }} 12 | accounts: {{ JSON.stringify(connection.accounts) }} 13 | chainId: {{ connection.chainId }} 14 | 15 | 16 | -------------------------------------------------------------------------------- /packages/react/src/exports/codegen.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest' 2 | 3 | import * as codegen from './codegen.js' 4 | 5 | test('exports', () => { 6 | expect(Object.keys(codegen)).toMatchInlineSnapshot(` 7 | [ 8 | "createReadContract", 9 | "createSimulateContract", 10 | "createUseReadContract", 11 | "createUseSimulateContract", 12 | "createUseWatchContractEvent", 13 | "createUseWriteContract", 14 | "createWatchContractEvent", 15 | "createWriteContract", 16 | ] 17 | `) 18 | }) 19 | -------------------------------------------------------------------------------- /playgrounds/next/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | # local env files 28 | .env*.local 29 | 30 | # vercel 31 | .vercel 32 | 33 | # typescript 34 | *.tsbuildinfo 35 | next-env.d.ts 36 | -------------------------------------------------------------------------------- /playgrounds/nuxt/components/Connect.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | Connect 10 | 11 | 12 | {{ connector.name }} 13 | 14 | 15 | 16 | {{ status }} 17 | {{ error?.message }} 18 | 19 | 20 | -------------------------------------------------------------------------------- /playgrounds/vite-vue/src/components/BlockNumber.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | Block Number 12 | 13 | {{ blockNumber }} 14 | 15 | {{ watchBlockNumber ? 'Stop' : 'Start' }} watching 16 | 17 | 18 | -------------------------------------------------------------------------------- /packages/core/src/utils/normalizeChainId.ts: -------------------------------------------------------------------------------- 1 | /** @deprecated use `Number` instead */ 2 | export function normalizeChainId(chainId: bigint | number | string | unknown) { 3 | if (typeof chainId === 'string') 4 | return Number.parseInt( 5 | chainId, 6 | chainId.trim().substring(0, 2) === '0x' ? 16 : 10, 7 | ) 8 | if (typeof chainId === 'bigint') return Number(chainId) 9 | if (typeof chainId === 'number') return chainId 10 | throw new Error( 11 | `Cannot normalize chainId "${chainId}" of type "${typeof chainId}"`, 12 | ) 13 | } 14 | -------------------------------------------------------------------------------- /playgrounds/vite-vue/src/components/Connect.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | Connect 10 | 11 | 12 | {{ connector.name }} 13 | 14 | 15 | 16 | {{ status }} 17 | {{ error?.message }} 18 | 19 | 20 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vanilla/src/wagmi.ts: -------------------------------------------------------------------------------- 1 | import { baseAccount, injected, walletConnect } from '@wagmi/connectors' 2 | import { createConfig, http } from '@wagmi/core' 3 | import { mainnet, sepolia } from '@wagmi/core/chains' 4 | 5 | export const config = createConfig({ 6 | chains: [mainnet, sepolia], 7 | connectors: [ 8 | injected(), 9 | baseAccount(), 10 | walletConnect({ projectId: import.meta.env.VITE_WC_PROJECT_ID }), 11 | ], 12 | transports: { 13 | [mainnet.id]: http(), 14 | [sepolia.id]: http(), 15 | }, 16 | }) 17 | -------------------------------------------------------------------------------- /packages/register-tests/react/src/useAccount.test-d.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expectTypeOf, test } from 'vitest' 3 | import { useAccount } from 'wagmi' 4 | 5 | import type { ChainId } from './config.js' 6 | 7 | test('default', () => { 8 | const result = useAccount() 9 | if (result.chain) expectTypeOf(result.chain.id).toEqualTypeOf() 10 | }) 11 | 12 | test('parameters: config', async () => { 13 | const result = useAccount({ config }) 14 | if (result.chain) expectTypeOf(result.chain.id).toEqualTypeOf<1 | 10 | 456>() 15 | }) 16 | -------------------------------------------------------------------------------- /playgrounds/vite-vue/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vite-vue", 3 | "private": true, 4 | "type": "module", 5 | "scripts": { 6 | "dev": "vite", 7 | "build": "vue-tsc && vite build", 8 | "preview": "vite preview" 9 | }, 10 | "dependencies": { 11 | "@tanstack/vue-query": ">=5.45.0", 12 | "@wagmi/vue": "workspace:*", 13 | "viem": "2.*", 14 | "vue": ">=3.4.21" 15 | }, 16 | "devDependencies": { 17 | "@vitejs/plugin-vue": "^5.0.4", 18 | "buffer": "^6.0.3", 19 | "vite": "^5.4.21", 20 | "vue-tsc": "^2.0.6" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/core/src/actions/estimateMaxPriorityFeePerGas.test.ts: -------------------------------------------------------------------------------- 1 | import { chain, config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { estimateMaxPriorityFeePerGas } from './estimateMaxPriorityFeePerGas.js' 5 | 6 | test('default', async () => { 7 | await expect(estimateMaxPriorityFeePerGas(config)).resolves.toBeDefined() 8 | }) 9 | 10 | test('parameters: chainId', async () => { 11 | await expect( 12 | estimateMaxPriorityFeePerGas(config, { 13 | chainId: chain.mainnet2.id, 14 | }), 15 | ).resolves.toBeDefined() 16 | }) 17 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/next/_gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | # local env files 28 | .env*.local 29 | 30 | # vercel 31 | .vercel 32 | 33 | # typescript 34 | *.tsbuildinfo 35 | next-env.d.ts 36 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/nuxt/components/Connect.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | Connect 10 | 11 | 12 | {{ connector.name }} 13 | 14 | 15 | 16 | {{ status }} 17 | {{ error?.message }} 18 | 19 | 20 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useConfig.test-d.ts: -------------------------------------------------------------------------------- 1 | import type { Config } from '@wagmi/core' 2 | import { config } from '@wagmi/test' 3 | import { expectTypeOf, test } from 'vitest' 4 | 5 | import { useConfig } from './useConfig.js' 6 | 7 | test('default', async () => { 8 | const result = useConfig() 9 | expectTypeOf(result).toEqualTypeOf() 10 | }) 11 | 12 | test('parameters: config', async () => { 13 | const result = useConfig({ config }) 14 | expectTypeOf(result).not.toEqualTypeOf() 15 | expectTypeOf(result).toEqualTypeOf() 16 | }) 17 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/nuxt/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nuxt-app", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "build": "nuxt build", 8 | "dev": "nuxt dev", 9 | "generate": "nuxt generate", 10 | "preview": "nuxt preview", 11 | "postinstall": "nuxt prepare" 12 | }, 13 | "dependencies": { 14 | "@tanstack/vue-query": ">=5.45.0", 15 | "@wagmi/vue": "latest", 16 | "nuxt": "^3.19.2", 17 | "viem": "latest", 18 | "vue": ">=3.4.21", 19 | "vue-router": "^4.3.2" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/vue/src/composables/useConfig.test-d.ts: -------------------------------------------------------------------------------- 1 | import type { Config } from '@wagmi/core' 2 | import { config } from '@wagmi/test' 3 | import { expectTypeOf, test } from 'vitest' 4 | 5 | import { useConfig } from './useConfig.js' 6 | 7 | test('default', async () => { 8 | const result = useConfig() 9 | expectTypeOf(result).toEqualTypeOf() 10 | }) 11 | 12 | test('parameters: config', async () => { 13 | const result = useConfig({ config }) 14 | expectTypeOf(result).not.toEqualTypeOf() 15 | expectTypeOf(result).toEqualTypeOf() 16 | }) 17 | -------------------------------------------------------------------------------- /packages/vue/src/composables/useConnections.test.ts: -------------------------------------------------------------------------------- 1 | import { connect } from '@wagmi/core' 2 | import { config } from '@wagmi/test' 3 | import { renderComposable } from '@wagmi/test/vue' 4 | import { expect, test } from 'vitest' 5 | 6 | import { useConnections } from './useConnections.js' 7 | 8 | test('default', async () => { 9 | const [connections] = renderComposable(() => useConnections()) 10 | 11 | expect(connections.value).toEqual([]) 12 | 13 | await connect(config, { connector: config.connectors[0]! }) 14 | 15 | expect(connections.value.length).toBe(1) 16 | }) 17 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vue/src/components/Connect.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | Connect 10 | 11 | 12 | {{ connector.name }} 13 | 14 | 15 | 16 | {{ status }} 17 | {{ error?.message }} 18 | 19 | 20 | -------------------------------------------------------------------------------- /playgrounds/nuxt/components/Account.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | Account 10 | 11 | 12 | account: {{ address }} 13 | 14 | chainId: {{ chainId }} 15 | 16 | status: {{ status }} 17 | 18 | 19 | 20 | Disconnect 21 | 22 | 23 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.defaultFormatter": "biomejs.biome", 3 | "editor.formatOnSave": true, 4 | "typescript.enablePromptUseWorkspaceTsdk": true, 5 | "typescript.preferences.importModuleSpecifier": "shortest", 6 | "typescript.tsdk": "node_modules/typescript/lib", 7 | "editor.codeActionsOnSave": { 8 | "source.fixAll.biome": "explicit" 9 | }, 10 | "[javascript][javascriptreact][json][typescript][typescriptreact]": { 11 | "editor.defaultFormatter": "biomejs.biome" 12 | }, 13 | "[vue]": { 14 | "editor.defaultFormatter": "Vue.volar" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /docs/base-network-setup.md: -------------------------------------------------------------------------------- 1 | # Base Network Setup with wagmi 2 | 3 | This note shows a minimal setup to use Base with wagmi. 4 | 5 | ## Chain IDs 6 | - Base Mainnet: `8453` 7 | - Base Sepolia: `84532` 8 | 9 | ## Example 10 | ```ts 11 | import { createConfig, http } from 'wagmi' 12 | import { base, baseSepolia } from 'wagmi/chains' 13 | 14 | export const config = createConfig({ 15 | chains: [base, baseSepolia], 16 | transports: { 17 | [base.id]: http('https://base-mainnet.g.alchemy.com/v2/'), 18 | [baseSepolia.id]: http('https://sepolia.base.org') 19 | } 20 | }) 21 | -------------------------------------------------------------------------------- /playgrounds/vite-vue/src/components/Account.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | Account 10 | 11 | 12 | account: {{ address }} 13 | 14 | chainId: {{ chainId }} 15 | 16 | status: {{ status }} 17 | 18 | 19 | 20 | Disconnect 21 | 22 | 23 | -------------------------------------------------------------------------------- /site/react/api/hooks.md: -------------------------------------------------------------------------------- 1 | 8 | 9 | # Hooks 10 | 11 | React Hooks for accounts, wallets, contracts, transactions, signing, ENS, and more. 12 | 13 | ## Import 14 | 15 | ```ts 16 | import { useAccount } from 'wagmi' 17 | ``` 18 | 19 | ## Available Hooks 20 | 21 | 22 | 23 | {{ hook.text }} 24 | 25 | 26 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/nuxt/components/Account.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | Account 10 | 11 | 12 | account: {{ address }} 13 | 14 | chainId: {{ chainId }} 15 | 16 | status: {{ status }} 17 | 18 | 19 | 20 | Disconnect 21 | 22 | 23 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vue/src/components/Account.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | Account 10 | 11 | 12 | account: {{ address }} 13 | 14 | chainId: {{ chainId }} 15 | 16 | status: {{ status }} 17 | 18 | 19 | 20 | Disconnect 21 | 22 | 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Get Help 4 | url: https://github.com/wevm/wagmi/discussions/new?category=q-a 5 | about: Ask a question and discuss with other community members. 6 | 7 | - name: Feature Request 8 | url: https://github.com/wevm/wagmi/discussions/new?category=ideas 9 | about: Request features or brainstorm ideas for new functionality. 10 | 11 | - name: Connector Request 12 | url: https://github.com/wevm/wagmi/discussions/new?category=connector-request 13 | about: Kick off a request for a new connector 14 | 15 | -------------------------------------------------------------------------------- /packages/register-tests/vue/src/useAccount.test-d.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { useAccount } from '@wagmi/vue' 3 | import { expectTypeOf, test } from 'vitest' 4 | 5 | import type { ChainId } from './config.js' 6 | 7 | test('default', () => { 8 | const result = useAccount() 9 | if (result.chain.value) 10 | expectTypeOf(result.chain.value.id).toEqualTypeOf() 11 | }) 12 | 13 | test('parameters: config', async () => { 14 | const result = useAccount({ config }) 15 | if (result.chain.value) 16 | expectTypeOf(result.chain.value.id).toEqualTypeOf<1 | 10 | 456>() 17 | }) 18 | -------------------------------------------------------------------------------- /site/.vitepress/theme/components/Banner.vue: -------------------------------------------------------------------------------- 1 | // TODO: Dismissable, a11y, etc. 2 | // https://github.com/faker-js/faker/pull/1487 3 | 4 | 5 | 6 | Wagmi is participating in Gitcoin Grants round 21. Consider supporting the project. Thank you. 🙏 8 | 9 | 10 | 11 | 17 | -------------------------------------------------------------------------------- /site/core/api/actions/getAccount.md: -------------------------------------------------------------------------------- 1 | # getAccount 2 | 3 | Action for getting current account. 4 | 5 | ## Import 6 | 7 | ```ts 8 | import { getAccount } from '@wagmi/core' 9 | ``` 10 | 11 | ## Usage 12 | 13 | ::: code-group 14 | ```ts [index.ts] 15 | import { getAccount } from '@wagmi/core' 16 | import { config } from './config' 17 | 18 | const account = getAccount(config) 19 | ``` 20 | <<< @/snippets/core/config.ts[config.ts] 21 | ::: 22 | 23 | ## Return Type 24 | 25 | ```ts 26 | import { type GetAccountReturnType } from '@wagmi/core' 27 | ``` 28 | 29 | 30 | -------------------------------------------------------------------------------- /packages/core/src/actions/getConnections.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { connect } from './connect.js' 5 | import { disconnect } from './disconnect.js' 6 | import { getConnections } from './getConnections.js' 7 | 8 | test('default', async () => { 9 | const connector = config.connectors[0]! 10 | expect(getConnections(config)).toEqual([]) 11 | await connect(config, { connector }) 12 | expect(getConnections(config).length).toEqual(1) 13 | await disconnect(config, { connector }) 14 | expect(getConnections(config)).toEqual([]) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/vue/src/exports/query.ts: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // @wagmi/core/query 3 | //////////////////////////////////////////////////////////////////////////////// 4 | 5 | // biome-ignore lint/performance/noBarrelFile: entrypoint module 6 | // biome-ignore lint/performance/noReExportAll: entrypoint module 7 | export * from '@wagmi/core/query' 8 | export { 9 | type UseMutationParameters, 10 | type UseMutationReturnType, 11 | type UseQueryParameters, 12 | type UseQueryReturnType, 13 | useMutation, 14 | useQuery, 15 | } from '../utils/query.js' 16 | -------------------------------------------------------------------------------- /playgrounds/next/src/app/globals.css: -------------------------------------------------------------------------------- 1 | :root { 2 | background-color: #181818; 3 | color: rgba(255, 255, 255, 0.87); 4 | color-scheme: light dark; 5 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; 6 | font-synthesis: none; 7 | font-weight: 400; 8 | line-height: 1.5; 9 | text-rendering: optimizeLegibility; 10 | 11 | -webkit-font-smoothing: antialiased; 12 | -moz-osx-font-smoothing: grayscale; 13 | -webkit-text-size-adjust: 100%; 14 | } 15 | 16 | @media (prefers-color-scheme: light) { 17 | :root { 18 | background-color: #f8f8f8; 19 | color: #181818; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /playgrounds/vite-core/src/index.css: -------------------------------------------------------------------------------- 1 | :root { 2 | background-color: #181818; 3 | color: rgba(255, 255, 255, 0.87); 4 | color-scheme: light dark; 5 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; 6 | font-synthesis: none; 7 | font-weight: 400; 8 | line-height: 1.5; 9 | text-rendering: optimizeLegibility; 10 | 11 | -webkit-font-smoothing: antialiased; 12 | -moz-osx-font-smoothing: grayscale; 13 | -webkit-text-size-adjust: 100%; 14 | } 15 | 16 | @media (prefers-color-scheme: light) { 17 | :root { 18 | background-color: #f8f8f8; 19 | color: #181818; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /playgrounds/vite-react/src/index.css: -------------------------------------------------------------------------------- 1 | :root { 2 | background-color: #181818; 3 | color: rgba(255, 255, 255, 0.87); 4 | color-scheme: light dark; 5 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; 6 | font-synthesis: none; 7 | font-weight: 400; 8 | line-height: 1.5; 9 | text-rendering: optimizeLegibility; 10 | 11 | -webkit-font-smoothing: antialiased; 12 | -moz-osx-font-smoothing: grayscale; 13 | -webkit-text-size-adjust: 100%; 14 | } 15 | 16 | @media (prefers-color-scheme: light) { 17 | :root { 18 | background-color: #f8f8f8; 19 | color: #181818; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /playgrounds/vite-vue/src/style.css: -------------------------------------------------------------------------------- 1 | :root { 2 | background-color: #181818; 3 | color: rgba(255, 255, 255, 0.87); 4 | color-scheme: light dark; 5 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; 6 | font-synthesis: none; 7 | font-weight: 400; 8 | line-height: 1.5; 9 | text-rendering: optimizeLegibility; 10 | 11 | -webkit-font-smoothing: antialiased; 12 | -moz-osx-font-smoothing: grayscale; 13 | -webkit-text-size-adjust: 100%; 14 | } 15 | 16 | @media (prefers-color-scheme: light) { 17 | :root { 18 | background-color: #f8f8f8; 19 | color: #181818; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /site/core/api/actions.md: -------------------------------------------------------------------------------- 1 | 8 | 9 | # Actions 10 | 11 | Actions for accounts, wallets, contracts, transactions, signing, ENS, and more. 12 | 13 | ## Import 14 | 15 | ```ts 16 | import { getAccount } from '@wagmi/core' 17 | ``` 18 | 19 | ## Available Actions 20 | 21 | 22 | 23 | {{ action.text }} 24 | 25 | 26 | -------------------------------------------------------------------------------- /site/snippets/abi-event.ts: -------------------------------------------------------------------------------- 1 | export const abi = [ 2 | { 3 | type: 'event', 4 | name: 'Approval', 5 | inputs: [ 6 | { indexed: true, name: 'owner', type: 'address' }, 7 | { indexed: true, name: 'spender', type: 'address' }, 8 | { indexed: false, name: 'value', type: 'uint256' }, 9 | ], 10 | }, 11 | { 12 | type: 'event', 13 | name: 'Transfer', 14 | inputs: [ 15 | { indexed: true, name: 'from', type: 'address' }, 16 | { indexed: true, name: 'to', type: 'address' }, 17 | { indexed: false, name: 'value', type: 'uint256' }, 18 | ], 19 | }, 20 | ] as const 21 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vue/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wagmi-vue-vite-starter", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "vue-tsc && vite build", 9 | "preview": "vite preview" 10 | }, 11 | "dependencies": { 12 | "@tanstack/vue-query": ">=5.45.0", 13 | "@wagmi/vue": "latest", 14 | "viem": "latest", 15 | "vue": ">=3.4.21" 16 | }, 17 | "devDependencies": { 18 | "@vitejs/plugin-vue": "^5.0.4", 19 | "buffer": "^6.0.3", 20 | "vite": "^5.4.21", 21 | "vue-tsc": "^2.0.6" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/core/src/createEmitter.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test, vi } from 'vitest' 2 | 3 | import type { ConnectorEventMap } from './connectors/createConnector.js' 4 | import { createEmitter } from './createEmitter.js' 5 | import { uid } from './utils/uid.js' 6 | 7 | test('default', () => { 8 | const emitter = createEmitter(uid()) 9 | 10 | const onMessage = vi.fn() 11 | emitter.on('message', onMessage) 12 | emitter.emit('message', { type: 'bar', data: 'baz' }) 13 | 14 | expect(onMessage).toHaveBeenCalledWith({ 15 | type: 'bar', 16 | data: 'baz', 17 | uid: emitter.uid, 18 | }) 19 | }) 20 | -------------------------------------------------------------------------------- /patches/prool.patch: -------------------------------------------------------------------------------- 1 | diff --git a/_lib/server.js b/_lib/server.js 2 | index 16fc552b33e575f40bfee99a38e44acc29587271..b249504c631d28279786392bd6c00d189e1e178f 100644 3 | --- a/_lib/server.js 4 | +++ b/_lib/server.js 5 | @@ -42,6 +42,7 @@ export function createServer(parameters) { 6 | return; 7 | } 8 | const { id, path } = extractPath(url); 9 | + response.setHeader("Access-Control-Allow-Origin", "*"); 10 | if (typeof id === 'number') { 11 | if (path === '/') { 12 | const { host, port } = pool.get(id) || (await pool.start(id)); 13 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/next/src/app/globals.css: -------------------------------------------------------------------------------- 1 | :root { 2 | background-color: #181818; 3 | color: rgba(255, 255, 255, 0.87); 4 | color-scheme: light dark; 5 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; 6 | font-synthesis: none; 7 | font-weight: 400; 8 | line-height: 1.5; 9 | text-rendering: optimizeLegibility; 10 | 11 | -webkit-font-smoothing: antialiased; 12 | -moz-osx-font-smoothing: grayscale; 13 | -webkit-text-size-adjust: 100%; 14 | } 15 | 16 | @media (prefers-color-scheme: light) { 17 | :root { 18 | background-color: #f8f8f8; 19 | color: #181818; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-react/src/index.css: -------------------------------------------------------------------------------- 1 | :root { 2 | background-color: #181818; 3 | color: rgba(255, 255, 255, 0.87); 4 | color-scheme: light dark; 5 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; 6 | font-synthesis: none; 7 | font-weight: 400; 8 | line-height: 1.5; 9 | text-rendering: optimizeLegibility; 10 | 11 | -webkit-font-smoothing: antialiased; 12 | -moz-osx-font-smoothing: grayscale; 13 | -webkit-text-size-adjust: 100%; 14 | } 15 | 16 | @media (prefers-color-scheme: light) { 17 | :root { 18 | background-color: #f8f8f8; 19 | color: #181818; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vue/src/style.css: -------------------------------------------------------------------------------- 1 | :root { 2 | background-color: #181818; 3 | color: rgba(255, 255, 255, 0.87); 4 | color-scheme: light dark; 5 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; 6 | font-synthesis: none; 7 | font-weight: 400; 8 | line-height: 1.5; 9 | text-rendering: optimizeLegibility; 10 | 11 | -webkit-font-smoothing: antialiased; 12 | -moz-osx-font-smoothing: grayscale; 13 | -webkit-text-size-adjust: 100%; 14 | } 15 | 16 | @media (prefers-color-scheme: light) { 17 | :root { 18 | background-color: #f8f8f8; 19 | color: #181818; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/test/src/exports/index.ts: -------------------------------------------------------------------------------- 1 | // biome-ignore lint/performance/noBarrelFile: entrypoint module 2 | export { chain, mainnet, mainnet2, optimism } from '../chains.js' 3 | export { 4 | mainnet2TestClient, 5 | mainnetTestClient, 6 | optimismTestClient, 7 | testClient, 8 | } from '../clients.js' 9 | export { config } from '../config.js' 10 | export { 11 | abi, 12 | accounts, 13 | address, 14 | bytecode, 15 | privateKey, 16 | typedData, 17 | walletConnectProjectId, 18 | } from '../constants.js' 19 | 20 | export { addressRegex, transactionHashRegex } from '../regex.js' 21 | 22 | export { wait } from '../utils.js' 23 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vanilla/src/style.css: -------------------------------------------------------------------------------- 1 | :root { 2 | background-color: #181818; 3 | color: rgba(255, 255, 255, 0.87); 4 | color-scheme: light dark; 5 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; 6 | font-synthesis: none; 7 | font-weight: 400; 8 | line-height: 1.5; 9 | text-rendering: optimizeLegibility; 10 | 11 | -webkit-font-smoothing: antialiased; 12 | -moz-osx-font-smoothing: grayscale; 13 | -webkit-text-size-adjust: 100%; 14 | } 15 | 16 | @media (prefers-color-scheme: light) { 17 | :root { 18 | background-color: #f8f8f8; 19 | color: #181818; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useEstimateFeesPerGas.test.ts: -------------------------------------------------------------------------------- 1 | import { renderHook } from '@wagmi/test/react' 2 | import { expect, test, vi } from 'vitest' 3 | 4 | import { useEstimateFeesPerGas } from './useEstimateFeesPerGas.js' 5 | 6 | test('default', async () => { 7 | const { result } = await renderHook(() => useEstimateFeesPerGas()) 8 | 9 | await vi.waitUntil(() => result.current.isSuccess, { timeout: 5_000 }) 10 | 11 | expect(Object.keys(result.current.data!)).toMatchInlineSnapshot(` 12 | [ 13 | "formatted", 14 | "gasPrice", 15 | "maxFeePerGas", 16 | "maxPriorityFeePerGas", 17 | ] 18 | `) 19 | }) 20 | -------------------------------------------------------------------------------- /playgrounds/vite-vue/src/components/SwitchChain.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | Switch Chain 10 | 11 | Chain ID: {{ chainId }} 12 | 13 | 15 | {{ chain.name }} 16 | 17 | 18 | 19 | {{ status }} 20 | {{ error }} 21 | 22 | 23 | -------------------------------------------------------------------------------- /packages/cli/src/utils/packages.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest' 2 | 3 | import { getIsPackageInstalled, getPackageManager } from './packages.js' 4 | 5 | test('getIsPackageInstalled: true', async () => { 6 | await expect(getIsPackageInstalled({ packageName: 'vitest' })).resolves.toBe( 7 | true, 8 | ) 9 | }) 10 | 11 | test('getIsPackageInstalled: false', async () => { 12 | await expect( 13 | getIsPackageInstalled({ packageName: 'vitest-unknown' }), 14 | ).resolves.toBe(false) 15 | }) 16 | 17 | test('getPackageManager', async () => { 18 | await expect(getPackageManager()).resolves.toMatchInlineSnapshot('"pnpm"') 19 | }) 20 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vanilla/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wagmi-core-vanilla-starter", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc && vite build", 9 | "preview": "vite preview" 10 | }, 11 | "dependencies": { 12 | "@wagmi/connectors": "latest", 13 | "@wagmi/core": "latest", 14 | "react": "^18.3.1", 15 | "react-dom": "^18.3.1", 16 | "viem": "latest" 17 | }, 18 | "devDependencies": { 19 | "@wagmi/cli": "latest", 20 | "buffer": "^6.0.3", 21 | "typescript": "^5.9.2", 22 | "vite": "^5.4.21" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /playgrounds/vite-core/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vite-core", 3 | "private": true, 4 | "type": "module", 5 | "scripts": { 6 | "dev": "vite", 7 | "build": "tsc && vite build", 8 | "preview": "vite preview" 9 | }, 10 | "dependencies": { 11 | "@wagmi/connectors": "workspace:*", 12 | "@wagmi/core": "workspace:*", 13 | "react": ">=18.3.1", 14 | "react-dom": ">=18.3.1", 15 | "viem": "2.*" 16 | }, 17 | "devDependencies": { 18 | "@types/react": ">=18.3.1", 19 | "@types/react-dom": ">=18.3.0", 20 | "@vitejs/plugin-react": "catalog:", 21 | "buffer": "^6.0.3", 22 | "vite": "^5.4.21" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /site/vue/api/composables.md: -------------------------------------------------------------------------------- 1 | 8 | 9 | # Composables 10 | 11 | Vue Composables for accounts, wallets, contracts, transactions, signing, ENS, and more. 12 | 13 | ## Import 14 | 15 | ```ts 16 | import { useAccount } from '@wagmi/vue' 17 | ``` 18 | 19 | ## Available Composables 20 | 21 | 22 | 23 | {{ composable.text }} 24 | 25 | 26 | -------------------------------------------------------------------------------- /packages/core/src/query/getCallsStatus.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { getCallsStatusQueryOptions } from './getCallsStatus.js' 5 | 6 | test('default', () => { 7 | expect( 8 | getCallsStatusQueryOptions(config, { 9 | id: '0x0000000000000000000000000000000000000000', 10 | }), 11 | ).toMatchInlineSnapshot(` 12 | { 13 | "queryFn": [Function], 14 | "queryKey": [ 15 | "callsStatus", 16 | { 17 | "id": "0x0000000000000000000000000000000000000000", 18 | }, 19 | ], 20 | "retry": [Function], 21 | } 22 | `) 23 | }) 24 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-react/src/wagmi.ts: -------------------------------------------------------------------------------- 1 | import { createConfig, http } from 'wagmi' 2 | import { mainnet, sepolia } from 'wagmi/chains' 3 | import { baseAccount, injected, walletConnect } from 'wagmi/connectors' 4 | 5 | export const config = createConfig({ 6 | chains: [mainnet, sepolia], 7 | connectors: [ 8 | injected(), 9 | baseAccount(), 10 | walletConnect({ projectId: import.meta.env.VITE_WC_PROJECT_ID }), 11 | ], 12 | transports: { 13 | [mainnet.id]: http(), 14 | [sepolia.id]: http(), 15 | }, 16 | }) 17 | 18 | declare module 'wagmi' { 19 | interface Register { 20 | config: typeof config 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /playgrounds/vite-vue/src/components/SwitchAccount.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | Switch Account 10 | 11 | 13 | {{ connector.name }} 14 | 15 | 16 | 17 | {{ status }} 18 | {{ error }} 19 | 20 | 21 | -------------------------------------------------------------------------------- /site/core/api/actions/getChains.md: -------------------------------------------------------------------------------- 1 | # getChains 2 | 3 | Action for getting configured chains. 4 | 5 | ## Import 6 | 7 | ```ts 8 | import { getChains } from '@wagmi/core' 9 | ``` 10 | 11 | ## Usage 12 | 13 | ::: code-group 14 | ```ts [index.ts] 15 | import { getChains } from '@wagmi/core' 16 | import { config } from './config' 17 | 18 | const chains = getChains(config) 19 | ``` 20 | <<< @/snippets/core/config.ts[config.ts] 21 | ::: 22 | 23 | ## Return Type 24 | 25 | ```ts 26 | import { type GetChainsReturnType } from '@wagmi/core' 27 | ``` 28 | 29 | `readonly [Chain, ...Chain[]]` 30 | 31 | Chains from [`config.chains`](/core/api/createConfig#chains). 32 | -------------------------------------------------------------------------------- /site/snippets/abi-write.ts: -------------------------------------------------------------------------------- 1 | export const abi = [ 2 | { 3 | type: 'function', 4 | name: 'approve', 5 | stateMutability: 'nonpayable', 6 | inputs: [ 7 | { name: 'spender', type: 'address' }, 8 | { name: 'amount', type: 'uint256' }, 9 | ], 10 | outputs: [{ type: 'bool' }], 11 | }, 12 | { 13 | type: 'function', 14 | name: 'transferFrom', 15 | stateMutability: 'nonpayable', 16 | inputs: [ 17 | { name: 'sender', type: 'address' }, 18 | { name: 'recipient', type: 'address' }, 19 | { name: 'amount', type: 'uint256' }, 20 | ], 21 | outputs: [{ type: 'bool' }], 22 | }, 23 | ] as const 24 | -------------------------------------------------------------------------------- /packages/connectors/src/coinbaseWallet.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, expectTypeOf, test } from 'vitest' 3 | 4 | import { coinbaseWallet } from './coinbaseWallet.js' 5 | 6 | test('setup', () => { 7 | const connectorFn = coinbaseWallet({ appName: 'wagmi', version: '4' }) 8 | const connector = config._internal.connectors.setup(connectorFn) 9 | expect(connector.name).toEqual('Coinbase Wallet') 10 | 11 | type ConnectFnParameters = NonNullable< 12 | Parameters<(typeof connector)['connect']>[0] 13 | > 14 | expectTypeOf().toMatchTypeOf< 15 | boolean | undefined 16 | >() 17 | }) 18 | -------------------------------------------------------------------------------- /packages/core/src/actions/watchClient.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import type { Client } from 'viem' 3 | import { expect, test } from 'vitest' 4 | 5 | import { switchChain } from './switchChain.js' 6 | import { watchClient } from './watchClient.js' 7 | 8 | test('default', async () => { 9 | const clients: Client[] = [] 10 | const unwatch = watchClient(config, { 11 | onChange(client) { 12 | clients.push(client) 13 | }, 14 | }) 15 | 16 | switchChain(config, { chainId: 456 }) 17 | switchChain(config, { chainId: 10 }) 18 | switchChain(config, { chainId: 1 }) 19 | 20 | expect(clients.length).toBe(3) 21 | 22 | unwatch() 23 | }) 24 | -------------------------------------------------------------------------------- /packages/core/src/query/waitForCallsStatus.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { waitForCallsStatusQueryOptions } from './waitForCallsStatus.js' 5 | 6 | test('default', () => { 7 | expect( 8 | waitForCallsStatusQueryOptions(config, { 9 | id: '0x0000000000000000000000000000000000000000', 10 | }), 11 | ).toMatchInlineSnapshot(` 12 | { 13 | "queryFn": [Function], 14 | "queryKey": [ 15 | "callsStatus", 16 | { 17 | "id": "0x0000000000000000000000000000000000000000", 18 | }, 19 | ], 20 | "retry": [Function], 21 | } 22 | `) 23 | }) 24 | -------------------------------------------------------------------------------- /packages/register-tests/react/src/useConfig.test-d.ts: -------------------------------------------------------------------------------- 1 | import { config as testConfig } from '@wagmi/test' 2 | import { expectTypeOf, test } from 'vitest' 3 | import { type Config, useConfig } from 'wagmi' 4 | 5 | import type { config } from './config.js' 6 | 7 | test('default', async () => { 8 | const result = useConfig() 9 | expectTypeOf(result).not.toEqualTypeOf() 10 | expectTypeOf(result).toEqualTypeOf() 11 | }) 12 | 13 | test('parameters: config', async () => { 14 | const result = useConfig({ config: testConfig }) 15 | expectTypeOf(result).not.toEqualTypeOf() 16 | expectTypeOf(result).toEqualTypeOf() 17 | }) 18 | -------------------------------------------------------------------------------- /site/core/api/actions/getConnections.md: -------------------------------------------------------------------------------- 1 | # getConnections 2 | 3 | Action for getting active connections. 4 | 5 | ## Import 6 | 7 | ```ts 8 | import { getConnections } from '@wagmi/core' 9 | ``` 10 | 11 | ## Usage 12 | 13 | ::: code-group 14 | ```ts [index.ts] 15 | import { getConnections } from '@wagmi/core' 16 | import { config } from './config' 17 | 18 | const connections = getConnections(config) 19 | ``` 20 | <<< @/snippets/core/config.ts[config.ts] 21 | ::: 22 | 23 | ## Return Type 24 | 25 | ```ts 26 | import { type GetConnectionsReturnType } from '@wagmi/core' 27 | ``` 28 | 29 | [`Connection[]`](/core/api/createConfig#connection) 30 | 31 | Active connections. 32 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-vanilla/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "module": "ESNext", 6 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | 16 | /* Linting */ 17 | "strict": true, 18 | "noUnusedLocals": true, 19 | "noUnusedParameters": true, 20 | "noFallthroughCasesInSwitch": true 21 | }, 22 | "include": ["src"] 23 | } 24 | -------------------------------------------------------------------------------- /packages/register-tests/vue/src/useConfig.test-d.ts: -------------------------------------------------------------------------------- 1 | import { config as testConfig } from '@wagmi/test' 2 | import { type Config, useConfig } from '@wagmi/vue' 3 | import { expectTypeOf, test } from 'vitest' 4 | 5 | import type { config } from './config.js' 6 | 7 | test('default', async () => { 8 | const result = useConfig() 9 | expectTypeOf(result).not.toEqualTypeOf() 10 | expectTypeOf(result).toEqualTypeOf() 11 | }) 12 | 13 | test('parameters: config', async () => { 14 | const result = useConfig({ config: testConfig }) 15 | expectTypeOf(result).not.toEqualTypeOf() 16 | expectTypeOf(result).toEqualTypeOf() 17 | }) 18 | -------------------------------------------------------------------------------- /playgrounds/next/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "noEmit": true, 9 | "esModuleInterop": true, 10 | "module": "esnext", 11 | "moduleResolution": "bundler", 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "jsx": "preserve", 15 | "incremental": true, 16 | "plugins": [ 17 | { 18 | "name": "next" 19 | } 20 | ] 21 | }, 22 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], 23 | "exclude": ["node_modules"] 24 | } 25 | -------------------------------------------------------------------------------- /site/vue/api/composables/useConfig.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: useConfig 3 | description: Composable for getting `Config` from the `WagmiPlugin`. 4 | --- 5 | 6 | # useConfig 7 | 8 | Composable for getting [`Config`](/vue/api/createConfig#config) from the [`WagmiPlugin`](/vue/api/WagmiPlugin). 9 | 10 | ## Import 11 | 12 | ```ts 13 | import { useConfig } from 'wagmi' 14 | ``` 15 | 16 | ## Usage 17 | 18 | ::: code-group 19 | ```vue [index.vue] 20 | 25 | ``` 26 | 27 | ::: 28 | 29 | ## Return Type 30 | 31 | ```ts 32 | import { type UseConfigReturnType } from 'wagmi' 33 | ``` 34 | -------------------------------------------------------------------------------- /site/core/api/actions/getConnectors.md: -------------------------------------------------------------------------------- 1 | # getConnectors 2 | 3 | Action for getting configured connectors. 4 | 5 | ## Import 6 | 7 | ```ts 8 | import { getConnectors } from '@wagmi/core' 9 | ``` 10 | 11 | ## Usage 12 | 13 | ::: code-group 14 | ```ts [index.ts] 15 | import { getConnectors } from '@wagmi/core' 16 | import { config } from './config' 17 | 18 | const connectors = getConnectors(config) 19 | ``` 20 | <<< @/snippets/core/config.ts[config.ts] 21 | ::: 22 | 23 | ## Return Type 24 | 25 | ```ts 26 | import { type GetConnectorsReturnType } from '@wagmi/core' 27 | ``` 28 | 29 | `readonly Connector[]` 30 | 31 | Connectors from [`config.connectors`](/core/api/createConfig#connectors-1). 32 | -------------------------------------------------------------------------------- /packages/core/src/actions/watchPublicClient.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import type { Client } from 'viem' 3 | import { expect, test } from 'vitest' 4 | 5 | import { switchChain } from './switchChain.js' 6 | import { watchPublicClient } from './watchPublicClient.js' 7 | 8 | test('default', async () => { 9 | const clients: Client[] = [] 10 | const unwatch = watchPublicClient(config, { 11 | onChange(client) { 12 | clients.push(client) 13 | }, 14 | }) 15 | 16 | switchChain(config, { chainId: 456 }) 17 | switchChain(config, { chainId: 10 }) 18 | switchChain(config, { chainId: 1 }) 19 | 20 | expect(clients.length).toBe(3) 21 | 22 | unwatch() 23 | }) 24 | -------------------------------------------------------------------------------- /site/core/api/createConnector.md: -------------------------------------------------------------------------------- 1 | # createConnector 2 | 3 | Creates new [`CreateConnectorFn`](#parameters). 4 | 5 | ## Import 6 | 7 | ```ts 8 | import { createConnector } from '@wagmi/core' 9 | ``` 10 | 11 | ## Usage 12 | 13 | ```ts 14 | import { createConnector } from '@wagmi/core' 15 | 16 | export type InjectedParameters = {} 17 | 18 | export function injected(parameters: InjectedParameters = {}) { 19 | return createConnector((config) => ({ 20 | // ... 21 | })) 22 | } 23 | ``` 24 | 25 | ## Parameters 26 | 27 | ```ts 28 | import { type CreateConnectorFn } from '@wagmi/core' 29 | ``` 30 | 31 | Read [Creating Connectors](/dev/creating-connectors) for more info on the `CreateConnectorFn` type. -------------------------------------------------------------------------------- /playgrounds/nuxt/app.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 29 | -------------------------------------------------------------------------------- /site/core/api/chains.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | # Chains 9 | 10 | ## Import 11 | 12 | Import via the `'@wagmi/core/chains'` entrypoint (proxies all chains from `'viem/chains'`). 13 | 14 | ```ts 15 | import { mainnet } from '@wagmi/core/chains' 16 | ``` 17 | 18 | ## Available Chains 19 | 20 | Chain definitions as of `viem@{{viemVersion}}`. For `viem@latest`, visit the [Viem repo](https://github.com/wevm/viem/blob/main/src/chains/index.ts). 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /packages/core/src/utils/extractRpcUrls.ts: -------------------------------------------------------------------------------- 1 | import type { Chain, Transport } from 'viem' 2 | 3 | type ExtractRpcUrlsParameters = { 4 | transports?: Record | undefined 5 | chain: Chain 6 | } 7 | 8 | export function extractRpcUrls(parameters: ExtractRpcUrlsParameters) { 9 | const { chain } = parameters 10 | const fallbackUrl = chain.rpcUrls.default.http[0] 11 | 12 | if (!parameters.transports) return [fallbackUrl] 13 | 14 | const transport = parameters.transports?.[chain.id]?.({ chain }) 15 | const transports = (transport?.value?.transports as NonNullable< 16 | typeof transport 17 | >[]) || [transport] 18 | return transports.map(({ value }) => value?.url || fallbackUrl) 19 | } 20 | -------------------------------------------------------------------------------- /packages/vue/src/composables/useChainId.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { renderComposable } from '@wagmi/test/vue' 3 | import { expect, test } from 'vitest' 4 | 5 | import { useChainId } from './useChainId.js' 6 | 7 | test('default', () => { 8 | const [chainId] = renderComposable(() => useChainId()) 9 | 10 | expect(chainId.value).toMatchInlineSnapshot('1') 11 | 12 | config.setState((x) => ({ ...x, chainId: 456 })) 13 | 14 | expect(chainId.value).toMatchInlineSnapshot('456') 15 | }) 16 | 17 | test('parameters: config', () => { 18 | const [chainId] = renderComposable(() => useChainId({ config }), { 19 | attach() {}, 20 | }) 21 | expect(chainId.value).toBeDefined() 22 | }) 23 | -------------------------------------------------------------------------------- /site/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "esModuleInterop": true, 5 | "forceConsistentCasingInFileNames": true, 6 | "jsx": "preserve", 7 | "lib": ["DOM", "ESNext"], 8 | "module": "ESNext", 9 | "moduleResolution": "node", 10 | "noUnusedLocals": true, 11 | "paths": { 12 | "~/*": ["src/*"] 13 | }, 14 | "resolveJsonModule": true, 15 | "skipLibCheck": true, 16 | "strict": true, 17 | "strictNullChecks": true, 18 | "target": "esnext", 19 | "types": ["vite/client", "vitepress"] 20 | }, 21 | "include": ["./*.ts", "./.vitepress/**/*.ts", "./.vitepress/**/*.vue"], 22 | "exclude": ["dist", "node_modules", "snippets"] 23 | } 24 | -------------------------------------------------------------------------------- /packages/react/src/exports/query.ts: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // @wagmi/core/query 3 | //////////////////////////////////////////////////////////////////////////////// 4 | 5 | // biome-ignore lint/performance/noBarrelFile: entrypoint module 6 | // biome-ignore lint/performance/noReExportAll: entrypoint module 7 | export * from '@wagmi/core/query' 8 | 9 | export { 10 | type UseInfiniteQueryParameters, 11 | type UseInfiniteQueryReturnType, 12 | type UseMutationParameters, 13 | type UseMutationReturnType, 14 | type UseQueryParameters, 15 | type UseQueryReturnType, 16 | useInfiniteQuery, 17 | useMutation, 18 | useQuery, 19 | } from '../utils/query.js' 20 | -------------------------------------------------------------------------------- /packages/test/src/exports/index.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from 'vitest' 2 | 3 | import * as react from './index.js' 4 | 5 | test('exports', () => { 6 | expect(Object.keys(react)).toMatchInlineSnapshot(` 7 | [ 8 | "chain", 9 | "mainnet", 10 | "mainnet2", 11 | "optimism", 12 | "mainnet2TestClient", 13 | "mainnetTestClient", 14 | "optimismTestClient", 15 | "testClient", 16 | "config", 17 | "abi", 18 | "accounts", 19 | "address", 20 | "bytecode", 21 | "privateKey", 22 | "typedData", 23 | "walletConnectProjectId", 24 | "addressRegex", 25 | "transactionHashRegex", 26 | "wait", 27 | ] 28 | `) 29 | }) 30 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/nuxt/app.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 29 | -------------------------------------------------------------------------------- /playgrounds/vite-vue/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "module": "ESNext", 6 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 7 | "skipLibCheck": true, 8 | 9 | "moduleResolution": "bundler", 10 | "allowImportingTsExtensions": true, 11 | "resolveJsonModule": true, 12 | "isolatedModules": true, 13 | "noEmit": true, 14 | "jsx": "preserve", 15 | 16 | "strict": true, 17 | "noUnusedLocals": true, 18 | "noUnusedParameters": true, 19 | "noFallthroughCasesInSwitch": true 20 | }, 21 | "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"], 22 | "references": [{ "path": "./tsconfig.node.json" }] 23 | } 24 | -------------------------------------------------------------------------------- /packages/connectors/src/gemini.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { gemini } from './gemini.js' 5 | 6 | test('setup', () => { 7 | const connectorFn = gemini() 8 | const connector = config._internal.connectors.setup(connectorFn) 9 | expect(connector.name).toEqual('Gemini Wallet') 10 | }) 11 | 12 | test('setup with parameters', () => { 13 | const connectorFn = gemini({ 14 | appMetadata: { 15 | name: 'Test App', 16 | url: 'https://example.com', 17 | }, 18 | }) 19 | const connector = config._internal.connectors.setup(connectorFn) 20 | expect(connector.name).toEqual('Gemini Wallet') 21 | expect(connector.id).toEqual('gemini') 22 | }) 23 | -------------------------------------------------------------------------------- /packages/core/src/types/properties.ts: -------------------------------------------------------------------------------- 1 | import type { Config, Connector } from '../createConfig.js' 2 | 3 | export type ChainIdParameter< 4 | config extends Config, 5 | chainId extends 6 | | config['chains'][number]['id'] 7 | | undefined = config['chains'][number]['id'], 8 | > = { 9 | chainId?: 10 | | (chainId extends config['chains'][number]['id'] ? chainId : undefined) 11 | | config['chains'][number]['id'] 12 | | undefined 13 | } 14 | 15 | export type ConnectorParameter = { 16 | connector?: Connector | undefined 17 | } 18 | 19 | export type ScopeKeyParameter = { scopeKey?: string | undefined } 20 | 21 | export type SyncConnectedChainParameter = { 22 | syncConnectedChain?: boolean | undefined 23 | } 24 | -------------------------------------------------------------------------------- /packages/vue/src/composables/useAccount.test.ts: -------------------------------------------------------------------------------- 1 | import { connect, disconnect } from '@wagmi/core' 2 | import { config } from '@wagmi/test' 3 | import { renderComposable } from '@wagmi/test/vue' 4 | import { expect, test } from 'vitest' 5 | 6 | import { useAccount } from './useAccount.js' 7 | 8 | test('default', async () => { 9 | const [account] = renderComposable(() => useAccount()) 10 | 11 | expect(account.address.value).not.toBeDefined() 12 | expect(account.status.value).toEqual('disconnected') 13 | 14 | await connect(config, { connector: config.connectors[0]! }) 15 | 16 | expect(account.address.value).toBeDefined() 17 | expect(account.status.value).toEqual('connected') 18 | 19 | await disconnect(config) 20 | }) 21 | -------------------------------------------------------------------------------- /packages/core/src/query/estimateGas.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { parseEther } from 'viem' 3 | import { expect, test } from 'vitest' 4 | 5 | import { estimateGasQueryOptions } from './estimateGas.js' 6 | 7 | test('default', () => { 8 | expect( 9 | estimateGasQueryOptions(config, { 10 | to: '0xd2135CfB216b74109775236E36d4b433F1DF507B', 11 | value: parseEther('0.01'), 12 | }), 13 | ).toMatchInlineSnapshot(` 14 | { 15 | "queryFn": [Function], 16 | "queryKey": [ 17 | "estimateGas", 18 | { 19 | "to": "0xd2135CfB216b74109775236E36d4b433F1DF507B", 20 | "value": 10000000000000000n, 21 | }, 22 | ], 23 | } 24 | `) 25 | }) 26 | -------------------------------------------------------------------------------- /packages/register-tests/vue/src/config.ts: -------------------------------------------------------------------------------- 1 | import { createConfig, mock } from '@wagmi/vue' 2 | import { celo, mainnet, optimism, zkSync } from '@wagmi/vue/chains' 3 | import { http } from 'viem' 4 | 5 | export const config = createConfig({ 6 | chains: [celo, mainnet, optimism, zkSync], 7 | connectors: [mock({ accounts: ['0x'] })], 8 | transports: { 9 | [celo.id]: http(), 10 | [mainnet.id]: http(), 11 | [optimism.id]: http(), 12 | [zkSync.id]: http(), 13 | }, 14 | }) 15 | 16 | export type ChainId = 17 | | typeof celo.id 18 | | typeof mainnet.id 19 | | typeof optimism.id 20 | | typeof zkSync.id 21 | 22 | declare module '@wagmi/vue' { 23 | interface Register { 24 | config: typeof config 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /site/core/api/connectors.md: -------------------------------------------------------------------------------- 1 | 9 | 10 | # Connectors 11 | 12 | Connectors for popular wallet providers and protocols. 13 | 14 | ## Import 15 | 16 | ```ts 17 | import { injected } from 'wagmi/connectors' 18 | ``` 19 | 20 | ## Built-In Connectors 21 | 22 | Available via the `'wagmi/connectors'` entrypoint. 23 | 24 | 25 | 26 | {{ connector.text }} 27 | 28 | 29 | -------------------------------------------------------------------------------- /site/react/api/connectors.md: -------------------------------------------------------------------------------- 1 | 9 | 10 | # Connectors 11 | 12 | Connectors for popular wallet providers and protocols. 13 | 14 | ## Import 15 | 16 | Import via the `'wagmi/connectors'` entrypoint. 17 | 18 | ```ts 19 | import { injected } from 'wagmi/connectors' 20 | ``` 21 | 22 | ## Available Connectors 23 | 24 | 25 | 26 | {{ connector.text }} 27 | 28 | 29 | -------------------------------------------------------------------------------- /packages/core/src/actions/watchAsset.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { connect } from './connect.js' 5 | import { disconnect } from './disconnect.js' 6 | import { watchAsset } from './watchAsset.js' 7 | 8 | const connector = config.connectors[0]! 9 | 10 | test('default', async () => { 11 | await connect(config, { connector }) 12 | await expect( 13 | watchAsset(config, { 14 | type: 'ERC20', 15 | options: { 16 | address: '0x0000000000000000000000000000000000000000', 17 | symbol: 'NULL', 18 | decimals: 18, 19 | }, 20 | }), 21 | ).resolves.toMatchInlineSnapshot('true') 22 | await disconnect(config, { connector }) 23 | }) 24 | -------------------------------------------------------------------------------- /packages/core/src/errors/connector.test.ts: -------------------------------------------------------------------------------- 1 | import { config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { 5 | ProviderNotFoundError, 6 | SwitchChainNotSupportedError, 7 | } from './connector.js' 8 | 9 | test('constructors', () => { 10 | expect(new ProviderNotFoundError()).toMatchInlineSnapshot(` 11 | [ProviderNotFoundError: Provider not found. 12 | 13 | Version: @wagmi/core@x.y.z] 14 | `) 15 | expect( 16 | new SwitchChainNotSupportedError({ 17 | connector: config.connectors[0]!, 18 | }), 19 | ).toMatchInlineSnapshot(` 20 | [SwitchChainNotSupportedError: "Mock Connector" does not support programmatic chain switching. 21 | 22 | Version: @wagmi/core@x.y.z] 23 | `) 24 | }) 25 | -------------------------------------------------------------------------------- /packages/core/src/query/readContract.test.ts: -------------------------------------------------------------------------------- 1 | import { abi, config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { readContractQueryOptions } from './readContract.js' 5 | 6 | test('default', () => { 7 | expect( 8 | readContractQueryOptions(config, { 9 | address: '0x', 10 | abi: abi.erc20, 11 | functionName: 'balanceOf', 12 | args: ['0x'], 13 | }), 14 | ).toMatchInlineSnapshot(` 15 | { 16 | "queryFn": [Function], 17 | "queryKey": [ 18 | "readContract", 19 | { 20 | "address": "0x", 21 | "args": [ 22 | "0x", 23 | ], 24 | "functionName": "balanceOf", 25 | }, 26 | ], 27 | } 28 | `) 29 | }) 30 | -------------------------------------------------------------------------------- /site/vue/api/connectors.md: -------------------------------------------------------------------------------- 1 | 9 | 10 | # Connectors 11 | 12 | Connectors for popular wallet providers and protocols. 13 | 14 | ## Import 15 | 16 | Import via the `'@wagmi/vue/connectors'` entrypoint. 17 | 18 | ```ts 19 | import { injected } from '@wagmi/vue/connectors' 20 | ``` 21 | 22 | ## Available Connectors 23 | 24 | 25 | 26 | {{ connector.text }} 27 | 28 | 29 | -------------------------------------------------------------------------------- /packages/core/src/actions/getGasPrice.test.ts: -------------------------------------------------------------------------------- 1 | import { chain, config, testClient } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { getGasPrice } from './getGasPrice.js' 5 | 6 | test('default', async () => { 7 | await testClient.mainnet.setNextBlockBaseFeePerGas({ 8 | baseFeePerGas: 2_000_000_000n, 9 | }) 10 | await expect(getGasPrice(config)).resolves.toBe(3000000000n) 11 | }) 12 | 13 | test('parameters: chainId', async () => { 14 | await testClient.mainnet2.setNextBlockBaseFeePerGas({ 15 | baseFeePerGas: 1_000_000_000n, 16 | }) 17 | await testClient.mainnet2.mine({ blocks: 1 }) 18 | await expect( 19 | getGasPrice(config, { chainId: chain.mainnet2.id }), 20 | ).resolves.toBe(1875000000n) 21 | }) 22 | -------------------------------------------------------------------------------- /packages/core/src/actions/watchChainId.test.ts: -------------------------------------------------------------------------------- 1 | import { chain, config } from '@wagmi/test' 2 | import { expect, test } from 'vitest' 3 | 4 | import { watchChainId } from './watchChainId.js' 5 | 6 | test('default', async () => { 7 | const chainIds: number[] = [] 8 | const unwatch = watchChainId(config, { 9 | onChange(chainId) { 10 | chainIds.push(chainId) 11 | }, 12 | }) 13 | config.setState((x) => ({ ...x, chainId: chain.mainnet2.id })) 14 | config.setState((x) => ({ ...x, chainId: chain.mainnet.id })) 15 | config.setState((x) => ({ ...x, chainId: chain.mainnet2.id })) 16 | 17 | expect(chainIds).toMatchInlineSnapshot(` 18 | [ 19 | 456, 20 | 1, 21 | 456, 22 | ] 23 | `) 24 | 25 | unwatch() 26 | }) 27 | -------------------------------------------------------------------------------- /playgrounds/next/src/app/providers.tsx: -------------------------------------------------------------------------------- 1 | 'use client' 2 | 3 | import { QueryClient, QueryClientProvider } from '@tanstack/react-query' 4 | import { type ReactNode, useState } from 'react' 5 | import { type State, WagmiProvider } from 'wagmi' 6 | 7 | import { getConfig } from '../wagmi' 8 | 9 | export function Providers(props: { 10 | children: ReactNode 11 | initialState?: State 12 | }) { 13 | const [config] = useState(() => getConfig()) 14 | const [queryClient] = useState(() => new QueryClient()) 15 | 16 | return ( 17 | 18 | 19 | {props.children} 20 | 21 | 22 | ) 23 | } 24 | -------------------------------------------------------------------------------- /site/cli/api/commands/init.md: -------------------------------------------------------------------------------- 1 | # init 2 | 3 | Creates configuration file. If TypeScript is detected, the config file will use TypeScript and be named `wagmi.config.ts`. Otherwise, the config file will use JavaScript and be named `wagmi.config.js`. 4 | 5 | ## Usage 6 | 7 | ```bash 8 | wagmi init 9 | ``` 10 | 11 | ## Options 12 | 13 | ### -c, --config \ 14 | 15 | `string` 16 | 17 | Path to config file. 18 | 19 | ```bash 20 | wagmi init --config wagmi.config.ts 21 | ``` 22 | 23 | ### -r, --root \ 24 | 25 | `string` 26 | 27 | Root path to resolve config from. 28 | 29 | ```bash 30 | wagmi init --root path/to/root 31 | ``` 32 | 33 | ### -h, --help 34 | 35 | Displays help message. 36 | 37 | ```bash 38 | wagmi init --help 39 | ``` 40 | 41 | -------------------------------------------------------------------------------- /packages/cli/src/utils/resolveConfig.ts: -------------------------------------------------------------------------------- 1 | import { bundleRequire } from 'bundle-require' 2 | 3 | import type { Config } from '../config.js' 4 | import type { MaybeArray } from '../types.js' 5 | 6 | type ResolveConfigParameters = { 7 | /** Path to config file */ 8 | configPath: string 9 | } 10 | 11 | /** Bundles and returns wagmi config object from path. */ 12 | export async function resolveConfig( 13 | parameters: ResolveConfigParameters, 14 | ): Promise> { 15 | const { configPath } = parameters 16 | const res = await bundleRequire({ filepath: configPath }) 17 | let config = res.mod.default 18 | if (config.default) config = config.default 19 | if (typeof config !== 'function') return config 20 | return await config() 21 | } 22 | -------------------------------------------------------------------------------- /packages/core/src/actions/watchChainId.ts: -------------------------------------------------------------------------------- 1 | import type { Config } from '../createConfig.js' 2 | import type { GetChainIdReturnType } from './getChainId.js' 3 | 4 | export type WatchChainIdParameters = { 5 | onChange( 6 | chainId: GetChainIdReturnType, 7 | prevChainId: GetChainIdReturnType, 8 | ): void 9 | } 10 | 11 | export type WatchChainIdReturnType = () => void 12 | 13 | /** https://wagmi.sh/core/api/actions/watchChainId */ 14 | export function watchChainId( 15 | config: config, 16 | parameters: WatchChainIdParameters, 17 | ): WatchChainIdReturnType { 18 | const { onChange } = parameters 19 | return config.subscribe((state) => state.chainId, onChange) 20 | } 21 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/next/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "noEmit": true, 9 | "esModuleInterop": true, 10 | "module": "esnext", 11 | "moduleResolution": "bundler", 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "jsx": "preserve", 15 | "incremental": true, 16 | "plugins": [ 17 | { 18 | "name": "next" 19 | } 20 | ], 21 | "paths": { 22 | "@/*": ["./src/*"] 23 | } 24 | }, 25 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], 26 | "exclude": ["node_modules"] 27 | } 28 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-react/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wagmi-vite-starter", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc && vite build", 9 | "preview": "vite preview" 10 | }, 11 | "dependencies": { 12 | "@tanstack/react-query": "5.45.1", 13 | "react": "^18.3.1", 14 | "react-dom": "^18.3.1", 15 | "viem": "latest", 16 | "wagmi": "latest" 17 | }, 18 | "devDependencies": { 19 | "@types/react": "^18.3.1", 20 | "@types/react-dom": "^18.3.0", 21 | "@vitejs/plugin-react": "^4.2.1", 22 | "@wagmi/cli": "latest", 23 | "buffer": "^6.0.3", 24 | "typescript": "^5.9.2", 25 | "vite": "^5.4.21" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/create-wagmi/templates/vite-react/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | "jsx": "react-jsx", 16 | 17 | /* Linting */ 18 | "strict": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noFallthroughCasesInSwitch": true 22 | }, 23 | "include": ["src"], 24 | "references": [{ "path": "./tsconfig.node.json" }] 25 | } 26 | -------------------------------------------------------------------------------- /site/vue/api/Nuxt.md: -------------------------------------------------------------------------------- 1 | # Nuxt 2 | 3 | [Nuxt Module](https://nuxt.com/docs/guide/concepts/modules) for Wagmi. Adds all [Composables](/vue/api/composables) as [auto-imports](https://nuxt.com/docs/guide/concepts/auto-imports). 4 | 5 | ## Usage 6 | 7 | ::: code-group 8 | ```ts twoslash [nuxt.config.ts] 9 | import { defineNuxtConfig } from 'nuxt/config' 10 | 11 | export default defineNuxtConfig({ 12 | modules: ['@wagmi/vue/nuxt'], 13 | }) 14 | ``` 15 | ```vue [index.vue] 16 | 20 | 21 | 22 | Address: {{ account.address }} 23 | 24 | ``` 25 | <<< @/snippets/vue/config.ts[config.ts] 26 | ::: 27 | 28 | -------------------------------------------------------------------------------- /packages/core/src/actions/getConnections.ts: -------------------------------------------------------------------------------- 1 | import type { Config, Connection } from '../createConfig.js' 2 | import type { Compute } from '../types/utils.js' 3 | import { deepEqual } from '../utils/deepEqual.js' 4 | 5 | export type GetConnectionsReturnType = Compute[] 6 | 7 | let previousConnections: Connection[] = [] 8 | 9 | /** https://wagmi.sh/core/api/actions/getConnections */ 10 | export function getConnections(config: Config): GetConnectionsReturnType { 11 | const connections = [...config.state.connections.values()] 12 | if (config.state.status === 'reconnecting') return previousConnections 13 | if (deepEqual(previousConnections, connections)) return previousConnections 14 | previousConnections = connections 15 | return connections 16 | } 17 | -------------------------------------------------------------------------------- /packages/core/src/actions/watchBlocks.test.ts: -------------------------------------------------------------------------------- 1 | import { config, testClient, wait } from '@wagmi/test' 2 | import type { Block } from 'viem' 3 | import { expect, test, vi } from 'vitest' 4 | import { watchBlocks } from './watchBlocks.js' 5 | 6 | test('default', async () => { 7 | const blocks: Block[] = [] 8 | const unwatch = watchBlocks(config, { 9 | onBlock(block) { 10 | blocks.push(block) 11 | }, 12 | }) 13 | 14 | await testClient.mainnet.mine({ blocks: 1 }) 15 | await wait(500) 16 | await testClient.mainnet.mine({ blocks: 1 }) 17 | await wait(500) 18 | await testClient.mainnet.mine({ blocks: 1 }) 19 | 20 | await vi.waitUntil(() => blocks.length === 3, { timeout: 5_000 }) 21 | expect(blocks.length).toBe(3) 22 | 23 | unwatch() 24 | }) 25 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useConfig.test.ts: -------------------------------------------------------------------------------- 1 | import { createWrapper, renderHook } from '@wagmi/test/react' 2 | import { expect, test, vi } from 'vitest' 3 | 4 | import { useConfig } from './useConfig.js' 5 | 6 | test('mounts', async () => { 7 | const { result } = await renderHook(() => useConfig()) 8 | expect(result.current).toBeDefined() 9 | }) 10 | 11 | test('behavior: throws when not inside Provider', () => { 12 | vi.spyOn(console, 'error').mockImplementation(() => {}) 13 | 14 | try { 15 | renderHook(() => useConfig(), { 16 | wrapper: createWrapper(() => null, undefined), 17 | }) 18 | } catch (error) { 19 | expect(error).toMatchInlineSnapshot( 20 | '[Error: `useConfig` must be used within `WagmiProvider`.]', 21 | ) 22 | } 23 | }) 24 | --------------------------------------------------------------------------------
{{ client }}
{{ connectorClient }}