Open
Description
Describe the bug
Starknet.js is not encoding correctly the type selector
To encode a selector
it needs to be hashed. But the current implementation is not doing the hashing if the name happens to be an hex string.
Because if this, dapps can request signatures using the hash instead of the name obfuscating the real method name, that can put users in danger as they are unable to see the real method name
To Reproduce
It can be reproduces with the following:
{
"types": {
"StarknetDomain": [
{ "name": "name", "type": "shortstring" },
{ "name": "version", "type": "shortstring" },
{ "name": "chainId", "type": "shortstring" },
{ "name": "revision", "type": "shortstring" }
],
"Message": [
{ "name": "Selector", "type": "selector" }
]
},
"primaryType": "Message",
"domain": {
"name": "Starknet.js bug",
"version": "0x31",
"chainId": "0x534e5f5345504f4c4941",
"revision": "1"
},
"message": {
"Selector": "0x1"
}
}
Expected behavior
Starknet.js should always apply the hash on the selector name, regardless of the name
Screenshots
Desktop (please complete the following information):
Node version: 18
Starknet.js version: v6.23.1 (latest)
Additional context