viem 2.57.18 → 2.57.20
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 +42 -0
- package/_cjs/accounts/index.js +2 -1
- package/_cjs/accounts/index.js.map +1 -1
- package/_cjs/accounts/utils/publicKeyToAddress.js +15 -0
- package/_cjs/accounts/utils/publicKeyToAddress.js.map +1 -1
- package/_cjs/actions/ens/getEnsText.js.map +1 -1
- package/_cjs/actions/public/call.js +19 -3
- package/_cjs/actions/public/call.js.map +1 -1
- package/_cjs/actions/public/estimateMaxPriorityFeePerGas.js +1 -1
- package/_cjs/actions/public/estimateMaxPriorityFeePerGas.js.map +1 -1
- package/_cjs/actions/public/getDelegation.js +2 -1
- package/_cjs/actions/public/getDelegation.js.map +1 -1
- package/_cjs/actions/public/getFeeHistory.js.map +1 -1
- package/_cjs/actions/token/internal.js +2 -10
- package/_cjs/actions/token/internal.js.map +1 -1
- package/_cjs/actions/wallet/deployContract.js +2 -1
- package/_cjs/actions/wallet/deployContract.js.map +1 -1
- package/_cjs/actions/wallet/prepareTransactionRequest.js +99 -76
- package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_cjs/actions/wallet/sendCalls.js +2 -1
- package/_cjs/actions/wallet/sendCalls.js.map +1 -1
- package/_cjs/actions/wallet/signAuthorization.js +2 -1
- package/_cjs/actions/wallet/signAuthorization.js.map +1 -1
- package/_cjs/chains/definitions/darwinia.js +1 -1
- package/_cjs/chains/definitions/darwinia.js.map +1 -1
- package/_cjs/chains/definitions/flowMainnet.js +1 -1
- package/_cjs/chains/definitions/flowMainnet.js.map +1 -1
- package/_cjs/chains/definitions/kinetiqElysium.js +30 -0
- package/_cjs/chains/definitions/kinetiqElysium.js.map +1 -0
- package/_cjs/chains/definitions/kinetiqElysiumTestnet.js +31 -0
- package/_cjs/chains/definitions/kinetiqElysiumTestnet.js.map +1 -0
- package/_cjs/chains/index.js +14 -9
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/encoding.js +9 -1
- package/_cjs/errors/encoding.js.map +1 -1
- package/_cjs/errors/typedData.js +2 -0
- package/_cjs/errors/typedData.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js +6 -5
- package/_cjs/index.js.map +1 -1
- package/_cjs/tempo/actions/accounts.js +14 -4
- package/_cjs/tempo/actions/accounts.js.map +1 -1
- package/_cjs/tempo/chainConfig.js +23 -1
- package/_cjs/tempo/chainConfig.js.map +1 -1
- package/_cjs/tempo/internal/relay.js +2 -2
- package/_cjs/tempo/internal/relay.js.map +1 -1
- package/_cjs/tempo/internal/utils.js +2 -10
- package/_cjs/tempo/internal/utils.js.map +1 -1
- package/_cjs/tokens/defineToken.js +1 -1
- package/_cjs/tokens/defineToken.js.map +1 -1
- package/_cjs/tokens/definitions/ousd.js +1 -0
- package/_cjs/tokens/definitions/ousd.js.map +1 -1
- package/_cjs/utils/address/getAddress.js +7 -6
- package/_cjs/utils/address/getAddress.js.map +1 -1
- package/_cjs/utils/address/isAddress.js +8 -12
- package/_cjs/utils/address/isAddress.js.map +1 -1
- package/_cjs/utils/encoding/fromRlp.js +33 -8
- package/_cjs/utils/encoding/fromRlp.js.map +1 -1
- package/_cjs/utils/index.js +5 -4
- package/_cjs/utils/index.js.map +1 -1
- package/_cjs/utils/promise/createBatchScheduler.js +7 -2
- package/_cjs/utils/promise/createBatchScheduler.js.map +1 -1
- package/_cjs/utils/typedData.js +5 -9
- package/_cjs/utils/typedData.js.map +1 -1
- package/_esm/accounts/index.js +1 -1
- package/_esm/accounts/index.js.map +1 -1
- package/_esm/accounts/utils/publicKeyToAddress.js +20 -1
- package/_esm/accounts/utils/publicKeyToAddress.js.map +1 -1
- package/_esm/actions/ens/getEnsText.js.map +1 -1
- package/_esm/actions/public/call.js +19 -3
- package/_esm/actions/public/call.js.map +1 -1
- package/_esm/actions/public/estimateMaxPriorityFeePerGas.js +1 -1
- package/_esm/actions/public/estimateMaxPriorityFeePerGas.js.map +1 -1
- package/_esm/actions/public/getDelegation.js +2 -1
- package/_esm/actions/public/getDelegation.js.map +1 -1
- package/_esm/actions/public/getFeeHistory.js.map +1 -1
- package/_esm/actions/token/internal.js +2 -10
- package/_esm/actions/token/internal.js.map +1 -1
- package/_esm/actions/wallet/deployContract.js +2 -1
- package/_esm/actions/wallet/deployContract.js.map +1 -1
- package/_esm/actions/wallet/prepareTransactionRequest.js +111 -79
- package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_esm/actions/wallet/sendCalls.js +2 -1
- package/_esm/actions/wallet/sendCalls.js.map +1 -1
- package/_esm/actions/wallet/signAuthorization.js +2 -1
- package/_esm/actions/wallet/signAuthorization.js.map +1 -1
- package/_esm/chains/definitions/darwinia.js +1 -1
- package/_esm/chains/definitions/darwinia.js.map +1 -1
- package/_esm/chains/definitions/flowMainnet.js +1 -1
- package/_esm/chains/definitions/flowMainnet.js.map +1 -1
- package/_esm/chains/definitions/kinetiqElysium.js +27 -0
- package/_esm/chains/definitions/kinetiqElysium.js.map +1 -0
- package/_esm/chains/definitions/kinetiqElysiumTestnet.js +28 -0
- package/_esm/chains/definitions/kinetiqElysiumTestnet.js.map +1 -0
- package/_esm/chains/index.js +2 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/encoding.js +8 -0
- package/_esm/errors/encoding.js.map +1 -1
- package/_esm/errors/typedData.js +2 -0
- package/_esm/errors/typedData.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/index.js +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/tempo/actions/accounts.js +19 -5
- package/_esm/tempo/actions/accounts.js.map +1 -1
- package/_esm/tempo/chainConfig.js +25 -1
- package/_esm/tempo/chainConfig.js.map +1 -1
- package/_esm/tempo/internal/relay/feePayer.js +1 -1
- package/_esm/tempo/internal/relay/feePayer.js.map +1 -1
- package/_esm/tempo/internal/relay.js +8 -3
- package/_esm/tempo/internal/relay.js.map +1 -1
- package/_esm/tempo/internal/utils.js +2 -10
- package/_esm/tempo/internal/utils.js.map +1 -1
- package/_esm/tokens/defineToken.js +2 -1
- package/_esm/tokens/defineToken.js.map +1 -1
- package/_esm/tokens/definitions/ousd.js +2 -1
- package/_esm/tokens/definitions/ousd.js.map +1 -1
- package/_esm/utils/address/getAddress.js +32 -6
- package/_esm/utils/address/getAddress.js.map +1 -1
- package/_esm/utils/address/isAddress.js +32 -12
- package/_esm/utils/address/isAddress.js.map +1 -1
- package/_esm/utils/encoding/fromRlp.js +37 -9
- package/_esm/utils/encoding/fromRlp.js.map +1 -1
- package/_esm/utils/index.js +1 -1
- package/_esm/utils/index.js.map +1 -1
- package/_esm/utils/promise/createBatchScheduler.js +7 -2
- package/_esm/utils/promise/createBatchScheduler.js.map +1 -1
- package/_esm/utils/typedData.js +7 -9
- package/_esm/utils/typedData.js.map +1 -1
- package/_types/accounts/index.d.ts +1 -1
- package/_types/accounts/index.d.ts.map +1 -1
- package/_types/accounts/utils/publicKeyToAddress.d.ts +16 -2
- package/_types/accounts/utils/publicKeyToAddress.d.ts.map +1 -1
- package/_types/actions/ens/getEnsText.d.ts +2 -1
- package/_types/actions/ens/getEnsText.d.ts.map +1 -1
- package/_types/actions/public/call.d.ts +1 -1
- package/_types/actions/public/call.d.ts.map +1 -1
- package/_types/actions/public/estimateMaxPriorityFeePerGas.d.ts +1 -1
- package/_types/actions/public/estimateMaxPriorityFeePerGas.d.ts.map +1 -1
- package/_types/actions/public/getDelegation.d.ts.map +1 -1
- package/_types/actions/public/getFeeHistory.d.ts +2 -1
- package/_types/actions/public/getFeeHistory.d.ts.map +1 -1
- package/_types/actions/token/internal.d.ts.map +1 -1
- package/_types/actions/wallet/deployContract.d.ts.map +1 -1
- package/_types/actions/wallet/prepareTransactionRequest.d.ts +2 -1
- package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
- package/_types/actions/wallet/sendCalls.d.ts.map +1 -1
- package/_types/actions/wallet/signAuthorization.d.ts.map +1 -1
- package/_types/chains/definitions/darwinia.d.ts +1 -1
- package/_types/chains/definitions/darwinia.d.ts.map +1 -1
- package/_types/chains/definitions/flowMainnet.d.ts +1 -1
- package/_types/chains/definitions/flowMainnet.d.ts.map +1 -1
- package/_types/chains/definitions/kinetiqElysium.d.ts +52 -0
- package/_types/chains/definitions/kinetiqElysium.d.ts.map +1 -0
- package/_types/chains/definitions/kinetiqElysiumTestnet.d.ts +52 -0
- package/_types/chains/definitions/kinetiqElysiumTestnet.d.ts.map +1 -0
- package/_types/chains/index.d.ts +2 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/encoding.d.ts +9 -0
- package/_types/errors/encoding.d.ts.map +1 -1
- package/_types/errors/typedData.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/index.d.ts +1 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/tempo/actions/accounts.d.ts +4 -1
- package/_types/tempo/actions/accounts.d.ts.map +1 -1
- package/_types/tempo/chainConfig.d.ts.map +1 -1
- package/_types/tempo/internal/utils.d.ts.map +1 -1
- package/_types/tokens/defineToken.d.ts +5 -1
- package/_types/tokens/defineToken.d.ts.map +1 -1
- package/_types/tokens/definitions/ousd.d.ts +2 -1
- package/_types/tokens/definitions/ousd.d.ts.map +1 -1
- package/_types/tokens/sets.d.ts +3 -0
- package/_types/tokens/sets.d.ts.map +1 -1
- package/_types/utils/address/getAddress.d.ts +23 -0
- package/_types/utils/address/getAddress.d.ts.map +1 -1
- package/_types/utils/address/isAddress.d.ts +22 -0
- package/_types/utils/address/isAddress.d.ts.map +1 -1
- package/_types/utils/encoding/fromRlp.d.ts +3 -3
- package/_types/utils/encoding/fromRlp.d.ts.map +1 -1
- package/_types/utils/index.d.ts +1 -1
- package/_types/utils/index.d.ts.map +1 -1
- package/_types/utils/promise/createBatchScheduler.d.ts.map +1 -1
- package/_types/utils/typedData.d.ts.map +1 -1
- package/_types/zksync/errors/bridge.d.ts +1 -1
- package/_types/zksync/errors/bridge.d.ts.map +1 -1
- package/accounts/index.ts +2 -0
- package/accounts/utils/publicKeyToAddress.ts +27 -1
- package/actions/ens/getEnsText.ts +2 -0
- package/actions/public/call.ts +20 -3
- package/actions/public/estimateMaxPriorityFeePerGas.ts +2 -2
- package/actions/public/getDelegation.ts +6 -1
- package/actions/public/getFeeHistory.ts +2 -0
- package/actions/token/internal.ts +2 -10
- package/actions/wallet/deployContract.ts +6 -1
- package/actions/wallet/prepareTransactionRequest.ts +138 -107
- package/actions/wallet/sendCalls.ts +6 -1
- package/actions/wallet/signAuthorization.ts +6 -1
- package/chains/definitions/darwinia.ts +1 -1
- package/chains/definitions/flowMainnet.ts +1 -1
- package/chains/definitions/kinetiqElysium.ts +27 -0
- package/chains/definitions/kinetiqElysiumTestnet.ts +28 -0
- package/chains/index.ts +2 -0
- package/errors/encoding.ts +12 -0
- package/errors/typedData.ts +2 -0
- package/errors/version.ts +1 -1
- package/index.ts +2 -0
- package/package.json +2 -2
- package/tempo/actions/accounts.ts +24 -6
- package/tempo/chainConfig.ts +33 -5
- package/tempo/internal/relay/feePayer.ts +1 -1
- package/tempo/internal/relay.ts +8 -3
- package/tempo/internal/utils.ts +2 -10
- package/tokens/defineToken.ts +6 -2
- package/tokens/definitions/ousd.ts +2 -1
- package/utils/address/getAddress.ts +31 -6
- package/utils/address/isAddress.ts +31 -10
- package/utils/encoding/fromRlp.ts +37 -5
- package/utils/index.ts +2 -0
- package/utils/promise/createBatchScheduler.ts +10 -2
- package/utils/typedData.ts +7 -9
- package/zksync/errors/bridge.ts +1 -1
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
type EstimateGasParameters,
|
|
14
14
|
estimateGas,
|
|
15
15
|
} from '../../actions/public/estimateGas.js'
|
|
16
|
+
import { internal_estimateMaxPriorityFeePerGas } from '../../actions/public/estimateMaxPriorityFeePerGas.js'
|
|
16
17
|
import {
|
|
17
18
|
type GetBlockErrorType,
|
|
18
19
|
getBlock as getBlock_,
|
|
@@ -34,6 +35,7 @@ import {
|
|
|
34
35
|
MaxFeePerGasTooLowError,
|
|
35
36
|
} from '../../errors/fee.js'
|
|
36
37
|
import { FeePayerNonceMismatchError } from '../../errors/transaction.js'
|
|
38
|
+
import type { ErrorType } from '../../errors/utils.js'
|
|
37
39
|
import type { DeriveAccount, GetAccountParameter } from '../../types/account.js'
|
|
38
40
|
import type { Block } from '../../types/block.js'
|
|
39
41
|
import type { ExtractCapabilities } from '../../types/capabilities.js'
|
|
@@ -242,6 +244,7 @@ export type PrepareTransactionRequestErrorType =
|
|
|
242
244
|
| GetTransactionCountErrorType
|
|
243
245
|
| EstimateGasErrorType
|
|
244
246
|
| EstimateFeesPerGasErrorType
|
|
247
|
+
| ErrorType
|
|
245
248
|
|
|
246
249
|
/**
|
|
247
250
|
* Prepares a transaction request for signing.
|
|
@@ -608,133 +611,161 @@ export async function prepareTransactionRequest<
|
|
|
608
611
|
)) ?? request
|
|
609
612
|
}
|
|
610
613
|
|
|
611
|
-
let block: Block | undefined
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
block = await getAction(
|
|
615
|
-
client,
|
|
616
|
-
getBlock_,
|
|
617
|
-
'getBlock',
|
|
618
|
-
)({ blockTag: 'latest' })
|
|
614
|
+
let block: Promise<Block> | undefined
|
|
615
|
+
function getBlock(): Promise<Block> {
|
|
616
|
+
block ??= getAction(client, getBlock_, 'getBlock')({ blockTag: 'latest' })
|
|
619
617
|
return block
|
|
620
618
|
}
|
|
621
619
|
|
|
622
|
-
|
|
620
|
+
// Chain fee hooks receive the block and the request, so the requests they
|
|
621
|
+
// depend on are made in sequence.
|
|
622
|
+
const hasFeeHooks = Object.values(chain?.fees ?? {}).some(
|
|
623
|
+
(fee) => typeof fee === 'function',
|
|
624
|
+
)
|
|
625
|
+
|
|
626
|
+
// The nonce does not depend on the type or the fees, so it is fetched
|
|
627
|
+
// concurrently with them.
|
|
628
|
+
const noncePromise =
|
|
623
629
|
parameters.includes('nonce') &&
|
|
624
630
|
typeof nonce === 'undefined' &&
|
|
625
631
|
account &&
|
|
626
632
|
!nonceManager
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
proofs,
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
633
|
+
? getAction(
|
|
634
|
+
client,
|
|
635
|
+
getTransactionCount,
|
|
636
|
+
'getTransactionCount',
|
|
637
|
+
)({
|
|
638
|
+
address: account.address,
|
|
639
|
+
blockTag: 'pending',
|
|
640
|
+
})
|
|
641
|
+
: undefined
|
|
642
|
+
// A rejection is thrown when the nonce is awaited.
|
|
643
|
+
noncePromise?.catch(() => {})
|
|
644
|
+
if (noncePromise && hasFeeHooks) request.nonce = await noncePromise
|
|
645
|
+
|
|
646
|
+
try {
|
|
647
|
+
if (
|
|
648
|
+
(parameters.includes('blobVersionedHashes') ||
|
|
649
|
+
parameters.includes('sidecars')) &&
|
|
650
|
+
blobs &&
|
|
651
|
+
kzg
|
|
652
|
+
) {
|
|
653
|
+
const commitments = blobsToCommitments({ blobs, kzg })
|
|
654
|
+
|
|
655
|
+
if (parameters.includes('blobVersionedHashes')) {
|
|
656
|
+
const versionedHashes = commitmentsToVersionedHashes({
|
|
657
|
+
commitments,
|
|
658
|
+
to: 'hex',
|
|
659
|
+
})
|
|
660
|
+
request.blobVersionedHashes = versionedHashes
|
|
661
|
+
}
|
|
662
|
+
if (parameters.includes('sidecars')) {
|
|
663
|
+
const proofs = blobsToProofs({ blobs, commitments, kzg })
|
|
664
|
+
const sidecars = toBlobSidecars({
|
|
665
|
+
blobs,
|
|
666
|
+
commitments,
|
|
667
|
+
proofs,
|
|
668
|
+
to: 'hex',
|
|
669
|
+
})
|
|
670
|
+
request.sidecars = sidecars
|
|
671
|
+
}
|
|
661
672
|
}
|
|
662
|
-
}
|
|
663
673
|
|
|
664
|
-
|
|
674
|
+
if (parameters.includes('chainId')) request.chainId = await getChainId()
|
|
665
675
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
676
|
+
if (
|
|
677
|
+
(parameters.includes('fees') || parameters.includes('type')) &&
|
|
678
|
+
typeof type === 'undefined'
|
|
679
|
+
) {
|
|
680
|
+
try {
|
|
681
|
+
request.type = getTransactionType(
|
|
682
|
+
request as TransactionSerializable,
|
|
683
|
+
) as any
|
|
684
|
+
} catch {
|
|
685
|
+
let isEip1559Network = eip1559NetworkCache.get(client.uid)
|
|
686
|
+
if (typeof isEip1559Network === 'undefined') {
|
|
687
|
+
const block = await getBlock()
|
|
688
|
+
isEip1559Network = typeof block?.baseFeePerGas === 'bigint'
|
|
689
|
+
eip1559NetworkCache.set(client.uid, isEip1559Network)
|
|
690
|
+
}
|
|
691
|
+
request.type = isEip1559Network ? 'eip1559' : 'legacy'
|
|
680
692
|
}
|
|
681
|
-
request.type = isEip1559Network ? 'eip1559' : 'legacy'
|
|
682
693
|
}
|
|
683
|
-
}
|
|
684
694
|
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
if (request.type !== 'legacy' && request.type !== 'eip2930') {
|
|
689
|
-
// EIP-1559 fees
|
|
690
|
-
if (
|
|
691
|
-
typeof request.maxFeePerGas === 'undefined' ||
|
|
692
|
-
typeof request.maxPriorityFeePerGas === 'undefined'
|
|
693
|
-
) {
|
|
694
|
-
const block = await getBlock()
|
|
695
|
-
const { maxFeePerGas, maxPriorityFeePerGas } =
|
|
696
|
-
await internal_estimateFeesPerGas(client, {
|
|
697
|
-
block: block as Block,
|
|
698
|
-
chain,
|
|
699
|
-
request: request as PrepareTransactionRequestParameters,
|
|
700
|
-
})
|
|
695
|
+
if (parameters.includes('fees')) {
|
|
696
|
+
// TODO(4844): derive blob base fees once https://github.com/ethereum/execution-apis/pull/486 is merged.
|
|
701
697
|
|
|
698
|
+
if (request.type !== 'legacy' && request.type !== 'eip2930') {
|
|
699
|
+
// EIP-1559 fees
|
|
702
700
|
if (
|
|
703
|
-
typeof request.
|
|
704
|
-
typeof request.
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
701
|
+
typeof request.maxFeePerGas === 'undefined' ||
|
|
702
|
+
typeof request.maxPriorityFeePerGas === 'undefined'
|
|
703
|
+
) {
|
|
704
|
+
// Without chain fee hooks, the priority fee does not depend on the
|
|
705
|
+
// block, so it is estimated concurrently with the block request.
|
|
706
|
+
const [block, priorityFee] = await Promise.all([
|
|
707
|
+
getBlock(),
|
|
708
|
+
hasFeeHooks || typeof request.maxPriorityFeePerGas === 'bigint'
|
|
709
|
+
? undefined
|
|
710
|
+
: internal_estimateMaxPriorityFeePerGas(client, {
|
|
711
|
+
block: getBlock(),
|
|
712
|
+
chain,
|
|
713
|
+
request: request as PrepareTransactionRequestParameters,
|
|
714
|
+
}),
|
|
715
|
+
])
|
|
716
|
+
const { maxFeePerGas, maxPriorityFeePerGas } =
|
|
717
|
+
await internal_estimateFeesPerGas(client, {
|
|
718
|
+
block,
|
|
719
|
+
chain,
|
|
720
|
+
request: (typeof priorityFee === 'bigint'
|
|
721
|
+
? { ...request, maxPriorityFeePerGas: priorityFee }
|
|
722
|
+
: request) as PrepareTransactionRequestParameters,
|
|
723
|
+
})
|
|
724
|
+
|
|
725
|
+
if (
|
|
726
|
+
typeof request.maxPriorityFeePerGas === 'undefined' &&
|
|
727
|
+
typeof request.maxFeePerGas === 'bigint' &&
|
|
728
|
+
request.maxFeePerGas < maxPriorityFeePerGas
|
|
729
|
+
)
|
|
730
|
+
throw new MaxFeePerGasTooLowError({
|
|
731
|
+
maxPriorityFeePerGas,
|
|
732
|
+
})
|
|
733
|
+
|
|
734
|
+
request.maxPriorityFeePerGas = maxPriorityFeePerGas
|
|
735
|
+
request.maxFeePerGas = maxFeePerGas
|
|
736
|
+
}
|
|
737
|
+
} else {
|
|
738
|
+
// Legacy fees
|
|
739
|
+
if (
|
|
740
|
+
typeof request.maxFeePerGas !== 'undefined' ||
|
|
741
|
+
typeof request.maxPriorityFeePerGas !== 'undefined'
|
|
732
742
|
)
|
|
733
|
-
|
|
743
|
+
throw new Eip1559FeesNotSupportedError()
|
|
744
|
+
|
|
745
|
+
if (typeof request.gasPrice === 'undefined') {
|
|
746
|
+
const block = await getBlock()
|
|
747
|
+
const { gasPrice: gasPrice_ } = await internal_estimateFeesPerGas(
|
|
748
|
+
client,
|
|
749
|
+
{
|
|
750
|
+
block: block as Block,
|
|
751
|
+
chain,
|
|
752
|
+
request: request as PrepareTransactionRequestParameters,
|
|
753
|
+
type: 'legacy',
|
|
754
|
+
},
|
|
755
|
+
)
|
|
756
|
+
request.gasPrice = gasPrice_
|
|
757
|
+
}
|
|
734
758
|
}
|
|
735
759
|
}
|
|
760
|
+
} catch (error) {
|
|
761
|
+
// A failed nonce request takes precedence over errors from the other
|
|
762
|
+
// parameters.
|
|
763
|
+
await noncePromise
|
|
764
|
+
throw error
|
|
736
765
|
}
|
|
737
766
|
|
|
767
|
+
if (noncePromise) request.nonce = await noncePromise
|
|
768
|
+
|
|
738
769
|
if (parameters.includes('gas') && typeof gas === 'undefined')
|
|
739
770
|
request.gas = await getAction(
|
|
740
771
|
client,
|
|
@@ -21,6 +21,7 @@ import { concat } from '../../utils/data/concat.js'
|
|
|
21
21
|
import { hexToBigInt } from '../../utils/encoding/fromHex.js'
|
|
22
22
|
import { numberToHex } from '../../utils/encoding/toHex.js'
|
|
23
23
|
import { getTransactionError } from '../../utils/errors/getTransactionError.js'
|
|
24
|
+
import { getAction } from '../../utils/getAction.js'
|
|
24
25
|
import { sendTransaction } from './sendTransaction.js'
|
|
25
26
|
|
|
26
27
|
export const fallbackMagicIdentifier =
|
|
@@ -225,7 +226,11 @@ export async function sendCalls<
|
|
|
225
226
|
const results: PromiseSettledResult<Hex>[] = []
|
|
226
227
|
for (const call of calls) {
|
|
227
228
|
try {
|
|
228
|
-
const value = await
|
|
229
|
+
const value = await getAction(
|
|
230
|
+
client,
|
|
231
|
+
sendTransaction,
|
|
232
|
+
'sendTransaction',
|
|
233
|
+
)({
|
|
229
234
|
account,
|
|
230
235
|
chain,
|
|
231
236
|
data: call.data,
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
} from '../../errors/account.js'
|
|
18
18
|
import type { ErrorType } from '../../errors/utils.js'
|
|
19
19
|
import type { Chain } from '../../types/chain.js'
|
|
20
|
+
import { getAction } from '../../utils/getAction.js'
|
|
20
21
|
import {
|
|
21
22
|
type PrepareAuthorizationErrorType,
|
|
22
23
|
type PrepareAuthorizationParameters,
|
|
@@ -103,6 +104,10 @@ export async function signAuthorization<
|
|
|
103
104
|
type: account.type,
|
|
104
105
|
})
|
|
105
106
|
|
|
106
|
-
const authorization = await
|
|
107
|
+
const authorization = await getAction(
|
|
108
|
+
client,
|
|
109
|
+
prepareAuthorization,
|
|
110
|
+
'prepareAuthorization',
|
|
111
|
+
)(parameters)
|
|
107
112
|
return account.signAuthorization(authorization)
|
|
108
113
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
|
2
|
+
|
|
3
|
+
export const kinetiqElysium = /*#__PURE__*/ defineChain({
|
|
4
|
+
id: 99_901,
|
|
5
|
+
name: 'Elysium',
|
|
6
|
+
blockTime: 100,
|
|
7
|
+
nativeCurrency: { name: 'HYPE', symbol: 'HYPE', decimals: 18 },
|
|
8
|
+
rpcUrls: {
|
|
9
|
+
default: {
|
|
10
|
+
http: ['https://rpc.elysium.kinetiq.xyz'],
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
blockExplorers: {
|
|
14
|
+
default: {
|
|
15
|
+
name: 'Elysium Explorer',
|
|
16
|
+
url: 'https://elysium.kinetiq.xyz',
|
|
17
|
+
apiUrl: 'https://elysium.kinetiq.xyz/api',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
contracts: {
|
|
21
|
+
multicall3: {
|
|
22
|
+
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
23
|
+
blockCreated: 1343,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
sourceId: 999,
|
|
27
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
|
2
|
+
|
|
3
|
+
export const kinetiqElysiumTestnet = /*#__PURE__*/ defineChain({
|
|
4
|
+
id: 99_801,
|
|
5
|
+
name: 'Kinetiq Elysium Testnet',
|
|
6
|
+
blockTime: 100,
|
|
7
|
+
nativeCurrency: { name: 'HYPE', symbol: 'HYPE', decimals: 18 },
|
|
8
|
+
rpcUrls: {
|
|
9
|
+
default: {
|
|
10
|
+
http: ['https://testnet-rpc.elysium.kinetiq.xyz'],
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
blockExplorers: {
|
|
14
|
+
default: {
|
|
15
|
+
name: 'Elysium Testnet Explorer',
|
|
16
|
+
url: 'https://testnet.elysium.kinetiq.xyz',
|
|
17
|
+
apiUrl: 'https://testnet.elysium.kinetiq.xyz/api',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
contracts: {
|
|
21
|
+
multicall3: {
|
|
22
|
+
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
23
|
+
blockCreated: 91163,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
sourceId: 998,
|
|
27
|
+
testnet: true,
|
|
28
|
+
})
|
package/chains/index.ts
CHANGED
|
@@ -351,6 +351,8 @@ export { kavaTestnet } from './definitions/kavaTestnet.js'
|
|
|
351
351
|
export { kcc } from './definitions/kcc.js'
|
|
352
352
|
export { kii } from './definitions/kii.js'
|
|
353
353
|
export { kiiTestnetOro } from './definitions/kiiTestnet.js'
|
|
354
|
+
export { kinetiqElysium } from './definitions/kinetiqElysium.js'
|
|
355
|
+
export { kinetiqElysiumTestnet } from './definitions/kinetiqElysiumTestnet.js'
|
|
354
356
|
export { kinto } from './definitions/kinto.js'
|
|
355
357
|
/** @deprecated Use `kaia` instead. */
|
|
356
358
|
export { klaytn } from './definitions/klaytn.js'
|
package/errors/encoding.ts
CHANGED
|
@@ -89,6 +89,18 @@ export class RlpListBoundaryExceededError extends BaseError {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
export type RlpNonCanonicalErrorType = RlpNonCanonicalError & {
|
|
93
|
+
name: 'RlpNonCanonicalError'
|
|
94
|
+
}
|
|
95
|
+
/** Thrown when an RLP payload uses a non-minimal length prefix or wraps a single byte below `0x80` in a length prefix. */
|
|
96
|
+
export class RlpNonCanonicalError extends BaseError {
|
|
97
|
+
constructor({ reason }: { reason: string }) {
|
|
98
|
+
super(`RLP payload is not canonically encoded: ${reason}.`, {
|
|
99
|
+
name: 'RlpNonCanonicalError',
|
|
100
|
+
})
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
92
104
|
export type RlpTrailingBytesErrorType = RlpTrailingBytesError & {
|
|
93
105
|
name: 'RlpTrailingBytesError'
|
|
94
106
|
}
|
package/errors/typedData.ts
CHANGED
|
@@ -10,6 +10,7 @@ export class InvalidDomainError extends BaseError {
|
|
|
10
10
|
constructor({ domain }: { domain: unknown }) {
|
|
11
11
|
super(`Invalid domain "${stringify(domain)}".`, {
|
|
12
12
|
metaMessages: ['Must be a valid EIP-712 domain.'],
|
|
13
|
+
name: 'InvalidDomainError',
|
|
13
14
|
})
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -27,6 +28,7 @@ export class InvalidPrimaryTypeError extends BaseError {
|
|
|
27
28
|
{
|
|
28
29
|
docsPath: '/api/glossary/Errors#typeddatainvalidprimarytypeerror',
|
|
29
30
|
metaMessages: ['Check that the primary type is a key in `types`.'],
|
|
31
|
+
name: 'InvalidPrimaryTypeError',
|
|
30
32
|
},
|
|
31
33
|
)
|
|
32
34
|
}
|
package/errors/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.57.
|
|
1
|
+
export const version = '2.57.20'
|
package/index.ts
CHANGED
|
@@ -911,6 +911,8 @@ export {
|
|
|
911
911
|
type RlpDepthLimitExceededErrorType,
|
|
912
912
|
RlpListBoundaryExceededError,
|
|
913
913
|
type RlpListBoundaryExceededErrorType,
|
|
914
|
+
RlpNonCanonicalError,
|
|
915
|
+
type RlpNonCanonicalErrorType,
|
|
914
916
|
RlpTrailingBytesError,
|
|
915
917
|
type RlpTrailingBytesErrorType,
|
|
916
918
|
SizeOverflowError,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "viem",
|
|
3
3
|
"description": "TypeScript Interface for Ethereum",
|
|
4
|
-
"version": "2.57.
|
|
4
|
+
"version": "2.57.20",
|
|
5
5
|
"main": "./_cjs/index.js",
|
|
6
6
|
"module": "./_esm/index.js",
|
|
7
7
|
"types": "./_types/index.d.ts",
|
|
@@ -233,7 +233,7 @@
|
|
|
233
233
|
"@scure/bip39": "1.6.0",
|
|
234
234
|
"abitype": "1.2.3",
|
|
235
235
|
"isows": "1.0.7",
|
|
236
|
-
"ox": "0.14.
|
|
236
|
+
"ox": "0.14.67",
|
|
237
237
|
"ws": "8.21.0"
|
|
238
238
|
},
|
|
239
239
|
"license": "MIT",
|
|
@@ -3,13 +3,17 @@ import type * as Hex from 'ox/Hex'
|
|
|
3
3
|
import type * as RpcSchema from 'ox/RpcSchema'
|
|
4
4
|
import { AccountConfig, AccountOperation, type RpcSchemaTempo } from 'ox/tempo'
|
|
5
5
|
import type { Account } from '../../accounts/types.js'
|
|
6
|
-
import type {
|
|
6
|
+
import type {
|
|
7
|
+
ReadContractErrorType,
|
|
8
|
+
ReadContractReturnType,
|
|
9
|
+
} from '../../actions/public/readContract.js'
|
|
7
10
|
import { readContract } from '../../actions/public/readContract.js'
|
|
8
11
|
import type { WriteContractReturnType } from '../../actions/wallet/writeContract.js'
|
|
9
12
|
import { writeContract } from '../../actions/wallet/writeContract.js'
|
|
10
13
|
import { writeContractSync } from '../../actions/wallet/writeContractSync.js'
|
|
11
14
|
import type { Client } from '../../clients/createClient.js'
|
|
12
15
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
|
16
|
+
import { zeroHash } from '../../constants/bytes.js'
|
|
13
17
|
import type { BaseErrorType } from '../../errors/base.js'
|
|
14
18
|
import type { Chain } from '../../types/chain.js'
|
|
15
19
|
import type { Log } from '../../types/log.js'
|
|
@@ -156,6 +160,9 @@ export declare namespace getConfig {
|
|
|
156
160
|
/**
|
|
157
161
|
* Gets the current configuration commitment for a configurable account.
|
|
158
162
|
*
|
|
163
|
+
* A chain without the configurable account precompile holds no commitments,
|
|
164
|
+
* so the commitment of every account on it is zero.
|
|
165
|
+
*
|
|
159
166
|
* @example
|
|
160
167
|
* ```ts
|
|
161
168
|
* import { createClient, http } from 'viem'
|
|
@@ -175,7 +182,7 @@ export declare namespace getConfig {
|
|
|
175
182
|
* @param client - Client.
|
|
176
183
|
* @param parameters - Parameters.
|
|
177
184
|
* @returns The current configuration commitment, or zero when no config has
|
|
178
|
-
* been committed.
|
|
185
|
+
* been committed or the chain has no configurable account precompile.
|
|
179
186
|
*/
|
|
180
187
|
export async function getConfigCommitment<
|
|
181
188
|
chain extends Chain | undefined,
|
|
@@ -185,10 +192,21 @@ export async function getConfigCommitment<
|
|
|
185
192
|
parameters: getConfigCommitment.Parameters,
|
|
186
193
|
): Promise<getConfigCommitment.ReturnValue> {
|
|
187
194
|
const { account, ...rest } = parameters
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
195
|
+
try {
|
|
196
|
+
return await withExecutionError(readContract)(client, {
|
|
197
|
+
...rest,
|
|
198
|
+
...getConfigCommitment.call({ account }),
|
|
199
|
+
})
|
|
200
|
+
} catch (e) {
|
|
201
|
+
const error = e as ReadContractErrorType
|
|
202
|
+
// A chain without the precompile answers no data, and holds no commitments.
|
|
203
|
+
if (
|
|
204
|
+
error.name === 'ContractFunctionExecutionError' &&
|
|
205
|
+
error.cause.name === 'ContractFunctionZeroDataError'
|
|
206
|
+
)
|
|
207
|
+
return zeroHash
|
|
208
|
+
throw error
|
|
209
|
+
}
|
|
192
210
|
}
|
|
193
211
|
|
|
194
212
|
export namespace getConfigCommitment {
|
package/tempo/chainConfig.ts
CHANGED
|
@@ -25,6 +25,7 @@ import { defineTransactionReceipt } from '../utils/formatters/transactionReceipt
|
|
|
25
25
|
import { defineTransactionRequest } from '../utils/formatters/transactionRequest.js'
|
|
26
26
|
import { getAction } from '../utils/getAction.js'
|
|
27
27
|
import { keccak256 } from '../utils/hash/keccak256.js'
|
|
28
|
+
import { recoverAddress } from '../utils/signature/recoverAddress.js'
|
|
28
29
|
import type { SerializeTransactionFn } from '../utils/transaction/serializeTransaction.js'
|
|
29
30
|
import type { Account, ConfigurableAccount } from './Account.js'
|
|
30
31
|
import {
|
|
@@ -578,11 +579,38 @@ export const chainConfig = {
|
|
|
578
579
|
}
|
|
579
580
|
}
|
|
580
581
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
582
|
+
const verify = () =>
|
|
583
|
+
getAction(
|
|
584
|
+
client,
|
|
585
|
+
verifyHash,
|
|
586
|
+
'verifyHash',
|
|
587
|
+
)({ ...parameters, chain: null })
|
|
588
|
+
|
|
589
|
+
const root = await (async () => {
|
|
590
|
+
try {
|
|
591
|
+
return isAddressEqual(
|
|
592
|
+
address,
|
|
593
|
+
await recoverAddress({ hash, signature }),
|
|
594
|
+
)
|
|
595
|
+
} catch {
|
|
596
|
+
return false
|
|
597
|
+
}
|
|
598
|
+
})()
|
|
599
|
+
if (!root) return await verify()
|
|
600
|
+
|
|
601
|
+
// A config commitment retires the root key (TIP-1113), whose signature still recovers
|
|
602
|
+
// to the account. Only the chain knows the commitment, so this reads it in every mode.
|
|
603
|
+
const [commitment, valid] = await Promise.all([
|
|
604
|
+
getConfigCommitment(client, {
|
|
605
|
+
account: address,
|
|
606
|
+
blockHash: parameters.blockHash,
|
|
607
|
+
blockNumber: parameters.blockNumber,
|
|
608
|
+
blockTag: parameters.blockTag,
|
|
609
|
+
requireCanonical: parameters.requireCanonical,
|
|
610
|
+
} as never),
|
|
611
|
+
verify(),
|
|
612
|
+
])
|
|
613
|
+
return valid && BigInt(commitment) === 0n
|
|
586
614
|
},
|
|
587
615
|
} as const satisfies viem_ChainConfig & { blockTime: number }
|
|
588
616
|
|
|
@@ -652,7 +652,7 @@ function isCanonical(serialized: `0x76${string}` | `0x78${string}`) {
|
|
|
652
652
|
: TxEnvelopeTempo.serialize(envelope)
|
|
653
653
|
return serialized_parsed === serialized.toLowerCase()
|
|
654
654
|
} catch {
|
|
655
|
-
//
|
|
655
|
+
// An envelope that cannot be parsed or serialized has no canonical encoding.
|
|
656
656
|
return false
|
|
657
657
|
}
|
|
658
658
|
}
|
package/tempo/internal/relay.ts
CHANGED
|
@@ -174,10 +174,15 @@ export async function fetch(
|
|
|
174
174
|
: Response.json(response)
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
/**
|
|
177
|
+
/**
|
|
178
|
+
* Reads a request body, returning `undefined` once its declared or streamed size exceeds {@link maxBodySize}.
|
|
179
|
+
*
|
|
180
|
+
* The cancel of an oversized body is not awaited: a cloned request's body settles its cancel only once
|
|
181
|
+
* the clone's body ends too.
|
|
182
|
+
*/
|
|
178
183
|
async function readBody(request: Request) {
|
|
179
184
|
if (Number(request.headers.get('content-length')) > maxBodySize) {
|
|
180
|
-
|
|
185
|
+
void request.body?.cancel().catch(() => {})
|
|
181
186
|
return undefined
|
|
182
187
|
}
|
|
183
188
|
const chunks: Uint8Array<ArrayBuffer>[] = []
|
|
@@ -189,7 +194,7 @@ async function readBody(request: Request) {
|
|
|
189
194
|
if (done) return chunks
|
|
190
195
|
size += value.byteLength
|
|
191
196
|
if (size > maxBodySize) {
|
|
192
|
-
|
|
197
|
+
void reader.cancel().catch(() => {})
|
|
193
198
|
return undefined
|
|
194
199
|
}
|
|
195
200
|
chunks.push(value)
|
package/tempo/internal/utils.ts
CHANGED
|
@@ -126,16 +126,8 @@ function resolveTokenForChain(
|
|
|
126
126
|
token: Token,
|
|
127
127
|
chainId: number,
|
|
128
128
|
): ResolvedToken | undefined {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return {
|
|
132
|
-
address,
|
|
133
|
-
currency: token.currency,
|
|
134
|
-
decimals: token.decimals,
|
|
135
|
-
name: token.name,
|
|
136
|
-
popular: token.popular,
|
|
137
|
-
symbol: token.symbol,
|
|
138
|
-
}
|
|
129
|
+
if (!(token.addresses as Record<number, Address>)[chainId]) return undefined
|
|
130
|
+
return token(chainId as never)
|
|
139
131
|
}
|
|
140
132
|
|
|
141
133
|
/**
|