Skip to content

Commit dff9a57

Browse files
authored
Update viem to ^2.27.0 (and unpin) (#268)
1 parent 2793081 commit dff9a57

File tree

3 files changed

+123
-72
lines changed

3 files changed

+123
-72
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,6 @@
8989
"lodash": "^4.17.21",
9090
"markdown-table": "2.0.0",
9191
"sha1": "^1.1.1",
92-
"viem": "2.7.14"
92+
"viem": "^2.27.0"
9393
}
9494
}

src/utils/gas.ts

+26-29
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { serializeTransaction, Hex } from 'viem';
1+
import { serializeTransaction, getTransactionType, Hex, TransactionSerializableGeneric, TransactionSerializableLegacy } from 'viem';
22
import { compress } from 'brotli-wasm';
33
import {
44
EVM_BASE_TX_COST,
@@ -162,18 +162,11 @@ export function getArbitrumL1Cost(bytes: number, gasPrice: number, baseFeePerByt
162162
* @param tx
163163
* @returns
164164
*/
165-
export function getSerializedTx(tx: JsonRpcTx, emulateSignatureComponents = false): string {
165+
export function getSerializedTx(_tx: JsonRpcTx, emulateSignatureComponents = false): string {
166166
let signature;
167167

168-
const type = normalizeTxType(tx.type);
169-
170-
const maxFeePerGas = (tx.maxFeePerGas)
171-
? hexToBigInt(tx.maxFeePerGas)
172-
: BigInt(0);
173-
174-
const maxPriorityFeePerGas = (tx.maxPriorityFeePerGas)
175-
? hexToBigInt(tx.maxPriorityFeePerGas)
176-
: BigInt(0);
168+
const tx = toTransactionSerializable(_tx);
169+
const type = getTransactionType(tx) as "eip2930" | "eip4844" | "eip7702" | "eip1559" | "legacy" | undefined;
177170

178171
// For arbitrum - part of their estimation flow at nitro
179172
// TEMORARILY DISABLED DUE TO CRASH REPORTED IN ISSUE #258
@@ -186,16 +179,29 @@ export function getSerializedTx(tx: JsonRpcTx, emulateSignatureComponents = fals
186179
}
187180

188181
return serializeTransaction ({
189-
to: tx.to as Hex,
190-
maxFeePerGas,
191-
maxPriorityFeePerGas,
192-
data: tx.data as Hex ? tx.data! as Hex : tx.input! as Hex,
193-
value: hexToBigInt(tx.value),
194-
chainId: parseInt(tx.chainId!),
182+
to: tx.to,
183+
maxFeePerGas: tx.maxFeePerGas,
184+
maxPriorityFeePerGas: tx.maxPriorityFeePerGas,
185+
data: tx.data,
186+
value: tx.value,
187+
chainId: tx.chainId,
195188
type,
196-
accessList: tx.accessList,
197-
nonce: parseInt(tx.nonce)
198-
}, signature)
189+
nonce: tx.nonce,
190+
} as TransactionSerializableLegacy, signature)
191+
}
192+
193+
export function toTransactionSerializable(_tx: JsonRpcTx) : TransactionSerializableGeneric {
194+
195+
return {
196+
data: _tx.data as Hex ? _tx.data! as Hex : _tx.input! as Hex,
197+
to: _tx.to as Hex,
198+
value: hexToBigInt(_tx.value),
199+
nonce: parseInt(_tx.nonce),
200+
gas: (_tx.gas) ? hexToBigInt(_tx.gas) : BigInt(0),
201+
maxFeePerGas: (_tx.maxFeePerGas) ? hexToBigInt(_tx.maxFeePerGas) : BigInt(0),
202+
maxPriorityFeePerGas: (_tx.maxPriorityFeePerGas) ? hexToBigInt(_tx.maxPriorityFeePerGas) : BigInt(0),
203+
chainId: (_tx.chainId === undefined) ? 1337 : parseInt(_tx.chainId),
204+
}
199205
}
200206

201207
/**
@@ -365,13 +371,4 @@ export function getArbitrumBaseFeePerByte(val: number): number {
365371
return parseInt(gwei.toString());
366372
}
367373

368-
export function normalizeTxType(_type: string): ("legacy" | "eip1559" | "eip2930" | "eip4844") {
369-
switch(hexToDecimal(_type)) {
370-
case 0: return 'legacy';
371-
case 1: return 'eip2930';
372-
case 2: return 'eip1559';
373-
case 3: return 'eip4844';
374-
default: return 'legacy';
375-
}
376-
}
377374

yarn.lock

+96-42
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
version "1.2.6"
77
resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf"
88

9-
"@adraffy/[email protected]":
10-
version "1.10.0"
11-
resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz#d2a39395c587e092d77cbbc80acf956a54f38bf7"
12-
139
"@adraffy/[email protected]":
1410
version "1.10.1"
1511
resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz#63430d04bd8c5e74f8d7d049338f1cd9d4f02069"
1612

13+
"@adraffy/ens-normalize@^1.10.1":
14+
version "1.11.0"
15+
resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.11.0.tgz#42cc67c5baa407ac25059fcd7d405cc5ecdb0c33"
16+
integrity sha512-/3DDPKHqqIqxUULp8yP4zODUY1i+2xvVWsv8A79xGWdCAG+8sb0hRh0Rk2QyOJUnnbyPUAZYcpBuRe3nS2OIUg==
17+
1718
"@aws-crypto/[email protected]":
1819
version "1.2.2"
1920
resolved "https://registry.yarnpkg.com/@aws-crypto/sha256-js/-/sha256-js-1.2.2.tgz#02acd1a1fda92896fc5a28ec7c6e164644ea32fc"
@@ -586,7 +587,7 @@
586587
tweetnacl "^1.0.3"
587588
tweetnacl-util "^0.15.1"
588589

589-
"@noble/[email protected]", "@noble/curves@~1.2.0":
590+
590591
version "1.2.0"
591592
resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.2.0.tgz#92d7e12e4e49b23105a2555c6984d41733d65c35"
592593
dependencies:
@@ -598,6 +599,20 @@
598599
dependencies:
599600
"@noble/hashes" "1.3.3"
600601

602+
603+
version "1.8.1"
604+
resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.8.1.tgz#19bc3970e205c99e4bdb1c64a4785706bce497ff"
605+
integrity sha512-warwspo+UYUPep0Q+vtdVB4Ugn8GGQj8iyB3gnRWsztmUHTI3S1nhdiWNsPUGL0vud7JlRRk1XEu7Lq1KGTnMQ==
606+
dependencies:
607+
"@noble/hashes" "1.7.1"
608+
609+
"@noble/curves@^1.6.0", "@noble/curves@~1.8.1":
610+
version "1.8.2"
611+
resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.8.2.tgz#8f24c037795e22b90ae29e222a856294c1d9ffc7"
612+
integrity sha512-vnI7V6lFNe0tLAuJMu+2sX+FcL14TaCWy1qiczg1VwRmPrpQCdq5ESXQMqUc2tluRNf6irBXrWbl1mGN8uaU/g==
613+
dependencies:
614+
"@noble/hashes" "1.7.2"
615+
601616
"@noble/[email protected]", "@noble/hashes@~1.0.0":
602617
version "1.0.0"
603618
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.0.0.tgz#d5e38bfbdaba174805a4e649f13be9a9ed3351ae"
@@ -606,10 +621,20 @@
606621
version "1.3.2"
607622
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39"
608623

609-
"@noble/[email protected]", "@noble/hashes@~1.3.0", "@noble/hashes@~1.3.2":
624+
"@noble/[email protected]", "@noble/hashes@~1.3.2":
610625
version "1.3.3"
611626
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.3.tgz#39908da56a4adc270147bb07968bf3b16cfe1699"
612627

628+
629+
version "1.7.1"
630+
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.7.1.tgz#5738f6d765710921e7a751e00c20ae091ed8db0f"
631+
integrity sha512-B8XBPsn4vT/KJAGqDzbwztd+6Yte3P4V7iafm24bxgDe/mlRuK6xmWPuCNrKt2vDafZ8MfJLlchDG/vYafQEjQ==
632+
633+
"@noble/[email protected]", "@noble/hashes@^1.5.0", "@noble/hashes@~1.7.1":
634+
version "1.7.2"
635+
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.7.2.tgz#d53c65a21658fb02f3303e7ee3ba89d6754c64b4"
636+
integrity sha512-biZ0NUSxyjLLqo6KxEJ1b+C2NAx0wtDoFvCaXHGgUkeHzf3Xc1xKumFKREuT7f7DARNZ/slvYUwFG6B0f2b6hQ==
637+
613638
"@noble/[email protected]", "@noble/secp256k1@~1.5.2":
614639
version "1.5.5"
615640
resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.5.5.tgz#315ab5745509d1a8c8e90d0bdf59823ccf9bcfc3"
@@ -875,10 +900,15 @@
875900
version "1.0.0"
876901
resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.0.0.tgz#109fb595021de285f05a7db6806f2f48296fcee7"
877902

878-
"@scure/base@~1.1.0", "@scure/base@~1.1.2", "@scure/base@~1.1.4":
903+
"@scure/base@~1.1.4":
879904
version "1.1.5"
880905
resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.5.tgz#1d85d17269fe97694b9c592552dd9e5e33552157"
881906

907+
"@scure/base@~1.2.2", "@scure/base@~1.2.4":
908+
version "1.2.4"
909+
resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.2.4.tgz#002eb571a35d69bdb4c214d0995dff76a8dcd2a9"
910+
integrity sha512-5Yy9czTO47mqz+/J8GM6GIId4umdCk1wc1q8rKERQulIoc8VP9pzDcghv10Tl2E7R96ZUx/PhND3ESYUQX8NuQ==
911+
882912
883913
version "1.0.1"
884914
resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.0.1.tgz#1409bdf9f07f0aec99006bb0d5827693418d3aa5"
@@ -887,14 +917,6 @@
887917
"@noble/secp256k1" "~1.5.2"
888918
"@scure/base" "~1.0.0"
889919

890-
891-
version "1.3.2"
892-
resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.3.2.tgz#90e78c027d5e30f0b22c1f8d50ff12f3fb7559f8"
893-
dependencies:
894-
"@noble/curves" "~1.2.0"
895-
"@noble/hashes" "~1.3.2"
896-
"@scure/base" "~1.1.2"
897-
898920
899921
version "1.3.3"
900922
resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.3.3.tgz#a9624991dc8767087c57999a5d79488f48eae6c8"
@@ -903,27 +925,37 @@
903925
"@noble/hashes" "~1.3.2"
904926
"@scure/base" "~1.1.4"
905927

928+
"@scure/[email protected]", "@scure/bip32@^1.5.0":
929+
version "1.6.2"
930+
resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.6.2.tgz#093caa94961619927659ed0e711a6e4bf35bffd0"
931+
integrity sha512-t96EPDMbtGgtb7onKKqxRLfE5g05k7uHnHRM2xdE6BP/ZmxaLtPek4J4KfVn/90IQNrU1IOAqMgiDtUdtbe3nw==
932+
dependencies:
933+
"@noble/curves" "~1.8.1"
934+
"@noble/hashes" "~1.7.1"
935+
"@scure/base" "~1.2.2"
936+
906937
907938
version "1.0.0"
908939
resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.0.0.tgz#47504e58de9a56a4bbed95159d2d6829fa491bb0"
909940
dependencies:
910941
"@noble/hashes" "~1.0.0"
911942
"@scure/base" "~1.0.0"
912943

913-
914-
version "1.2.1"
915-
resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.2.1.tgz#5cee8978656b272a917b7871c981e0541ad6ac2a"
916-
dependencies:
917-
"@noble/hashes" "~1.3.0"
918-
"@scure/base" "~1.1.0"
919-
920944
921945
version "1.2.2"
922946
resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.2.2.tgz#f3426813f4ced11a47489cbcf7294aa963966527"
923947
dependencies:
924948
"@noble/hashes" "~1.3.2"
925949
"@scure/base" "~1.1.4"
926950

951+
"@scure/[email protected]", "@scure/bip39@^1.4.0":
952+
version "1.5.4"
953+
resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.5.4.tgz#07fd920423aa671be4540d59bdd344cc1461db51"
954+
integrity sha512-TFM4ni0vKvCfBpohoh+/lY05i9gRbSwXWngAsF4CABQxoaOHijxuaZ2R6cStDQ5CHtHO9aGJTr4ksVJASRRyMA==
955+
dependencies:
956+
"@noble/hashes" "~1.7.1"
957+
"@scure/base" "~1.2.4"
958+
927959
928960
version "5.27.1"
929961
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.27.1.tgz#489604054d821e1de155f80fe650085b37cad235"
@@ -1189,9 +1221,10 @@
11891221
base64-sol "1.0.1"
11901222
hardhat-watcher "^2.1.1"
11911223

1192-
1193-
version "1.0.0"
1194-
resolved "https://registry.yarnpkg.com/abitype/-/abitype-1.0.0.tgz#237176dace81d90d018bebf3a45cb42f2a2d9e97"
1224+
[email protected], abitype@^1.0.6:
1225+
version "1.0.8"
1226+
resolved "https://registry.yarnpkg.com/abitype/-/abitype-1.0.8.tgz#3554f28b2e9d6e9f35eb59878193eabd1b9f46ba"
1227+
integrity sha512-ZeiI6h3GnW06uYDLx0etQtX/p8E24UaHHBj57RSjK7YBFe7iuVn07EDpOeP451D06sF27VOz9JJPlIKJmXgkEg==
11951228

11961229
abitype@^0.9.8:
11971230
version "0.9.10"
@@ -2263,6 +2296,11 @@ [email protected], ethjs-util@^0.1.6:
22632296
is-hex-prefixed "1.0.0"
22642297
strip-hex-prefix "1.0.0"
22652298

2299+
2300+
version "5.0.1"
2301+
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-5.0.1.tgz#53f5ffd0a492ac800721bb42c66b841de96423c4"
2302+
integrity sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==
2303+
22662304
evp_bytestokey@^1.0.3:
22672305
version "1.0.3"
22682306
resolved "https://registry.yarnpkg.com/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz#7fcbdb198dc71959432efe13842684e0525acb02"
@@ -2901,9 +2939,10 @@ isomorphic-unfetch@^3.0.0:
29012939
node-fetch "^2.6.1"
29022940
unfetch "^4.2.0"
29032941

2904-
2905-
version "1.0.3"
2906-
resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.3.tgz#93c1cf0575daf56e7120bab5c8c448b0809d0d74"
2942+
2943+
version "1.0.6"
2944+
resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.6.tgz#0da29d706fa51551c663c627ace42769850f86e7"
2945+
integrity sha512-lPHCayd40oW98/I0uvgaHKWCSvkzY27LjWLbtzOm64yQ+G3Q5npjjbdppU65iZXkK1Zt+kH9pfegli0AYfwYYw==
29072946

29082947
jackspeak@^2.3.5:
29092948
version "2.3.6"
@@ -3276,6 +3315,19 @@ os-tmpdir@~1.0.2:
32763315
version "1.0.2"
32773316
resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
32783317

3318+
3319+
version "0.6.9"
3320+
resolved "https://registry.yarnpkg.com/ox/-/ox-0.6.9.tgz#da1ee04fa10de30c8d04c15bfb80fe58b1f554bd"
3321+
integrity sha512-wi5ShvzE4eOcTwQVsIPdFr+8ycyX+5le/96iAJutaZAvCes1J0+RvpEPg5QDPDiaR0XQQAvZVl7AwqQcINuUug==
3322+
dependencies:
3323+
"@adraffy/ens-normalize" "^1.10.1"
3324+
"@noble/curves" "^1.6.0"
3325+
"@noble/hashes" "^1.5.0"
3326+
"@scure/bip32" "^1.5.0"
3327+
"@scure/bip39" "^1.4.0"
3328+
abitype "^1.0.6"
3329+
eventemitter3 "5.0.1"
3330+
32793331
p-limit@^3.0.2:
32803332
version "3.1.0"
32813333
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b"
@@ -3996,18 +4048,19 @@ uuid@^8.3.2:
39964048
version "8.3.2"
39974049
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
39984050

3999-
4000-
version "2.7.14"
4001-
resolved "https://registry.yarnpkg.com/viem/-/viem-2.7.14.tgz#347d316cb5400f0b896b2205b1bc8073aa5e27e0"
4051+
viem@^2.27.0:
4052+
version "2.27.0"
4053+
resolved "https://registry.yarnpkg.com/viem/-/viem-2.27.0.tgz#edfca8e107d96eecff70d6c4f049c5e43422f902"
4054+
integrity sha512-pKw2dcwDi6TaWlTzLHYazOgjO1GgbUpE1zdLsLNSiCjHNrMTpL/teL0wVHnJDLiB2tR5CL19LBqefYNtRUkH5Q==
40024055
dependencies:
4003-
"@adraffy/ens-normalize" "1.10.0"
4004-
"@noble/curves" "1.2.0"
4005-
"@noble/hashes" "1.3.2"
4006-
"@scure/bip32" "1.3.2"
4007-
"@scure/bip39" "1.2.1"
4008-
abitype "1.0.0"
4009-
isows "1.0.3"
4010-
ws "8.13.0"
4056+
"@noble/curves" "1.8.1"
4057+
"@noble/hashes" "1.7.1"
4058+
"@scure/bip32" "1.6.2"
4059+
"@scure/bip39" "1.5.4"
4060+
abitype "1.0.8"
4061+
isows "1.0.6"
4062+
ox "0.6.9"
4063+
ws "8.18.1"
40114064

40124065
webidl-conversions@^3.0.0:
40134066
version "3.0.1"
@@ -4088,9 +4141,10 @@ [email protected]:
40884141
version "7.4.6"
40894142
resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.6.tgz#5654ca8ecdeee47c33a9a4bf6d28e2be2980377c"
40904143

4091-
4092-
version "8.13.0"
4093-
resolved "https://registry.yarnpkg.com/ws/-/ws-8.13.0.tgz#9a9fb92f93cf41512a0735c8f4dd09b8a1211cd0"
4144+
4145+
version "8.18.1"
4146+
resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.1.tgz#ea131d3784e1dfdff91adb0a4a116b127515e3cb"
4147+
integrity sha512-RKW2aJZMXeMxVpnZ6bck+RswznaxmzdULiBr6KY7XkTnW8uvt0iT9H5DkHUChXrc+uurzwa0rVI16n/Xzjdz1w==
40944148

40954149
40964150
version "8.5.0"

0 commit comments

Comments
 (0)