Skip to content

Commit aa74f22

Browse files
committed
DisputeGameFactory and FaultDisputeGame
1 parent f8c7e2e commit aa74f22

File tree

2 files changed

+55
-6
lines changed

2 files changed

+55
-6
lines changed

optimism/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .cross_chain_messenger import CrossChainMessenger
2-
from .contracts import OptimismPortal, StandardBridge, L2ToL1MessagePasser, L2OutputOracle, CrossChainMessengerContract
2+
from .contracts import OptimismPortal, StandardBridge, L2ToL1MessagePasser, L2OutputOracle, DisputeGameFactory, FaultDisputeGame, CrossChainMessengerContract
33

4-
__all__ = ["CrossChainMessenger", "OptimismPortal", "StandardBridge", "CrossChainMessengerContract", "L2OutputOracle", "L2ToL1MessagePasser"]
4+
__all__ = ["CrossChainMessenger", "OptimismPortal", "StandardBridge", "CrossChainMessengerContract", "L2OutputOracle", "DisputeGameFactory", "FaultDisputeGame", "L2ToL1MessagePasser"]

optimism/contracts.py

+53-4
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def finalize_withdrawl_transaction(self, tx):
5959

6060
finalize_withdrawl_transaction_tx = self.contract.functions.finalizeWithdrawalTransaction(tx).build_transaction({
6161
"from": self.account.address,
62-
"gas": 500000,
62+
"gas": 100000,
6363
"nonce": self.provider.eth.get_transaction_count(self.account.address)
6464
})
6565

@@ -68,9 +68,13 @@ def finalize_withdrawl_transaction(self, tx):
6868
def is_output_finalized():
6969
pass
7070

71-
def proven_withdrawls(self, withdrawl_hash):
71+
def proof_maturity_delay_seconds(self):
72+
73+
return self.contract.functions.proofMaturityDelaySeconds().call()
7274

73-
return self.contract.functions.provenWithdrawals(withdrawl_hash).call()
75+
def proven_withdrawls(self, withdrawl_hash, proof_submitter):
76+
77+
return self.contract.functions.provenWithdrawals(withdrawl_hash, proof_submitter).call()
7478

7579
class StandardBridge(Contract):
7680

@@ -278,6 +282,51 @@ def get_l2_output(self, l2_output_index):
278282

279283
return output_root.hex(), timestamp, l2_block_number
280284

285+
class DisputeGameFactory(Contract):
286+
287+
def __init__(self, chain_id_l1, chain_id_l2, provider=None):
288+
289+
if provider is None:
290+
self.provider = get_provider(chain_id_l1)
291+
else:
292+
self.provider = provider
293+
294+
if is_chain_supported(chain_id_l1) is False:
295+
raise Exception(f"Chain ID {chain_id_l1} not supported: add it to the config.json file or open a request to add it.")
296+
if is_chain_supported(chain_id_l2) is False:
297+
raise Exception(f"Chain ID {chain_id_l2} not supported: add it to the config.json file or open a request to add it.")
298+
299+
self.address = read_addresses(chain_id_l1, chain_id_l2, layer="l1")["DISPUTE_GAME_FACTORY"]
300+
301+
self.contract = self.provider.eth.contract(address=self.address, abi=load_abi("DISPUTE_GAME_FACTORY"))
302+
303+
def game_count(self):
304+
305+
return self.contract.functions.gameCount().call()
306+
307+
def game_at_index(self, index):
308+
309+
return self.contract.functions.gameAtIndex(index).call()
310+
311+
312+
class FaultDisputeGame(Contract):
313+
314+
def __init__(self, address, provider):
315+
316+
self.provider = provider
317+
318+
self.address = address
319+
320+
self.contract = self.provider.eth.contract(address=self.address, abi=load_abi("FAULT_DISPUTE_GAME"))
321+
322+
def root_claim(self):
323+
324+
return self.contract.functions.rootClaim().call()
325+
326+
def l2_block_number(self):
327+
328+
return self.contract.functions.l2BlockNumber().call()
329+
281330
class L2ToL1MessagePasser(Contract):
282331

283332
def __init__(self, chain_id_l1, chain_id_l2, account, provider=None):
@@ -297,7 +346,7 @@ def initiate_withdrawl(self, to, gas_limit, data, value):
297346

298347
initiate_withdrawl_tx = self.contract.functions.initiateWithdrawal(to, gas_limit, data).build_transaction({
299348
"from": self.account.address,
300-
"gas": 500000,
349+
"gas": 100000,
301350
"nonce": self.provider.eth.get_transaction_count(self.account.address),
302351
"value": value
303352
})

0 commit comments

Comments
 (0)