|
20 | 20 | Hash, |
21 | 21 | SentTransactionResponse, |
22 | 22 | SierraContractClass, |
| 23 | + SignatureOnStateDiff, |
| 24 | + StateUpdateWithBlock, |
23 | 25 | Tag, |
24 | 26 | Transaction, |
25 | 27 | TransactionReceipt, |
|
49 | 51 | DeployAccountTransactionResponseSchema, |
50 | 52 | EstimatedFeeSchema, |
51 | 53 | SentTransactionSchema, |
| 54 | + SignatureOnStateDiffSchema, |
52 | 55 | StarknetBlockSchema, |
| 56 | + StateUpdateWithBlockSchema, |
53 | 57 | TransactionReceiptSchema, |
54 | 58 | TransactionStatusSchema, |
55 | 59 | TypesOfContractClassSchema, |
@@ -143,21 +147,33 @@ async def get_state_update( |
143 | 147 | self, |
144 | 148 | block_hash: Optional[Union[Hash, Tag]] = None, |
145 | 149 | block_number: Optional[Union[int, Tag]] = None, |
146 | | - ) -> BlockStateUpdate: |
| 150 | + include_block: bool = False, |
| 151 | + ) -> Union[BlockStateUpdate, StateUpdateWithBlock]: |
147 | 152 | """ |
148 | | - Get the information about the result of executing the requested block |
| 153 | + Get the information about the result of executing the requested block. |
149 | 154 |
|
150 | | - :param block_hash: Block's hash |
151 | | - :param block_number: Block's number (default "pending") |
152 | | - :return: BlockStateUpdate object representing changes in the requested block |
| 155 | + :param block_hash: Block's hash. |
| 156 | + :param block_number: Block's number (default "pending"). |
| 157 | + :param include_block: Flag deciding whether to include the queried block. Defaults to false. |
| 158 | + :return: BlockStateUpdate object representing changes in the requested block. |
153 | 159 | """ |
154 | 160 | block_identifier = get_block_identifier( |
155 | 161 | block_hash=block_hash, block_number=block_number |
156 | 162 | ) |
| 163 | + |
| 164 | + params = { |
| 165 | + "includeBlock": str(include_block).lower(), |
| 166 | + **block_identifier, |
| 167 | + } |
| 168 | + |
157 | 169 | res = await self._feeder_gateway_client.call( |
158 | | - method_name="get_state_update", |
159 | | - params=block_identifier, |
| 170 | + method_name="get_state_update", params=params |
160 | 171 | ) |
| 172 | + |
| 173 | + if include_block: |
| 174 | + return StateUpdateWithBlockSchema().load( |
| 175 | + res, unknown=EXCLUDE |
| 176 | + ) # pyright: ignore |
161 | 177 | return BlockStateUpdateSchema().load(res, unknown=EXCLUDE) # pyright: ignore |
162 | 178 |
|
163 | 179 | async def get_storage_at( |
@@ -461,6 +477,42 @@ async def get_full_contract( |
461 | 477 | res, unknown=EXCLUDE |
462 | 478 | ) # pyright: ignore |
463 | 479 |
|
| 480 | + async def get_signature( |
| 481 | + self, |
| 482 | + block_hash: Optional[Union[Hash, Tag]] = None, |
| 483 | + block_number: Optional[Union[int, Tag]] = None, |
| 484 | + ) -> SignatureOnStateDiff: |
| 485 | + """ |
| 486 | + Information on what is this signature and how it is calulated here: |
| 487 | + https://community.starknet.io/t/introducing-p2p-authentication-and-mismatch-resolution-in-v0-12-2/97993#signature-on-state-diff-commitment-and-block-hash-3 |
| 488 | +
|
| 489 | + :param block_hash: Block's hash or literals `"pending"` or `"latest"`. |
| 490 | + :param block_number: Block's number or literals `"pending"` or `"latest"`. |
| 491 | +
|
| 492 | + :return: Signature on state diff. |
| 493 | + """ |
| 494 | + block_identifier = get_block_identifier( |
| 495 | + block_hash=block_hash, block_number=block_number |
| 496 | + ) |
| 497 | + res = await self._feeder_gateway_client.call( |
| 498 | + method_name="get_signature", |
| 499 | + params={**block_identifier}, |
| 500 | + ) |
| 501 | + return SignatureOnStateDiffSchema().load( |
| 502 | + res, unknown=EXCLUDE |
| 503 | + ) # pyright: ignore |
| 504 | + |
| 505 | + async def get_public_key(self) -> str: |
| 506 | + """ |
| 507 | + Method returning current public key. |
| 508 | +
|
| 509 | + :return: Public key. |
| 510 | + """ |
| 511 | + public_key = await self._feeder_gateway_client.call( |
| 512 | + method_name="get_public_key" |
| 513 | + ) |
| 514 | + return cast(str, public_key) |
| 515 | + |
464 | 516 |
|
465 | 517 | def get_block_identifier( |
466 | 518 | block_hash: Optional[Union[Hash, Tag]] = None, |
|
0 commit comments