Skip to content

Commit

Permalink
docs: plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Oct 12, 2023
1 parent 0c38c47 commit 4e0e306
Show file tree
Hide file tree
Showing 7 changed files with 542 additions and 7 deletions.
6 changes: 3 additions & 3 deletions docs/.vitepress/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,10 +531,10 @@ export function getSidebar() {
{ text: 'blockExplorer', link: '/cli/api/plugins/blockExplorer' },
{ text: 'etherscan', link: '/cli/api/plugins/etherscan' },
{ text: 'fetch', link: '/cli/api/plugins/fetch' },
{ text: 'foundry 🚧', link: '/cli/api/plugins/foundry' },
{ text: 'hardhat 🚧', link: '/cli/api/plugins/hardhat' },
{ text: 'foundry', link: '/cli/api/plugins/foundry' },
{ text: 'hardhat', link: '/cli/api/plugins/hardhat' },
{ text: 'react 🚧', link: '/cli/api/plugins/react' },
{ text: 'sourcify 🚧', link: '/cli/api/plugins/sourcify' },
{ text: 'sourcify', link: '/cli/api/plugins/sourcify' },
],
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/cli/api/plugins/blockExplorer.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default defineConfig({

### cacheDuration

`number`
`number | undefined`

Duration in milliseconds to cache ABIs. Defaults to `1_800_000` (30 minutes).

Expand Down
8 changes: 6 additions & 2 deletions docs/cli/api/plugins/etherscan.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default defineConfig({
plugins: [
etherscan({
apiKey: process.env.ETHERSCAN_API_KEY,
chainId: 1,
contracts: [
{
name: 'Wagmigotchi',
Expand Down Expand Up @@ -60,6 +61,7 @@ export default defineConfig({
plugins: [
etherscan({
apiKey: process.env.ETHERSCAN_API_KEY, // [!code focus]
chainId: 1,
contracts: [
{
name: 'Wagmigotchi',
Expand All @@ -73,7 +75,7 @@ export default defineConfig({

### cacheDuration

`number`
`number | undefined`

- Duration in milliseconds to cache ABIs.
- Defaults to `1_800_000` (30 minutes).
Expand All @@ -87,6 +89,7 @@ export default defineConfig({
etherscan({
apiKey: process.env.ETHERSCAN_API_KEY,
cacheDuration: 300_000, // [!code focus]
chainId: 1,
contracts: [
{
name: 'Wagmigotchi',
Expand All @@ -102,7 +105,7 @@ export default defineConfig({

`number`

Chain id to use for fetching ABI. If [`address`](/cli/config/options#address) is an object, `chainId` is used to select the address.
Chain ID to use for fetching ABI. If [`address`](/cli/config/options#address) is an object, `chainId` is used to select the address.

```ts
import { defineConfig } from '@wagmi/cli'
Expand Down Expand Up @@ -145,6 +148,7 @@ export default defineConfig({
plugins: [
etherscan({
apiKey: process.env.ETHERSCAN_API_KEY,
chainId: 1,
contracts: [ // [!code focus]
{ // [!code focus]
name: 'Wagmigotchi', // [!code focus]
Expand Down
2 changes: 1 addition & 1 deletion docs/cli/api/plugins/fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { type FetchConfig } from '@wagmi/cli/plugins'

### cacheDuration

`number`
`number | undefined`

- Duration in milliseconds to cache ABIs.
- Defaults to `1_800_000` (30 minutes).
Expand Down
217 changes: 217 additions & 0 deletions docs/cli/api/plugins/foundry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
# foundry

Plugin for resolving ABIs from [Foundry](https://github.com/foundry-rs/foundry) projects. Supports [`watch`](/cli/api/commands/generate#w-watch) mode.

## Import

```ts
import { foundry } from '@wagmi/cli/plugins'
```

## Usage

```ts{2,6-8}
import { defineConfig } from '@wagmi/cli'
import { foundry } from '@wagmi/cli/plugins'
export default defineConfig({
plugins: [
foundry({
project: '../hello_foundry',
}),
],
})
```

## Configuration

```ts
import { type FoundryConfig } from '@wagmi/cli/plugins'
```

### artifacts

`string | undefined`

- Project's artifacts directory. Same as your `foundry.toml`/`forge`s `--out` (`-o`) option.
- Defaults to `'out/'`.

```ts
import { defineConfig } from '@wagmi/cli'
import { foundry } from '@wagmi/cli/plugins'

export default defineConfig({
plugins: [
foundry({
artifacts: 'out/', // [!code focus]
}),
],
})
```

### deployments

`{ [key: string]: address?: Address | Record<chainId, Address> | undefined } | undefined`

Mapping of addresses to attach to artifacts.

```ts
import { defineConfig } from '@wagmi/cli'
import { foundry } from '@wagmi/cli/plugins'

export default defineConfig({
plugins: [
foundry({
deployments: { // [!code focus]
Counter: { // [!code focus]
1: '0x314159265dd8dbb310642f98f50c066173c1259b', // [!code focus]
5: '0x112234455c3a32fd11230c42e7bccd4a84e02010', // [!code focus]
}, // [!code focus]
}, // [!code focus]
}),
],
})
```

### exclude

`string[] | undefined`

Artifact files to exclude relative to `artifacts`. Supports glob patterns.

```ts
import { defineConfig } from '@wagmi/cli'
import { foundry } from '@wagmi/cli/plugins'

export default defineConfig({
plugins: [
foundry({
exclude: [ // [!code focus]
// the following patterns are excluded by default // [!code focus]
'Common.sol/**', // [!code focus]
'Components.sol/**', // [!code focus]
'Script.sol/**', // [!code focus]
'StdAssertions.sol/**', // [!code focus]
'StdInvariant.sol/**', // [!code focus]
'StdError.sol/**', // [!code focus]
'StdCheats.sol/**', // [!code focus]
'StdMath.sol/**', // [!code focus]
'StdJson.sol/**', // [!code focus]
'StdStorage.sol/**', // [!code focus]
'StdUtils.sol/**', // [!code focus]
'Vm.sol/**', // [!code focus]
'console.sol/**', // [!code focus]
'console2.sol/**', // [!code focus]
'test.sol/**', // [!code focus]
'**.s.sol/*.json', // [!code focus]
'**.t.sol/*.json', // [!code focus]
], // [!code focus]
}),
],
})
```

### forge

`{ clean?: boolean | undefined; build?: boolean | undefined; path?: string | undefined; rebuild?: boolean | undefined } | undefined`

Options for `forge`.

```ts
import { defineConfig } from '@wagmi/cli'
import { foundry } from '@wagmi/cli/plugins'

export default defineConfig({
plugins: [
foundry({
forge: { // [!code focus]
clean: true, // [!code focus]
build: true, // [!code focus]
path: 'path/to/forge', // [!code focus]
rebuild: true, // [!code focus]
}, // [!code focus]
}),
],
})
```

#### clean

- Remove build artifacts and cache directories on start up.
- Defaults to `false`.

#### build

- Build Foundry project before fetching artifacts.
- Defaults to `true`.

#### path

- Path to `forge` executable command.
- Defaults to `forge`.

#### rebuild

- Rebuild every time a watched file or directory is changed. Used for setting up [`watch`](/cli/api/commands/generate#w-watch) mode.
- Defaults to `true`.

### include

`string[] | undefined`

Artifact files to include relative to `artifacts`. Supports glob patterns.

```ts
import { defineConfig } from '@wagmi/cli'
import { foundry } from '@wagmi/cli/plugins'

export default defineConfig({
plugins: [
foundry({
include: [ // [!code focus]
// the following patterns are included by default // [!code focus]
'*.json', // [!code focus]
], // [!code focus]
}),
],
})
```

### namePrefix

`string | undefined`

Prefix to prepend to artifact names. Useful for preventing name collisions between contracts from other sources.

```ts
import { defineConfig } from '@wagmi/cli'
import { foundry } from '@wagmi/cli/plugins'

export default defineConfig({
plugins: [
foundry({ // [!code focus]
namePrefix: 'HelloFoundry', // [!code focus]
}), // [!code focus]
],
})
```

### project

`string | undefined`

- Path to Foundry project.
- Defaults to Foundry configuration using `forge config --json` command.

```ts
import { defineConfig } from '@wagmi/cli'
import { foundry } from '@wagmi/cli/plugins'

export default defineConfig({
plugins: [
foundry({ // [!code focus]
project: '../hello_foundry', // [!code focus]
}), // [!code focus]
],
})
```
Loading

1 comment on commit 4e0e306

@vercel
Copy link

@vercel vercel bot commented on 4e0e306 Oct 12, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

wagmi-v2 – ./docs

wagmi-v2.vercel.app
wagmi-v2-wagmi-dev.vercel.app
alpha.wagmi.sh
wagmi-v2-git-alpha-wagmi-dev.vercel.app

Please sign in to comment.