Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/wagmi-dev/wagmi
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Nov 28, 2023
2 parents 71ebcec + e113b75 commit 68c18f9
Show file tree
Hide file tree
Showing 61 changed files with 359 additions and 381 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Once the Next.js dev server is running, you can make changes to any of the packa

## Running the test suite

wagmi uses [Anvil](https://github.com/foundry-rs/foundry/tree/master/anvil) to execute tests against a local Ethereum node. First, install Anvil via [Foundry](https://book.getfoundry.sh/getting-started/installation). Next, add the following to your environment (recommended to use [`direnv`](https://github.com/direnv/direnv)):
wagmi uses [Anvil](https://github.com/foundry-rs/foundry/tree/master/crates/anvil) to execute tests against a local Ethereum node. First, install Anvil via [Foundry](https://book.getfoundry.sh/getting-started/installation). Next, add the following to your environment (recommended to use [`direnv`](https://github.com/direnv/direnv)):

```bash
ANVIL_FORK_URL=https://eth-mainnet.alchemyapi.io/v2/<apiKey>
Expand Down
27 changes: 27 additions & 0 deletions .github/logo-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions .github/logo-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
timeout-minutes: 5

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install dependencies
uses: ./.github/actions/install-dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/on-push-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
timeout-minutes: 5

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
name: Publish Snapshot
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install dependencies
uses: ./.github/actions/install-dependencies
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ jobs:
timeout-minutes: 5

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install dependencies
uses: ./.github/actions/install-dependencies

- name: Lint code
run: pnpm format && pnpm lint:fix

- uses: stefanzweifel/git-auto-commit-action@v4
- uses: stefanzweifel/git-auto-commit-action@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -33,7 +33,7 @@ jobs:
timeout-minutes: 5

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install dependencies
uses: ./.github/actions/install-dependencies
Expand All @@ -48,7 +48,7 @@ jobs:
timeout-minutes: 5

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install dependencies
uses: ./.github/actions/install-dependencies
Expand All @@ -66,7 +66,7 @@ jobs:
ANVIL_BLOCK_NUMBER: 16966590

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install dependencies
uses: ./.github/actions/install-dependencies
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wagmi-dev/.github/main/content/logo-dark.svg">
<img alt="wagmi logo" src="https://raw.githubusercontent.com/wagmi-dev/.github/main/content/logo-light.svg" width="auto" height="60">
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/wagmi/main/.github/logo-dark.svg">
<img alt="wagmi logo" src="https://raw.githubusercontent.com/wevm/wagmi/main/.github/logo-light.svg" width="auto" height="60">
</picture>
</p>

Expand Down
1 change: 1 addition & 0 deletions docs/pages/cli/plugins/foundry.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default defineConfig({
'Components.sol/**',
'Script.sol/**',
'StdAssertions.sol/**',
'StdInvariant.sol/**',
'StdError.sol/**',
'StdCheats.sol/**',
'StdMath.sol/**',
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/core/actions/watchBlockNumber.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const unwatch = watchBlockNumber(
)
```

### listen (optional)
### listen

Listen to network for block number changes.

Expand Down
1 change: 0 additions & 1 deletion docs/pages/core/chains.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ const { chains, publicClient } = configureChains(
- `canto`
- `celo`
- `celoAlfajores`
- `celoCannoli`
- `classic`
- `chronos`
- `chronosTestnet`
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/core/connectors/walletConnect.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ the newly added chain.

#### metadata (optional)

Metadata for your app. [See more](https://docs.walletconnect.com/2.0/javascript/providers/ethereum#initialization)
Metadata for your app. [See more](https://docs.walletconnect.com/2.0/advanced/providers/ethereum#initialization)

```ts {6-11}
import { WalletConnectConnector } from '@wagmi/core/connectors/walletConnect'
Expand All @@ -133,7 +133,7 @@ const connector = new WalletConnectConnector({

#### showQrModal (optional)

Whether or not to show the QR Code Modal upon connection. [See more](https://docs.walletconnect.com/2.0/javascript/providers/ethereum#initialization). Defaults to `true`.
Whether or not to show the QR Code Modal upon connection. [See more](https://docs.walletconnect.com/2.0/advanced/providers/ethereum#initialization). Defaults to `true`.

```ts {6}
import { WalletConnectConnector } from '@wagmi/core/connectors/walletConnect'
Expand Down
23 changes: 1 addition & 22 deletions docs/pages/core/providers/alchemy.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,4 @@ const { chains, publicClient } = configureChains(
[mainnet],
[alchemyProvider({ apiKey: 'yourAlchemyApiKey' })],
)
```

### stallTimeout (optional)

The timeout in milliseconds after which another provider will be attempted.

```ts {10}
import { configureChains, mainnet } from '@wagmi/core'
import { alchemyProvider } from '@wagmi/core/providers/alchemy'
import { publicProvider } from '@wagmi/core/providers/public'

const { chains, publicClient } = configureChains(
[mainnet],
[
alchemyProvider({
apiKey: 'yourAlchemyApiKey',
stallTimeout: 1_000,
}),
publicProvider(),
],
)
```
```
2 changes: 1 addition & 1 deletion docs/pages/core/providers/configuring-chains.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ const { chains } = configureChains(
infuraProvider({ apiKey: 'yourInfuraApiKey' }),
publicProvider(),
],
{ retryCount: 5 },
{ retryDelay: 150 },
)
```

Expand Down
22 changes: 0 additions & 22 deletions docs/pages/core/providers/infura.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,3 @@ const { chains, publicClient } = configureChains(
[infuraProvider({ apiKey: 'yourInfuraApiKey' })],
)
```

### stallTimeout (optional)

The timeout in milliseconds after which another provider will be attempted.

```ts {11}
import { configureChains } from '@wagmi/core'
import { mainnet, polygon } from '@wagmi/core/chains'
import { infuraProvider } from '@wagmi/core/providers/infura'
import { publicProvider } from '@wagmi/core/providers/public'

const { chains, publicClient } = configureChains(
[mainnet, polygon],
[
infuraProvider({
apiKey: 'yourInfuraApiKey',
stallTimeout: 1_000,
}),
publicProvider(),
],
)
```
24 changes: 0 additions & 24 deletions docs/pages/core/providers/jsonRpc.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,3 @@ const { chains, publicClient } = configureChains(
],
)
```

### stallTimeout (optional)

The timeout in milliseconds after which another provider will be attempted.

```ts {13,15}
import { configureChains } from '@wagmi/core'
import { mainnet, polygon } from '@wagmi/core/chains'
import { jsonRpcProvider } from '@wagmi/core/providers/jsonRpc'

const { chains, publicClient } = configureChains(
[mainnet, polygon],
[
jsonRpcProvider({
rpc: (chain) => ({
http: `https://${chain.id}.example.com`,
webSocket: `wss://${chain.id}.example.com`,
}),
stallTimeout: 1000,
}),
alchemyProvider({ stallTimeout: 1000 }),
],
)
```
20 changes: 0 additions & 20 deletions docs/pages/core/providers/public.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,3 @@ Note: The above example is using chains from [`@wagmi/core/chains`](/core/chains
webSocketPublicClient: PublicClient
}
```

## Configuration

### stallTimeout (optional)

The timeout in milliseconds after which another provider will be attempted.

```ts {9}
import { configureChains } from '@wagmi/core'
import { mainnet, polygon } from '@wagmi/core/chains'
import { publicProvider } from '@wagmi/core/providers/public'

const { chains, publicClient } = configureChains(
[mainnet, polygon],
[
alchemyProvider({ apiKey: 'yourAlchemyApiKey' }),
publicProvider({ stallTimeout: 1_000 }),
],
)
```
2 changes: 1 addition & 1 deletion docs/pages/examples/connect-wallet.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ import {

export function Profile() {
const { address, connector, isConnected } = useAccount()
const { data: ensAvatar } = useEnsAvatar({ address })
const { data: ensName } = useEnsName({ address })
const { data: ensAvatar } = useEnsAvatar({ name: ensName })
const { connect, connectors, error, isLoading, pendingConnector } =
useConnect()
const { disconnect } = useDisconnect()
Expand Down
14 changes: 7 additions & 7 deletions docs/pages/examples/send-transaction.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export function SendTransaction() {
placeholder="0.05"
value={amount}
/>
<button>Send</button>
<button type="submit">Send</button>
</form>
)
}
Expand All @@ -129,7 +129,7 @@ We will need to:
import * as React from 'react'
import { useDebounce } from 'use-debounce'
import { usePrepareSendTransaction, useSendTransaction } from 'wagmi'
import { utils } from 'ethers'
import { parseEther } from 'viem'

export function SendTransaction() {
const [to, setTo] = React.useState('')
Expand All @@ -140,7 +140,7 @@ export function SendTransaction() {

const { config } = usePrepareSendTransaction({
to: debouncedTo,
value: debouncedAmount ? utils.parseEther(debouncedAmount) : undefined,
value: debouncedAmount ? parseEther(debouncedAmount) : undefined,
})
const { sendTransaction } = useSendTransaction(config)

Expand All @@ -163,7 +163,7 @@ export function SendTransaction() {
placeholder="0.05"
value={amount}
/>
<button disabled={!sendTransaction || !to || !amount}>Send</button>
<button type="submit" disabled={!sendTransaction || !to || !amount}>Send</button>
</form>
)
}
Expand Down Expand Up @@ -196,7 +196,7 @@ import {
useSendTransaction,
useWaitForTransaction,
} from 'wagmi'
import { utils } from 'ethers'
import { parseEther } from 'viem'

export function SendTransaction() {
const [to, setTo] = React.useState('')
Expand All @@ -207,7 +207,7 @@ export function SendTransaction() {

const { config } = usePrepareSendTransaction({
to: debouncedTo,
value: debouncedAmount ? utils.parseEther(debouncedAmount) : undefined,
value: debouncedAmount ? parseEther(debouncedAmount) : undefined,
})
const { data, sendTransaction } = useSendTransaction(config)

Expand All @@ -234,7 +234,7 @@ export function SendTransaction() {
placeholder="0.05"
value={amount}
/>
<button disabled={isLoading || !sendTransaction || !to || !amount}>
<button type="submit" disabled={isLoading || !sendTransaction || !to || !amount}>
{isLoading ? 'Sending...' : 'Send'}
</button>
{isSuccess && (
Expand Down
1 change: 0 additions & 1 deletion docs/pages/react/chains.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ const { chains, publicClient } = configureChains(
- `canto`
- `celo`
- `celoAlfajores`
- `celoCannoli`
- `classic`
- `chronos`
- `chronosTestnet`
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/react/connectors/injected.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const connector = new InjectedConnector()
<Callout type="info">
Injected wallets can set up custom name mappings in wagmi. You can [see the
full list and add to it
here](https://github.com/wagmi-dev/references/blob/main/packages/connectors/src/utils/getInjectedName.ts).
here](https://github.com/wagmi-dev/references/blob/0.x/packages/connectors/src/utils/getInjectedName.ts).
By default, "Injected" is the name for unmapped wallets.
</Callout>

Expand Down
Loading

1 comment on commit 68c18f9

@vercel
Copy link

@vercel vercel bot commented on 68c18f9 Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.