-
Notifications
You must be signed in to change notification settings - Fork 0
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
New completion worker model #188
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: Brendan Le Glaunec <harold.kutenberg@gmail.com>
added const to seaport sale
93157ab
to
2cc1924
Compare
@@ -18,7 +18,7 @@ type Transfer struct { | |||
EventIndex uint `json:"event_index"` | |||
SenderAddress string `json:"sender_address"` | |||
ReceiverAddress string `json:"receiver_address"` | |||
TokenCount uint `json:"token_count"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this change necessary?
service/parsers/erc20_transfer.go
Outdated
|
||
value, ok := fields["value"].(*big.Int) | ||
if !ok { | ||
return nil, fmt.Errorf("invalid type for \"value\" field (%T)", fields["value"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, fmt.Errorf("invalid type for \"value\" field (%T)", fields["value"]) | |
return nil, fmt.Errorf("invalid type for %q field (%T)", fieldValue, fields[fieldValue]) |
if len(log.Topics) < 3 && len(log.Topics) > 4 { | ||
p.log.Warn(). | ||
Uint("index", log.Index). | ||
Int("topics", len(log.Topics)). | ||
Msg("skipping log with invalid topic length") | ||
continue | ||
} | ||
|
||
transfer, err := parsers.ERC721Transfer(log) | ||
if err != nil { | ||
return nil, fmt.Errorf("could not parse sale ERC721 transfer: %w", err) | ||
} | ||
switch { | ||
|
||
case len(log.Topics) == 3: | ||
|
||
transfer, err := parsers.ERC20Transfer(log) | ||
if err != nil { | ||
return nil, fmt.Errorf("could not parse sale ERC20 transfer: %w", err) | ||
} | ||
|
||
transferLookup[transfer.Hash()] = append(transferLookup[transfer.Hash()], transfer) | ||
transferLookup[transfer.TransactionHash] = append(transferLookup[transfer.TransactionHash], transfer) | ||
|
||
case len(log.Topics) == 4: | ||
|
||
transfer, err := parsers.ERC721Transfer(log) | ||
if err != nil { | ||
return nil, fmt.Errorf("could not parse sale ERC721 transfer: %w", err) | ||
} | ||
|
||
transferLookup[transfer.TransactionHash] = append(transferLookup[transfer.TransactionHash], transfer) | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't this change already in an earlier PR as well? Does this PR include older commits that weren't merged or is my memory playing tricks on me? 😄
// if there is more than 1 nft transfer and 1 token transfer | ||
// (could be 2 nft transfers next cases will cover this) | ||
if len(transfers) > 2 { | ||
continue | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a normal case that there are more than two transfers? When can it happen? How do we deal with it? It seems like the only supported case is exactly 2 transfers, and that other cases trigger warnings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will take a look at changing the approach this weekend, see comment. This is too brittle, and too hard to keep extending.
// Sort everything by log index | ||
sort.Slice(sales, func(i, j int) bool { | ||
return sales[i].EventIndex < sales[i].EventIndex | ||
}) | ||
sort.Slice(transactionTransfers, func(i, j int) bool { | ||
return transactionTransfers[i].EventIndex < transactionTransfers[i].EventIndex | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this approach is flawed, as we might end up mixing things. What I would like to see is the ability to get all the events for the transaction, and then pattern-matching a certain "anatomy" for it. We should run all transaction logs through a parser, that matches all the events in the transaction by type to identify what is happening.
WIP