Skip to content
This repository was archived by the owner on Sep 30, 2021. It is now read-only.
This repository was archived by the owner on Sep 30, 2021. It is now read-only.

Getting an error when calling setKeys #82

@ansonla3

Description

@ansonla3

Environment: Nodejs@v12.8.1

const { importPrivateKey, session } = require('@substrate/txwrapper');

const metadataRpc = require('@polkadot/metadata/Metadata/v10/static');
const address = importPrivateKey('0xb58db8423c16f1cc6037125221aec3cc25e7943b5e805bfe43b172993eab475c').address;

const baseTxInfo = {
  address: 'HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F', // seed "//Alice"
  blockHash:
    '0x1fc7493f3c1e9ac758a183839906475f8363aafb1b1d3e910fe16fab4ae1b582',
  blockNumber: 4302222,
  genesisHash:
    '0xe3777fa922cafbff200cadeaea1a76bd7898ad5b89f7848999058b50e715f636',
  metadataRpc,
  nonce: 1,
  specVersion: 1019,
  tip: 0,
  validityPeriod: 240 * 60
};

const newSessionKeys = '0xc789db36a43045f3a841f1e89f466196b987a6187dc723ec57b1d32957d927e038d7228cc027c07e5a87ff165c9f977b97578f10663f9b13ceb566ea96fa634a64ea351696ba1c8f7b8264c041c1b64ec1f5ab6b9c8b62acf94147d0ef31406c8a8bf532abebae1c03cb5731f0492f1b6cce91d827019f55b34ba868d9b8fc445cf5b6d3752b30643456c50b620eb46f21155809c5f8f550ee7ff1df0e50a355';

console.log(session.setKeys(newSessionKeys, baseTxInfo));

Output:

node index.js
/Users/anson/offline-tx/node_modules/@substrate/txwrapper/node_modules/@polkadot/types/known/index.js:45
  specName,
  ^

TypeError: Cannot destructure property `specName` of 'undefined' or 'null'.
    at Object.getSpecTypes (/Users/anson/offline-tx/node_modules/@substrate/txwrapper/node_modules/@polkadot/types/known/index.js:44:45)
    at Object.getRegistry (/Users/anson/offline-tx/node_modules/@substrate/txwrapper/lib/util/registry.js:21:31)
    at Object.createMethod (/Users/anson/offline-tx/node_modules/@substrate/txwrapper/lib/util/method.js:35:33)
    at Object.setKeys (/Users/anson/offline-tx/node_modules/@substrate/txwrapper/lib/methods/session/setKeys.js:11:19)
    at Object.<anonymous> (/Users/anson/offline-tx/index.js:22:21)
    at Module._compile (internal/modules/cjs/loader.js:868:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:879:10)
    at Module.load (internal/modules/cjs/loader.js:731:32)
    at Function.Module._load (internal/modules/cjs/loader.js:644:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:931:10)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions