Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deserialization of events with entitlements and add better error logging #67

Merged
merged 19 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ ENV/
env.bak/
venv.bak/
pythonenv*
myenv

# Spyder project settings
.spyderproject
Expand Down
22 changes: 22 additions & 0 deletions examples/transactions_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,25 @@ async def run(self, ctx: Config):
f"transaction proposer: {transaction.proposal_key.address.hex()}"
)
self.log.info(f"transaction script: {transaction.script.decode('utf-8')}")


class DebuggingFetchTransactionByIdExample(Example):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added example which makes a mainnet call to the failing tx ID ef6e6dcba87c5f853e0ec940dd382d609ffe11109c28ed239843d71618fa1d71, will remove this before merging changes

def __init__(self) -> None:
super().__init__(
tag="T.LL.", name="DebuggingFetchTransactionByIdExample", sort_order=501
)

lealobanov marked this conversation as resolved.
Show resolved Hide resolved
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}")
lealobanov marked this conversation as resolved.
Show resolved Hide resolved
291 changes: 291 additions & 0 deletions failed_events.json
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an output of the failing event payloads for reference, will remove before merging changes

Original file line number Diff line number Diff line change
@@ -0,0 +1,291 @@
[
{
"value": {
"id": "flow.AccountCapabilityControllerIssued",
"fields": [
{
"name": "id",
"value": {
"value": "3",
"type": "UInt64"
}
},
{
"name": "address",
"value": {
"value": "0x646997908e65fb70",
"type": "Address"
}
},
{
"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"
},
{
"value": {
"id": "flow.StorageCapabilityControllerIssued",
"fields": [
{
"name": "id",
"value": {
"value": "148",
"type": "UInt64"
}
},
{
"name": "address",
"value": {
"value": "0x0342200ce19810f6",
"type": "Address"
}
},
{
"name": "type",
"value": {
"value": {
"staticType": {
"type": {
"type": "",
"kind": "Resource",
"typeID": "A.befbaccb5032a457.ContractManager.Manager",
"fields": [
{ "type": { "kind": "UInt64" }, "id": "uuid" },
{
"type": {
"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" }
]
}
},
"kind": "Capability",
"id": "acct"
},
{
"type": {
"type": {
"type": "",
"kind": "Resource",
"typeID": "A.707c0b39a8d689cb.FungibleTokenRouter.Router",
"fields": [
{ "type": { "kind": "UInt64" }, "id": "uuid" },
{ "type": { "kind": "Address" }, "id": "defaultAddress" },
{
"type": {
"key": { "kind": "String" },
"value": { "kind": "Address" },
"kind": "Dictionary"
},
"id": "addressOverrides"
}
]
},
"kind": "Reference",
"authorization": {
"kind": "EntitlementConjunctionSet",
"entitlements": [
{
"kind": "Entitlement",
"typeID": "A.707c0b39a8d689cb.FungibleTokenRouter.Owner"
}
]
}
},
"kind": "Capability",
"id": "routerCap"
},
{
"type": {
"key": { "kind": "String" },
"value": { "kind": "AnyStruct" },
"kind": "Dictionary"
},
"id": "data"
},
{
"type": {
"key": { "kind": "String" },
"value": { "kind": "AnyResource" },
"kind": "Dictionary"
},
"id": "resources"
}
]
},
"kind": "Reference",
"authorization": {
"kind": "Unauthorized",
"entitlements": null
}
}
},
"type": "Type"
}
},
{
"name": "path",
"value": {
"value": {
"domain": "storage",
"identifier": "ContractManager_0xbefbaccb5032a457"
},
"type": "Path"
}
}
]
},
"type": "Event"
},
{
"value": {
"id": "flow.CapabilityPublished",
"fields": [
{
"name": "address",
"value": {
"value": "0x0342200ce19810f6",
"type": "Address"
}
},
{
"name": "path",
"value": {
"value": {
"domain": "public",
"identifier": "ContractManager_0xbefbaccb5032a457"
},
"type": "Path"
}
},
{
"name": "capability",
"value": {
"value": {
"borrowType": {
"type": {
"type": "",
"kind": "Resource",
"typeID": "A.befbaccb5032a457.ContractManager.Manager",
"fields": [
{ "type": { "kind": "UInt64" }, "id": "uuid" },
{
"type": {
"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" }
]
}
},
"kind": "Capability",
"id": "acct"
},
{
"type": {
"type": {
"type": "",
"kind": "Resource",
"typeID": "A.707c0b39a8d689cb.FungibleTokenRouter.Router",
"fields": [
{ "type": { "kind": "UInt64" }, "id": "uuid" },
{ "type": { "kind": "Address" }, "id": "defaultAddress" },
{
"type": {
"key": { "kind": "String" },
"value": { "kind": "Address" },
"kind": "Dictionary"
},
"id": "addressOverrides"
}
]
},
"kind": "Reference",
"authorization": {
"kind": "EntitlementConjunctionSet",
"entitlements": [
{
"kind": "Entitlement",
"typeID": "A.707c0b39a8d689cb.FungibleTokenRouter.Owner"
}
]
}
},
"kind": "Capability",
"id": "routerCap"
},
{
"type": {
"key": { "kind": "String" },
"value": { "kind": "AnyStruct" },
"kind": "Dictionary"
},
"id": "data"
},
{
"type": {
"key": { "kind": "String" },
"value": { "kind": "AnyResource" },
"kind": "Dictionary"
},
"id": "resources"
}
]
},
"kind": "Reference",
"authorization": {
"kind": "Unauthorized",
"entitlements": null
}
},
"address": "0x0342200ce19810f6",
"id": "148"
},
"type": "Capability"
}
}
]
},
"type": "Event"
}
]
Loading
Loading