Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: url encoded characters are not properly handled in contract_by_denom #1560

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

* [#1520](https://github.com/crypto-org-chain/cronos/pull/1520) Avoid invalid chain id for signer error when rpc call before chain id set in BeginBlock.
* [#1539](https://github.com/crypto-org-chain/cronos/pull/1539) Fix go-block-stm bug that causes app hash mismatch.
* [#1560](https://github.com/crypto-org-chain/cronos/pull/1560) Update queries contract addresses by native denom from a query in contract_by_denom.

*Jun 18, 2024*

Expand Down
10 changes: 6 additions & 4 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ info:
description: A REST interface for state queries
version: 1.0.0
paths:
/cronos/v1/contract_by_denom/{denom}:
/cronos/v1/contract_by_denom:
get:
summary: ContractByDenom queries contract addresses by native denom
summary: >-
ContractByDenom queries contract addresses by native denom from a query
string.
operationId: ContractByDenom
responses:
'200':
Expand Down Expand Up @@ -217,8 +219,8 @@ paths:
}
parameters:
- name: denom
in: path
required: true
in: query
required: false
type: string
tags:
- Query
Expand Down
4 changes: 4 additions & 0 deletions integration_tests/configs/genesis_token_mapping.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ config {
denom: 'gravity0x0000000000000000000000000000000000000000',
contract: '0x68542BD12B41F5D51D6282Ec7D91D7d0D78E4503',
},
{
denom: 'ibc/6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD5D19762F541EC971ACB0865',
contract: '0x0000000000000000000000000000000000000000',
},
],
auto_contracts: [
{
Expand Down
29 changes: 24 additions & 5 deletions integration_tests/test_exported_genesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from pathlib import Path

import pytest
import requests
from pystarport import ports

from .network import setup_custom_cronos
from .utils import ADDRS, CONTRACTS
Expand Down Expand Up @@ -29,8 +31,25 @@ def test_exported_contract(custom_cronos):

def test_exported_token_mapping(custom_cronos):
cli = custom_cronos.cosmos_cli(0)
rsp = cli.query_contract_by_denom(
"gravity0x0000000000000000000000000000000000000000"
)
assert rsp["contract"] == "0x68542BD12B41F5D51D6282Ec7D91D7d0D78E4503"
assert rsp["auto_contract"] == "0x68542BD12B41F5D51D6282Ec7D91D7d0D78E4503"
port = ports.api_port(custom_cronos.base_port(0))
for case in [
{
"denom": "gravity0x0000000000000000000000000000000000000000",
"expected": {
"contract": "0x68542BD12B41F5D51D6282Ec7D91D7d0D78E4503",
"auto_contract": "0x68542BD12B41F5D51D6282Ec7D91D7d0D78E4503",
},
},
{
"denom": "ibc/6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD5D19762F541EC971ACB0865", # noqa: E501
"expected": {
"contract": "0x0000000000000000000000000000000000000000",
"auto_contract": "",
},
},
]:
denom = case["denom"]
expected = case["expected"]
assert cli.query_contract_by_denom(denom) == expected
url = f"http://127.0.0.1:{port}/cronos/v1/contract_by_denom?denom={denom}"
assert requests.get(url).json() == expected
4 changes: 2 additions & 2 deletions proto/cronos/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ option go_package = "github.com/crypto-org-chain/cronos/v2/x/cronos/types";

// Query defines the gRPC querier service.
service Query {
// ContractByDenom queries contract addresses by native denom
// ContractByDenom queries contract addresses by native denom from a query string.
rpc ContractByDenom(ContractByDenomRequest) returns (ContractByDenomResponse) {
option (google.api.http).get = "/cronos/v1/contract_by_denom/{denom}";
option (google.api.http).get = "/cronos/v1/contract_by_denom";
}

// DenomByContract queries native denom by contract address
Expand Down
104 changes: 52 additions & 52 deletions x/cronos/types/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 13 additions & 31 deletions x/cronos/types/query.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading