From 2c468f5b8771bf03fa3ff44ba04b140401afb76f Mon Sep 17 00:00:00 2001 From: Eugenio Paluello Date: Tue, 29 Oct 2024 19:35:59 +0100 Subject: [PATCH] Indexer refactoring: Constants (#1396) * fix: type constants * fix: move DEFAULT_BLOCK_GAS_LIMIT to constants.ts * fix: move IGNORED_KEYS to constants.ts * fix: move config const to constants.ts * fix: import * reorganize constants * fmt * update location --------- Co-authored-by: Thomas Coratger <60488569+tcoratger@users.noreply.github.com> Co-authored-by: Thomas Coratger --- indexer/deno.lock | 101 ++++++++++++++++++++++------------- indexer/src/constants.ts | 42 ++++++++++++--- indexer/src/types/header.ts | 11 +--- indexer/src/types/log.ts | 17 ++---- indexer/tests/header.test.ts | 3 +- indexer/tests/log.test.ts | 4 +- 6 files changed, 107 insertions(+), 71 deletions(-) diff --git a/indexer/deno.lock b/indexer/deno.lock index 8b0f78940..1a5fd721e 100644 --- a/indexer/deno.lock +++ b/indexer/deno.lock @@ -3,45 +3,39 @@ "packages": { "specifiers": { "npm:@types/node": "npm:@types/node@18.16.19", - "npm:sinon": "npm:sinon@18.0.0" + "npm:sinon": "npm:sinon@19.0.2" }, "npm": { - "@sinonjs/commons@2.0.0": { - "integrity": "sha512-uLa0j859mMrg2slwQYdO/AkrOfmH+X6LTVmNTS9CqexuE2IvVORIkSpJLqePAbEnKJ77aMmCwr1NUZ57120Xcg==", - "dependencies": { - "type-detect": "type-detect@4.0.8" - } - }, "@sinonjs/commons@3.0.1": { "integrity": "sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==", "dependencies": { "type-detect": "type-detect@4.0.8" } }, - "@sinonjs/fake-timers@11.2.2": { - "integrity": "sha512-G2piCSxQ7oWOxwGSAyFHfPIsyeJGXYtc6mFbnFA+kRXkiEnTl8c/8jul2S329iFBnDI9HGoeWWAZvuvOkZccgw==", + "@sinonjs/fake-timers@13.0.5": { + "integrity": "sha512-36/hTbH2uaWuGVERyC6da9YwGWnzUZXuPro/F2LfsdOsLnCojz/iSH8MxUt/FD2S5XBSVPhmArFUXcpCQ2Hkiw==", "dependencies": { "@sinonjs/commons": "@sinonjs/commons@3.0.1" } }, - "@sinonjs/samsam@8.0.0": { - "integrity": "sha512-Bp8KUVlLp8ibJZrnvq2foVhP0IVX2CIprMJPK0vqGqgrDa0OHVKeZyBykqskkrdxV6yKBPmGasO8LVjAKR3Gew==", + "@sinonjs/samsam@8.0.2": { + "integrity": "sha512-v46t/fwnhejRSFTGqbpn9u+LQ9xJDse10gNnPgAcxgdoCDMXj/G2asWAC/8Qs+BAZDicX+MNZouXT1A7c83kVw==", "dependencies": { - "@sinonjs/commons": "@sinonjs/commons@2.0.0", + "@sinonjs/commons": "@sinonjs/commons@3.0.1", "lodash.get": "lodash.get@4.4.2", - "type-detect": "type-detect@4.0.8" + "type-detect": "type-detect@4.1.0" } }, - "@sinonjs/text-encoding@0.7.2": { - "integrity": "sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==", + "@sinonjs/text-encoding@0.7.3": { + "integrity": "sha512-DE427ROAphMQzU4ENbliGYrBSYPXF+TtLg9S8vzeA+OF4ZKzoDdzfL8sxuMUGS/lgRhM6j1URSk9ghf7Xo1tyA==", "dependencies": {} }, "@types/node@18.16.19": { "integrity": "sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==", "dependencies": {} }, - "diff@5.2.0": { - "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", + "diff@7.0.0": { + "integrity": "sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw==", "dependencies": {} }, "has-flag@4.0.0": { @@ -56,28 +50,28 @@ "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", "dependencies": {} }, - "nise@6.0.0": { - "integrity": "sha512-K8ePqo9BFvN31HXwEtTNGzgrPpmvgciDsFz8aztFjt4LqKO/JeFD8tBOeuDiCMXrIl/m1YvfH8auSpxfaD09wg==", + "nise@6.1.1": { + "integrity": "sha512-aMSAzLVY7LyeM60gvBS423nBmIPP+Wy7St7hsb+8/fc1HmeoHJfLO8CKse4u3BtOZvQLJghYPI2i/1WZrEj5/g==", "dependencies": { "@sinonjs/commons": "@sinonjs/commons@3.0.1", - "@sinonjs/fake-timers": "@sinonjs/fake-timers@11.2.2", - "@sinonjs/text-encoding": "@sinonjs/text-encoding@0.7.2", + "@sinonjs/fake-timers": "@sinonjs/fake-timers@13.0.5", + "@sinonjs/text-encoding": "@sinonjs/text-encoding@0.7.3", "just-extend": "just-extend@6.2.0", - "path-to-regexp": "path-to-regexp@6.2.2" + "path-to-regexp": "path-to-regexp@8.2.0" } }, - "path-to-regexp@6.2.2": { - "integrity": "sha512-GQX3SSMokngb36+whdpRXE+3f9V8UzyAorlYvOGx87ufGHehNTn5lCxrKtLyZ4Yl/wEKnNnr98ZzOwwDZV5ogw==", + "path-to-regexp@8.2.0": { + "integrity": "sha512-TdrF7fW9Rphjq4RjrW0Kp2AW0Ahwu9sRGTkS6bvDi0SCwZlEZYmcfDbEsTz8RVk0EHIS/Vd1bv3JhG+1xZuAyQ==", "dependencies": {} }, - "sinon@18.0.0": { - "integrity": "sha512-+dXDXzD1sBO6HlmZDd7mXZCR/y5ECiEiGCBSGuFD/kZ0bDTofPYc6JaeGmPSF+1j1MejGUWkORbYOLDyvqCWpA==", + "sinon@19.0.2": { + "integrity": "sha512-euuToqM+PjO4UgXeLETsfQiuoyPXlqFezr6YZDFwHR3t4qaX0fZUe1MfPMznTL5f8BWrVS89KduLdMUsxFCO6g==", "dependencies": { "@sinonjs/commons": "@sinonjs/commons@3.0.1", - "@sinonjs/fake-timers": "@sinonjs/fake-timers@11.2.2", - "@sinonjs/samsam": "@sinonjs/samsam@8.0.0", - "diff": "diff@5.2.0", - "nise": "nise@6.0.0", + "@sinonjs/fake-timers": "@sinonjs/fake-timers@13.0.5", + "@sinonjs/samsam": "@sinonjs/samsam@8.0.2", + "diff": "diff@7.0.0", + "nise": "nise@6.1.1", "supports-color": "supports-color@7.2.0" } }, @@ -90,6 +84,10 @@ "type-detect@4.0.8": { "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dependencies": {} + }, + "type-detect@4.1.0": { + "integrity": "sha512-Acylog8/luQ8L7il+geoSxhEkazvkslg7PSNKOX59mbB9cOveP5aq9h74Y7YU8yDpJwetzQQrfIwtf4Wp4LKcw==", + "dependencies": {} } } }, @@ -132,27 +130,39 @@ "https://deno.land/x/xhr@0.3.0/mod.ts": "094aacd627fd9635cd942053bf8032b5223b909858fa9dc8ffa583752ff63b20", "https://esm.sh/@apibara/indexer@0.2.2": "e79b6231660c752e8d5cdaab0e5bc749fe9391bad3cad4ae14c7ec43aef31881", "https://esm.sh/@apibara/indexer@0.2.2/starknet": "f67c50a85f58eaa85292c0b3fdb0af5d0a9b2cb91dc27f1a7d289fd9b240ef5a", - "https://esm.sh/@ethereumjs/block@5.0.1": "c0d3d2b056c05c84a41b532395bb9ff00d97266bcd9aa0077cd280dad81fc9f7", - "https://esm.sh/@ethereumjs/evm@2.1.0": "f9ef9071e1f4dc9aa56d8409d14f733498ba254d20f34914978c4fa45605dfff", + "https://esm.sh/@ethereumjs/block@5.0.1": "20b616bc726aa3dd41d902c7b3b33181196bee7e580667d447818f4ee9be9505", + "https://esm.sh/@ethereumjs/evm@2.1.0": "42834501673a7bf262b5bc8178a0f98e07b5f8f77964060be27b91c76d91a4cd", "https://esm.sh/@ethereumjs/rlp@5.0.1": "7b9dd4514d91155bac856e0ba4b82303667491dad35c3f6f9544a5c8b6253ca6", - "https://esm.sh/@ethereumjs/trie@6.0.1": "2ea95b4d545ec2971bde5b938442b1c8885c6651b54201a4aebcdb32d619fd46", - "https://esm.sh/@ethereumjs/tx@5.1.0": "db89697de73a85aec54490818cd5e604b20dcb5d90bcdc7f19d4ca96fbb30286", - "https://esm.sh/@ethereumjs/util@9.0.1": "9d8c888c45407154e055b5d546a44f534c7478c21cc1f85d67cc43c1b5d4bec8", - "https://esm.sh/@ethereumjs/vm@7.1.0": "7624a3e9f45c79ea6758285f1e9ff3fba7b9fee0c88e3899dd6fed5ba1a2a391", - "https://esm.sh/starknet@5.24.3": "d566d139b1b25566d70584b163184697df6e3ad769a137a9c4fbd7111e16e7a4", + "https://esm.sh/@ethereumjs/trie@6.0.1": "153890273dd47972252b8284269bb19d90880ac7498aa44bedaaf9baa5a7df65", + "https://esm.sh/@ethereumjs/tx@5.1.0": "db0eeb4794f85cb5adc842a71f65f20084c1543e7537540f19f5865a8349600b", + "https://esm.sh/@ethereumjs/util@9.0.1": "35ab8ce9d60abcb6e79dcdd7e4116bbd400a735dc8101c63ec6f04a1767e30a3", + "https://esm.sh/@ethereumjs/vm@7.1.0": "755d44e81d01c9bdcd9856ebe340fb30927a70aa3788e8bf3df71da330a54365", + "https://esm.sh/starknet@5.24.3": "d65450f3e98eb7557fcda6a8d58f26be58e3f7a931ef1a32ed21d56f5b914692", "https://esm.sh/v135/@adraffy/ens-normalize@1.10.0/denonext/ens-normalize.mjs": "62517a294467b1122a56461b2a5961b47250b10eb163892bd6404639377bcb50", "https://esm.sh/v135/@apibara/indexer@0.2.2/denonext/indexer.mjs": "4e82307442bfbe961694e6961353b6f597450b46c7ff0397ffb66faf9b086e18", "https://esm.sh/v135/@apibara/indexer@0.2.2/denonext/starknet.js": "3d4e9a238bbe354005b186d3297ad17e020517c1fcc35c9cdda9dc54def96c29", "https://esm.sh/v135/@ethereumjs/block@5.0.1/denonext/block.mjs": "20a28bfa0504bfed4db609014df71a7370fab4042c8d7588e24e52799e0f5377", + "https://esm.sh/v135/@ethereumjs/block@5.1.1/denonext/block.mjs": "7850e8b35a7ef7b1945542c8466dc0941b724533d110e6c7e95f75afa5e5ecf8", + "https://esm.sh/v135/@ethereumjs/block@5.2.0/denonext/block.mjs": "7e58260271f92a7a7331825d0af839ed621ef5c78fa1aba17c88b143c848fd36", "https://esm.sh/v135/@ethereumjs/blockchain@7.0.1/denonext/blockchain.mjs": "40d1839341e06c624a337def06784fec5ec14a2b7f3499e3697cb0dbbb7e6eaf", + "https://esm.sh/v135/@ethereumjs/blockchain@7.1.0/denonext/blockchain.mjs": "b0a855f197281cc140e594f10017520ccea4fef8809e8ef56ec0ba3ccb0a3208", "https://esm.sh/v135/@ethereumjs/common@4.1.0/denonext/common.mjs": "1262c0794b45bb3338b0a1f689bfad7e3025c19a7d7b25dc3343c6f05de57f2b", + "https://esm.sh/v135/@ethereumjs/common@4.2.0/denonext/common.mjs": "833819137f8e3107ac337b0a728b515c73e35228fc0590fe0146636a08464ebb", + "https://esm.sh/v135/@ethereumjs/common@4.3.0/denonext/common.mjs": "64ae3588e243526d1c4c5a605855379a1f43e1a3420ec92361e8af8f2d66dabb", "https://esm.sh/v135/@ethereumjs/ethash@3.0.1/denonext/ethash.mjs": "270e354c9f7428321908b15ee2ed2059d809252301975ed8319642252c4c8c45", + "https://esm.sh/v135/@ethereumjs/ethash@3.0.3/denonext/ethash.mjs": "4e448a4c934fac61043240cca076531852dfd92b097781b24afc3ddf09e12f8a", "https://esm.sh/v135/@ethereumjs/evm@2.1.0/denonext/evm.mjs": "354c7af6010e607889342a26db50d2ce6f19c0da6a7f57596b2787d953730b5d", "https://esm.sh/v135/@ethereumjs/rlp@5.0.1/denonext/rlp.mjs": "e7053dd0273991e806a6a7a9ced77044fa81064deb6fbd38f72939fc371fab49", + "https://esm.sh/v135/@ethereumjs/rlp@5.0.2/denonext/rlp.mjs": "b366ad4607c58648fca6bc59f1129ccffb03ae6f9ecf4acbf84d0af6c472fd36", "https://esm.sh/v135/@ethereumjs/statemanager@2.1.0/denonext/statemanager.mjs": "004f1d957428db256cff0c2be1df939d1e631cf1d59a70e64ca59c63005d640b", "https://esm.sh/v135/@ethereumjs/trie@6.0.1/denonext/trie.mjs": "4530fab65263d29256c46a40cc86d8fe213d2b946f9707f63710a40d96838c43", + "https://esm.sh/v135/@ethereumjs/trie@6.1.1/denonext/trie.mjs": "18cb2ba2ca9a6b923b76df39f6a0bbb8924da060ca7e197dc33fb70ebaeb0daf", + "https://esm.sh/v135/@ethereumjs/trie@6.2.0/denonext/trie.mjs": "ad6ac166528a3cce269df6ab190194a9d17b7b33ac0a4915099b5f4b14b50906", "https://esm.sh/v135/@ethereumjs/tx@5.1.0/denonext/tx.mjs": "598717f77b3f07f343c860b7204ca78a9e07cc4a34834f10151a7e8cd6a707bd", + "https://esm.sh/v135/@ethereumjs/tx@5.2.1/denonext/tx.mjs": "9707ea745ab915b2b0b2516fc4bca0cd557c92a7db29af488c6b803a8e72e4ce", + "https://esm.sh/v135/@ethereumjs/tx@5.3.0/denonext/tx.mjs": "8c331389009b54c703325185dc239e2704e98338c95aaa59e3d0111e1123b73a", "https://esm.sh/v135/@ethereumjs/util@9.0.1/denonext/util.mjs": "d88f5e19c3354780d1381d1396c0fdcdde3da06b9dc5f49f35c707bf2319a718", + "https://esm.sh/v135/@ethereumjs/util@9.0.3/denonext/util.mjs": "4136b56b8c6f0f50a3b9c817b477c5e8921762c1964b84c1dc49689817af52a2", "https://esm.sh/v135/@ethereumjs/vm@7.1.0/denonext/vm.mjs": "0231103fb52517f7cff4fff9a025b0f3ff400bf3789095df4973e0157c348cd9", "https://esm.sh/v135/@noble/curves@1.1.0/denonext/_shortw_utils.js": "00cb8e706dc9a27d2b2ec805553cee799f10e479df771114b488f2c9c9a0dcec", "https://esm.sh/v135/@noble/curves@1.1.0/denonext/abstract/curve.js": "afcf481de38fff74955d1dd734cdc15e34a900ba71ed8656ad5c8810b0e66e5a", @@ -169,6 +179,13 @@ "https://esm.sh/v135/@noble/curves@1.2.0/denonext/abstract/utils.js": "33d6521fbb6756d058dff59616da1e55a55972b4848976c27e81c4b4bc36c0e4", "https://esm.sh/v135/@noble/curves@1.2.0/denonext/abstract/weierstrass.js": "5cb85ed9ad826f7e623f0052a55a865ad957eab06c30697804157844e82416a9", "https://esm.sh/v135/@noble/curves@1.2.0/denonext/secp256k1.js": "da024e491d38a1407d3bdf54f669bbefb879b710dfae945d4ca58a676fcfd37d", + "https://esm.sh/v135/@noble/curves@1.3.0/denonext/_shortw_utils.js": "8d690a8fbb0100093f6ab96457c634465eb4bd79f07adb30bbda5234d189c5e8", + "https://esm.sh/v135/@noble/curves@1.3.0/denonext/abstract/curve.js": "280130b0d3e1f15037b449b5870e1f39f5db99f8c310f85a9d4ab129d6dfa583", + "https://esm.sh/v135/@noble/curves@1.3.0/denonext/abstract/hash-to-curve.js": "591fb0f81529b2dc9f7ea61a0b988ab659564688ce33bd6c95b0e55c698cb338", + "https://esm.sh/v135/@noble/curves@1.3.0/denonext/abstract/modular.js": "f6a63a4725fe208141f87a773ba9485813ffd5291129656fd073f832fbcd4437", + "https://esm.sh/v135/@noble/curves@1.3.0/denonext/abstract/utils.js": "0ff50d14245befb0ee4b0eae5f0292acc5fd0f6e5f385195654d7825f0a75669", + "https://esm.sh/v135/@noble/curves@1.3.0/denonext/abstract/weierstrass.js": "f97e7a6ecf9f23a864538f7089645c17103f3809134c0bb99c29d56ce824e7b4", + "https://esm.sh/v135/@noble/curves@1.3.0/denonext/secp256k1.js": "641ad16ddf79c7f4b69cba4d266078ef21f446cfc3fec83120f6de4f6dee84aa", "https://esm.sh/v135/@noble/hashes@1.3.1/denonext/_assert.js": "d22dfffef44f75a84f61b9cedac204d6d39d6ccb14fc489e81bb9ab68de5f1c7", "https://esm.sh/v135/@noble/hashes@1.3.1/denonext/_sha2.js": "79869533e91a0a6ed446fb6d203c5ae9c458dc7ce990760446f4dbc0698eddab", "https://esm.sh/v135/@noble/hashes@1.3.1/denonext/crypto.js": "a66049789449b1cb447eb89a7f3f7adcd1ec4063beeacd3e0b6d84138ef38690", @@ -191,10 +208,13 @@ "https://esm.sh/v135/@noble/hashes@1.3.3/denonext/_assert.js": "f8882bd96e2a6d1834a445c5af97f927b1ba028f34963c8570568e33385c4419", "https://esm.sh/v135/@noble/hashes@1.3.3/denonext/_sha2.js": "7b27807ccd3cf7c3b90ce23b17bc9c5d791a72e41dd2e01a4debd9727990bca9", "https://esm.sh/v135/@noble/hashes@1.3.3/denonext/crypto.js": "cf6efbafcbb35e03bcb3a36cccd3d6d1f9bc4ba23f44a79551929a28c83e7901", + "https://esm.sh/v135/@noble/hashes@1.3.3/denonext/hmac.js": "c7a0a4fa8e369846713459398dfa1dc373ae5e6fa0eb7280f33dfd3f55a5c8fc", + "https://esm.sh/v135/@noble/hashes@1.3.3/denonext/ripemd160.js": "35ff63c8b0aac4bbd13b79494f7603edf9694444ec5e18d91ba09c4495451b69", "https://esm.sh/v135/@noble/hashes@1.3.3/denonext/sha256.js": "762e0b0cbde1990fc905eb816d30cdc0cf7dd4c23d123408c6963294f124f97d", "https://esm.sh/v135/@noble/hashes@1.3.3/denonext/sha3.js": "3765211a8eec7f75e4ad8f265c023ed372b16327f214133ce4fc64c3a1423404", "https://esm.sh/v135/@noble/hashes@1.3.3/denonext/utils.js": "701831e12a7e656df467b62f929ac9536ababef1b9b7445c7f87512366ae3933", "https://esm.sh/v135/@scure/base@1.1.5/denonext/base.mjs": "442a66c701330f27adff8b2fa6067308ff9a82b8e178c8482882ff4aa7dfee82", + "https://esm.sh/v135/@scure/base@1.1.6/denonext/base.mjs": "7c4c43cca9644ce6301e900ab7edcfebfd057ca778fa0efdd0cb746ae4339c6a", "https://esm.sh/v135/@scure/starknet@0.3.0/denonext/starknet.mjs": "d50471d53849ef5de4018ca196ef69fb8f487016b83c36b4a9509291672abd6c", "https://esm.sh/v135/aes-js@4.0.0-beta.5/denonext/aes-js.mjs": "b1b896f1484bbfc1178a000fd60d00c9f73ef9d30f5b8dcdf9796e684b231f86", "https://esm.sh/v135/bigint-crypto-utils@3.3.0/denonext/bigint-crypto-utils.mjs": "b578d1c4acc591b72e9e78ff896e705e542f91de789cd8490d1445e66acc21bd", @@ -232,6 +252,12 @@ "https://esm.sh/v135/ethereum-cryptography@2.1.2/denonext/secp256k1.js": "5d3152902365507958e16c57af02485d4486bc3a6f3df2d0b0ba0e59ba21bcc7", "https://esm.sh/v135/ethereum-cryptography@2.1.2/denonext/sha256.js": "961c9a682c3eebde948a48a5e71dc297f7c0927dd54e2d526ed71a23c798ec55", "https://esm.sh/v135/ethereum-cryptography@2.1.2/denonext/utils.js": "5e7d94766e9c1f6fe6a1233e63d84aaa3475d8660920e327de33503b645ceed4", + "https://esm.sh/v135/ethereum-cryptography@2.1.3/denonext/keccak.js": "7788e72f8aac863e531f8b2ac4d605e464ffa0a1f0e8d4b5ac74487e78a2937e", + "https://esm.sh/v135/ethereum-cryptography@2.1.3/denonext/random.js": "281c7233147d3aebd4866036ef2cda5883ecba22066e62adee68af937afc8aae", + "https://esm.sh/v135/ethereum-cryptography@2.1.3/denonext/ripemd160.js": "ed3df67d7324e8e3916409d9fa4ffc0d676a2ecbc7e13cd10f461071f5860b75", + "https://esm.sh/v135/ethereum-cryptography@2.1.3/denonext/secp256k1.js": "344a8e4200e5a1e2b1c62f84916187f3919dfdb5846ea94ee230f07ca44ad559", + "https://esm.sh/v135/ethereum-cryptography@2.1.3/denonext/sha256.js": "5356d6c4d013edbc2b0b34694240db23c5f4e7dcb61a48b838f951303cfc2ae2", + "https://esm.sh/v135/ethereum-cryptography@2.1.3/denonext/utils.js": "cd91f0ffa0c0775db2dad0936c1fd494659bcce3b14d375fbbcf6442a88e64b4", "https://esm.sh/v135/ethers@6.10.0/denonext/abi.js": "a4d92e6fe8b5028cf44ae4e57c3ae7cc434737e8b8207a1eeccf29a0c4cdf3b4", "https://esm.sh/v135/ethers@6.10.0/denonext/address.js": "3de1718c6d8416081667f7282ff144a3b7d6438f89d9494ee38941cea85217d8", "https://esm.sh/v135/ethers@6.10.0/denonext/constants.js": "41c55737b34d90465e50c1f8dbd9be80496645e56a32b4399f84ea082890cdbd", @@ -249,6 +275,7 @@ "https://esm.sh/v135/js-sdsl@4.4.2/denonext/js-sdsl.mjs": "9eec3540be7381f795ea76ddc1674aacdb190e4bcb84ed4d9a7e5020977a9e75", "https://esm.sh/v135/lossless-json@2.0.11/denonext/lossless-json.mjs": "cb67043586fcaab9a862a403c35abc3c8485788ec59fd403565c7f550a932085", "https://esm.sh/v135/lru-cache@10.1.0/denonext/lru-cache.mjs": "8eccca15513d8d1e660969697e34dd104c57dfbe3f20f0e88e04650a3e1bd93a", + "https://esm.sh/v135/lru-cache@10.2.0/denonext/lru-cache.mjs": "f524a6e9a51f3da40659f7ad3ad251e55e18b7ae807ea3a9a546f355e7c426bb", "https://esm.sh/v135/ms@2.1.2/denonext/ms.mjs": "aa4dc45ba72554c5011168f8910cc646c37af53cfff1a15a4decced838b8eb14", "https://esm.sh/v135/pako@2.1.0/denonext/pako.mjs": "a96661a4528965146d092709c0566bbb9a6fbc04e21587adfae26d48b2b3d763", "https://esm.sh/v135/readable-stream@3.6.2/denonext/readable-stream.mjs": "35fc04c3200b796d676d0e83607fcfc150048bdcc5bdb7d5d836b5921049788f", diff --git a/indexer/src/constants.ts b/indexer/src/constants.ts index 81a19457c..3443ce14e 100644 --- a/indexer/src/constants.ts +++ b/indexer/src/constants.ts @@ -2,7 +2,7 @@ import { padString } from "./utils/hex.ts"; import { hash } from "./deps.ts"; // Get Sink Type or returns "console" if the value is null or undefined -export const SINK_TYPE = (() => { +export const SINK_TYPE: "console" | "mongo" = (() => { const addr = Deno.env.get("SINK_TYPE") ?? "console"; if (addr !== "console" && addr !== "mongo") { throw new Error("Invalid SINK_TYPE"); @@ -11,17 +11,23 @@ export const SINK_TYPE = (() => { })(); // Get the sink options from the sink type -export const SINK_OPTIONS = SINK_TYPE === "mongo" +export const SINK_OPTIONS: { + connectionString?: string; + database?: string; + collectionNames: string[]; +} = SINK_TYPE === "mongo" ? { connectionString: Deno.env.get("MONGO_CONNECTION_STRING") ?? "mongodb://mongo:mongo@mongo:27017", database: Deno.env.get("MONGO_DATABASE_NAME") ?? "kakarot-test-db", collectionNames: ["headers", "transactions", "receipts", "logs"], } - : {}; + : { + collectionNames: [], + }; // Get the starting block or returns 0 if the value is null or undefined -export const STARTING_BLOCK = (() => { +export const STARTING_BLOCK: number = (() => { const startingBlock = Number(Deno.env.get("STARTING_BLOCK") ?? 0); return Number.isSafeInteger(startingBlock) && startingBlock >= 0 ? startingBlock @@ -31,16 +37,17 @@ export const STARTING_BLOCK = (() => { })(); // Get authentication token from Apibara or returns an empty string if the value is null or undefined -export const AUTH_TOKEN = Deno.env.get("APIBARA_AUTH_TOKEN") ?? ""; +export const AUTH_TOKEN: string = Deno.env.get("APIBARA_AUTH_TOKEN") ?? ""; // Get stream URL or returns "http://localhost:7171" if the value is null or undefined -export const STREAM_URL = Deno.env.get("STREAM_URL") ?? "http://localhost:7171"; +export const STREAM_URL: string = Deno.env.get("STREAM_URL") ?? + "http://localhost:7171"; // Creates string that starts with "0x" and is padded to a total length of 64 chars -export const NULL_HASH = padString("0x", 32); +export const NULL_HASH: string = padString("0x", 32); // Get the hash selector from the transaction executed -export const TRANSACTION_EXECUTED = hash.getSelectorFromName( +export const TRANSACTION_EXECUTED: string = hash.getSelectorFromName( "transaction_executed", ); @@ -50,3 +57,22 @@ export const KAKAROT_ADDRESS: string = (() => { if (!kakarotAddress) throw new Error("ENV: KAKAROT_ADDRESS is not set"); return kakarotAddress; })(); + +// A default block gas limit in case the call to get_block_gas_limit fails. +export const DEFAULT_BLOCK_GAS_LIMIT: string = (() => { + const defaultBlockGasLimitStr = Deno.env.get("DEFAULT_BLOCK_GAS_LIMIT"); + if (!defaultBlockGasLimitStr) { + throw new Error("ENV: DEFAULT_BLOCK_GAS_LIMIT is not set"); + } + return defaultBlockGasLimitStr; +})(); + +// Events containing these keys are not +// ETH logs and should be ignored. +export const IGNORED_KEYS: bigint[] = [ + BigInt(hash.getSelectorFromName("transaction_executed")), + BigInt(hash.getSelectorFromName("evm_contract_deployed")), + BigInt(hash.getSelectorFromName("Transfer")), + BigInt(hash.getSelectorFromName("Approval")), + BigInt(hash.getSelectorFromName("OwnershipTransferred")), +]; diff --git a/indexer/src/types/header.ts b/indexer/src/types/header.ts index 63511408a..afe280aea 100644 --- a/indexer/src/types/header.ts +++ b/indexer/src/types/header.ts @@ -10,16 +10,7 @@ import { JsonRpcBlock } from "./types.ts"; import { KAKAROT } from "../provider.ts"; // Constant -import { NULL_HASH } from "../constants.ts"; - -// A default block gas limit in case the call to get_block_gas_limit fails. -export const DEFAULT_BLOCK_GAS_LIMIT = (() => { - const defaultBlockGasLimitStr = Deno.env.get("DEFAULT_BLOCK_GAS_LIMIT"); - if (!defaultBlockGasLimitStr) { - throw new Error("ENV: DEFAULT_BLOCK_GAS_LIMIT is not set"); - } - return defaultBlockGasLimitStr; -})(); +import { DEFAULT_BLOCK_GAS_LIMIT, NULL_HASH } from "../constants.ts"; /** * Converts a Starknet block header to an Ethereum block header in JSON RPC format. diff --git a/indexer/src/types/log.ts b/indexer/src/types/log.ts index aa9819187..681e58dc7 100644 --- a/indexer/src/types/log.ts +++ b/indexer/src/types/log.ts @@ -2,7 +2,10 @@ import { padBigint } from "../utils/hex.ts"; // Constants -import { KAKAROT_ADDRESS, NULL_HASH } from "../constants.ts"; +import { IGNORED_KEYS, KAKAROT_ADDRESS, NULL_HASH } from "../constants.ts"; + +// Types +import { JsonRpcLog } from "./types.ts"; // Starknet import { Event, hash } from "../deps.ts"; @@ -16,18 +19,6 @@ import { PrefixedHexString, } from "../deps.ts"; -import { JsonRpcLog } from "./types.ts"; - -// Events containing these keys are not -// ETH logs and should be ignored. -export const IGNORED_KEYS = [ - BigInt(hash.getSelectorFromName("transaction_executed")), - BigInt(hash.getSelectorFromName("evm_contract_deployed")), - BigInt(hash.getSelectorFromName("Transfer")), - BigInt(hash.getSelectorFromName("Approval")), - BigInt(hash.getSelectorFromName("OwnershipTransferred")), -]; - /** * @param transaction - A Ethereum transaction. * @param event - A Starknet event. diff --git a/indexer/tests/header.test.ts b/indexer/tests/header.test.ts index 1ec6ec027..54f00f5a0 100644 --- a/indexer/tests/header.test.ts +++ b/indexer/tests/header.test.ts @@ -6,8 +6,9 @@ import { PrefixedHexString, } from "../src/deps.ts"; import { assertEquals } from "https://deno.land/std@0.213.0/assert/assert_equals.ts"; -import { DEFAULT_BLOCK_GAS_LIMIT, toEthHeader } from "../src/types/header.ts"; +import { toEthHeader } from "../src/types/header.ts"; import { JsonRpcBlock } from "../src/types/types.ts"; +import { DEFAULT_BLOCK_GAS_LIMIT } from "../src/constants.ts"; import { padString } from "../src/utils/hex.ts"; import sinon from "npm:sinon"; import { KAKAROT } from "../src/provider.ts"; diff --git a/indexer/tests/log.test.ts b/indexer/tests/log.test.ts index eebcc9d42..7f498a5d4 100644 --- a/indexer/tests/log.test.ts +++ b/indexer/tests/log.test.ts @@ -1,8 +1,8 @@ import { assertEquals } from "https://deno.land/std@0.213.0/assert/mod.ts"; -import { fromJsonRpcLog, IGNORED_KEYS, toEthLog } from "../src/types/log.ts"; +import { fromJsonRpcLog, toEthLog } from "../src/types/log.ts"; import { JsonRpcLog } from "../src/types/types.ts"; import { bigIntToHex, Event, JsonRpcTx } from "../src/deps.ts"; -import { KAKAROT_ADDRESS } from "../src/constants.ts"; +import { IGNORED_KEYS, KAKAROT_ADDRESS } from "../src/constants.ts"; // Mock for hexToBytes const mockHexToBytes = (hex: string): Uint8Array => {