viem 1.2.13 → 1.2.15
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/actions/ens/getEnsAddress.js +4 -7
- package/dist/cjs/actions/ens/getEnsAddress.js.map +1 -1
- package/dist/cjs/actions/ens/getEnsName.js +6 -20
- package/dist/cjs/actions/ens/getEnsName.js.map +1 -1
- package/dist/cjs/actions/ens/getEnsText.js +31 -23
- package/dist/cjs/actions/ens/getEnsText.js.map +1 -1
- package/dist/cjs/clients/createClient.js.map +1 -1
- package/dist/cjs/constants/abis.js +30 -2
- package/dist/cjs/constants/abis.js.map +1 -1
- package/dist/cjs/errors/version.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/test.js.map +1 -1
- package/dist/cjs/utils/ens/errors.js +24 -0
- package/dist/cjs/utils/ens/errors.js.map +1 -0
- package/dist/esm/actions/ens/getEnsAddress.js +5 -8
- package/dist/esm/actions/ens/getEnsAddress.js.map +1 -1
- package/dist/esm/actions/ens/getEnsName.js +6 -21
- package/dist/esm/actions/ens/getEnsName.js.map +1 -1
- package/dist/esm/actions/ens/getEnsText.js +32 -24
- package/dist/esm/actions/ens/getEnsText.js.map +1 -1
- package/dist/esm/clients/createClient.js.map +1 -1
- package/dist/esm/constants/abis.js +29 -1
- package/dist/esm/constants/abis.js.map +1 -1
- package/dist/esm/errors/version.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/test.js +4 -4
- package/dist/esm/test.js.map +1 -1
- package/dist/esm/utils/ens/errors.js +25 -0
- package/dist/esm/utils/ens/errors.js.map +1 -0
- package/dist/types/actions/ens/getEnsAddress.d.ts.map +1 -1
- package/dist/types/actions/ens/getEnsName.d.ts.map +1 -1
- package/dist/types/actions/ens/getEnsText.d.ts.map +1 -1
- package/dist/types/clients/createClient.d.ts +6 -6
- package/dist/types/clients/createClient.d.ts.map +1 -1
- package/dist/types/constants/abis.d.ts +39 -1
- package/dist/types/constants/abis.d.ts.map +1 -1
- package/dist/types/errors/version.d.ts +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/test.d.ts +4 -4
- package/dist/types/test.d.ts.map +1 -1
- package/dist/types/utils/ens/errors.d.ts +2 -0
- package/dist/types/utils/ens/errors.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/actions/ens/getEnsAddress.ts +4 -13
- package/src/actions/ens/getEnsName.ts +6 -27
- package/src/actions/ens/getEnsText.ts +32 -23
- package/src/clients/createClient.ts +19 -24
- package/src/constants/abis.ts +31 -1
- package/src/errors/version.ts +1 -1
- package/src/index.ts +4 -0
- package/src/test.ts +16 -4
- package/src/utils/ens/errors.ts +27 -0
|
@@ -21,9 +21,7 @@ export type ClientConfig<
|
|
|
21
21
|
| undefined,
|
|
22
22
|
> = {
|
|
23
23
|
/** The Account to use for the Client. This will be used for Actions that require an account as an argument. */
|
|
24
|
-
account?: accountOrAddress
|
|
25
|
-
? accountOrAddress | Account | Address // `accountOrAddress` defined, add for inference
|
|
26
|
-
: Account | Address | undefined // `accountOrAddress` undefined, show possible types for autocomplete
|
|
24
|
+
account?: accountOrAddress | Account | Address | undefined
|
|
27
25
|
/** Flags for batch settings. */
|
|
28
26
|
batch?:
|
|
29
27
|
| {
|
|
@@ -32,9 +30,7 @@ export type ClientConfig<
|
|
|
32
30
|
}
|
|
33
31
|
| undefined
|
|
34
32
|
/** Chain for the client. */
|
|
35
|
-
chain?:
|
|
36
|
-
? chain // `chain` defined, add for inference
|
|
37
|
-
: Chain | undefined // `chain` undefined, show possible types for autocomplete
|
|
33
|
+
chain?: Chain | undefined | chain
|
|
38
34
|
/** A key for the client. */
|
|
39
35
|
key?: string | undefined
|
|
40
36
|
/** A name for the client. */
|
|
@@ -58,23 +54,20 @@ export type Client<
|
|
|
58
54
|
account extends Account | undefined = Account | undefined,
|
|
59
55
|
rpcSchema extends RpcSchema | undefined = undefined,
|
|
60
56
|
extended extends Extended | undefined = Extended | undefined,
|
|
61
|
-
> =
|
|
62
|
-
|
|
57
|
+
> = Client_Base<transport, chain, account, rpcSchema> &
|
|
58
|
+
(extended extends Extended ? extended : unknown) & {
|
|
63
59
|
extend: <const client extends Extended>(
|
|
64
60
|
fn: (
|
|
65
61
|
client: Client<transport, chain, account, rpcSchema, extended>,
|
|
66
62
|
) => client,
|
|
67
|
-
) =>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
Prettify<client> & (extended extends Extended ? extended : unknown)
|
|
74
|
-
>
|
|
63
|
+
) => Client<
|
|
64
|
+
transport,
|
|
65
|
+
chain,
|
|
66
|
+
account,
|
|
67
|
+
rpcSchema,
|
|
68
|
+
Prettify<client> & (extended extends Extended ? extended : unknown)
|
|
75
69
|
>
|
|
76
|
-
}
|
|
77
|
-
>
|
|
70
|
+
}
|
|
78
71
|
|
|
79
72
|
type Client_Base<
|
|
80
73
|
transport extends Transport = Transport,
|
|
@@ -129,12 +122,14 @@ export function createClient<
|
|
|
129
122
|
accountOrAddress extends Account | Address | undefined = undefined,
|
|
130
123
|
>(
|
|
131
124
|
parameters: ClientConfig<transport, chain, accountOrAddress>,
|
|
132
|
-
):
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
125
|
+
): Prettify<
|
|
126
|
+
Client<
|
|
127
|
+
transport,
|
|
128
|
+
chain,
|
|
129
|
+
accountOrAddress extends Address
|
|
130
|
+
? Prettify<JsonRpcAccount<accountOrAddress>>
|
|
131
|
+
: accountOrAddress
|
|
132
|
+
>
|
|
138
133
|
>
|
|
139
134
|
|
|
140
135
|
export function createClient(parameters: ClientConfig): Client {
|
package/src/constants/abis.ts
CHANGED
|
@@ -43,7 +43,21 @@ export const multicall3Abi = [
|
|
|
43
43
|
},
|
|
44
44
|
] as const
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
const universalResolverErrors = [
|
|
47
|
+
{
|
|
48
|
+
inputs: [],
|
|
49
|
+
name: 'ResolverNotFound',
|
|
50
|
+
type: 'error',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
inputs: [],
|
|
54
|
+
name: 'ResolverWildcardNotSupported',
|
|
55
|
+
type: 'error',
|
|
56
|
+
},
|
|
57
|
+
] as const
|
|
58
|
+
|
|
59
|
+
export const universalResolverResolveAbi = [
|
|
60
|
+
...universalResolverErrors,
|
|
47
61
|
{
|
|
48
62
|
name: 'resolve',
|
|
49
63
|
type: 'function',
|
|
@@ -59,6 +73,22 @@ export const universalResolverAbi = [
|
|
|
59
73
|
},
|
|
60
74
|
] as const
|
|
61
75
|
|
|
76
|
+
export const universalResolverReverseAbi = [
|
|
77
|
+
...universalResolverErrors,
|
|
78
|
+
{
|
|
79
|
+
name: 'reverse',
|
|
80
|
+
type: 'function',
|
|
81
|
+
stateMutability: 'view',
|
|
82
|
+
inputs: [{ type: 'bytes', name: 'reverseName' }],
|
|
83
|
+
outputs: [
|
|
84
|
+
{ type: 'string', name: 'resolvedName' },
|
|
85
|
+
{ type: 'address', name: 'resolvedAddress' },
|
|
86
|
+
{ type: 'address', name: 'reverseResolver' },
|
|
87
|
+
{ type: 'address', name: 'resolver' },
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
] as const
|
|
91
|
+
|
|
62
92
|
export const textResolverAbi = [
|
|
63
93
|
{
|
|
64
94
|
name: 'text',
|
package/src/errors/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.2.
|
|
1
|
+
export const version = '1.2.15'
|
package/src/index.ts
CHANGED
|
@@ -55,6 +55,7 @@ export type {
|
|
|
55
55
|
DeployContractReturnType,
|
|
56
56
|
} from './actions/wallet/deployContract.js'
|
|
57
57
|
export type { DropTransactionParameters } from './actions/test/dropTransaction.js'
|
|
58
|
+
export type { GetAutomineReturnType } from './actions/test/getAutomine.js'
|
|
58
59
|
export type {
|
|
59
60
|
EstimateContractGasParameters,
|
|
60
61
|
EstimateContractGasReturnType,
|
|
@@ -181,6 +182,9 @@ export type {
|
|
|
181
182
|
RequestPermissionsReturnType,
|
|
182
183
|
RequestPermissionsParameters,
|
|
183
184
|
} from './actions/wallet/requestPermissions.js'
|
|
185
|
+
export type { GetTxpoolContentReturnType } from './actions/test/getTxpoolContent.js'
|
|
186
|
+
export type { GetTxpoolStatusReturnType } from './actions/test/getTxpoolStatus.js'
|
|
187
|
+
export type { InspectTxpoolReturnType } from './actions/test/inspectTxpool.js'
|
|
184
188
|
export type { ResetParameters } from './actions/test/reset.js'
|
|
185
189
|
export type { RevertParameters } from './actions/test/revert.js'
|
|
186
190
|
export type {
|
package/src/test.ts
CHANGED
|
@@ -2,9 +2,18 @@ export {
|
|
|
2
2
|
dropTransaction,
|
|
3
3
|
type DropTransactionParameters,
|
|
4
4
|
} from './actions/test/dropTransaction.js'
|
|
5
|
-
export {
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export {
|
|
6
|
+
getAutomine,
|
|
7
|
+
type GetAutomineReturnType,
|
|
8
|
+
} from './actions/test/getAutomine.js'
|
|
9
|
+
export {
|
|
10
|
+
getTxpoolContent,
|
|
11
|
+
type GetTxpoolContentReturnType,
|
|
12
|
+
} from './actions/test/getTxpoolContent.js'
|
|
13
|
+
export {
|
|
14
|
+
getTxpoolStatus,
|
|
15
|
+
type GetTxpoolStatusReturnType,
|
|
16
|
+
} from './actions/test/getTxpoolStatus.js'
|
|
8
17
|
export {
|
|
9
18
|
impersonateAccount,
|
|
10
19
|
type ImpersonateAccountParameters,
|
|
@@ -13,7 +22,10 @@ export {
|
|
|
13
22
|
increaseTime,
|
|
14
23
|
type IncreaseTimeParameters,
|
|
15
24
|
} from './actions/test/increaseTime.js'
|
|
16
|
-
export {
|
|
25
|
+
export {
|
|
26
|
+
inspectTxpool,
|
|
27
|
+
type InspectTxpoolReturnType,
|
|
28
|
+
} from './actions/test/inspectTxpool.js'
|
|
17
29
|
export { mine, type MineParameters } from './actions/test/mine.js'
|
|
18
30
|
export { removeBlockTimestampInterval } from './actions/test/removeBlockTimestampInterval.js'
|
|
19
31
|
export { reset, type ResetParameters } from './actions/test/reset.js'
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { panicReasons } from '../../constants/solidity.js'
|
|
2
|
+
import { BaseError } from '../../errors/base.js'
|
|
3
|
+
import { ContractFunctionRevertedError } from '../../errors/contract.js'
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* @description Checks if error is a valid null result UniversalResolver error
|
|
7
|
+
*/
|
|
8
|
+
export function isNullUniversalResolverError(
|
|
9
|
+
err: unknown,
|
|
10
|
+
callType: 'resolve' | 'reverse',
|
|
11
|
+
): boolean {
|
|
12
|
+
if (!(err instanceof BaseError)) return false
|
|
13
|
+
const cause = err.walk((e) => e instanceof ContractFunctionRevertedError)
|
|
14
|
+
if (!(cause instanceof ContractFunctionRevertedError)) return false
|
|
15
|
+
if (cause.data?.errorName === 'ResolverNotFound') return true
|
|
16
|
+
if (cause.data?.errorName === 'ResolverWildcardNotSupported') return true
|
|
17
|
+
// Backwards compatibility for older UniversalResolver contracts
|
|
18
|
+
if (
|
|
19
|
+
cause.reason?.includes(
|
|
20
|
+
'Wildcard on non-extended resolvers is not supported',
|
|
21
|
+
)
|
|
22
|
+
)
|
|
23
|
+
return true
|
|
24
|
+
// No primary name set for address.
|
|
25
|
+
if (callType === 'reverse' && cause.reason === panicReasons[50]) return true
|
|
26
|
+
return false
|
|
27
|
+
}
|