Skip to content

Commit

Permalink
feat: token gains and losses
Browse files Browse the repository at this point in the history
  • Loading branch information
Otto-AA committed Aug 6, 2024
1 parent c18c8d4 commit d0b58da
Show file tree
Hide file tree
Showing 17 changed files with 1,026 additions and 39 deletions.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ requests==2.31.0
networkx==3.3
types_networkx==3.2.1.20240425
# TODO: use specific commit
traces_parser @ git+https://github.com/TOD-theses/traces_parser
traces_parser @ git+https://github.com/TOD-theses/traces_parser
eth_abi==5.1.0
12 changes: 6 additions & 6 deletions tests/analysis/snapshots/snap_test_currency_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,53 @@
GenericRepr("<CALL@000000000000000000000000000000000000aaaa:1#0>"),
{
"change": -10,
"currency_identifier": "Wei",
"owner": "0x000000000000000000000000000000000000aaaa",
"token_address": None,
"type": "ETHER",
},
),
(
GenericRepr("<CALL@000000000000000000000000000000000000aaaa:1#0>"),
{
"change": 10,
"currency_identifier": "Wei",
"owner": "0x000000000000000000000000000000000000bbbb",
"token_address": None,
"type": "ETHER",
},
),
(
GenericRepr("<CALLCODE@000000000000000000000000000000000000aaaa:1#0>"),
{
"change": -20,
"currency_identifier": "Wei",
"owner": "0x000000000000000000000000000000000000aaaa",
"token_address": None,
"type": "ETHER",
},
),
(
GenericRepr("<CALLCODE@000000000000000000000000000000000000aaaa:1#0>"),
{
"change": 20,
"currency_identifier": "Wei",
"owner": "0x000000000000000000000000000000000000cccc",
"token_address": None,
"type": "ETHER",
},
),
(
GenericRepr("<CALL@000000000000000000000000000000000000bbbb:1#0>"),
{
"change": -10,
"currency_identifier": "Wei",
"owner": "0x000000000000000000000000000000000000bbbb",
"token_address": None,
"type": "ETHER",
},
),
(
GenericRepr("<CALL@000000000000000000000000000000000000bbbb:1#0>"),
{
"change": 10,
"currency_identifier": "Wei",
"owner": "0x000000000000000000000000000000000000cccc",
"token_address": None,
"type": "ETHER",
},
),
Expand Down
14 changes: 7 additions & 7 deletions tests/evaluation/snapshots/snap_test_financial_gain_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@
"report": {
"gains": {
"0x000000000000000000000000000000000000cccc": {
"ETHER": {
"ETHER-Wei": {
"change": 10,
"currency_identifier": "Wei",
"owner": "0x000000000000000000000000000000000000cccc",
"token_address": None,
"type": "ETHER",
}
}
},
"losses": {
"0x000000000000000000000000000000000000aaaa": {
"ETHER": {
"ETHER-Wei": {
"change": -8,
"currency_identifier": "Wei",
"owner": "0x000000000000000000000000000000000000aaaa",
"token_address": None,
"type": "ETHER",
}
},
"0x000000000000000000000000000000000000bbbb": {
"ETHER": {
"ETHER-Wei": {
"change": -2,
"currency_identifier": "Wei",
"owner": "0x000000000000000000000000000000000000bbbb",
"token_address": None,
"type": "ETHER",
}
},
Expand All @@ -45,7 +45,7 @@
"test_financial_gain_loss_evaluation evaluation_str"
] = """=== Evaluation: Financial gains and losses ===
Losses in normal compared to reverse scenario:
> 0x000000000000000000000000000000000000cccc lost 10 ETHER (in Wei)
> 0x000000000000000000000000000000000000cccc lost 10 ETHER Wei
"""
Empty file.
161 changes: 161 additions & 0 deletions tests/utils/events/snapshots/snap_test_events_decoder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# -*- coding: utf-8 -*-
# snapshottest: v1 - https://goo.gl/zC4yUc
from __future__ import unicode_literals

from snapshottest import Snapshot


snapshots = Snapshot()

snapshots["test_events_decoder_erc1155_burn_batch currency_changes"] = [
{
"change": -4369,
"currency_identifier": "0x000000000000000000000000000000000000abcd-0xabababababababababababababababababababababababababababababababab",
"owner": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"type": "ERC-1155",
},
{
"change": -8738,
"currency_identifier": "0x000000000000000000000000000000000000abcd-0xcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd",
"owner": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"type": "ERC-1155",
},
]

snapshots["test_events_decoder_erc1155_burn_single currency_changes"] = [
{
"change": -855236050549443759,
"currency_identifier": "0x000000000000000000000000000000000000abcd-0xabababababababababababababababababababababababababababababababab",
"owner": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"type": "ERC-1155",
}
]

snapshots["test_events_decoder_erc1155_mint_batch currency_changes"] = [
{
"change": 4369,
"currency_identifier": "0x000000000000000000000000000000000000abcd-0xabababababababababababababababababababababababababababababababab",
"owner": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"type": "ERC-1155",
},
{
"change": 8738,
"currency_identifier": "0x000000000000000000000000000000000000abcd-0xcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd",
"owner": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"type": "ERC-1155",
},
]

snapshots["test_events_decoder_erc1155_mint_single currency_changes"] = [
{
"change": 855236050549443759,
"currency_identifier": "0x000000000000000000000000000000000000abcd-0xabababababababababababababababababababababababababababababababab",
"owner": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"type": "ERC-1155",
}
]

snapshots["test_events_decoder_erc1155_transfer_batch currency_changes"] = [
{
"change": -4369,
"currency_identifier": "0x000000000000000000000000000000000000abcd-0xabababababababababababababababababababababababababababababababab",
"owner": "0xffffffffffffffffffffffffffffffffffffffff",
"type": "ERC-1155",
},
{
"change": 4369,
"currency_identifier": "0x000000000000000000000000000000000000abcd-0xabababababababababababababababababababababababababababababababab",
"owner": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"type": "ERC-1155",
},
{
"change": -8738,
"currency_identifier": "0x000000000000000000000000000000000000abcd-0xcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd",
"owner": "0xffffffffffffffffffffffffffffffffffffffff",
"type": "ERC-1155",
},
{
"change": 8738,
"currency_identifier": "0x000000000000000000000000000000000000abcd-0xcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd",
"owner": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"type": "ERC-1155",
},
]

snapshots["test_events_decoder_erc1155_transfer_single currency_changes"] = [
{
"change": -855236050549443759,
"currency_identifier": "0x000000000000000000000000000000000000abcd-0xabababababababababababababababababababababababababababababababab",
"owner": "0xffffffffffffffffffffffffffffffffffffffff",
"type": "ERC-1155",
},
{
"change": 855236050549443759,
"currency_identifier": "0x000000000000000000000000000000000000abcd-0xabababababababababababababababababababababababababababababababab",
"owner": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"type": "ERC-1155",
},
]

snapshots["test_events_decoder_erc20_transfer currency_changes"] = [
{
"change": -855236050549443759,
"currency_identifier": "0x000000000000000000000000000000000000abcd",
"owner": "0x916b2aff900d06c526b4935f999462b65f1a24fe",
"type": "ERC-20",
},
{
"change": 855236050549443759,
"currency_identifier": "0x000000000000000000000000000000000000abcd",
"owner": "0xd68060e9b273492d643a8eca70ad18c9ce2fb378",
"type": "ERC-20",
},
]

snapshots["test_events_decoder_erc721_transfer currency_changes"] = [
{
"change": -1,
"currency_identifier": "0x000000000000000000000000000000000000abcd-0x0000000000000000000000000000000000000000000000000bde68a8201b8caf",
"owner": "0x916b2aff900d06c526b4935f999462b65f1a24fe",
"type": "ERC-721",
},
{
"change": 1,
"currency_identifier": "0x000000000000000000000000000000000000abcd-0x0000000000000000000000000000000000000000000000000bde68a8201b8caf",
"owner": "0xd68060e9b273492d643a8eca70ad18c9ce2fb378",
"type": "ERC-721",
},
]

snapshots["test_events_decoder_erc777_burned currency_changes"] = [
{
"change": -855236050549443759,
"currency_identifier": "0x000000000000000000000000000000000000abcd",
"owner": "0xd68060e9b273492d643a8eca70ad18c9ce2fb378",
"type": "ERC-777",
}
]

snapshots["test_events_decoder_erc777_mint currency_changes"] = [
{
"change": 855236050549443759,
"currency_identifier": "0x000000000000000000000000000000000000abcd",
"owner": "0xd68060e9b273492d643a8eca70ad18c9ce2fb378",
"type": "ERC-777",
}
]

snapshots["test_events_decoder_erc777_sent currency_changes"] = [
{
"change": -855236050549443759,
"currency_identifier": "0x000000000000000000000000000000000000abcd",
"owner": "0xffffffffffffffffffffffffffffffffffffffff",
"type": "ERC-777",
},
{
"change": 855236050549443759,
"currency_identifier": "0x000000000000000000000000000000000000abcd",
"owner": "0xd68060e9b273492d643a8eca70ad18c9ce2fb378",
"type": "ERC-777",
},
]
Loading

0 comments on commit d0b58da

Please sign in to comment.