|
| 1 | +""" |
| 2 | +Provides mock responses for L1 RPC calls. |
| 3 | +""" |
| 4 | + |
| 5 | +import json |
| 6 | +from typing import Any |
| 7 | + |
| 8 | + |
| 9 | +class L1Manager: |
| 10 | + def set_new_tx(self, feeder_gateway_tx: dict, block_timestamp: int) -> None: |
| 11 | + """ |
| 12 | + Gets a feeder gateway transaction, and its block timestamp and updates the cache with info retrieved from L1. |
| 13 | + """ |
| 14 | + |
| 15 | + def get_logs(self, filter: Any) -> str: |
| 16 | + """ |
| 17 | + Returns raw logs response from Alchemy. |
| 18 | + """ |
| 19 | + return json.dumps( |
| 20 | + { |
| 21 | + "jsonrpc": "2.0", |
| 22 | + "id": "1", |
| 23 | + "result": [ |
| 24 | + { |
| 25 | + "address": "0xc662c410c0ecf747543f5ba90660f6abebd9c8c4", |
| 26 | + "topics": [ |
| 27 | + "0xdb80dd488acf86d17c747445b0eabb5d57c541d3bd7b6b87af987858e5066b2b", |
| 28 | + "0x000000000000000000000000f5b6ee2caeb6769659f6c091d209dfdcaf3f69eb", |
| 29 | + "0x0616757a151c21f9be8775098d591c2807316d992bbc3bb1a5c1821630589256", |
| 30 | + "0x01b64b1b3b690b43b9b514fb81377518f4039cd3e4f4914d8a6bdf01d679fb19", |
| 31 | + ], |
| 32 | + "data": "0x0000000000000000000000000000000000000000000000000000000000000060" |
| 33 | + "000000000000000000000000000000000000000000000000000000000019b255" |
| 34 | + "00000000000000000000000000000000000000000000000000001308aba4ade2" |
| 35 | + "0000000000000000000000000000000000000000000000000000000000000005" |
| 36 | + "00000000000000000000000004c46e830bb56ce22735d5d8fc9cb90309317d0f" |
| 37 | + "000000000000000000000000c50a951c4426760ba75c5253985a16196b342168" |
| 38 | + "011bf9dbebdd770c31ff13808c96a1cb2de15a240274dc527e7d809bb2bf38df" |
| 39 | + "0000000000000000000000000000000000000000000000956dfdeac59085edc3" |
| 40 | + "0000000000000000000000000000000000000000000000000000000000000000", |
| 41 | + "blockHash": "0xb33512d13e1a2ff4f3aa6e799a4a2455249be5198760a3f41300a8362d802bf8", |
| 42 | + "blockNumber": "0x16cda82", |
| 43 | + "blockTimestamp": "0x692c23df", |
| 44 | + "transactionHash": "0x726df509fdd23a944f923a6fc18e80cbe7300a54aa34f8e6bd77e9961ca6ce52", |
| 45 | + "transactionIndex": "0x4f", |
| 46 | + "logIndex": "0x7b", |
| 47 | + "removed": False, |
| 48 | + } |
| 49 | + ], |
| 50 | + } |
| 51 | + ) |
| 52 | + |
| 53 | + def get_block_by_number(self, block_number: int) -> str: |
| 54 | + """ |
| 55 | + Returns raw block response from Alchemy. |
| 56 | + """ |
| 57 | + return json.dumps( |
| 58 | + { |
| 59 | + "jsonrpc": "2.0", |
| 60 | + "id": "1", |
| 61 | + "result": { |
| 62 | + "number": "0x68b3", |
| 63 | + "hash": "0xd5f1812548be429cbdc6376b29611fc49e06f1359758c4ceaaa3b393e2239f9c", |
| 64 | + "mixHash": "0x24900fb3da77674a861c428429dce0762707ecb6052325bbd9b3c64e74b5af9d", |
| 65 | + "parentHash": "0x1f68ac259155e2f38211ddad0f0a15394d55417b185a93923e2abe71bb7a4d6d", |
| 66 | + "nonce": "0x378da40ff335b070", |
| 67 | + "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", |
| 68 | + "logsBloom": "0x00000000000000100000004080000000000500000000000000020000100000000800001000000004000001000000000000000800040010000020100000000400000010000000000000000040000000000000040000000000000000000000000000000400002400000000000000000000000000000004000004000000000000840000000800000080010004000000001000000800000000000000000000000000000000000800000000000040000000020000000000000000000800000400000000000000000000000600000400000000002000000000000000000000004000000000000000100000000000000000000000000000000000040000900010000000", |
| 69 | + "transactionsRoot": "0x4d0c8e91e16bdff538c03211c5c73632ed054d00a7e210c0eb25146c20048126", |
| 70 | + "stateRoot": "0x91309efa7e42c1f137f31fe9edbe88ae087e6620d0d59031324da3e2f4f93233", |
| 71 | + "receiptsRoot": "0x68461ab700003503a305083630a8fb8d14927238f0bc8b6b3d246c0c64f21f4a", |
| 72 | + "miner": "0xb42b6c4a95406c78ff892d270ad20b22642e102d", |
| 73 | + "difficulty": "0x66e619a", |
| 74 | + "totalDifficulty": "0x1e875d746ae", |
| 75 | + "extraData": "0xd583010502846765746885676f312e37856c696e7578", |
| 76 | + "size": "0x334", |
| 77 | + "gasLimit": "0x47e7c4", |
| 78 | + "gasUsed": "0x37993", |
| 79 | + "timestamp": "0x5835c54d", |
| 80 | + "uncles": [], |
| 81 | + "transactions": [ |
| 82 | + "0xa0807e117a8dd124ab949f460f08c36c72b710188f01609595223b325e58e0fc", |
| 83 | + "0xeae6d797af50cb62a596ec3939114d63967c374fa57de9bc0f4e2b576ed6639d", |
| 84 | + ], |
| 85 | + "baseFeePerGas": "0x7", |
| 86 | + "withdrawalsRoot": "0x7a4ecf19774d15cf9c15adf0dd8e8a250c128b26c9e2ab2a08d6c9c8ffbd104f", |
| 87 | + "withdrawals": [ |
| 88 | + { |
| 89 | + "index": "0x0", |
| 90 | + "validatorIndex": "0x9d8c0", |
| 91 | + "address": "0xb9d7934878b5fb9610b3fe8a5e441e8fad7e293f", |
| 92 | + "amount": "0x11a33e3760", |
| 93 | + } |
| 94 | + ], |
| 95 | + "blobGasUsed": "0x0", |
| 96 | + "excessBlobGas": "0x0", |
| 97 | + "parentBeaconBlockRoot": "0x95c4dbd5b19f6fe3cbc3183be85ff4e85ebe75c5b4fc911f1c91e5b7a554a685", |
| 98 | + }, |
| 99 | + } |
| 100 | + ) |
| 101 | + |
| 102 | + def get_block_number(self) -> str: |
| 103 | + """ |
| 104 | + Returns raw block number. |
| 105 | + """ |
| 106 | + return json.dumps( |
| 107 | + { |
| 108 | + "jsonrpc": "2.0", |
| 109 | + "id": "1", |
| 110 | + "result": "0x2377", |
| 111 | + } |
| 112 | + ) |
0 commit comments