Skip to content

Commit

Permalink
Merge pull request #658 from oasisprotocol/andrew7234/653-follow-up
Browse files Browse the repository at this point in the history
[api] shorten query
  • Loading branch information
Andrew7234 authored Mar 8, 2024
2 parents 895c62c + 39c5fc6 commit d4f20a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 9 additions & 3 deletions storage/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1403,13 +1403,19 @@ func (c *StorageClient) RuntimeEvents(ctx context.Context, p apiTypes.GetRuntime
// TODO: That's a little odd to do in the database layer. Move this farther
// out if we have the energy.
if fromPreimageContextIdentifier != nil && fromPreimageContextVersion != nil {
e.Body["from_eth"] = EthChecksumAddrFromPreimage(*fromPreimageContextIdentifier, *fromPreimageContextVersion, fromPreimageData)
if from_eth := EthChecksumAddrFromPreimage(*fromPreimageContextIdentifier, *fromPreimageContextVersion, fromPreimageData); from_eth != nil {
e.Body["from_eth"] = from_eth
}
}
if toPreimageContextIdentifier != nil && toPreimageContextVersion != nil {
e.Body["to_eth"] = EthChecksumAddrFromPreimage(*toPreimageContextIdentifier, *toPreimageContextVersion, toPreimageData)
if to_eth := EthChecksumAddrFromPreimage(*toPreimageContextIdentifier, *toPreimageContextVersion, toPreimageData); to_eth != nil {
e.Body["to_eth"] = to_eth
}
}
if ownerPreimageContextIdentifier != nil && ownerPreimageContextVersion != nil {
e.Body["owner_eth"] = EthChecksumAddrFromPreimage(*ownerPreimageContextIdentifier, *ownerPreimageContextVersion, ownerPreimageData)
if owner_eth := EthChecksumAddrFromPreimage(*ownerPreimageContextIdentifier, *ownerPreimageContextVersion, ownerPreimageData); owner_eth != nil {
e.Body["owner_eth"] = owner_eth
}
}
es.Events = append(es.Events, e)
}
Expand Down
12 changes: 3 additions & 9 deletions storage/client/queries/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,17 +411,11 @@ const (
preimages.context_identifier = 'oasis-runtime-sdk/address: secp256k1eth' AND
preimages.context_version = 0
LEFT JOIN chain.address_preimages AS pre_from ON
evs.body->>'from' = pre_from.address AND
pre_from.context_identifier = 'oasis-runtime-sdk/address: secp256k1eth' AND
pre_from.context_version = 0
evs.body->>'from' = pre_from.address
LEFT JOIN chain.address_preimages AS pre_to ON
evs.body->>'to' = pre_to.address AND
pre_to.context_identifier = 'oasis-runtime-sdk/address: secp256k1eth' AND
pre_to.context_version = 0
evs.body->>'to' = pre_to.address
LEFT JOIN chain.address_preimages AS pre_owner ON
evs.body->>'owner' = pre_owner.address AND
pre_owner.context_identifier = 'oasis-runtime-sdk/address: secp256k1eth' AND
pre_owner.context_version = 0
evs.body->>'owner' = pre_owner.address
LEFT JOIN chain.evm_tokens as tokens ON
(evs.runtime=tokens.runtime) AND
(preimages.address=tokens.token_address) AND
Expand Down

0 comments on commit d4f20a1

Please sign in to comment.