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

Account Class Hash in wallet_addStarknetChain #2132

Open
rsodre opened this issue Apr 3, 2024 · 0 comments
Open

Account Class Hash in wallet_addStarknetChain #2132

rsodre opened this issue Apr 3, 2024 · 0 comments

Comments

@rsodre
Copy link

rsodre commented Apr 3, 2024

Hello,

I'm adding a custom network (local and L3) to ArgentX from my dapp using wallet_addStarknetChain.
There is no specification for account class hash in AddStarknetChainParameters, but it is important to specify it.

Trying to pass accountClassHash or classHash does not have any effect (just being hopeful...):

const params = {
  "id": "LOCAL_KATANA",
  "chainId": "LOCAL_KATANA",
  "chainName": "Katana Local",
  "baseUrl": "http://localhost:5050",
  "rpcUrl": "http://localhost:5050",
  "rpcUrls": ["http://localhost:5050"],
  "nativeCurrency": {
    "address": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
    "name": "Ether",
    "symbol": "ETH",
    "decimals": 18
  },
  "accountClassHash": "0x029927c8af6bccf3f6fda035981e765a7bdbf18a2dc0d630494f8758aa908e2b",
  "classHash": "0x029927c8af6bccf3f6fda035981e765a7bdbf18a2dc0d630494f8758aa908e2b"
}
window?.starknet?.request({ type: 'wallet_addStarknetChain', params })

Looking at ArgentX source code, it looks like you should accept the class hash in accountImplementation, but it results a strangeZodError. But something is happening! Only bugged, it seems

https://github.com/argentlabs/argent-x/blob/main/packages/extension/src/inpage/requestMessageHandlers/addStarknetChain.ts#L6-L22

const params = {
  "id": "LOCAL_KATANA",
  "chainId": "LOCAL_KATANA",
  "chainName": "Katana Local",
  "baseUrl": "http://localhost:5050",
  "rpcUrl": "http://localhost:5050",
  "rpcUrls": ["http://localhost:5050"],
  "nativeCurrency": {
    "address": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
    "name": "Ether",
    "symbol": "ETH",
    "decimals": 18
  },
  "accountImplementation": "0x029927c8af6bccf3f6fda035981e765a7bdbf18a2dc0d630494f8758aa908e2b"
}
window?.starknet?.request({ type: 'wallet_addStarknetChain', params })

the error...

[
  {
    "code": "invalid_union",
    "unionErrors": [
      {
        "issues": [
          {
            "code": "invalid_type",
            "expected": "object",
            "received": "string",
            "path": [
              "accountClassHash"
            ],
            "message": "Expected object, received string"
          }
        ],
        "name": "ZodError"
      },
      {
        "issues": [
          {
            "code": "invalid_type",
            "expected": "undefined",
            "received": "string",
            "path": [
              "accountClassHash"
            ],
            "message": "Expected undefined, received string"
          }
        ],
        "name": "ZodError"
      }
    ],
    "path": [
      "accountClassHash"
    ],
    "message": "Invalid input"
  }
]
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

No branches or pull requests

1 participant