diff --git a/packages/eventindexer/.gitignore b/packages/eventindexer/.gitignore index 9dbce223f63..af36bba2839 100644 --- a/packages/eventindexer/.gitignore +++ b/packages/eventindexer/.gitignore @@ -41,7 +41,8 @@ terraform.rc .idea -Bridge.json -TaikoL2.json -IHeaderSync.json -AssignmentHook.json \ No newline at end of file +# Ignore binary file +eventindexer + +# Ignore abi files +contracts/**/*.json diff --git a/packages/eventindexer/ProverPool.json b/packages/eventindexer/ProverPool.json deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/packages/eventindexer/SgxVerifier.json b/packages/eventindexer/SgxVerifier.json deleted file mode 100644 index d8975035755..00000000000 --- a/packages/eventindexer/SgxVerifier.json +++ /dev/null @@ -1,968 +0,0 @@ -[ - { - "type": "function", - "name": "INSTANCE_EXPIRY", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint64", - "internalType": "uint64" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "INSTANCE_VALIDITY_DELAY", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint64", - "internalType": "uint64" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "acceptOwnership", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "addInstances", - "inputs": [ - { - "name": "_instances", - "type": "address[]", - "internalType": "address[]" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256[]", - "internalType": "uint256[]" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "addressManager", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "addressRegistered", - "inputs": [ - { - "name": "instanceAddress", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "alreadyAttested", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "deleteInstances", - "inputs": [ - { - "name": "_ids", - "type": "uint256[]", - "internalType": "uint256[]" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "impl", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "inNonReentrant", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "init", - "inputs": [ - { - "name": "_owner", - "type": "address", - "internalType": "address" - }, - { - "name": "_addressManager", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "instances", - "inputs": [ - { - "name": "instanceId", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "addr", - "type": "address", - "internalType": "address" - }, - { - "name": "validSince", - "type": "uint64", - "internalType": "uint64" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "lastUnpausedAt", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint64", - "internalType": "uint64" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "nextInstanceId", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "owner", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "pause", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "paused", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "pendingOwner", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "proxiableUUID", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "registerInstance", - "inputs": [ - { - "name": "_attestation", - "type": "tuple", - "internalType": "struct V3Struct.ParsedV3QuoteStruct", - "components": [ - { - "name": "header", - "type": "tuple", - "internalType": "struct V3Struct.Header", - "components": [ - { - "name": "version", - "type": "bytes2", - "internalType": "bytes2" - }, - { - "name": "attestationKeyType", - "type": "bytes2", - "internalType": "bytes2" - }, - { - "name": "teeType", - "type": "bytes4", - "internalType": "bytes4" - }, - { - "name": "qeSvn", - "type": "bytes2", - "internalType": "bytes2" - }, - { - "name": "pceSvn", - "type": "bytes2", - "internalType": "bytes2" - }, - { - "name": "qeVendorId", - "type": "bytes16", - "internalType": "bytes16" - }, - { - "name": "userData", - "type": "bytes20", - "internalType": "bytes20" - } - ] - }, - { - "name": "localEnclaveReport", - "type": "tuple", - "internalType": "struct V3Struct.EnclaveReport", - "components": [ - { - "name": "cpuSvn", - "type": "bytes16", - "internalType": "bytes16" - }, - { - "name": "miscSelect", - "type": "bytes4", - "internalType": "bytes4" - }, - { - "name": "reserved1", - "type": "bytes28", - "internalType": "bytes28" - }, - { - "name": "attributes", - "type": "bytes16", - "internalType": "bytes16" - }, - { - "name": "mrEnclave", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "reserved2", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "mrSigner", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "reserved3", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "isvProdId", - "type": "uint16", - "internalType": "uint16" - }, - { - "name": "isvSvn", - "type": "uint16", - "internalType": "uint16" - }, - { - "name": "reserved4", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "reportData", - "type": "bytes", - "internalType": "bytes" - } - ] - }, - { - "name": "v3AuthData", - "type": "tuple", - "internalType": "struct V3Struct.ECDSAQuoteV3AuthData", - "components": [ - { - "name": "ecdsa256BitSignature", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "ecdsaAttestationKey", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "pckSignedQeReport", - "type": "tuple", - "internalType": "struct V3Struct.EnclaveReport", - "components": [ - { - "name": "cpuSvn", - "type": "bytes16", - "internalType": "bytes16" - }, - { - "name": "miscSelect", - "type": "bytes4", - "internalType": "bytes4" - }, - { - "name": "reserved1", - "type": "bytes28", - "internalType": "bytes28" - }, - { - "name": "attributes", - "type": "bytes16", - "internalType": "bytes16" - }, - { - "name": "mrEnclave", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "reserved2", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "mrSigner", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "reserved3", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "isvProdId", - "type": "uint16", - "internalType": "uint16" - }, - { - "name": "isvSvn", - "type": "uint16", - "internalType": "uint16" - }, - { - "name": "reserved4", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "reportData", - "type": "bytes", - "internalType": "bytes" - } - ] - }, - { - "name": "qeReportSignature", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "qeAuthData", - "type": "tuple", - "internalType": "struct V3Struct.QEAuthData", - "components": [ - { - "name": "parsedDataSize", - "type": "uint16", - "internalType": "uint16" - }, - { - "name": "data", - "type": "bytes", - "internalType": "bytes" - } - ] - }, - { - "name": "certification", - "type": "tuple", - "internalType": "struct V3Struct.CertificationData", - "components": [ - { - "name": "certType", - "type": "uint16", - "internalType": "uint16" - }, - { - "name": "certDataSize", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "decodedCertDataArray", - "type": "bytes[3]", - "internalType": "bytes[3]" - } - ] - } - ] - } - ] - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "renounceOwnership", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "resolve", - "inputs": [ - { - "name": "_chainId", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "_name", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "_allowZeroAddress", - "type": "bool", - "internalType": "bool" - } - ], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address payable" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "resolve", - "inputs": [ - { - "name": "_name", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "_allowZeroAddress", - "type": "bool", - "internalType": "bool" - } - ], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address payable" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "transferOwnership", - "inputs": [ - { - "name": "newOwner", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "unpause", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "upgradeTo", - "inputs": [ - { - "name": "newImplementation", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "upgradeToAndCall", - "inputs": [ - { - "name": "newImplementation", - "type": "address", - "internalType": "address" - }, - { - "name": "data", - "type": "bytes", - "internalType": "bytes" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "verifyProof", - "inputs": [ - { - "name": "_ctx", - "type": "tuple", - "internalType": "struct IVerifier.Context", - "components": [ - { - "name": "metaHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "blobHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "prover", - "type": "address", - "internalType": "address" - }, - { - "name": "blockId", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "isContesting", - "type": "bool", - "internalType": "bool" - }, - { - "name": "blobUsed", - "type": "bool", - "internalType": "bool" - }, - { - "name": "msgSender", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "_tran", - "type": "tuple", - "internalType": "struct TaikoData.Transition", - "components": [ - { - "name": "parentHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "blockHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "stateRoot", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "graffiti", - "type": "bytes32", - "internalType": "bytes32" - } - ] - }, - { - "name": "_proof", - "type": "tuple", - "internalType": "struct TaikoData.TierProof", - "components": [ - { - "name": "tier", - "type": "uint16", - "internalType": "uint16" - }, - { - "name": "data", - "type": "bytes", - "internalType": "bytes" - } - ] - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "event", - "name": "AdminChanged", - "inputs": [ - { - "name": "previousAdmin", - "type": "address", - "indexed": false, - "internalType": "address" - }, - { - "name": "newAdmin", - "type": "address", - "indexed": false, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "BeaconUpgraded", - "inputs": [ - { - "name": "beacon", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Initialized", - "inputs": [ - { - "name": "version", - "type": "uint8", - "indexed": false, - "internalType": "uint8" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "InstanceAdded", - "inputs": [ - { - "name": "id", - "type": "uint256", - "indexed": true, - "internalType": "uint256" - }, - { - "name": "instance", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "replaced", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "validSince", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "InstanceDeleted", - "inputs": [ - { - "name": "id", - "type": "uint256", - "indexed": true, - "internalType": "uint256" - }, - { - "name": "instance", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "OwnershipTransferStarted", - "inputs": [ - { - "name": "previousOwner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "newOwner", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "OwnershipTransferred", - "inputs": [ - { - "name": "previousOwner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "newOwner", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Paused", - "inputs": [ - { - "name": "account", - "type": "address", - "indexed": false, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Unpaused", - "inputs": [ - { - "name": "account", - "type": "address", - "indexed": false, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Upgraded", - "inputs": [ - { - "name": "implementation", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "error", - "name": "FUNC_NOT_IMPLEMENTED", - "inputs": [] - }, - { - "type": "error", - "name": "INVALID_PAUSE_STATUS", - "inputs": [] - }, - { - "type": "error", - "name": "REENTRANT_CALL", - "inputs": [] - }, - { - "type": "error", - "name": "RESOLVER_DENIED", - "inputs": [] - }, - { - "type": "error", - "name": "RESOLVER_INVALID_MANAGER", - "inputs": [] - }, - { - "type": "error", - "name": "RESOLVER_UNEXPECTED_CHAINID", - "inputs": [] - }, - { - "type": "error", - "name": "RESOLVER_ZERO_ADDR", - "inputs": [ - { - "name": "chainId", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "name", - "type": "bytes32", - "internalType": "bytes32" - } - ] - }, - { - "type": "error", - "name": "SGX_ALREADY_ATTESTED", - "inputs": [] - }, - { - "type": "error", - "name": "SGX_INVALID_ATTESTATION", - "inputs": [] - }, - { - "type": "error", - "name": "SGX_INVALID_INSTANCE", - "inputs": [] - }, - { - "type": "error", - "name": "SGX_INVALID_PROOF", - "inputs": [] - }, - { - "type": "error", - "name": "SGX_RA_NOT_SUPPORTED", - "inputs": [] - }, - { - "type": "error", - "name": "ZERO_ADDRESS", - "inputs": [] - }, - { - "type": "error", - "name": "ZERO_VALUE", - "inputs": [] - } -] diff --git a/packages/eventindexer/Swap.json b/packages/eventindexer/Swap.json deleted file mode 100644 index 97a2bc659b3..00000000000 --- a/packages/eventindexer/Swap.json +++ /dev/null @@ -1,1032 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address", - "name": "_factory", - "type": "address" - }, - { - "internalType": "address", - "name": "_WETH", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "WETH", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "tokenA", - "type": "address" - }, - { - "internalType": "address", - "name": "tokenB", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amountADesired", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountBDesired", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountAMin", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountBMin", - "type": "uint256" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" - } - ], - "name": "addLiquidity", - "outputs": [ - { - "internalType": "uint256", - "name": "amountA", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountB", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "liquidity", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "token", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amountTokenDesired", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountTokenMin", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountETHMin", - "type": "uint256" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" - } - ], - "name": "addLiquidityETH", - "outputs": [ - { - "internalType": "uint256", - "name": "amountToken", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountETH", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "liquidity", - "type": "uint256" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "factory", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amountOut", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "reserveIn", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "reserveOut", - "type": "uint256" - } - ], - "name": "getAmountIn", - "outputs": [ - { - "internalType": "uint256", - "name": "amountIn", - "type": "uint256" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amountIn", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "reserveIn", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "reserveOut", - "type": "uint256" - } - ], - "name": "getAmountOut", - "outputs": [ - { - "internalType": "uint256", - "name": "amountOut", - "type": "uint256" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amountOut", - "type": "uint256" - }, - { - "internalType": "address[]", - "name": "path", - "type": "address[]" - } - ], - "name": "getAmountsIn", - "outputs": [ - { - "internalType": "uint256[]", - "name": "amounts", - "type": "uint256[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amountIn", - "type": "uint256" - }, - { - "internalType": "address[]", - "name": "path", - "type": "address[]" - } - ], - "name": "getAmountsOut", - "outputs": [ - { - "internalType": "uint256[]", - "name": "amounts", - "type": "uint256[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amountA", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "reserveA", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "reserveB", - "type": "uint256" - } - ], - "name": "quote", - "outputs": [ - { - "internalType": "uint256", - "name": "amountB", - "type": "uint256" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "tokenA", - "type": "address" - }, - { - "internalType": "address", - "name": "tokenB", - "type": "address" - }, - { - "internalType": "uint256", - "name": "liquidity", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountAMin", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountBMin", - "type": "uint256" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" - } - ], - "name": "removeLiquidity", - "outputs": [ - { - "internalType": "uint256", - "name": "amountA", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountB", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "token", - "type": "address" - }, - { - "internalType": "uint256", - "name": "liquidity", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountTokenMin", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountETHMin", - "type": "uint256" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" - } - ], - "name": "removeLiquidityETH", - "outputs": [ - { - "internalType": "uint256", - "name": "amountToken", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountETH", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "token", - "type": "address" - }, - { - "internalType": "uint256", - "name": "liquidity", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountTokenMin", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountETHMin", - "type": "uint256" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" - } - ], - "name": "removeLiquidityETHSupportingFeeOnTransferTokens", - "outputs": [ - { - "internalType": "uint256", - "name": "amountETH", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "token", - "type": "address" - }, - { - "internalType": "uint256", - "name": "liquidity", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountTokenMin", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountETHMin", - "type": "uint256" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "approveMax", - "type": "bool" - }, - { - "internalType": "uint8", - "name": "v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "s", - "type": "bytes32" - } - ], - "name": "removeLiquidityETHWithPermit", - "outputs": [ - { - "internalType": "uint256", - "name": "amountToken", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountETH", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "token", - "type": "address" - }, - { - "internalType": "uint256", - "name": "liquidity", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountTokenMin", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountETHMin", - "type": "uint256" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "approveMax", - "type": "bool" - }, - { - "internalType": "uint8", - "name": "v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "s", - "type": "bytes32" - } - ], - "name": "removeLiquidityETHWithPermitSupportingFeeOnTransferTokens", - "outputs": [ - { - "internalType": "uint256", - "name": "amountETH", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "tokenA", - "type": "address" - }, - { - "internalType": "address", - "name": "tokenB", - "type": "address" - }, - { - "internalType": "uint256", - "name": "liquidity", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountAMin", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountBMin", - "type": "uint256" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "approveMax", - "type": "bool" - }, - { - "internalType": "uint8", - "name": "v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "s", - "type": "bytes32" - } - ], - "name": "removeLiquidityWithPermit", - "outputs": [ - { - "internalType": "uint256", - "name": "amountA", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountB", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amountOut", - "type": "uint256" - }, - { - "internalType": "address[]", - "name": "path", - "type": "address[]" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" - } - ], - "name": "swapETHForExactTokens", - "outputs": [ - { - "internalType": "uint256[]", - "name": "amounts", - "type": "uint256[]" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amountOutMin", - "type": "uint256" - }, - { - "internalType": "address[]", - "name": "path", - "type": "address[]" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" - } - ], - "name": "swapExactETHForTokens", - "outputs": [ - { - "internalType": "uint256[]", - "name": "amounts", - "type": "uint256[]" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amountOutMin", - "type": "uint256" - }, - { - "internalType": "address[]", - "name": "path", - "type": "address[]" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" - } - ], - "name": "swapExactETHForTokensSupportingFeeOnTransferTokens", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amountIn", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountOutMin", - "type": "uint256" - }, - { - "internalType": "address[]", - "name": "path", - "type": "address[]" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" - } - ], - "name": "swapExactTokensForETH", - "outputs": [ - { - "internalType": "uint256[]", - "name": "amounts", - "type": "uint256[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amountIn", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountOutMin", - "type": "uint256" - }, - { - "internalType": "address[]", - "name": "path", - "type": "address[]" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" - } - ], - "name": "swapExactTokensForETHSupportingFeeOnTransferTokens", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amountIn", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountOutMin", - "type": "uint256" - }, - { - "internalType": "address[]", - "name": "path", - "type": "address[]" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" - } - ], - "name": "swapExactTokensForTokens", - "outputs": [ - { - "internalType": "uint256[]", - "name": "amounts", - "type": "uint256[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amountIn", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountOutMin", - "type": "uint256" - }, - { - "internalType": "address[]", - "name": "path", - "type": "address[]" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" - } - ], - "name": "swapExactTokensForTokensSupportingFeeOnTransferTokens", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amountOut", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountInMax", - "type": "uint256" - }, - { - "internalType": "address[]", - "name": "path", - "type": "address[]" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" - } - ], - "name": "swapTokensForExactETH", - "outputs": [ - { - "internalType": "uint256[]", - "name": "amounts", - "type": "uint256[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amountOut", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountInMax", - "type": "uint256" - }, - { - "internalType": "address[]", - "name": "path", - "type": "address[]" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "deadline", - "type": "uint256" - } - ], - "name": "swapTokensForExactTokens", - "outputs": [ - { - "internalType": "uint256[]", - "name": "amounts", - "type": "uint256[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "type": "event", - "name": "Swap", - "inputs": [ - { - "type": "address", - "name": "sender", - "indexed": true - }, - { - "type": "uint256", - "name": "amount0In", - "indexed": false - }, - { - "type": "uint256", - "name": "amount1In", - "indexed": false - }, - { - "type": "uint256", - "name": "amount0Out", - "indexed": false - }, - { - "type": "uint256", - "name": "amount1Out", - "indexed": false - }, - { - "type": "address", - "name": "to", - "indexed": true - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Mint", - "inputs": [ - { - "type": "address", - "name": "sender", - "indexed": true - }, - { - "type": "uint256", - "name": "amount0", - "indexed": false - }, - { - "type": "uint256", - "name": "amount1", - "indexed": false - } - ], - "anonymous": false - }, - { - "stateMutability": "payable", - "type": "receive" - } -] diff --git a/packages/eventindexer/TaikoL1.json b/packages/eventindexer/TaikoL1.json deleted file mode 100644 index 7dd634023e2..00000000000 --- a/packages/eventindexer/TaikoL1.json +++ /dev/null @@ -1,1961 +0,0 @@ -[ - { - "type": "receive", - "stateMutability": "payable" - }, - { - "type": "function", - "name": "acceptOwnership", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "addressManager", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getBlock", - "inputs": [ - { - "name": "_blockId", - "type": "uint64", - "internalType": "uint64" - } - ], - "outputs": [ - { - "name": "blk_", - "type": "tuple", - "internalType": "struct TaikoData.Block", - "components": [ - { - "name": "metaHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "assignedProver", - "type": "address", - "internalType": "address" - }, - { - "name": "livenessBond", - "type": "uint96", - "internalType": "uint96" - }, - { - "name": "blockId", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "proposedAt", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "proposedIn", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "nextTransitionId", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "verifiedTransitionId", - "type": "uint32", - "internalType": "uint32" - } - ] - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getConfig", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "tuple", - "internalType": "struct TaikoData.Config", - "components": [ - { - "name": "chainId", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "blockMaxProposals", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "blockRingBufferSize", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "maxBlocksToVerify", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "blockMaxGasLimit", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "livenessBond", - "type": "uint96", - "internalType": "uint96" - }, - { - "name": "stateRootSyncInternal", - "type": "uint8", - "internalType": "uint8" - }, - { - "name": "checkEOAForCalldataDA", - "type": "bool", - "internalType": "bool" - } - ] - } - ], - "stateMutability": "pure" - }, - { - "type": "function", - "name": "getLastSyncedBlock", - "inputs": [], - "outputs": [ - { - "name": "blockId_", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "blockHash_", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "stateRoot_", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getLastVerifiedBlock", - "inputs": [], - "outputs": [ - { - "name": "blockId_", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "blockHash_", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "stateRoot_", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getStateVariables", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "tuple", - "internalType": "struct TaikoData.SlotA", - "components": [ - { - "name": "genesisHeight", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "genesisTimestamp", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "lastSyncedBlockId", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "lastSynecdAt", - "type": "uint64", - "internalType": "uint64" - } - ] - }, - { - "name": "", - "type": "tuple", - "internalType": "struct TaikoData.SlotB", - "components": [ - { - "name": "numBlocks", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "lastVerifiedBlockId", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "provingPaused", - "type": "bool", - "internalType": "bool" - }, - { - "name": "__reservedB1", - "type": "uint8", - "internalType": "uint8" - }, - { - "name": "__reservedB2", - "type": "uint16", - "internalType": "uint16" - }, - { - "name": "__reservedB3", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "lastUnpausedAt", - "type": "uint64", - "internalType": "uint64" - } - ] - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getTransition", - "inputs": [ - { - "name": "_blockId", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "_tid", - "type": "uint32", - "internalType": "uint32" - } - ], - "outputs": [ - { - "name": "", - "type": "tuple", - "internalType": "struct TaikoData.TransitionState", - "components": [ - { - "name": "key", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "blockHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "stateRoot", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "prover", - "type": "address", - "internalType": "address" - }, - { - "name": "validityBond", - "type": "uint96", - "internalType": "uint96" - }, - { - "name": "contester", - "type": "address", - "internalType": "address" - }, - { - "name": "contestBond", - "type": "uint96", - "internalType": "uint96" - }, - { - "name": "timestamp", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "tier", - "type": "uint16", - "internalType": "uint16" - }, - { - "name": "__reserved1", - "type": "uint8", - "internalType": "uint8" - } - ] - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getTransition", - "inputs": [ - { - "name": "_blockId", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "_parentHash", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "outputs": [ - { - "name": "", - "type": "tuple", - "internalType": "struct TaikoData.TransitionState", - "components": [ - { - "name": "key", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "blockHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "stateRoot", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "prover", - "type": "address", - "internalType": "address" - }, - { - "name": "validityBond", - "type": "uint96", - "internalType": "uint96" - }, - { - "name": "contester", - "type": "address", - "internalType": "address" - }, - { - "name": "contestBond", - "type": "uint96", - "internalType": "uint96" - }, - { - "name": "timestamp", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "tier", - "type": "uint16", - "internalType": "uint16" - }, - { - "name": "__reserved1", - "type": "uint8", - "internalType": "uint8" - } - ] - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "impl", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "inNonReentrant", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "init", - "inputs": [ - { - "name": "_owner", - "type": "address", - "internalType": "address" - }, - { - "name": "_addressManager", - "type": "address", - "internalType": "address" - }, - { - "name": "_genesisBlockHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "_toPause", - "type": "bool", - "internalType": "bool" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "init2", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "lastUnpausedAt", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint64", - "internalType": "uint64" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "owner", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "pause", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "pauseProving", - "inputs": [ - { - "name": "_pause", - "type": "bool", - "internalType": "bool" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "paused", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "pendingOwner", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "proposeBlock", - "inputs": [ - { - "name": "_params", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "_txList", - "type": "bytes", - "internalType": "bytes" - } - ], - "outputs": [ - { - "name": "meta_", - "type": "tuple", - "internalType": "struct TaikoData.BlockMetadata", - "components": [ - { - "name": "l1Hash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "difficulty", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "blobHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "extraData", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "depositsHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "coinbase", - "type": "address", - "internalType": "address" - }, - { - "name": "id", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "gasLimit", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "timestamp", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "l1Height", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "minTier", - "type": "uint16", - "internalType": "uint16" - }, - { - "name": "blobUsed", - "type": "bool", - "internalType": "bool" - }, - { - "name": "parentMetaHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "sender", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "deposits_", - "type": "tuple[]", - "internalType": "struct TaikoData.EthDeposit[]", - "components": [ - { - "name": "recipient", - "type": "address", - "internalType": "address" - }, - { - "name": "amount", - "type": "uint96", - "internalType": "uint96" - }, - { - "name": "id", - "type": "uint64", - "internalType": "uint64" - } - ] - } - ], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "proveBlock", - "inputs": [ - { - "name": "_blockId", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "_input", - "type": "bytes", - "internalType": "bytes" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "proxiableUUID", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "renounceOwnership", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "resolve", - "inputs": [ - { - "name": "_chainId", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "_name", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "_allowZeroAddress", - "type": "bool", - "internalType": "bool" - } - ], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address payable" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "resolve", - "inputs": [ - { - "name": "_name", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "_allowZeroAddress", - "type": "bool", - "internalType": "bool" - } - ], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address payable" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "state", - "inputs": [], - "outputs": [ - { - "name": "__reserve1", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "slotA", - "type": "tuple", - "internalType": "struct TaikoData.SlotA", - "components": [ - { - "name": "genesisHeight", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "genesisTimestamp", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "lastSyncedBlockId", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "lastSynecdAt", - "type": "uint64", - "internalType": "uint64" - } - ] - }, - { - "name": "slotB", - "type": "tuple", - "internalType": "struct TaikoData.SlotB", - "components": [ - { - "name": "numBlocks", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "lastVerifiedBlockId", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "provingPaused", - "type": "bool", - "internalType": "bool" - }, - { - "name": "__reservedB1", - "type": "uint8", - "internalType": "uint8" - }, - { - "name": "__reservedB2", - "type": "uint16", - "internalType": "uint16" - }, - { - "name": "__reservedB3", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "lastUnpausedAt", - "type": "uint64", - "internalType": "uint64" - } - ] - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "transferOwnership", - "inputs": [ - { - "name": "newOwner", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "unpause", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "upgradeTo", - "inputs": [ - { - "name": "newImplementation", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "upgradeToAndCall", - "inputs": [ - { - "name": "newImplementation", - "type": "address", - "internalType": "address" - }, - { - "name": "data", - "type": "bytes", - "internalType": "bytes" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "verifyBlocks", - "inputs": [ - { - "name": "_maxBlocksToVerify", - "type": "uint64", - "internalType": "uint64" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "event", - "name": "AdminChanged", - "inputs": [ - { - "name": "previousAdmin", - "type": "address", - "indexed": false, - "internalType": "address" - }, - { - "name": "newAdmin", - "type": "address", - "indexed": false, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "BeaconUpgraded", - "inputs": [ - { - "name": "beacon", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "BlockProposed", - "inputs": [ - { - "name": "blockId", - "type": "uint256", - "indexed": true, - "internalType": "uint256" - }, - { - "name": "assignedProver", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "livenessBond", - "type": "uint96", - "indexed": false, - "internalType": "uint96" - }, - { - "name": "meta", - "type": "tuple", - "indexed": false, - "internalType": "struct TaikoData.BlockMetadata", - "components": [ - { - "name": "l1Hash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "difficulty", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "blobHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "extraData", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "depositsHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "coinbase", - "type": "address", - "internalType": "address" - }, - { - "name": "id", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "gasLimit", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "timestamp", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "l1Height", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "minTier", - "type": "uint16", - "internalType": "uint16" - }, - { - "name": "blobUsed", - "type": "bool", - "internalType": "bool" - }, - { - "name": "parentMetaHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "sender", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "depositsProcessed", - "type": "tuple[]", - "indexed": false, - "internalType": "struct TaikoData.EthDeposit[]", - "components": [ - { - "name": "recipient", - "type": "address", - "internalType": "address" - }, - { - "name": "amount", - "type": "uint96", - "internalType": "uint96" - }, - { - "name": "id", - "type": "uint64", - "internalType": "uint64" - } - ] - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "BlockProposed", - "inputs": [ - { - "name": "blockId", - "type": "uint256", - "indexed": true, - "internalType": "uint256" - }, - { - "name": "assignedProver", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "livenessBond", - "type": "uint96", - "indexed": false, - "internalType": "uint96" - }, - { - "name": "meta", - "type": "tuple", - "indexed": false, - "internalType": "struct TaikoData.BlockMetadata", - "components": [ - { - "name": "l1Hash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "difficulty", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "blobHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "extraData", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "depositsHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "coinbase", - "type": "address", - "internalType": "address" - }, - { - "name": "id", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "gasLimit", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "timestamp", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "l1Height", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "minTier", - "type": "uint16", - "internalType": "uint16" - }, - { - "name": "blobUsed", - "type": "bool", - "internalType": "bool" - }, - { - "name": "parentMetaHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "sender", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "depositsProcessed", - "type": "tuple[]", - "indexed": false, - "internalType": "struct TaikoData.EthDeposit[]", - "components": [ - { - "name": "recipient", - "type": "address", - "internalType": "address" - }, - { - "name": "amount", - "type": "uint96", - "internalType": "uint96" - }, - { - "name": "id", - "type": "uint64", - "internalType": "uint64" - } - ] - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "BlockVerified", - "inputs": [ - { - "name": "blockId", - "type": "uint256", - "indexed": true, - "internalType": "uint256" - }, - { - "name": "prover", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "blockHash", - "type": "bytes32", - "indexed": false, - "internalType": "bytes32" - }, - { - "name": "stateRoot", - "type": "bytes32", - "indexed": false, - "internalType": "bytes32" - }, - { - "name": "tier", - "type": "uint16", - "indexed": false, - "internalType": "uint16" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "BlockVerified", - "inputs": [ - { - "name": "blockId", - "type": "uint256", - "indexed": true, - "internalType": "uint256" - }, - { - "name": "prover", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "blockHash", - "type": "bytes32", - "indexed": false, - "internalType": "bytes32" - }, - { - "name": "stateRoot", - "type": "bytes32", - "indexed": false, - "internalType": "bytes32" - }, - { - "name": "tier", - "type": "uint16", - "indexed": false, - "internalType": "uint16" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Initialized", - "inputs": [ - { - "name": "version", - "type": "uint8", - "indexed": false, - "internalType": "uint8" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "OwnershipTransferStarted", - "inputs": [ - { - "name": "previousOwner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "newOwner", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "OwnershipTransferred", - "inputs": [ - { - "name": "previousOwner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "newOwner", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Paused", - "inputs": [ - { - "name": "account", - "type": "address", - "indexed": false, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ProvingPaused", - "inputs": [ - { - "name": "paused", - "type": "bool", - "indexed": false, - "internalType": "bool" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ProvingPaused", - "inputs": [ - { - "name": "paused", - "type": "bool", - "indexed": false, - "internalType": "bool" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "StateVariablesUpdated", - "inputs": [ - { - "name": "slotB", - "type": "tuple", - "indexed": false, - "internalType": "struct TaikoData.SlotB", - "components": [ - { - "name": "numBlocks", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "lastVerifiedBlockId", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "provingPaused", - "type": "bool", - "internalType": "bool" - }, - { - "name": "__reservedB1", - "type": "uint8", - "internalType": "uint8" - }, - { - "name": "__reservedB2", - "type": "uint16", - "internalType": "uint16" - }, - { - "name": "__reservedB3", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "lastUnpausedAt", - "type": "uint64", - "internalType": "uint64" - } - ] - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "TransitionContested", - "inputs": [ - { - "name": "blockId", - "type": "uint256", - "indexed": true, - "internalType": "uint256" - }, - { - "name": "tran", - "type": "tuple", - "indexed": false, - "internalType": "struct TaikoData.Transition", - "components": [ - { - "name": "parentHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "blockHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "stateRoot", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "graffiti", - "type": "bytes32", - "internalType": "bytes32" - } - ] - }, - { - "name": "contester", - "type": "address", - "indexed": false, - "internalType": "address" - }, - { - "name": "contestBond", - "type": "uint96", - "indexed": false, - "internalType": "uint96" - }, - { - "name": "tier", - "type": "uint16", - "indexed": false, - "internalType": "uint16" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "TransitionContested", - "inputs": [ - { - "name": "blockId", - "type": "uint256", - "indexed": true, - "internalType": "uint256" - }, - { - "name": "tran", - "type": "tuple", - "indexed": false, - "internalType": "struct TaikoData.Transition", - "components": [ - { - "name": "parentHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "blockHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "stateRoot", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "graffiti", - "type": "bytes32", - "internalType": "bytes32" - } - ] - }, - { - "name": "contester", - "type": "address", - "indexed": false, - "internalType": "address" - }, - { - "name": "contestBond", - "type": "uint96", - "indexed": false, - "internalType": "uint96" - }, - { - "name": "tier", - "type": "uint16", - "indexed": false, - "internalType": "uint16" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "TransitionProved", - "inputs": [ - { - "name": "blockId", - "type": "uint256", - "indexed": true, - "internalType": "uint256" - }, - { - "name": "tran", - "type": "tuple", - "indexed": false, - "internalType": "struct TaikoData.Transition", - "components": [ - { - "name": "parentHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "blockHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "stateRoot", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "graffiti", - "type": "bytes32", - "internalType": "bytes32" - } - ] - }, - { - "name": "prover", - "type": "address", - "indexed": false, - "internalType": "address" - }, - { - "name": "validityBond", - "type": "uint96", - "indexed": false, - "internalType": "uint96" - }, - { - "name": "tier", - "type": "uint16", - "indexed": false, - "internalType": "uint16" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "TransitionProved", - "inputs": [ - { - "name": "blockId", - "type": "uint256", - "indexed": true, - "internalType": "uint256" - }, - { - "name": "tran", - "type": "tuple", - "indexed": false, - "internalType": "struct TaikoData.Transition", - "components": [ - { - "name": "parentHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "blockHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "stateRoot", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "graffiti", - "type": "bytes32", - "internalType": "bytes32" - } - ] - }, - { - "name": "prover", - "type": "address", - "indexed": false, - "internalType": "address" - }, - { - "name": "validityBond", - "type": "uint96", - "indexed": false, - "internalType": "uint96" - }, - { - "name": "tier", - "type": "uint16", - "indexed": false, - "internalType": "uint16" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Unpaused", - "inputs": [ - { - "name": "account", - "type": "address", - "indexed": false, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Upgraded", - "inputs": [ - { - "name": "implementation", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "error", - "name": "ETH_TRANSFER_FAILED", - "inputs": [] - }, - { - "type": "error", - "name": "FUNC_NOT_IMPLEMENTED", - "inputs": [] - }, - { - "type": "error", - "name": "INVALID_PAUSE_STATUS", - "inputs": [] - }, - { - "type": "error", - "name": "L1_ALREADY_CONTESTED", - "inputs": [] - }, - { - "type": "error", - "name": "L1_ALREADY_CONTESTED", - "inputs": [] - }, - { - "type": "error", - "name": "L1_ALREADY_PROVED", - "inputs": [] - }, - { - "type": "error", - "name": "L1_ALREADY_PROVED", - "inputs": [] - }, - { - "type": "error", - "name": "L1_BATCH_TRANSFER_FAILED", - "inputs": [] - }, - { - "type": "error", - "name": "L1_BATCH_TRANSFER_FAILED", - "inputs": [] - }, - { - "type": "error", - "name": "L1_BLOB_NOT_AVAILABLE", - "inputs": [] - }, - { - "type": "error", - "name": "L1_BLOB_NOT_AVAILABLE", - "inputs": [] - }, - { - "type": "error", - "name": "L1_BLOB_NOT_FOUND", - "inputs": [] - }, - { - "type": "error", - "name": "L1_BLOB_NOT_FOUND", - "inputs": [] - }, - { - "type": "error", - "name": "L1_BLOCK_MISMATCH", - "inputs": [] - }, - { - "type": "error", - "name": "L1_BLOCK_MISMATCH", - "inputs": [] - }, - { - "type": "error", - "name": "L1_BLOCK_MISMATCH", - "inputs": [] - }, - { - "type": "error", - "name": "L1_CANNOT_CONTEST", - "inputs": [] - }, - { - "type": "error", - "name": "L1_CANNOT_CONTEST", - "inputs": [] - }, - { - "type": "error", - "name": "L1_INVALID_BLOCK_ID", - "inputs": [] - }, - { - "type": "error", - "name": "L1_INVALID_BLOCK_ID", - "inputs": [] - }, - { - "type": "error", - "name": "L1_INVALID_BLOCK_ID", - "inputs": [] - }, - { - "type": "error", - "name": "L1_INVALID_CONFIG", - "inputs": [] - }, - { - "type": "error", - "name": "L1_INVALID_GENESIS_HASH", - "inputs": [] - }, - { - "type": "error", - "name": "L1_INVALID_GENESIS_HASH", - "inputs": [] - }, - { - "type": "error", - "name": "L1_INVALID_PARAM", - "inputs": [] - }, - { - "type": "error", - "name": "L1_INVALID_PAUSE_STATUS", - "inputs": [] - }, - { - "type": "error", - "name": "L1_INVALID_PAUSE_STATUS", - "inputs": [] - }, - { - "type": "error", - "name": "L1_INVALID_SIG", - "inputs": [] - }, - { - "type": "error", - "name": "L1_INVALID_SIG", - "inputs": [] - }, - { - "type": "error", - "name": "L1_INVALID_TIER", - "inputs": [] - }, - { - "type": "error", - "name": "L1_INVALID_TIER", - "inputs": [] - }, - { - "type": "error", - "name": "L1_INVALID_TRANSITION", - "inputs": [] - }, - { - "type": "error", - "name": "L1_INVALID_TRANSITION", - "inputs": [] - }, - { - "type": "error", - "name": "L1_LIVENESS_BOND_NOT_RECEIVED", - "inputs": [] - }, - { - "type": "error", - "name": "L1_NOT_ASSIGNED_PROVER", - "inputs": [] - }, - { - "type": "error", - "name": "L1_NOT_ASSIGNED_PROVER", - "inputs": [] - }, - { - "type": "error", - "name": "L1_NO_HOOKS", - "inputs": [] - }, - { - "type": "error", - "name": "L1_PROVING_PAUSED", - "inputs": [] - }, - { - "type": "error", - "name": "L1_RECEIVE_DISABLED", - "inputs": [] - }, - { - "type": "error", - "name": "L1_TOO_LATE", - "inputs": [] - }, - { - "type": "error", - "name": "L1_TOO_MANY_BLOCKS", - "inputs": [] - }, - { - "type": "error", - "name": "L1_TOO_MANY_BLOCKS", - "inputs": [] - }, - { - "type": "error", - "name": "L1_TRANSITION_ID_ZERO", - "inputs": [] - }, - { - "type": "error", - "name": "L1_TRANSITION_ID_ZERO", - "inputs": [] - }, - { - "type": "error", - "name": "L1_TRANSITION_NOT_FOUND", - "inputs": [] - }, - { - "type": "error", - "name": "L1_TRANSITION_NOT_FOUND", - "inputs": [] - }, - { - "type": "error", - "name": "L1_UNEXPECTED_PARENT", - "inputs": [] - }, - { - "type": "error", - "name": "L1_UNEXPECTED_PARENT", - "inputs": [] - }, - { - "type": "error", - "name": "L1_UNEXPECTED_TRANSITION_ID", - "inputs": [] - }, - { - "type": "error", - "name": "L1_UNEXPECTED_TRANSITION_ID", - "inputs": [] - }, - { - "type": "error", - "name": "REENTRANT_CALL", - "inputs": [] - }, - { - "type": "error", - "name": "RESOLVER_DENIED", - "inputs": [] - }, - { - "type": "error", - "name": "RESOLVER_INVALID_MANAGER", - "inputs": [] - }, - { - "type": "error", - "name": "RESOLVER_UNEXPECTED_CHAINID", - "inputs": [] - }, - { - "type": "error", - "name": "RESOLVER_ZERO_ADDR", - "inputs": [ - { - "name": "chainId", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "name", - "type": "bytes32", - "internalType": "bytes32" - } - ] - }, - { - "type": "error", - "name": "ZERO_ADDRESS", - "inputs": [] - }, - { - "type": "error", - "name": "ZERO_VALUE", - "inputs": [] - } -] diff --git a/packages/eventindexer/TaikoToken.json b/packages/eventindexer/TaikoToken.json deleted file mode 100644 index 3e68c27f388..00000000000 --- a/packages/eventindexer/TaikoToken.json +++ /dev/null @@ -1,1113 +0,0 @@ -[ - { - "type": "function", - "name": "CLOCK_MODE", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "string", - "internalType": "string" - } - ], - "stateMutability": "pure" - }, - { - "type": "function", - "name": "DOMAIN_SEPARATOR", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "acceptOwnership", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "addressManager", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "allowance", - "inputs": [ - { - "name": "owner", - "type": "address", - "internalType": "address" - }, - { - "name": "spender", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "approve", - "inputs": [ - { - "name": "spender", - "type": "address", - "internalType": "address" - }, - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "balanceOf", - "inputs": [ - { - "name": "account", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "batchTransfer", - "inputs": [ - { - "name": "recipients", - "type": "address[]", - "internalType": "address[]" - }, - { - "name": "amounts", - "type": "uint256[]", - "internalType": "uint256[]" - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "checkpoints", - "inputs": [ - { - "name": "account", - "type": "address", - "internalType": "address" - }, - { - "name": "pos", - "type": "uint32", - "internalType": "uint32" - } - ], - "outputs": [ - { - "name": "", - "type": "tuple", - "internalType": "struct ERC20VotesUpgradeable.Checkpoint", - "components": [ - { - "name": "fromBlock", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "votes", - "type": "uint224", - "internalType": "uint224" - } - ] - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "clock", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint48", - "internalType": "uint48" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "decimals", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint8", - "internalType": "uint8" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "decreaseAllowance", - "inputs": [ - { - "name": "spender", - "type": "address", - "internalType": "address" - }, - { - "name": "subtractedValue", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "delegate", - "inputs": [ - { - "name": "delegatee", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "delegateBySig", - "inputs": [ - { - "name": "delegatee", - "type": "address", - "internalType": "address" - }, - { - "name": "nonce", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "expiry", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "v", - "type": "uint8", - "internalType": "uint8" - }, - { - "name": "r", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "s", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "delegates", - "inputs": [ - { - "name": "account", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "eip712Domain", - "inputs": [], - "outputs": [ - { - "name": "fields", - "type": "bytes1", - "internalType": "bytes1" - }, - { - "name": "name", - "type": "string", - "internalType": "string" - }, - { - "name": "version", - "type": "string", - "internalType": "string" - }, - { - "name": "chainId", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "verifyingContract", - "type": "address", - "internalType": "address" - }, - { - "name": "salt", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "extensions", - "type": "uint256[]", - "internalType": "uint256[]" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getPastTotalSupply", - "inputs": [ - { - "name": "timepoint", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getPastVotes", - "inputs": [ - { - "name": "account", - "type": "address", - "internalType": "address" - }, - { - "name": "timepoint", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getVotes", - "inputs": [ - { - "name": "account", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "impl", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "inNonReentrant", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "increaseAllowance", - "inputs": [ - { - "name": "spender", - "type": "address", - "internalType": "address" - }, - { - "name": "addedValue", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "init", - "inputs": [ - { - "name": "_owner", - "type": "address", - "internalType": "address" - }, - { - "name": "_recipient", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "lastUnpausedAt", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint64", - "internalType": "uint64" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "string", - "internalType": "string" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "nonces", - "inputs": [ - { - "name": "owner", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "numCheckpoints", - "inputs": [ - { - "name": "account", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "uint32", - "internalType": "uint32" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "owner", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "pause", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "paused", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "pendingOwner", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "permit", - "inputs": [ - { - "name": "owner", - "type": "address", - "internalType": "address" - }, - { - "name": "spender", - "type": "address", - "internalType": "address" - }, - { - "name": "value", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "deadline", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "v", - "type": "uint8", - "internalType": "uint8" - }, - { - "name": "r", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "s", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "proxiableUUID", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "renounceOwnership", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "resolve", - "inputs": [ - { - "name": "_chainId", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "_name", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "_allowZeroAddress", - "type": "bool", - "internalType": "bool" - } - ], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address payable" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "resolve", - "inputs": [ - { - "name": "_name", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "_allowZeroAddress", - "type": "bool", - "internalType": "bool" - } - ], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address payable" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "symbol", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "string", - "internalType": "string" - } - ], - "stateMutability": "pure" - }, - { - "type": "function", - "name": "totalSupply", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "transfer", - "inputs": [ - { - "name": "to", - "type": "address", - "internalType": "address" - }, - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "transferFrom", - "inputs": [ - { - "name": "from", - "type": "address", - "internalType": "address" - }, - { - "name": "to", - "type": "address", - "internalType": "address" - }, - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "transferOwnership", - "inputs": [ - { - "name": "newOwner", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "unpause", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "upgradeTo", - "inputs": [ - { - "name": "newImplementation", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "upgradeToAndCall", - "inputs": [ - { - "name": "newImplementation", - "type": "address", - "internalType": "address" - }, - { - "name": "data", - "type": "bytes", - "internalType": "bytes" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "event", - "name": "AdminChanged", - "inputs": [ - { - "name": "previousAdmin", - "type": "address", - "indexed": false, - "internalType": "address" - }, - { - "name": "newAdmin", - "type": "address", - "indexed": false, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Approval", - "inputs": [ - { - "name": "owner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "spender", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "value", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "BeaconUpgraded", - "inputs": [ - { - "name": "beacon", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "DelegateChanged", - "inputs": [ - { - "name": "delegator", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "fromDelegate", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "toDelegate", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "DelegateVotesChanged", - "inputs": [ - { - "name": "delegate", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "previousBalance", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - }, - { - "name": "newBalance", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "EIP712DomainChanged", - "inputs": [], - "anonymous": false - }, - { - "type": "event", - "name": "Initialized", - "inputs": [ - { - "name": "version", - "type": "uint8", - "indexed": false, - "internalType": "uint8" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "OwnershipTransferStarted", - "inputs": [ - { - "name": "previousOwner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "newOwner", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "OwnershipTransferred", - "inputs": [ - { - "name": "previousOwner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "newOwner", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Paused", - "inputs": [ - { - "name": "account", - "type": "address", - "indexed": false, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Transfer", - "inputs": [ - { - "name": "from", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "to", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "value", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Unpaused", - "inputs": [ - { - "name": "account", - "type": "address", - "indexed": false, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Upgraded", - "inputs": [ - { - "name": "implementation", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "error", - "name": "FUNC_NOT_IMPLEMENTED", - "inputs": [] - }, - { - "type": "error", - "name": "INVALID_PAUSE_STATUS", - "inputs": [] - }, - { - "type": "error", - "name": "REENTRANT_CALL", - "inputs": [] - }, - { - "type": "error", - "name": "RESOLVER_DENIED", - "inputs": [] - }, - { - "type": "error", - "name": "RESOLVER_INVALID_MANAGER", - "inputs": [] - }, - { - "type": "error", - "name": "RESOLVER_UNEXPECTED_CHAINID", - "inputs": [] - }, - { - "type": "error", - "name": "RESOLVER_ZERO_ADDR", - "inputs": [ - { - "name": "chainId", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "name", - "type": "bytes32", - "internalType": "bytes32" - } - ] - }, - { - "type": "error", - "name": "TT_INVALID_PARAM", - "inputs": [] - }, - { - "type": "error", - "name": "ZERO_ADDRESS", - "inputs": [] - }, - { - "type": "error", - "name": "ZERO_VALUE", - "inputs": [] - } -] diff --git a/packages/eventindexer/api/api.go b/packages/eventindexer/api/api.go index ff77cdce199..8bbe3ae13cf 100644 --- a/packages/eventindexer/api/api.go +++ b/packages/eventindexer/api/api.go @@ -9,12 +9,16 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/labstack/echo/v4" + "github.com/urfave/cli/v2" + + "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/http" "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/repo" - "github.com/urfave/cli/v2" ) type API struct { + db db.DB + httpPort uint64 srv *http.Server @@ -96,6 +100,7 @@ func InitFromConfig(ctx context.Context, api *API, cfg *Config) error { return err } + api.db = db api.srv = srv api.httpPort = cfg.HTTPPort @@ -106,4 +111,9 @@ func (api *API) Close(ctx context.Context) { if err := api.srv.Shutdown(ctx); err != nil { slog.Error("srv shutdown", "error", err) } + + // Close db connection. + if err := api.db.Close(); err != nil { + slog.Error("Failed to close db connection", "err", err) + } } diff --git a/packages/eventindexer/api/config.go b/packages/eventindexer/api/config.go index 430f12d37f9..b407f711cfe 100644 --- a/packages/eventindexer/api/config.go +++ b/packages/eventindexer/api/config.go @@ -1,21 +1,16 @@ package api import ( - "database/sql" "strings" - "github.com/taikoxyz/taiko-mono/packages/eventindexer/cmd/flags" - "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" "github.com/urfave/cli/v2" "gorm.io/driver/mysql" "gorm.io/gorm" "gorm.io/gorm/logger" -) -type DB interface { - DB() (*sql.DB, error) - GormDB() *gorm.DB -} + "github.com/taikoxyz/taiko-mono/packages/eventindexer/cmd/flags" + "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" +) type Config struct { // db configs @@ -31,7 +26,7 @@ type Config struct { MetricsHTTPPort uint64 ETHClientTimeout uint64 CORSOrigins []string - OpenDBFunc func() (DB, error) + OpenDBFunc func() (db.DB, error) } // NewConfigFromCliContext creates a new config instance from command line flags. @@ -52,7 +47,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { MetricsHTTPPort: c.Uint64(flags.MetricsHTTPPort.Name), CORSOrigins: cors, RPCUrl: c.String(flags.APIRPCUrl.Name), - OpenDBFunc: func() (DB, error) { + OpenDBFunc: func() (db.DB, error) { return db.OpenDBConnection(db.DBConnectionOpts{ Name: c.String(flags.DatabaseUsername.Name), Password: c.String(flags.DatabasePassword.Name), @@ -61,7 +56,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { MaxIdleConns: c.Uint64(flags.DatabaseMaxIdleConns.Name), MaxOpenConns: c.Uint64(flags.DatabaseMaxOpenConns.Name), MaxConnLifetime: c.Uint64(flags.DatabaseConnMaxLifetime.Name), - OpenFunc: func(dsn string) (*db.DB, error) { + OpenFunc: func(dsn string) (db.DB, error) { gormDB, err := gorm.Open(mysql.Open(dsn), &gorm.Config{ Logger: logger.Default.LogMode(logger.Silent), }) diff --git a/packages/eventindexer/db.go b/packages/eventindexer/db.go deleted file mode 100644 index 531c2b6f3ca..00000000000 --- a/packages/eventindexer/db.go +++ /dev/null @@ -1,25 +0,0 @@ -package eventindexer - -import ( - "database/sql" - - "github.com/cyberhorsey/errors" - "gorm.io/gorm" -) - -var ( - ErrNoDB = errors.Validation.NewWithKeyAndDetail("ERR_NO_DB", "DB is required") -) - -type DBConnectionOpts struct { - Name string - Password string - Host string - Database string - OpenFunc func(dsn string) (DB, error) -} - -type DB interface { - DB() (*sql.DB, error) - GormDB() *gorm.DB -} diff --git a/packages/eventindexer/event.go b/packages/eventindexer/event.go index b73f6da498b..fdda18b7c66 100644 --- a/packages/eventindexer/event.go +++ b/packages/eventindexer/event.go @@ -114,8 +114,9 @@ type EventRepository interface { req *http.Request, address string, ) (paginate.Page, error) - DeleteAllAfterBlockID(blockID uint64, srcChainID uint64) error + DeleteAllAfterBlockID(ctx context.Context, blockID uint64, srcChainID uint64) error FindLatestBlockID( + ctx context.Context, srcChainID uint64, ) (uint64, error) GetBlockProvenBy(ctx context.Context, blockID int) ([]*Event, error) diff --git a/packages/eventindexer/generator/config.go b/packages/eventindexer/generator/config.go index 962d266a976..819a11c7df2 100644 --- a/packages/eventindexer/generator/config.go +++ b/packages/eventindexer/generator/config.go @@ -1,21 +1,16 @@ package generator import ( - "database/sql" "time" - "github.com/taikoxyz/taiko-mono/packages/eventindexer/cmd/flags" - "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" "github.com/urfave/cli/v2" "gorm.io/driver/mysql" "gorm.io/gorm" "gorm.io/gorm/logger" -) -type DB interface { - DB() (*sql.DB, error) - GormDB() *gorm.DB -} + "github.com/taikoxyz/taiko-mono/packages/eventindexer/cmd/flags" + "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" +) type Config struct { // db configs @@ -29,7 +24,7 @@ type Config struct { MetricsHTTPPort uint64 GenesisDate time.Time Regenerate bool - OpenDBFunc func() (DB, error) + OpenDBFunc func() (db.DB, error) } // NewConfigFromCliContext creates a new config instance from command line flags. @@ -50,7 +45,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { MetricsHTTPPort: c.Uint64(flags.MetricsHTTPPort.Name), GenesisDate: date, Regenerate: c.Bool(flags.Regenerate.Name), - OpenDBFunc: func() (DB, error) { + OpenDBFunc: func() (db.DB, error) { return db.OpenDBConnection(db.DBConnectionOpts{ Name: c.String(flags.DatabaseUsername.Name), Password: c.String(flags.DatabasePassword.Name), @@ -59,7 +54,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { MaxIdleConns: c.Uint64(flags.DatabaseMaxIdleConns.Name), MaxOpenConns: c.Uint64(flags.DatabaseMaxOpenConns.Name), MaxConnLifetime: c.Uint64(flags.DatabaseConnMaxLifetime.Name), - OpenFunc: func(dsn string) (*db.DB, error) { + OpenFunc: func(dsn string) (db.DB, error) { gormDB, err := gorm.Open(mysql.Open(dsn), &gorm.Config{ Logger: logger.Default.LogMode(logger.Silent), }) diff --git a/packages/eventindexer/generator/config_test.go b/packages/eventindexer/generator/config_test.go index 290e03421e0..83be7c9beb4 100644 --- a/packages/eventindexer/generator/config_test.go +++ b/packages/eventindexer/generator/config_test.go @@ -6,8 +6,10 @@ import ( "time" "github.com/stretchr/testify/assert" - "github.com/taikoxyz/taiko-mono/packages/eventindexer/cmd/flags" "github.com/urfave/cli/v2" + + "github.com/taikoxyz/taiko-mono/packages/eventindexer/cmd/flags" + "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" ) func setupApp() *cli.App { @@ -37,7 +39,7 @@ func TestNewConfigFromCliContext(t *testing.T) { wantTime, _ := time.Parse("2006-01-02", "2023-07-07") assert.Equal(t, wantTime, c.GenesisDate) - c.OpenDBFunc = func() (DB, error) { + c.OpenDBFunc = func() (db.DB, error) { return nil, nil } diff --git a/packages/eventindexer/generator/generator.go b/packages/eventindexer/generator/generator.go index f5acd51a5c7..e4e5f4d1743 100644 --- a/packages/eventindexer/generator/generator.go +++ b/packages/eventindexer/generator/generator.go @@ -9,10 +9,12 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/shopspring/decimal" - "github.com/taikoxyz/taiko-mono/packages/eventindexer" - "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/tasks" "github.com/urfave/cli/v2" "gorm.io/gorm" + + "github.com/taikoxyz/taiko-mono/packages/eventindexer" + "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" + "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/tasks" ) var ( @@ -23,7 +25,7 @@ var ( // a cronjob, to parse the indexed data from the database, and generate // time series data that can easily be displayed via charting libraries. type Generator struct { - db DB + db db.DB genesisDate time.Time regenerate bool } diff --git a/packages/eventindexer/indexer/config.go b/packages/eventindexer/indexer/config.go index 7e92c695c71..f0ac08b1983 100644 --- a/packages/eventindexer/indexer/config.go +++ b/packages/eventindexer/indexer/config.go @@ -1,21 +1,15 @@ package indexer import ( - "database/sql" - "github.com/ethereum/go-ethereum/common" - "github.com/taikoxyz/taiko-mono/packages/eventindexer/cmd/flags" - "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" "github.com/urfave/cli/v2" "gorm.io/driver/mysql" "gorm.io/gorm" "gorm.io/gorm/logger" -) -type DB interface { - DB() (*sql.DB, error) - GormDB() *gorm.DB -} + "github.com/taikoxyz/taiko-mono/packages/eventindexer/cmd/flags" + "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" +) type Config struct { // db configs @@ -37,7 +31,7 @@ type Config struct { IndexNFTs bool IndexERC20s bool Layer string - OpenDBFunc func() (DB, error) + OpenDBFunc func() (db.DB, error) } // NewConfigFromCliContext creates a new config instance from command line flags. @@ -61,7 +55,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { IndexNFTs: c.Bool(flags.IndexNFTs.Name), IndexERC20s: c.Bool(flags.IndexERC20s.Name), Layer: c.String(flags.Layer.Name), - OpenDBFunc: func() (DB, error) { + OpenDBFunc: func() (db.DB, error) { return db.OpenDBConnection(db.DBConnectionOpts{ Name: c.String(flags.DatabaseUsername.Name), Password: c.String(flags.DatabasePassword.Name), @@ -70,7 +64,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { MaxIdleConns: c.Uint64(flags.DatabaseMaxIdleConns.Name), MaxOpenConns: c.Uint64(flags.DatabaseMaxOpenConns.Name), MaxConnLifetime: c.Uint64(flags.DatabaseConnMaxLifetime.Name), - OpenFunc: func(dsn string) (*db.DB, error) { + OpenFunc: func(dsn string) (db.DB, error) { gormDB, err := gorm.Open(mysql.Open(dsn), &gorm.Config{ Logger: logger.Default.LogMode(logger.Silent), }) diff --git a/packages/eventindexer/indexer/indexer.go b/packages/eventindexer/indexer/indexer.go index cec7189d1be..836f4bce3bb 100644 --- a/packages/eventindexer/indexer/indexer.go +++ b/packages/eventindexer/indexer/indexer.go @@ -9,11 +9,13 @@ import ( "github.com/cyberhorsey/errors" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" + "github.com/urfave/cli/v2" + "github.com/taikoxyz/taiko-mono/packages/eventindexer" "github.com/taikoxyz/taiko-mono/packages/eventindexer/contracts/bridge" "github.com/taikoxyz/taiko-mono/packages/eventindexer/contracts/taikol1" + "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/repo" - "github.com/urfave/cli/v2" ) var ( @@ -34,6 +36,8 @@ var ( ) type Indexer struct { + db db.DB + accountRepo eventindexer.AccountRepository eventRepo eventindexer.EventRepository nftBalanceRepo eventindexer.NFTBalanceRepository @@ -183,6 +187,7 @@ func InitFromConfig(ctx context.Context, i *Indexer, cfg *Config) error { } } + i.db = db i.blockSaveMutex = &sync.Mutex{} i.accountRepo = accountRepository i.eventRepo = eventRepository @@ -212,4 +217,9 @@ func InitFromConfig(ctx context.Context, i *Indexer, cfg *Config) error { func (i *Indexer) Close(ctx context.Context) { i.wg.Wait() + + // Close db connection. + if err := i.db.Close(); err != nil { + slog.Error("Failed to close db connection", "err", err) + } } diff --git a/packages/eventindexer/indexer/set_initial_processing_block_height.go b/packages/eventindexer/indexer/set_initial_processing_block_height.go index d1866d15dc6..cc8e47830a3 100644 --- a/packages/eventindexer/indexer/set_initial_processing_block_height.go +++ b/packages/eventindexer/indexer/set_initial_processing_block_height.go @@ -26,7 +26,7 @@ func (i *Indexer) setInitialIndexingBlockByMode( switch mode { case Sync: // get most recently processed block height from the DB - latest, err := i.eventRepo.FindLatestBlockID( + latest, err := i.eventRepo.FindLatestBlockID(ctx, i.srcChainID, ) if err != nil { diff --git a/packages/eventindexer/pkg/db/db.go b/packages/eventindexer/pkg/db/db.go index 3b865643fb7..0fd3e6a7500 100644 --- a/packages/eventindexer/pkg/db/db.go +++ b/packages/eventindexer/pkg/db/db.go @@ -3,33 +3,48 @@ package db import ( "database/sql" "fmt" + "github.com/cyberhorsey/errors" "time" - "github.com/cyberhorsey/errors" "gorm.io/gorm" ) -type DB struct { +var ( + ErrNoDB = errors.Validation.NewWithKeyAndDetail("ERR_NO_DB", "DB is required") +) + +type DB interface { + DB() (*sql.DB, error) + GormDB() *gorm.DB + Close() error +} + +type Database struct { gormdb *gorm.DB } -func (db *DB) DB() (*sql.DB, error) { +func (db *Database) DB() (*sql.DB, error) { return db.gormdb.DB() } -func (db *DB) GormDB() *gorm.DB { +func (db *Database) GormDB() *gorm.DB { return db.gormdb } -func New(gormdb *gorm.DB) *DB { - return &DB{ - gormdb: gormdb, +func (db *Database) Close() error { + sqlDB, err := db.DB() + if err != nil { + return err } + + return sqlDB.Close() } -var ( - ErrNoDB = errors.Validation.NewWithKeyAndDetail("ERR_NO_DB", "DB is required") -) +func New(gormdb *gorm.DB) DB { + return &Database{ + gormdb: gormdb, + } +} type DBConnectionOpts struct { Name string @@ -39,10 +54,10 @@ type DBConnectionOpts struct { MaxIdleConns uint64 MaxOpenConns uint64 MaxConnLifetime uint64 - OpenFunc func(dsn string) (*DB, error) + OpenFunc func(dsn string) (DB, error) } -func OpenDBConnection(opts DBConnectionOpts) (*DB, error) { +func OpenDBConnection(opts DBConnectionOpts) (DB, error) { dsn := "" if opts.Password == "" { dsn = fmt.Sprintf( diff --git a/packages/eventindexer/pkg/flags/config.go b/packages/eventindexer/pkg/flags/config.go index e206f701dca..3211077a161 100644 --- a/packages/eventindexer/pkg/flags/config.go +++ b/packages/eventindexer/pkg/flags/config.go @@ -6,8 +6,9 @@ import ( "github.com/ethereum-optimism/optimism/op-service/txmgr" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - "github.com/taikoxyz/taiko-mono/packages/eventindexer/cmd/flags" "github.com/urfave/cli/v2" + + "github.com/taikoxyz/taiko-mono/packages/eventindexer/cmd/flags" ) // InitTxmgrConfigsFromCli initializes the transaction manager configs from the command line flags. diff --git a/packages/eventindexer/pkg/mock/event_repository.go b/packages/eventindexer/pkg/mock/event_repository.go index bec9186eb83..44a83bbbb1c 100644 --- a/packages/eventindexer/pkg/mock/event_repository.go +++ b/packages/eventindexer/pkg/mock/event_repository.go @@ -147,12 +147,13 @@ func (r *EventRepository) GetAssignedBlocksByProverAddress( } // DeleteAllAfterBlockID is used when a reorg is detected -func (r *EventRepository) DeleteAllAfterBlockID(blockID uint64, srcChainID uint64) error { +func (r *EventRepository) DeleteAllAfterBlockID(ctx context.Context, blockID uint64, srcChainID uint64) error { return nil } // GetLatestBlockID get latest block id func (r *EventRepository) FindLatestBlockID( + ctx context.Context, srcChainID uint64, ) (uint64, error) { if srcChainID == MockChainID.Uint64() { diff --git a/packages/eventindexer/pkg/repo/account.go b/packages/eventindexer/pkg/repo/account.go index a8cf37a4b78..ad7bcfdd7b8 100644 --- a/packages/eventindexer/pkg/repo/account.go +++ b/packages/eventindexer/pkg/repo/account.go @@ -2,6 +2,7 @@ package repo import ( "context" + "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" "strings" "time" @@ -12,16 +13,16 @@ import ( ) type AccountRepository struct { - db eventindexer.DB + db db.DB } -func NewAccountRepository(db eventindexer.DB) (*AccountRepository, error) { - if db == nil { - return nil, eventindexer.ErrNoDB +func NewAccountRepository(dbHandler db.DB) (*AccountRepository, error) { + if dbHandler == nil { + return nil, db.ErrNoDB } return &AccountRepository{ - db: db, + db: dbHandler, }, nil } @@ -33,7 +34,7 @@ func (r *AccountRepository) Save( // only insert if address doesn't exist a := &eventindexer.Account{} - if err := r.db.GormDB().Where("address = ?", address.Hex()).First(a).Error; err != nil { + if err := r.db.GormDB().WithContext(ctx).Where("address = ?", address.Hex()).First(a).Error; err != nil { if err != gorm.ErrRecordNotFound { return err } diff --git a/packages/eventindexer/pkg/repo/account_test.go b/packages/eventindexer/pkg/repo/account_test.go index 4f148562b89..c0c76f5f262 100644 --- a/packages/eventindexer/pkg/repo/account_test.go +++ b/packages/eventindexer/pkg/repo/account_test.go @@ -14,18 +14,18 @@ import ( func Test_NewAccountRepository(t *testing.T) { tests := []struct { name string - db eventindexer.DB + db db.DB wantErr error }{ { "success", - &db.DB{}, + &db.Database{}, nil, }, { "noDb", nil, - eventindexer.ErrNoDB, + db.ErrNoDB, }, } diff --git a/packages/eventindexer/pkg/repo/chart.go b/packages/eventindexer/pkg/repo/chart.go index 18b83610561..1dcb765aaa0 100644 --- a/packages/eventindexer/pkg/repo/chart.go +++ b/packages/eventindexer/pkg/repo/chart.go @@ -2,6 +2,7 @@ package repo import ( "context" + "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" "github.com/taikoxyz/taiko-mono/packages/eventindexer" "golang.org/x/exp/slog" @@ -9,21 +10,21 @@ import ( ) type ChartRepository struct { - db eventindexer.DB + db db.DB } -func NewChartRepository(db eventindexer.DB) (*ChartRepository, error) { - if db == nil { - return nil, eventindexer.ErrNoDB +func NewChartRepository(dbHandler db.DB) (*ChartRepository, error) { + if dbHandler == nil { + return nil, db.ErrNoDB } return &ChartRepository{ - db: db, + db: dbHandler, }, nil } -func (r *ChartRepository) getDB() *gorm.DB { - return r.db.GormDB().Table("time_series_data") +func (r *ChartRepository) getDB(ctx context.Context) *gorm.DB { + return r.db.GormDB().WithContext(ctx).Table("time_series_data") } func (r *ChartRepository) Find( @@ -42,7 +43,7 @@ func (r *ChartRepository) Find( WHERE task = ? AND date BETWEEN ? AND ? ORDER BY date;` - tx = r.getDB().Raw(q, task, start, end) + tx = r.getDB(ctx).Raw(q, task, start, end) if feeTokenAddress != "" { q = `SELECT * FROM time_series_data @@ -50,14 +51,14 @@ func (r *ChartRepository) Find( AND fee_token_address = ? ORDER BY date;` - tx = r.getDB().Raw(q, task, start, end, feeTokenAddress) + tx = r.getDB(ctx).Raw(q, task, start, end, feeTokenAddress) } else if tier != "" { q = `SELECT * FROM time_series_data WHERE task = ? AND date BETWEEN ? AND ? AND tier = ? ORDER BY date;` - tx = r.getDB().Raw(q, task, start, end, tier) + tx = r.getDB(ctx).Raw(q, task, start, end, tier) } var tsd []*eventindexer.TimeSeriesData diff --git a/packages/eventindexer/pkg/repo/chart_test.go b/packages/eventindexer/pkg/repo/chart_test.go index 77b820f0666..e10b29ebb8e 100644 --- a/packages/eventindexer/pkg/repo/chart_test.go +++ b/packages/eventindexer/pkg/repo/chart_test.go @@ -5,25 +5,25 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/taikoxyz/taiko-mono/packages/eventindexer" + "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" ) func Test_NewChartRepo(t *testing.T) { tests := []struct { name string - db eventindexer.DB + db db.DB wantErr error }{ { "success", - &db.DB{}, + &db.Database{}, nil, }, { "noDb", nil, - eventindexer.ErrNoDB, + db.ErrNoDB, }, } @@ -43,7 +43,7 @@ func Test_GetDB(t *testing.T) { chartRepo, err := NewChartRepository(db) assert.Equal(t, nil, err) - assert.NotNil(t, chartRepo.getDB()) + assert.NotNil(t, chartRepo.getDB(context.Background())) } func Test_Integration_FindChart(t *testing.T) { diff --git a/packages/eventindexer/pkg/repo/containers_test.go b/packages/eventindexer/pkg/repo/containers_test.go index d047a450ba2..616148e7eee 100644 --- a/packages/eventindexer/pkg/repo/containers_test.go +++ b/packages/eventindexer/pkg/repo/containers_test.go @@ -6,13 +6,13 @@ import ( "testing" "github.com/pressly/goose/v3" - "github.com/taikoxyz/taiko-mono/packages/eventindexer" - "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" "gorm.io/driver/mysql" "gorm.io/gorm" "gorm.io/gorm/logger" + + "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" ) var ( @@ -21,7 +21,7 @@ var ( dbPassword = "password" ) -func testMysql(t *testing.T) (eventindexer.DB, func(), error) { +func testMysql(t *testing.T) (db.DB, func(), error) { req := testcontainers.ContainerRequest{ Image: "mysql:8.0.33", ExposedPorts: []string{"3306/tcp", "33060/tcp"}, diff --git a/packages/eventindexer/pkg/repo/erc20_balance.go b/packages/eventindexer/pkg/repo/erc20_balance.go index 9bf52bfe330..7dae67175c1 100644 --- a/packages/eventindexer/pkg/repo/erc20_balance.go +++ b/packages/eventindexer/pkg/repo/erc20_balance.go @@ -2,6 +2,7 @@ package repo import ( "context" + "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" "math/big" "net/http" "strings" @@ -14,21 +15,20 @@ import ( ) type ERC20BalanceRepository struct { - db eventindexer.DB + db db.DB } -func NewERC20BalanceRepository(db eventindexer.DB) (*ERC20BalanceRepository, error) { - if db == nil { - return nil, eventindexer.ErrNoDB +func NewERC20BalanceRepository(dbHandler db.DB) (*ERC20BalanceRepository, error) { + if dbHandler == nil { + return nil, db.ErrNoDB } return &ERC20BalanceRepository{ - db: db, + db: dbHandler, }, nil } func (r *ERC20BalanceRepository) increaseBalanceInDB( - ctx context.Context, db *gorm.DB, opts eventindexer.UpdateERC20BalanceOpts, ) (*eventindexer.ERC20Balance, error) { @@ -68,7 +68,6 @@ func (r *ERC20BalanceRepository) increaseBalanceInDB( } func (r *ERC20BalanceRepository) decreaseBalanceInDB( - ctx context.Context, db *gorm.DB, opts eventindexer.UpdateERC20BalanceOpts, ) (*eventindexer.ERC20Balance, error) { @@ -123,13 +122,13 @@ func (r *ERC20BalanceRepository) IncreaseAndDecreaseBalancesInTx( retries := 10 for retries > 0 { err = r.db.GormDB().Transaction(func(tx *gorm.DB) (err error) { - increasedBalance, err = r.increaseBalanceInDB(ctx, tx, increaseOpts) + increasedBalance, err = r.increaseBalanceInDB(tx.WithContext(ctx), increaseOpts) if err != nil { return err } if decreaseOpts.Amount != "0" && decreaseOpts.Amount != "" { - decreasedBalance, err = r.decreaseBalanceInDB(ctx, tx, decreaseOpts) + decreasedBalance, err = r.decreaseBalanceInDB(tx.WithContext(ctx), decreaseOpts) } return err diff --git a/packages/eventindexer/pkg/repo/erc20_balance_test.go b/packages/eventindexer/pkg/repo/erc20_balance_test.go index e329c3366ae..dd07a8a95e2 100644 --- a/packages/eventindexer/pkg/repo/erc20_balance_test.go +++ b/packages/eventindexer/pkg/repo/erc20_balance_test.go @@ -13,18 +13,18 @@ import ( func Test_NewERC20BalanceRepo(t *testing.T) { tests := []struct { name string - db eventindexer.DB + db db.DB wantErr error }{ { "success", - &db.DB{}, + &db.Database{}, nil, }, { "noDb", nil, - eventindexer.ErrNoDB, + db.ErrNoDB, }, } diff --git a/packages/eventindexer/pkg/repo/event.go b/packages/eventindexer/pkg/repo/event.go index 3acbebddc07..13f37b82d4b 100644 --- a/packages/eventindexer/pkg/repo/event.go +++ b/packages/eventindexer/pkg/repo/event.go @@ -8,22 +8,24 @@ import ( "github.com/morkid/paginate" "github.com/pkg/errors" "github.com/shopspring/decimal" - "github.com/taikoxyz/taiko-mono/packages/eventindexer" "gorm.io/datatypes" "gorm.io/gorm" + + "github.com/taikoxyz/taiko-mono/packages/eventindexer" + "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" ) type EventRepository struct { - db eventindexer.DB + db db.DB } -func NewEventRepository(db eventindexer.DB) (*EventRepository, error) { - if db == nil { - return nil, eventindexer.ErrNoDB +func NewEventRepository(dbHandler db.DB) (*EventRepository, error) { + if dbHandler == nil { + return nil, db.ErrNoDB } return &EventRepository{ - db: db, + db: dbHandler, }, nil } @@ -111,7 +113,7 @@ func (r *EventRepository) Save(ctx context.Context, opts eventindexer.SaveEventO e.FeeTokenAddress = *opts.FeeTokenAddress } - if err := r.db.GormDB().Create(e).Error; err != nil { + if err := r.db.GormDB().WithContext(ctx).Create(e).Error; err != nil { return nil, errors.Wrap(err, "r.db.Create") } @@ -124,7 +126,7 @@ func (r *EventRepository) FindByEventTypeAndBlockID( blockID int64) (*eventindexer.Event, error) { e := &eventindexer.Event{} - if err := r.db.GormDB(). + if err := r.db.GormDB().WithContext(ctx). Where("event = ?", eventType). Where("block_id = ?", blockID).First(e).Error; err != nil { if err == gorm.ErrRecordNotFound { @@ -143,7 +145,7 @@ func (r *EventRepository) Delete( ) error { e := &eventindexer.Event{} - return r.db.GormDB().Delete(e, id).Error + return r.db.GormDB().WithContext(ctx).Delete(e, id).Error } func (r *EventRepository) FindUniqueProvers( @@ -151,7 +153,7 @@ func (r *EventRepository) FindUniqueProvers( ) ([]eventindexer.UniqueProversResponse, error) { addrs := make([]eventindexer.UniqueProversResponse, 0) - if err := r.db.GormDB(). + if err := r.db.GormDB().WithContext(ctx). Raw("SELECT address, count(*) AS count FROM events WHERE event = ? GROUP BY address", eventindexer.EventNameTransitionProved). FirstOrInit(&addrs).Error; err != nil { @@ -166,7 +168,7 @@ func (r *EventRepository) FindUniqueProposers( ) ([]eventindexer.UniqueProposersResponse, error) { addrs := make([]eventindexer.UniqueProposersResponse, 0) - if err := r.db.GormDB(). + if err := r.db.GormDB().WithContext(ctx). Raw("SELECT address, count(*) AS count FROM events WHERE event = ? GROUP BY address", eventindexer.EventNameBlockProposed). FirstOrInit(&addrs).Error; err != nil { @@ -183,7 +185,7 @@ func (r *EventRepository) GetCountByAddressAndEventName( ) (int, error) { var count int - if err := r.db.GormDB(). + if err := r.db.GormDB().WithContext(ctx). Raw("SELECT count(*) AS count FROM events WHERE event = ? AND address = ?", event, address). FirstOrInit(&count).Error; err != nil { return 0, errors.Wrap(err, "r.db.FirstOrInit") @@ -202,7 +204,7 @@ func (r *EventRepository) GetByAddressAndEventName( DefaultSize: 100, }) - q := r.db.GormDB(). + q := r.db.GormDB().WithContext(ctx). Raw("SELECT * FROM events WHERE event = ? AND address = ?", event, address) reqCtx := pg.With(q) @@ -219,7 +221,7 @@ func (r *EventRepository) FirstByAddressAndEventName( ) (*eventindexer.Event, error) { e := &eventindexer.Event{} - if err := r.db.GormDB(). + if err := r.db.GormDB().WithContext(ctx). Where("address = ?", address). Where("event = ?", event). First(e).Error; err != nil { @@ -242,7 +244,7 @@ func (r *EventRepository) GetAssignedBlocksByProverAddress( DefaultSize: 100, }) - q := r.db.GormDB(). + q := r.db.GormDB().WithContext(ctx). Raw("SELECT * FROM events WHERE event = ? AND assigned_prover = ?", eventindexer.EventNameBlockProposed, address) reqCtx := pg.With(q) @@ -253,24 +255,25 @@ func (r *EventRepository) GetAssignedBlocksByProverAddress( } // DeleteAllAfterBlockID is used when a reorg is detected -func (r *EventRepository) DeleteAllAfterBlockID(blockID uint64, srcChainID uint64) error { +func (r *EventRepository) DeleteAllAfterBlockID(ctx context.Context, blockID uint64, srcChainID uint64) error { query := ` DELETE FROM events WHERE block_id >= ? AND chain_id = ?` - return r.db.GormDB().Table("events").Exec(query, blockID, srcChainID).Error + return r.db.GormDB().WithContext(ctx).Table("events").Exec(query, blockID, srcChainID).Error } // GetLatestBlockID get latest block id func (r *EventRepository) FindLatestBlockID( + ctx context.Context, srcChainID uint64, ) (uint64, error) { - q := `SELECT COALESCE(MAX(emitted_block_id), 0) + q := `SELECT COALESCE(MAX(emitted_block_id), 0) FROM events WHERE chain_id = ?` var b uint64 - if err := r.db.GormDB().Table("events").Raw(q, srcChainID).Scan(&b).Error; err != nil { + if err := r.db.GormDB().WithContext(ctx).Table("events").Raw(q, srcChainID).Scan(&b).Error; err != nil { return 0, err } @@ -280,7 +283,7 @@ func (r *EventRepository) FindLatestBlockID( func (r *EventRepository) GetBlockProvenBy(ctx context.Context, blockID int) ([]*eventindexer.Event, error) { e := []*eventindexer.Event{} - if err := r.db.GormDB(). + if err := r.db.GormDB().WithContext(ctx). Where("block_id = ?", blockID). Where("event = ?", eventindexer.EventNameTransitionProved). Find(&e).Error; err != nil { @@ -293,7 +296,7 @@ func (r *EventRepository) GetBlockProvenBy(ctx context.Context, blockID int) ([] func (r *EventRepository) GetBlockProposedBy(ctx context.Context, blockID int) (*eventindexer.Event, error) { e := &eventindexer.Event{} - if err := r.db.GormDB(). + if err := r.db.GormDB().WithContext(ctx). Where("block_id = ?", blockID). Where("event = ?", eventindexer.EventNameBlockProposed). First(&e).Error; err != nil { diff --git a/packages/eventindexer/pkg/repo/interface.go b/packages/eventindexer/pkg/repo/interface.go new file mode 100644 index 00000000000..e0281bfd25d --- /dev/null +++ b/packages/eventindexer/pkg/repo/interface.go @@ -0,0 +1 @@ +package repo diff --git a/packages/eventindexer/pkg/repo/nft_balance.go b/packages/eventindexer/pkg/repo/nft_balance.go index d1bab45d5da..35e07bdd3c0 100644 --- a/packages/eventindexer/pkg/repo/nft_balance.go +++ b/packages/eventindexer/pkg/repo/nft_balance.go @@ -2,6 +2,7 @@ package repo import ( "context" + "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" "net/http" "strings" "time" @@ -13,16 +14,16 @@ import ( ) type NFTBalanceRepository struct { - db eventindexer.DB + db db.DB } -func NewNFTBalanceRepository(db eventindexer.DB) (*NFTBalanceRepository, error) { - if db == nil { - return nil, eventindexer.ErrNoDB +func NewNFTBalanceRepository(dbHandler db.DB) (*NFTBalanceRepository, error) { + if dbHandler == nil { + return nil, db.ErrNoDB } return &NFTBalanceRepository{ - db: db, + db: dbHandler, }, nil } diff --git a/packages/eventindexer/pkg/repo/nft_balance_test.go b/packages/eventindexer/pkg/repo/nft_balance_test.go index 650956a14f4..c713e6d4f36 100644 --- a/packages/eventindexer/pkg/repo/nft_balance_test.go +++ b/packages/eventindexer/pkg/repo/nft_balance_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/taikoxyz/taiko-mono/packages/eventindexer" "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" ) @@ -13,18 +14,18 @@ import ( func Test_NewNFTBalanceRepo(t *testing.T) { tests := []struct { name string - db eventindexer.DB + db db.DB wantErr error }{ { "success", - &db.DB{}, + &db.Database{}, nil, }, { "noDb", nil, - eventindexer.ErrNoDB, + db.ErrNoDB, }, } diff --git a/packages/eventindexer/pkg/repo/nft_metadata.go b/packages/eventindexer/pkg/repo/nft_metadata.go index 384d4d80db3..85168fe9c7c 100644 --- a/packages/eventindexer/pkg/repo/nft_metadata.go +++ b/packages/eventindexer/pkg/repo/nft_metadata.go @@ -6,21 +6,23 @@ import ( "github.com/morkid/paginate" "github.com/pkg/errors" - "github.com/taikoxyz/taiko-mono/packages/eventindexer" "gorm.io/gorm" + + "github.com/taikoxyz/taiko-mono/packages/eventindexer" + "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" ) type NFTMetadataRepository struct { - db eventindexer.DB + db db.DB } -func NewNFTMetadataRepository(db eventindexer.DB) (*NFTMetadataRepository, error) { - if db == nil { - return nil, eventindexer.ErrNoDB +func NewNFTMetadataRepository(dbHandler db.DB) (*NFTMetadataRepository, error) { + if dbHandler == nil { + return nil, db.ErrNoDB } return &NFTMetadataRepository{ - db: db, + db: dbHandler, }, nil } diff --git a/packages/eventindexer/pkg/repo/transaction.go b/packages/eventindexer/pkg/repo/transaction.go index 6e8f919ffca..edf0af8ce6f 100644 --- a/packages/eventindexer/pkg/repo/transaction.go +++ b/packages/eventindexer/pkg/repo/transaction.go @@ -10,7 +10,9 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/pkg/errors" "github.com/shopspring/decimal" + "github.com/taikoxyz/taiko-mono/packages/eventindexer" + "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" ) var ( @@ -18,16 +20,16 @@ var ( ) type TransactionRepository struct { - db eventindexer.DB + db db.DB } -func NewTransactionRepository(db eventindexer.DB) (*TransactionRepository, error) { - if db == nil { - return nil, eventindexer.ErrNoDB +func NewTransactionRepository(dbHandler db.DB) (*TransactionRepository, error) { + if dbHandler == nil { + return nil, db.ErrNoDB } return &TransactionRepository{ - db: db, + db: dbHandler, }, nil } diff --git a/packages/eventindexer/pkg/repo/transaction_test.go b/packages/eventindexer/pkg/repo/transaction_test.go index 8f761c5e60b..ff79909c5a0 100644 --- a/packages/eventindexer/pkg/repo/transaction_test.go +++ b/packages/eventindexer/pkg/repo/transaction_test.go @@ -9,25 +9,25 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/stretchr/testify/assert" - "github.com/taikoxyz/taiko-mono/packages/eventindexer" + "github.com/taikoxyz/taiko-mono/packages/eventindexer/pkg/db" ) func Test_NewTransactionRepo(t *testing.T) { tests := []struct { name string - db eventindexer.DB + db db.DB wantErr error }{ { "success", - &db.DB{}, + &db.Database{}, nil, }, { "noDb", nil, - eventindexer.ErrNoDB, + db.ErrNoDB, }, } diff --git a/packages/eventindexer/abigen.sh b/packages/eventindexer/scripts/abigen.sh similarity index 76% rename from packages/eventindexer/abigen.sh rename to packages/eventindexer/scripts/abigen.sh index 16c96eec86a..c49c3e49565 100755 --- a/packages/eventindexer/abigen.sh +++ b/packages/eventindexer/scripts/abigen.sh @@ -1,4 +1,4 @@ -#/bin/sh +#!/bin/sh if [ ! -d "../protocol/out" ]; then echo "ABI not generated in protocol package yet. Please run npm install && pnpm run compile in ../protocol" @@ -12,9 +12,9 @@ names=("TaikoL1" "Bridge" "SgxVerifier" "TaikoToken") for (( i = 0; i < ${#paths[@]}; ++i )); do - jq .abi ../protocol/out/${paths[i]}/${names[i]}.json > ${names[i]}.json lower=$(echo "${names[i]}" | tr '[:upper:]' '[:lower:]') - abigen --abi ${names[i]}.json \ + jq .abi ../protocol/out/${paths[i]}/${names[i]}.json > contracts/$lower/${names[i]}.json + abigen --abi contracts/$lower/${names[i]}.json \ --pkg $lower \ --type ${names[i]} \ --out contracts/$lower/${names[i]}.go