viem 2.58.1 → 2.58.3
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 +26 -0
- package/_cjs/actions/public/createEventFilter.js +2 -12
- package/_cjs/actions/public/createEventFilter.js.map +1 -1
- package/_cjs/actions/public/estimateFeesPerGas.js +16 -16
- package/_cjs/actions/public/estimateFeesPerGas.js.map +1 -1
- package/_cjs/actions/public/getLogs.js +6 -12
- package/_cjs/actions/public/getLogs.js.map +1 -1
- package/_cjs/actions/public/internal/encodeEventFilterTopics.js +19 -0
- package/_cjs/actions/public/internal/encodeEventFilterTopics.js.map +1 -0
- package/_cjs/actions/public/simulateBlocks.js +1 -0
- package/_cjs/actions/public/simulateBlocks.js.map +1 -1
- package/_cjs/actions/public/watchEvent.js +2 -12
- package/_cjs/actions/public/watchEvent.js.map +1 -1
- package/_cjs/celo/parsers.js +8 -2
- package/_cjs/celo/parsers.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/tempo/Abis.js +24 -1
- package/_cjs/tempo/Abis.js.map +1 -1
- package/_cjs/tempo/Decorator.js +1 -0
- package/_cjs/tempo/Decorator.js.map +1 -1
- package/_cjs/tempo/Selectors.js +1 -0
- package/_cjs/tempo/Selectors.js.map +1 -1
- package/_cjs/tempo/actions/channel.js +20 -0
- package/_cjs/tempo/actions/channel.js.map +1 -1
- package/_cjs/tempo/actions/simulate.js +1 -0
- package/_cjs/tempo/actions/simulate.js.map +1 -1
- package/_cjs/tempo/internal/replacement.js.map +1 -1
- package/_cjs/utils/ccip.js +6 -2
- package/_cjs/utils/ccip.js.map +1 -1
- package/_cjs/utils/ens/avatar/utils.js +1 -1
- package/_cjs/utils/ens/avatar/utils.js.map +1 -1
- package/_cjs/utils/siwe/createSiweMessage.js +2 -2
- package/_cjs/utils/siwe/createSiweMessage.js.map +1 -1
- package/_cjs/utils/siwe/parseSiweMessage.js +12 -4
- package/_cjs/utils/siwe/parseSiweMessage.js.map +1 -1
- package/_cjs/utils/siwe/validateSiweMessage.js +1 -1
- package/_cjs/utils/siwe/validateSiweMessage.js.map +1 -1
- package/_cjs/utils/stateOverride.js +5 -2
- package/_cjs/utils/stateOverride.js.map +1 -1
- package/_cjs/utils/transaction/parseTransaction.js +1 -0
- package/_cjs/utils/transaction/parseTransaction.js.map +1 -1
- package/_esm/actions/public/createEventFilter.js +2 -13
- package/_esm/actions/public/createEventFilter.js.map +1 -1
- package/_esm/actions/public/estimateFeesPerGas.js +16 -16
- package/_esm/actions/public/estimateFeesPerGas.js.map +1 -1
- package/_esm/actions/public/getLogs.js +6 -13
- package/_esm/actions/public/getLogs.js.map +1 -1
- package/_esm/actions/public/internal/encodeEventFilterTopics.js +22 -0
- package/_esm/actions/public/internal/encodeEventFilterTopics.js.map +1 -0
- package/_esm/actions/public/simulateBlocks.js +1 -0
- package/_esm/actions/public/simulateBlocks.js.map +1 -1
- package/_esm/actions/public/watchEvent.js +2 -13
- package/_esm/actions/public/watchEvent.js.map +1 -1
- package/_esm/celo/parsers.js +9 -3
- package/_esm/celo/parsers.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/tempo/Abis.js +24 -1
- package/_esm/tempo/Abis.js.map +1 -1
- package/_esm/tempo/Decorator.js +1 -0
- package/_esm/tempo/Decorator.js.map +1 -1
- package/_esm/tempo/Selectors.js +1 -0
- package/_esm/tempo/Selectors.js.map +1 -1
- package/_esm/tempo/actions/channel.js +72 -0
- package/_esm/tempo/actions/channel.js.map +1 -1
- package/_esm/tempo/actions/simulate.js +1 -0
- package/_esm/tempo/actions/simulate.js.map +1 -1
- package/_esm/tempo/internal/replacement.js +3 -1
- package/_esm/tempo/internal/replacement.js.map +1 -1
- package/_esm/utils/ccip.js +7 -2
- package/_esm/utils/ccip.js.map +1 -1
- package/_esm/utils/ens/avatar/utils.js +1 -1
- package/_esm/utils/ens/avatar/utils.js.map +1 -1
- package/_esm/utils/siwe/createSiweMessage.js +2 -2
- package/_esm/utils/siwe/createSiweMessage.js.map +1 -1
- package/_esm/utils/siwe/parseSiweMessage.js +14 -4
- package/_esm/utils/siwe/parseSiweMessage.js.map +1 -1
- package/_esm/utils/siwe/validateSiweMessage.js +2 -1
- package/_esm/utils/siwe/validateSiweMessage.js.map +1 -1
- package/_esm/utils/stateOverride.js +5 -2
- package/_esm/utils/stateOverride.js.map +1 -1
- package/_esm/utils/transaction/parseTransaction.js +1 -1
- package/_esm/utils/transaction/parseTransaction.js.map +1 -1
- package/_types/actions/public/createEventFilter.d.ts +1 -1
- package/_types/actions/public/createEventFilter.d.ts.map +1 -1
- package/_types/actions/public/getLogs.d.ts +1 -1
- package/_types/actions/public/getLogs.d.ts.map +1 -1
- package/_types/actions/public/internal/encodeEventFilterTopics.d.ts +14 -0
- package/_types/actions/public/internal/encodeEventFilterTopics.d.ts.map +1 -0
- package/_types/actions/public/simulateBlocks.d.ts.map +1 -1
- package/_types/actions/public/watchEvent.d.ts.map +1 -1
- package/_types/celo/parsers.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/tempo/Abis.d.ts +123 -3
- package/_types/tempo/Abis.d.ts.map +1 -1
- package/_types/tempo/Decorator.d.ts +23 -0
- package/_types/tempo/Decorator.d.ts.map +1 -1
- package/_types/tempo/Selectors.d.ts +1 -0
- package/_types/tempo/Selectors.d.ts.map +1 -1
- package/_types/tempo/actions/channel.d.ts +372 -6
- package/_types/tempo/actions/channel.d.ts.map +1 -1
- package/_types/tempo/actions/simulate.d.ts.map +1 -1
- package/_types/tempo/internal/replacement.d.ts +3 -1
- package/_types/tempo/internal/replacement.d.ts.map +1 -1
- package/_types/utils/ccip.d.ts.map +1 -1
- package/_types/utils/siwe/parseSiweMessage.d.ts.map +1 -1
- package/_types/utils/siwe/validateSiweMessage.d.ts.map +1 -1
- package/_types/utils/stateOverride.d.ts.map +1 -1
- package/_types/utils/transaction/parseTransaction.d.ts +4 -1
- package/_types/utils/transaction/parseTransaction.d.ts.map +1 -1
- package/actions/public/createEventFilter.ts +4 -19
- package/actions/public/estimateFeesPerGas.ts +18 -18
- package/actions/public/getLogs.ts +8 -19
- package/actions/public/internal/encodeEventFilterTopics.ts +32 -0
- package/actions/public/simulateBlocks.ts +1 -0
- package/actions/public/watchEvent.ts +2 -18
- package/celo/parsers.ts +13 -2
- package/errors/version.ts +1 -1
- package/package.json +1 -1
- package/tempo/Abis.ts +24 -1
- package/tempo/Decorator.ts +26 -0
- package/tempo/Selectors.ts +1 -0
- package/tempo/actions/channel.ts +92 -0
- package/tempo/actions/simulate.ts +1 -0
- package/tempo/internal/replacement.ts +3 -1
- package/utils/ccip.ts +6 -2
- package/utils/ens/avatar/utils.ts +1 -1
- package/utils/siwe/createSiweMessage.ts +2 -2
- package/utils/siwe/parseSiweMessage.ts +13 -4
- package/utils/siwe/validateSiweMessage.ts +2 -1
- package/utils/stateOverride.ts +4 -2
- package/utils/transaction/parseTransaction.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type InvalidAddressErrorType } from '../../errors/address.js';
|
|
2
2
|
import { type InvalidLegacyVErrorType, type InvalidSerializedTransactionErrorType, type InvalidYParityErrorType } from '../../errors/transaction.js';
|
|
3
3
|
import type { ErrorType } from '../../errors/utils.js';
|
|
4
|
-
import type { Hex } from '../../types/misc.js';
|
|
4
|
+
import type { Hex, Signature } from '../../types/misc.js';
|
|
5
5
|
import type { AccessList, TransactionSerializable, TransactionSerializableEIP1559, TransactionSerializableEIP2930, TransactionSerializableEIP4844, TransactionSerializableEIP7702, TransactionSerializableLegacy, TransactionSerialized, TransactionSerializedGeneric, TransactionType } from '../../types/transaction.js';
|
|
6
6
|
import type { IsNarrowable } from '../../types/utils.js';
|
|
7
7
|
import { type IsAddressErrorType } from '../address/isAddress.js';
|
|
@@ -26,5 +26,8 @@ type ParseAccessListErrorType = InvalidAddressErrorType | IsAddressErrorType | E
|
|
|
26
26
|
export declare function parseAccessList(accessList_: RecursiveArray<Hex>): AccessList;
|
|
27
27
|
type ParseAuthorizationListErrorType = HexToNumberErrorType | ParseEIP155SignatureErrorType | ErrorType;
|
|
28
28
|
type ParseEIP155SignatureErrorType = HexToBigIntErrorType | InvalidYParityErrorType | PadHexErrorType | ErrorType;
|
|
29
|
+
export declare function parseEIP155Signature(transactionArray: RecursiveArray<Hex>): Signature & {
|
|
30
|
+
yParity: number;
|
|
31
|
+
};
|
|
29
32
|
export {};
|
|
30
33
|
//# sourceMappingURL=parseTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseTransaction.d.ts","sourceRoot":"","sources":["../../../utils/transaction/parseTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAEL,KAAK,uBAAuB,EAE5B,KAAK,qCAAqC,EAE1C,KAAK,uBAAuB,EAC7B,MAAM,6BAA6B,CAAA;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAKtD,OAAO,KAAK,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"parseTransaction.d.ts","sourceRoot":"","sources":["../../../utils/transaction/parseTransaction.ts"],"names":[],"mappings":"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"}
|
|
@@ -10,19 +10,16 @@ import type {
|
|
|
10
10
|
MaybeExtractEventArgsFromAbi,
|
|
11
11
|
} from '../../types/contract.js'
|
|
12
12
|
import type { Filter } from '../../types/filter.js'
|
|
13
|
-
import type { Hex
|
|
13
|
+
import type { Hex } from '../../types/misc.js'
|
|
14
14
|
import type { Prettify } from '../../types/utils.js'
|
|
15
|
-
import {
|
|
16
|
-
type EncodeEventTopicsErrorType,
|
|
17
|
-
type EncodeEventTopicsParameters,
|
|
18
|
-
encodeEventTopics,
|
|
19
|
-
} from '../../utils/abi/encodeEventTopics.js'
|
|
15
|
+
import type { EncodeEventTopicsErrorType } from '../../utils/abi/encodeEventTopics.js'
|
|
20
16
|
import type { RequestErrorType } from '../../utils/buildRequest.js'
|
|
21
17
|
import {
|
|
22
18
|
type NumberToHexErrorType,
|
|
23
19
|
numberToHex,
|
|
24
20
|
} from '../../utils/encoding/toHex.js'
|
|
25
21
|
import { createFilterRequestScope } from '../../utils/filters/createFilterRequestScope.js'
|
|
22
|
+
import { encodeEventFilterTopics } from './internal/encodeEventFilterTopics.js'
|
|
26
23
|
|
|
27
24
|
export type CreateEventFilterParameters<
|
|
28
25
|
abiEvent extends AbiEvent | undefined = undefined,
|
|
@@ -188,19 +185,7 @@ export async function createEventFilter<
|
|
|
188
185
|
method: 'eth_newFilter',
|
|
189
186
|
})
|
|
190
187
|
|
|
191
|
-
|
|
192
|
-
if (events) {
|
|
193
|
-
const encoded = (events as AbiEvent[]).flatMap((event) =>
|
|
194
|
-
encodeEventTopics({
|
|
195
|
-
abi: [event],
|
|
196
|
-
eventName: (event as AbiEvent).name,
|
|
197
|
-
args,
|
|
198
|
-
} as EncodeEventTopicsParameters),
|
|
199
|
-
)
|
|
200
|
-
// TODO: Clean up type casting
|
|
201
|
-
topics = [encoded as LogTopic]
|
|
202
|
-
if (event) topics = topics[0] as LogTopic[]
|
|
203
|
-
}
|
|
188
|
+
const topics = encodeEventFilterTopics({ args, event, events: events_ })
|
|
204
189
|
|
|
205
190
|
const id: Hex = await client.request({
|
|
206
191
|
method: 'eth_newFilter',
|
|
@@ -118,23 +118,6 @@ export async function internal_estimateFeesPerGas<
|
|
|
118
118
|
type = 'eip1559',
|
|
119
119
|
} = args || {}
|
|
120
120
|
|
|
121
|
-
const baseFeeMultiplier = await (async () => {
|
|
122
|
-
if (typeof chain?.fees?.baseFeeMultiplier === 'function')
|
|
123
|
-
return chain.fees.baseFeeMultiplier({
|
|
124
|
-
block: block_ as Block,
|
|
125
|
-
client,
|
|
126
|
-
request,
|
|
127
|
-
} as ChainFeesFnParameters)
|
|
128
|
-
return chain?.fees?.baseFeeMultiplier ?? 1.2
|
|
129
|
-
})()
|
|
130
|
-
if (baseFeeMultiplier < 1) throw new BaseFeeScalarError()
|
|
131
|
-
|
|
132
|
-
const decimals = baseFeeMultiplier.toString().split('.')[1]?.length ?? 0
|
|
133
|
-
const denominator = 10 ** decimals
|
|
134
|
-
const multiply = (base: bigint) =>
|
|
135
|
-
(base * BigInt(Math.round(baseFeeMultiplier * denominator))) /
|
|
136
|
-
BigInt(denominator)
|
|
137
|
-
|
|
138
121
|
// Chain fee hooks receive the block and the request, so the requests they
|
|
139
122
|
// depend on are made in sequence.
|
|
140
123
|
const hasFeeHooks = Object.values(chain?.fees ?? {}).some(
|
|
@@ -178,9 +161,26 @@ export async function internal_estimateFeesPerGas<
|
|
|
178
161
|
typeof block?.baseFeePerGas === 'bigint',
|
|
179
162
|
)
|
|
180
163
|
|
|
164
|
+
const baseFeeMultiplier = await (async () => {
|
|
165
|
+
if (typeof chain?.fees?.baseFeeMultiplier === 'function')
|
|
166
|
+
return chain.fees.baseFeeMultiplier({
|
|
167
|
+
block: block as Block,
|
|
168
|
+
client,
|
|
169
|
+
request,
|
|
170
|
+
} as ChainFeesFnParameters)
|
|
171
|
+
return chain?.fees?.baseFeeMultiplier ?? 1.2
|
|
172
|
+
})()
|
|
173
|
+
if (baseFeeMultiplier < 1) throw new BaseFeeScalarError()
|
|
174
|
+
|
|
175
|
+
const decimals = baseFeeMultiplier.toString().split('.')[1]?.length ?? 0
|
|
176
|
+
const denominator = 10 ** decimals
|
|
177
|
+
const multiply = (base: bigint) =>
|
|
178
|
+
(base * BigInt(Math.round(baseFeeMultiplier * denominator))) /
|
|
179
|
+
BigInt(denominator)
|
|
180
|
+
|
|
181
181
|
if (typeof chain?.fees?.estimateFeesPerGas === 'function') {
|
|
182
182
|
const fees = (await chain.fees.estimateFeesPerGas({
|
|
183
|
-
block:
|
|
183
|
+
block: block as Block,
|
|
184
184
|
client,
|
|
185
185
|
multiply,
|
|
186
186
|
request,
|
|
@@ -10,14 +10,10 @@ import type {
|
|
|
10
10
|
MaybeExtractEventArgsFromAbi,
|
|
11
11
|
} from '../../types/contract.js'
|
|
12
12
|
import type { Log } from '../../types/log.js'
|
|
13
|
-
import type { Hash
|
|
13
|
+
import type { Hash } from '../../types/misc.js'
|
|
14
14
|
import type { RpcLog } from '../../types/rpc.js'
|
|
15
15
|
import type { DecodeEventLogErrorType } from '../../utils/abi/decodeEventLog.js'
|
|
16
|
-
import {
|
|
17
|
-
type EncodeEventTopicsErrorType,
|
|
18
|
-
type EncodeEventTopicsParameters,
|
|
19
|
-
encodeEventTopics,
|
|
20
|
-
} from '../../utils/abi/encodeEventTopics.js'
|
|
16
|
+
import type { EncodeEventTopicsErrorType } from '../../utils/abi/encodeEventTopics.js'
|
|
21
17
|
import { parseEventLogs } from '../../utils/abi/parseEventLogs.js'
|
|
22
18
|
import type { RequestErrorType } from '../../utils/buildRequest.js'
|
|
23
19
|
import {
|
|
@@ -29,6 +25,7 @@ import {
|
|
|
29
25
|
formatLog,
|
|
30
26
|
} from '../../utils/formatters/log.js'
|
|
31
27
|
import type { GetBlockErrorType } from './getBlock.js'
|
|
28
|
+
import { encodeEventFilterTopics } from './internal/encodeEventFilterTopics.js'
|
|
32
29
|
import { type IterateLogsParameters, iterateLogs } from './iterateLogs.js'
|
|
33
30
|
|
|
34
31
|
export type GetLogsParameters<
|
|
@@ -203,19 +200,11 @@ export async function getLogs<
|
|
|
203
200
|
const strict = strict_ ?? false
|
|
204
201
|
const events = events_ ?? (event ? [event] : undefined)
|
|
205
202
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
eventName: (event as AbiEvent).name,
|
|
212
|
-
args: events_ ? undefined : args,
|
|
213
|
-
} as EncodeEventTopicsParameters),
|
|
214
|
-
)
|
|
215
|
-
// TODO: Clean up type casting
|
|
216
|
-
topics = [encoded as LogTopic]
|
|
217
|
-
if (event) topics = topics[0] as LogTopic[]
|
|
218
|
-
}
|
|
203
|
+
const topics = encodeEventFilterTopics({
|
|
204
|
+
args: events_ ? undefined : args,
|
|
205
|
+
event,
|
|
206
|
+
events: events_,
|
|
207
|
+
})
|
|
219
208
|
|
|
220
209
|
let logs: RpcLog[]
|
|
221
210
|
if (blockHash) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AbiEvent } from 'abitype'
|
|
2
|
+
|
|
3
|
+
import type { LogTopic } from '../../../types/misc.js'
|
|
4
|
+
import {
|
|
5
|
+
type EncodeEventTopicsParameters,
|
|
6
|
+
encodeEventTopics,
|
|
7
|
+
} from '../../../utils/abi/encodeEventTopics.js'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Encodes the `topics` of a log filter from an `event` or `events` option.
|
|
11
|
+
*
|
|
12
|
+
* A single `event` encodes to its topic list. Otherwise, the topics of every
|
|
13
|
+
* event in `events` are flattened into the first topic position.
|
|
14
|
+
*/
|
|
15
|
+
export function encodeEventFilterTopics(parameters: {
|
|
16
|
+
args?: unknown | undefined
|
|
17
|
+
event?: AbiEvent | undefined
|
|
18
|
+
events?: readonly unknown[] | undefined
|
|
19
|
+
}): LogTopic[] {
|
|
20
|
+
const { args, event } = parameters
|
|
21
|
+
const events = parameters.events ?? (event ? [event] : undefined)
|
|
22
|
+
if (!events) return []
|
|
23
|
+
const encoded = (events as AbiEvent[]).flatMap((event) =>
|
|
24
|
+
encodeEventTopics({
|
|
25
|
+
abi: [event],
|
|
26
|
+
eventName: event.name,
|
|
27
|
+
args,
|
|
28
|
+
} as EncodeEventTopicsParameters),
|
|
29
|
+
)
|
|
30
|
+
if (event) return encoded as LogTopic[]
|
|
31
|
+
return [encoded as LogTopic]
|
|
32
|
+
}
|
|
@@ -18,16 +18,11 @@ import type {
|
|
|
18
18
|
} from '../../types/contract.js'
|
|
19
19
|
import type { Filter } from '../../types/filter.js'
|
|
20
20
|
import type { Log } from '../../types/log.js'
|
|
21
|
-
import type { LogTopic } from '../../types/misc.js'
|
|
22
21
|
import type { GetPollOptions } from '../../types/transport.js'
|
|
23
22
|
import {
|
|
24
23
|
AbiEventAmbiguityError,
|
|
25
24
|
decodeEventLog,
|
|
26
25
|
} from '../../utils/abi/decodeEventLog.js'
|
|
27
|
-
import {
|
|
28
|
-
type EncodeEventTopicsParameters,
|
|
29
|
-
encodeEventTopics,
|
|
30
|
-
} from '../../utils/abi/encodeEventTopics.js'
|
|
31
26
|
import { formatLog } from '../../utils/formatters/log.js'
|
|
32
27
|
import { getAction } from '../../utils/getAction.js'
|
|
33
28
|
import { type ObserveErrorType, observe } from '../../utils/observe.js'
|
|
@@ -40,6 +35,7 @@ import {
|
|
|
40
35
|
import { getBlockNumber } from './getBlockNumber.js'
|
|
41
36
|
import { getFilterChanges } from './getFilterChanges.js'
|
|
42
37
|
import { type GetLogsParameters, getLogs } from './getLogs.js'
|
|
38
|
+
import { encodeEventFilterTopics } from './internal/encodeEventFilterTopics.js'
|
|
43
39
|
import { isRangeError } from './internal/isRangeError.js'
|
|
44
40
|
import {
|
|
45
41
|
getSubscriptionTransport,
|
|
@@ -339,19 +335,7 @@ export function watchEvent<
|
|
|
339
335
|
const transport = getSubscriptionTransport(client)
|
|
340
336
|
|
|
341
337
|
const events_ = events ?? (event ? [event] : undefined)
|
|
342
|
-
|
|
343
|
-
if (events_) {
|
|
344
|
-
const encoded = (events_ as AbiEvent[]).flatMap((event) =>
|
|
345
|
-
encodeEventTopics({
|
|
346
|
-
abi: [event],
|
|
347
|
-
eventName: (event as AbiEvent).name,
|
|
348
|
-
args,
|
|
349
|
-
} as EncodeEventTopicsParameters),
|
|
350
|
-
)
|
|
351
|
-
// TODO: Clean up type casting
|
|
352
|
-
topics = [encoded as LogTopic]
|
|
353
|
-
if (event) topics = topics[0] as LogTopic[]
|
|
354
|
-
}
|
|
338
|
+
const topics = encodeEventFilterTopics({ args, event, events })
|
|
355
339
|
|
|
356
340
|
const { unsubscribe: unsubscribe_ } = await transport.subscribe({
|
|
357
341
|
params: ['logs', { address, topics }],
|
package/celo/parsers.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { GetSerializedTransactionType } from '../utils/transaction/getSeria
|
|
|
11
11
|
import {
|
|
12
12
|
type ParseTransactionReturnType as ParseTransactionReturnType_,
|
|
13
13
|
parseAccessList,
|
|
14
|
+
parseEIP155Signature,
|
|
14
15
|
toTransactionArray,
|
|
15
16
|
} from '../utils/transaction/parseTransaction.js'
|
|
16
17
|
import {
|
|
@@ -129,7 +130,12 @@ function parseTransactionCIP42(
|
|
|
129
130
|
|
|
130
131
|
assertTransactionCIP42(transaction as TransactionSerializableCIP42)
|
|
131
132
|
|
|
132
|
-
|
|
133
|
+
const signature =
|
|
134
|
+
transactionArray.length === 15
|
|
135
|
+
? parseEIP155Signature(transactionArray as RecursiveArray<Hex>)
|
|
136
|
+
: undefined
|
|
137
|
+
|
|
138
|
+
return { ...signature, ...transaction } as TransactionSerializableCIP42
|
|
133
139
|
}
|
|
134
140
|
|
|
135
141
|
function parseTransactionCIP64(
|
|
@@ -200,5 +206,10 @@ function parseTransactionCIP64(
|
|
|
200
206
|
|
|
201
207
|
assertTransactionCIP64(transaction as TransactionSerializableCIP64)
|
|
202
208
|
|
|
203
|
-
|
|
209
|
+
const signature =
|
|
210
|
+
transactionArray.length === 13
|
|
211
|
+
? parseEIP155Signature(transactionArray as RecursiveArray<Hex>)
|
|
212
|
+
: undefined
|
|
213
|
+
|
|
214
|
+
return { ...signature, ...transaction } as TransactionSerializableCIP64
|
|
204
215
|
}
|
package/errors/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.58.
|
|
1
|
+
export const version = '2.58.3'
|
package/package.json
CHANGED
package/tempo/Abis.ts
CHANGED
|
@@ -1690,6 +1690,29 @@ export const tip20ChannelReserve = [
|
|
|
1690
1690
|
],
|
|
1691
1691
|
outputs: [{ type: 'bytes32' }],
|
|
1692
1692
|
},
|
|
1693
|
+
{
|
|
1694
|
+
name: 'verifyVoucher',
|
|
1695
|
+
type: 'function',
|
|
1696
|
+
stateMutability: 'view',
|
|
1697
|
+
inputs: [
|
|
1698
|
+
{
|
|
1699
|
+
type: 'tuple',
|
|
1700
|
+
name: 'descriptor',
|
|
1701
|
+
components: [
|
|
1702
|
+
{ type: 'address', name: 'payer' },
|
|
1703
|
+
{ type: 'address', name: 'payee' },
|
|
1704
|
+
{ type: 'address', name: 'operator' },
|
|
1705
|
+
{ type: 'address', name: 'token' },
|
|
1706
|
+
{ type: 'bytes32', name: 'salt' },
|
|
1707
|
+
{ type: 'address', name: 'authorizedSigner' },
|
|
1708
|
+
{ type: 'bytes32', name: 'expiringNonceHash' },
|
|
1709
|
+
],
|
|
1710
|
+
},
|
|
1711
|
+
{ type: 'uint96', name: 'cumulativeAmount' },
|
|
1712
|
+
{ type: 'bytes', name: 'signature' },
|
|
1713
|
+
],
|
|
1714
|
+
outputs: [{ type: 'bool', name: 'valid' }],
|
|
1715
|
+
},
|
|
1693
1716
|
{
|
|
1694
1717
|
name: 'domainSeparator',
|
|
1695
1718
|
type: 'function',
|
|
@@ -1764,7 +1787,7 @@ export const tip20ChannelReserve = [
|
|
|
1764
1787
|
],
|
|
1765
1788
|
},
|
|
1766
1789
|
{
|
|
1767
|
-
name: '
|
|
1790
|
+
name: 'OpeningCommitmentRecorded',
|
|
1768
1791
|
type: 'event',
|
|
1769
1792
|
inputs: [
|
|
1770
1793
|
{ type: 'bytes32', name: 'channelId', indexed: true },
|
package/tempo/Decorator.ts
CHANGED
|
@@ -1208,6 +1208,31 @@ type DecoratorBase<
|
|
|
1208
1208
|
topUpSync: (
|
|
1209
1209
|
parameters: channelActions.topUpSync.Parameters<chain, account>,
|
|
1210
1210
|
) => Promise<channelActions.topUpSync.ReturnValue>
|
|
1211
|
+
/**
|
|
1212
|
+
* Verifies a TIP-20 channel reserve voucher signature.
|
|
1213
|
+
*
|
|
1214
|
+
* Returns whether `signature` is a valid voucher for `cumulativeAmount` from the
|
|
1215
|
+
* channel's voucher signer (`authorizedSigner` if set, else the payer). It does
|
|
1216
|
+
* not check `cumulativeAmount` against the channel's deposit or settled amount.
|
|
1217
|
+
* Throws `ChannelNotFoundError` when the channel does not exist.
|
|
1218
|
+
*
|
|
1219
|
+
* @example
|
|
1220
|
+
* ```ts
|
|
1221
|
+
* import { parseUnits } from 'viem'
|
|
1222
|
+
*
|
|
1223
|
+
* const valid = await client.channel.verifyVoucher({
|
|
1224
|
+
* channel,
|
|
1225
|
+
* cumulativeAmount: parseUnits('40', 6),
|
|
1226
|
+
* signature: '0x...',
|
|
1227
|
+
* })
|
|
1228
|
+
* ```
|
|
1229
|
+
*
|
|
1230
|
+
* @param parameters - Parameters.
|
|
1231
|
+
* @returns Whether the voucher signature is valid.
|
|
1232
|
+
*/
|
|
1233
|
+
verifyVoucher: (
|
|
1234
|
+
parameters: channelActions.verifyVoucher.Parameters,
|
|
1235
|
+
) => Promise<channelActions.verifyVoucher.ReturnValue>
|
|
1211
1236
|
/**
|
|
1212
1237
|
* Withdraws payer funds after the close grace period elapses.
|
|
1213
1238
|
*
|
|
@@ -6348,6 +6373,7 @@ export function decorator() {
|
|
|
6348
6373
|
'signVoucher',
|
|
6349
6374
|
'topUp',
|
|
6350
6375
|
'topUpSync',
|
|
6376
|
+
'verifyVoucher',
|
|
6351
6377
|
'withdraw',
|
|
6352
6378
|
'withdrawSync',
|
|
6353
6379
|
]),
|
package/tempo/Selectors.ts
CHANGED
|
@@ -163,6 +163,7 @@ export const tip20ChannelReserve = {
|
|
|
163
163
|
settle: '0x97fb5104',
|
|
164
164
|
storageCredits: '0x4d65338b',
|
|
165
165
|
topUp: '0xdc48471e',
|
|
166
|
+
verifyVoucher: '0xcabd6d5a',
|
|
166
167
|
withdraw: '0x41e2c664',
|
|
167
168
|
} as const satisfies FunctionSelectors<typeof Abis.tip20ChannelReserve>
|
|
168
169
|
|
package/tempo/actions/channel.ts
CHANGED
|
@@ -1223,6 +1223,98 @@ export namespace topUpSync {
|
|
|
1223
1223
|
export type ErrorType = topUp.ErrorType
|
|
1224
1224
|
}
|
|
1225
1225
|
|
|
1226
|
+
/**
|
|
1227
|
+
* Verifies a TIP-20 channel reserve voucher signature.
|
|
1228
|
+
*
|
|
1229
|
+
* Returns whether `signature` is a valid voucher for `cumulativeAmount` from the
|
|
1230
|
+
* channel's voucher signer (`authorizedSigner` if set, else the payer). It does
|
|
1231
|
+
* not check `cumulativeAmount` against the channel's deposit or settled amount.
|
|
1232
|
+
* Throws `ChannelNotFoundError` when the channel does not exist.
|
|
1233
|
+
*
|
|
1234
|
+
* @example
|
|
1235
|
+
* ```ts
|
|
1236
|
+
* import { createClient, http, parseUnits } from 'viem'
|
|
1237
|
+
* import { tempo } from 'viem/chains'
|
|
1238
|
+
* import { Actions } from 'viem/tempo'
|
|
1239
|
+
*
|
|
1240
|
+
* const client = createClient({
|
|
1241
|
+
* chain: tempo,
|
|
1242
|
+
* transport: http(),
|
|
1243
|
+
* })
|
|
1244
|
+
*
|
|
1245
|
+
* const valid = await Actions.channel.verifyVoucher(client, {
|
|
1246
|
+
* channel,
|
|
1247
|
+
* cumulativeAmount: parseUnits('40', 6),
|
|
1248
|
+
* signature: '0x...',
|
|
1249
|
+
* })
|
|
1250
|
+
* ```
|
|
1251
|
+
*
|
|
1252
|
+
* @param client - Client.
|
|
1253
|
+
* @param parameters - Parameters.
|
|
1254
|
+
* @returns Whether the voucher signature is valid.
|
|
1255
|
+
*/
|
|
1256
|
+
export async function verifyVoucher<chain extends Chain | undefined>(
|
|
1257
|
+
client: Client<Transport, chain>,
|
|
1258
|
+
parameters: verifyVoucher.Parameters,
|
|
1259
|
+
): Promise<verifyVoucher.ReturnValue> {
|
|
1260
|
+
const { channel, cumulativeAmount, signature, ...rest } = parameters
|
|
1261
|
+
return withExecutionError(readContract)(client, {
|
|
1262
|
+
...rest,
|
|
1263
|
+
...verifyVoucher.call({ channel, cumulativeAmount, signature }),
|
|
1264
|
+
} as never) as never
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
export namespace verifyVoucher {
|
|
1268
|
+
export type Parameters = ReadParameters & Args
|
|
1269
|
+
|
|
1270
|
+
export type Args = {
|
|
1271
|
+
/** TIP-20 channel. */
|
|
1272
|
+
channel: ox_Channel.from.Value
|
|
1273
|
+
/** Total voucher amount signed for the channel. */
|
|
1274
|
+
cumulativeAmount: bigint
|
|
1275
|
+
/** Voucher signature. */
|
|
1276
|
+
signature: Hex.Hex
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
export type ReturnValue = boolean
|
|
1280
|
+
|
|
1281
|
+
// TODO: exhaustive error type
|
|
1282
|
+
export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
|
|
1283
|
+
|
|
1284
|
+
/**
|
|
1285
|
+
* Defines a call to the `verifyVoucher` function.
|
|
1286
|
+
*
|
|
1287
|
+
* Can be passed as a parameter to:
|
|
1288
|
+
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
|
|
1289
|
+
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
|
|
1290
|
+
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
|
|
1291
|
+
*
|
|
1292
|
+
* @example
|
|
1293
|
+
* ```ts
|
|
1294
|
+
* import { parseUnits } from 'viem'
|
|
1295
|
+
* import { Actions } from 'viem/tempo'
|
|
1296
|
+
*
|
|
1297
|
+
* const call = Actions.channel.verifyVoucher.call({
|
|
1298
|
+
* channel,
|
|
1299
|
+
* cumulativeAmount: parseUnits('40', 6),
|
|
1300
|
+
* signature: '0x...',
|
|
1301
|
+
* })
|
|
1302
|
+
* ```
|
|
1303
|
+
*
|
|
1304
|
+
* @param args - Arguments.
|
|
1305
|
+
* @returns The call.
|
|
1306
|
+
*/
|
|
1307
|
+
export function call(args: Args) {
|
|
1308
|
+
const { channel, cumulativeAmount, signature } = args
|
|
1309
|
+
return defineCall({
|
|
1310
|
+
address: ox_Channel.address,
|
|
1311
|
+
abi: Abis.tip20ChannelReserve,
|
|
1312
|
+
functionName: 'verifyVoucher',
|
|
1313
|
+
args: [ox_Channel.from(channel), cumulativeAmount, signature],
|
|
1314
|
+
})
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1226
1318
|
/**
|
|
1227
1319
|
* Withdraws payer funds after the close grace period elapses.
|
|
1228
1320
|
*
|
|
@@ -32,7 +32,9 @@ export const transactionReplacement = {
|
|
|
32
32
|
/**
|
|
33
33
|
* Returns the expiring nonce hash of a Tempo transaction:
|
|
34
34
|
* `keccak256(encodeForSigning(tx) || sender)`. It excludes the fee payer
|
|
35
|
-
* signature and
|
|
35
|
+
* signature, and for sponsored transactions also the fee token, since the
|
|
36
|
+
* sender does not sign it. Re-sponsoring a transaction keeps its hash, but
|
|
37
|
+
* unsponsored transactions that differ only in fee token hash differently.
|
|
36
38
|
*
|
|
37
39
|
* @internal
|
|
38
40
|
*/
|
package/utils/ccip.ts
CHANGED
|
@@ -304,10 +304,14 @@ export async function ccipRequest({
|
|
|
304
304
|
)
|
|
305
305
|
|
|
306
306
|
let result: any
|
|
307
|
+
let message: string | undefined
|
|
307
308
|
if (
|
|
308
309
|
response.headers.get('Content-Type')?.startsWith('application/json')
|
|
309
310
|
) {
|
|
310
|
-
|
|
311
|
+
const json = JSON.parse(responseBody)
|
|
312
|
+
result = json.data
|
|
313
|
+
// EIP-3668 gateways describe 4xx and 5xx errors as `{ message: string }`.
|
|
314
|
+
if (typeof json.message === 'string') message = json.message
|
|
311
315
|
} else {
|
|
312
316
|
result = responseBody
|
|
313
317
|
}
|
|
@@ -317,7 +321,7 @@ export async function ccipRequest({
|
|
|
317
321
|
body,
|
|
318
322
|
details: result?.error
|
|
319
323
|
? stringify(result.error)
|
|
320
|
-
: response.statusText,
|
|
324
|
+
: (message ?? response.statusText),
|
|
321
325
|
headers: response.headers,
|
|
322
326
|
status: response.status,
|
|
323
327
|
url,
|
|
@@ -129,7 +129,7 @@ export function resolveAvatarUri({
|
|
|
129
129
|
if (uri.startsWith('http') && !isIPNS && !isIPFS) {
|
|
130
130
|
let replacedUri = uri
|
|
131
131
|
if (gatewayUrls?.arweave)
|
|
132
|
-
replacedUri = uri.replace(/https:\/\/arweave.net/g,
|
|
132
|
+
replacedUri = uri.replace(/https:\/\/arweave.net/g, arweaveGateway)
|
|
133
133
|
return { uri: replacedUri, isOnChain: false, isEncoded: false }
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -119,11 +119,11 @@ export function createSiweMessage(
|
|
|
119
119
|
],
|
|
120
120
|
})
|
|
121
121
|
const statement = parameters.statement
|
|
122
|
-
if (statement
|
|
122
|
+
if (statement && /[\r\n\u2028\u2029]/.test(statement))
|
|
123
123
|
throw new SiweInvalidMessageFieldError({
|
|
124
124
|
field: 'statement',
|
|
125
125
|
metaMessages: [
|
|
126
|
-
|
|
126
|
+
'- Statement must not include a line break.',
|
|
127
127
|
'',
|
|
128
128
|
`Provided value: ${statement}`,
|
|
129
129
|
],
|
|
@@ -28,8 +28,17 @@ function parseSiweDateTime(value: string): Date {
|
|
|
28
28
|
export function parseSiweMessage(
|
|
29
29
|
message: string,
|
|
30
30
|
): Prettify<ExactPartial<SiweMessage>> {
|
|
31
|
-
const
|
|
32
|
-
|
|
31
|
+
const prefixMatch = message.match(prefixRegex)
|
|
32
|
+
const suffixMatch = message.match(suffixRegex)
|
|
33
|
+
// A statement with a line break skips the optional `statement` group, so
|
|
34
|
+
// check the text between the blank line after the address and the suffix.
|
|
35
|
+
if (prefixMatch && suffixMatch) {
|
|
36
|
+
const section = message
|
|
37
|
+
.slice(message.indexOf('\n\n') + 2, suffixMatch.index)
|
|
38
|
+
.replace(/\n\n?$/, '')
|
|
39
|
+
if (/[\r\n\u2028\u2029]/.test(section)) return {}
|
|
40
|
+
}
|
|
41
|
+
const { scheme, statement, ...prefix } = (prefixMatch?.groups ?? {}) as {
|
|
33
42
|
address: Address
|
|
34
43
|
domain: string
|
|
35
44
|
scheme?: string
|
|
@@ -43,7 +52,7 @@ export function parseSiweMessage(
|
|
|
43
52
|
requestId,
|
|
44
53
|
resources: resources_,
|
|
45
54
|
...suffix
|
|
46
|
-
} = (
|
|
55
|
+
} = (suffixMatch?.groups ?? {}) as {
|
|
47
56
|
chainId: string
|
|
48
57
|
expirationTime?: string
|
|
49
58
|
issuedAt?: string
|
|
@@ -77,4 +86,4 @@ const prefixRegex =
|
|
|
77
86
|
|
|
78
87
|
// https://regexr.com/80gf9
|
|
79
88
|
const suffixRegex =
|
|
80
|
-
|
|
89
|
+
/^(?:URI: (?<uri>.+))\n(?:Version: (?<version>.+))\n(?:Chain ID: (?<chainId>\d+))\n(?:Nonce: (?<nonce>[a-zA-Z0-9]+))\n(?:Issued At: (?<issuedAt>.+))(?:\nExpiration Time: (?<expirationTime>.+))?(?:\nNot Before: (?<notBefore>.+))?(?:\nRequest ID: (?<requestId>.*))?(?:\nResources:(?<resources>(?:\n- .+)*))?/m
|
|
@@ -55,7 +55,8 @@ export function validateSiweMessage(
|
|
|
55
55
|
|
|
56
56
|
if (domain && message.domain !== domain) return false
|
|
57
57
|
if (nonce && message.nonce !== nonce) return false
|
|
58
|
-
if
|
|
58
|
+
// EIP-4361: if `scheme` is not specified, HTTPS is assumed by default.
|
|
59
|
+
if (scheme && (message.scheme ?? 'https') !== scheme) return false
|
|
59
60
|
|
|
60
61
|
// EIP-4361 requires `nonce = 8*( ALPHA / DIGIT )` and `version = "1"`.
|
|
61
62
|
if (message.nonce !== undefined && !nonceRegex.test(message.nonce))
|
package/utils/stateOverride.ts
CHANGED
|
@@ -90,11 +90,13 @@ export function serializeStateOverride(
|
|
|
90
90
|
): RpcStateOverride | undefined {
|
|
91
91
|
if (!parameters) return undefined
|
|
92
92
|
const rpcStateOverride: RpcStateOverride = {}
|
|
93
|
+
const addresses = new Set<string>()
|
|
93
94
|
for (const { address, ...accountState } of parameters) {
|
|
94
95
|
if (!isAddress(address, { strict: false }))
|
|
95
96
|
throw new InvalidAddressError({ address })
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
const key = address.toLowerCase()
|
|
98
|
+
if (addresses.has(key)) throw new AccountStateConflictError({ address })
|
|
99
|
+
addresses.add(key)
|
|
98
100
|
rpcStateOverride[address] = serializeAccountStateOverride(accountState)
|
|
99
101
|
}
|
|
100
102
|
return rpcStateOverride
|
|
@@ -624,7 +624,7 @@ type ParseEIP155SignatureErrorType =
|
|
|
624
624
|
| PadHexErrorType
|
|
625
625
|
| ErrorType
|
|
626
626
|
|
|
627
|
-
function parseEIP155Signature(
|
|
627
|
+
export function parseEIP155Signature(
|
|
628
628
|
transactionArray: RecursiveArray<Hex>,
|
|
629
629
|
): Signature & { yParity: number } {
|
|
630
630
|
const signature = transactionArray.slice(-3)
|