diff --git a/examples/transactions_examples.py b/examples/transactions_examples.py index 1246848..6b5f7fe 100644 --- a/examples/transactions_examples.py +++ b/examples/transactions_examples.py @@ -283,23 +283,23 @@ async def run(self, ctx: Config): self.log.info(f"transaction script: {transaction.script.decode('utf-8')}") -class DebuggingFetchTransactionByIdExample(Example): - def __init__(self) -> None: - super().__init__( - tag="T.LL.", name="DebuggingFetchTransactionByIdExample", sort_order=501 - ) - - async def run(self, ctx: Config): - # First Step : Create a client to connect to the flow blockchain - # flow_client function creates a client using the host and port - async with flow_client( - # host=ctx.access_node_host, port=ctx.access_node_port - host="access.mainnet.nodes.onflow.org", - port=9000, - ) as client: - - tx_id = "ef6e6dcba87c5f853e0ec940dd382d609ffe11109c28ed239843d71618fa1d71" - - transaction = await client.get_transaction_result(id=bytes.fromhex(tx_id)) - - print(f"Transaction ID: {tx_id}") +# class DebuggingFetchTransactionByIdExample(Example): +# def __init__(self) -> None: +# super().__init__( +# tag="T.LL.", name="DebuggingFetchTransactionByIdExample", sort_order=501 +# ) +# +# async def run(self, ctx: Config): +# # First Step : Create a client to connect to the flow blockchain +# # flow_client function creates a client using the host and port +# async with flow_client( +# # host=ctx.access_node_host, port=ctx.access_node_port +# host="access.mainnet.nodes.onflow.org", +# port=9000, +# ) as client: +# +# tx_id = "ef6e6dcba87c5f853e0ec940dd382d609ffe11109c28ed239843d71618fa1d71" +# +# transaction = await client.get_transaction_result(id=bytes.fromhex(tx_id)) +# +# print(f"Transaction ID: {tx_id}") diff --git a/flow_py_sdk/cadence/__init__.py b/flow_py_sdk/cadence/__init__.py index 74bd2c5..3381f51 100644 --- a/flow_py_sdk/cadence/__init__.py +++ b/flow_py_sdk/cadence/__init__.py @@ -90,7 +90,7 @@ StoragePathKind, PublicPathKind, PrivatePathKind, - AuthAccountKind, + AccountKind, PublicAccountKind, AuthAccountKeysKind, PublicAccountKeysKind, diff --git a/flow_py_sdk/cadence/decode.py b/flow_py_sdk/cadence/decode.py index 758f229..705b315 100644 --- a/flow_py_sdk/cadence/decode.py +++ b/flow_py_sdk/cadence/decode.py @@ -40,20 +40,20 @@ def decode(obj: dict[Any, Any]) -> Union[Value, Kind, dict]: decoder = _cadence_decoders[type_] return decoder(obj) - # Recursively handle nested structures - if isinstance(obj, dict): - for key, value in obj.items(): - if isinstance(value, dict): - obj[key] = decode(value) # Recursive call for nested dict - elif isinstance(value, list): - obj[key] = [ - decode(item) for item in value - ] # Recursive list handling - - elif isinstance(obj, list): - obj = [ - decode(item) for item in obj - ] # Handle obj itself as a list if list type + # # Recursively handle nested structures + # if isinstance(obj, dict): + # for key, value in obj.items(): + # if isinstance(value, dict): + # obj[key] = decode(value) # Recursive call for nested dict + # elif isinstance(value, list): + # obj[key] = [ + # decode(item) for item in value + # ] # Recursive list handling + # + # elif isinstance(obj, list): + # obj = [ + # decode(item) for item in obj + # ] # Handle obj itself as a list if list type return obj # Return the object if no decoder applies diff --git a/flow_py_sdk/cadence/simple_kinds.py b/flow_py_sdk/cadence/simple_kinds.py index b41e024..ad9b18c 100644 --- a/flow_py_sdk/cadence/simple_kinds.py +++ b/flow_py_sdk/cadence/simple_kinds.py @@ -275,10 +275,10 @@ def kind_str(cls) -> str: return "PrivatePath" -class AuthAccountKind(SimpleKind): +class AccountKind(SimpleKind): @classmethod def kind_str(cls) -> str: - return "AuthAccount" + return "Account" class PublicAccountKind(SimpleKind): @@ -372,7 +372,7 @@ def kind_str(cls) -> str: StoragePathKind, PublicPathKind, PrivatePathKind, - AuthAccountKind, + AccountKind, PublicAccountKind, AuthAccountKeysKind, PublicAccountKeysKind, diff --git a/tests/cadence/encode_test.py b/tests/cadence/encode_test.py index 28b88d0..46c7ff4 100644 --- a/tests/cadence/encode_test.py +++ b/tests/cadence/encode_test.py @@ -1400,6 +1400,68 @@ def testInclusiveRangeKind(self): ) self._encodeAndDecodeAll([kind]) + def testAccountCapabilityControllerIssued(self): + kind = _EncodeTestParams( + "AccountCapabilityControllerIssued event", + cadence.Event( + "flow.AccountCapabilityControllerIssued", + [ + ( + "type", + cadence.TypeValue( + cadence.ReferenceKind( + cadence.EntitlementConjunctionSetKind( + [ + cadence.EntitlementKind("Storage"), + cadence.EntitlementKind("Contracts"), + cadence.EntitlementKind("Keys"), + cadence.EntitlementKind("Inbox"), + cadence.EntitlementKind("Capabilities"), + ] + ), + cadence.AccountKind() + ), + ), + ) + ] + ), + """ + { + "value": { + "id": "flow.AccountCapabilityControllerIssued", + "fields": [ + { + "name": "type", + "value": { + "value": { + "staticType": { + "type": { + "kind": "Account" + }, + "kind": "Reference", + "authorization": { + "kind": "EntitlementConjunctionSet", + "entitlements": [ + { "kind": "Entitlement", "typeID": "Storage" }, + { "kind": "Entitlement", "typeID": "Contracts" }, + { "kind": "Entitlement", "typeID": "Keys" }, + { "kind": "Entitlement", "typeID": "Inbox" }, + { "kind": "Entitlement", "typeID": "Capabilities" } + ] + } + } + }, + "type": "Type" + } + } + ] + }, + "type": "Event" + } + """, + ) + self._encodeAndDecodeAll([kind]) + def testStorefrontEvent(self): self.maxDiff = None event = _EncodeTestParams(