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

Opaque error when running build:typesBundle #10904

Open
3 of 10 tasks
timbrinded opened this issue Sep 9, 2024 · 1 comment
Open
3 of 10 tasks

Opaque error when running build:typesBundle #10904

timbrinded opened this issue Sep 9, 2024 · 1 comment
Labels
Help Wanted Tasks open for external contributions, suitable for independent or collaborative work. P4 - Needs Investigation Requires analysis to determine cause or feasibility. Not fully understood, needs research first.

Comments

@timbrinded
Copy link

  • I'm submitting a ...

    • Bug report
    • Feature request
    • Support request
    • Other
  • What is the current behavior and expected behavior?

In developing the storage hub chain, we have been testing against a pre-release typesbundle. The PolkadotJS app has been rejecting latest versions of the storage-hub.

The @polkadot/dev process is very idiosyncratic so not apparent what is failing or why.

❯ yarn build:typesBundle
$ polkadot-dev-run-test --env node --loader extensionless typesBundle
$ /home/tim/.nvm/versions/node/v20.14.0/bin/node --no-warnings --enable-source-maps --loader extensionless --require @polkadot/dev-test/node --loader @polkadot/dev-ts/cached /home/tim/workspace/pjs-ui/node_modules/@polkadot/dev/scripts/polkadot-exec-node-test.mjs packages/apps-config/src/api/typesBundle.spec.ts packages/apps-config/src/api/typesBundleCheck.spec.ts

    0:00.000  xx

         x /home/timbo/workspace/pjs-ui/packages/apps-config/src/api/typesBundle.spec.ts
           packages/apps-config/src/api/typesBundle.spec.ts

                 testCodeFailure / ERR_TEST_FAILURE

         x /home/timbo/workspace/pjs-ui/packages/apps-config/src/api/typesBundleCheck.spec.ts
           packages/apps-config/src/api/typesBundleCheck.spec.ts

                 testCodeFailure / ERR_TEST_FAILURE

          passed :: 0
          failed :: 2
         skipped :: 0
            todo :: 0
           total :: 2
         elapsed :: 2.430s



        tests 2
        suites 0
        pass 0
        fail 2
        cancelled 0
        skipped 0
        todo 0
        duration_ms 2428.100591

Caution

No indication or why it is failing or how to fix it. Adding console.log() steps similarly don't appear to do anything.

  • What is the motivation for changing the behavior?

So that latest runtimeApi and RPC methods can be used on the FE

  • Please tell us about your environment:

Package: @storagehub/types-bundle : 0.1.4

Node 20 & 22

  • Version:

  • Environment:

    • Node.js
    • Browser
    • Other (limited support for other environments)
  • Language:

    • JavaScript
    • TypeScript (include tsc --version)
    • Other
@timbrinded
Copy link
Author

TBH this code can almost entirely be ripped out. I've rewritten the test spec as a normal script, and just run it with tsx.

// Copyright 2017-2024 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0

import fs from 'node:fs';

import { objectSpread } from '@polkadot/util';

import chain from './chain/index.js';
import spec from './spec/index.js';

const specEntries = Object.entries(spec);
const chainEntries = Object.entries(chain);
const typesBundle: { chain: Record<string, unknown>, spec: Record<string, unknown> } = { chain: {}, spec: {} };

// Process specs
for (const [k, v] of specEntries) {
  const value = objectSpread<{ derives: unknown }>({}, v);

  delete value.derives;
  typesBundle.spec[k] = value;
}

// Process chains
for (const [k, v] of chainEntries) {
  const value = objectSpread<{ derives: unknown }>({}, v);

  delete value.derives;
  typesBundle.chain[k] = value;
}

// Generate the typesBundle.ts file
const content = `// Copyright 2017-2024 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0

// Do not edit, auto-generated by @polkadot/apps-config

import type { OverrideBundleType } from '@polkadot/types/types';

/* eslint-disable quotes */
/* eslint-disable quote-props */
/* eslint-disable sort-keys */

export const typesBundle = ${JSON.stringify(typesBundle, null, 2)} as unknown as OverrideBundleType;
`;

fs.writeFileSync('packages/apps-config/src/api/typesBundle.ts', content);

console.log('typesBundle.ts has been generated successfully.');

run with: yarn tsx packages/apps-config/src/api/bundleGen.ts

@TarikGul TarikGul added P4 - Needs Investigation Requires analysis to determine cause or feasibility. Not fully understood, needs research first. Help Wanted Tasks open for external contributions, suitable for independent or collaborative work. labels Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted Tasks open for external contributions, suitable for independent or collaborative work. P4 - Needs Investigation Requires analysis to determine cause or feasibility. Not fully understood, needs research first.
Projects
Status: P4 - Needs Investigation
Development

No branches or pull requests

2 participants