ExocoreNetwork / exocore

Omnichain Restaking
7 stars 9 forks source link

fix(assets,delegation): case insensitive query #80

Closed MaxMustermann2 closed 3 months ago

MaxMustermann2 commented 4 months ago

When a query command for the x/assets or the x/delegation module is received, the input should be sanitized before execution.

Fixes #66

Example: all lowercase

$ exocored query delegation QueryDelegationInfo 0x3e108c058e8066da635321dc3018294ca82ddedf_0x65 0xdac17f958d2ee523a2206206994597c13d831ec7_0x65
delegation_infos:
  exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph:
    undelegatable_share: "5000.000000000000000000"
    wait_undelegation_amount: "0"

Example: random case

$ exocored query delegation QueryDelegationInfo 0x3E108C058e8066da635321dc3018294ca82ddedf_0x65 0xdac17f958d2ee523A2206206994597c13d831ec7_0x65
delegation_infos:
  exo18cggcpvwspnd5c6ny8wrqxpffj5zmhklprtnph:
    undelegatable_share: "5000.000000000000000000"
    wait_undelegation_amount: "0"
cloud8little commented 3 months ago

Testing.

cloud8little commented 3 months ago

Test passed with https://github.com/ExocoreNetwork/exocore/pull/80/commits/7348e76149a9d0aff087ab09cade903a250f6787.

Test cases:

exocored q assets QueStakerAssetInfos 0x0B34c4D876cd569129CF56baFAbb3F9E97A4fF42_0x9ce1 --node http://localhost:20000
asset_infos:
  0x83e6850591425e3c1e263c054f4466838b9bd9e4_0x9ce1:
    total_deposit_amount: "2000000000000000000000"
    wait_unbonding_amount: "0"
    withdrawable_amount: "0"

exocored q assets QueStakerSpecifiedAssetAmount 40161 0x0B34c4D876cd569129CF56baFAbb3F9E97A4fF42 0x83e6850591425e3c1e263c054f4466838b9bd9e4  --node http://localhost:20000
total_deposit_amount: "2000000000000000000000"
wait_unbonding_amount: "0"
withdrawable_amount: "0"

exocored q assets QueStakingAssetInfo 0x83E6850591425e3C1E263c054f4466838B9Bd9e4 40161 --node http://localhost:20000
asset_basic_info:
  address: 0x83E6850591425e3C1E263c054f4466838B9Bd9e4
  decimals: 18
  exocore_chain_index: "0"
  layer_zero_chain_id: "40161"
  meta_info: Exocore testnet ETH
  name: exoETH
  symbol: exoETH
  total_supply: "10000000000000000000000000000000000"
staking_total_amount: "10000000000000000000000"

exocored query assets QueOperatorSpecifiedAssetAmount operatorAddr clientChainID assetAddr [flags]

operator_acc_addrs:
- exo13hasr43vvq8v44xpzh0l6yuym4kca98f87j7ac
- exo1c5x7mxphvgavjhu0au9jjqnfqcyspevtyy27mz
- exo1u25udsfm5wu3h5s5xqayf6jjycy2etwyfctk5w
- exo1uw7n7xqxj2hmk5dlw92as6s7se5mmkafuwx982
- exo1lzf5247us2xwhg29mutpx5gyq4aemwqgc08ev7

exocored q assets QueOperatorSpecifiedAssetAmount exo1c5x7mxphvgavjhu0au9jjqnfqcyspevtyy27mz 40161 0x83E6850591425e3C1E263c054f4466838B9Bd9e4 --node http://localhost:20000
operator_amount: "0"
operator_share: "0.000000000000000000"
operator_unbonding_amount: "0"
total_amount: "2750000000000000000000"
total_share: "2750000000000000000000.000000000000000000"
wait_unbonding_amount: "0"

exocored q delegation QueryDelegationInfo 0x0B34c4D876cd569129CF56baFAbb3F9E97A4fF42_0x9ce1 0x83E6850591425e3C1E263c054f4466838B9Bd9e4_0x9ce1 --node http://localhost:20000
delegation_infos:
  exo1lzf5247us2xwhg29mutpx5gyq4aemwqgc08ev7:
    undelegatable_share: "300000000000000000000.000000000000000000"
    wait_undelegation_amount: "0"
  exo1u25udsfm5wu3h5s5xqayf6jjycy2etwyfctk5w:
    undelegatable_share: "1500000000000000000000.000000000000000000"
    wait_undelegation_amount: "0"
  exo1uw7n7xqxj2hmk5dlw92as6s7se5mmkafuwx982:
    undelegatable_share: "200000000000000000000.000000000000000000"
    wait_undelegation_amount: "0"

exocored q delegation QuerySingleDelegationInfo 40161 0x0B34c4D876cd569129CF56baFAbb3F9E97A4fF42 0x83E6850591425e3C1E263c054f4466838B9Bd9e4 exo1u25udsfm5wu3h5s5xqayf6jjycy2etwyfctk5w --node http://loca
lhost:20000
undelegatable_share: "1500000000000000000000.000000000000000000"
wait_undelegation_amount: "0"