viem 2.55.11 → 2.55.13
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 +22 -0
- package/_cjs/actions/wallet/prepareTransactionRequest.js +12 -12
- package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_cjs/actions/wallet/sendTransaction.js +24 -12
- package/_cjs/actions/wallet/sendTransaction.js.map +1 -1
- package/_cjs/actions/wallet/sendTransactionSync.js +24 -12
- package/_cjs/actions/wallet/sendTransactionSync.js.map +1 -1
- package/_cjs/clients/createClient.js +1 -0
- package/_cjs/clients/createClient.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/tempo/Decorator.js +7 -0
- package/_cjs/tempo/Decorator.js.map +1 -1
- package/_cjs/tempo/actions/earn/deployment.js +654 -0
- package/_cjs/tempo/actions/earn/deployment.js.map +1 -0
- package/_cjs/tempo/actions/earn.js +15 -0
- package/_cjs/tempo/actions/earn.js.map +1 -1
- package/_cjs/tempo/actions/zone.js +11 -1
- package/_cjs/tempo/actions/zone.js.map +1 -1
- package/_cjs/tempo/chainConfig.js +24 -23
- package/_cjs/tempo/chainConfig.js.map +1 -1
- package/_cjs/tempo/internal/WithdrawalSenderTag.js +2 -2
- package/_cjs/tempo/internal/WithdrawalSenderTag.js.map +1 -1
- package/_cjs/tempo/zones/Abis.js +17 -0
- package/_cjs/tempo/zones/Abis.js.map +1 -1
- package/_esm/actions/wallet/prepareTransactionRequest.js +14 -13
- package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_esm/actions/wallet/sendTransaction.js +24 -12
- package/_esm/actions/wallet/sendTransaction.js.map +1 -1
- package/_esm/actions/wallet/sendTransactionSync.js +24 -12
- package/_esm/actions/wallet/sendTransactionSync.js.map +1 -1
- package/_esm/clients/createClient.js +4 -3
- package/_esm/clients/createClient.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/tempo/Decorator.js +7 -0
- package/_esm/tempo/Decorator.js.map +1 -1
- package/_esm/tempo/actions/earn/deployment.js +967 -0
- package/_esm/tempo/actions/earn/deployment.js.map +1 -0
- package/_esm/tempo/actions/earn.js +2 -0
- package/_esm/tempo/actions/earn.js.map +1 -1
- package/_esm/tempo/actions/zone.js +11 -1
- package/_esm/tempo/actions/zone.js.map +1 -1
- package/_esm/tempo/chainConfig.js +26 -28
- package/_esm/tempo/chainConfig.js.map +1 -1
- package/_esm/tempo/internal/WithdrawalSenderTag.js +3 -3
- package/_esm/tempo/internal/WithdrawalSenderTag.js.map +1 -1
- package/_esm/tempo/zones/Abis.js +17 -0
- package/_esm/tempo/zones/Abis.js.map +1 -1
- package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
- package/_types/actions/wallet/sendTransaction.d.ts.map +1 -1
- package/_types/actions/wallet/sendTransactionSync.d.ts.map +1 -1
- package/_types/clients/createClient.d.ts +3 -3
- package/_types/clients/createClient.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/tempo/Decorator.d.ts +18 -0
- package/_types/tempo/Decorator.d.ts.map +1 -1
- package/_types/tempo/actions/earn/deployment.d.ts +1710 -0
- package/_types/tempo/actions/earn/deployment.d.ts.map +1 -0
- package/_types/tempo/actions/earn.d.ts +1 -1
- package/_types/tempo/actions/earn.d.ts.map +1 -1
- package/_types/tempo/actions/zone.d.ts.map +1 -1
- package/_types/tempo/chainConfig.d.ts.map +1 -1
- package/_types/tempo/internal/WithdrawalSenderTag.d.ts +2 -1
- package/_types/tempo/internal/WithdrawalSenderTag.d.ts.map +1 -1
- package/_types/tempo/zones/Abis.d.ts +48 -0
- package/_types/tempo/zones/Abis.d.ts.map +1 -1
- package/actions/wallet/prepareTransactionRequest.ts +18 -17
- package/actions/wallet/sendTransaction.ts +25 -10
- package/actions/wallet/sendTransactionSync.ts +25 -10
- package/clients/createClient.ts +4 -3
- package/errors/version.ts +1 -1
- package/package.json +1 -1
- package/tempo/Decorator.ts +41 -0
- package/tempo/actions/earn/deployment.ts +1427 -0
- package/tempo/actions/earn.ts +3 -0
- package/tempo/actions/zone.ts +10 -1
- package/tempo/chainConfig.ts +30 -27
- package/tempo/internal/WithdrawalSenderTag.ts +5 -4
- package/tempo/zones/Abis.ts +17 -0
package/tempo/actions/earn.ts
CHANGED
|
@@ -67,6 +67,9 @@ import * as policyActions from './policy.js'
|
|
|
67
67
|
import * as tokenActions from './token.js'
|
|
68
68
|
import * as zoneActions from './zone.js'
|
|
69
69
|
|
|
70
|
+
// biome-ignore lint/performance/noBarrelFile: namespace module
|
|
71
|
+
export * from './earn/deployment.js'
|
|
72
|
+
|
|
70
73
|
/** TIP-403 policy ID that allows every sender, recipient, and mint recipient. */
|
|
71
74
|
export const alwaysAllowPolicyId = 1n
|
|
72
75
|
|
package/tempo/actions/zone.ts
CHANGED
|
@@ -29,6 +29,7 @@ import { zeroHash } from '../../constants/bytes.js'
|
|
|
29
29
|
import type { BaseErrorType } from '../../errors/base.js'
|
|
30
30
|
import type { Chain, GetChainParameter } from '../../types/chain.js'
|
|
31
31
|
import type { Compute, UnionOmit } from '../../types/utils.js'
|
|
32
|
+
import { parseEventLogs } from '../../utils/abi/parseEventLogs.js'
|
|
32
33
|
import type { RequestErrorType } from '../../utils/buildRequest.js'
|
|
33
34
|
import { type ObserveErrorType, observe } from '../../utils/observe.js'
|
|
34
35
|
import { type PollErrorType, poll } from '../../utils/poll.js'
|
|
@@ -1547,8 +1548,16 @@ export async function requestWithdrawalSync<
|
|
|
1547
1548
|
gas: parameters.gas ?? defaultWithdrawalGas,
|
|
1548
1549
|
throwOnReceiptRevert,
|
|
1549
1550
|
} as never)
|
|
1551
|
+
const [event] = parseEventLogs({
|
|
1552
|
+
abi: ZoneAbis.zoneOutbox,
|
|
1553
|
+
logs: receipt.logs,
|
|
1554
|
+
eventName: 'WithdrawalRequested',
|
|
1555
|
+
strict: true,
|
|
1556
|
+
})
|
|
1557
|
+
if (!event) throw new Error('`WithdrawalRequested` event not found.')
|
|
1550
1558
|
const senderTag = WithdrawalSenderTag.from({
|
|
1551
|
-
|
|
1559
|
+
fallbackNonce: event.args.fallbackNonce,
|
|
1560
|
+
sender: event.args.sender,
|
|
1552
1561
|
transactionHash: receipt.transactionHash,
|
|
1553
1562
|
})
|
|
1554
1563
|
return { receipt, senderTag }
|
package/tempo/chainConfig.ts
CHANGED
|
@@ -116,6 +116,36 @@ export const chainConfig = {
|
|
|
116
116
|
if (request.account?.source !== 'multisig') delete request.account
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
// Register concurrency before account preparation performs storage or
|
|
120
|
+
// network I/O so overlapping requests cannot miss each other.
|
|
121
|
+
const useExpiringNonce = await (async () => {
|
|
122
|
+
if (request.nonceKey === 'expiring' || request.nonceKey === maxUint256)
|
|
123
|
+
return true
|
|
124
|
+
if (multisig) return false
|
|
125
|
+
if (request.feePayer && typeof request.nonceKey === 'undefined')
|
|
126
|
+
return true
|
|
127
|
+
const account = request.account as
|
|
128
|
+
| Account
|
|
129
|
+
| MultisigAccount
|
|
130
|
+
| Address
|
|
131
|
+
| undefined
|
|
132
|
+
const address = typeof account === 'string' ? account : account?.address
|
|
133
|
+
if (address && typeof request.nonceKey === 'undefined')
|
|
134
|
+
return await Concurrent.detect(address.toLowerCase())
|
|
135
|
+
return false
|
|
136
|
+
})()
|
|
137
|
+
|
|
138
|
+
if (useExpiringNonce) {
|
|
139
|
+
request.nonceKey = maxUint256
|
|
140
|
+
request.nonce = 0
|
|
141
|
+
if (typeof request.validAfter === 'undefined')
|
|
142
|
+
request.validAfter = randomValidAfter()
|
|
143
|
+
if (typeof request.validBefore === 'undefined')
|
|
144
|
+
request.validBefore = Math.floor(Date.now() / 1000) + maxExpirySecs
|
|
145
|
+
} else if (typeof request.nonceKey !== 'undefined') {
|
|
146
|
+
request.nonce = typeof request.nonce === 'number' ? request.nonce : 0
|
|
147
|
+
}
|
|
148
|
+
|
|
119
149
|
if (
|
|
120
150
|
!request.keyAuthorization &&
|
|
121
151
|
request.account?.source === 'accessKey'
|
|
@@ -156,33 +186,6 @@ export const chainConfig = {
|
|
|
156
186
|
}
|
|
157
187
|
}
|
|
158
188
|
|
|
159
|
-
// Use expiring nonces for concurrent transactions (TIP-1009).
|
|
160
|
-
// When nonceKey is 'expiring', feePayer is specified, or concurrent requests
|
|
161
|
-
// are detected, we use expiring nonces (nonceKey = uint256.max) with a
|
|
162
|
-
// validBefore timestamp.
|
|
163
|
-
const useExpiringNonce = await (async () => {
|
|
164
|
-
if (request.nonceKey === 'expiring') return true
|
|
165
|
-
if (multisig) return false
|
|
166
|
-
if (request.feePayer && typeof request.nonceKey === 'undefined')
|
|
167
|
-
return true
|
|
168
|
-
const address = request.account?.address
|
|
169
|
-
if (address && typeof request.nonceKey === 'undefined')
|
|
170
|
-
return await Concurrent.detect(address)
|
|
171
|
-
return false
|
|
172
|
-
})()
|
|
173
|
-
|
|
174
|
-
if (useExpiringNonce) {
|
|
175
|
-
request.nonceKey = maxUint256
|
|
176
|
-
request.nonce = 0
|
|
177
|
-
if (typeof request.validAfter === 'undefined')
|
|
178
|
-
request.validAfter = randomValidAfter()
|
|
179
|
-
if (typeof request.validBefore === 'undefined')
|
|
180
|
-
request.validBefore = Math.floor(Date.now() / 1000) + maxExpirySecs
|
|
181
|
-
} else if (typeof request.nonceKey !== 'undefined') {
|
|
182
|
-
// Explicit nonceKey provided (2D nonce mode)
|
|
183
|
-
request.nonce = typeof request.nonce === 'number' ? request.nonce : 0
|
|
184
|
-
}
|
|
185
|
-
|
|
186
189
|
if (!request.feeToken && request.chain?.feeToken)
|
|
187
190
|
request.feeToken = request.chain.feeToken
|
|
188
191
|
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import type { Address } from 'abitype'
|
|
2
2
|
import { AbiParameters, Hash, type Hex } from 'ox'
|
|
3
3
|
|
|
4
|
-
/** Derives a withdrawal sender tag
|
|
4
|
+
/** Derives a user withdrawal sender tag. @internal */
|
|
5
5
|
export function from(options: from.Options): Hex.Hex {
|
|
6
|
-
const { sender, transactionHash } = options
|
|
6
|
+
const { fallbackNonce, sender, transactionHash } = options
|
|
7
7
|
return Hash.keccak256(
|
|
8
8
|
AbiParameters.encodePacked(
|
|
9
|
-
['address', 'bytes32'],
|
|
10
|
-
[sender, transactionHash],
|
|
9
|
+
['address', 'bytes32', 'uint64'],
|
|
10
|
+
[sender, transactionHash, fallbackNonce],
|
|
11
11
|
),
|
|
12
12
|
)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export declare namespace from {
|
|
16
16
|
type Options = {
|
|
17
|
+
fallbackNonce: bigint
|
|
17
18
|
sender: Address
|
|
18
19
|
transactionHash: Hex.Hex
|
|
19
20
|
}
|
package/tempo/zones/Abis.ts
CHANGED
|
@@ -168,6 +168,23 @@ export const zonePortal = [
|
|
|
168
168
|
] as const
|
|
169
169
|
|
|
170
170
|
export const zoneOutbox = [
|
|
171
|
+
{
|
|
172
|
+
name: 'WithdrawalRequested',
|
|
173
|
+
type: 'event',
|
|
174
|
+
inputs: [
|
|
175
|
+
{ name: 'withdrawalIndex', type: 'uint64', indexed: true },
|
|
176
|
+
{ name: 'sender', type: 'address', indexed: true },
|
|
177
|
+
{ name: 'token', type: 'address', indexed: false },
|
|
178
|
+
{ name: 'to', type: 'address', indexed: false },
|
|
179
|
+
{ name: 'amount', type: 'uint128', indexed: false },
|
|
180
|
+
{ name: 'fee', type: 'uint128', indexed: false },
|
|
181
|
+
{ name: 'memo', type: 'bytes32', indexed: false },
|
|
182
|
+
{ name: 'gasLimit', type: 'uint64', indexed: false },
|
|
183
|
+
{ name: 'fallbackNonce', type: 'uint64', indexed: false },
|
|
184
|
+
{ name: 'data', type: 'bytes', indexed: false },
|
|
185
|
+
{ name: 'revealTo', type: 'bytes', indexed: false },
|
|
186
|
+
],
|
|
187
|
+
},
|
|
171
188
|
{
|
|
172
189
|
name: 'requestWithdrawal',
|
|
173
190
|
type: 'function',
|