starknet.py icon indicating copy to clipboard operation
starknet.py copied to clipboard

Allow ignoring unknown keys in RPC responses by set env

Open tkumor3 opened this issue 11 months ago • 2 comments

Closes #1305

  • Remove hardcoded unknown=EXCLUDE from deserializing in FullNodeClient
  • Allow ignoring unknown keys in RPC responses by set env

I had to leave some unknown=EXCLUDE because devnet sometimes returns more fields than starknet-spec claim should be sent

Introduced changes

  • [ ] This PR contains breaking changes

tkumor3 avatar Mar 05 '24 11:03 tkumor3

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 97.81%. Comparing base (a2686e2) to head (9bfbde1).

Additional details and impacted files
@@             Coverage Diff              @@
##           development    #1312   +/-   ##
============================================
  Coverage        97.80%   97.81%           
============================================
  Files               94       95    +1     
  Lines             4743     4752    +9     
============================================
+ Hits              4639     4648    +9     
  Misses             104      104           
Files Coverage Δ
starknet_py/net/client_models.py 99.57% <100.00%> (+<0.01%) :arrow_up:
starknet_py/net/full_node_client.py 99.51% <100.00%> (ø)
starknet_py/net/schemas/rpc.py 99.21% <100.00%> (+<0.01%) :arrow_up:
starknet_py/utils/schema.py 100.00% <100.00%> (ø)

codecov[bot] avatar Mar 05 '24 14:03 codecov[bot]

INCLUDE strategy can't be added because mapping Schema to dataclass doesn't work with it. Example:

    def make_dataclass(self, data, **kwargs) -> ExecutionResources:
>       return ExecutionResources(**data)
E       TypeError: ExecutionResources.__init__() got an unexpected keyword argument 'segment_arena_builtin'

tkumor3 avatar Mar 06 '24 08:03 tkumor3

Could we add some unit tests by setting a temporary environment variable?

It's problematic because we need to keep broken schema in our code to test it

tkumor3 avatar Mar 13 '24 09:03 tkumor3

This PR should be updated with apropriate docs section that will explain this feature and give some examples.

Any idea about an example, IMO the description how to set it seems to be clear

tkumor3 avatar Mar 18 '24 13:03 tkumor3

This PR should be updated with apropriate docs section that will explain this feature and give some examples.

Any idea about an example, IMO the description how to set it seems to be clear

The description you've provided should be enough

THenry14 avatar Mar 18 '24 14:03 THenry14