viem 2.44.2 → 2.45.0
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 +36 -0
- package/_cjs/account-abstraction/actions/bundler/prepareUserOperation.js +4 -2
- package/_cjs/account-abstraction/actions/bundler/prepareUserOperation.js.map +1 -1
- package/_cjs/account-abstraction/actions/bundler/sendUserOperation.js.map +1 -1
- package/_cjs/account-abstraction/clients/createBundlerClient.js +8 -2
- package/_cjs/account-abstraction/clients/createBundlerClient.js.map +1 -1
- package/_cjs/actions/public/estimateContractGas.js +3 -1
- package/_cjs/actions/public/estimateContractGas.js.map +1 -1
- package/_cjs/actions/public/simulateContract.js +3 -1
- package/_cjs/actions/public/simulateContract.js.map +1 -1
- package/_cjs/actions/wallet/sendCalls.js +17 -1
- package/_cjs/actions/wallet/sendCalls.js.map +1 -1
- package/_cjs/actions/wallet/sendTransaction.js +11 -7
- package/_cjs/actions/wallet/sendTransaction.js.map +1 -1
- package/_cjs/actions/wallet/sendTransactionSync.js +11 -7
- package/_cjs/actions/wallet/sendTransactionSync.js.map +1 -1
- package/_cjs/actions/wallet/writeContract.js +2 -2
- package/_cjs/actions/wallet/writeContract.js.map +1 -1
- package/_cjs/chains/definitions/megaeth.js +33 -0
- package/_cjs/chains/definitions/megaeth.js.map +1 -0
- package/_cjs/chains/definitions/megaethTestnet.js +6 -1
- package/_cjs/chains/definitions/megaethTestnet.js.map +1 -1
- package/_cjs/chains/definitions/rise.js +28 -0
- package/_cjs/chains/definitions/rise.js.map +1 -0
- package/_cjs/chains/definitions/stable.js +35 -0
- package/_cjs/chains/definitions/stable.js.map +1 -0
- package/_cjs/chains/definitions/stableTestnet.js +10 -3
- package/_cjs/chains/definitions/stableTestnet.js.map +1 -1
- package/_cjs/chains/index.js +13 -7
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/clients/createClient.js +2 -1
- package/_cjs/clients/createClient.js.map +1 -1
- package/_cjs/clients/createWalletClient.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/op-stack/index.js +9 -1
- package/_cjs/op-stack/index.js.map +1 -1
- package/_cjs/tempo/Abis.js +2 -2
- package/_cjs/tempo/Abis.js.map +1 -1
- package/_cjs/tempo/Addresses.js +2 -1
- package/_cjs/tempo/Addresses.js.map +1 -1
- package/_cjs/tempo/Decorator.js +19 -0
- package/_cjs/tempo/Decorator.js.map +1 -1
- package/_cjs/tempo/Transport.js +1 -1
- package/_cjs/tempo/Transport.js.map +1 -1
- package/_cjs/tempo/actions/fee.js +91 -0
- package/_cjs/tempo/actions/fee.js.map +1 -1
- package/_cjs/tempo/actions/index.js +2 -1
- package/_cjs/tempo/actions/index.js.map +1 -1
- package/_cjs/tempo/actions/validator.js +308 -0
- package/_cjs/tempo/actions/validator.js.map +1 -0
- package/_cjs/types/dataSuffix.js +3 -0
- package/_cjs/types/dataSuffix.js.map +1 -0
- package/_cjs/utils/abi/decodeEventLog.js +29 -12
- package/_cjs/utils/abi/decodeEventLog.js.map +1 -1
- package/_esm/account-abstraction/actions/bundler/prepareUserOperation.js +4 -2
- package/_esm/account-abstraction/actions/bundler/prepareUserOperation.js.map +1 -1
- package/_esm/account-abstraction/actions/bundler/sendUserOperation.js.map +1 -1
- package/_esm/account-abstraction/clients/createBundlerClient.js +8 -2
- package/_esm/account-abstraction/clients/createBundlerClient.js.map +1 -1
- package/_esm/actions/public/estimateContractGas.js +3 -1
- package/_esm/actions/public/estimateContractGas.js.map +1 -1
- package/_esm/actions/public/simulateContract.js +3 -1
- package/_esm/actions/public/simulateContract.js.map +1 -1
- package/_esm/actions/wallet/sendCalls.js +17 -1
- package/_esm/actions/wallet/sendCalls.js.map +1 -1
- package/_esm/actions/wallet/sendTransaction.js +11 -7
- package/_esm/actions/wallet/sendTransaction.js.map +1 -1
- package/_esm/actions/wallet/sendTransactionSync.js +11 -7
- package/_esm/actions/wallet/sendTransactionSync.js.map +1 -1
- package/_esm/actions/wallet/writeContract.js +2 -2
- package/_esm/actions/wallet/writeContract.js.map +1 -1
- package/_esm/chains/definitions/megaeth.js +30 -0
- package/_esm/chains/definitions/megaeth.js.map +1 -0
- package/_esm/chains/definitions/megaethTestnet.js +6 -1
- package/_esm/chains/definitions/megaethTestnet.js.map +1 -1
- package/_esm/chains/definitions/rise.js +25 -0
- package/_esm/chains/definitions/rise.js.map +1 -0
- package/_esm/chains/definitions/stable.js +32 -0
- package/_esm/chains/definitions/stable.js.map +1 -0
- package/_esm/chains/definitions/stableTestnet.js +10 -3
- package/_esm/chains/definitions/stableTestnet.js.map +1 -1
- package/_esm/chains/index.js +3 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/clients/createClient.js +2 -1
- package/_esm/clients/createClient.js.map +1 -1
- package/_esm/clients/createWalletClient.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/op-stack/index.js +4 -0
- package/_esm/op-stack/index.js.map +1 -1
- package/_esm/tempo/Abis.js +1 -1
- package/_esm/tempo/Abis.js.map +1 -1
- package/_esm/tempo/Account.js +6 -6
- package/_esm/tempo/Addresses.js +1 -0
- package/_esm/tempo/Addresses.js.map +1 -1
- package/_esm/tempo/Decorator.js +19 -0
- package/_esm/tempo/Decorator.js.map +1 -1
- package/_esm/tempo/Transport.js +1 -1
- package/_esm/tempo/Transport.js.map +1 -1
- package/_esm/tempo/WebAuthnP256.js +2 -2
- package/_esm/tempo/actions/amm.js +28 -28
- package/_esm/tempo/actions/dex.js +68 -68
- package/_esm/tempo/actions/faucet.js +4 -4
- package/_esm/tempo/actions/fee.js +236 -10
- package/_esm/tempo/actions/fee.js.map +1 -1
- package/_esm/tempo/actions/index.js +1 -0
- package/_esm/tempo/actions/index.js.map +1 -1
- package/_esm/tempo/actions/nonce.js +4 -4
- package/_esm/tempo/actions/policy.js +36 -36
- package/_esm/tempo/actions/reward.js +28 -28
- package/_esm/tempo/actions/token.js +122 -122
- package/_esm/tempo/actions/validator.js +1017 -0
- package/_esm/tempo/actions/validator.js.map +1 -0
- package/_esm/types/dataSuffix.js +2 -0
- package/_esm/types/dataSuffix.js.map +1 -0
- package/_esm/utils/abi/decodeEventLog.js +34 -13
- package/_esm/utils/abi/decodeEventLog.js.map +1 -1
- package/_types/account-abstraction/actions/bundler/prepareUserOperation.d.ts +2 -0
- package/_types/account-abstraction/actions/bundler/prepareUserOperation.d.ts.map +1 -1
- package/_types/account-abstraction/actions/bundler/sendUserOperation.d.ts +2 -0
- package/_types/account-abstraction/actions/bundler/sendUserOperation.d.ts.map +1 -1
- package/_types/account-abstraction/clients/createBundlerClient.d.ts +4 -0
- package/_types/account-abstraction/clients/createBundlerClient.d.ts.map +1 -1
- package/_types/actions/public/estimateContractGas.d.ts.map +1 -1
- package/_types/actions/public/simulateContract.d.ts.map +1 -1
- package/_types/actions/wallet/sendCalls.d.ts.map +1 -1
- package/_types/actions/wallet/sendTransaction.d.ts +7 -2
- package/_types/actions/wallet/sendTransaction.d.ts.map +1 -1
- package/_types/actions/wallet/sendTransactionSync.d.ts +5 -0
- package/_types/actions/wallet/sendTransactionSync.d.ts.map +1 -1
- package/_types/actions/wallet/writeContract.d.ts.map +1 -1
- package/_types/chains/definitions/megaeth.d.ts +46 -0
- package/_types/chains/definitions/megaeth.d.ts.map +1 -0
- package/_types/chains/definitions/megaethTestnet.d.ts +6 -1
- package/_types/chains/definitions/megaethTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/rise.d.ts +46 -0
- package/_types/chains/definitions/rise.d.ts.map +1 -0
- package/_types/chains/definitions/stable.d.ts +47 -0
- package/_types/chains/definitions/stable.d.ts.map +1 -0
- package/_types/chains/definitions/stableTestnet.d.ts +10 -13
- package/_types/chains/definitions/stableTestnet.d.ts.map +1 -1
- package/_types/chains/index.d.ts +3 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/clients/createClient.d.ts +5 -0
- package/_types/clients/createClient.d.ts.map +1 -1
- package/_types/clients/createWalletClient.d.ts +1 -1
- package/_types/clients/createWalletClient.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/index.d.ts +2 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/op-stack/index.d.ts +4 -0
- package/_types/op-stack/index.d.ts.map +1 -1
- package/_types/tempo/Abis.d.ts +1 -1
- package/_types/tempo/Abis.d.ts.map +1 -1
- package/_types/tempo/Account.d.ts +6 -6
- package/_types/tempo/Addresses.d.ts +1 -0
- package/_types/tempo/Addresses.d.ts.map +1 -1
- package/_types/tempo/Decorator.d.ts +607 -208
- package/_types/tempo/Decorator.d.ts.map +1 -1
- package/_types/tempo/Transport.d.ts.map +1 -1
- package/_types/tempo/WebAuthnP256.d.ts +2 -2
- package/_types/tempo/actions/amm.d.ts +28 -28
- package/_types/tempo/actions/dex.d.ts +68 -68
- package/_types/tempo/actions/faucet.d.ts +4 -4
- package/_types/tempo/actions/fee.d.ts +380 -10
- package/_types/tempo/actions/fee.d.ts.map +1 -1
- package/_types/tempo/actions/index.d.ts +1 -0
- package/_types/tempo/actions/index.d.ts.map +1 -1
- package/_types/tempo/actions/nonce.d.ts +4 -4
- package/_types/tempo/actions/policy.d.ts +36 -36
- package/_types/tempo/actions/reward.d.ts +28 -28
- package/_types/tempo/actions/token.d.ts +122 -122
- package/_types/tempo/actions/validator.d.ts +1174 -0
- package/_types/tempo/actions/validator.d.ts.map +1 -0
- package/_types/types/dataSuffix.d.ts +16 -0
- package/_types/types/dataSuffix.d.ts.map +1 -0
- package/_types/utils/abi/decodeEventLog.d.ts.map +1 -1
- package/account-abstraction/actions/bundler/prepareUserOperation.ts +7 -1
- package/account-abstraction/actions/bundler/sendUserOperation.ts +2 -0
- package/account-abstraction/clients/createBundlerClient.ts +12 -1
- package/actions/public/estimateContractGas.ts +11 -2
- package/actions/public/simulateContract.ts +11 -2
- package/actions/wallet/sendCalls.ts +18 -1
- package/actions/wallet/sendTransaction.ts +19 -8
- package/actions/wallet/sendTransactionSync.ts +17 -7
- package/actions/wallet/writeContract.ts +1 -2
- package/chains/definitions/megaeth.ts +30 -0
- package/chains/definitions/megaethTestnet.ts +6 -1
- package/chains/definitions/rise.ts +25 -0
- package/chains/definitions/stable.ts +32 -0
- package/chains/definitions/stableTestnet.ts +10 -3
- package/chains/index.ts +3 -0
- package/clients/createClient.ts +7 -0
- package/clients/createWalletClient.ts +1 -0
- package/errors/version.ts +1 -1
- package/index.ts +2 -0
- package/op-stack/index.ts +24 -0
- package/package.json +1 -1
- package/tempo/Abis.ts +1 -1
- package/tempo/Account.ts +6 -6
- package/tempo/Addresses.ts +1 -0
- package/tempo/Decorator.ts +672 -208
- package/tempo/Transport.ts +4 -1
- package/tempo/WebAuthnP256.ts +2 -2
- package/tempo/actions/amm.ts +28 -28
- package/tempo/actions/dex.ts +68 -68
- package/tempo/actions/faucet.ts +4 -4
- package/tempo/actions/fee.ts +346 -10
- package/tempo/actions/index.ts +1 -0
- package/tempo/actions/nonce.ts +4 -4
- package/tempo/actions/policy.ts +36 -36
- package/tempo/actions/reward.ts +28 -28
- package/tempo/actions/token.ts +122 -122
- package/tempo/actions/validator.ts +1417 -0
- package/types/dataSuffix.ts +18 -0
- package/utils/abi/decodeEventLog.ts +38 -14
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Hex } from './misc.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Data suffix configuration for transaction attribution.
|
|
5
|
+
*
|
|
6
|
+
* Can be specified in two forms:
|
|
7
|
+
* - Simple hex string: `"0x1234"` - Appended to transaction data, not required
|
|
8
|
+
* - Object form: `{ value: "0x1234", required: true }` - Explicit required flag
|
|
9
|
+
*
|
|
10
|
+
* When `required` is `true`, transactions will fail if the suffix cannot be appended.
|
|
11
|
+
* When `required` is `false` (default), the suffix is best-effort.
|
|
12
|
+
*/
|
|
13
|
+
export type DataSuffix =
|
|
14
|
+
| Hex
|
|
15
|
+
| {
|
|
16
|
+
value: Hex
|
|
17
|
+
required?: boolean | undefined
|
|
18
|
+
}
|
|
@@ -133,36 +133,60 @@ export function decodeEventLog<
|
|
|
133
133
|
const indexedInputs = inputs
|
|
134
134
|
.map((x, i) => [x, i] as const)
|
|
135
135
|
.filter(([x]) => 'indexed' in x && x.indexed)
|
|
136
|
+
|
|
137
|
+
const missingIndexedInputs: [AbiParameter, number][] = []
|
|
138
|
+
|
|
136
139
|
for (let i = 0; i < indexedInputs.length; i++) {
|
|
137
140
|
const [param, argIndex] = indexedInputs[i]
|
|
138
141
|
const topic = argTopics[i]
|
|
139
|
-
if (!topic)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
if (!topic) {
|
|
143
|
+
if (strict)
|
|
144
|
+
throw new DecodeLogTopicsMismatch({
|
|
145
|
+
abiItem,
|
|
146
|
+
param: param as AbiParameter & { indexed: boolean },
|
|
147
|
+
})
|
|
148
|
+
// Track missing indexed inputs to decode from data when strict is false
|
|
149
|
+
missingIndexedInputs.push([param, argIndex])
|
|
150
|
+
continue
|
|
151
|
+
}
|
|
144
152
|
args[isUnnamed ? argIndex : param.name || argIndex] = decodeTopic({
|
|
145
153
|
param,
|
|
146
154
|
value: topic,
|
|
147
155
|
})
|
|
148
156
|
}
|
|
149
157
|
|
|
150
|
-
// Decode data (non-indexed args).
|
|
158
|
+
// Decode data (non-indexed args + missing indexed args when strict is false).
|
|
151
159
|
const nonIndexedInputs = inputs.filter((x) => !('indexed' in x && x.indexed))
|
|
152
|
-
|
|
160
|
+
|
|
161
|
+
// When strict is false, missing indexed inputs should be decoded from data
|
|
162
|
+
const inputsToDecode = strict
|
|
163
|
+
? nonIndexedInputs
|
|
164
|
+
: [...missingIndexedInputs.map(([param]) => param), ...nonIndexedInputs]
|
|
165
|
+
|
|
166
|
+
if (inputsToDecode.length > 0) {
|
|
153
167
|
if (data && data !== '0x') {
|
|
154
168
|
try {
|
|
155
169
|
const decodedData = decodeAbiParameters(
|
|
156
|
-
|
|
170
|
+
inputsToDecode,
|
|
157
171
|
data,
|
|
158
172
|
) as unknown[]
|
|
159
173
|
if (decodedData) {
|
|
160
|
-
|
|
174
|
+
let dataIndex = 0
|
|
175
|
+
// First, assign missing indexed parameters (when strict is false)
|
|
176
|
+
if (!strict) {
|
|
177
|
+
for (const [param, argIndex] of missingIndexedInputs) {
|
|
178
|
+
args[isUnnamed ? argIndex : param.name || argIndex] =
|
|
179
|
+
decodedData[dataIndex++]
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Then, assign non-indexed parameters
|
|
183
|
+
if (isUnnamed) {
|
|
161
184
|
for (let i = 0; i < inputs.length; i++)
|
|
162
|
-
args[i]
|
|
163
|
-
|
|
185
|
+
if (args[i] === undefined && dataIndex < decodedData.length)
|
|
186
|
+
args[i] = decodedData[dataIndex++]
|
|
187
|
+
} else
|
|
164
188
|
for (let i = 0; i < nonIndexedInputs.length; i++)
|
|
165
|
-
args[nonIndexedInputs[i].name!] = decodedData[
|
|
189
|
+
args[nonIndexedInputs[i].name!] = decodedData[dataIndex++]
|
|
166
190
|
}
|
|
167
191
|
} catch (err) {
|
|
168
192
|
if (strict) {
|
|
@@ -173,7 +197,7 @@ export function decodeEventLog<
|
|
|
173
197
|
throw new DecodeLogDataMismatch({
|
|
174
198
|
abiItem,
|
|
175
199
|
data: data,
|
|
176
|
-
params:
|
|
200
|
+
params: inputsToDecode,
|
|
177
201
|
size: size(data),
|
|
178
202
|
})
|
|
179
203
|
throw err
|
|
@@ -183,7 +207,7 @@ export function decodeEventLog<
|
|
|
183
207
|
throw new DecodeLogDataMismatch({
|
|
184
208
|
abiItem,
|
|
185
209
|
data: '0x',
|
|
186
|
-
params:
|
|
210
|
+
params: inputsToDecode,
|
|
187
211
|
size: 0,
|
|
188
212
|
})
|
|
189
213
|
}
|