viem 2.28.2 → 2.28.4
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.
- package/CHANGELOG.md +12 -0
- package/_cjs/actions/wallet/getCallsStatus.js.map +1 -1
- package/_cjs/actions/wallet/getCapabilities.js +5 -1
- package/_cjs/actions/wallet/getCapabilities.js.map +1 -1
- package/_cjs/actions/wallet/sendCalls.js +18 -2
- package/_cjs/actions/wallet/sendCalls.js.map +1 -1
- package/_cjs/chains/definitions/plumeMainnet.js +4 -4
- package/_cjs/chains/definitions/plumeMainnet.js.map +1 -1
- package/_cjs/chains/definitions/plumeSepolia.js +4 -4
- package/_cjs/chains/definitions/plumeSepolia.js.map +1 -1
- package/_cjs/clients/decorators/wallet.js +1 -1
- package/_cjs/clients/decorators/wallet.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/types/capabilities.js +3 -0
- package/_cjs/types/capabilities.js.map +1 -0
- package/_cjs/types/eip1193.js.map +1 -1
- package/_cjs/types/register.js +3 -0
- package/_cjs/types/register.js.map +1 -0
- package/_esm/actions/wallet/getCallsStatus.js.map +1 -1
- package/_esm/actions/wallet/getCapabilities.js +5 -1
- package/_esm/actions/wallet/getCapabilities.js.map +1 -1
- package/_esm/actions/wallet/sendCalls.js +18 -2
- package/_esm/actions/wallet/sendCalls.js.map +1 -1
- package/_esm/chains/definitions/plumeMainnet.js +4 -4
- package/_esm/chains/definitions/plumeMainnet.js.map +1 -1
- package/_esm/chains/definitions/plumeSepolia.js +4 -4
- package/_esm/chains/definitions/plumeSepolia.js.map +1 -1
- package/_esm/clients/decorators/wallet.js +1 -1
- package/_esm/clients/decorators/wallet.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/types/capabilities.js +2 -0
- package/_esm/types/capabilities.js.map +1 -0
- package/_esm/types/eip1193.js.map +1 -1
- package/_esm/types/register.js +2 -0
- package/_esm/types/register.js.map +1 -0
- package/_types/actions/wallet/getCallsStatus.d.ts +3 -2
- package/_types/actions/wallet/getCallsStatus.d.ts.map +1 -1
- package/_types/actions/wallet/getCapabilities.d.ts +2 -2
- package/_types/actions/wallet/getCapabilities.d.ts.map +1 -1
- package/_types/actions/wallet/sendCalls.d.ts +7 -5
- package/_types/actions/wallet/sendCalls.d.ts.map +1 -1
- package/_types/chains/definitions/plumeMainnet.d.ts +4 -4
- package/_types/chains/definitions/plumeSepolia.d.ts +4 -4
- package/_types/clients/decorators/wallet.d.ts +1 -1
- package/_types/clients/decorators/wallet.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/index.d.ts +8 -2
- package/_types/index.d.ts.map +1 -1
- package/_types/types/capabilities.d.ts +36 -0
- package/_types/types/capabilities.d.ts.map +1 -0
- package/_types/types/eip1193.d.ts +9 -14
- package/_types/types/eip1193.d.ts.map +1 -1
- package/_types/types/register.d.ts +14 -0
- package/_types/types/register.d.ts.map +1 -0
- package/actions/wallet/getCallsStatus.ts +3 -5
- package/actions/wallet/getCapabilities.ts +17 -9
- package/actions/wallet/sendCalls.ts +32 -11
- package/chains/definitions/plumeMainnet.ts +4 -4
- package/chains/definitions/plumeSepolia.ts +4 -4
- package/clients/decorators/wallet.ts +4 -4
- package/errors/version.ts +1 -1
- package/index.ts +11 -3
- package/package.json +1 -1
- package/types/capabilities.ts +58 -0
- package/types/eip1193.ts +13 -19
- package/types/register.ts +15 -0
@@ -6,11 +6,13 @@ import type { Transport } from '../../clients/transports/createTransport.js'
|
|
6
6
|
import type { ErrorType } from '../../errors/utils.js'
|
7
7
|
import type { Account } from '../../types/account.js'
|
8
8
|
import type {
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Capabilities,
|
10
|
+
ChainIdToCapabilities,
|
11
|
+
ExtractCapabilities,
|
12
|
+
} from '../../types/capabilities.js'
|
12
13
|
import type { Prettify } from '../../types/utils.js'
|
13
14
|
import type { RequestErrorType } from '../../utils/buildRequest.js'
|
15
|
+
import { numberToHex } from '../../utils/encoding/toHex.js'
|
14
16
|
|
15
17
|
export type GetCapabilitiesParameters<
|
16
18
|
chainId extends number | undefined = undefined,
|
@@ -23,8 +25,11 @@ export type GetCapabilitiesReturnType<
|
|
23
25
|
chainId extends number | undefined = undefined,
|
24
26
|
> = Prettify<
|
25
27
|
chainId extends number
|
26
|
-
?
|
27
|
-
:
|
28
|
+
? ExtractCapabilities<'getCapabilities', 'ReturnType'>
|
29
|
+
: ChainIdToCapabilities<
|
30
|
+
Capabilities<ExtractCapabilities<'getCapabilities', 'ReturnType'>>,
|
31
|
+
number
|
32
|
+
>
|
28
33
|
>
|
29
34
|
|
30
35
|
export type GetCapabilitiesErrorType = RequestErrorType | ErrorType
|
@@ -59,17 +64,20 @@ export async function getCapabilities<
|
|
59
64
|
|
60
65
|
const account_ = account ? parseAccount(account) : undefined
|
61
66
|
|
67
|
+
const params = chainId
|
68
|
+
? ([account_?.address, [numberToHex(chainId)]] as const)
|
69
|
+
: ([account_?.address] as const)
|
62
70
|
const capabilities_raw = await client.request({
|
63
71
|
method: 'wallet_getCapabilities',
|
64
|
-
params
|
72
|
+
params,
|
65
73
|
})
|
66
74
|
|
67
|
-
const capabilities = {} as
|
68
|
-
|
75
|
+
const capabilities = {} as ChainIdToCapabilities<
|
76
|
+
ExtractCapabilities<'getCapabilities', 'ReturnType'>,
|
69
77
|
number
|
70
78
|
>
|
71
79
|
for (const [key, value] of Object.entries(capabilities_raw))
|
72
|
-
capabilities[Number(key)] = value
|
80
|
+
capabilities[Number(key)] = value as never
|
73
81
|
return (
|
74
82
|
typeof chainId === 'number' ? capabilities[chainId] : capabilities
|
75
83
|
) as never
|
@@ -7,11 +7,10 @@ import type { BaseError } from '../../errors/base.js'
|
|
7
7
|
import type { ErrorType } from '../../errors/utils.js'
|
8
8
|
import type { Account, GetAccountParameter } from '../../types/account.js'
|
9
9
|
import type { Call, Calls } from '../../types/calls.js'
|
10
|
+
import type { ExtractCapabilities } from '../../types/capabilities.js'
|
10
11
|
import type { Chain, DeriveChain } from '../../types/chain.js'
|
11
|
-
import type {
|
12
|
-
|
13
|
-
WalletSendCallsParameters,
|
14
|
-
} from '../../types/eip1193.js'
|
12
|
+
import type { WalletSendCallsParameters } from '../../types/eip1193.js'
|
13
|
+
import type { Prettify } from '../../types/utils.js'
|
15
14
|
import { encodeFunctionData } from '../../utils/abi/encodeFunctionData.js'
|
16
15
|
import type { RequestErrorType } from '../../utils/buildRequest.js'
|
17
16
|
import { numberToHex } from '../../utils/encoding/toHex.js'
|
@@ -27,16 +26,16 @@ export type SendCallsParameters<
|
|
27
26
|
> = {
|
28
27
|
chain?: chainOverride | Chain | undefined
|
29
28
|
calls: Calls<Narrow<calls>>
|
30
|
-
capabilities?:
|
29
|
+
capabilities?: ExtractCapabilities<'sendCalls', 'Request'> | undefined
|
31
30
|
forceAtomic?: boolean | undefined
|
32
31
|
id?: string | undefined
|
33
32
|
version?: WalletSendCallsParameters[number]['version'] | undefined
|
34
33
|
} & GetAccountParameter<account, Account | Address, true, true>
|
35
34
|
|
36
|
-
export type SendCallsReturnType = {
|
37
|
-
capabilities?:
|
35
|
+
export type SendCallsReturnType = Prettify<{
|
36
|
+
capabilities?: ExtractCapabilities<'sendCalls', 'ReturnType'> | undefined
|
38
37
|
id: string
|
39
|
-
}
|
38
|
+
}>
|
40
39
|
|
41
40
|
export type SendCallsErrorType = RequestErrorType | ErrorType
|
42
41
|
|
@@ -83,7 +82,6 @@ export async function sendCalls<
|
|
83
82
|
): Promise<SendCallsReturnType> {
|
84
83
|
const {
|
85
84
|
account: account_ = client.account,
|
86
|
-
capabilities,
|
87
85
|
chain = client.chain,
|
88
86
|
forceAtomic = false,
|
89
87
|
id,
|
@@ -122,7 +120,7 @@ export async function sendCalls<
|
|
122
120
|
{
|
123
121
|
atomicRequired: forceAtomic,
|
124
122
|
calls,
|
125
|
-
capabilities,
|
123
|
+
capabilities: formatRequestCapabilities(parameters.capabilities),
|
126
124
|
chainId: numberToHex(chain!.id),
|
127
125
|
from: account?.address,
|
128
126
|
id,
|
@@ -133,7 +131,7 @@ export async function sendCalls<
|
|
133
131
|
{ retryCount: 0 },
|
134
132
|
)
|
135
133
|
if (typeof response === 'string') return { id: response }
|
136
|
-
return response
|
134
|
+
return response as never
|
137
135
|
} catch (err) {
|
138
136
|
throw getTransactionError(err as BaseError, {
|
139
137
|
...parameters,
|
@@ -142,3 +140,26 @@ export async function sendCalls<
|
|
142
140
|
})
|
143
141
|
}
|
144
142
|
}
|
143
|
+
|
144
|
+
function formatRequestCapabilities(
|
145
|
+
capabilities: ExtractCapabilities<'sendCalls', 'Request'> | undefined,
|
146
|
+
) {
|
147
|
+
const paymasterService = capabilities?.paymasterService
|
148
|
+
? Object.entries(capabilities.paymasterService).reduce(
|
149
|
+
(paymasterService, [chainId, value]) => ({
|
150
|
+
...(paymasterService ?? {}),
|
151
|
+
[numberToHex(Number(chainId))]: value,
|
152
|
+
}),
|
153
|
+
{},
|
154
|
+
)
|
155
|
+
: undefined
|
156
|
+
|
157
|
+
return {
|
158
|
+
...capabilities,
|
159
|
+
...(paymasterService
|
160
|
+
? {
|
161
|
+
paymasterService,
|
162
|
+
}
|
163
|
+
: {}),
|
164
|
+
}
|
165
|
+
}
|
@@ -12,15 +12,15 @@ export const plumeMainnet = /*#__PURE__*/ defineChain({
|
|
12
12
|
},
|
13
13
|
rpcUrls: {
|
14
14
|
default: {
|
15
|
-
http: ['https://
|
16
|
-
webSocket: ['wss://
|
15
|
+
http: ['https://rpc.plume.org'],
|
16
|
+
webSocket: ['wss://rpc.plume.org'],
|
17
17
|
},
|
18
18
|
},
|
19
19
|
blockExplorers: {
|
20
20
|
default: {
|
21
21
|
name: 'Blockscout',
|
22
|
-
url: 'https://
|
23
|
-
apiUrl: 'https://
|
22
|
+
url: 'https://explorer.plume.org',
|
23
|
+
apiUrl: 'https://explorer.plume.org/api',
|
24
24
|
},
|
25
25
|
},
|
26
26
|
contracts: {
|
@@ -12,15 +12,15 @@ export const plumeSepolia = /*#__PURE__*/ defineChain({
|
|
12
12
|
},
|
13
13
|
rpcUrls: {
|
14
14
|
default: {
|
15
|
-
http: ['https://testnet-rpc.
|
16
|
-
webSocket: ['wss://testnet-rpc.
|
15
|
+
http: ['https://testnet-rpc.plume.org'],
|
16
|
+
webSocket: ['wss://testnet-rpc.plume.org'],
|
17
17
|
},
|
18
18
|
},
|
19
19
|
blockExplorers: {
|
20
20
|
default: {
|
21
21
|
name: 'Blockscout',
|
22
|
-
url: 'https://testnet-explorer.
|
23
|
-
apiUrl: 'https://testnet-explorer.
|
22
|
+
url: 'https://testnet-explorer.plume.org',
|
23
|
+
apiUrl: 'https://testnet-explorer.plume.org/api',
|
24
24
|
},
|
25
25
|
},
|
26
26
|
contracts: {
|
@@ -238,9 +238,9 @@ export type WalletActions<
|
|
238
238
|
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
239
239
|
* })
|
240
240
|
*/
|
241
|
-
getCapabilities: (
|
242
|
-
parameters?: GetCapabilitiesParameters
|
243
|
-
) => Promise<GetCapabilitiesReturnType
|
241
|
+
getCapabilities: <chainId extends number | undefined>(
|
242
|
+
parameters?: GetCapabilitiesParameters<chainId>,
|
243
|
+
) => Promise<GetCapabilitiesReturnType<chainId>>
|
244
244
|
/**
|
245
245
|
* Returns the chain ID associated with the current network.
|
246
246
|
*
|
@@ -963,7 +963,7 @@ export function walletActions<
|
|
963
963
|
deployContract: (args) => deployContract(client, args),
|
964
964
|
getAddresses: () => getAddresses(client),
|
965
965
|
getCallsStatus: (args) => getCallsStatus(client, args),
|
966
|
-
getCapabilities: () => getCapabilities(client),
|
966
|
+
getCapabilities: (args) => getCapabilities(client, args),
|
967
967
|
getChainId: () => getChainId(client),
|
968
968
|
getPermissions: () => getPermissions(client),
|
969
969
|
prepareAuthorization: (args) => prepareAuthorization(client, args),
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.28.
|
1
|
+
export const version = '2.28.4'
|
package/index.ts
CHANGED
@@ -13,7 +13,6 @@ export {
|
|
13
13
|
type ParseAbiItem,
|
14
14
|
type ParseAbiParameter,
|
15
15
|
type ParseAbiParameters,
|
16
|
-
type ResolvedRegister,
|
17
16
|
type TypedData,
|
18
17
|
type TypedDataDomain,
|
19
18
|
type TypedDataParameter,
|
@@ -1105,6 +1104,16 @@ export type {
|
|
1105
1104
|
BlockTag,
|
1106
1105
|
Uncle,
|
1107
1106
|
} from './types/block.js'
|
1107
|
+
export type {
|
1108
|
+
Capabilities,
|
1109
|
+
/** @deprecated Use `Capabilities` instead. */
|
1110
|
+
Capabilities as WalletCapabilities,
|
1111
|
+
CapabilitiesSchema,
|
1112
|
+
/** @deprecated Use `ChainIdToCapabilities` instead. */
|
1113
|
+
ChainIdToCapabilities as WalletCapabilitiesRecord,
|
1114
|
+
ChainIdToCapabilities,
|
1115
|
+
ExtractCapabilities,
|
1116
|
+
} from './types/capabilities.js'
|
1108
1117
|
export type {
|
1109
1118
|
ByteArray,
|
1110
1119
|
Hash,
|
@@ -1133,8 +1142,6 @@ export type {
|
|
1133
1142
|
RpcSchema,
|
1134
1143
|
RpcSchemaOverride,
|
1135
1144
|
TestRpcSchema,
|
1136
|
-
WalletCapabilities,
|
1137
|
-
WalletCapabilitiesRecord,
|
1138
1145
|
WalletCallReceipt,
|
1139
1146
|
WalletGetCallsStatusReturnType,
|
1140
1147
|
WalletGrantPermissionsParameters,
|
@@ -1178,6 +1185,7 @@ export type {
|
|
1178
1185
|
SignedAuthorization,
|
1179
1186
|
SignedAuthorizationList,
|
1180
1187
|
} from './types/authorization.js'
|
1188
|
+
export type { ResolvedRegister } from './types/register.js'
|
1181
1189
|
export type {
|
1182
1190
|
Index,
|
1183
1191
|
Quantity,
|
package/package.json
CHANGED
@@ -0,0 +1,58 @@
|
|
1
|
+
import type { Hex } from './misc.js'
|
2
|
+
import type { ResolvedRegister } from './register.js'
|
3
|
+
import type { Prettify } from './utils.js'
|
4
|
+
|
5
|
+
export type CapabilitiesSchema = ResolvedRegister['CapabilitiesSchema']
|
6
|
+
|
7
|
+
export type DefaultCapabilitiesSchema = {
|
8
|
+
getCapabilities: {
|
9
|
+
ReturnType: {
|
10
|
+
atomic?:
|
11
|
+
| {
|
12
|
+
status: 'supported' | 'ready' | 'unsupported'
|
13
|
+
}
|
14
|
+
| undefined
|
15
|
+
paymasterService?:
|
16
|
+
| {
|
17
|
+
supported: boolean
|
18
|
+
}
|
19
|
+
| undefined
|
20
|
+
}
|
21
|
+
}
|
22
|
+
sendCalls: {
|
23
|
+
Request: {
|
24
|
+
paymasterService?:
|
25
|
+
| {
|
26
|
+
[chainId: number]: {
|
27
|
+
url: string
|
28
|
+
context?: Record<string, any> | undefined
|
29
|
+
}
|
30
|
+
}
|
31
|
+
| undefined
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
export type Capabilities<capabilities extends Record<string, any> = {}> = {
|
37
|
+
[key: string]: any
|
38
|
+
} & capabilities
|
39
|
+
|
40
|
+
export type ChainIdToCapabilities<
|
41
|
+
capabilities extends Capabilities = Capabilities,
|
42
|
+
id extends string | number = Hex,
|
43
|
+
> = {
|
44
|
+
[chainId in id]: capabilities
|
45
|
+
}
|
46
|
+
|
47
|
+
export type ExtractCapabilities<
|
48
|
+
method extends string,
|
49
|
+
key extends 'Request' | 'ReturnType',
|
50
|
+
> = Prettify<
|
51
|
+
method extends keyof CapabilitiesSchema
|
52
|
+
? CapabilitiesSchema[method] extends {
|
53
|
+
[k in key]: infer value extends Record<string, any>
|
54
|
+
}
|
55
|
+
? Capabilities<value>
|
56
|
+
: Capabilities
|
57
|
+
: Capabilities
|
58
|
+
>
|
package/types/eip1193.ts
CHANGED
@@ -9,6 +9,7 @@ import type {
|
|
9
9
|
RpcUserOperationReceipt,
|
10
10
|
} from '../account-abstraction/types/rpc.js'
|
11
11
|
import type { BlockTag } from './block.js'
|
12
|
+
import type { Capabilities, ChainIdToCapabilities } from './capabilities.js'
|
12
13
|
import type { Hash, Hex, LogTopic } from './misc.js'
|
13
14
|
import type { RpcStateOverride } from './rpc.js'
|
14
15
|
import type {
|
@@ -121,17 +122,6 @@ export type NetworkSync = {
|
|
121
122
|
startingBlock: Quantity
|
122
123
|
}
|
123
124
|
|
124
|
-
export type WalletCapabilities = {
|
125
|
-
[capability: string]: any
|
126
|
-
}
|
127
|
-
|
128
|
-
export type WalletCapabilitiesRecord<
|
129
|
-
capabilities extends WalletCapabilities = WalletCapabilities,
|
130
|
-
id extends string | number = Hex,
|
131
|
-
> = {
|
132
|
-
[chainId in id]: capabilities
|
133
|
-
}
|
134
|
-
|
135
125
|
export type WalletCallReceipt<quantity = Hex, status = Hex> = {
|
136
126
|
logs: {
|
137
127
|
address: Hex
|
@@ -187,13 +177,13 @@ export type WalletGrantPermissionsReturnType = {
|
|
187
177
|
}
|
188
178
|
|
189
179
|
export type WalletGetCallsStatusReturnType<
|
190
|
-
capabilities extends
|
180
|
+
capabilities extends Capabilities = Capabilities,
|
191
181
|
numberType = Hex,
|
192
182
|
bigintType = Hex,
|
193
183
|
receiptStatus = Hex,
|
194
184
|
> = {
|
195
185
|
atomic: boolean
|
196
|
-
capabilities?: capabilities |
|
186
|
+
capabilities?: capabilities | Capabilities | undefined
|
197
187
|
chainId: numberType
|
198
188
|
id: string
|
199
189
|
receipts?: WalletCallReceipt<bigintType, receiptStatus>[] | undefined
|
@@ -215,19 +205,19 @@ export type WalletPermission = {
|
|
215
205
|
}
|
216
206
|
|
217
207
|
export type WalletSendCallsParameters<
|
218
|
-
capabilities extends
|
208
|
+
capabilities extends Capabilities = Capabilities,
|
219
209
|
chainId extends Hex | number = Hex,
|
220
210
|
quantity extends Quantity | bigint = Quantity,
|
221
211
|
> = [
|
222
212
|
{
|
223
213
|
atomicRequired: boolean
|
224
214
|
calls: readonly {
|
225
|
-
capabilities?: capabilities |
|
215
|
+
capabilities?: capabilities | Capabilities | undefined
|
226
216
|
to?: Address | undefined
|
227
217
|
data?: Hex | undefined
|
228
218
|
value?: quantity | undefined
|
229
219
|
}[]
|
230
|
-
capabilities?: capabilities |
|
220
|
+
capabilities?: capabilities | Capabilities | undefined
|
231
221
|
chainId?: chainId | undefined
|
232
222
|
id?: string | undefined
|
233
223
|
from?: Address | undefined
|
@@ -236,7 +226,7 @@ export type WalletSendCallsParameters<
|
|
236
226
|
]
|
237
227
|
|
238
228
|
export type WalletSendCallsReturnType<
|
239
|
-
capabilities extends
|
229
|
+
capabilities extends Capabilities = Capabilities,
|
240
230
|
> = {
|
241
231
|
capabilities?: capabilities | undefined
|
242
232
|
id: string
|
@@ -1795,8 +1785,12 @@ export type WalletRpcSchema = [
|
|
1795
1785
|
*/
|
1796
1786
|
{
|
1797
1787
|
Method: 'wallet_getCapabilities'
|
1798
|
-
Parameters?:
|
1799
|
-
|
1788
|
+
Parameters?:
|
1789
|
+
| readonly []
|
1790
|
+
| readonly [Address | undefined]
|
1791
|
+
| readonly [Address | undefined, readonly Hex[] | undefined]
|
1792
|
+
| undefined
|
1793
|
+
ReturnType: Prettify<ChainIdToCapabilities>
|
1800
1794
|
},
|
1801
1795
|
/**
|
1802
1796
|
* @description Gets the wallets current permissions.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import type { DefaultCapabilitiesSchema } from './capabilities.js'
|
2
|
+
|
3
|
+
// biome-ignore lint/suspicious/noEmptyInterface:
|
4
|
+
export interface Register {}
|
5
|
+
|
6
|
+
export type ResolvedRegister = {
|
7
|
+
CapabilitiesSchema: Register extends { CapabilitiesSchema: infer schema }
|
8
|
+
? schema
|
9
|
+
: DefaultRegister['CapabilitiesSchema']
|
10
|
+
}
|
11
|
+
|
12
|
+
/** @internal */
|
13
|
+
type DefaultRegister = {
|
14
|
+
CapabilitiesSchema: DefaultCapabilitiesSchema
|
15
|
+
}
|