Skip to content

Commit

Permalink
[api] add runtimeEvmBalance.token_contract_addr_eth instead of replacing
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew7234 committed Jul 20, 2023
1 parent 0e1ee16 commit 845d216
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions api/spec/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1740,15 +1740,19 @@ components:
RuntimeEvmBalance:
description: Balance of an account for a specific runtime and EVM token.
type: object
required: [balance, token_contract_addr, token_decimals, token_type]
required: [balance, token_contract_addr, token_contract_addr_eth, token_decimals, token_type]
properties:
balance:
<<: *BigIntType
description: Number of tokens held, in base units.
token_contract_addr:
type: string
description: The oasis address of this token's contract.
example: 'oasis1qzk5pr2x8ah04lgjee3lv06fmyvqvz45egjv4ps0'
token_contract_addr_eth:
type: string
description: The EVM address of this token's contract. Encoded as a lowercase hex string.
example: 'dc19a122e268128b5ee20366299fc7b5b199c8e3'
example: '0xF8E3DE55D24D13607A12628E0A113B66BA578bDC'
token_symbol:
type: string
description: The token ticker symbol. Not guaranteed to be unique across distinct EVM tokens.
Expand Down
3 changes: 2 additions & 1 deletion storage/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,7 @@ func (c *StorageClient) RuntimeAccount(ctx context.Context, address staking.Addr
var addrPreimage []byte
if err = runtimeEvmRows.Scan(
&b.Balance,
&b.TokenContractAddr,
&addrPreimage,
&b.TokenSymbol,
&b.TokenName,
Expand All @@ -1404,7 +1405,7 @@ func (c *StorageClient) RuntimeAccount(ctx context.Context, address staking.Addr
); err != nil {
return nil, wrapError(err)
}
b.TokenContractAddr = ethCommon.BytesToAddress(addrPreimage).String()
b.TokenContractAddrEth = 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,8 @@ const (
AccountRuntimeEvmBalances = `
SELECT
balances.balance AS balance,
preimages.address_data AS token_address,
balances.token_address AS token_address,
preimages.address_data AS token_address_eth,
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 Down

0 comments on commit 845d216

Please sign in to comment.