Skip to content

[Bug] walletConnect createOfferForIds Incorrectly identifies CATs as NFTs when using Asset ID #2647

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

Open
BrandtH22 opened this issue Apr 8, 2025 · 6 comments · May be fixed by #2655
Open
Assignees
Labels
bug Something isn't working

Comments

@BrandtH22
Copy link
Contributor

BrandtH22 commented Apr 8, 2025

What happened?

When sending a create offer for ids request via walletConnect, cats are identified as NFTs rather than as CATs when using the CATs asset id (the standard CLI and RPC commands default to CATs and this behavior is different). This issue persists when the driver dict is added.

Current workaround is to first query the wallet with getWallets to identify the wallet ID associated with the CAT then run the createOfferForIds command using the wallet ID in place of the assetID. If the cat is not yet added to the wallet then one first needs to add it with the walletConnect command chia_addCATToken then run getWallets to get its wallet ID.

An example payload that was used with the example dApp to reproduce the user reported issue:
Offer:

{"1":1000,"0x0f921c8585d3fea928cab803d050a8b7252705859ba2e0661f15634cec1fd9ab":-1}

Workaround offer payload using walletID 5 as an example (this will correctly identify the cat at that walletID):

{"1":1000,"5":-1}

Driver Dict:

{
  "0x0f921c8585d3fea928cab803d050a8b7252705859ba2e0661f15634cec1fd9ab":
  {
    "type": "cat",
    "tail": "0x0f921c8585d3fea928cab803d050a8b7252705859ba2e0661f15634cec1fd9ab"
  }
}

Example full payload from user who initially reported the issue:

{
  "chainId": "chia:mainnet",
  "request": {
    "method": "chia_createOfferForIds",
    "params": {
      "offer": {
        "1": 329563080000,
        "79f6313fdb6ba66347a5bcad4af6878ac07bf5fafedeb384c3b350d913c8b6b6": -1830906
      },
      "fee": 0,
      "driverDict": {},
      "validateOnly": true,
      "disableJSONFormatting": true
    }
  }
}

Issue reported by palvit | DeFi Geeks in discord (https://discord.com/channels/1034523881404370984/1034870571864948777/1358929424522805469)

Version

2.5.3 but also occurs in earlier versions (earliest tested was 2.3.0)

What platform are you using?

Windows

What ui mode are you using?

GUI

Relevant log output or stacktrace

@BrandtH22 BrandtH22 added the bug Something isn't working label Apr 8, 2025
@BrandtH22 BrandtH22 changed the title [Bug] walletConnect createOfferForIds Incorrectly identifies CATs as NFTs [Bug] walletConnect createOfferForIds Incorrectly identifies CATs as NFTs when using Asset ID Apr 8, 2025
@ChiaMineJP ChiaMineJP self-assigned this Apr 12, 2025
@ChiaMineJP
Copy link
Contributor

"type": "cat" is incorrect. "cat" must be "CAT" in order to be recognized as a CAT token.

{
  "0x0f921c8585d3fea928cab803d050a8b7252705859ba2e0661f15634cec1fd9ab":
  {
    "type": "cat", # <-- This should be "CAT". (All capital)
    "tail": "0x0f921c8585d3fea928cab803d050a8b7252705859ba2e0661f15634cec1fd9ab"
  }
}

Image

@ChiaMineJP
Copy link
Contributor

Also, you should avoid empty driver_dict like {} in order for the requesting asset to be recognized as CAT.
You need to remove driver_dict from the JSON payload.

Image

@BrandtH22
Copy link
Contributor Author

"type": "cat" is incorrect. "cat" must be "CAT" in order to be recognized as a CAT token.

{
"0x0f921c8585d3fea928cab803d050a8b7252705859ba2e0661f15634cec1fd9ab":
{
"type": "cat", # <-- This should be "CAT". (All capital)
"tail": "0x0f921c8585d3fea928cab803d050a8b7252705859ba2e0661f15634cec1fd9ab"
}
}

Image

I have tried both lowercase and capital CAT neither result in the walletConnect payload being identified as a cat and in all cases except for using the walletID the cat is identified as an NFT.

Image

Image

@ChiaMineJP
Copy link
Contributor

I'll further look into this issue as soon as I can.

@BrandtH22
Copy link
Contributor Author

Thank you!

@ChiaMineJP
Copy link
Contributor

I found the root cause here.
https://github.com/Chia-Network/chia-blockchain-gui/blob/main/packages/gui/src/util/createOfferForIdsToOfferBuilderData.ts#L41-L44

When an asset is unknown, it is identified as an NFT in the GUI, which behaves differently from the CLI/RPC.
I'm creating a PR to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants