viem 2.21.27 → 2.21.28
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +8 -0
- package/_cjs/actions/wallet/sendTransaction.js +35 -11
- package/_cjs/actions/wallet/sendTransaction.js.map +1 -1
- package/_cjs/actions/wallet/writeContract.js +3 -3
- package/_cjs/actions/wallet/writeContract.js.map +1 -1
- package/_cjs/chains/definitions/kakarotStarknetSepolia.js +1 -1
- package/_cjs/chains/definitions/kakarotStarknetSepolia.js.map +1 -1
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/experimental/eip5792/actions/getCapabilities.js +2 -3
- package/_cjs/experimental/eip5792/actions/getCapabilities.js.map +1 -1
- package/_cjs/experimental/eip5792/decorators/eip5792.js.map +1 -1
- package/_esm/actions/wallet/sendTransaction.js +37 -11
- package/_esm/actions/wallet/sendTransaction.js.map +1 -1
- package/_esm/actions/wallet/writeContract.js +3 -3
- package/_esm/actions/wallet/writeContract.js.map +1 -1
- package/_esm/chains/definitions/kakarotStarknetSepolia.js +1 -1
- package/_esm/chains/definitions/kakarotStarknetSepolia.js.map +1 -1
- package/_esm/chains/index.js +1 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/experimental/eip5792/actions/getCapabilities.js +2 -3
- package/_esm/experimental/eip5792/actions/getCapabilities.js.map +1 -1
- package/_esm/experimental/eip5792/decorators/eip5792.js.map +1 -1
- package/_types/actions/wallet/prepareTransactionRequest.d.ts +1 -1
- package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
- package/_types/actions/wallet/sendTransaction.d.ts +2 -1
- package/_types/actions/wallet/sendTransaction.d.ts.map +1 -1
- package/_types/actions/wallet/writeContract.d.ts +2 -2
- package/_types/actions/wallet/writeContract.d.ts.map +1 -1
- package/_types/chains/definitions/kakarotStarknetSepolia.d.ts +1 -1
- package/_types/chains/definitions/kakarotStarknetSepolia.d.ts.map +1 -1
- package/_types/chains/index.d.ts +1 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/transaction.d.ts +1 -1
- package/_types/errors/transaction.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/experimental/eip5792/actions/getCapabilities.d.ts +6 -9
- package/_types/experimental/eip5792/actions/getCapabilities.d.ts.map +1 -1
- package/_types/experimental/eip5792/decorators/eip5792.d.ts +1 -1
- package/_types/experimental/eip5792/decorators/eip5792.d.ts.map +1 -1
- package/_types/types/account.d.ts +4 -8
- package/_types/types/account.d.ts.map +1 -1
- package/_types/utils/errors/getTransactionError.d.ts +1 -1
- package/_types/utils/errors/getTransactionError.d.ts.map +1 -1
- package/actions/wallet/prepareTransactionRequest.ts +1 -1
- package/actions/wallet/sendTransaction.ts +50 -15
- package/actions/wallet/writeContract.ts +5 -5
- package/chains/definitions/kakarotStarknetSepolia.ts +1 -1
- package/chains/index.ts +1 -0
- package/errors/transaction.ts +1 -1
- package/errors/version.ts +1 -1
- package/experimental/eip5792/actions/getCapabilities.ts +10 -21
- package/experimental/eip5792/decorators/eip5792.ts +1 -3
- package/package.json +1 -1
- package/types/account.ts +17 -6
- package/utils/errors/getTransactionError.ts +1 -1
@@ -1,9 +1,11 @@
|
|
1
|
+
import type { Address } from 'abitype'
|
2
|
+
|
1
3
|
import { parseAccount } from '../../../accounts/utils/parseAccount.js'
|
2
4
|
import type { Client } from '../../../clients/createClient.js'
|
3
5
|
import type { Transport } from '../../../clients/transports/createTransport.js'
|
4
6
|
import { AccountNotFoundError } from '../../../errors/account.js'
|
5
7
|
import type { ErrorType } from '../../../errors/utils.js'
|
6
|
-
import type { Account
|
8
|
+
import type { Account } from '../../../types/account.js'
|
7
9
|
import type { Chain } from '../../../types/chain.js'
|
8
10
|
import type {
|
9
11
|
WalletCapabilities,
|
@@ -12,9 +14,9 @@ import type {
|
|
12
14
|
import type { Prettify } from '../../../types/utils.js'
|
13
15
|
import type { RequestErrorType } from '../../../utils/buildRequest.js'
|
14
16
|
|
15
|
-
export type GetCapabilitiesParameters
|
16
|
-
account
|
17
|
-
|
17
|
+
export type GetCapabilitiesParameters = {
|
18
|
+
account?: Account | Address | undefined
|
19
|
+
}
|
18
20
|
|
19
21
|
export type GetCapabilitiesReturnType = Prettify<
|
20
22
|
WalletCapabilitiesRecord<WalletCapabilities, number>
|
@@ -42,24 +44,11 @@ export type GetCapabilitiesErrorType = RequestErrorType | ErrorType
|
|
42
44
|
* })
|
43
45
|
* const capabilities = await getCapabilities(client)
|
44
46
|
*/
|
45
|
-
export async function getCapabilities<
|
46
|
-
|
47
|
-
|
48
|
-
>(
|
49
|
-
...parameters: account extends Account
|
50
|
-
?
|
51
|
-
| [client: Client<Transport, chain, account>]
|
52
|
-
| [
|
53
|
-
client: Client<Transport, chain, account>,
|
54
|
-
parameters: GetCapabilitiesParameters<account>,
|
55
|
-
]
|
56
|
-
: [
|
57
|
-
client: Client<Transport, chain, account>,
|
58
|
-
parameters: GetCapabilitiesParameters<account>,
|
59
|
-
]
|
47
|
+
export async function getCapabilities<chain extends Chain | undefined>(
|
48
|
+
client: Client<Transport, chain>,
|
49
|
+
parameters: GetCapabilitiesParameters = {},
|
60
50
|
): Promise<GetCapabilitiesReturnType> {
|
61
|
-
const
|
62
|
-
const account_raw = args?.account ?? client.account
|
51
|
+
const account_raw = parameters?.account ?? client.account
|
63
52
|
|
64
53
|
if (!account_raw) throw new AccountNotFoundError()
|
65
54
|
const account = parseAccount(account_raw)
|
@@ -80,9 +80,7 @@ export type Eip5792Actions<
|
|
80
80
|
* })
|
81
81
|
*/
|
82
82
|
getCapabilities: (
|
83
|
-
|
84
|
-
? [] | [parameters: GetCapabilitiesParameters<account>]
|
85
|
-
: [parameters: GetCapabilitiesParameters<undefined>]
|
83
|
+
parameters?: GetCapabilitiesParameters,
|
86
84
|
) => Promise<GetCapabilitiesReturnType>
|
87
85
|
/**
|
88
86
|
* Requests the connected wallet to send a batch of calls.
|
package/package.json
CHANGED
package/types/account.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { Address } from 'abitype'
|
2
2
|
|
3
3
|
import type { Account, JsonRpcAccount } from '../accounts/types.js'
|
4
|
-
import type { IsUndefined, Prettify } from './utils.js'
|
4
|
+
import type { IsUndefined, MaybeRequired, Prettify } from './utils.js'
|
5
5
|
|
6
6
|
export type DeriveAccount<
|
7
7
|
account extends Account | undefined,
|
@@ -12,11 +12,22 @@ export type GetAccountParameter<
|
|
12
12
|
account extends Account | undefined = Account | undefined,
|
13
13
|
accountOverride extends Account | Address | undefined = Account | Address,
|
14
14
|
required extends boolean = true,
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
nullish extends boolean = false,
|
16
|
+
> = MaybeRequired<
|
17
|
+
{
|
18
|
+
account?:
|
19
|
+
| accountOverride
|
20
|
+
| Account
|
21
|
+
| Address
|
22
|
+
| (nullish extends true ? null : never)
|
23
|
+
| undefined
|
24
|
+
},
|
25
|
+
IsUndefined<account> extends true
|
26
|
+
? required extends true
|
27
|
+
? true
|
28
|
+
: false
|
29
|
+
: false
|
30
|
+
>
|
20
31
|
|
21
32
|
export type ParseAccount<
|
22
33
|
accountOrAddress extends Account | Address | undefined =
|