@@ -44,7 +44,55 @@ def withdraw_eth(self, value):
44
44
l2_to_l1_message_passer = L2ToL1MessagePasser (self .account_l2 , provider = self .provider_l2 , network = self .network )
45
45
46
46
return l2_to_l1_message_passer .initiate_withdrawl (self .account_l2 .address , 0 , b"" , value )
47
+
48
+ def prove_message (self , l2_txn_hash ):
49
+
50
+ l2_txn = self .provider_l2 .eth .get_transaction (l2_txn_hash )
51
+ l2_txn_receipt = self .provider_l2 .eth .get_transaction_receipt (l2_txn_hash )
52
+
53
+ withdrawl_message , withrawl_message_hash = to_low_level_message (l2_txn , l2_txn_receipt )
54
+ proof = self .get_bedrock_message_proof (l2_txn , withrawl_message_hash )
47
55
56
+ optimism_portal = OptimismPortal (self .account_l1 , provider = self .provider_l1 , network = self .network )
57
+ return optimism_portal .prove_withdrawl_transaction (tuple (withdrawl_message .values ()), proof ["l2OutputIndex" ], tuple (proof ["outputRootProof" ].values ()), tuple (proof ["withdrawalProof" ]))
58
+
59
+ def finalize_message (self , l2_txn_hash ):
60
+
61
+ l2_txn = self .provider_l2 .eth .get_transaction (l2_txn_hash )
62
+ l2_txn_receipt = self .provider_l2 .eth .get_transaction_receipt (l2_txn_hash )
63
+
64
+ withdrawl_message , withrawl_message_hash = to_low_level_message (l2_txn , l2_txn_receipt )
65
+
66
+ optimism_portal = OptimismPortal (self .account_l1 , network = self .network )
67
+ return optimism_portal .finalize_withdrawl_transaction (tuple (withdrawl_message .values ()))
68
+
69
+
70
+ def get_bedrock_message_proof (self , txn , withdrawl_hash ):
71
+
72
+ l2_block_number = txn .blockNumber
73
+
74
+ l2_output_oracle = L2OutputOracle (self .account_l1 , network = self .network )
75
+
76
+ latest_l2_output_index = l2_output_oracle .latest_output_index ()
77
+ output_root , timestamp , l2_block_number = l2_output_oracle .get_l2_output (latest_l2_output_index )
78
+
79
+ message_slot = hash_message_hash (withdrawl_hash )
80
+
81
+ state_trie_proof = make_state_trie_proof (self .provider_l2 , l2_block_number , L2_TO_L1_MESSAGE_PASSER , message_slot )
82
+
83
+ block = self .provider_l2 .eth .get_block (l2_block_number )
84
+
85
+ return {
86
+ "outputRootProof" : {
87
+ "version" : OUTPUT_ROOT_PROOF_VERSION ,
88
+ "stateRoot" : block .stateRoot .hex (),
89
+ "messagePasserStorageRoot" : state_trie_proof ["storage_root" ].hex (),
90
+ "latestBlockhash" : block .hash .hex (),
91
+ },
92
+ "withdrawalProof" : [el .hex () for el in state_trie_proof ["storage_proof" ]],
93
+ "l2OutputIndex" : latest_l2_output_index ,
94
+ }
95
+
48
96
def get_message_status (self , txn_hash ):
49
97
50
98
l1_to_l2 = True
@@ -93,52 +141,33 @@ def get_message_status(self, txn_hash):
93
141
return MessageStatus .IN_CHALLENGE_PERIOD
94
142
else :
95
143
return MessageStatus .FAILED_L2_TO_L1_MESSAGE
96
-
97
144
98
- def prove_message (self , l2_txn_hash ):
99
-
100
- l2_txn = self .provider_l2 .eth .get_transaction (l2_txn_hash )
101
- l2_txn_receipt = self .provider_l2 .eth .get_transaction_receipt (l2_txn_hash )
102
-
103
- withdrawl_message , withrawl_message_hash = to_low_level_message (l2_txn , l2_txn_receipt )
104
- proof = self ._get_bedrock_message_proof (l2_txn , withrawl_message_hash )
105
-
106
- optimism_portal = OptimismPortal (self .account_l1 , provider = self .provider_l1 , network = self .network )
107
- return optimism_portal .prove_withdrawl_transaction (tuple (withdrawl_message .values ()), proof ["l2OutputIndex" ], tuple (proof ["outputRootProof" ].values ()), tuple (proof ["withdrawalProof" ]))
145
+ def get_deposits_by_address (self , address , from_block = 0 , to_block = "latest" ):
146
+ raise NotImplementedError
108
147
109
- def finalize_message (self , l2_txn_hash ):
110
-
111
- l2_txn = self .provider_l2 .eth .get_transaction (l2_txn_hash )
112
- l2_txn_receipt = self .provider_l2 .eth .get_transaction_receipt (l2_txn_hash )
113
-
114
- withdrawl_message , withrawl_message_hash = to_low_level_message (l2_txn , l2_txn_receipt )
115
-
116
- optimism_portal = OptimismPortal (self .account_l1 , network = self .network )
117
- return optimism_portal .finalize_withdrawl_transaction (tuple (withdrawl_message .values ()))
118
-
119
-
120
- def _get_bedrock_message_proof (self , txn , withdrawl_hash ):
121
-
122
- l2_block_number = txn .blockNumber
123
-
124
- l2_output_oracle = L2OutputOracle (self .account_l1 , network = self .network )
125
-
126
- latest_l2_output_index = l2_output_oracle .latest_output_index ()
127
- output_root , timestamp , l2_block_number = l2_output_oracle .get_l2_output (latest_l2_output_index )
128
-
129
- message_slot = hash_message_hash (withdrawl_hash )
130
-
131
- state_trie_proof = make_state_trie_proof (self .provider_l2 , l2_block_number , L2_TO_L1_MESSAGE_PASSER , message_slot )
132
-
133
- block = self .provider_l2 .eth .get_block (l2_block_number )
134
-
135
- return {
136
- "outputRootProof" : {
137
- "version" : OUTPUT_ROOT_PROOF_VERSION ,
138
- "stateRoot" : block .stateRoot .hex (),
139
- "messagePasserStorageRoot" : state_trie_proof ["storage_root" ].hex (),
140
- "latestBlockhash" : block .hash .hex (),
141
- },
142
- "withdrawalProof" : [el .hex () for el in state_trie_proof ["storage_proof" ]],
143
- "l2OutputIndex" : latest_l2_output_index ,
144
- }
148
+ def get_withdrawls_by_address (self , address , from_block = 0 , to_block = "latest" ):
149
+ raise NotImplementedError
150
+
151
+ def estimate_l2_gas_limit (self , message ):
152
+ raise NotImplementedError
153
+
154
+ def estimate_message_wait_time_seconds (self , message ):
155
+ raise NotImplementedError
156
+
157
+ def get_challenge_period_seconds (self ):
158
+ raise NotImplementedError
159
+
160
+ def get_proven_withdrawl (self ):
161
+ raise NotImplementedError
162
+
163
+ def get_message_state_root (self ):
164
+ raise NotImplementedError
165
+
166
+ def get_state_batch_appended_event_by_batch_index (self ):
167
+ raise NotImplementedError
168
+
169
+ def get_state_batch_appended_event_by_transaction_index (self ):
170
+ raise NotImplementedError
171
+
172
+ def get_state_root_batch_by_transaction_index (self ):
173
+ raise NotImplementedError
0 commit comments