@@ -983,21 +983,49 @@ def claim_winnings(
983983 raise ValueError (f"No RPC URL for chain { self ._chain_id } " )
984984
985985 w3 = Web3 (Web3 .HTTPProvider (rpc_url ))
986+ print (f"Connected to RPC: { rpc_url } " )
986987
987- # Query getStaticMarketData() from market contract
988- # Returns: (ctf, collateralToken, conditionId, yesTokenId, noTokenId)
989- static_data_selector = "0x3e47d6f3" # getStaticMarketData()
990- static_data = w3 .eth .call ({
988+ # Ensure address is checksummed
989+ market_contract_address = Web3 .to_checksum_address (market_contract_address )
990+ print (f"Market address: { market_contract_address } " )
991+
992+ # Query individual getters from market contract
993+ # ctf() -> address
994+ print ("Querying ctf()..." )
995+ ctf_data = w3 .eth .call ({
996+ "to" : market_contract_address ,
997+ "data" : "0x22a9339f" , # ctf()
998+ })
999+ ctf_address = Web3 .to_checksum_address ("0x" + ctf_data [12 :32 ].hex ())
1000+ print (f"CTF address: { ctf_address } " )
1001+
1002+ # collateralToken() -> address
1003+ collateral_data = w3 .eth .call ({
1004+ "to" : market_contract_address ,
1005+ "data" : "0xb2016bd4" , # collateralToken()
1006+ })
1007+ collateral_token = Web3 .to_checksum_address ("0x" + collateral_data [12 :32 ].hex ())
1008+
1009+ # conditionId() -> bytes32
1010+ condition_data = w3 .eth .call ({
1011+ "to" : market_contract_address ,
1012+ "data" : "0x2ddc7de7" , # conditionId()
1013+ })
1014+ condition_id = "0x" + condition_data .hex ()
1015+
1016+ # yesTokenId() -> uint256
1017+ yes_data = w3 .eth .call ({
9911018 "to" : market_contract_address ,
992- "data" : static_data_selector ,
1019+ "data" : "0x76cd28a2" , # yesTokenId()
9931020 })
1021+ yes_token_id = int (yes_data .hex (), 16 )
9941022
995- # Decode the response (5 values: address, address, bytes32, uint256, uint256)
996- ctf_address = "0x" + static_data [ 12 : 32 ]. hex ()
997- collateral_token = "0x" + static_data [ 44 : 64 ]. hex ()
998- condition_id = "0x" + static_data [ 64 : 96 ]. hex ()
999- yes_token_id = int ( static_data [ 96 : 128 ]. hex (), 16 )
1000- no_token_id = int (static_data [ 128 : 160 ] .hex (), 16 )
1023+ # noTokenId() -> uint256
1024+ no_data = w3 . eth . call ({
1025+ "to" : market_contract_address ,
1026+ "data" : "0x8c2557a8" , # noTokenId ()
1027+ } )
1028+ no_token_id = int (no_data .hex (), 16 )
10011029
10021030 print (f"Market data:" )
10031031 print (f" CTF: { ctf_address } " )
@@ -1006,14 +1034,19 @@ def claim_winnings(
10061034
10071035 # Query getResolutionStatus() from market contract
10081036 # Returns: (expired, resolved, assertionId, winningOutcome, canPropose, canSettle)
1009- resolution_selector = "0x7a9262a2 " # getResolutionStatus()
1037+ resolution_selector = "0x13b63fce " # getResolutionStatus()
10101038 resolution_data = w3 .eth .call ({
10111039 "to" : market_contract_address ,
10121040 "data" : resolution_selector ,
10131041 })
10141042
10151043 # Decode: bool, bool, bytes32, uint8, bool, bool
1016- resolved = bool (int (resolution_data [31 :32 ].hex (), 16 ))
1044+ # Each value is padded to 32 bytes:
1045+ # expired: bytes 0-32 (value at byte 31)
1046+ # resolved: bytes 32-64 (value at byte 63)
1047+ # assertionId: bytes 64-96
1048+ # winningOutcome: bytes 96-128 (uint8 padded)
1049+ resolved = bool (resolution_data [63 ])
10171050 winning_outcome = int (resolution_data [96 :128 ].hex (), 16 )
10181051
10191052 if not resolved :
0 commit comments