-
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}/transactions: Add heuristic field for "is tx a native token transfer?" #469
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 |
---|---|---|
|
@@ -1233,16 +1233,30 @@ func (c *StorageClient) RuntimeTransactions(ctx context.Context, p apiTypes.GetR | |
encryptionEnvelope.Format = *encryptionEnvelopeFormat | ||
t.EncryptionEnvelope = &encryptionEnvelope | ||
} | ||
// TODO: Here we render Ethereum-compatible address preimages. That's | ||
// a little odd to do in the database layer. Move this farther out if | ||
// we have the energy. | ||
|
||
// Render Ethereum-compatible address preimages. | ||
// TODO: That's a little odd to do in the database layer. Move this farther | ||
// out if we have the energy. | ||
if sender0PreimageContextIdentifier != nil && sender0PreimageContextVersion != nil { | ||
t.Sender0Eth = EthChecksumAddrFromPreimage(*sender0PreimageContextIdentifier, *sender0PreimageContextVersion, sender0PreimageData) | ||
} | ||
if toPreimageContextIdentifier != nil && toPreimageContextVersion != nil { | ||
t.ToEth = EthChecksumAddrFromPreimage(*toPreimageContextIdentifier, *toPreimageContextVersion, toPreimageData) | ||
} | ||
|
||
// Heuristically decide if this is a native runtime token transfer. | ||
// TODO: Similarly to above, this application logic doesn't belong here (= the DB layer); | ||
// move it out if we establish a separate app/logic layer. | ||
if t.Method != nil { | ||
if *t.Method == "accounts.Transfer" { | ||
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. put this on the list of places to think about if a paratime ever uses multiple denominations in the accounts system 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. Yeah :/, I thought about it. |
||
t.IsLikelyNativeTokenTransfer = common.Ptr(true) | ||
} else if *t.Method == "evm.Call" && t.Body != nil && (*t.Body)["data"] == "" { | ||
// Note: This demands that the body.data key does exist (as we expect from evm.Call tx bodies), | ||
// but has an empty value. | ||
t.IsLikelyNativeTokenTransfer = common.Ptr(true) | ||
} | ||
} | ||
|
||
ts.Transactions = append(ts.Transactions, t) | ||
} | ||
|
||
|
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.
should we add this field to
required
?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.
Maybe. I do have arguments for keeping it optional, but they are relatively weak: 1) We currently just omit it if it's
false
. 2) It's such an unusual field (in that it's a heuristic, rather than just restructured blockchain contents) that I kinda like keeping the door ajar to removing the field later if desired.I don't need much of a push to promote it to
required
later.