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

add new type in api - settings in order to support different types of… #476

Merged
merged 9 commits into from
Jun 15, 2021
Merged

add new type in api - settings in order to support different types of… #476

merged 9 commits into from
Jun 15, 2021

Conversation

wirednkod
Copy link
Member

@wirednkod wirednkod commented Jun 1, 2021

… inputs - 'json-rpc' and 'substrate-connect';

The new format will be:

{ type: 'json-rpc', url: 'ws://someUrl' }

or

{ type: 'substrate-connect', chain: 'available network' }

@wirednkod wirednkod marked this pull request as draft June 1, 2021 12:21
Copy link
Member

@jacogr jacogr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments, I think the enum usage here is related to the fact that non-type import as are now used here. The polkadot-js codebase were cleared from all usage of these quite some time ago (18-25+ months now), they are really problematic when used in a library.

Merge master should fix the CI failures.

import EventEmitter from 'eventemitter3';
import store from 'store';

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

import { CAMERA, CAMERA_DEFAULT, CRYPTOS, CRYPTOS_ETH, CRYPTOS_LEDGER, ENDPOINT_DEFAULT, ENDPOINTS, ICON_DEFAULT, ICONS, LANGUAGE_DEFAULT, LEDGER_CONN, LEDGER_CONN_DEFAULT, LOCKING, LOCKING_DEFAULT, PREFIX_DEFAULT, PREFIXES, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './defaults';
import { Endpoint, EndpointType, Option, SettingsStruct } from './types';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These need to be import type

@@ -2,10 +2,11 @@
// SPDX-License-Identifier: Apache-2.0

import { Settings, settings } from './Settings';
import { Endpoint, EndpointType, JsonRpcEndpoint, SubstrateConnectEndpoint } from './types';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import type (and move up to the correct place)


export { ENDPOINT_DEFAULT, ICON_DEFAULT, ICON_DEFAULT_HOST, LANGUAGE_DEFAULT, LOCKING_DEFAULT, PREFIX_DEFAULT, UIMODE_DEFAULT, UITHEME_DEFAULT } from './defaults';
export { packageInfo } from './packageInfo';

export { settings, Settings };
export { settings, Settings, Endpoint, JsonRpcEndpoint, SubstrateConnectEndpoint, EndpointType };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the type exports here. (We always only have the types in /types.ts)

chain: string;
}

export enum EndpointType {
Copy link
Member

@jacogr jacogr Jun 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the enum, it is hugely problematic (polkadot-js doesn't use these at all) -

  • it creates a bunch of code to make this work in the transpiling phase
  • it turns type-only imports into type & code imports (types files now contain actual JS logic)

This is sufficient: export type EndpointType = 'json-rpc' | 'substrate-connect';

Co-authored-by: Jaco <jacogr@gmail.com>
Copy link
Member

@jacogr jacogr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems sane. Thank you.

@jacogr jacogr merged commit 851c452 into polkadot-js:master Jun 15, 2021
@polkadot-js-bot
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

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

Successfully merging this pull request may close these issues.

3 participants