viem 0.0.0-main.20230708T001525 → 0.0.0-main.20230708T044110
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/dist/cjs/clients/createClient.js +19 -12
- package/dist/cjs/clients/createClient.js.map +1 -1
- package/dist/cjs/clients/createPublicClient.js +6 -7
- package/dist/cjs/clients/createPublicClient.js.map +1 -1
- package/dist/cjs/clients/createTestClient.js +9 -9
- package/dist/cjs/clients/createTestClient.js.map +1 -1
- package/dist/cjs/clients/createWalletClient.js +6 -6
- package/dist/cjs/clients/createWalletClient.js.map +1 -1
- package/dist/cjs/clients/decorators/public.js +44 -42
- package/dist/cjs/clients/decorators/public.js.map +1 -1
- package/dist/cjs/clients/decorators/wallet.js +17 -15
- package/dist/cjs/clients/decorators/wallet.js.map +1 -1
- package/dist/cjs/errors/version.js +1 -1
- package/dist/esm/clients/createClient.js +19 -15
- package/dist/esm/clients/createClient.js.map +1 -1
- package/dist/esm/clients/createPublicClient.js +6 -26
- package/dist/esm/clients/createPublicClient.js.map +1 -1
- package/dist/esm/clients/createTestClient.js +9 -32
- package/dist/esm/clients/createTestClient.js.map +1 -1
- package/dist/esm/clients/createWalletClient.js +6 -42
- package/dist/esm/clients/createWalletClient.js.map +1 -1
- package/dist/esm/clients/decorators/public.js +44 -42
- package/dist/esm/clients/decorators/public.js.map +1 -1
- package/dist/esm/clients/decorators/wallet.js +17 -15
- package/dist/esm/clients/decorators/wallet.js.map +1 -1
- package/dist/esm/errors/version.js +1 -1
- package/dist/types/clients/createClient.d.ts +29 -32
- package/dist/types/clients/createClient.d.ts.map +1 -1
- package/dist/types/clients/createPublicClient.d.ts +3 -3
- package/dist/types/clients/createPublicClient.d.ts.map +1 -1
- package/dist/types/clients/createTestClient.d.ts +9 -7
- package/dist/types/clients/createTestClient.d.ts.map +1 -1
- package/dist/types/clients/createWalletClient.d.ts +3 -3
- package/dist/types/clients/createWalletClient.d.ts.map +1 -1
- package/dist/types/clients/decorators/public.d.ts +1 -519
- package/dist/types/clients/decorators/public.d.ts.map +1 -1
- package/dist/types/clients/decorators/wallet.d.ts +1 -519
- package/dist/types/clients/decorators/wallet.d.ts.map +1 -1
- package/dist/types/errors/version.d.ts +1 -1
- package/dist/types/types/chain.d.ts +3 -4
- package/dist/types/types/chain.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/clients/createClient.ts +113 -89
- package/src/clients/createPublicClient.ts +26 -26
- package/src/clients/createTestClient.ts +41 -47
- package/src/clients/createWalletClient.ts +30 -33
- package/src/clients/decorators/public.ts +49 -44
- package/src/clients/decorators/wallet.ts +18 -16
- package/src/errors/version.ts +1 -1
- package/src/types/chain.ts +6 -7
@@ -1,7 +1,6 @@
|
|
1
|
-
import type { Address
|
1
|
+
import type { Address } from 'abitype'
|
2
2
|
|
3
3
|
import type { Account, JsonRpcAccount } from '../accounts/types.js'
|
4
|
-
import type { ParseAccount } from '../types/account.js'
|
5
4
|
import type { Chain } from '../types/chain.js'
|
6
5
|
import type {
|
7
6
|
EIP1193RequestFn,
|
@@ -13,60 +12,82 @@ import { parseAccount } from '../utils/accounts.js'
|
|
13
12
|
import { uid } from '../utils/uid.js'
|
14
13
|
import type { Transport } from './transports/createTransport.js'
|
15
14
|
|
16
|
-
export type MulticallBatchOptions = {
|
17
|
-
/** The maximum size (in bytes) for each calldata chunk. @default 1_024 */
|
18
|
-
batchSize?: number
|
19
|
-
/** The maximum number of milliseconds to wait before sending a batch. @default 0 */
|
20
|
-
wait?: number
|
21
|
-
}
|
22
|
-
|
23
15
|
export type ClientConfig<
|
24
|
-
|
25
|
-
|
26
|
-
|
16
|
+
transport extends Transport = Transport,
|
17
|
+
chain extends Chain | undefined = Chain | undefined,
|
18
|
+
accountOrAddress extends Account | Address | undefined =
|
27
19
|
| Account
|
28
20
|
| Address
|
29
21
|
| undefined,
|
30
22
|
> = {
|
31
23
|
/** The Account to use for the Client. This will be used for Actions that require an account as an argument. */
|
32
|
-
account?:
|
24
|
+
account?: accountOrAddress extends Account | Address
|
25
|
+
? accountOrAddress | Account | Address // `accountOrAddress` defined, add for inference
|
26
|
+
: Account | Address | undefined // `accountOrAddress` undefined, show possible types for autocomplete
|
33
27
|
/** Flags for batch settings. */
|
34
|
-
batch?:
|
35
|
-
|
36
|
-
|
37
|
-
|
28
|
+
batch?:
|
29
|
+
| {
|
30
|
+
/** Toggle to enable `eth_call` multicall aggregation. */
|
31
|
+
multicall?: boolean | Prettify<MulticallBatchOptions> | undefined
|
32
|
+
}
|
33
|
+
| undefined
|
38
34
|
/** Chain for the client. */
|
39
|
-
chain?:
|
35
|
+
chain?: chain extends Chain
|
36
|
+
? chain // `chain` defined, add for inference
|
37
|
+
: Chain | undefined // `chain` undefined, show possible types for autocomplete
|
40
38
|
/** A key for the client. */
|
41
|
-
key?: string
|
39
|
+
key?: string | undefined
|
42
40
|
/** A name for the client. */
|
43
|
-
name?: string
|
41
|
+
name?: string | undefined
|
44
42
|
/**
|
45
43
|
* Frequency (in ms) for polling enabled actions & events.
|
46
44
|
* @default 4_000
|
47
45
|
*/
|
48
|
-
pollingInterval?: number
|
46
|
+
pollingInterval?: number | undefined
|
49
47
|
/** The RPC transport */
|
50
|
-
transport:
|
48
|
+
transport: transport
|
51
49
|
/** The type of client. */
|
52
|
-
type?: string
|
50
|
+
type?: string | undefined
|
53
51
|
}
|
54
52
|
|
53
|
+
// TODO: Move `transport` to slot index 2 since `chain` and `account` used more frequently.
|
54
|
+
// Otherwise, we end up with a lot of `Client<Transport, chain, account>` in actions.
|
55
|
+
export type Client<
|
56
|
+
transport extends Transport = Transport,
|
57
|
+
chain extends Chain | undefined = Chain | undefined,
|
58
|
+
account extends Account | undefined = Account | undefined,
|
59
|
+
rpcSchema extends RpcSchema | undefined = undefined,
|
60
|
+
extended extends Extended | undefined = Extended | undefined,
|
61
|
+
> = Prettify<
|
62
|
+
Prettify<Client_Base<transport, chain, account, rpcSchema>> & {
|
63
|
+
extend: <const client extends Extended>(
|
64
|
+
fn: (
|
65
|
+
client: Client<transport, chain, account, rpcSchema, extended>,
|
66
|
+
) => client,
|
67
|
+
) => Prettify<
|
68
|
+
Client<
|
69
|
+
transport,
|
70
|
+
chain,
|
71
|
+
account,
|
72
|
+
rpcSchema,
|
73
|
+
Prettify<client> & (extended extends Extended ? extended : unknown)
|
74
|
+
>
|
75
|
+
>
|
76
|
+
} & (extended extends Extended ? extended : unknown)
|
77
|
+
>
|
78
|
+
|
55
79
|
type Client_Base<
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
80
|
+
transport extends Transport = Transport,
|
81
|
+
chain extends Chain | undefined = Chain | undefined,
|
82
|
+
account extends Account | undefined = Account | undefined,
|
83
|
+
rpcSchema extends RpcSchema | undefined = undefined,
|
60
84
|
> = {
|
61
85
|
/** The Account of the Client. */
|
62
|
-
account:
|
86
|
+
account: account
|
63
87
|
/** Flags for batch settings. */
|
64
|
-
batch?:
|
65
|
-
/** Toggle to enable `eth_call` multicall aggregation. */
|
66
|
-
multicall?: boolean | MulticallBatchOptions
|
67
|
-
}
|
88
|
+
batch?: ClientConfig['batch']
|
68
89
|
/** Chain for the client. */
|
69
|
-
chain:
|
90
|
+
chain: chain
|
70
91
|
/** A key for the client. */
|
71
92
|
key: string
|
72
93
|
/** A name for the client. */
|
@@ -74,86 +95,89 @@ type Client_Base<
|
|
74
95
|
/** Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds. */
|
75
96
|
pollingInterval: number
|
76
97
|
/** Request function wrapped with friendly error handling */
|
77
|
-
request:
|
78
|
-
?
|
79
|
-
|
98
|
+
request: EIP1193RequestFn<
|
99
|
+
rpcSchema extends undefined ? EIP1474Methods : rpcSchema
|
100
|
+
>
|
80
101
|
/** The RPC transport */
|
81
|
-
transport: ReturnType<
|
102
|
+
transport: ReturnType<transport>['config'] & ReturnType<transport>['value']
|
82
103
|
/** The type of client. */
|
83
104
|
type: string
|
84
105
|
/** A unique ID for the client. */
|
85
106
|
uid: string
|
86
107
|
}
|
87
108
|
|
88
|
-
type Extended =
|
89
|
-
|
90
|
-
}
|
109
|
+
type Extended = Prettify<
|
110
|
+
// disallow redefining base properties
|
111
|
+
{ [K in keyof Client_Base]?: undefined } & {
|
112
|
+
[key: string]: unknown
|
113
|
+
}
|
114
|
+
>
|
91
115
|
|
92
|
-
export type
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
> = Client_Base<TTransport, TChain, TAccount, TRpcSchema> & {
|
99
|
-
extend: <TNextExtended extends Extended = Extended>(
|
100
|
-
fn: (
|
101
|
-
client: Client<TTransport, TChain, TAccount, TRpcSchema, TExtended>,
|
102
|
-
) => Narrow<TNextExtended>,
|
103
|
-
) => Client<
|
104
|
-
TTransport,
|
105
|
-
TChain,
|
106
|
-
TAccount,
|
107
|
-
TRpcSchema,
|
108
|
-
(TExtended extends Extended ? TExtended : {}) & TNextExtended
|
109
|
-
>
|
110
|
-
} & (TExtended extends Extended ? TExtended : {})
|
116
|
+
export type MulticallBatchOptions = {
|
117
|
+
/** The maximum size (in bytes) for each calldata chunk. @default 1_024 */
|
118
|
+
batchSize?: number | undefined
|
119
|
+
/** The maximum number of milliseconds to wait before sending a batch. @default 0 */
|
120
|
+
wait?: number | undefined
|
121
|
+
}
|
111
122
|
|
112
123
|
/**
|
113
|
-
*
|
124
|
+
* Creates a base client with the given transport.
|
114
125
|
*/
|
115
126
|
export function createClient<
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
>(
|
120
|
-
|
121
|
-
|
122
|
-
chain,
|
123
|
-
key = 'base',
|
124
|
-
name = 'Base Client',
|
125
|
-
pollingInterval = 4_000,
|
127
|
+
transport extends Transport,
|
128
|
+
chain extends Chain | undefined = undefined,
|
129
|
+
accountOrAddress extends Account | Address | undefined = undefined,
|
130
|
+
>(
|
131
|
+
parameters: ClientConfig<transport, chain, accountOrAddress>,
|
132
|
+
): Client<
|
126
133
|
transport,
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
134
|
+
chain,
|
135
|
+
accountOrAddress extends Address
|
136
|
+
? Prettify<JsonRpcAccount<accountOrAddress>>
|
137
|
+
: accountOrAddress
|
138
|
+
>
|
139
|
+
|
140
|
+
export function createClient(parameters: ClientConfig): Client {
|
141
|
+
const {
|
142
|
+
batch,
|
143
|
+
key = 'base',
|
144
|
+
name = 'Base Client',
|
145
|
+
pollingInterval = 4_000,
|
146
|
+
type = 'base',
|
147
|
+
} = parameters
|
148
|
+
|
149
|
+
const chain = parameters.chain
|
150
|
+
const account = parameters.account
|
151
|
+
? parseAccount(parameters.account)
|
152
|
+
: undefined
|
153
|
+
const { config, request, value } = parameters.transport({
|
154
|
+
chain,
|
155
|
+
pollingInterval,
|
156
|
+
})
|
157
|
+
const transport = { ...config, ...value }
|
158
|
+
|
136
159
|
const client = {
|
137
|
-
account
|
138
|
-
? parseAccount(account)
|
139
|
-
: undefined) as ParseAccount<TAccountOrAddress>,
|
160
|
+
account,
|
140
161
|
batch,
|
141
|
-
chain
|
162
|
+
chain,
|
142
163
|
key,
|
143
164
|
name,
|
144
165
|
pollingInterval,
|
145
166
|
request,
|
146
|
-
transport
|
167
|
+
transport,
|
147
168
|
type,
|
148
169
|
uid: uid(),
|
149
170
|
}
|
150
|
-
|
151
|
-
|
152
|
-
|
171
|
+
|
172
|
+
function extend(base: typeof client) {
|
173
|
+
type ExtendFn = (base: typeof client) => unknown
|
174
|
+
return (extendFn: ExtendFn) => {
|
175
|
+
const extended = extendFn(base) as Extended
|
153
176
|
for (const key in client) delete extended[key]
|
154
|
-
const
|
155
|
-
return Object.assign(
|
177
|
+
const combined = { ...base, ...extended }
|
178
|
+
return Object.assign(combined, { extend: extend(combined) })
|
156
179
|
}
|
157
180
|
}
|
181
|
+
|
158
182
|
return Object.assign(client, { extend: extend(client) as any })
|
159
183
|
}
|
@@ -6,23 +6,25 @@ import { type PublicActions, publicActions } from './decorators/public.js'
|
|
6
6
|
import type { Transport } from './transports/createTransport.js'
|
7
7
|
|
8
8
|
export type PublicClientConfig<
|
9
|
-
|
10
|
-
|
11
|
-
> =
|
12
|
-
|
13
|
-
|
9
|
+
transport extends Transport = Transport,
|
10
|
+
chain extends Chain | undefined = Chain | undefined,
|
11
|
+
> = Prettify<
|
12
|
+
Pick<
|
13
|
+
ClientConfig<transport, chain>,
|
14
|
+
'batch' | 'chain' | 'key' | 'name' | 'pollingInterval' | 'transport'
|
15
|
+
>
|
14
16
|
>
|
15
17
|
|
16
18
|
export type PublicClient<
|
17
|
-
|
18
|
-
|
19
|
+
transport extends Transport = Transport,
|
20
|
+
chain extends Chain | undefined = Chain | undefined,
|
19
21
|
> = Prettify<
|
20
22
|
Client<
|
21
|
-
|
22
|
-
|
23
|
+
transport,
|
24
|
+
chain,
|
23
25
|
undefined,
|
24
26
|
PublicRpcSchema,
|
25
|
-
PublicActions<
|
27
|
+
PublicActions<transport, chain>
|
26
28
|
>
|
27
29
|
>
|
28
30
|
|
@@ -46,23 +48,21 @@ export type PublicClient<
|
|
46
48
|
* })
|
47
49
|
*/
|
48
50
|
export function createPublicClient<
|
49
|
-
|
50
|
-
|
51
|
-
>(
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
chain,
|
51
|
+
transport extends Transport,
|
52
|
+
chain extends Chain | undefined = undefined,
|
53
|
+
>(
|
54
|
+
parameters: PublicClientConfig<transport, chain>,
|
55
|
+
): PublicClient<transport, chain>
|
56
|
+
|
57
|
+
export function createPublicClient(
|
58
|
+
parameters: PublicClientConfig,
|
59
|
+
): PublicClient {
|
60
|
+
const { key = 'public', name = 'Public Client' } = parameters
|
61
|
+
const client = createClient({
|
62
|
+
...parameters,
|
62
63
|
key,
|
63
64
|
name,
|
64
|
-
pollingInterval,
|
65
|
-
transport,
|
66
65
|
type: 'publicClient',
|
67
|
-
})
|
66
|
+
})
|
67
|
+
return client.extend(publicActions)
|
68
68
|
}
|
@@ -2,6 +2,7 @@ import type { Account } from '../accounts/types.js'
|
|
2
2
|
import type { ParseAccount } from '../types/account.js'
|
3
3
|
import type { Chain } from '../types/chain.js'
|
4
4
|
import type { TestRpcSchema } from '../types/eip1193.js'
|
5
|
+
import type { Prettify } from '../types/utils.js'
|
5
6
|
import { type Client, type ClientConfig, createClient } from './createClient.js'
|
6
7
|
import { type TestActions, testActions } from './decorators/test.js'
|
7
8
|
import type { Transport } from './transports/createTransport.js'
|
@@ -10,36 +11,38 @@ import type { Address } from 'abitype'
|
|
10
11
|
export type TestClientMode = 'anvil' | 'hardhat' | 'ganache'
|
11
12
|
|
12
13
|
export type TestClientConfig<
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
mode extends TestClientMode = TestClientMode,
|
15
|
+
transport extends Transport = Transport,
|
16
|
+
chain extends Chain | undefined = Chain | undefined,
|
17
|
+
accountOrAddress extends Account | Address | undefined =
|
17
18
|
| Account
|
18
19
|
| Address
|
19
20
|
| undefined,
|
20
|
-
> =
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
> = Prettify<
|
22
|
+
Pick<
|
23
|
+
ClientConfig<transport, chain, accountOrAddress>,
|
24
|
+
'account' | 'chain' | 'key' | 'name' | 'pollingInterval' | 'transport'
|
25
|
+
> & {
|
26
|
+
/** Mode of the test client. */
|
27
|
+
mode: mode | ('anvil' | 'hardhat' | 'ganache') // TODO: Type utility that expands `TestClientMode`
|
28
|
+
}
|
29
|
+
>
|
27
30
|
|
28
31
|
export type TestClient<
|
29
32
|
TMode extends TestClientMode = TestClientMode,
|
30
|
-
|
31
|
-
|
33
|
+
transport extends Transport = Transport,
|
34
|
+
chain extends Chain | undefined = Chain | undefined,
|
32
35
|
TAccount extends Account | undefined = Account | undefined,
|
33
36
|
TIncludeActions extends boolean = true,
|
34
|
-
> =
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
> = Prettify<
|
38
|
+
{ mode: TMode } & Client<
|
39
|
+
transport,
|
40
|
+
chain,
|
41
|
+
TAccount,
|
42
|
+
TestRpcSchema<TMode>,
|
43
|
+
TIncludeActions extends true ? TestActions : Record<string, unknown>
|
44
|
+
>
|
45
|
+
>
|
43
46
|
|
44
47
|
/**
|
45
48
|
* @description Creates a test client with a given transport.
|
@@ -65,33 +68,24 @@ export type TestClient<
|
|
65
68
|
* })
|
66
69
|
*/
|
67
70
|
export function createTestClient<
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
>(
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
mode
|
78
|
-
|
79
|
-
|
80
|
-
}: TestClientConfig<TMode, TTransport, TChain, TAccountOrAddress>): TestClient<
|
81
|
-
TMode,
|
82
|
-
TTransport,
|
83
|
-
TChain,
|
84
|
-
ParseAccount<TAccountOrAddress>
|
85
|
-
> {
|
86
|
-
return createClient({
|
87
|
-
account,
|
88
|
-
chain,
|
71
|
+
mode extends 'anvil' | 'hardhat' | 'ganache', // TODO: Type utility that expands `TestClientMode`
|
72
|
+
transport extends Transport,
|
73
|
+
chain extends Chain | undefined = undefined,
|
74
|
+
accountOrAddress extends Account | Address | undefined = undefined,
|
75
|
+
>(
|
76
|
+
parameters: TestClientConfig<mode, transport, chain, accountOrAddress>,
|
77
|
+
): TestClient<mode, transport, chain, ParseAccount<accountOrAddress>>
|
78
|
+
|
79
|
+
export function createTestClient(parameters: TestClientConfig): TestClient {
|
80
|
+
const { key = 'test', name = 'Test Client', mode } = parameters
|
81
|
+
const client = createClient({
|
82
|
+
...parameters,
|
89
83
|
key,
|
90
84
|
name,
|
91
|
-
pollingInterval,
|
92
|
-
transport,
|
93
85
|
type: 'testClient',
|
94
86
|
})
|
95
|
-
|
96
|
-
|
87
|
+
return client.extend((config) => ({
|
88
|
+
mode,
|
89
|
+
...testActions({ mode })(config),
|
90
|
+
}))
|
97
91
|
}
|
@@ -10,28 +10,30 @@ import { type WalletActions, walletActions } from './decorators/wallet.js'
|
|
10
10
|
import type { Transport } from './transports/createTransport.js'
|
11
11
|
|
12
12
|
export type WalletClientConfig<
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
transport extends Transport = Transport,
|
14
|
+
chain extends Chain | undefined = Chain | undefined,
|
15
|
+
accountOrAddress extends Account | Address | undefined =
|
16
16
|
| Account
|
17
17
|
| Address
|
18
18
|
| undefined,
|
19
|
-
> =
|
20
|
-
|
21
|
-
|
19
|
+
> = Prettify<
|
20
|
+
Pick<
|
21
|
+
ClientConfig<transport, chain, accountOrAddress>,
|
22
|
+
'account' | 'chain' | 'key' | 'name' | 'pollingInterval' | 'transport'
|
23
|
+
>
|
22
24
|
>
|
23
25
|
|
24
26
|
export type WalletClient<
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
transport extends Transport = Transport,
|
28
|
+
chain extends Chain | undefined = Chain | undefined,
|
29
|
+
account extends Account | undefined = Account | undefined,
|
28
30
|
> = Prettify<
|
29
31
|
Client<
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
transport,
|
33
|
+
chain,
|
34
|
+
account,
|
33
35
|
WalletRpcSchema,
|
34
|
-
WalletActions<
|
36
|
+
WalletActions<chain, account>
|
35
37
|
>
|
36
38
|
>
|
37
39
|
|
@@ -72,28 +74,23 @@ export type WalletClient<
|
|
72
74
|
* })
|
73
75
|
*/
|
74
76
|
export function createWalletClient<
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
>(
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
ParseAccount<TAccountOrAddress>
|
89
|
-
> {
|
90
|
-
return createClient({
|
91
|
-
account,
|
92
|
-
chain,
|
77
|
+
transport extends Transport,
|
78
|
+
chain extends Chain | undefined = undefined,
|
79
|
+
accountOrAddress extends Account | Address | undefined = undefined,
|
80
|
+
>(
|
81
|
+
parameters: WalletClientConfig<transport, chain, accountOrAddress>,
|
82
|
+
): WalletClient<transport, chain, ParseAccount<accountOrAddress>>
|
83
|
+
|
84
|
+
export function createWalletClient(
|
85
|
+
parameters: WalletClientConfig,
|
86
|
+
): WalletClient {
|
87
|
+
const { key = 'wallet', name = 'Wallet Client', transport } = parameters
|
88
|
+
const client = createClient({
|
89
|
+
...parameters,
|
93
90
|
key,
|
94
91
|
name,
|
95
|
-
pollingInterval,
|
96
92
|
transport: (opts) => transport({ ...opts, retryCount: 0 }),
|
97
93
|
type: 'walletClient',
|
98
|
-
})
|
94
|
+
})
|
95
|
+
return client.extend(walletActions)
|
99
96
|
}
|
@@ -1374,52 +1374,57 @@ export type PublicActions<
|
|
1374
1374
|
) => WatchPendingTransactionsReturnType
|
1375
1375
|
}
|
1376
1376
|
|
1377
|
-
export
|
1377
|
+
export function publicActions<
|
1378
1378
|
TTransport extends Transport = Transport,
|
1379
1379
|
TChain extends Chain | undefined = Chain | undefined,
|
1380
1380
|
TAccount extends Account | undefined = Account | undefined,
|
1381
1381
|
>(
|
1382
1382
|
client: Client<TTransport, TChain, TAccount>,
|
1383
|
-
): PublicActions<TTransport, TChain, TAccount>
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1383
|
+
): PublicActions<TTransport, TChain, TAccount> {
|
1384
|
+
return {
|
1385
|
+
call: (args) => call(client, args),
|
1386
|
+
createBlockFilter: () => createBlockFilter(client),
|
1387
|
+
createContractEventFilter: (args) =>
|
1388
|
+
createContractEventFilter(client, args),
|
1389
|
+
createEventFilter: (args) => createEventFilter(client, args),
|
1390
|
+
createPendingTransactionFilter: () =>
|
1391
|
+
createPendingTransactionFilter(client),
|
1392
|
+
estimateContractGas: (args) => estimateContractGas(client, args as any),
|
1393
|
+
estimateGas: (args) => estimateGas(client, args),
|
1394
|
+
getBalance: (args) => getBalance(client, args),
|
1395
|
+
getBlock: (args) => getBlock(client, args),
|
1396
|
+
getBlockNumber: (args) => getBlockNumber(client, args),
|
1397
|
+
getBlockTransactionCount: (args) => getBlockTransactionCount(client, args),
|
1398
|
+
getBytecode: (args) => getBytecode(client, args),
|
1399
|
+
getChainId: () => getChainId(client),
|
1400
|
+
getEnsAddress: (args) => getEnsAddress(client, args),
|
1401
|
+
getEnsAvatar: (args) => getEnsAvatar(client, args),
|
1402
|
+
getEnsName: (args) => getEnsName(client, args),
|
1403
|
+
getEnsResolver: (args) => getEnsResolver(client, args),
|
1404
|
+
getEnsText: (args) => getEnsText(client, args),
|
1405
|
+
getFeeHistory: (args) => getFeeHistory(client, args),
|
1406
|
+
getFilterChanges: (args) => getFilterChanges(client, args),
|
1407
|
+
getFilterLogs: (args) => getFilterLogs(client, args),
|
1408
|
+
getGasPrice: () => getGasPrice(client),
|
1409
|
+
getLogs: (args) => getLogs(client, args),
|
1410
|
+
getStorageAt: (args) => getStorageAt(client, args),
|
1411
|
+
getTransaction: (args) => getTransaction(client, args),
|
1412
|
+
getTransactionConfirmations: (args) =>
|
1413
|
+
getTransactionConfirmations(client, args),
|
1414
|
+
getTransactionCount: (args) => getTransactionCount(client, args),
|
1415
|
+
getTransactionReceipt: (args) => getTransactionReceipt(client, args),
|
1416
|
+
multicall: (args) => multicall(client, args),
|
1417
|
+
readContract: (args) => readContract(client, args),
|
1418
|
+
simulateContract: (args) => simulateContract(client, args),
|
1419
|
+
verifyMessage: (args) => verifyMessage(client, args),
|
1420
|
+
verifyTypedData: (args) => verifyTypedData(client, args),
|
1421
|
+
uninstallFilter: (args) => uninstallFilter(client, args),
|
1422
|
+
waitForTransactionReceipt: (args) =>
|
1423
|
+
waitForTransactionReceipt(client, args),
|
1424
|
+
watchBlocks: (args) => watchBlocks(client, args),
|
1425
|
+
watchBlockNumber: (args) => watchBlockNumber(client, args),
|
1426
|
+
watchContractEvent: (args) => watchContractEvent(client, args),
|
1427
|
+
watchEvent: (args) => watchEvent(client, args),
|
1428
|
+
watchPendingTransactions: (args) => watchPendingTransactions(client, args),
|
1429
|
+
}
|
1430
|
+
}
|