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

Able to create alexander APIRx but not kusama, substratetest in react-native #1379

Closed
turingpavan opened this issue Sep 10, 2019 · 5 comments
Labels

Comments

@turingpavan
Copy link

Can connect and get details for Alexander, hosted by parity and Web3 Foundation

  1. wss://poc3-rpc.polkadot.io/
  2. wss://alex.unfrastructure.io/public/ws
import { ApiRx, WsProvider, ApiPromise } from '@polkadot/api';
 var provider;
 var api;
        try {
            provider = new WsProvider(rpcServer);
            api = await ApiRx.create(provider).toPromise();
        } catch (error) {
            console.log(error);
   }

But the issue is,
Fails in following Wsproviders with below error

  1. Kusama wss://kusama-rpc.polkadot.io/
  2. wss://canary-5.kusama.network/
  3. wss://substrate-rpc.parity.io/

console.error: "2019-09-10 13:04:50", " RPC-CORE:", "getMetadata (block: Hash): Metadata:: U8a: failed on 'MagicNumber':: U8a: failed on 'MetadataEnum':: Unable to create Enum via index 7, in MetadataV0, MetadataV1, MetadataV2, MetadataV3, MetadataV4, MetadataV5"

console.error
7455fce6-615b-432d-a856-c602438c55d6:72976:24
apply
7455fce6-615b-432d-a856-c602438c55d6:537382:25
Object.error
7455fce6-615b-432d-a856-c602438c55d6:537414:16
call$
7455fce6-615b-432d-a856-c602438c55d6:536287:21
tryCatch
7455fce6-615b-432d-a856-c602438c55d6:32250:19
Generator.invoke [as _invoke]
7455fce6-615b-432d-a856-c602438c55d6:32425:24
Generator.prototype. [as next]
7455fce6-615b-432d-a856-c602438c55d6:32293:23
tryCatch
7455fce6-615b-432d-a856-c602438c55d6:32250:19
invoke
7455fce6-615b-432d-a856-c602438c55d6:32326:22

@jacogr
Copy link
Member

jacogr commented Sep 10, 2019

You are on an ancient version of the API, as per the message it doesn't have Metadata version 7 support, your API only has support up to v5. (Alexander is only on v3)

Update your API, the latest stable 0.91.1 was actually released yesterday. (Since your is . very far behind, also take a look at the CHANGELOG and UPGRADING guides for changes)

@jacogr jacogr closed this as completed Sep 10, 2019
@jacogr jacogr added the support label Sep 10, 2019
@turingpavan
Copy link
Author

turingpavan commented Sep 10, 2019 via email

@turingpavan
Copy link
Author

turingpavan commented Sep 10, 2019

Upgraded to 0.91.1
It did load.

       const provider = new WsProvider('wss://poc3-rpc.polkadot.io/');
       const  api = await ApiRx.create({ provider }).toPromise();

Getting the following error on create

Unable to decode Vec on index 0 createType(ExtrinsicV1):: createType(Call):: Calling Call.findFunction before extrinsics have been injected.
RPC-CORE: getBlock (hash: Hash): SignedBlock:: createType(SignedBlock):: Struct: failed on 'block':: Struct: failed on 'extrinsics':: createType(ExtrinsicV1):: createType(Call):: Calling Call.findFunction before extrinsics have been injected.
API/DECORATOR: Error: FATAL: Unable to initialize the API: getBlock (hash: Hash): SignedBlock:: createType(SignedBlock):: Struct: failed on 'block':: Struct: failed on 'extrinsics':: createType(ExtrinsicV1):: createType(Call):: Calling Call.findFunction before extrinsics have been injected.

@turingpavan
Copy link
Author

turingpavan commented Sep 10, 2019

Working fine after clean install watchman watch-del-all && rm package-lock.json && rm -rf node_modules && rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-map-* && NODE_OPTIONS=--max_old_space_size=8192 npm install

But,
header.blockNumber is undefined, header.number gives block numbers instead.

import { ApiRx, WsProvider, ApiPromise } from '@polkadot/api';
 var provider;
 var api;
        try {
            provider = new WsProvider(rpcServer);
            api = await ApiRx.create(provider).toPromise();
        } catch (error) {
            console.log(error);
   }
  api.rpc.chain.subscribeNewHeads().subscribe((header) => {
          console.log(`Chain is at #${header.blockNumber}`);
          console.log(`Chain is at #${header.number}`);
          console.log(`Chain is at #${header}`);
        });

header = {"parentHash":"0xecf52f1796f9f3b50bc92691967ebd6c0d29f07c8aaf17bb6c0fea9a5ee1bb13","number":259454,"stateRoot":"0x3f9e149a64f9531aebd2ce66366c8489ab192d3f45c1e0b2b6d733693746b551","extrinsicsRoot":"0x5a2cb032e3f3ac5af7747e66d6abeda0e70b2dfa5f41067eba1a886501198e39","digest":{"logs":["0x064241424544010300000085f2930f0000000067f60000","0x05424142450101e67bd36607f4ac701db9775f618c159544f589a88d6d7b2d74ba39d0c688b30d452b0c4299ece78df1a58ac472922673d0951b8dd796c85785b4b2b90b7b1881"]}}

@polkadot-js-bot
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.

@polkadot-js polkadot-js locked as resolved and limited conversation to collaborators Jun 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants