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

Cannot construct proper call #2

Open
vikiival opened this issue Nov 9, 2024 · 1 comment
Open

Cannot construct proper call #2

vikiival opened this issue Nov 9, 2024 · 1 comment

Comments

@vikiival
Copy link

vikiival commented Nov 9, 2024

Context

I am trying to compose a dummy identity.setIdentity call

     const call = api.tx.identity.setIdentity({
        display: {
          type: "Raw",
          value: formData.displayName,
        },
        email: {
          type: "Raw",
          value: formData.email,
        },
        additional: [
          [{
            type: "Raw",
            value: "discord",
          },
          {
            type: "Raw",
            value: "Open Hack Dedot",
          }]
        ],
        legal: {
          type: "None",
        },
        web: {
          type: "None",
        },
        riot: {
          type: "None",
        },
        image: {
          type: "None",
        },
        twitter: {
          type: "None",
        }
      })

However based on the types everything is correct but the call results in the fail

UserForm.tsx:92 Error: TypeError: Cannot read properties of undefined (reading 'type')
    at Object.encode (dedot.js?v=49664071:3591:15)
    at Shape.subEncode (dedot.js?v=49664071:2310:43)
    at Shape.subEncode (dedot.js?v=49664071:1640:14)
    at dedot.js?v=49664071:1692:14
    at Array.forEach (<anonymous>)
    at Shape.subEncode (dedot.js?v=49664071:1691:13)
    at Shape.subEncode (dedot.js?v=49664071:1640:14)
    at dedot.js?v=49664071:1692:14
    at Array.forEach (<anonymous>)
    at Shape.subEncode (dedot.js?v=49664071:1691:13)

When I try the simpler call like remark

const call = api.tx.system.remark(formData.displayName)

I am able to create a proper tx

@sinzii
Copy link
Member

sinzii commented Nov 9, 2024

Hey @vikiival, thanks for raising the question.

  1. What is the chain that you're connecting to to set the identity. Different chain might have different types for the identity pallet. So e.g if you're connecting to Westend you might want to use WestendApi when constructing the client.
import { DedotClient, WsProvider } from 'dedot';
import { WestendApi } from '@dedot/chaintypes';
import { WESTEND } from './networks.ts';

// initialize the client and connect to the network
const client = new DedotClient<WestendApi>(new WsProvider(WESTEND.endpoint));
await client.connect();

// OR via static factory
const client = await DedotClient.new<WestendApi>(new WsProvider(WESTEND.endpoint));
  1. You might want to update the @dedot/chaintypes package to the latest version so the types will be updated as well to reflect the latest metadata changes.
  2. You might also want to update dedot package to the latest version as well.

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

2 participants