viem 2.33.3 → 2.33.4-canary-20250807091217

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/_cjs/chains/index.js.map +1 -1
  3. package/_cjs/errors/version.js +1 -1
  4. package/_cjs/errors/version.js.map +1 -1
  5. package/_cjs/experimental/erc7811/actions/getAssets.js +89 -0
  6. package/_cjs/experimental/erc7811/actions/getAssets.js.map +1 -0
  7. package/_cjs/experimental/erc7811/decorators/erc7811.js +12 -0
  8. package/_cjs/experimental/erc7811/decorators/erc7811.js.map +1 -0
  9. package/_cjs/experimental/erc7811/index.js +8 -0
  10. package/_cjs/experimental/erc7811/index.js.map +1 -0
  11. package/_cjs/experimental/index.js +3 -1
  12. package/_cjs/experimental/index.js.map +1 -1
  13. package/_cjs/index.js.map +1 -1
  14. package/_esm/chains/index.js +2 -0
  15. package/_esm/chains/index.js.map +1 -1
  16. package/_esm/errors/version.js +1 -1
  17. package/_esm/errors/version.js.map +1 -1
  18. package/_esm/experimental/erc7811/actions/getAssets.js +109 -0
  19. package/_esm/experimental/erc7811/actions/getAssets.js.map +1 -0
  20. package/_esm/experimental/erc7811/decorators/erc7811.js +27 -0
  21. package/_esm/experimental/erc7811/decorators/erc7811.js.map +1 -0
  22. package/_esm/experimental/erc7811/index.js +4 -0
  23. package/_esm/experimental/erc7811/index.js.map +1 -0
  24. package/_esm/experimental/index.js +1 -0
  25. package/_esm/experimental/index.js.map +1 -1
  26. package/_esm/index.js.map +1 -1
  27. package/_types/chains/index.d.ts +2 -0
  28. package/_types/chains/index.d.ts.map +1 -1
  29. package/_types/errors/version.d.ts +1 -1
  30. package/_types/errors/version.d.ts.map +1 -1
  31. package/_types/experimental/erc7811/actions/getAssets.d.ts +106 -0
  32. package/_types/experimental/erc7811/actions/getAssets.d.ts.map +1 -0
  33. package/_types/experimental/erc7811/decorators/erc7811.d.ts +50 -0
  34. package/_types/experimental/erc7811/decorators/erc7811.d.ts.map +1 -0
  35. package/_types/experimental/erc7811/index.d.ts +3 -0
  36. package/_types/experimental/erc7811/index.d.ts.map +1 -0
  37. package/_types/experimental/index.d.ts +1 -0
  38. package/_types/experimental/index.d.ts.map +1 -1
  39. package/_types/index.d.ts +1 -1
  40. package/_types/index.d.ts.map +1 -1
  41. package/_types/types/eip1193.d.ts +31 -0
  42. package/_types/types/eip1193.d.ts.map +1 -1
  43. package/chains/index.ts +2 -0
  44. package/errors/version.ts +1 -1
  45. package/experimental/erc7811/actions/getAssets.ts +249 -0
  46. package/experimental/erc7811/decorators/erc7811.ts +80 -0
  47. package/experimental/erc7811/index.ts +9 -0
  48. package/experimental/erc7811/package.json +6 -0
  49. package/experimental/index.ts +5 -0
  50. package/index.ts +2 -0
  51. package/package.json +6 -1
  52. package/types/eip1193.ts +37 -0
@@ -0,0 +1,80 @@
1
+ import type { Client } from '../../../clients/createClient.js'
2
+ import type { Transport } from '../../../clients/transports/createTransport.js'
3
+ import type { Account } from '../../../types/account.js'
4
+ import type { Chain } from '../../../types/chain.js'
5
+ import {
6
+ type Asset,
7
+ type GetAssetsParameters,
8
+ type GetAssetsReturnType,
9
+ getAssets,
10
+ } from '../actions/getAssets.js'
11
+
12
+ export type Erc7811Actions<
13
+ account extends Account | undefined = Account | undefined,
14
+ > = {
15
+ /**
16
+ * Requests to get assets for an account from a wallet.
17
+ *
18
+ * - Docs: https://viem.sh/experimental/erc7811/getAssets
19
+ *
20
+ * @param client - Client to use
21
+ * @param parameters - {@link GetAssetsParameters}
22
+ * @returns List of assets for the given account {@link GetAssetsReturnType}
23
+ *
24
+ * @example
25
+ * import { createWalletClient, custom } from 'viem'
26
+ * import { mainnet } from 'viem/chains'
27
+ * import { erc7811Actions } from 'viem/experimental/erc7811'
28
+ *
29
+ * const client = createWalletClient({
30
+ * chain: mainnet,
31
+ * transport: custom(window.ethereum),
32
+ * }).extend(erc7811Actions())
33
+ *
34
+ * const response = await client.getAssets({
35
+ * account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
36
+ * })
37
+ */
38
+ getAssets: <
39
+ aggregate extends
40
+ | boolean
41
+ | ((asset: Asset) => string)
42
+ | undefined = undefined,
43
+ >(
44
+ ...[parameters]: account extends Account
45
+ ? [GetAssetsParameters<aggregate, account>] | []
46
+ : [GetAssetsParameters<aggregate, account>]
47
+ ) => Promise<GetAssetsReturnType<aggregate>>
48
+ }
49
+
50
+ /**
51
+ * A suite of ERC-7811 Wallet Actions.
52
+ *
53
+ * @example
54
+ * import { createPublicClient, createWalletClient, http } from 'viem'
55
+ * import { mainnet } from 'viem/chains'
56
+ * import { erc7811Actions } from 'viem/experimental/erc7811'
57
+ *
58
+ * const client = createWalletClient({
59
+ * chain: mainnet,
60
+ * transport: http(),
61
+ * }).extend(erc7811Actions())
62
+ *
63
+ * const response = await client.getAssets({
64
+ * account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
65
+ * })
66
+ */
67
+ export function erc7811Actions() {
68
+ return <
69
+ transport extends Transport,
70
+ chain extends Chain | undefined = Chain | undefined,
71
+ account extends Account | undefined = Account | undefined,
72
+ >(
73
+ client: Client<transport, chain, account>,
74
+ ): Erc7811Actions<account> => {
75
+ return {
76
+ // @ts-expect-error
77
+ getAssets: (...[parameters]) => getAssets(client, parameters),
78
+ }
79
+ }
80
+ }
@@ -0,0 +1,9 @@
1
+ // biome-ignore lint/performance/noBarrelFile: entrypoint
2
+ export {
3
+ type GetAssetsErrorType,
4
+ type GetAssetsParameters,
5
+ type GetAssetsReturnType,
6
+ getAssets,
7
+ } from './actions/getAssets.js'
8
+
9
+ export { type Erc7811Actions, erc7811Actions } from './decorators/erc7811.js'
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "types": "../../_types/experimental/erc7811/index.d.ts",
4
+ "module": "../../_esm/experimental/erc7811/index.js",
5
+ "main": "../../_cjs/experimental/erc7811/index.js"
6
+ }
@@ -181,6 +181,11 @@ export {
181
181
  erc7846Actions,
182
182
  } from './erc7846/decorators/erc7846.js'
183
183
 
184
+ export {
185
+ type Erc7811Actions,
186
+ erc7811Actions,
187
+ } from './erc7811/decorators/erc7811.js'
188
+
184
189
  export {
185
190
  type Erc7895Actions,
186
191
  erc7895Actions,
package/index.ts CHANGED
@@ -1156,6 +1156,8 @@ export type {
1156
1156
  RpcSchema,
1157
1157
  RpcSchemaOverride,
1158
1158
  TestRpcSchema,
1159
+ WalletGetAssetsParameters,
1160
+ WalletGetAssetsReturnType,
1159
1161
  WalletCallReceipt,
1160
1162
  WalletGetCallsStatusReturnType,
1161
1163
  WalletGrantPermissionsParameters,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.33.3",
4
+ "version": "2.33.4-canary-20250807091217",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
@@ -74,6 +74,11 @@
74
74
  "import": "./_esm/experimental/erc7821/index.js",
75
75
  "default": "./_cjs/experimental/erc7821/index.js"
76
76
  },
77
+ "./experimental/erc7811": {
78
+ "types": "./_types/experimental/erc7811/index.d.ts",
79
+ "import": "./_esm/experimental/erc7811/index.js",
80
+ "default": "./_cjs/experimental/erc7811/index.js"
81
+ },
77
82
  "./experimental/erc7846": {
78
83
  "types": "./_types/experimental/erc7846/index.d.ts",
79
84
  "import": "./_esm/experimental/erc7846/index.js",
package/types/eip1193.ts CHANGED
@@ -176,6 +176,31 @@ export type WalletGrantPermissionsReturnType = {
176
176
  | undefined
177
177
  }
178
178
 
179
+ export type WalletGetAssetsParameters = {
180
+ account: Address
181
+ assetFilter?:
182
+ | {
183
+ [chainId: Hex]: readonly {
184
+ address: Address
185
+ type: 'native' | 'erc20' | 'erc721' | (string & {})
186
+ }[]
187
+ }
188
+ | undefined
189
+ assetTypeFilter?:
190
+ | readonly ('native' | 'erc20' | 'erc721' | (string & {}))[]
191
+ | undefined
192
+ chainFilter?: readonly Hex[] | undefined
193
+ }
194
+
195
+ export type WalletGetAssetsReturnType = {
196
+ [chainId: Hex]: readonly {
197
+ address: Address | 'native'
198
+ balance: Hex
199
+ metadata?: unknown | undefined
200
+ type: 'native' | 'erc20' | 'erc721' | (string & {})
201
+ }[]
202
+ }
203
+
179
204
  export type WalletGetCallsStatusReturnType<
180
205
  capabilities extends Capabilities = Capabilities,
181
206
  numberType = Hex,
@@ -1843,6 +1868,18 @@ export type WalletRpcSchema = [
1843
1868
  Parameters?: undefined
1844
1869
  ReturnType: void
1845
1870
  },
1871
+ /**
1872
+ * @description Returns the assets owned by the wallet.
1873
+ * @link https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7811.md
1874
+ * @example
1875
+ * provider.request({ method: 'wallet_getAssets', params: [...] })
1876
+ * // => { ... }
1877
+ */
1878
+ {
1879
+ Method: 'wallet_getAssets'
1880
+ Parameters?: [WalletGetAssetsParameters]
1881
+ ReturnType: WalletGetAssetsReturnType
1882
+ },
1846
1883
  /**
1847
1884
  * @description Returns the status of a call batch that was sent via `wallet_sendCalls`.
1848
1885
  * @link https://eips.ethereum.org/EIPS/eip-5792