From b3e05132d596cf71f73910b95806b1ffc77f7b44 Mon Sep 17 00:00:00 2001 From: Andrew Low Date: Thu, 7 Mar 2024 17:22:12 -0800 Subject: [PATCH 1/2] [api] shorten query --- storage/client/queries/queries.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/storage/client/queries/queries.go b/storage/client/queries/queries.go index c0b4999db..cdf7bc482 100644 --- a/storage/client/queries/queries.go +++ b/storage/client/queries/queries.go @@ -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 From 39c5fc6d55d6770477b38ac35b37456603de9ada Mon Sep 17 00:00:00 2001 From: Andrew Low Date: Thu, 7 Mar 2024 19:00:29 -0800 Subject: [PATCH 2/2] [api] do not populate null fields in event body --- storage/client/client.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/storage/client/client.go b/storage/client/client.go index ca329469f..d0216a1f8 100644 --- a/storage/client/client.go +++ b/storage/client/client.go @@ -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) }