diff --git a/libs/metrics/src/l1/abis/bridgeHub.abi.ts b/libs/metrics/src/l1/abis/bridgeHub.abi.ts new file mode 100644 index 0000000..d26112e --- /dev/null +++ b/libs/metrics/src/l1/abis/bridgeHub.abi.ts @@ -0,0 +1,819 @@ +export const bridgeHubAbi = [ + { + inputs: [], + stateMutability: "nonpayable", + type: "constructor", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint8", + name: "version", + type: "uint8", + }, + ], + name: "Initialized", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "oldAdmin", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "newAdmin", + type: "address", + }, + ], + name: "NewAdmin", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: false, + internalType: "address", + name: "stateTransitionManager", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "chainGovernance", + type: "address", + }, + ], + name: "NewChain", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "oldPendingAdmin", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "newPendingAdmin", + type: "address", + }, + ], + name: "NewPendingAdmin", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "previousOwner", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "newOwner", + type: "address", + }, + ], + name: "OwnershipTransferStarted", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "previousOwner", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "newOwner", + type: "address", + }, + ], + name: "OwnershipTransferred", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "Paused", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "Unpaused", + type: "event", + }, + { + inputs: [], + name: "acceptAdmin", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "acceptOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_stateTransitionManager", + type: "address", + }, + ], + name: "addStateTransitionManager", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_token", + type: "address", + }, + ], + name: "addToken", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "admin", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + ], + name: "baseToken", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "address", + name: "_stateTransitionManager", + type: "address", + }, + { + internalType: "address", + name: "_baseToken", + type: "address", + }, + { + internalType: "uint256", + name: "_salt", + type: "uint256", + }, + { + internalType: "address", + name: "_admin", + type: "address", + }, + { + internalType: "bytes", + name: "_initData", + type: "bytes", + }, + ], + name: "createNewChain", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + ], + name: "getHyperchain", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_owner", + type: "address", + }, + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "uint256", + name: "_gasPrice", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2GasLimit", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2GasPerPubdataByteLimit", + type: "uint256", + }, + ], + name: "l2TransactionBaseCost", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "pause", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "paused", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "pendingOwner", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "bytes32", + name: "_l2TxHash", + type: "bytes32", + }, + { + internalType: "uint256", + name: "_l2BatchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2MessageIndex", + type: "uint256", + }, + { + internalType: "uint16", + name: "_l2TxNumberInBatch", + type: "uint16", + }, + { + internalType: "bytes32[]", + name: "_merkleProof", + type: "bytes32[]", + }, + { + internalType: "enum TxStatus", + name: "_status", + type: "uint8", + }, + ], + name: "proveL1ToL2TransactionStatus", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "uint256", + name: "_batchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_index", + type: "uint256", + }, + { + components: [ + { + internalType: "uint8", + name: "l2ShardId", + type: "uint8", + }, + { + internalType: "bool", + name: "isService", + type: "bool", + }, + { + internalType: "uint16", + name: "txNumberInBatch", + type: "uint16", + }, + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "bytes32", + name: "key", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "value", + type: "bytes32", + }, + ], + internalType: "struct L2Log", + name: "_log", + type: "tuple", + }, + { + internalType: "bytes32[]", + name: "_proof", + type: "bytes32[]", + }, + ], + name: "proveL2LogInclusion", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "uint256", + name: "_batchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_index", + type: "uint256", + }, + { + components: [ + { + internalType: "uint16", + name: "txNumberInBatch", + type: "uint16", + }, + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "bytes", + name: "data", + type: "bytes", + }, + ], + internalType: "struct L2Message", + name: "_message", + type: "tuple", + }, + { + internalType: "bytes32[]", + name: "_proof", + type: "bytes32[]", + }, + ], + name: "proveL2MessageInclusion", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_stateTransitionManager", + type: "address", + }, + ], + name: "removeStateTransitionManager", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + components: [ + { + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + internalType: "uint256", + name: "mintValue", + type: "uint256", + }, + { + internalType: "address", + name: "l2Contract", + type: "address", + }, + { + internalType: "uint256", + name: "l2Value", + type: "uint256", + }, + { + internalType: "bytes", + name: "l2Calldata", + type: "bytes", + }, + { + internalType: "uint256", + name: "l2GasLimit", + type: "uint256", + }, + { + internalType: "uint256", + name: "l2GasPerPubdataByteLimit", + type: "uint256", + }, + { + internalType: "bytes[]", + name: "factoryDeps", + type: "bytes[]", + }, + { + internalType: "address", + name: "refundRecipient", + type: "address", + }, + ], + internalType: "struct L2TransactionRequestDirect", + name: "_request", + type: "tuple", + }, + ], + name: "requestL2TransactionDirect", + outputs: [ + { + internalType: "bytes32", + name: "canonicalTxHash", + type: "bytes32", + }, + ], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + components: [ + { + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + internalType: "uint256", + name: "mintValue", + type: "uint256", + }, + { + internalType: "uint256", + name: "l2Value", + type: "uint256", + }, + { + internalType: "uint256", + name: "l2GasLimit", + type: "uint256", + }, + { + internalType: "uint256", + name: "l2GasPerPubdataByteLimit", + type: "uint256", + }, + { + internalType: "address", + name: "refundRecipient", + type: "address", + }, + { + internalType: "address", + name: "secondBridgeAddress", + type: "address", + }, + { + internalType: "uint256", + name: "secondBridgeValue", + type: "uint256", + }, + { + internalType: "bytes", + name: "secondBridgeCalldata", + type: "bytes", + }, + ], + internalType: "struct L2TransactionRequestTwoBridgesOuter", + name: "_request", + type: "tuple", + }, + ], + name: "requestL2TransactionTwoBridges", + outputs: [ + { + internalType: "bytes32", + name: "canonicalTxHash", + type: "bytes32", + }, + ], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_newPendingAdmin", + type: "address", + }, + ], + name: "setPendingAdmin", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_sharedBridge", + type: "address", + }, + ], + name: "setSharedBridge", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "sharedBridge", + outputs: [ + { + internalType: "contract IL1SharedBridge", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + ], + name: "stateTransitionManager", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_stateTransitionManager", + type: "address", + }, + ], + name: "stateTransitionManagerIsRegistered", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_token", + type: "address", + }, + ], + name: "tokenIsRegistered", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "newOwner", + type: "address", + }, + ], + name: "transferOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "unpause", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, +] as const; diff --git a/libs/metrics/src/l1/abis/diamondProxy.abi.ts b/libs/metrics/src/l1/abis/diamondProxy.abi.ts new file mode 100644 index 0000000..2a5a8e5 --- /dev/null +++ b/libs/metrics/src/l1/abis/diamondProxy.abi.ts @@ -0,0 +1,663 @@ +export const diamondProxyAbi = [ + { + inputs: [], + name: "baseTokenGasPriceMultiplierDenominator", + outputs: [ + { + internalType: "uint128", + name: "", + type: "uint128", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "baseTokenGasPriceMultiplierNominator", + outputs: [ + { + internalType: "uint128", + name: "", + type: "uint128", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes4", + name: "_selector", + type: "bytes4", + }, + ], + name: "facetAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "facetAddresses", + outputs: [ + { + internalType: "address[]", + name: "", + type: "address[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_facet", + type: "address", + }, + ], + name: "facetFunctionSelectors", + outputs: [ + { + internalType: "bytes4[]", + name: "", + type: "bytes4[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "facets", + outputs: [ + { + components: [ + { + internalType: "address", + name: "addr", + type: "address", + }, + { + internalType: "bytes4[]", + name: "selectors", + type: "bytes4[]", + }, + ], + internalType: "struct IGetters.Facet[]", + name: "result", + type: "tuple[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getAdmin", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getBaseToken", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getBaseTokenBridge", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getBridgehub", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getFirstUnprocessedPriorityTx", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getL2BootloaderBytecodeHash", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getL2DefaultAccountBytecodeHash", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getL2SystemContractsUpgradeBatchNumber", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getL2SystemContractsUpgradeBlockNumber", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getL2SystemContractsUpgradeTxHash", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getName", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getPendingAdmin", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getPriorityQueueSize", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getPriorityTxMaxGasLimit", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getProtocolVersion", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getPubdataPricingMode", + outputs: [ + { + internalType: "enum PubdataPricingMode", + name: "", + type: "uint8", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getSemverProtocolVersion", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32", + }, + { + internalType: "uint32", + name: "", + type: "uint32", + }, + { + internalType: "uint32", + name: "", + type: "uint32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getStateTransitionManager", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getTotalBatchesCommitted", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getTotalBatchesExecuted", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getTotalBatchesVerified", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getTotalBlocksCommitted", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getTotalBlocksExecuted", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getTotalBlocksVerified", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getTotalPriorityTxs", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getVerifier", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getVerifierParams", + outputs: [ + { + components: [ + { + internalType: "bytes32", + name: "recursionNodeLevelVkHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "recursionLeafLevelVkHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "recursionCircuitsSetVksHash", + type: "bytes32", + }, + ], + internalType: "struct VerifierParams", + name: "", + type: "tuple", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "isDiamondStorageFrozen", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_l2BatchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2MessageIndex", + type: "uint256", + }, + ], + name: "isEthWithdrawalFinalized", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_facet", + type: "address", + }, + ], + name: "isFacetFreezable", + outputs: [ + { + internalType: "bool", + name: "isFreezable", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes4", + name: "_selector", + type: "bytes4", + }, + ], + name: "isFunctionFreezable", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_address", + type: "address", + }, + ], + name: "isValidator", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_batchNumber", + type: "uint256", + }, + ], + name: "l2LogsRootHash", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "priorityQueueFrontOperation", + outputs: [ + { + components: [ + { + internalType: "bytes32", + name: "canonicalTxHash", + type: "bytes32", + }, + { + internalType: "uint64", + name: "expirationTimestamp", + type: "uint64", + }, + { + internalType: "uint192", + name: "layer2Tip", + type: "uint192", + }, + ], + internalType: "struct PriorityOperation", + name: "", + type: "tuple", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_batchNumber", + type: "uint256", + }, + ], + name: "storedBatchHash", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_batchNumber", + type: "uint256", + }, + ], + name: "storedBlockHash", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const; diff --git a/libs/metrics/src/l1/abis/index.ts b/libs/metrics/src/l1/abis/index.ts new file mode 100644 index 0000000..a8c48ff --- /dev/null +++ b/libs/metrics/src/l1/abis/index.ts @@ -0,0 +1,3 @@ +export * from "./bridgeHub.abi"; +export * from "./diamondProxy.abi"; +export * from "./sharedBridge.abi"; diff --git a/libs/metrics/src/l1/abis/sharedBridge.abi.ts b/libs/metrics/src/l1/abis/sharedBridge.abi.ts new file mode 100644 index 0000000..30114f5 --- /dev/null +++ b/libs/metrics/src/l1/abis/sharedBridge.abi.ts @@ -0,0 +1,1051 @@ +export const sharedBridgeAbi = [ + { + inputs: [ + { + internalType: "address", + name: "_l1WethAddress", + type: "address", + }, + { + internalType: "contract IBridgehub", + name: "_bridgehub", + type: "address", + }, + { + internalType: "uint256", + name: "_eraChainId", + type: "uint256", + }, + { + internalType: "address", + name: "_eraDiamondProxy", + type: "address", + }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: true, + internalType: "address", + name: "from", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "l1Token", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "BridgehubDepositBaseTokenInitiated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: true, + internalType: "bytes32", + name: "txDataHash", + type: "bytes32", + }, + { + indexed: true, + internalType: "bytes32", + name: "l2DepositTxHash", + type: "bytes32", + }, + ], + name: "BridgehubDepositFinalized", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: true, + internalType: "bytes32", + name: "txDataHash", + type: "bytes32", + }, + { + indexed: true, + internalType: "address", + name: "from", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "l1Token", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "BridgehubDepositInitiated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "l1Token", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "ClaimedFailedDepositSharedBridge", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint8", + name: "version", + type: "uint8", + }, + ], + name: "Initialized", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: true, + internalType: "bytes32", + name: "l2DepositTxHash", + type: "bytes32", + }, + { + indexed: true, + internalType: "address", + name: "from", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "l1Token", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "LegacyDepositInitiated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "previousOwner", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "newOwner", + type: "address", + }, + ], + name: "OwnershipTransferStarted", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "previousOwner", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "newOwner", + type: "address", + }, + ], + name: "OwnershipTransferred", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "Paused", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "Unpaused", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "l1Token", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "WithdrawalFinalizedSharedBridge", + type: "event", + }, + { + inputs: [], + name: "BRIDGE_HUB", + outputs: [ + { + internalType: "contract IBridgehub", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "ERA_CHAIN_ID", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "ERA_DIAMOND_PROXY", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "L1_WETH_TOKEN", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "acceptOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "bytes32", + name: "_txDataHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "_txHash", + type: "bytes32", + }, + ], + name: "bridgehubConfirmL2Transaction", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "address", + name: "_prevMsgSender", + type: "address", + }, + { + internalType: "uint256", + name: "_l2Value", + type: "uint256", + }, + { + internalType: "bytes", + name: "_data", + type: "bytes", + }, + ], + name: "bridgehubDeposit", + outputs: [ + { + components: [ + { + internalType: "bytes32", + name: "magicValue", + type: "bytes32", + }, + { + internalType: "address", + name: "l2Contract", + type: "address", + }, + { + internalType: "bytes", + name: "l2Calldata", + type: "bytes", + }, + { + internalType: "bytes[]", + name: "factoryDeps", + type: "bytes[]", + }, + { + internalType: "bytes32", + name: "txDataHash", + type: "bytes32", + }, + ], + internalType: "struct L2TransactionRequestTwoBridgesInner", + name: "request", + type: "tuple", + }, + ], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "address", + name: "_prevMsgSender", + type: "address", + }, + { + internalType: "address", + name: "_l1Token", + type: "address", + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, + ], + name: "bridgehubDepositBaseToken", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + internalType: "address", + name: "l1Token", + type: "address", + }, + ], + name: "chainBalance", + outputs: [ + { + internalType: "uint256", + name: "balance", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "address", + name: "_depositSender", + type: "address", + }, + { + internalType: "address", + name: "_l1Token", + type: "address", + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, + { + internalType: "bytes32", + name: "_l2TxHash", + type: "bytes32", + }, + { + internalType: "uint256", + name: "_l2BatchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2MessageIndex", + type: "uint256", + }, + { + internalType: "uint16", + name: "_l2TxNumberInBatch", + type: "uint16", + }, + { + internalType: "bytes32[]", + name: "_merkleProof", + type: "bytes32[]", + }, + ], + name: "claimFailedDeposit", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_depositSender", + type: "address", + }, + { + internalType: "address", + name: "_l1Token", + type: "address", + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, + { + internalType: "bytes32", + name: "_l2TxHash", + type: "bytes32", + }, + { + internalType: "uint256", + name: "_l2BatchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2MessageIndex", + type: "uint256", + }, + { + internalType: "uint16", + name: "_l2TxNumberInBatch", + type: "uint16", + }, + { + internalType: "bytes32[]", + name: "_merkleProof", + type: "bytes32[]", + }, + ], + name: "claimFailedDepositLegacyErc20Bridge", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + internalType: "bytes32", + name: "l2DepositTxHash", + type: "bytes32", + }, + ], + name: "depositHappened", + outputs: [ + { + internalType: "bytes32", + name: "depositDataHash", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_prevMsgSender", + type: "address", + }, + { + internalType: "address", + name: "_l2Receiver", + type: "address", + }, + { + internalType: "address", + name: "_l1Token", + type: "address", + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2TxGasLimit", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2TxGasPerPubdataByte", + type: "uint256", + }, + { + internalType: "address", + name: "_refundRecipient", + type: "address", + }, + ], + name: "depositLegacyErc20Bridge", + outputs: [ + { + internalType: "bytes32", + name: "l2TxHash", + type: "bytes32", + }, + ], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2BatchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2MessageIndex", + type: "uint256", + }, + { + internalType: "uint16", + name: "_l2TxNumberInBatch", + type: "uint16", + }, + { + internalType: "bytes", + name: "_message", + type: "bytes", + }, + { + internalType: "bytes32[]", + name: "_merkleProof", + type: "bytes32[]", + }, + ], + name: "finalizeWithdrawal", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_l2BatchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2MessageIndex", + type: "uint256", + }, + { + internalType: "uint16", + name: "_l2TxNumberInBatch", + type: "uint16", + }, + { + internalType: "bytes", + name: "_message", + type: "bytes", + }, + { + internalType: "bytes32[]", + name: "_merkleProof", + type: "bytes32[]", + }, + ], + name: "finalizeWithdrawalLegacyErc20Bridge", + outputs: [ + { + internalType: "address", + name: "l1Receiver", + type: "address", + }, + { + internalType: "address", + name: "l1Token", + type: "address", + }, + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_owner", + type: "address", + }, + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "address", + name: "_l2BridgeAddress", + type: "address", + }, + ], + name: "initializeChainGovernance", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + internalType: "uint256", + name: "l2BatchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "l2ToL1MessageNumber", + type: "uint256", + }, + ], + name: "isWithdrawalFinalized", + outputs: [ + { + internalType: "bool", + name: "isFinalized", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + ], + name: "l2BridgeAddress", + outputs: [ + { + internalType: "address", + name: "l2Bridge", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "legacyBridge", + outputs: [ + { + internalType: "contract IL1ERC20Bridge", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "pause", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "paused", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "pendingOwner", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + ], + name: "receiveEth", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_token", + type: "address", + }, + { + internalType: "address", + name: "_target", + type: "address", + }, + { + internalType: "uint256", + name: "_targetChainId", + type: "uint256", + }, + { + internalType: "uint256", + name: "_gasPerToken", + type: "uint256", + }, + ], + name: "safeTransferFundsFromLegacy", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_eraLegacyBridgeLastDepositBatch", + type: "uint256", + }, + { + internalType: "uint256", + name: "_eraLegacyBridgeLastDepositTxNumber", + type: "uint256", + }, + ], + name: "setEraLegacyBridgeLastDepositTime", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_eraPostDiamondUpgradeFirstBatch", + type: "uint256", + }, + ], + name: "setEraPostDiamondUpgradeFirstBatch", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_eraPostLegacyBridgeUpgradeFirstBatch", + type: "uint256", + }, + ], + name: "setEraPostLegacyBridgeUpgradeFirstBatch", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_legacyBridge", + type: "address", + }, + ], + name: "setL1Erc20Bridge", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_token", + type: "address", + }, + { + internalType: "address", + name: "_target", + type: "address", + }, + { + internalType: "uint256", + name: "_targetChainId", + type: "uint256", + }, + ], + name: "transferFundsFromLegacy", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "newOwner", + type: "address", + }, + ], + name: "transferOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "unpause", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, +] as const; diff --git a/libs/metrics/src/l1/l1MetricsService.spec.ts b/libs/metrics/src/l1/l1MetricsService.spec.ts new file mode 100644 index 0000000..1d42209 --- /dev/null +++ b/libs/metrics/src/l1/l1MetricsService.spec.ts @@ -0,0 +1,128 @@ +import { Logger } from "@nestjs/common"; +import { Test, TestingModule } from "@nestjs/testing"; +import { WINSTON_MODULE_PROVIDER } from "nest-winston"; + +import { bridgeHubAbi, sharedBridgeAbi } from "@zkchainhub/metrics/l1/abis"; +import { IPricingService, PRICING_PROVIDER } from "@zkchainhub/pricing"; +import { EvmProviderService } from "@zkchainhub/providers"; +import { L1_CONTRACTS } from "@zkchainhub/shared"; + +import { L1MetricsService } from "./l1MetricsService"; + +// Mock implementations of the dependencies +const mockEvmProviderService = { + // Mock methods and properties as needed +}; + +const mockPricingService = { + // Mock methods and properties as needed +}; + +export const mockLogger: Partial = { + log: jest.fn(), + warn: jest.fn(), + error: jest.fn(), + debug: jest.fn(), +}; + +describe("L1MetricsService", () => { + let l1MetricsService: L1MetricsService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [ + L1MetricsService, + { + provide: L1MetricsService, + useFactory: ( + evmProviderService: EvmProviderService, + pricingService: IPricingService, + logger: Logger, + ) => { + return new L1MetricsService(evmProviderService, pricingService, logger); + }, + inject: [EvmProviderService, PRICING_PROVIDER, WINSTON_MODULE_PROVIDER], + }, + { + provide: EvmProviderService, + useValue: mockEvmProviderService, + }, + { + provide: PRICING_PROVIDER, + useValue: mockPricingService, + }, + { + provide: WINSTON_MODULE_PROVIDER, + useValue: mockLogger, + }, + ], + }).compile(); + + l1MetricsService = module.get(L1MetricsService); + }); + + describe("constructor", () => { + it("initialize bridgeHub and sharedBridge", () => { + expect(l1MetricsService["bridgeHub"]).toEqual({ + abi: bridgeHubAbi, + address: L1_CONTRACTS.BRIDGE_HUB, + }); + expect(l1MetricsService["sharedBridge"]).toEqual({ + abi: sharedBridgeAbi, + address: L1_CONTRACTS.SHARED_BRIDGE, + }); + }); + + it("initialize diamondContracts map as empty", () => { + expect(l1MetricsService["diamondContracts"].size).toBe(0); + }); + }); + + describe("l1Tvl", () => { + it("return l1Tvl", async () => { + const result = await l1MetricsService.l1Tvl(); + expect(result).toEqual({ ETH: { amount: 1000000, amountUsd: 1000000 } }); + }); + }); + + describe("getBatchesInfo", () => { + it("return getBatchesInfo", async () => { + const result = await l1MetricsService.getBatchesInfo(1); + expect(result).toEqual({ commited: 100, verified: 100, proved: 100 }); + }); + }); + + describe("tvl", () => { + it("return tvl", async () => { + const result = await l1MetricsService.tvl(1); + expect(result).toEqual({ ETH: { amount: 1000000, amountUsd: 1000000 } }); + }); + }); + + describe("chainType", () => { + it("return chainType", async () => { + const result = await l1MetricsService.chainType(1); + expect(result).toBe("rollup"); + }); + }); + + describe("ethGasInfo", () => { + it("return ethGasInfo", async () => { + const result = await l1MetricsService.ethGasInfo(); + expect(result).toEqual({ gasPrice: 50, ethTransfer: 21000, erc20Transfer: 65000 }); + }); + }); + + describe("feeParams", () => { + it("return feeParams", async () => { + const result = await l1MetricsService.feeParams(1); + expect(result).toEqual({ + batchOverheadL1Gas: 50000, + maxPubdataPerBatch: 120000, + maxL2GasPerBatch: 10000000, + priorityTxMaxPubdata: 15000, + minimalL2GasPrice: 10000000, + }); + }); + }); +}); diff --git a/libs/metrics/src/l1/l1MetricsService.ts b/libs/metrics/src/l1/l1MetricsService.ts index 5d589ad..346ebf5 100644 --- a/libs/metrics/src/l1/l1MetricsService.ts +++ b/libs/metrics/src/l1/l1MetricsService.ts @@ -1,11 +1,70 @@ -import { Injectable } from "@nestjs/common"; +import { Inject, Injectable, LoggerService } from "@nestjs/common"; +import { WINSTON_MODULE_NEST_PROVIDER } from "nest-winston"; +import { bridgeHubAbi, sharedBridgeAbi } from "@zkchainhub/metrics/l1/abis"; +import { IPricingService, PRICING_PROVIDER } from "@zkchainhub/pricing"; import { EvmProviderService } from "@zkchainhub/providers"; +import { AbiWithAddress, ChainId, L1_CONTRACTS } from "@zkchainhub/shared"; /** * Acts as a wrapper around Viem library to provide methods to interact with an EVM-based blockchain. */ @Injectable() export class L1MetricsService { - constructor(private readonly evmProviderService: EvmProviderService) {} + private readonly bridgeHub: Readonly = { + abi: bridgeHubAbi, + address: L1_CONTRACTS.BRIDGE_HUB, + }; + private readonly sharedBridge: Readonly = { + abi: sharedBridgeAbi, + address: L1_CONTRACTS.SHARED_BRIDGE, + }; + private readonly diamondContracts: Map = new Map(); + + constructor( + private readonly evmProviderService: EvmProviderService, + @Inject(PRICING_PROVIDER) private readonly pricingService: IPricingService, + @Inject(WINSTON_MODULE_NEST_PROVIDER) private readonly logger: LoggerService, + ) {} + + //TODO: Implement l1Tvl. + async l1Tvl(): Promise<{ [asset: string]: { amount: number; amountUsd: number } }> { + return { ETH: { amount: 1000000, amountUsd: 1000000 } }; + } + //TODO: Implement getBatchesInfo. + async getBatchesInfo( + _chainId: number, + ): Promise<{ commited: number; verified: number; proved: number }> { + return { commited: 100, verified: 100, proved: 100 }; + } + //TODO: Implement tvl. + async tvl( + _chainId: number, + ): Promise<{ [asset: string]: { amount: number; amountUsd: number } }> { + return { ETH: { amount: 1000000, amountUsd: 1000000 } }; + } + //TODO: Implement chainType. + async chainType(_chainId: number): Promise<"validium" | "rollup"> { + return "rollup"; + } + //TODO: Implement ethGasInfo. + async ethGasInfo(): Promise<{ gasPrice: number; ethTransfer: number; erc20Transfer: number }> { + return { gasPrice: 50, ethTransfer: 21000, erc20Transfer: 65000 }; + } + //TODO: Implement feeParams. + async feeParams(_chainId: number): Promise<{ + batchOverheadL1Gas: number; + maxPubdataPerBatch: number; + maxL2GasPerBatch: number; + priorityTxMaxPubdata: number; + minimalL2GasPrice: number; + }> { + return { + batchOverheadL1Gas: 50000, + maxPubdataPerBatch: 120000, + maxL2GasPerBatch: 10000000, + priorityTxMaxPubdata: 15000, + minimalL2GasPrice: 10000000, + }; + } } diff --git a/libs/metrics/src/metrics.module.ts b/libs/metrics/src/metrics.module.ts index bd39e3b..4a793d6 100644 --- a/libs/metrics/src/metrics.module.ts +++ b/libs/metrics/src/metrics.module.ts @@ -1,6 +1,8 @@ import { Module } from "@nestjs/common"; +import { CoingeckoService, PRICING_PROVIDER, PricingModule } from "@zkchainhub/pricing"; import { ProvidersModule } from "@zkchainhub/providers"; +import { LoggerModule } from "@zkchainhub/shared"; import { L1MetricsService } from "./l1"; @@ -9,8 +11,14 @@ import { L1MetricsService } from "./l1"; * This module exports Services for interacting with EVM-based blockchains. */ @Module({ - imports: [ProvidersModule], - providers: [L1MetricsService], + imports: [LoggerModule, ProvidersModule, PricingModule], + providers: [ + L1MetricsService, + { + provide: PRICING_PROVIDER, + useClass: CoingeckoService, + }, + ], exports: [L1MetricsService], }) export class MetricsModule {} diff --git a/libs/pricing/src/interfaces/pricing.interface.ts b/libs/pricing/src/interfaces/pricing.interface.ts index 052fc32..cba5e5c 100644 --- a/libs/pricing/src/interfaces/pricing.interface.ts +++ b/libs/pricing/src/interfaces/pricing.interface.ts @@ -1,6 +1,7 @@ /** - * Represents a pricing service that provides token prices. + * Represents the symbol used to inject the pricing service interface. */ +export const PRICING_PROVIDER = Symbol("IPricingService"); /** * Represents a pricing service that retrieves token prices. */ diff --git a/libs/shared/src/constants/index.ts b/libs/shared/src/constants/index.ts index bdeb317..9962fbe 100644 --- a/libs/shared/src/constants/index.ts +++ b/libs/shared/src/constants/index.ts @@ -1,2 +1,3 @@ +export * from "./l1"; export const TOKEN_CACHE_TTL_IN_SEC = 60; export const BASE_CURRENCY = "usd"; diff --git a/libs/shared/src/constants/l1.ts b/libs/shared/src/constants/l1.ts new file mode 100644 index 0000000..b1edade --- /dev/null +++ b/libs/shared/src/constants/l1.ts @@ -0,0 +1,5 @@ +export const L1_CONTRACTS = { + BRIDGE_HUB: "0x303a465B659cBB0ab36eE643eA362c509EEb5213", + DIAMOND_PROXY: "0x32400084C286CF3E17e7B677ea9583e60a000324", + SHARED_BRIDGE: "0xD7f9f54194C633F36CCD5F3da84ad4a1c38cB2cB", +} as const; diff --git a/libs/shared/src/types/index.ts b/libs/shared/src/types/index.ts index 642a22c..1540e93 100644 --- a/libs/shared/src/types/index.ts +++ b/libs/shared/src/types/index.ts @@ -1 +1,2 @@ export * from "./rollup.type"; +export * from "./utils.type"; diff --git a/libs/shared/src/types/utils.type.ts b/libs/shared/src/types/utils.type.ts index 124165c..8489ff4 100644 --- a/libs/shared/src/types/utils.type.ts +++ b/libs/shared/src/types/utils.type.ts @@ -1,3 +1,5 @@ import { Abi, Address } from "abitype"; export type AbiWithAddress = { abi: Abi; address: Address }; + +export type ChainId = number;