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

(graphql) add new account_udts api for grapqhl #699

Closed
Naupio opened this issue Jul 4, 2022 · 19 comments · Fixed by #698
Closed

(graphql) add new account_udts api for grapqhl #699

Naupio opened this issue Jul 4, 2022 · 19 comments · Fixed by #698
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@Naupio
Copy link
Contributor

Naupio commented Jul 4, 2022

No description provided.

@Naupio Naupio self-assigned this Jul 4, 2022
@Naupio Naupio added enhancement New feature or request documentation Improvements or additions to documentation labels Jul 4, 2022
@Naupio Naupio moved this from QA to In Progress in Nervos Wallet/Explorer Jul 4, 2022
@Naupio Naupio linked a pull request Jul 4, 2022 that will close this issue
@Keith-CY
Copy link
Member

Keith-CY commented Jul 5, 2022

The PR has been merged, could we move this task into QA?

@Naupio Naupio moved this from In Progress to QA in Nervos Wallet/Explorer Jul 5, 2022
@Naupio
Copy link
Contributor Author

Naupio commented Jul 5, 2022

example:

    query {
      account_ckbs(
        input: { address_hashes: ["0x715AB282B873B79A7BE8B0E8C13C4E8966A52040"] }
      ) {
        udt_script_hash
        value
        udt {
          id
          name
          bridge_account_id
          script_hash
          decimal
          value
        }
        account {
          id
          eth_address
          script_hash
        }
      }
    }

    {
      "data": {
        "account_ckbs": [
          {
            "account": {
              "eth_address": null,
              "id": 1,
              "script_hash": "0x595cc14e574a708dc70a320d2026f79374246ed4659261131cdda7dd5814b5ca"
            },
            "udt": {
              "bridge_account_id": 375,
              "decimal": 18,
              "id": "1",
              "name": "pCKB",
              "script_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
              "value": null
            },
            "udt_script_hash": "0x595cc14e574a708dc70a320d2026f79374246ed4659261131cdda7dd5814b5ca",
            "value": "1165507481400061309833"
          }
        ]
      }
    }

@Naupio
Copy link
Contributor Author

Naupio commented Jul 5, 2022

account udt example:

    query {
      account_udts(
        input: {
          address_hashes: ["0x715AB282B873B79A7BE8B0E8C13C4E8966A52040"],

          udt_script_hash: "0x595cc14e574a708dc70a320d2026f79374246ed4659261131cdda7dd5814b5ca"
        }
      ) {
        udt_script_hash
        value
        udt {
          id
          name
          bridge_account_id
          script_hash
          decimal
          value
        }
        account {
          id
          eth_address
          script_hash
        }
      }
    }

    {
      "data": {
        "account_udts": [
          {
            "account": {
              "eth_address": null,
              "id": 1,
              "script_hash": "0x595cc14e574a708dc70a320d2026f79374246ed4659261131cdda7dd5814b5ca"
            },
            "udt": {
              "bridge_account_id": 375,
              "decimal": 18,
              "id": "1",
              "name": "pCKB",
              "script_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
              "value": null
            },
            "udt_script_hash": "0x595cc14e574a708dc70a320d2026f79374246ed4659261131cdda7dd5814b5ca",
            "value": "1165507481400061309833"
          }
        ]
      }
    }

@Keith-CY
Copy link
Member

Keith-CY commented Jul 5, 2022

We will start testing APIs because it's an important service for the community, let's start from this query @FrederLu it's a graphql API request, and feel free to ask about details of each field and its updating mechanism.

@Keith-CY Keith-CY assigned FrederLu and unassigned Naupio Jul 5, 2022
@FrederLu
Copy link

FrederLu commented Jul 5, 2022

Ok, I look at the graphql API information for community services and then ask the API for details of each field and its update mechanism.

@FrederLu
Copy link

FrederLu commented Jul 6, 2022

@Naupio @zmcNotafraid

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

image

image

https://pudge.explorer.nervos.org/transaction/0x8efad8bd75af1b14a9f88a4f068b50e75c73504c1484dbc5d4b7d4753485b47d https://pudge.explorer.nervos.org/transaction/0x0785536dee0b78d9ad93902451900d70b97c0fa8060c68f994948a1dbe92c647

Compared with the information on the metamask, the value of the interface account remains unchanged before the withdrawal operation.

@FrederLu
Copy link

FrederLu commented Jul 7, 2022

image

image

After sending tokens to other accounts, the account amount in the interface does not decrease.

@Keith-CY Keith-CY added this to the 2022/07/06 - 2022/07/13 milestone Jul 7, 2022
@Naupio Naupio self-assigned this Jul 8, 2022
@FrederLu
Copy link

FrederLu commented Jul 11, 2022

@Naupio

	account_udts(
		input: {
			address_hashes: ["0x1a9a8e69246896ac1720c1f407309c142c5c3cdc"]
			udt_script_hash: "0x595cc14e574a708dc70a320d2026f79374246ed4659261131cdda7dd5814b5ca"
		}
	) {
		udt_script_hash
		value
		udt {
			id
			name
			bridge_account_id
			script_hash
			decimal
			value
		}
		account {
			id
			eth_address
			script_hash
		}
	}
}

https://pudge.explorer.nervos.org/transaction/0xccc25d9e3a05df4701879978e4ed57d18c5c04dd9d697cf0bd1a4a516739fd65
image

After operating Withdrawal, the data on nerouns and metamask are displayed and changed, but the interface is not updated.

@Naupio
Copy link
Contributor Author

Naupio commented Jul 11, 2022

seems data source table not updated by withdrawal
#684

{
"account_current_bridged_udt_balances": [
	{
		"id" : 43388,
		"address_hash" : "1A9A8E69246896AC1720C1F407309C142C5C3CDC",
		"account_id" : 46102,
		"udt_script_hash" : "595CC14E574A708DC70A320D2026F79374246ED4659261131CDDA7DD5814B5CA",
		"udt_id" : 1,
		"value" : 2400000000000000000000,
		"value_fetched_at" : null,
		"layer1_block_number" : 5975984,
		"block_number" : null,
		"inserted_at" : "2022-07-06T20:01:22.000Z",
		"updated_at" : "2022-07-10T02:13:52.000Z"
	}
]}
{
"account_current_udt_balances": [
	{
		"id" : 1337148,
		"address_hash" : "1A9A8E69246896AC1720C1F407309C142C5C3CDC",
		"token_contract_address_hash" : "E05D380839F32BC12FB690AA6FE26B00BD982613",
		"udt_id" : null,
		"account_id" : null,
		"value" : 401000000000000000000,
		"value_fetched_at" : "2022-07-06T23:25:56.855Z",
		"block_number" : 169242,
		"inserted_at" : "2022-07-06T23:25:56.000Z",
		"updated_at" : "2022-07-06T23:25:56.000Z"
	}
]}

@Naupio Naupio changed the title (v1) add account_current_udt and account_current_bridged_udt combine api for grapqhl (graphql) add account_current_udt and account_current_bridged_udt combine api for grapqhl Jul 11, 2022
@FrederLu
Copy link

Now the amount of the interface is updated normally after the Deposit/Withdrawal transaction operation, but the service access takes a long time and is unstable.

@Naupio
Copy link
Contributor Author

Naupio commented Jul 18, 2022

seems #684 was fixed, any update here? @FrederLu

@FrederLu
Copy link

seems #684 was fixed, any update here? @FrederLu

@zmcNotafraid @Naupio
Previously, the api will be updated after verifying the Withdrawal/Deposit operation, but it will take a little longer. After operating Withdrawal today, I found that the api has not been updated for a long time, so I need to take a look.

@Naupio
Copy link
Contributor Author

Naupio commented Jul 21, 2022

new api account_udts replace account_current_udt and account_current_bridged_udt
@Keith-CY

@Naupio Naupio changed the title (graphql) add account_current_udt and account_current_bridged_udt combine api for grapqhl (graphql) use account udts for grapqhl Jul 21, 2022
@Naupio
Copy link
Contributor Author

Naupio commented Jul 21, 2022

cc @Keith-CY
fix accout udts api only return one record error and filter udt.name == nil record.
commit: b7d84f7

example:

query {
    account_udts(
        input: { address_hashes: ["0x40dfb7df991c9aa6138a60f0cac6ed1d02b834b8"] }
    ) {
        value
        udt {
            id
            type
            name
            icon
            decimal
            symbol
        }
    }
    account_current_udts(
        input: { address_hashes: ["0x40dfb7df991c9aa6138a60f0cac6ed1d02b834b8"] }
    ) {
        udt {
            name
        }
    		updated_at
        value
    }
    account_current_bridged_udts(
        input: { address_hashes: ["0x40dfb7df991c9aa6138a60f0cac6ed1d02b834b8"] }
    ) {
        udt {
            name
        }
        updated_at
        value
    }

    account_ckbs(
        input: { address_hashes: ["0x40dfb7df991c9aa6138a60f0cac6ed1d02b834b8"] }
    ) {
        udt {
            name
        }
        value
    }
}

return:

{
  "data": {
    "account_ckbs": [
      {
        "udt": {
          "name": "pCKB"
        },
        "value": "2913433910000000000000"
      }
    ],
    "account_current_bridged_udts": [
      {
        "udt": {
          "name": "pCKB"
        },
        "updated_at": "2022-07-13T16:35:26",
        "value": "2913433910000000000000"
      },
      {
        "udt": {
          "name": "Godwoken Bridge Test Token (via GodwokenBridge from CKB)"
        },
        "updated_at": "2022-07-06T16:23:44",
        "value": "100000000000000000000"
      }
    ],
    "account_current_udts": [
      {
        "udt": {
          "name": "pCKB"
        },
        "updated_at": "2022-07-04T05:01:34",
        "value": "1282198940000000000000"
      }
    ],
    "account_udts": [
      {
        "udt": {
          "decimal": 18,
          "icon": "https://cryptologos.cc/logos/nervos-network-ckb-logo.png",
          "id": "1",
          "name": "pCKB",
          "symbol": "pCKB",
          "type": "BRIDGE"
        },
        "value": "2913433910000000000000"
      },
      {
        "udt": {
          "decimal": null,
          "icon": null,
          "id": "80",
          "name": "Godwoken Bridge Test Token (via GodwokenBridge from CKB)",
          "symbol": "TTKN.gw|gb.ckb",
          "type": "BRIDGE"
        },
        "value": "100000000000000000000"
      }
    ]
  }
}

@Naupio Naupio changed the title (graphql) use account udts for grapqhl (graphql) use new account_udts api for grapqhl Jul 21, 2022
@Naupio Naupio changed the title (graphql) use new account_udts api for grapqhl (graphql) add new account_udts api for grapqhl Jul 21, 2022
@FrederLu
Copy link

User Account 0xcc0af0af911dd40853b8c8dfee90b32f8d1ecad6 on the mainnet operates 2 transactions, the amount in the graphql interface still stays at the amount before the transaction.

Image

Image

@Keith-CY
Copy link
Member

Keith-CY commented Aug 3, 2022

Please check this issue @Naupio

@Naupio
Copy link
Contributor Author

Naupio commented Aug 3, 2022

query {
	account_udts(input: {address_hashes: ["0xcc0af0af911dd40853b8c8dfee90b32f8d1ecad6"]}) {
    value
    udt {
      id
      name
      bridge_account_id
    }
  }
}

{
  "data": {
    "account_udts": [
      {
        "udt": {
          "bridge_account_id": null,
          "id": "33",
          "name": "pCKB (via Godwoken Bridge from CKB)"
        },
        "value": "895837040000000000000"
      },
      {
        "udt": {
          "bridge_account_id": 33,
          "id": "1",
          "name": "pCKB (via Godwoken Bridge from CKB)"
        },
        "value": "900000000000000000000"
      },
      {
        "udt": {
          "bridge_account_id": 133,
          "id": "128",
          "name": "YOK (via Godwoken Bridge from CKB)"
        },
        "value": "200000000000000000000"
      }
    ]
  }
}

@Naupio
Copy link
Contributor Author

Naupio commented Aug 3, 2022

bridge token value will be sync when this pr merge https://github.com/Magickbase/godwoken_explorer/pull/805/files

@FrederLu
Copy link

FrederLu commented Aug 9, 2022

Verified.

@FrederLu FrederLu moved this from QA to Production in Nervos Wallet/Explorer Aug 9, 2022
@FrederLu FrederLu moved this from Production to Done in Nervos Wallet/Explorer Aug 9, 2022
@Keith-CY Keith-CY closed this as completed Sep 5, 2022
Repository owner moved this from Done to Production in Nervos Wallet/Explorer Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants