From f4b18bb4900901c88a484c22e2d9a01179e1aeb3 Mon Sep 17 00:00:00 2001 From: Alejandro Martinez Andres <11448715+al3mart@users.noreply.github.com> Date: Fri, 7 Jun 2024 21:52:57 +0200 Subject: [PATCH 1/3] fix(paseo): relay for identity --- packages/apps-config/src/endpoints/testingRelayPaseo.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/apps-config/src/endpoints/testingRelayPaseo.ts b/packages/apps-config/src/endpoints/testingRelayPaseo.ts index a5c10d3a6d7c..bf798c9e5702 100644 --- a/packages/apps-config/src/endpoints/testingRelayPaseo.ts +++ b/packages/apps-config/src/endpoints/testingRelayPaseo.ts @@ -174,7 +174,7 @@ export const testRelayPaseo: EndpointOption = { dnslink: 'paseo', genesisHash: PASEO_GENESIS, info: 'paseo', - isPeopleForIdentity: true, + isPeopleForIdentity: false, isRelay: true, linked: [ ...testParasPaseoCommon, From cf66a439314d6f704163ac5ef903256093de86cc Mon Sep 17 00:00:00 2001 From: Alejandro Martinez Andres <11448715+al3mart@users.noreply.github.com> Date: Sun, 9 Jun 2024 18:39:09 +0200 Subject: [PATCH 2/3] fix: check for paseo to enable identity --- packages/react-api/src/Api.tsx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/react-api/src/Api.tsx b/packages/react-api/src/Api.tsx index 34cb3726f8e2..e13a30709024 100644 --- a/packages/react-api/src/Api.tsx +++ b/packages/react-api/src/Api.tsx @@ -58,7 +58,7 @@ export const DEFAULT_AUX = ['Aux1', 'Aux2', 'Aux3', 'Aux4', 'Aux5', 'Aux6', 'Aux const DISALLOW_EXTENSIONS: string[] = []; const EMPTY_STATE = { hasInjectedAccounts: false, isApiReady: false } as unknown as ApiState; -function isKeyringLoaded () { +function isKeyringLoaded() { try { return !!keyring.keyring; } catch { @@ -66,7 +66,7 @@ function isKeyringLoaded () { } } -function getDevTypes (): Record> { +function getDevTypes(): Record> { const types = decodeUrlTypes() || store.get('types', {}) as Record>; const names = Object.keys(types); @@ -75,7 +75,7 @@ function getDevTypes (): Record> { return types; } -async function getInjectedAccounts (injectedPromise: Promise): Promise { +async function getInjectedAccounts(injectedPromise: Promise): Promise { try { await injectedPromise; @@ -95,7 +95,7 @@ async function getInjectedAccounts (injectedPromise: Promise string { +function makeCreateLink(baseApiUrl: string, isElectron: boolean): (path: string) => string { return (path: string, apiUrl?: string): string => `${isElectron ? 'https://polkadot.js.org/apps/' @@ -103,7 +103,7 @@ function makeCreateLink (baseApiUrl: string, isElectron: boolean): (path: string }?rpc=${encodeURIComponent(apiUrl || baseApiUrl)}#${path}`; } -async function retrieve (api: ApiPromise, injectedPromise: Promise): Promise { +async function retrieve(api: ApiPromise, injectedPromise: Promise): Promise { const [systemChain, systemChainType, systemName, systemVersion, injectedAccounts] = await Promise.all([ api.rpc.system.chain(), api.rpc.system.chainType @@ -131,7 +131,7 @@ async function retrieve (api: ApiPromise, injectedPromise: Promise, store: KeyringStore | undefined, types: Record>, urlIsEthereum = false): Promise { +async function loadOnReady(api: ApiPromise, endpoint: LinkOption | null, fork: Blockchain | null, injectedPromise: Promise, store: KeyringStore | undefined, types: Record>, urlIsEthereum = false): Promise { statics.registry.register(types); const { injectedAccounts, properties, systemChain, systemChainType, systemName, systemVersion } = await retrieve(api, injectedPromise); @@ -203,7 +203,7 @@ async function loadOnReady (api: ApiPromise, endpoint: LinkOption | null, fork: * @internal * Creates a ScProvider from a [/parachain] string */ -async function getLightProvider (chain: string): Promise { +async function getLightProvider(chain: string): Promise { const [sc, relayName, paraName] = chain.split('/'); if (sc !== 'substrate-connect') { @@ -228,7 +228,7 @@ async function getLightProvider (chain: string): Promise { /** * @internal */ -async function createApi (apiUrl: string, signer: ApiSigner, isLocalFork: boolean, onError: (error: unknown) => void): Promise { +async function createApi(apiUrl: string, signer: ApiSigner, isLocalFork: boolean, onError: (error: unknown) => void): Promise { const types = getDevTypes(); const isLight = apiUrl.startsWith('light://'); let provider; @@ -270,7 +270,7 @@ async function createApi (apiUrl: string, signer: ApiSigner, isLocalFork: boolea return { fork: chopsticksFork, types }; } -export function ApiCtxRoot ({ apiUrl, children, isElectron, store: keyringStore }: Props): React.ReactElement | null { +export function ApiCtxRoot({ apiUrl, children, isElectron, store: keyringStore }: Props): React.ReactElement | null { const { queuePayload, queueSetTxStatus } = useQueue(); const [state, setState] = useState(EMPTY_STATE); const [isApiConnected, setIsApiConnected] = useState(false); @@ -299,7 +299,7 @@ export function ApiCtxRoot ({ apiUrl, children, isElectron, store: keyringStore [apiUrl, isElectron] ); // TODO: Once the people migration is complete for polkadot, we can remove the polkadot check at the end. - const enableIdentity = apiEndpoint?.isPeople || (isNumber(apiEndpoint?.paraId) && (apiEndpoint?.paraId >= 2000)) || apiEndpoint?.info?.toLowerCase() === 'polkadot'; + const enableIdentity = apiEndpoint?.isPeople || (isNumber(apiEndpoint?.paraId) && (apiEndpoint?.paraId >= 2000)) || apiEndpoint?.info?.toLowerCase() === 'polkadot' || apiEndpoint?.info?.toLowerCase() === 'paseo'; // TODO remove `(apiEndpoint?.relayName === 'polkadot' && !apiEndpoint?.isRelay && apiRelay)` once polkadot is migrated over to the people chain for identities. const value = useMemo( () => objectSpread({}, state, { api: statics.api, apiEndpoint, apiError, apiIdentity: (apiEndpoint?.relayName === 'polkadot' && !apiEndpoint?.isRelay && apiRelay) || ((apiEndpoint?.isPeopleForIdentity && apiSystemPeople) || statics.api), apiRelay, apiSystemPeople, apiUrl, createLink, enableIdentity, extensions, isApiConnected, isApiInitialized, isElectron, isLocalFork, isWaitingInjected: !extensions }), From f08569dd15cbed305edf8087e3022c4b52360074 Mon Sep 17 00:00:00 2001 From: Alejandro Martinez Andres <11448715+al3mart@users.noreply.github.com> Date: Sun, 9 Jun 2024 18:43:02 +0200 Subject: [PATCH 3/3] fix: lint --- packages/react-api/src/Api.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/react-api/src/Api.tsx b/packages/react-api/src/Api.tsx index e13a30709024..961323fee966 100644 --- a/packages/react-api/src/Api.tsx +++ b/packages/react-api/src/Api.tsx @@ -58,7 +58,7 @@ export const DEFAULT_AUX = ['Aux1', 'Aux2', 'Aux3', 'Aux4', 'Aux5', 'Aux6', 'Aux const DISALLOW_EXTENSIONS: string[] = []; const EMPTY_STATE = { hasInjectedAccounts: false, isApiReady: false } as unknown as ApiState; -function isKeyringLoaded() { +function isKeyringLoaded () { try { return !!keyring.keyring; } catch { @@ -66,7 +66,7 @@ function isKeyringLoaded() { } } -function getDevTypes(): Record> { +function getDevTypes (): Record> { const types = decodeUrlTypes() || store.get('types', {}) as Record>; const names = Object.keys(types); @@ -75,7 +75,7 @@ function getDevTypes(): Record> { return types; } -async function getInjectedAccounts(injectedPromise: Promise): Promise { +async function getInjectedAccounts (injectedPromise: Promise): Promise { try { await injectedPromise; @@ -95,7 +95,7 @@ async function getInjectedAccounts(injectedPromise: Promise } } -function makeCreateLink(baseApiUrl: string, isElectron: boolean): (path: string) => string { +function makeCreateLink (baseApiUrl: string, isElectron: boolean): (path: string) => string { return (path: string, apiUrl?: string): string => `${isElectron ? 'https://polkadot.js.org/apps/' @@ -103,7 +103,7 @@ function makeCreateLink(baseApiUrl: string, isElectron: boolean): (path: string) }?rpc=${encodeURIComponent(apiUrl || baseApiUrl)}#${path}`; } -async function retrieve(api: ApiPromise, injectedPromise: Promise): Promise { +async function retrieve (api: ApiPromise, injectedPromise: Promise): Promise { const [systemChain, systemChainType, systemName, systemVersion, injectedAccounts] = await Promise.all([ api.rpc.system.chain(), api.rpc.system.chainType @@ -131,7 +131,7 @@ async function retrieve(api: ApiPromise, injectedPromise: Promise, store: KeyringStore | undefined, types: Record>, urlIsEthereum = false): Promise { +async function loadOnReady (api: ApiPromise, endpoint: LinkOption | null, fork: Blockchain | null, injectedPromise: Promise, store: KeyringStore | undefined, types: Record>, urlIsEthereum = false): Promise { statics.registry.register(types); const { injectedAccounts, properties, systemChain, systemChainType, systemName, systemVersion } = await retrieve(api, injectedPromise); @@ -203,7 +203,7 @@ async function loadOnReady(api: ApiPromise, endpoint: LinkOption | null, fork: B * @internal * Creates a ScProvider from a [/parachain] string */ -async function getLightProvider(chain: string): Promise { +async function getLightProvider (chain: string): Promise { const [sc, relayName, paraName] = chain.split('/'); if (sc !== 'substrate-connect') { @@ -228,7 +228,7 @@ async function getLightProvider(chain: string): Promise { /** * @internal */ -async function createApi(apiUrl: string, signer: ApiSigner, isLocalFork: boolean, onError: (error: unknown) => void): Promise { +async function createApi (apiUrl: string, signer: ApiSigner, isLocalFork: boolean, onError: (error: unknown) => void): Promise { const types = getDevTypes(); const isLight = apiUrl.startsWith('light://'); let provider; @@ -270,7 +270,7 @@ async function createApi(apiUrl: string, signer: ApiSigner, isLocalFork: boolean return { fork: chopsticksFork, types }; } -export function ApiCtxRoot({ apiUrl, children, isElectron, store: keyringStore }: Props): React.ReactElement | null { +export function ApiCtxRoot ({ apiUrl, children, isElectron, store: keyringStore }: Props): React.ReactElement | null { const { queuePayload, queueSetTxStatus } = useQueue(); const [state, setState] = useState(EMPTY_STATE); const [isApiConnected, setIsApiConnected] = useState(false);