File tree Expand file tree Collapse file tree 3 files changed +63
-0
lines changed
api/oas-generator/src/oas_generator/renderer/templates/models
src/algokit_algod_client/models
tests/modules/algod_client/manual Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -336,6 +336,23 @@ class Block:
336336 ),
337337 )
338338
339+ def __post_init__(self) -> None:
340+ # populates genesis id and hash on transactions if required to ensure
341+ # tx id's are correct
342+ genesis_id = self.header.genesis_id
343+ genesis_hash = self.header.genesis_hash
344+ set_frozen_field = object.__setattr__
345+ for txn_in_block in self.payset or []:
346+ txn = txn_in_block.signed_transaction.signed_transaction.txn
347+
348+ if txn_in_block.has_genesis_id and txn.genesis_id is None:
349+ set_frozen_field(txn, "genesis_id", genesis_id)
350+
351+ # the following assumes that Consensus.RequireGenesisHash is true
352+ # so assigns genesis hash unless explicitly set to False
353+ if txn_in_block.has_genesis_hash is not False and txn.genesis_hash is None:
354+ set_frozen_field(txn, "genesis_hash", genesis_hash)
355+
339356
340357@dataclass(slots=True)
341358class BlockResponse:
Original file line number Diff line number Diff line change @@ -337,6 +337,23 @@ class Block:
337337 ),
338338 )
339339
340+ def __post_init__ (self ) -> None :
341+ # populates genesis id and hash on transactions if required to ensure
342+ # tx id's are correct
343+ genesis_id = self .header .genesis_id
344+ genesis_hash = self .header .genesis_hash
345+ set_frozen_field = object .__setattr__
346+ for txn_in_block in self .payset or []:
347+ txn = txn_in_block .signed_transaction .signed_transaction .txn
348+
349+ if txn_in_block .has_genesis_id and txn .genesis_id is None :
350+ set_frozen_field (txn , "genesis_id" , genesis_id )
351+
352+ # the following assumes that Consensus.RequireGenesisHash is true
353+ # so assigns genesis hash unless explicitly set to False
354+ if txn_in_block .has_genesis_hash is not False and txn .genesis_hash is None :
355+ set_frozen_field (txn , "genesis_hash" , genesis_hash )
356+
340357
341358@dataclass (slots = True )
342359class BlockResponse :
Original file line number Diff line number Diff line change 1+ import algokit_algod_client
2+ import algokit_indexer_client
3+
4+ _ROUND = 24098947
5+
6+
7+ def test_algod_tx_id_matches_indexer () -> None :
8+ algod_client = algokit_algod_client .AlgodClient (
9+ algokit_algod_client .ClientConfig (
10+ base_url = "https://mainnet-api.algonode.cloud" ,
11+ token = None ,
12+ )
13+ )
14+ indexer_client = algokit_indexer_client .IndexerClient (
15+ algokit_indexer_client .ClientConfig (
16+ base_url = "https://mainnet-idx.algonode.cloud" ,
17+ token = None ,
18+ )
19+ )
20+
21+ algod_txns = algod_client .get_block (_ROUND ).block .payset
22+ assert algod_txns is not None
23+ algod_txn = algod_txns [0 ].signed_transaction .signed_transaction .txn
24+
25+ idx_txns = indexer_client .lookup_block (_ROUND ).transactions
26+ assert idx_txns is not None
27+ idx_txn = idx_txns [0 ]
28+
29+ assert algod_txn .tx_id () == idx_txn .id_
You can’t perform that action at this time.
0 commit comments