Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: Experimental EIP-5792 Actions #3878

Merged
merged 13 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/nine-colts-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"wagmi": minor
"@wagmi/core": minor
---

Added experimental EIP-5792 Actions & Hooks.
2 changes: 1 addition & 1 deletion .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
strategy:
matrix:
typescript-version: ['5.0.4', '5.1.6', '5.2.2', 'latest']
viem-version: ['2.8.4', 'latest']
viem-version: ['2.9.31', 'latest']

steps:
- name: Clone repository
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ packages/cli/plugins
packages/core/actions
packages/core/chains
packages/core/codegen
packages/core/experimental
packages/core/internal
packages/core/query
packages/react/actions
packages/react/chains
packages/react/codegen
packages/react/connectors
packages/react/experimental
packages/react/query
50 changes: 50 additions & 0 deletions docs/.vitepress/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,31 @@ export function getSidebar() {
},
],
},
{
text: 'Experimental',
items: [
{
text: 'useCallsStatus',
link: '/react/api/hooks/useCallsStatus',
},
{
text: 'useCapabilities',
link: '/react/api/hooks/useCapabilities',
},
{
text: 'useSendCalls',
link: '/react/api/hooks/useSendCalls',
},
{
text: 'useShowCallsStatus',
link: '/react/api/hooks/useShowCallsStatus',
},
{
text: 'useWriteContracts',
link: '/react/api/hooks/useWriteContracts',
},
],
},
],
'/core': [
{
Expand Down Expand Up @@ -687,6 +712,31 @@ export function getSidebar() {
},
],
},
{
text: 'Experimental',
items: [
{
text: 'getCallsStatus',
link: '/core/api/actions/getCallsStatus',
},
{
text: 'getCapabilities',
link: '/core/api/actions/getCapabilities',
},
{
text: 'sendCalls',
link: '/core/api/actions/sendCalls',
},
{
text: 'showCallsStatus',
link: '/core/api/actions/showCallsStatus',
},
{
text: 'writeContracts',
link: '/core/api/actions/writeContracts',
},
],
},
],
'/cli': [
{
Expand Down
101 changes: 101 additions & 0 deletions docs/core/api/actions/getCallsStatus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<script setup>
const packageName = '@wagmi/core/experimental'
const actionName = 'getCallsStatus'
const typeName = 'GetCallsStatus'
</script>

# getCallsStatus

Action to fetch the status and receipts of a call batch that was sent via [`sendCalls`](/core/api/actions/sendCalls).

[Read more.](https://github.com/ethereum/EIPs/blob/1663ea2e7a683285f977eda51c32cec86553f585/EIPS/eip-5792.md#wallet_getcallsstatus)

::: warning
This is an experimental action that is not supported in most wallets. It is recommended to have a fallback mechanism if using this in production.
:::

## Import

```ts
import { getCallsStatus } from '@wagmi/core/experimental'
```

## Usage

::: code-group
```ts [index.ts]
import { getCallsStatus } from '@wagmi/core/experimental'
import { config } from './config'

const status = await getCallsStatus(config, {
id: '0x1234567890abcdef',
})
```
<<< @/snippets/core/config.ts[config.ts]
:::

## Parameters

```ts
import { type GetCallsStatusParameters } from '@wagmi/core/experimental'
```

### connector

`Connector | undefined`

Connector to get call statuses with.

::: code-group
```ts [index.ts]
import { getConnections, getCallsStatus } from '@wagmi/core/experimental'
import { config } from './config'

const connections = getConnections(config)
const status = await getCallsStatus(config, {
connector: connections[0]?.connector, // [!code focus]
id: '0x1234567890abcdef',
})
```
<<< @/snippets/core/config.ts[config.ts]
:::

### id

`string`

Identifier of the call batch.

::: code-group
```ts [index.ts]
import { getCallsStatus } from '@wagmi/core/experimental'
import { config } from './config'

const status = await getCallsStatus(config, {
id: '0x1234567890abcdef', // [!code focus]
})
```
<<< @/snippets/core/config.ts[config.ts]
:::

## Return Type

```ts
import { type GetCallsStatusReturnType } from '@wagmi/core/experimental'
```

`bigint`

Most recent block number seen.

## Error

```ts
import { type GetCallsStatusErrorType } from '@wagmi/core/experimental'
```

<!--@include: @shared/query-imports.md-->

## Viem

- [`getCallsStatus`](https://viem.sh/experimental/eip5792/getCallsStatus)
98 changes: 98 additions & 0 deletions docs/core/api/actions/getCapabilities.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<script setup>
const packageName = '@wagmi/core/experimental'
const actionName = 'getCapabilities'
const typeName = 'GetCapabilities'
</script>

# getCapabilities

Action to extract capabilities (grouped by chain ID) that a connected wallet supports (e.g. paymasters, session keys, etc).

[Read more.](https://github.com/ethereum/EIPs/blob/815028dc634463e1716fc5ce44c019a6040f0bef/EIPS/eip-5792.md#wallet_getcapabilities)

::: warning
This is an experimental action that is not supported in most wallets. It is recommended to have a fallback mechanism if using this in production.
:::

## Import

```ts
import { getCapabilities } from '@wagmi/core/experimental'
```

## Usage

::: code-group
```ts [index.ts]
import { getCapabilities } from '@wagmi/core/experimental'
import { config } from './config'

const capabilities = await getCapabilities(config)
```
<<< @/snippets/core/config.ts[config.ts]
:::

## Parameters

```ts
import { type GetCapabilitiesParameters } from '@wagmi/core/experimental'
```

### account

`Account | Address | undefined`

Fetch capabilities for the provided account.

::: code-group
```ts [index.ts]
import { getCapabilities } from '@wagmi/core/experimental'
import { config } from './config'

const capabilities = await getCapabilities(config, {
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', // [!code focus]
})
```
<<< @/snippets/core/config.ts[config.ts]
:::

### connector

`Connector | undefined`

Connector to get capabilities from.

::: code-group
```ts [index.ts]
import { getConnections, getCapabilities } from '@wagmi/core/experimental'
import { config } from './config'

const connections = getConnections(config)
const capabilities = await getCapabilities(config, {
connector: connections[0]?.connector, // [!code focus]
})
```
<<< @/snippets/core/config.ts[config.ts]
:::

## Return Type

```ts
import { type GetCapabilitiesReturnType } from '@wagmi/core/experimental'
```

`bigint`

Most recent block number seen.

## Error

```ts
import { type GetCapabilitiesErrorType } from '@wagmi/core/experimental'
```

<!--@include: @shared/query-imports.md-->

## Viem

- [`getCapabilities`](https://viem.sh/experimental/eip5792/getCapabilities)
Loading
Loading