viem 2.9.7 → 2.9.9
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 +20 -1
- package/_cjs/actions/public/call.js +6 -10
- package/_cjs/actions/public/call.js.map +1 -1
- package/_cjs/chains/definitions/lineaGoerli.js +30 -0
- package/_cjs/chains/definitions/lineaGoerli.js.map +1 -0
- package/_cjs/chains/definitions/lineaSepolia.js +30 -0
- package/_cjs/chains/definitions/lineaSepolia.js.map +1 -0
- package/_cjs/chains/index.js +7 -3
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/experimental/actions/{getCallsStatus.js → getCallsReceipt.js} +5 -5
- package/_cjs/experimental/actions/getCallsReceipt.js.map +1 -0
- package/_cjs/experimental/actions/sendCalls.js +1 -1
- package/_cjs/experimental/actions/sendCalls.js.map +1 -1
- package/_cjs/experimental/actions/writeContracts.js +23 -0
- package/_cjs/experimental/actions/writeContracts.js.map +1 -0
- package/_cjs/experimental/decorators/eip5792.js +4 -2
- package/_cjs/experimental/decorators/eip5792.js.map +1 -1
- package/_cjs/experimental/index.js +5 -3
- package/_cjs/experimental/index.js.map +1 -1
- package/_cjs/utils/formatters/transactionRequest.js +15 -4
- package/_cjs/utils/formatters/transactionRequest.js.map +1 -1
- package/_esm/actions/public/call.js +6 -10
- package/_esm/actions/public/call.js.map +1 -1
- package/_esm/chains/definitions/lineaGoerli.js +27 -0
- package/_esm/chains/definitions/lineaGoerli.js.map +1 -0
- package/_esm/chains/definitions/lineaSepolia.js +27 -0
- package/_esm/chains/definitions/lineaSepolia.js.map +1 -0
- package/_esm/chains/index.js +3 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/experimental/actions/{getCallsStatus.js → getCallsReceipt.js} +8 -8
- package/_esm/experimental/actions/getCallsReceipt.js.map +1 -0
- package/_esm/experimental/actions/getCapabilities.js +1 -1
- package/_esm/experimental/actions/sendCalls.js +2 -2
- package/_esm/experimental/actions/sendCalls.js.map +1 -1
- package/_esm/experimental/actions/writeContracts.js +62 -0
- package/_esm/experimental/actions/writeContracts.js.map +1 -0
- package/_esm/experimental/decorators/eip5792.js +5 -3
- package/_esm/experimental/decorators/eip5792.js.map +1 -1
- package/_esm/experimental/index.js +2 -1
- package/_esm/experimental/index.js.map +1 -1
- package/_esm/utils/formatters/transactionRequest.js +15 -4
- package/_esm/utils/formatters/transactionRequest.js.map +1 -1
- package/_types/actions/public/call.d.ts.map +1 -1
- package/_types/chains/definitions/lineaGoerli.d.ts +35 -0
- package/_types/chains/definitions/lineaGoerli.d.ts.map +1 -0
- package/_types/chains/definitions/lineaSepolia.d.ts +35 -0
- package/_types/chains/definitions/lineaSepolia.d.ts.map +1 -0
- package/_types/chains/index.d.ts +3 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/experimental/actions/getCallsReceipt.d.ts +35 -0
- package/_types/experimental/actions/getCallsReceipt.d.ts.map +1 -0
- package/_types/experimental/actions/getCapabilities.d.ts +1 -1
- package/_types/experimental/actions/sendCalls.d.ts +3 -3
- package/_types/experimental/actions/sendCalls.d.ts.map +1 -1
- package/_types/experimental/actions/writeContracts.d.ts +62 -0
- package/_types/experimental/actions/writeContracts.d.ts.map +1 -0
- package/_types/experimental/decorators/eip5792.d.ts +55 -9
- package/_types/experimental/decorators/eip5792.d.ts.map +1 -1
- package/_types/experimental/index.d.ts +2 -1
- package/_types/experimental/index.d.ts.map +1 -1
- package/_types/index.d.ts +1 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/types/contract.d.ts +1 -1
- package/_types/types/contract.d.ts.map +1 -1
- package/_types/types/eip1193.d.ts +6 -6
- package/_types/types/eip1193.d.ts.map +1 -1
- package/_types/utils/formatters/transactionRequest.d.ts.map +1 -1
- package/actions/public/call.ts +5 -11
- package/chains/definitions/lineaGoerli.ts +27 -0
- package/chains/definitions/lineaSepolia.ts +27 -0
- package/chains/index.ts +3 -0
- package/errors/version.ts +1 -1
- package/experimental/actions/{getCallsStatus.ts → getCallsReceipt.ts} +14 -14
- package/experimental/actions/getCapabilities.ts +1 -1
- package/experimental/actions/sendCalls.ts +4 -4
- package/experimental/actions/writeContracts.ts +115 -0
- package/experimental/decorators/eip5792.ts +76 -15
- package/experimental/index.ts +11 -5
- package/index.ts +2 -2
- package/package.json +1 -1
- package/types/contract.ts +2 -1
- package/types/eip1193.ts +6 -6
- package/utils/formatters/transactionRequest.ts +13 -6
- package/_cjs/experimental/actions/getCallsStatus.js.map +0 -1
- package/_esm/experimental/actions/getCallsStatus.js.map +0 -1
- package/_types/experimental/actions/getCallsStatus.d.ts +0 -35
- package/_types/experimental/actions/getCallsStatus.d.ts.map +0 -1
@@ -3,50 +3,50 @@ import type { Transport } from '../../clients/transports/createTransport.js'
|
|
3
3
|
import type { ErrorType } from '../../errors/utils.js'
|
4
4
|
import type { Account } from '../../types/account.js'
|
5
5
|
import type { Chain } from '../../types/chain.js'
|
6
|
-
import type {
|
6
|
+
import type { WalletGetCallsReceiptReturnType } from '../../types/eip1193.js'
|
7
7
|
import type { Prettify } from '../../types/utils.js'
|
8
8
|
import type { RequestErrorType } from '../../utils/buildRequest.js'
|
9
9
|
import { hexToBigInt } from '../../utils/encoding/fromHex.js'
|
10
10
|
import { receiptStatuses } from '../../utils/formatters/transactionReceipt.js'
|
11
11
|
|
12
|
-
export type
|
12
|
+
export type GetCallsReceiptParameters = { id: string }
|
13
13
|
|
14
|
-
export type
|
15
|
-
|
14
|
+
export type GetCallsReceiptReturnType = Prettify<
|
15
|
+
WalletGetCallsReceiptReturnType<bigint, 'success' | 'reverted'>
|
16
16
|
>
|
17
17
|
|
18
|
-
export type
|
18
|
+
export type GetCallsReceiptErrorType = RequestErrorType | ErrorType
|
19
19
|
|
20
20
|
/**
|
21
21
|
* Returns the status of a call batch that was sent via `sendCalls`.
|
22
22
|
*
|
23
|
-
* - Docs: https://viem.sh/
|
24
|
-
* - JSON-RPC Methods: [`
|
23
|
+
* - Docs: https://viem.sh/experimental/actions/getCallsReceipt
|
24
|
+
* - JSON-RPC Methods: [`wallet_getCallsReceipt`](https://eips.ethereum.org/EIPS/eip-5792)
|
25
25
|
*
|
26
26
|
* @param client - Client to use
|
27
|
-
* @returns Status of the calls. {@link
|
27
|
+
* @returns Status of the calls. {@link GetCallsReceiptReturnType}
|
28
28
|
*
|
29
29
|
* @example
|
30
30
|
* import { createWalletClient, custom } from 'viem'
|
31
31
|
* import { mainnet } from 'viem/chains'
|
32
|
-
* import {
|
32
|
+
* import { getCallsReceipt } from 'viem/wallet'
|
33
33
|
*
|
34
34
|
* const client = createWalletClient({
|
35
35
|
* chain: mainnet,
|
36
36
|
* transport: custom(window.ethereum),
|
37
37
|
* })
|
38
|
-
* const { receipts, status } = await
|
38
|
+
* const { receipts, status } = await getCallsReceipt(client, { id: '0xdeadbeef' })
|
39
39
|
*/
|
40
|
-
export async function
|
40
|
+
export async function getCallsReceipt<
|
41
41
|
chain extends Chain | undefined,
|
42
42
|
account extends Account | undefined = undefined,
|
43
43
|
>(
|
44
44
|
client: Client<Transport, chain, account>,
|
45
|
-
parameters:
|
46
|
-
): Promise<
|
45
|
+
parameters: GetCallsReceiptParameters,
|
46
|
+
): Promise<GetCallsReceiptReturnType> {
|
47
47
|
const { id } = parameters
|
48
48
|
const { receipts, status } = await client.request({
|
49
|
-
method: '
|
49
|
+
method: 'wallet_getCallsReceipt',
|
50
50
|
params: id,
|
51
51
|
})
|
52
52
|
return {
|
@@ -19,7 +19,7 @@ export type GetCapabilitiesErrorType = RequestErrorType | ErrorType
|
|
19
19
|
/**
|
20
20
|
* Extract capabilities that a connected wallet supports (e.g. paymasters, session keys, etc).
|
21
21
|
*
|
22
|
-
* - Docs: https://viem.sh/
|
22
|
+
* - Docs: https://viem.sh/experimental/actions/getCapabilities
|
23
23
|
* - JSON-RPC Methods: [`wallet_getCapabilities`](https://eips.ethereum.org/EIPS/eip-5792)
|
24
24
|
*
|
25
25
|
* @param client - Client to use
|
@@ -25,8 +25,8 @@ export type SendCallsParameters<
|
|
25
25
|
calls: OneOf<
|
26
26
|
| {
|
27
27
|
to: Hex
|
28
|
-
data?: Hex
|
29
|
-
value?: bigint
|
28
|
+
data?: Hex | undefined
|
29
|
+
value?: bigint | undefined
|
30
30
|
}
|
31
31
|
| {
|
32
32
|
data: Hex
|
@@ -46,7 +46,7 @@ export type SendCallsErrorType = RequestErrorType | ErrorType
|
|
46
46
|
/**
|
47
47
|
* Requests the connected wallet to send a batch of calls.
|
48
48
|
*
|
49
|
-
* - Docs: https://viem.sh/
|
49
|
+
* - Docs: https://viem.sh/experimental/actions/sendCalls
|
50
50
|
* - JSON-RPC Methods: [`wallet_sendCalls`](https://eips.ethereum.org/EIPS/eip-5792)
|
51
51
|
*
|
52
52
|
* @param client - Client to use
|
@@ -93,7 +93,7 @@ export async function sendCalls<
|
|
93
93
|
|
94
94
|
if (!account_)
|
95
95
|
throw new AccountNotFoundError({
|
96
|
-
docsPath: '/
|
96
|
+
docsPath: '/experimental/actions/sendCalls',
|
97
97
|
})
|
98
98
|
const account = parseAccount(account_)
|
99
99
|
|
@@ -0,0 +1,115 @@
|
|
1
|
+
import type { AbiStateMutability, Narrow } from 'abitype'
|
2
|
+
|
3
|
+
import type { Client } from '../../clients/createClient.js'
|
4
|
+
import type { Transport } from '../../clients/transports/createTransport.js'
|
5
|
+
import type { ErrorType } from '../../errors/utils.js'
|
6
|
+
import type { Account, GetAccountParameter } from '../../types/account.js'
|
7
|
+
import type { Chain, GetChainParameter } from '../../types/chain.js'
|
8
|
+
import type { ContractFunctionParameters } from '../../types/contract.js'
|
9
|
+
import type { MulticallContracts } from '../../types/multicall.js'
|
10
|
+
import {
|
11
|
+
type EncodeFunctionDataErrorType,
|
12
|
+
encodeFunctionData,
|
13
|
+
} from '../../utils/abi/encodeFunctionData.js'
|
14
|
+
import {
|
15
|
+
type SendCallsErrorType,
|
16
|
+
type SendCallsParameters,
|
17
|
+
type SendCallsReturnType,
|
18
|
+
sendCalls,
|
19
|
+
} from './sendCalls.js'
|
20
|
+
|
21
|
+
export type WriteContractsParameters<
|
22
|
+
contracts extends readonly unknown[] = readonly ContractFunctionParameters[],
|
23
|
+
chain extends Chain | undefined = Chain | undefined,
|
24
|
+
account extends Account | undefined = Account | undefined,
|
25
|
+
chainOverride extends Chain | undefined = Chain | undefined,
|
26
|
+
> = Pick<
|
27
|
+
SendCallsParameters<chain, account, chainOverride>,
|
28
|
+
'capabilities' | 'version'
|
29
|
+
> & {
|
30
|
+
contracts: MulticallContracts<
|
31
|
+
Narrow<contracts>,
|
32
|
+
{ mutability: AbiStateMutability }
|
33
|
+
>
|
34
|
+
} & GetAccountParameter<account> &
|
35
|
+
GetChainParameter<chain, chainOverride>
|
36
|
+
|
37
|
+
export type WriteContractsReturnType = SendCallsReturnType
|
38
|
+
|
39
|
+
export type WriteContractsErrorType =
|
40
|
+
| EncodeFunctionDataErrorType
|
41
|
+
| SendCallsErrorType
|
42
|
+
| ErrorType
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Requests for the wallet to sign and broadcast a batch of write contract calls (transactions) to the network.
|
46
|
+
*
|
47
|
+
* - Docs: https://viem.sh/experimental/actions/writeContracts
|
48
|
+
*
|
49
|
+
* @param client - Client to use
|
50
|
+
* @param parameters - {@link WriteContractsParameters}
|
51
|
+
* @returns Unique identifier for the call batch. {@link WriteContractsReturnType}
|
52
|
+
*
|
53
|
+
* @example
|
54
|
+
* import { createPublicClient, http, parseAbi } from 'viem'
|
55
|
+
* import { mainnet } from 'viem/chains'
|
56
|
+
* import { writeContracts } from 'viem/experimental'
|
57
|
+
*
|
58
|
+
* const client = createPublicClient({
|
59
|
+
* chain: mainnet,
|
60
|
+
* transport: http(),
|
61
|
+
* })
|
62
|
+
* const abi = parseAbi([
|
63
|
+
* 'function approve(address, uint256) returns (bool)',
|
64
|
+
* 'function transferFrom(address, address, uint256) returns (bool)',
|
65
|
+
* ])
|
66
|
+
* const id = await writeContracts(client, {
|
67
|
+
* contracts: [
|
68
|
+
* {
|
69
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
70
|
+
* abi,
|
71
|
+
* functionName: 'approve',
|
72
|
+
* args: ['0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC', 100n],
|
73
|
+
* },
|
74
|
+
* {
|
75
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
76
|
+
* abi,
|
77
|
+
* functionName: 'transferFrom',
|
78
|
+
* args: [
|
79
|
+
* '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
|
80
|
+
* '0x0000000000000000000000000000000000000000',
|
81
|
+
* 100n
|
82
|
+
* ],
|
83
|
+
* },
|
84
|
+
* ],
|
85
|
+
* })
|
86
|
+
*/
|
87
|
+
export async function writeContracts<
|
88
|
+
const contracts extends readonly unknown[],
|
89
|
+
chain extends Chain | undefined,
|
90
|
+
account extends Account | undefined = undefined,
|
91
|
+
chainOverride extends Chain | undefined = undefined,
|
92
|
+
>(
|
93
|
+
client: Client<Transport, chain>,
|
94
|
+
parameters: WriteContractsParameters<
|
95
|
+
contracts,
|
96
|
+
chain,
|
97
|
+
account,
|
98
|
+
chainOverride
|
99
|
+
>,
|
100
|
+
): Promise<WriteContractsReturnType> {
|
101
|
+
const contracts = parameters.contracts as ContractFunctionParameters[]
|
102
|
+
const calls = contracts.map((contract) => {
|
103
|
+
const { address, abi, functionName, args, value } = contract
|
104
|
+
return {
|
105
|
+
data: encodeFunctionData({
|
106
|
+
abi,
|
107
|
+
functionName,
|
108
|
+
args,
|
109
|
+
}),
|
110
|
+
to: address,
|
111
|
+
value,
|
112
|
+
} satisfies SendCallsParameters['calls'][number]
|
113
|
+
})
|
114
|
+
return sendCalls(client, { ...parameters, calls } as SendCallsParameters)
|
115
|
+
}
|
@@ -3,10 +3,10 @@ import type { Transport } from '../../clients/transports/createTransport.js'
|
|
3
3
|
import type { Account } from '../../types/account.js'
|
4
4
|
import type { Chain } from '../../types/chain.js'
|
5
5
|
import {
|
6
|
-
type
|
7
|
-
type
|
8
|
-
|
9
|
-
} from '../actions/
|
6
|
+
type GetCallsReceiptParameters,
|
7
|
+
type GetCallsReceiptReturnType,
|
8
|
+
getCallsReceipt,
|
9
|
+
} from '../actions/getCallsReceipt.js'
|
10
10
|
import {
|
11
11
|
type GetCapabilitiesReturnType,
|
12
12
|
getCapabilities,
|
@@ -16,6 +16,11 @@ import {
|
|
16
16
|
type SendCallsReturnType,
|
17
17
|
sendCalls,
|
18
18
|
} from '../actions/sendCalls.js'
|
19
|
+
import {
|
20
|
+
type WriteContractsParameters,
|
21
|
+
type WriteContractsReturnType,
|
22
|
+
writeContracts,
|
23
|
+
} from '../actions/writeContracts.js'
|
19
24
|
|
20
25
|
export type WalletActionsEip5792<
|
21
26
|
chain extends Chain | undefined = Chain | undefined,
|
@@ -24,11 +29,11 @@ export type WalletActionsEip5792<
|
|
24
29
|
/**
|
25
30
|
* Returns the status of a call batch that was sent via `sendCalls`.
|
26
31
|
*
|
27
|
-
* - Docs: https://viem.sh/
|
28
|
-
* - JSON-RPC Methods: [`
|
32
|
+
* - Docs: https://viem.sh/experimental/actions/getCallsReceipt
|
33
|
+
* - JSON-RPC Methods: [`wallet_getCallsReceipt`](https://eips.ethereum.org/EIPS/eip-5792)
|
29
34
|
*
|
30
35
|
* @param client - Client to use
|
31
|
-
* @returns Status of the calls. {@link
|
36
|
+
* @returns Status of the calls. {@link GetCallsReceiptReturnType}
|
32
37
|
*
|
33
38
|
* @example
|
34
39
|
* import { createWalletClient, custom } from 'viem'
|
@@ -40,15 +45,15 @@ export type WalletActionsEip5792<
|
|
40
45
|
* transport: custom(window.ethereum),
|
41
46
|
* }).extend(walletActionsEip5792())
|
42
47
|
*
|
43
|
-
* const { receipts, status } = await client.
|
48
|
+
* const { receipts, status } = await client.getCallsReceipt({ id: '0xdeadbeef' })
|
44
49
|
*/
|
45
|
-
|
46
|
-
parameters:
|
47
|
-
) => Promise<
|
50
|
+
getCallsReceipt: (
|
51
|
+
parameters: GetCallsReceiptParameters,
|
52
|
+
) => Promise<GetCallsReceiptReturnType>
|
48
53
|
/**
|
49
54
|
* Extract capabilities that a connected wallet supports (e.g. paymasters, session keys, etc).
|
50
55
|
*
|
51
|
-
* - Docs: https://viem.sh/
|
56
|
+
* - Docs: https://viem.sh/experimental/actions/getCapabilities
|
52
57
|
* - JSON-RPC Methods: [`wallet_getCapabilities`](https://eips.ethereum.org/EIPS/eip-5792)
|
53
58
|
*
|
54
59
|
* @param client - Client to use
|
@@ -70,7 +75,7 @@ export type WalletActionsEip5792<
|
|
70
75
|
/**
|
71
76
|
* Requests the connected wallet to send a batch of calls.
|
72
77
|
*
|
73
|
-
* - Docs: https://viem.sh/
|
78
|
+
* - Docs: https://viem.sh/experimental/actions/sendCalls
|
74
79
|
* - JSON-RPC Methods: [`wallet_sendCalls`](https://eips.ethereum.org/EIPS/eip-5792)
|
75
80
|
*
|
76
81
|
* @param client - Client to use
|
@@ -103,12 +108,67 @@ export type WalletActionsEip5792<
|
|
103
108
|
sendCalls: <chainOverride extends Chain | undefined = undefined>(
|
104
109
|
parameters: SendCallsParameters<chain, account, chainOverride>,
|
105
110
|
) => Promise<SendCallsReturnType>
|
111
|
+
/**
|
112
|
+
* Requests for the wallet to sign and broadcast a batch of write contract calls (transactions) to the network.
|
113
|
+
*
|
114
|
+
* - Docs: https://viem.sh/experimental/actions/writeContracts
|
115
|
+
*
|
116
|
+
* @param client - Client to use
|
117
|
+
* @param parameters - {@link WriteContractsParameters}
|
118
|
+
* @returns Unique identifier for the call batch. {@link WriteContractsReturnType}
|
119
|
+
*
|
120
|
+
* @example
|
121
|
+
* import { createPublicClient, http, parseAbi } from 'viem'
|
122
|
+
* import { mainnet } from 'viem/chains'
|
123
|
+
* import { writeContracts } from 'viem/experimental'
|
124
|
+
*
|
125
|
+
* const client = createPublicClient({
|
126
|
+
* chain: mainnet,
|
127
|
+
* transport: http(),
|
128
|
+
* })
|
129
|
+
* const abi = parseAbi([
|
130
|
+
* 'function approve(address, uint256) returns (bool)',
|
131
|
+
* 'function transferFrom(address, address, uint256) returns (bool)',
|
132
|
+
* ])
|
133
|
+
* const id = await client.writeContracts({
|
134
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
135
|
+
* contracts: [
|
136
|
+
* {
|
137
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
138
|
+
* abi,
|
139
|
+
* functionName: 'approve',
|
140
|
+
* args: ['0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC', 100n],
|
141
|
+
* },
|
142
|
+
* {
|
143
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
144
|
+
* abi,
|
145
|
+
* functionName: 'transferFrom',
|
146
|
+
* args: [
|
147
|
+
* '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
|
148
|
+
* '0x0000000000000000000000000000000000000000',
|
149
|
+
* 100n
|
150
|
+
* ],
|
151
|
+
* },
|
152
|
+
* ],
|
153
|
+
* })
|
154
|
+
*/
|
155
|
+
writeContracts: <
|
156
|
+
const contracts extends readonly unknown[],
|
157
|
+
chainOverride extends Chain | undefined = undefined,
|
158
|
+
>(
|
159
|
+
parameters: WriteContractsParameters<
|
160
|
+
contracts,
|
161
|
+
chain,
|
162
|
+
account,
|
163
|
+
chainOverride
|
164
|
+
>,
|
165
|
+
) => Promise<WriteContractsReturnType>
|
106
166
|
}
|
107
167
|
|
108
168
|
/**
|
109
169
|
* A suite of EIP-5792 Wallet Actions.
|
110
170
|
*
|
111
|
-
* - Docs: https://viem.sh/
|
171
|
+
* - Docs: https://viem.sh/experimental
|
112
172
|
*
|
113
173
|
* @example
|
114
174
|
* import { createPublicClient, createWalletClient, http } from 'viem'
|
@@ -131,9 +191,10 @@ export function walletActionsEip5792() {
|
|
131
191
|
client: Client<transport, chain, account>,
|
132
192
|
): WalletActionsEip5792<chain, account> => {
|
133
193
|
return {
|
134
|
-
|
194
|
+
getCallsReceipt: (parameters) => getCallsReceipt(client, parameters),
|
135
195
|
getCapabilities: () => getCapabilities(client),
|
136
196
|
sendCalls: (parameters) => sendCalls(client, parameters),
|
197
|
+
writeContracts: (parameters) => writeContracts(client, parameters),
|
137
198
|
}
|
138
199
|
}
|
139
200
|
}
|
package/experimental/index.ts
CHANGED
@@ -10,11 +10,17 @@ export {
|
|
10
10
|
sendCalls,
|
11
11
|
} from './actions/sendCalls.js'
|
12
12
|
export {
|
13
|
-
type
|
14
|
-
type
|
15
|
-
type
|
16
|
-
|
17
|
-
} from './actions/
|
13
|
+
type GetCallsReceiptErrorType,
|
14
|
+
type GetCallsReceiptParameters,
|
15
|
+
type GetCallsReceiptReturnType,
|
16
|
+
getCallsReceipt,
|
17
|
+
} from './actions/getCallsReceipt.js'
|
18
|
+
export {
|
19
|
+
type WriteContractsErrorType,
|
20
|
+
type WriteContractsParameters,
|
21
|
+
type WriteContractsReturnType,
|
22
|
+
writeContracts,
|
23
|
+
} from './actions/writeContracts.js'
|
18
24
|
|
19
25
|
export {
|
20
26
|
type WalletActionsEip5792,
|
package/index.ts
CHANGED
@@ -1001,8 +1001,8 @@ export type {
|
|
1001
1001
|
TestRpcSchema,
|
1002
1002
|
WalletCapabilities,
|
1003
1003
|
WalletCapabilitiesRecord,
|
1004
|
-
|
1005
|
-
|
1004
|
+
WalletCallReceipt,
|
1005
|
+
WalletGetCallsReceiptReturnType,
|
1006
1006
|
WalletSendCallsParameters,
|
1007
1007
|
WalletPermissionCaveat,
|
1008
1008
|
WalletPermission,
|
package/package.json
CHANGED
package/types/contract.ts
CHANGED
@@ -209,7 +209,8 @@ export type ContractFunctionParameters<
|
|
209
209
|
| allFunctionNames // show all options
|
210
210
|
| (functionName extends allFunctionNames ? functionName : never) // infer value
|
211
211
|
args?: (abi extends Abi ? UnionWiden<args> : never) | allArgs | undefined
|
212
|
-
} & (readonly [] extends allArgs ? {} : { args: Widen<args> })
|
212
|
+
} & (readonly [] extends allArgs ? {} : { args: Widen<args> }) &
|
213
|
+
GetValue<abi, functionName>
|
213
214
|
|
214
215
|
export type ContractFunctionReturnType<
|
215
216
|
abi extends Abi | readonly unknown[] = Abi,
|
package/types/eip1193.ts
CHANGED
@@ -118,7 +118,7 @@ export type WalletCapabilitiesRecord<
|
|
118
118
|
[chainId in id]: capabilities
|
119
119
|
}
|
120
120
|
|
121
|
-
export type
|
121
|
+
export type WalletCallReceipt<quantity = Hex, status = Hex> = {
|
122
122
|
logs: {
|
123
123
|
address: Hex
|
124
124
|
data: Hex
|
@@ -131,9 +131,9 @@ export type WalletGetCallsStatusReceipt<quantity = Hex, status = Hex> = {
|
|
131
131
|
transactionHash: Hex
|
132
132
|
}
|
133
133
|
|
134
|
-
export type
|
134
|
+
export type WalletGetCallsReceiptReturnType<quantity = Hex, status = Hex> = {
|
135
135
|
status: 'PENDING' | 'CONFIRMED'
|
136
|
-
receipts?:
|
136
|
+
receipts?: WalletCallReceipt<quantity, status>[] | undefined
|
137
137
|
}
|
138
138
|
|
139
139
|
export type WalletPermissionCaveat = {
|
@@ -1319,13 +1319,13 @@ export type WalletRpcSchema = [
|
|
1319
1319
|
* @description Returns the status of a call batch that was sent via `wallet_sendCalls`.
|
1320
1320
|
* @link https://eips.ethereum.org/EIPS/eip-5792
|
1321
1321
|
* @example
|
1322
|
-
* provider.request({ method: '
|
1322
|
+
* provider.request({ method: 'wallet_getCallsReceipt' })
|
1323
1323
|
* // => { ... }
|
1324
1324
|
*/
|
1325
1325
|
{
|
1326
|
-
Method: '
|
1326
|
+
Method: 'wallet_getCallsReceipt'
|
1327
1327
|
Parameters?: string
|
1328
|
-
ReturnType:
|
1328
|
+
ReturnType: WalletGetCallsReceiptReturnType
|
1329
1329
|
},
|
1330
1330
|
/**
|
1331
1331
|
* @description Gets the connected wallet's capabilities.
|
@@ -30,13 +30,19 @@ export type FormatTransactionRequestErrorType = ErrorType
|
|
30
30
|
export function formatTransactionRequest(
|
31
31
|
request: ExactPartial<TransactionRequest>,
|
32
32
|
) {
|
33
|
-
const rpcRequest = {
|
33
|
+
const rpcRequest = {} as RpcTransactionRequest
|
34
34
|
|
35
|
-
if (
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
if (typeof request.accessList !== 'undefined')
|
36
|
+
rpcRequest.accessList = request.accessList
|
37
|
+
if (typeof request.blobs !== 'undefined') {
|
38
|
+
if (typeof request.blobs[0] !== 'string')
|
39
|
+
rpcRequest.blobs = (request.blobs as ByteArray[]).map((x) =>
|
40
|
+
bytesToHex(x),
|
41
|
+
)
|
42
|
+
else rpcRequest.blobs = request.blobs
|
43
|
+
}
|
44
|
+
if (typeof request.data !== 'undefined') rpcRequest.data = request.data
|
45
|
+
if (typeof request.from !== 'undefined') rpcRequest.from = request.from
|
40
46
|
if (typeof request.gas !== 'undefined')
|
41
47
|
rpcRequest.gas = numberToHex(request.gas)
|
42
48
|
if (typeof request.gasPrice !== 'undefined')
|
@@ -49,6 +55,7 @@ export function formatTransactionRequest(
|
|
49
55
|
rpcRequest.maxPriorityFeePerGas = numberToHex(request.maxPriorityFeePerGas)
|
50
56
|
if (typeof request.nonce !== 'undefined')
|
51
57
|
rpcRequest.nonce = numberToHex(request.nonce)
|
58
|
+
if (typeof request.to !== 'undefined') rpcRequest.to = request.to
|
52
59
|
if (typeof request.type !== 'undefined')
|
53
60
|
rpcRequest.type = rpcTransactionType[request.type]
|
54
61
|
if (typeof request.value !== 'undefined')
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../experimental/actions/getCallsStatus.ts"],"names":[],"mappings":";;;AAQA,gEAA6D;AAC7D,wFAA8E;AA8BvE,KAAK,UAAU,cAAc,CAIlC,MAAyC,EACzC,UAAoC;IAEpC,MAAM,EAAE,EAAE,EAAE,GAAG,UAAU,CAAA;IACzB,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAChD,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,EAAE;KACX,CAAC,CAAA;IACF,OAAO;QACL,MAAM;QACN,QAAQ,EACN,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YAC1B,GAAG,OAAO;YACV,WAAW,EAAE,IAAA,wBAAW,EAAC,OAAO,CAAC,WAAW,CAAC;YAC7C,OAAO,EAAE,IAAA,wBAAW,EAAC,OAAO,CAAC,OAAO,CAAC;YACrC,MAAM,EAAE,uCAAe,CAAC,OAAO,CAAC,MAAuB,CAAC;SACzD,CAAC,CAAC,IAAI,EAAE;KACZ,CAAA;AACH,CAAC;AAtBD,wCAsBC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../experimental/actions/getCallsStatus.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAA;AAU9E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAIlC,MAAyC,EACzC,UAAoC;IAEpC,MAAM,EAAE,EAAE,EAAE,GAAG,UAAU,CAAA;IACzB,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAChD,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,EAAE;KACX,CAAC,CAAA;IACF,OAAO;QACL,MAAM;QACN,QAAQ,EACN,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YAC1B,GAAG,OAAO;YACV,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC;YAC7C,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC;YACrC,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,MAAuB,CAAC;SACzD,CAAC,CAAC,IAAI,EAAE;KACZ,CAAA;AACH,CAAC"}
|
@@ -1,35 +0,0 @@
|
|
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';
|
6
|
-
import type { WalletGetCallsStatusReturnType } from '../../types/eip1193.js';
|
7
|
-
import type { Prettify } from '../../types/utils.js';
|
8
|
-
import type { RequestErrorType } from '../../utils/buildRequest.js';
|
9
|
-
export type GetCallsStatusParameters = {
|
10
|
-
id: string;
|
11
|
-
};
|
12
|
-
export type GetCallsStatusReturnType = Prettify<WalletGetCallsStatusReturnType<bigint, 'success' | 'reverted'>>;
|
13
|
-
export type GetCallsStatusErrorType = RequestErrorType | ErrorType;
|
14
|
-
/**
|
15
|
-
* Returns the status of a call batch that was sent via `sendCalls`.
|
16
|
-
*
|
17
|
-
* - Docs: https://viem.sh/eip5792/actions/getCallsStatus
|
18
|
-
* - JSON-RPC Methods: [`wallet_getCallsStatus`](https://eips.ethereum.org/EIPS/eip-5792)
|
19
|
-
*
|
20
|
-
* @param client - Client to use
|
21
|
-
* @returns Status of the calls. {@link GetCallsStatusReturnType}
|
22
|
-
*
|
23
|
-
* @example
|
24
|
-
* import { createWalletClient, custom } from 'viem'
|
25
|
-
* import { mainnet } from 'viem/chains'
|
26
|
-
* import { getCallsStatus } from 'viem/wallet'
|
27
|
-
*
|
28
|
-
* const client = createWalletClient({
|
29
|
-
* chain: mainnet,
|
30
|
-
* transport: custom(window.ethereum),
|
31
|
-
* })
|
32
|
-
* const { receipts, status } = await getCallsStatus(client, { id: '0xdeadbeef' })
|
33
|
-
*/
|
34
|
-
export declare function getCallsStatus<chain extends Chain | undefined, account extends Account | undefined = undefined>(client: Client<Transport, chain, account>, parameters: GetCallsStatusParameters): Promise<GetCallsStatusReturnType>;
|
35
|
-
//# sourceMappingURL=getCallsStatus.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getCallsStatus.d.ts","sourceRoot":"","sources":["../../../experimental/actions/getCallsStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAA;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAA;AAC5E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAInE,MAAM,MAAM,wBAAwB,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA;AAErD,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAC7C,8BAA8B,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,CAAC,CAC/D,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,gBAAgB,GAAG,SAAS,CAAA;AAElE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,cAAc,CAClC,KAAK,SAAS,KAAK,GAAG,SAAS,EAC/B,OAAO,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EAE/C,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,EACzC,UAAU,EAAE,wBAAwB,GACnC,OAAO,CAAC,wBAAwB,CAAC,CAgBnC"}
|