viem 2.52.0 → 2.53.1
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 +44 -0
- package/_cjs/account-abstraction/actions/bundler/estimateUserOperationGas.js +2 -0
- package/_cjs/account-abstraction/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_cjs/chains/definitions/citrate.js +17 -0
- package/_cjs/chains/definitions/citrate.js.map +1 -0
- package/_cjs/chains/definitions/grav.js +24 -0
- package/_cjs/chains/definitions/grav.js.map +1 -0
- package/_cjs/chains/definitions/ladyChain.js +22 -0
- package/_cjs/chains/definitions/ladyChain.js.map +1 -0
- package/_cjs/chains/definitions/monad.js +5 -5
- package/_cjs/chains/definitions/monad.js.map +1 -1
- package/_cjs/chains/definitions/tempoModerato.js +1 -0
- package/_cjs/chains/definitions/tempoModerato.js.map +1 -1
- package/_cjs/chains/definitions/valygoNft.js +37 -0
- package/_cjs/chains/definitions/valygoNft.js.map +1 -0
- package/_cjs/chains/definitions/valygoSmartchain.js +37 -0
- package/_cjs/chains/definitions/valygoSmartchain.js.map +1 -0
- package/_cjs/chains/definitions/whitechainSepolia.js +31 -0
- package/_cjs/chains/definitions/whitechainSepolia.js.map +1 -0
- package/_cjs/chains/index.js +25 -13
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/tempo/Abis.js +1866 -1866
- package/_cjs/tempo/Abis.js.map +1 -1
- package/_cjs/tempo/Account.js +35 -3
- package/_cjs/tempo/Account.js.map +1 -1
- package/_cjs/tempo/Client.js +27 -0
- package/_cjs/tempo/Client.js.map +1 -0
- package/_cjs/tempo/Formatters.js +2 -1
- package/_cjs/tempo/Formatters.js.map +1 -1
- package/_cjs/tempo/Scopes.js +39 -0
- package/_cjs/tempo/Scopes.js.map +1 -0
- package/_cjs/tempo/Selectors.js +226 -0
- package/_cjs/tempo/Selectors.js.map +1 -0
- package/_cjs/tempo/Transaction.js +22 -0
- package/_cjs/tempo/Transaction.js.map +1 -1
- package/_cjs/tempo/chainConfig.js +10 -0
- package/_cjs/tempo/chainConfig.js.map +1 -1
- package/_cjs/tempo/index.js +14 -1
- package/_cjs/tempo/index.js.map +1 -1
- package/_esm/account-abstraction/actions/bundler/estimateUserOperationGas.js +2 -0
- package/_esm/account-abstraction/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_esm/chains/definitions/citrate.js +14 -0
- package/_esm/chains/definitions/citrate.js.map +1 -0
- package/_esm/chains/definitions/grav.js +21 -0
- package/_esm/chains/definitions/grav.js.map +1 -0
- package/_esm/chains/definitions/ladyChain.js +19 -0
- package/_esm/chains/definitions/ladyChain.js.map +1 -0
- package/_esm/chains/definitions/monad.js +5 -5
- package/_esm/chains/definitions/monad.js.map +1 -1
- package/_esm/chains/definitions/tempoModerato.js +1 -0
- package/_esm/chains/definitions/tempoModerato.js.map +1 -1
- package/_esm/chains/definitions/valygoNft.js +34 -0
- package/_esm/chains/definitions/valygoNft.js.map +1 -0
- package/_esm/chains/definitions/valygoSmartchain.js +34 -0
- package/_esm/chains/definitions/valygoSmartchain.js.map +1 -0
- package/_esm/chains/definitions/whitechainSepolia.js +28 -0
- package/_esm/chains/definitions/whitechainSepolia.js.map +1 -0
- package/_esm/chains/index.js +6 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/tempo/Abis.js +1865 -1865
- package/_esm/tempo/Abis.js.map +1 -1
- package/_esm/tempo/Account.js +81 -4
- package/_esm/tempo/Account.js.map +1 -1
- package/_esm/tempo/Client.js +66 -0
- package/_esm/tempo/Client.js.map +1 -0
- package/_esm/tempo/Formatters.js +5 -1
- package/_esm/tempo/Formatters.js.map +1 -1
- package/_esm/tempo/Scopes.js +49 -0
- package/_esm/tempo/Scopes.js.map +1 -0
- package/_esm/tempo/Selectors.js +224 -0
- package/_esm/tempo/Selectors.js.map +1 -0
- package/_esm/tempo/Transaction.js +34 -0
- package/_esm/tempo/Transaction.js.map +1 -1
- package/_esm/tempo/chainConfig.js +24 -1
- package/_esm/tempo/chainConfig.js.map +1 -1
- package/_esm/tempo/index.js +10 -1
- package/_esm/tempo/index.js.map +1 -1
- package/_types/account-abstraction/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
- package/_types/actions/wallet/prepareTransactionRequest.d.ts +12 -1
- package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
- package/_types/chains/definitions/citrate.d.ts +57 -0
- package/_types/chains/definitions/citrate.d.ts.map +1 -0
- package/_types/chains/definitions/grav.d.ts +43 -0
- package/_types/chains/definitions/grav.d.ts.map +1 -0
- package/_types/chains/definitions/ladyChain.d.ts +50 -0
- package/_types/chains/definitions/ladyChain.d.ts.map +1 -0
- package/_types/chains/definitions/monad.d.ts +5 -5
- package/_types/chains/definitions/tempo.d.ts +36 -0
- package/_types/chains/definitions/tempo.d.ts.map +1 -1
- package/_types/chains/definitions/tempoDevnet.d.ts +36 -0
- package/_types/chains/definitions/tempoDevnet.d.ts.map +1 -1
- package/_types/chains/definitions/tempoLocalnet.d.ts +36 -0
- package/_types/chains/definitions/tempoLocalnet.d.ts.map +1 -1
- package/_types/chains/definitions/tempoModerato.d.ts +38 -0
- package/_types/chains/definitions/tempoModerato.d.ts.map +1 -1
- package/_types/chains/definitions/valygoNft.d.ts +48 -0
- package/_types/chains/definitions/valygoNft.d.ts.map +1 -0
- package/_types/chains/definitions/valygoSmartchain.d.ts +48 -0
- package/_types/chains/definitions/valygoSmartchain.d.ts.map +1 -0
- package/_types/chains/definitions/whitechainSepolia.d.ts +46 -0
- package/_types/chains/definitions/whitechainSepolia.d.ts.map +1 -0
- package/_types/chains/index.d.ts +6 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/tempo/Abis.d.ts +5816 -5816
- package/_types/tempo/Abis.d.ts.map +1 -1
- package/_types/tempo/Account.d.ts +48 -1
- package/_types/tempo/Account.d.ts.map +1 -1
- package/_types/tempo/Client.d.ts +98 -0
- package/_types/tempo/Client.d.ts.map +1 -0
- package/_types/tempo/Formatters.d.ts.map +1 -1
- package/_types/tempo/Scopes.d.ts +48 -0
- package/_types/tempo/Scopes.d.ts.map +1 -0
- package/_types/tempo/Selectors.d.ts +223 -0
- package/_types/tempo/Selectors.d.ts.map +1 -0
- package/_types/tempo/Transaction.d.ts +5 -1
- package/_types/tempo/Transaction.d.ts.map +1 -1
- package/_types/tempo/chainConfig.d.ts +34 -15
- package/_types/tempo/chainConfig.d.ts.map +1 -1
- package/_types/tempo/index.d.ts +10 -1
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/tempo/zones/zone.d.ts +108 -0
- package/_types/tempo/zones/zone.d.ts.map +1 -1
- package/account-abstraction/actions/bundler/estimateUserOperationGas.ts +2 -0
- package/actions/wallet/prepareTransactionRequest.ts +40 -5
- package/chains/definitions/citrate.ts +14 -0
- package/chains/definitions/grav.ts +21 -0
- package/chains/definitions/ladyChain.ts +19 -0
- package/chains/definitions/monad.ts +5 -5
- package/chains/definitions/tempoModerato.ts +1 -0
- package/chains/definitions/valygoNft.ts +34 -0
- package/chains/definitions/valygoSmartchain.ts +34 -0
- package/chains/definitions/whitechainSepolia.ts +28 -0
- package/chains/index.ts +6 -0
- package/errors/version.ts +1 -1
- package/package.json +3 -4
- package/tempo/Abis.ts +1869 -1869
- package/tempo/Account.ts +97 -4
- package/tempo/Client.ts +172 -0
- package/tempo/Formatters.ts +12 -1
- package/tempo/Scopes.ts +124 -0
- package/tempo/Selectors.ts +260 -0
- package/tempo/Transaction.ts +42 -0
- package/tempo/chainConfig.ts +32 -3
- package/tempo/index.ts +35 -0
package/tempo/Transaction.ts
CHANGED
|
@@ -7,6 +7,7 @@ import * as Signature from 'ox/Signature'
|
|
|
7
7
|
import {
|
|
8
8
|
type AuthorizationTempo,
|
|
9
9
|
type KeyAuthorization,
|
|
10
|
+
type MultisigConfig,
|
|
10
11
|
type TransactionReceipt as ox_TransactionReceipt,
|
|
11
12
|
SignatureEnvelope,
|
|
12
13
|
type TempoAddress,
|
|
@@ -124,7 +125,9 @@ export type TransactionRequestTempo<
|
|
|
124
125
|
feePayer?: Account | true | undefined
|
|
125
126
|
feeToken?: TempoAddress.Address | bigint | undefined
|
|
126
127
|
keyAuthorization?: KeyAuthorization.Signed<quantity, index> | undefined
|
|
128
|
+
multisig?: MultisigConfig.Config<index> | undefined
|
|
127
129
|
nonceKey?: 'expiring' | quantity | undefined
|
|
130
|
+
signatures?: readonly SignatureEnvelope.Serialized[] | undefined
|
|
128
131
|
validBefore?: index | undefined
|
|
129
132
|
validAfter?: index | undefined
|
|
130
133
|
}
|
|
@@ -145,8 +148,10 @@ export type TransactionSerializableTempo<
|
|
|
145
148
|
feePayerSignature?: viem_Signature | null | undefined
|
|
146
149
|
from?: Address | undefined
|
|
147
150
|
keyAuthorization?: KeyAuthorization.Signed<quantity, index> | undefined
|
|
151
|
+
multisig?: MultisigConfig.Config<index> | undefined
|
|
148
152
|
nonceKey?: quantity | undefined
|
|
149
153
|
signature?: SignatureEnvelope.SignatureEnvelope<quantity, index> | undefined
|
|
154
|
+
signatures?: readonly SignatureEnvelope.Serialized[] | undefined
|
|
150
155
|
validBefore?: index | undefined
|
|
151
156
|
validAfter?: index | undefined
|
|
152
157
|
type?: 'tempo' | undefined
|
|
@@ -170,12 +175,16 @@ export function getType(
|
|
|
170
175
|
if (
|
|
171
176
|
(account?.keyType && account.keyType !== 'secp256k1') ||
|
|
172
177
|
account?.source === 'accessKey' ||
|
|
178
|
+
account?.source === 'multisig' ||
|
|
173
179
|
typeof transaction.calls !== 'undefined' ||
|
|
174
180
|
typeof transaction.feePayer !== 'undefined' ||
|
|
181
|
+
typeof transaction.feePayerSignature !== 'undefined' ||
|
|
175
182
|
typeof transaction.feeToken !== 'undefined' ||
|
|
176
183
|
typeof transaction.keyAuthorization !== 'undefined' ||
|
|
184
|
+
typeof transaction.multisig !== 'undefined' ||
|
|
177
185
|
typeof transaction.nonceKey !== 'undefined' ||
|
|
178
186
|
typeof transaction.signature !== 'undefined' ||
|
|
187
|
+
typeof transaction.signatures !== 'undefined' ||
|
|
179
188
|
typeof transaction.validBefore !== 'undefined' ||
|
|
180
189
|
typeof transaction.validAfter !== 'undefined'
|
|
181
190
|
)
|
|
@@ -337,6 +346,39 @@ async function serializeTempo(
|
|
|
337
346
|
// the fee payer.
|
|
338
347
|
if (shouldStripFeeTokenForSponsorship) delete transaction_ox.feeToken
|
|
339
348
|
|
|
349
|
+
// Native multisig (TIP-1061): combine the collected owner approvals into the
|
|
350
|
+
// multisig signature envelope and serialize the broadcast transaction. The
|
|
351
|
+
// approvals are recovered against the multisig owner digest and ordered into
|
|
352
|
+
// the strictly-ascending owner address order the node requires.
|
|
353
|
+
//
|
|
354
|
+
// Bootstrap (`init`) is auto-detected from the nonce: the protocol requires
|
|
355
|
+
// (and consumes) nonce `0` for the first transaction from a derived account,
|
|
356
|
+
// so `nonce == 0` uniquely identifies a bootstrap. This matches the serialized
|
|
357
|
+
// nonce above (a falsy `nonce` serializes as `0`). The owner approval digest
|
|
358
|
+
// doesn't commit to `init`, so attaching it here (rather than at owner-signing)
|
|
359
|
+
// is safe.
|
|
360
|
+
// NOTE: fee-payer + multisig is handled in a later phase.
|
|
361
|
+
if (transaction.multisig && transaction.signatures && !feePayer) {
|
|
362
|
+
const payload = TxTempo.getSignPayload(TxTempo.from(transaction_ox))
|
|
363
|
+
const signatures = transaction.signatures.map((approval) =>
|
|
364
|
+
SignatureEnvelope.from(approval),
|
|
365
|
+
)
|
|
366
|
+
const sorted = SignatureEnvelope.sortMultisigApprovals({
|
|
367
|
+
payload,
|
|
368
|
+
signatures,
|
|
369
|
+
genesisConfig: transaction.multisig,
|
|
370
|
+
})
|
|
371
|
+
const signature = SignatureEnvelope.from({
|
|
372
|
+
genesisConfig: transaction.multisig,
|
|
373
|
+
signatures: sorted,
|
|
374
|
+
...(nonce ? {} : { init: true }),
|
|
375
|
+
})
|
|
376
|
+
return TxTempo.serialize(transaction_ox, {
|
|
377
|
+
feePayerSignature: undefined,
|
|
378
|
+
signature,
|
|
379
|
+
})
|
|
380
|
+
}
|
|
381
|
+
|
|
340
382
|
if (signature && typeof transaction.feePayer === 'object') {
|
|
341
383
|
const tx = TxTempo.from(transaction_ox, {
|
|
342
384
|
signature,
|
package/tempo/chainConfig.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { Address } from 'abitype'
|
|
1
2
|
import * as Hex from 'ox/Hex'
|
|
2
|
-
import { SignatureEnvelope, type TokenId } from 'ox/tempo'
|
|
3
|
+
import { MultisigConfig, SignatureEnvelope, type TokenId } from 'ox/tempo'
|
|
3
4
|
import { getCode } from '../actions/public/getCode.js'
|
|
4
5
|
import { verifyHash } from '../actions/public/verifyHash.js'
|
|
5
6
|
import { maxUint256 } from '../constants/number.js'
|
|
@@ -12,7 +13,7 @@ import { defineTransactionRequest } from '../utils/formatters/transactionRequest
|
|
|
12
13
|
import { getAction } from '../utils/getAction.js'
|
|
13
14
|
import { keccak256 } from '../utils/hash/keccak256.js'
|
|
14
15
|
import type { SerializeTransactionFn } from '../utils/transaction/serializeTransaction.js'
|
|
15
|
-
import type { Account } from './Account.js'
|
|
16
|
+
import type { Account, MultisigAccount } from './Account.js'
|
|
16
17
|
import { getMetadata } from './actions/accessKey.js'
|
|
17
18
|
import * as Formatters from './Formatters.js'
|
|
18
19
|
import type { Hardfork } from './Hardfork.js'
|
|
@@ -42,13 +43,16 @@ export const chainConfig = {
|
|
|
42
43
|
prepareTransactionRequest: [
|
|
43
44
|
async (r, { client, phase }) => {
|
|
44
45
|
const request = r as Transaction.TransactionRequest & {
|
|
45
|
-
account?: Account | undefined
|
|
46
|
+
account?: Account | MultisigAccount | undefined
|
|
46
47
|
chainId?: number | undefined
|
|
47
48
|
chain?:
|
|
48
49
|
| (Chain & {
|
|
49
50
|
feeToken?: TokenId.TokenIdOrAddress | undefined
|
|
50
51
|
})
|
|
51
52
|
| undefined
|
|
53
|
+
from?: Address | undefined
|
|
54
|
+
multisig?: MultisigConfig.Config | undefined
|
|
55
|
+
signatures?: readonly unknown[] | undefined
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
// FIXME: node estimates gas with secp256k1 dummy sig + null feePayerSignature.
|
|
@@ -60,9 +64,34 @@ export const chainConfig = {
|
|
|
60
64
|
else if (request.account?.source === 'accessKey')
|
|
61
65
|
request.gas = (request.gas ?? 0n) + 10_000n
|
|
62
66
|
}
|
|
67
|
+
|
|
63
68
|
return request as unknown as typeof r
|
|
64
69
|
}
|
|
65
70
|
|
|
71
|
+
// Native multisig (TIP-1061). The transaction sender is the derived
|
|
72
|
+
// multisig account, not a signing account (owner accounts only contribute
|
|
73
|
+
// approvals later via `signTransaction`). Derive the sender from the
|
|
74
|
+
// config; core fills nonce/gas/fees for it via `request.from`, and the
|
|
75
|
+
// serializer auto-detects bootstrap (`init`) from `nonce == 0`.
|
|
76
|
+
//
|
|
77
|
+
// The config is taken from an explicit `multisig` field, or inferred from
|
|
78
|
+
// a multisig account (so callers can just pass `account` to
|
|
79
|
+
// `prepareTransactionRequest` without also passing `multisig`).
|
|
80
|
+
const multisig =
|
|
81
|
+
request.multisig ??
|
|
82
|
+
(request.account?.source === 'multisig'
|
|
83
|
+
? (request.account as MultisigAccount).config
|
|
84
|
+
: undefined)
|
|
85
|
+
if (multisig) {
|
|
86
|
+
request.multisig = multisig
|
|
87
|
+
request.from = MultisigConfig.getAddress(multisig)
|
|
88
|
+
// A non-multisig `account` (e.g. the client's default) isn't the sender,
|
|
89
|
+
// so drop it: core then fills nonce/gas/fees for the multisig sender via
|
|
90
|
+
// `request.from`. A multisig account *is* the sender — keep it so the
|
|
91
|
+
// prepared request can be sent without re-passing `account`.
|
|
92
|
+
if (request.account?.source !== 'multisig') delete request.account
|
|
93
|
+
}
|
|
94
|
+
|
|
66
95
|
if (
|
|
67
96
|
!request.keyAuthorization &&
|
|
68
97
|
request.account?.source === 'accessKey'
|
package/tempo/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ export type {
|
|
|
13
13
|
} from 'ox/tempo'
|
|
14
14
|
export {
|
|
15
15
|
Channel,
|
|
16
|
+
MultisigConfig,
|
|
16
17
|
Period,
|
|
17
18
|
ReceivePolicyReceipt,
|
|
18
19
|
TempoAddress,
|
|
@@ -21,12 +22,42 @@ export {
|
|
|
21
22
|
VirtualAddress,
|
|
22
23
|
VirtualMaster,
|
|
23
24
|
} from 'ox/tempo'
|
|
25
|
+
export {
|
|
26
|
+
type CustomTransport,
|
|
27
|
+
type CustomTransportConfig,
|
|
28
|
+
type CustomTransportErrorType,
|
|
29
|
+
custom,
|
|
30
|
+
} from '../clients/transports/custom.js'
|
|
31
|
+
export {
|
|
32
|
+
type FallbackTransport,
|
|
33
|
+
type FallbackTransportConfig,
|
|
34
|
+
type FallbackTransportErrorType,
|
|
35
|
+
fallback,
|
|
36
|
+
} from '../clients/transports/fallback.js'
|
|
37
|
+
export {
|
|
38
|
+
type HttpTransport,
|
|
39
|
+
type HttpTransportConfig,
|
|
40
|
+
type HttpTransportErrorType,
|
|
41
|
+
http,
|
|
42
|
+
} from '../clients/transports/http.js'
|
|
43
|
+
export {
|
|
44
|
+
type WebSocketTransport,
|
|
45
|
+
type WebSocketTransportConfig,
|
|
46
|
+
type WebSocketTransportErrorType,
|
|
47
|
+
webSocket,
|
|
48
|
+
} from '../clients/transports/webSocket.js'
|
|
24
49
|
export * as Abis from './Abis.js'
|
|
25
50
|
export * as Account from './Account.js'
|
|
26
51
|
export * as Addresses from './Addresses.js'
|
|
27
52
|
export * as Actions from './actions/index.js'
|
|
28
53
|
export * as Capabilities from './Capabilities.js'
|
|
29
54
|
export * as Chain from './Chain.js'
|
|
55
|
+
export {
|
|
56
|
+
type Client,
|
|
57
|
+
type ClientConfig,
|
|
58
|
+
type CreateClientErrorType,
|
|
59
|
+
createClient,
|
|
60
|
+
} from './Client.js'
|
|
30
61
|
export {
|
|
31
62
|
type Decorator as TempoActions,
|
|
32
63
|
decorator as tempoActions,
|
|
@@ -37,6 +68,10 @@ export * as Formatters from './Formatters.js'
|
|
|
37
68
|
export * as Hardfork from './Hardfork.js'
|
|
38
69
|
export * as KeyAuthorizationManager from './KeyAuthorizationManager.js'
|
|
39
70
|
export * as P256 from './P256.js'
|
|
71
|
+
/** @experimental */
|
|
72
|
+
export * as Scopes from './Scopes.js'
|
|
73
|
+
/** @experimental */
|
|
74
|
+
export * as Selectors from './Selectors.js'
|
|
40
75
|
export * as Storage from './Storage.js'
|
|
41
76
|
export * as TokenIds from './TokenIds.js'
|
|
42
77
|
// Export types required for inference.
|