Skip to content

Commit

Permalink
[api] return evm address instead of oasis addr in RuntimeEvmBalance
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew7234 committed Jul 20, 2023
1 parent fe16d30 commit 0e1ee16
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion storage/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1393,16 +1393,18 @@ func (c *StorageClient) RuntimeAccount(ctx context.Context, address staking.Addr

for runtimeEvmRows.Next() {
b := RuntimeEvmBalance{}
var addrPreimage []byte
if err = runtimeEvmRows.Scan(
&b.Balance,
&b.TokenContractAddr,
&addrPreimage,
&b.TokenSymbol,
&b.TokenName,
&b.TokenType,
&b.TokenDecimals,
); err != nil {
return nil, wrapError(err)
}
b.TokenContractAddr = ethCommon.BytesToAddress(addrPreimage).String()
a.EvmBalances = append(a.EvmBalances, b)
}

Expand Down
3 changes: 2 additions & 1 deletion storage/client/queries/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ const (
AccountRuntimeEvmBalances = `
SELECT
balances.balance AS balance,
balances.token_address AS token_address,
preimages.address_data AS token_address,
tokens.symbol AS token_symbol,
tokens.token_name AS token_name,
CASE -- NOTE: There are two queries that use this CASE via copy-paste; edit both if changing.
Expand All @@ -531,6 +531,7 @@ const (
END AS token_type,
tokens.decimals AS token_decimals
FROM chain.evm_token_balances AS balances
JOIN chain.address_preimages AS preimages ON (preimages.address = balances.token_address AND preimages.context_identifier = 'oasis-runtime-sdk/address: secp256k1eth' AND preimages.context_version = 0)
JOIN chain.evm_tokens AS tokens USING (runtime, token_address)
WHERE runtime = $1 AND
balances.account_address = $2::text AND
Expand Down

0 comments on commit 0e1ee16

Please sign in to comment.