-
Notifications
You must be signed in to change notification settings - Fork 4
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
runtime: fix owner update for burned NFT instances #589
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,7 +121,11 @@ type NFTKey struct { | |
} | ||
|
||
type PossibleNFT struct { | ||
NewOwner *apiTypes.Address | ||
// NewOwner has the latest owner if .NumTransfers is more than zero. If | ||
// the last transfer burned this NFT instance, then it's the empty string. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, thank you for the docstrings! Can we keep it as a pointer though? Right now, to realize that the Optional: I also suggest the special value be something other than the empty string, e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not feeling that special string idea. I'll add a Burned bool field. |
||
NewOwner apiTypes.Address | ||
// NumTransfers is how many times we saw it transferred. If it's more than | ||
// zero, the new owner is in .NewOwner. | ||
NumTransfers int | ||
} | ||
|
||
|
@@ -270,7 +274,7 @@ func registerNFTExist(nftChanges map[NFTKey]*PossibleNFT, contractAddr apiTypes. | |
func registerNFTTransfer(nftChanges map[NFTKey]*PossibleNFT, contractAddr apiTypes.Address, tokenID *big.Int, newOwner apiTypes.Address) { | ||
possibleNFT := findPossibleNFT(nftChanges, contractAddr, tokenID) | ||
possibleNFT.NumTransfers++ | ||
possibleNFT.NewOwner = &newOwner | ||
possibleNFT.NewOwner = newOwner | ||
} | ||
|
||
func findTokenChange(tokenChanges map[TokenChangeKey]*big.Int, contractAddr apiTypes.Address, accountAddr apiTypes.Address) *big.Int { | ||
|
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 would prefer to keep the single-statement setup here. It will keep the upsert a lot more similar to other upserts, both on the Go and SQL side, and thus easier to read and reason about.
We'll just need a special value for
owner
(or rather$4
) that SQL can recognize. So in the old query, only a single line would need to change, something likeThere 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.
"please do this completely differently. approved"
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.
Sorry if it looked weird. As explained on slack, approved to unblock you after I'm gone in my timezone.
Also, "completely differently" is ... one possible interpretation in that the whole PR is not very large, so the percentage of affected lines is large. But I agree with all the debugging work that led to the small PR, and with the semantics of the fix, which is to sometimes force the NULL into the DB. Those are the more important parts IMO, and my comment is about a technicality and code readability.
Really signing off now.