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

Fix: fix issue 801 account udts return with native and bridge token #805

Merged

Conversation

Naupio
Copy link
Contributor

@Naupio Naupio commented Jul 31, 2022

summary:
if checking address had some token which type is the bridge(and its mapping native token was exist), will return both native token and bridge token, and their balance values will be the same

env: testnet-stg

error example:
image

expect example:

query {
  account_udts(
    input: { address_hashes: ["0x2454851a9320a0e11a3dd27f0d3585158ea84c94"] }
  ) {
    udt_script_hash
    value
    uniq_id
    udt {
      id
      type
      name
      bridge_account_id
      script_hash
      decimal
      value
    }
    account {
      id
      eth_address
      script_hash
    }
  }
}

result:

{
  "data": {
    "account_udts": [
      {
        "account": {
          "eth_address": null,
          "id": 29407,
          "script_hash": "0x454843ef13a5c57f97270b50bc49ef2d12e35fb7e72a145b0909ba65a5f9bfdd"
        },
        "udt": {
          "bridge_account_id": 40446,
          "decimal": null,
          "id": "29407",
          "name": "USDC (via ForceBridge from ETH)",
          "script_hash": "0x23f7af8acb0f5c0382f2637fe1813cbdcc1fc728be56f889ea8fca7d66180831",
          "type": "BRIDGE",
          "value": null
        },
        "udt_script_hash": "0x454843ef13a5c57f97270b50bc49ef2d12e35fb7e72a145b0909ba65a5f9bfdd",
        "uniq_id": 40446,
        "value": "38991000000"
      },
      {
        "account": {
          "eth_address": "0x20fb98bb94ad9b98c0f0089138012e49323d0fef",
          "id": 40446,
          "script_hash": "0xf4d317748f716b4a7c25b4b31f79ad424ef5c4e481c967a9ac7d70bbf6a3b1d7"
        },
        "udt": {
          "bridge_account_id": null,
          "decimal": 6,
          "id": "40446",
          "name": "USDC (via ForceBridge from ETH)",
          "script_hash": null,
          "type": "NATIVE",
          "value": null
        },
        "udt_script_hash": null,
        "uniq_id": 40446,
        "value": "38991000000"
      },
      {
        "account": {
          "eth_address": null,
          "id": 29378,
          "script_hash": "0xf864e1aecdec0ca2ebc8762034e1b4b318ad8a49a73db20069f873ddf6759312"
        },
        "udt": {
          "bridge_account_id": 40445,
          "decimal": null,
          "id": "29378",
          "name": "DAI (via ForceBridge from ETH)",
          "script_hash": "0x938bfcf98a741c84055386a230c0a056913c3cac11c15fd520dabc23172f62e5",
          "type": "BRIDGE",
          "value": null
        },
        "udt_script_hash": "0xf864e1aecdec0ca2ebc8762034e1b4b318ad8a49a73db20069f873ddf6759312",
        "uniq_id": 40445,
        "value": "39998000000000000000000"
      },
      {
        "account": {
          "eth_address": "0x24a9467fd390d8ca70e848ce8a2e9bbe087eab0e",
          "id": 40445,
          "script_hash": "0x5d14afbcf42209abc80f41d4f5532b7a2f477ae167f8173b205bfcfb06bda4bd"
        },
        "udt": {
          "bridge_account_id": null,
          "decimal": 18,
          "id": "40445",
          "name": "DAI (via ForceBridge from ETH)",
          "script_hash": null,
          "type": "NATIVE",
          "value": null
        },
        "udt_script_hash": null,
        "uniq_id": 40445,
        "value": "39998000000000000000000"
      },
      {
        "account": {
          "eth_address": "0x90fc553abad2b8b6ffe9282e36db52ce6388c648",
          "id": 40447,
          "script_hash": "0xf89626a72e17818405dcbd03bedd8ece00ad0af9a08d5035e3ad8fd51211d5e2"
        },
        "udt": {
          "bridge_account_id": null,
          "decimal": 6,
          "id": "40447",
          "name": "USDT (via ForceBridge from ETH)",
          "script_hash": null,
          "type": "NATIVE",
          "value": null
        },
        "udt_script_hash": null,
        "uniq_id": 40447,
        "value": "40000000000"
      },
      {
        "account": {
          "eth_address": null,
          "id": 29406,
          "script_hash": "0xd907349338fae71918f2078677b1f92259b9df2548fbce83b24d37a60825ae6a"
        },
        "udt": {
          "bridge_account_id": 40447,
          "decimal": null,
          "id": "29406",
          "name": "USDT (via ForceBridge from ETH)",
          "script_hash": "0x907d01da7ff3fa24bd9ef647f05f0b97a0f1c0f705ebce2b4d6d915d6895d317",
          "type": "BRIDGE",
          "value": null
        },
        "udt_script_hash": "0xd907349338fae71918f2078677b1f92259b9df2548fbce83b24d37a60825ae6a",
        "uniq_id": 40447,
        "value": "40000000000"
      }
    ]
  }
}

link issue: #801

@Naupio Naupio requested review from zmcNotafraid and Keith-CY July 31, 2022 15:29
@Keith-CY
Copy link
Member

Please elaborate on the issue this PR is going to treat so we don't have to view it in another issue. Of course, appending a ref link to the original issue is recommended for tracing.

Take pr in neuron as an example nervosnetwork/neuron#2454

@Naupio Naupio self-assigned this Aug 2, 2022
@Naupio Naupio linked an issue Aug 3, 2022 that may be closed by this pull request
@Naupio Naupio force-pushed the issue-801-testnet branch from 59c91c9 to fce6b04 Compare August 3, 2022 07:40
@coveralls
Copy link
Collaborator

coveralls commented Aug 3, 2022

Pull Request Test Coverage Report for Build fce6b04076c772971441c66fb17cc0c3d0b49565-PR-805

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 8 of 8 (100.0%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.3%) to 25.525%

Files with Coverage Reduction New Missed Lines %
lib/godwoken_explorer/graphql/resolovers/account_udt.ex 4 86.17%
Totals Coverage Status
Change from base Build ccd682fcd0bcb0a459da8768491465e32864af2d-PR-822: 0.3%
Covered Lines: 1204
Relevant Lines: 4717

💛 - Coveralls

@Naupio Naupio force-pushed the issue-801-testnet branch from fce6b04 to 2eae111 Compare August 3, 2022 10:47
@Naupio Naupio force-pushed the issue-801-testnet branch from 2eae111 to aca0dbc Compare August 3, 2022 10:54
@Naupio Naupio merged commit 6b8a732 into Magickbase:godwoken-v1-testnet-prod Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

graphql: fix account udt return native and bridge token
4 participants