Skip to content

Commit e88edb2

Browse files
authored
feat: stabilize EIP-5792 (#3592)
* feat: stabilize eip5792 * Update three-socks-thank.md * chore: tweaks * chore: tweaks * chore: tweaks * chore: tweaks
1 parent 6aa70af commit e88edb2

33 files changed

+457
-181
lines changed

.changeset/three-socks-thank.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"viem": minor
3+
---
4+
5+
Stabilized EIP-5792 (moved out of experimental).

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
{
111111
"name": "import * from 'viem' (esm)",
112112
"path": "./src/_esm/index.js",
113-
"limit": "70 kB",
113+
"limit": "71 kB",
114114
"import": "*"
115115
},
116116
{
@@ -151,7 +151,7 @@
151151
{
152152
"name": "import * from 'viem/actions'",
153153
"path": "./src/_esm/actions/index.js",
154-
"limit": "55 kB",
154+
"limit": "56 kB",
155155
"import": "*"
156156
},
157157
{

site/pages/experimental/eip5792/getCallsStatus.mdx renamed to site/pages/docs/actions/wallet/getCallsStatus.mdx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ description: Returns the status of a call batch.
66

77
Returns the status of a call batch that was sent via `sendCalls`.
88

9-
[Read more.](https://eips.ethereum.org/EIPS/eip-5792#wallet_getcallsstatus)
10-
11-
:::warning[Warning]
12-
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.
13-
:::
9+
[Read more](https://eips.ethereum.org/EIPS/eip-5792#wallet_getcallsstatus)
1410

1511
## Usage
1612

@@ -37,12 +33,11 @@ import 'viem/window'
3733
// ---cut---
3834
import { createWalletClient, custom } from 'viem'
3935
import { mainnet } from 'viem/chains'
40-
import { eip5792Actions } from 'viem/experimental'
4136

4237
export const walletClient = createWalletClient({
4338
chain: mainnet,
4439
transport: custom(window.ethereum!),
45-
}).extend(eip5792Actions())
40+
})
4641

4742
export const [account] = await walletClient.getAddresses()
4843
```

site/pages/experimental/eip5792/getCapabilities.mdx renamed to site/pages/docs/actions/wallet/getCapabilities.mdx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ description: Extract capabilities that a connected wallet supports.
66

77
Extract capabilities (grouped by chain ID) that a connected wallet supports (e.g. paymasters, session keys, etc).
88

9-
[Read more.](https://github.com/ethereum/EIPs/blob/815028dc634463e1716fc5ce44c019a6040f0bef/EIPS/eip-5792.md#wallet_getcapabilities)
10-
11-
:::warning[Warning]
12-
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.
13-
:::
9+
[Read more](https://github.com/ethereum/EIPs/blob/815028dc634463e1716fc5ce44c019a6040f0bef/EIPS/eip-5792.md#wallet_getcapabilities)
1410

1511
## Usage
1612

@@ -44,12 +40,11 @@ import 'viem/window'
4440
// ---cut---
4541
import { createWalletClient, custom } from 'viem'
4642
import { mainnet } from 'viem/chains'
47-
import { eip5792Actions } from 'viem/experimental'
4843

4944
export const walletClient = createWalletClient({
5045
chain: mainnet,
5146
transport: custom(window.ethereum!),
52-
}).extend(eip5792Actions())
47+
})
5348

5449
export const [account] = await walletClient.getAddresses()
5550
```
@@ -73,7 +68,6 @@ const capabilities = await walletClient.getCapabilities()
7368
```ts [config.ts] filename="config.ts"
7469
import 'viem/window'
7570
import { createWalletClient, custom } from 'viem'
76-
import { eip5792Actions } from 'viem/experimental'
7771

7872
// Retrieve Account from an EIP-1193 Provider.
7973
const [account] = await window.ethereum!.request({
@@ -83,7 +77,7 @@ const [account] = await window.ethereum!.request({
8377
export const walletClient = createWalletClient({
8478
account,
8579
transport: custom(window.ethereum!)
86-
}).extend(eip5792Actions())
80+
})
8781
```
8882

8983
:::

site/pages/experimental/eip5792/sendCalls.mdx renamed to site/pages/docs/actions/wallet/sendCalls.mdx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ description: Sign and broadcast a batch of calls to the network.
66

77
Requests for the wallet to sign and broadcast a batch of calls to the network.
88

9-
[Read more.](https://eips.ethereum.org/EIPS/eip-5792#wallet_sendcalls)
10-
11-
:::warning[Warning]
12-
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.
13-
:::
9+
[Read more](https://eips.ethereum.org/EIPS/eip-5792#wallet_sendcalls)
1410

1511
## Usage
1612

@@ -40,12 +36,11 @@ import 'viem/window'
4036
// ---cut---
4137
import { createWalletClient, custom } from 'viem'
4238
import { mainnet } from 'viem/chains'
43-
import { eip5792Actions } from 'viem/experimental'
4439

4540
export const walletClient = createWalletClient({
4641
chain: mainnet,
4742
transport: custom(window.ethereum!),
48-
}).extend(eip5792Actions())
43+
})
4944

5045
export const [account] = await walletClient.getAddresses()
5146
```
@@ -86,7 +81,6 @@ const { id } = await walletClient.sendCalls({ // [!code focus:99]
8681
```ts [config.ts] filename="config.ts"
8782
import 'viem/window'
8883
import { createWalletClient, custom } from 'viem'
89-
import { eip5792Actions } from 'viem/experimental'
9084

9185
// Retrieve Account from an EIP-1193 Provider.
9286
const [account] = await window.ethereum!.request({
@@ -96,7 +90,7 @@ const [account] = await window.ethereum!.request({
9690
export const walletClient = createWalletClient({
9791
account,
9892
transport: custom(window.ethereum!)
99-
}).extend(eip5792Actions())
93+
})
10094
```
10195

10296
:::
@@ -162,7 +156,6 @@ export const wagmiAbi = [
162156
```ts [config.ts] filename="config.ts"
163157
import 'viem/window'
164158
import { createWalletClient, custom } from 'viem'
165-
import { eip5792Actions } from 'viem/experimental'
166159

167160
// Retrieve Account from an EIP-1193 Provider.
168161
const [account] = await window.ethereum!.request({
@@ -172,7 +165,7 @@ const [account] = await window.ethereum!.request({
172165
export const walletClient = createWalletClient({
173166
account,
174167
transport: custom(window.ethereum!)
175-
}).extend(eip5792Actions())
168+
})
176169
```
177170

178171
:::

site/pages/experimental/eip5792/showCallsStatus.mdx renamed to site/pages/docs/actions/wallet/showCallsStatus.mdx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ Requests for the wallet to show information about a call batch that was sent via
88

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

11-
:::warning[Warning]
12-
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.
13-
:::
14-
1511
## Usage
1612

1713
:::code-group
@@ -29,12 +25,11 @@ import 'viem/window'
2925
// ---cut---
3026
import { createWalletClient, custom } from 'viem'
3127
import { mainnet } from 'viem/chains'
32-
import { eip5792Actions } from 'viem/experimental'
3328

3429
export const walletClient = createWalletClient({
3530
chain: mainnet,
3631
transport: custom(window.ethereum!),
37-
}).extend(eip5792Actions())
32+
})
3833

3934
export const [account] = await walletClient.getAddresses()
4035
```

site/pages/experimental/eip5792/waitForCallsStatus.mdx renamed to site/pages/docs/actions/wallet/waitForCallsStatus.mdx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ description: Waits for a call batch to be confirmed & included on a Block.
66

77
Waits for a call batch to be confirmed & included on a [Block](/docs/glossary/terms#block) before returning the status & receipts.
88

9-
:::warning[Warning]
10-
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.
11-
:::
12-
139
## Usage
1410

1511
:::code-group
@@ -44,12 +40,11 @@ import 'viem/window'
4440
// ---cut---
4541
import { createWalletClient, custom } from 'viem'
4642
import { mainnet } from 'viem/chains'
47-
import { eip5792Actions } from 'viem/experimental'
4843

4944
export const walletClient = createWalletClient({
5045
chain: mainnet,
5146
transport: custom(window.ethereum!),
52-
}).extend(eip5792Actions())
47+
})
5348

5449
export const [account] = await walletClient.getAddresses()
5550
```

site/pages/experimental/eip5792/client.mdx

Lines changed: 0 additions & 16 deletions
This file was deleted.

site/vercel.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@
6767
{
6868
"source": "/docs/eip7702/:path*",
6969
"destination": "/docs/eip7702/:path*"
70+
},
71+
{
72+
"source": "/:match/experimental/eip5792/:path*",
73+
"destination": "/:match/docs/actions/wallet/:path*"
7074
}
7175
]
7276
}

src/actions/index.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ test('exports actions', () => {
3535
"getBlockNumber": [Function],
3636
"getBlockTransactionCount": [Function],
3737
"getBytecode": [Function],
38+
"getCallsStatus": [Function],
39+
"getCapabilities": [Function],
3840
"getChainId": [Function],
3941
"getCode": [Function],
4042
"getContractEvents": [Function],
@@ -72,6 +74,7 @@ test('exports actions', () => {
7274
"requestPermissions": [Function],
7375
"reset": [Function],
7476
"revert": [Function],
77+
"sendCalls": [Function],
7578
"sendRawTransaction": [Function],
7679
"sendTransaction": [Function],
7780
"sendUnsignedTransaction": [Function],
@@ -89,6 +92,7 @@ test('exports actions', () => {
8992
"setNonce": [Function],
9093
"setRpcUrl": [Function],
9194
"setStorageAt": [Function],
95+
"showCallsStatus": [Function],
9296
"signAuthorization": [Function],
9397
"signMessage": [Function],
9498
"signTransaction": [Function],
@@ -104,6 +108,7 @@ test('exports actions', () => {
104108
"verifyHash": [Function],
105109
"verifyMessage": [Function],
106110
"verifyTypedData": [Function],
111+
"waitForCallsStatus": [Function],
107112
"waitForTransactionReceipt": [Function],
108113
"watchAsset": [Function],
109114
"watchBlockNumber": [Function],

src/actions/index.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,37 @@ export {
316316
type GetPermissionsReturnType,
317317
getPermissions,
318318
} from './wallet/getPermissions.js'
319+
export {
320+
type GetCapabilitiesParameters,
321+
type GetCapabilitiesErrorType,
322+
type GetCapabilitiesReturnType,
323+
getCapabilities,
324+
} from './wallet/getCapabilities.js'
325+
export {
326+
type SendCallsErrorType,
327+
type SendCallsParameters,
328+
type SendCallsReturnType,
329+
sendCalls,
330+
} from './wallet/sendCalls.js'
331+
export {
332+
type GetCallsStatusErrorType,
333+
type GetCallsStatusParameters,
334+
type GetCallsStatusReturnType,
335+
getCallsStatus,
336+
} from './wallet/getCallsStatus.js'
337+
export {
338+
type ShowCallsStatusErrorType,
339+
type ShowCallsStatusParameters,
340+
type ShowCallsStatusReturnType,
341+
showCallsStatus,
342+
} from './wallet/showCallsStatus.js'
343+
export {
344+
type WaitForCallsStatusErrorType,
345+
type WaitForCallsStatusParameters,
346+
type WaitForCallsStatusReturnType,
347+
type WaitForCallsStatusTimeoutErrorType,
348+
waitForCallsStatus,
349+
} from './wallet/waitForCallsStatus.js'
319350
export {
320351
type GetProofErrorType,
321352
type GetProofParameters,

src/experimental/eip5792/actions/getCallsStatus.test.ts renamed to src/actions/wallet/getCallsStatus.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { expect, test } from 'vitest'
2-
import { anvilMainnet } from '../../../../test/src/anvil.js'
3-
import { accounts } from '../../../../test/src/constants.js'
4-
import { mine } from '../../../actions/index.js'
5-
import { mainnet } from '../../../chains/index.js'
6-
import { createClient } from '../../../clients/createClient.js'
7-
import { custom } from '../../../clients/transports/custom.js'
8-
import { RpcRequestError } from '../../../errors/request.js'
2+
import { anvilMainnet } from '../../../test/src/anvil.js'
3+
import { accounts } from '../../../test/src/constants.js'
4+
import { mainnet } from '../../chains/index.js'
5+
import { createClient } from '../../clients/createClient.js'
6+
import { custom } from '../../clients/transports/custom.js'
7+
import { RpcRequestError } from '../../errors/request.js'
98
import type {
109
WalletCallReceipt,
1110
WalletGetCallsStatusReturnType,
12-
} from '../../../types/eip1193.js'
13-
import type { Hex } from '../../../types/misc.js'
14-
import { getHttpRpcClient, parseEther } from '../../../utils/index.js'
15-
import { uid } from '../../../utils/uid.js'
11+
} from '../../types/eip1193.js'
12+
import type { Hex } from '../../types/misc.js'
13+
import { getHttpRpcClient, parseEther } from '../../utils/index.js'
14+
import { uid } from '../../utils/uid.js'
15+
import { mine } from '../index.js'
1616
import { getCallsStatus } from './getCallsStatus.js'
1717
import { sendCalls } from './sendCalls.js'
1818

src/experimental/eip5792/actions/getCallsStatus.ts renamed to src/actions/wallet/getCallsStatus.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import type { Client } from '../../../clients/createClient.js'
2-
import type { Transport } from '../../../clients/transports/createTransport.js'
3-
import type { ErrorType } from '../../../errors/utils.js'
4-
import type { Account } from '../../../types/account.js'
5-
import type { Chain } from '../../../types/chain.js'
1+
import type { Client } from '../../clients/createClient.js'
2+
import type { Transport } from '../../clients/transports/createTransport.js'
3+
import type { ErrorType } from '../../errors/utils.js'
4+
import type { Account } from '../../types/account.js'
5+
import type { Chain } from '../../types/chain.js'
66
import type {
77
WalletCapabilities,
88
WalletGetCallsStatusReturnType,
9-
} from '../../../types/eip1193.js'
10-
import type { Prettify } from '../../../types/utils.js'
11-
import type { RequestErrorType } from '../../../utils/buildRequest.js'
12-
import { hexToBigInt, hexToNumber } from '../../../utils/encoding/fromHex.js'
13-
import { receiptStatuses } from '../../../utils/formatters/transactionReceipt.js'
9+
} from '../../types/eip1193.js'
10+
import type { Prettify } from '../../types/utils.js'
11+
import type { RequestErrorType } from '../../utils/buildRequest.js'
12+
import { hexToBigInt, hexToNumber } from '../../utils/encoding/fromHex.js'
13+
import { receiptStatuses } from '../../utils/formatters/transactionReceipt.js'
1414

1515
export type GetCallsStatusParameters = { id: string }
1616

@@ -34,7 +34,7 @@ export type GetCallsStatusErrorType = RequestErrorType | ErrorType
3434
/**
3535
* Returns the status of a call batch that was sent via `sendCalls`.
3636
*
37-
* - Docs: https://viem.sh/experimental/eip5792/getCallsStatus
37+
* - Docs: https://viem.sh/docs/actions/wallet/getCallsStatus
3838
* - JSON-RPC Methods: [`wallet_getCallsStatus`](https://eips.ethereum.org/EIPS/eip-5792)
3939
*
4040
* @param client - Client to use
@@ -43,7 +43,7 @@ export type GetCallsStatusErrorType = RequestErrorType | ErrorType
4343
* @example
4444
* import { createWalletClient, custom } from 'viem'
4545
* import { mainnet } from 'viem/chains'
46-
* import { getCallsStatus } from 'viem/experimental'
46+
* import { getCallsStatus } from 'viem/actions'
4747
*
4848
* const client = createWalletClient({
4949
* chain: mainnet,

src/experimental/eip5792/actions/getCapabilities.test.ts renamed to src/actions/wallet/getCapabilities.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { expect, test } from 'vitest'
22

3-
import { accounts } from '../../../../test/src/constants.js'
4-
import type { JsonRpcAccount } from '../../../accounts/types.js'
5-
import { type Client, createClient } from '../../../clients/createClient.js'
6-
import type { Transport } from '../../../clients/transports/createTransport.js'
7-
import { custom } from '../../../clients/transports/custom.js'
8-
import type { Chain } from '../../../types/chain.js'
3+
import { accounts } from '../../../test/src/constants.js'
4+
import type { JsonRpcAccount } from '../../accounts/types.js'
5+
import { type Client, createClient } from '../../clients/createClient.js'
6+
import type { Transport } from '../../clients/transports/createTransport.js'
7+
import { custom } from '../../clients/transports/custom.js'
8+
import type { Chain } from '../../types/chain.js'
99
import { getCapabilities } from './getCapabilities.js'
1010

1111
const client = createClient({

0 commit comments

Comments
 (0)