Skip to content
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
13 changes: 3 additions & 10 deletions hathor/event/model/event_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Optional, TypeAlias, Union, cast
from typing import Any, Optional, TypeAlias, Union, cast

from pydantic import Extra, validator
from typing_extensions import Self
Expand All @@ -31,7 +31,8 @@ class TxOutput(BaseModel, extra=Extra.ignore):
value: int
token_data: int
script: str
decoded: Optional[DecodedTxOutput]
# Instead of None, an empty dict represents an unknown script, as requested by our wallet-service use case.
decoded: DecodedTxOutput | dict[Any, Any]


class TxInput(BaseModel):
Expand Down Expand Up @@ -123,17 +124,9 @@ def from_event_arguments(cls, args: EventArguments) -> Self:
tx_json = tx_extra_data_json['tx']
meta_json = tx_extra_data_json['meta']
tx_json['metadata'] = meta_json
tx_json['outputs'] = [
output | dict(decoded=output['decoded'] or None)
for output in tx_json['outputs']
]

inputs = []
for tx_input in tx_json['inputs']:
decoded = tx_input.get('decoded')
if decoded and decoded.get('address') is None:
# we remove the decoded data if it does not contain an address
tx_input['decoded'] = None
inputs.append(
dict(
tx_id=tx_input['tx_id'],
Expand Down
Loading