viem 2.26.5 → 2.27.0-canary-20250414221820
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 +16 -0
- package/_cjs/actions/ens/getEnsAddress.js +7 -7
- package/_cjs/actions/ens/getEnsAddress.js.map +1 -1
- package/_cjs/actions/ens/getEnsText.js +3 -6
- package/_cjs/actions/ens/getEnsText.js.map +1 -1
- package/_cjs/chains/definitions/hoodi.js +6 -0
- package/_cjs/chains/definitions/hoodi.js.map +1 -1
- package/_cjs/chains/definitions/lestnet.js +22 -0
- package/_cjs/chains/definitions/lestnet.js.map +1 -0
- package/_cjs/chains/definitions/peaq.js +2 -2
- package/_cjs/chains/definitions/peaq.js.map +1 -1
- package/_cjs/chains/definitions/tronShasta.js +22 -0
- package/_cjs/chains/definitions/tronShasta.js.map +1 -0
- package/_cjs/chains/index.js +11 -7
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/constants/abis.js +52 -1
- package/_cjs/constants/abis.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/errors/version.js.map +1 -1
- package/_cjs/experimental/eip5792/actions/getCallsStatus.js +1 -1
- package/_cjs/utils/ccip.js +7 -1
- package/_cjs/utils/ccip.js.map +1 -1
- package/_cjs/utils/ens/localBatchGatewayRequest.js +45 -0
- package/_cjs/utils/ens/localBatchGatewayRequest.js.map +1 -0
- package/_esm/actions/ens/getEnsAddress.js +7 -7
- package/_esm/actions/ens/getEnsAddress.js.map +1 -1
- package/_esm/actions/ens/getEnsText.js +3 -6
- package/_esm/actions/ens/getEnsText.js.map +1 -1
- package/_esm/chains/definitions/hoodi.js +6 -0
- package/_esm/chains/definitions/hoodi.js.map +1 -1
- package/_esm/chains/definitions/lestnet.js +19 -0
- package/_esm/chains/definitions/lestnet.js.map +1 -0
- package/_esm/chains/definitions/peaq.js +2 -2
- package/_esm/chains/definitions/peaq.js.map +1 -1
- package/_esm/chains/definitions/tronShasta.js +19 -0
- package/_esm/chains/definitions/tronShasta.js.map +1 -0
- package/_esm/chains/index.js +2 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/constants/abis.js +51 -0
- package/_esm/constants/abis.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/errors/version.js.map +1 -1
- package/_esm/experimental/eip5792/actions/getCallsStatus.js +1 -1
- package/_esm/utils/ccip.js +7 -1
- package/_esm/utils/ccip.js.map +1 -1
- package/_esm/utils/ens/localBatchGatewayRequest.js +41 -0
- package/_esm/utils/ens/localBatchGatewayRequest.js.map +1 -0
- package/_types/actions/ens/getEnsAddress.d.ts.map +1 -1
- package/_types/actions/ens/getEnsText.d.ts.map +1 -1
- package/_types/chains/definitions/hoodi.d.ts +6 -9
- package/_types/chains/definitions/hoodi.d.ts.map +1 -1
- package/_types/chains/definitions/lestnet.d.ts +37 -0
- package/_types/chains/definitions/lestnet.d.ts.map +1 -0
- package/_types/chains/definitions/peaq.d.ts +2 -2
- package/_types/chains/definitions/tronShasta.d.ts +37 -0
- package/_types/chains/definitions/tronShasta.d.ts.map +1 -0
- package/_types/chains/index.d.ts +2 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/constants/abis.d.ts +36 -0
- package/_types/constants/abis.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/errors/version.d.ts.map +1 -1
- package/_types/utils/ccip.d.ts.map +1 -1
- package/_types/utils/ens/localBatchGatewayRequest.d.ts +8 -0
- package/_types/utils/ens/localBatchGatewayRequest.d.ts.map +1 -0
- package/actions/ens/getEnsAddress.ts +7 -7
- package/actions/ens/getEnsText.ts +3 -6
- package/chains/definitions/hoodi.ts +6 -0
- package/chains/definitions/lestnet.ts +19 -0
- package/chains/definitions/peaq.ts +2 -2
- package/chains/definitions/tronShasta.ts +19 -0
- package/chains/index.ts +2 -0
- package/constants/abis.ts +52 -0
- package/errors/version.ts +1 -1
- package/experimental/eip5792/actions/getCallsStatus.ts +1 -1
- package/package.json +1 -1
- package/utils/ccip.ts +10 -1
- package/utils/ens/localBatchGatewayRequest.ts +60 -0
package/constants/abis.ts
CHANGED
@@ -43,6 +43,58 @@ export const multicall3Abi = [
|
|
43
43
|
},
|
44
44
|
] as const
|
45
45
|
|
46
|
+
export const batchGatewayAbi = [
|
47
|
+
{
|
48
|
+
name: 'query',
|
49
|
+
type: 'function',
|
50
|
+
stateMutability: 'view',
|
51
|
+
inputs: [
|
52
|
+
{
|
53
|
+
type: 'tuple[]',
|
54
|
+
name: 'queries',
|
55
|
+
components: [
|
56
|
+
{
|
57
|
+
type: 'address',
|
58
|
+
name: 'sender',
|
59
|
+
},
|
60
|
+
{
|
61
|
+
type: 'string[]',
|
62
|
+
name: 'urls',
|
63
|
+
},
|
64
|
+
{
|
65
|
+
type: 'bytes',
|
66
|
+
name: 'data',
|
67
|
+
},
|
68
|
+
],
|
69
|
+
},
|
70
|
+
],
|
71
|
+
outputs: [
|
72
|
+
{
|
73
|
+
type: 'bool[]',
|
74
|
+
name: 'failures',
|
75
|
+
},
|
76
|
+
{
|
77
|
+
type: 'bytes[]',
|
78
|
+
name: 'responses',
|
79
|
+
},
|
80
|
+
],
|
81
|
+
},
|
82
|
+
{
|
83
|
+
name: 'HttpError',
|
84
|
+
type: 'error',
|
85
|
+
inputs: [
|
86
|
+
{
|
87
|
+
type: 'uint16',
|
88
|
+
name: 'status',
|
89
|
+
},
|
90
|
+
{
|
91
|
+
type: 'string',
|
92
|
+
name: 'message',
|
93
|
+
},
|
94
|
+
],
|
95
|
+
},
|
96
|
+
] as const
|
97
|
+
|
46
98
|
const universalResolverErrors = [
|
47
99
|
{
|
48
100
|
inputs: [],
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.
|
1
|
+
export const version = '2.27.0-canary-20250414221820'
|
@@ -74,7 +74,7 @@ export async function getCallsStatus<
|
|
74
74
|
return ['pending', statusCode] as const
|
75
75
|
if (statusCode >= 200 && statusCode < 300)
|
76
76
|
return ['success', statusCode] as const
|
77
|
-
if (statusCode >=
|
77
|
+
if (statusCode >= 300 && statusCode < 700)
|
78
78
|
return ['failure', statusCode] as const
|
79
79
|
// @ts-expect-error: for backwards compatibility
|
80
80
|
if (statusCode === 'CONFIRMED') return ['success', 200] as const
|
package/package.json
CHANGED
package/utils/ccip.ts
CHANGED
@@ -24,6 +24,10 @@ import { encodeAbiParameters } from './abi/encodeAbiParameters.js'
|
|
24
24
|
import { isAddressEqual } from './address/isAddressEqual.js'
|
25
25
|
import { concat } from './data/concat.js'
|
26
26
|
import { isHex } from './data/isHex.js'
|
27
|
+
import {
|
28
|
+
localBatchGatewayRequest,
|
29
|
+
localBatchGatewayUrl,
|
30
|
+
} from './ens/localBatchGatewayRequest.js'
|
27
31
|
import { stringify } from './stringify.js'
|
28
32
|
|
29
33
|
export const offchainLookupSignature = '0x556f1830'
|
@@ -84,7 +88,12 @@ export async function offchainLookup<chain extends Chain | undefined>(
|
|
84
88
|
if (!isAddressEqual(to, sender))
|
85
89
|
throw new OffchainLookupSenderMismatchError({ sender, to })
|
86
90
|
|
87
|
-
const result =
|
91
|
+
const result = urls.includes(localBatchGatewayUrl)
|
92
|
+
? await localBatchGatewayRequest({
|
93
|
+
data: callData,
|
94
|
+
ccipRequest: ccipRequest_,
|
95
|
+
})
|
96
|
+
: await ccipRequest_({ data: callData, sender, urls })
|
88
97
|
|
89
98
|
const { data: data_ } = await call(client, {
|
90
99
|
blockNumber,
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import { batchGatewayAbi } from '../../constants/abis.js'
|
2
|
+
import { solidityError } from '../../constants/solidity.js'
|
3
|
+
import type { Hex } from '../../types/misc.js'
|
4
|
+
import { decodeFunctionData } from '../abi/decodeFunctionData.js'
|
5
|
+
import { encodeErrorResult } from '../abi/encodeErrorResult.js'
|
6
|
+
import { encodeFunctionResult } from '../abi/encodeFunctionResult.js'
|
7
|
+
import type {
|
8
|
+
CcipRequestErrorType,
|
9
|
+
CcipRequestParameters,
|
10
|
+
CcipRequestReturnType,
|
11
|
+
} from '../ccip.js'
|
12
|
+
|
13
|
+
export const localBatchGatewayUrl = 'x-batch-gateway:true'
|
14
|
+
|
15
|
+
export async function localBatchGatewayRequest(parameters: {
|
16
|
+
data: Hex
|
17
|
+
ccipRequest: (
|
18
|
+
parameters: CcipRequestParameters,
|
19
|
+
) => Promise<CcipRequestReturnType>
|
20
|
+
}): Promise<Hex> {
|
21
|
+
const { data, ccipRequest } = parameters
|
22
|
+
|
23
|
+
const {
|
24
|
+
args: [queries],
|
25
|
+
} = decodeFunctionData({ abi: batchGatewayAbi, data })
|
26
|
+
|
27
|
+
const failures: boolean[] = []
|
28
|
+
const responses: Hex[] = []
|
29
|
+
await Promise.all(
|
30
|
+
queries.map(async (query, i) => {
|
31
|
+
try {
|
32
|
+
responses[i] = await ccipRequest(query)
|
33
|
+
failures[i] = false
|
34
|
+
} catch (err) {
|
35
|
+
failures[i] = true
|
36
|
+
responses[i] = encodeError(err as CcipRequestErrorType)
|
37
|
+
}
|
38
|
+
}),
|
39
|
+
)
|
40
|
+
|
41
|
+
return encodeFunctionResult({
|
42
|
+
abi: batchGatewayAbi,
|
43
|
+
functionName: 'query',
|
44
|
+
result: [failures, responses],
|
45
|
+
})
|
46
|
+
}
|
47
|
+
|
48
|
+
function encodeError(error: CcipRequestErrorType): Hex {
|
49
|
+
if (error.name === 'HttpRequestError' && error.status)
|
50
|
+
return encodeErrorResult({
|
51
|
+
abi: batchGatewayAbi,
|
52
|
+
errorName: 'HttpError',
|
53
|
+
args: [error.status, error.shortMessage],
|
54
|
+
})
|
55
|
+
return encodeErrorResult({
|
56
|
+
abi: [solidityError],
|
57
|
+
errorName: 'Error',
|
58
|
+
args: ['shortMessage' in error ? error.shortMessage : error.message],
|
59
|
+
})
|
60
|
+
}
|