polkadot-js / api

Promise and RxJS APIs around Polkadot and Substrate based chains via RPC calls. It is dynamically generated based on what the Substrate runtime provides in terms of metadata.
Apache License 2.0
1.07k stars 350 forks source link

api.derive.crowdloan.contributions: Expected hex value to convert, found '0x' #4981

Closed gdnathan closed 2 years ago

gdnathan commented 2 years ago

Context:

I'm trying to fetch datas from an ended crowdloan. The crowdloan is on kusama, for parachain id 2113.

installed api with:

yarn add @polkadot/api

So, I first connect:

import { ApiPromise, WsProvider } from '@polkadot/api';

async function connect() {
    let endpoint = config.endpoint;
        global.endpoint = endpoint;
        const provider = new WsProvider('wss://kusama-rpc.polkadot.io');
        const api = await ApiPromise.create({
            provider,
        });
        return api;
}

then fetch the addresses of the users that contributed:

async function fetchCrowdloan() {
    try {
        const api = await connect();

        console.log(await api.derive.crowdloan.contributions(2113))
        process.exit(0)
        // other stuff
    } catch (error) {
        console.log(error)
        process.exit(1)
    }
}

fetchCrowdloan()

Yesterday, when i ran my script, an array of the 478 users i expected to be here, was logged in the terminal. I closed my PC, went to sleep, and this morning, it doesn't work anymore, I get this error when running node myscript.js:

2022-06-23 12:27:51        RPC-CORE: getKeysPaged(childKey: PrefixedStorageKey, prefix: StorageKey, count: u32, startKey?: StorageKey, at?: Hash): Vec<StorageKey>:: creat
eType(StorageKey):: Expected hex value to convert, found '0x'
2022-06-23 12:27:51             DRR: createType(StorageKey):: Expected hex value to convert, found '0x'
Error: createType(StorageKey):: Expected hex value to convert, found '0x'
    at createTypeUnsafe (/home/erudyx/work/rusty-crewmates/polkadot/kusama-crowdloan-snapshot/node_modules/@polkadot/types-create/cjs/create/type.js:73:18)
    at TypeRegistry.createTypeUnsafe (/home/erudyx/work/rusty-crewmates/polkadot/kusama-crowdloan-snapshot/node_modules/@polkadot/types/cjs/create/registry.js:333:46)
    at /home/erudyx/work/rusty-crewmates/polkadot/kusama-crowdloan-snapshot/node_modules/@polkadot/rpc-core/cjs/bundle.js:395:50
    at Array.map (<anonymous>)
    at RpcCore._formatInputs (/home/erudyx/work/rusty-crewmates/polkadot/kusama-crowdloan-snapshot/node_modules/@polkadot/rpc-core/cjs/bundle.js:395:19)
    at callWithRegistry (/home/erudyx/work/rusty-crewmates/polkadot/kusama-crowdloan-snapshot/node_modules/@polkadot/rpc-core/cjs/bundle.js:252:27)
    at Observable._subscribe (/home/erudyx/work/rusty-crewmates/polkadot/kusama-crowdloan-snapshot/node_modules/@polkadot/rpc-core/cjs/bundle.js:266:9)
    at Observable._trySubscribe (/home/erudyx/work/rusty-crewmates/polkadot/kusama-crowdloan-snapshot/node_modules/rxjs/dist/cjs/internal/Observable.js:41:25)
    at /home/erudyx/work/rusty-crewmates/polkadot/kusama-crowdloan-snapshot/node_modules/rxjs/dist/cjs/internal/Observable.js:35:31
    at Object.errorContext (/home/erudyx/work/rusty-crewmates/polkadot/kusama-crowdloan-snapshot/node_modules/rxjs/dist/cjs/internal/util/errorContext.js:22:9)

How can i solve it ? All of the other calls are working fine, it's really just the contribution() function

polkadot-js-bot commented 2 years ago

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.