Description
- Bug report
- What is the current behavior and expected behavior?
If I create this basic example ltfschoen/open-polkadot-js-library@81a0fe8, where I'm specifically using the latest @polkadot/api version 15.2.1, and @polkadot/keyring version 13.3.1, the README file for the keyring here https://github.com/polkadot-js/common/blob/v13.3.1/packages/keyring/README.md#usage says to import it with import Keyring from '@polkadot/keyring';
, but if I do that it gives error:
Type 'typeof import("/>path>/open-polkadot-js-library/packages/example/node_modules/@polkadot/api/index")' has no construct signatures.
21 const keyring = new Keyring({ type: 'sr25519' });
So I think that README should be changed to be as shown in https://polkadot.js.org/docs/api/examples/promise/make-transfer, where you import it with `import { Keyring } from '@polkadot/keyring';
**UPDATE** Actually, I'm not sure what I changed, but now I can access it successfully using both `import Keyring from '@polkadot/keyring';` and ``import { Keyring } from '@polkadot/keyring';`
I've created a PR here https://github.com/polkadot-js/common/pull/1970 for that.
But if I import it that way so I can use the `Keyring` constructor, and follow this basic example https://polkadot.js.org/docs/api/examples/promise/listen-to-balance-change of checking the balance of an account by providing their SS58 address string as an argument:
let { data: { free: previousFree }, nonce: previousNonce }
= await api.query.system.account('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY');
It outputs error:
src/index.ts:30:9 - error TS2339: Property 'data' does not exist on type 'Codec'.
30 let { data: { free: previousFree }, nonce: previousNonce } = await api.query.system.account('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY');
~~~~
And if I check the response it outputs:
let res = await api.query.system.account('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY');
console.log(res.toJSON());
It outputs `{nonce: 0, consumers: 0, providers: 0, sufficients: 0, data: {…}}`
I can access the values of `nonce` and `data` as follows:
let res = await api.query.system.account(account.address);
console.log(JSON.parse(res.toString()).data);
But why doesn't it work if I just run it the way it is shown in the example:
let { data: { free: previousFree }, nonce: previousNonce }
= await api.query.system.account('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY');
* **Please tell us about your environment:**
- Version: Sonoma 14.5
- Environment: macOS
- [X] Node.js
- [ ] Browser
- [ ] Other (limited support for other environments)
- Language:
- [ ] JavaScript
- [X] TypeScript (include tsc --version)
- [ ] Other