Skip to content

feat: add first_block to the to_json_extended method of base transaction class #1003

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

Merged
merged 2 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions hathor/transaction/base_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,13 @@ def serialize_output(tx: BaseTransaction, tx_out: TxOutput) -> dict[str, Any]:
'parents': [],
}

# A nano contract tx must be confirmed by one block at least
# to be considered "executed"
if meta.first_block is not None:
ret['first_block'] = meta.first_block.hex()
else:
ret['first_block'] = None

for parent in self.parents:
ret['parents'].append(parent.hex())

Expand Down
18 changes: 13 additions & 5 deletions hathor/transaction/resources/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ def render_GET(self, request):
],
'inputs': [],
'outputs': [],
'tokens': []
'tokens': [],
'first_block': None,
},
{
'tx_id': ('00002b3be4e3876e67b5e090d76dcd71'
Expand All @@ -166,7 +167,9 @@ def render_GET(self, request):
],
'inputs': [],
'outputs': [],
'tokens': []
'tokens': [],
'first_block': ('000005af290a55b079014a0be3246479'
'e84eeb635f02010dbf3e5f3414a85bbb')
}
],
'blocks': [
Expand All @@ -189,7 +192,9 @@ def render_GET(self, request):
'script': 'dqkUixvdsajkV6vO+9Jjgjbaheqn016IrA=='
}
],
'tokens': []
'tokens': [],
'first_block': ('000005af290a55b079014a0be3246479'
'e84eeb635f02010dbf3e5f3414a85bbb')
},
{
'tx_id': ('00035e46a20d0ecbda0dc6fdcaa243e9'
Expand All @@ -210,7 +215,9 @@ def render_GET(self, request):
'script': 'dqkUdNQbj29Md1xsAYinK+RsDJCCB7eIrA=='
}
],
'tokens': []
'tokens': [],
'first_block': ('000005af290a55b079014a0be3246479'
'e84eeb635f02010dbf3e5f3414a85bbb')
},
{
'tx_id': ('000133cc80b625b1babbd454edc3474e'
Expand All @@ -231,7 +238,8 @@ def render_GET(self, request):
'script': 'dqkU0AoLEAX+1b36s+VyaMc9bkj/5byIrA=='
}
],
'tokens': []
'tokens': [],
'first_block': None
}
]
}
Expand Down
5 changes: 4 additions & 1 deletion hathor/transaction/resources/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ def get_list_tx(self, request):
],
'tokens': [],
'height': 12345,
'first_block': None
},
{
'tx_id': ('00000b8792cb13e8adb51cc7d866541f'
Expand Down Expand Up @@ -496,7 +497,9 @@ def get_list_tx(self, request):
'script': 'dqkUjjPg+zwG6JDe901I0ybQxcAPrAuIrA=='
}
],
'tokens': []
'tokens': [],
'first_block': ('000005af290a55b079014a0be3246479'
'e84eeb635f02010dbf3e5f3414a85bbb')
}
],
'has_more': True
Expand Down
6 changes: 4 additions & 2 deletions hathor/wallet/resources/thin_wallet/address_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,10 @@ def get_address_history(self, addresses: list[str], ref_hash: Optional[str]) ->
},
"token": "00"
}
]
}
],
"first_block": ("000005af290a55b079014a0be3246479"
"e84eeb635f02010dbf3e5f3414a85bbb")
}
]
}
},
Expand Down
7 changes: 5 additions & 2 deletions hathor/wallet/resources/thin_wallet/token_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ def render_GET(self, request: Request) -> bytes:
'script': 'dqkUjjPg+zwG6JDe901I0ybQxcAPrAuIrA=='
}
],
'tokens': []
'tokens': [],
'first_block': None
},
{
'tx_id': ('00000b8792cb13e8adb51cc7d866541f'
Expand Down Expand Up @@ -276,7 +277,9 @@ def render_GET(self, request: Request) -> bytes:
'script': 'dqkUjjPg+zwG6JDe901I0ybQxcAPrAuIrA=='
}
],
'tokens': []
'tokens': [],
'first_block': ('000005af290a55b079014a0be3246479'
'e84eeb635f02010dbf3e5f3414a85bbb')
}
],
'has_more': True
Expand Down