Skip to content

Commit

Permalink
test commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bee344 committed Jul 23, 2024
1 parent 82bdfaa commit 1924fcd
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 17 deletions.
24 changes: 15 additions & 9 deletions packages/page-settings/src/Metadata/Extensions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

import type { ChainInfo } from '../types.js';

Check failure on line 4 in packages/page-settings/src/Metadata/Extensions.tsx

View workflow job for this annotation

GitHub Actions / pr (lint)

Run autofix to sort these imports!
import type { HexString } from '@polkadot/util/types';
import type { RawMetadataDef } from '@polkadot/extension-inject/types';

import React, { useCallback, useMemo, useRef, useState } from 'react';
import type { MetadataDef } from '@polkadot/extension-inject/types';

import { knownExtensions } from '@polkadot/apps-config';
import { externalEmptySVG } from '@polkadot/apps-config/ui/logos/external';
import { Button, Dropdown, Spinner, styled, Table } from '@polkadot/react-components';
import { useToggle } from '@polkadot/react-hooks';
import { objectSpread } from '@polkadot/util';

import { useTranslation } from '../translate.js';
import useExtensions from '../useExtensions.js';
Expand All @@ -19,14 +20,15 @@ import iconOption from './iconOption.js';
interface Props {
chainInfo: ChainInfo | null;
className?: string;
rawMetadata: HexString | null;
rawMetadata?: HexString | null;
}

function Extensions ({ chainInfo, className, rawMetadata }: Props): React.ReactElement<Props> {
const rawDef: RawMetadataDef = {
genesisHash: chainInfo ? chainInfo.genesisHash : '0x00',
rawMetadata: rawMetadata ? rawMetadata : '0x00',
}
function Extensions({ chainInfo, className, rawMetadata }: Props): React.ReactElement<Props> {

Check failure on line 26 in packages/page-settings/src/Metadata/Extensions.tsx

View workflow job for this annotation

GitHub Actions / pr (lint)

Missing space before function parentheses
const rawDef: MetadataDef = objectSpread<MetadataDef>({}, { ...chainInfo, rawMetadata: rawMetadata ? rawMetadata : '0x00' })

Check failure on line 27 in packages/page-settings/src/Metadata/Extensions.tsx

View workflow job for this annotation

GitHub Actions / pr (lint)

Unnecessary use of conditional expression for default assignment

Check failure on line 27 in packages/page-settings/src/Metadata/Extensions.tsx

View workflow job for this annotation

GitHub Actions / pr (lint)

Missing semicolon
console.log('raw placeholder', rawMetadata)

Check failure on line 28 in packages/page-settings/src/Metadata/Extensions.tsx

View workflow job for this annotation

GitHub Actions / pr (lint)

Expected blank line before this statement

Check failure on line 28 in packages/page-settings/src/Metadata/Extensions.tsx

View workflow job for this annotation

GitHub Actions / pr (lint)

Missing semicolon
// const rawDef = chainInfo;
console.log('rawDef in Extensions.tsx:', rawDef);

const { t } = useTranslation();
const { extensions } = useExtensions();
const [selectedIndex, setSelectedIndex] = useState(0);
Expand All @@ -43,13 +45,17 @@ function Extensions ({ chainInfo, className, rawMetadata }: Props): React.ReactE
(): void => {
if (chainInfo && extensions?.[selectedIndex]) {
toggleBusy();
console.log('updating meta');

console.log('running _updateMeta');
console.log('running new rawDef', rawDef);


Check failure on line 52 in packages/page-settings/src/Metadata/Extensions.tsx

View workflow job for this annotation

GitHub Actions / pr (lint)

More than 1 blank line not allowed
extensions[selectedIndex]
.update(chainInfo, rawDef)
.update(rawDef)
.catch(() => false)
.then(() => toggleBusy())
.catch(console.error);
console.log('updated')

Check failure on line 58 in packages/page-settings/src/Metadata/Extensions.tsx

View workflow job for this annotation

GitHub Actions / pr (lint)

Missing semicolon
}
},
[chainInfo, extensions, rawDef, selectedIndex, toggleBusy]
Expand Down
6 changes: 5 additions & 1 deletion packages/page-settings/src/Metadata/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ export default function Metadata (): React.ReactElement {
const { isDevelopment } = useApi();
const rawMetadata = useRawMetadata();
const chainInfo = useChainInfo();
const isMetadataReady = rawMetadata !== null;

console.log('chainInfo: ', chainInfo)

Check failure on line 19 in packages/page-settings/src/Metadata/index.tsx

View workflow job for this annotation

GitHub Actions / pr (lint)

Missing semicolon
console.log('raw metadata after chain: ', rawMetadata)

return (
<>
{!isDevelopment && (
{!isDevelopment && isMetadataReady && (
<Extensions chainInfo={chainInfo}

Check warning on line 25 in packages/page-settings/src/Metadata/index.tsx

View workflow job for this annotation

GitHub Actions / pr (lint)

Property should be placed on a new line
rawMetadata={rawMetadata} />

Check warning on line 26 in packages/page-settings/src/Metadata/index.tsx

View workflow job for this annotation

GitHub Actions / pr (lint)

The closing bracket must be aligned with the opening tag (expected column 9 on the next line)
)}
Expand Down
14 changes: 7 additions & 7 deletions packages/page-settings/src/useExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import type { ApiPromise } from '@polkadot/api';
import type { InjectedExtension, InjectedMetadataKnown, MetadataDef, RawMetadataDef } from '@polkadot/extension-inject/types';
import type { InjectedExtension, InjectedMetadataKnown, MetadataDef } from '@polkadot/extension-inject/types';

import { useEffect, useMemo, useState } from 'react';
import store from 'store';
Expand All @@ -12,7 +12,7 @@ import { createNamedHook, useApi } from '@polkadot/react-hooks';
interface ExtensionKnown {
extension: InjectedExtension;
known: InjectedMetadataKnown[];
update: (def: MetadataDef, rawDef: RawMetadataDef) => Promise<boolean>;
update: (def: MetadataDef) => Promise<boolean>;
}

interface ExtensionInfo extends ExtensionKnown {
Expand Down Expand Up @@ -106,19 +106,19 @@ async function getExtensionInfo (api: ApiPromise, extension: InjectedExtension):
return {
extension,
known,
update: async (def: MetadataDef, rawDef: RawMetadataDef): Promise<boolean> => {
console.log('def: ', def)
console.log('rawdef: ', rawDef)
update: async (def: MetadataDef,): Promise<boolean> => {
console.log('def in useExtensions: ', def)
let isOk = false;

try {
console.log('checking')
const firstCheck = await metadata.provide(def);
console.log('first check done')
const secondCheck = await metadata.provideRaw(rawDef)
console.log('second check done')
isOk = firstCheck && secondCheck;
isOk = firstCheck;
console.log('old isOk: ', isOk);
const secondCheck = await metadata.get();
console.log('injected meta: ', secondCheck)
if (isOk) {
saveProperties(api, extension);
triggerAll();
Expand Down
1 change: 1 addition & 0 deletions packages/react-hooks/src/useLedger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ let ledger: LedgerGeneric | null = null;
let ledgerType: TransportType | null = null;

function retrieveLedger (api: ApiPromise): LedgerGeneric {
console.log('retrieve ledger');
const currType = uiSettings.ledgerConn as TransportType;

if (!ledger || ledgerType !== currType) {
Expand Down
7 changes: 7 additions & 0 deletions packages/react-signer/src/TxSigned.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ async function wrapTx (api: ApiPromise, currentItem: QueueTx, { isMultiCall, mul
async function extractParams (api: ApiPromise, address: string, options: Partial<SignerOptions>, getLedger: () => LedgerGeneric, setQrState: (state: QrState) => void): Promise<['qr' | 'signing', string, Partial<SignerOptions>, boolean]> {
const pair = keyring.getPair(address);
const { meta: { accountOffset, addressOffset, isExternal, isHardware, isInjected, isLocal, isProxied, source } } = pair;
console.log('isHardware: ', isHardware);
console.log('isExternal ', isExternal);
console.log('isInjexted: ', isInjected);

if (isHardware) {
return ['signing', address, { ...options, signer: new LedgerSigner(api, getLedger, accountOffset || 0, addressOffset || 0) }, false];
Expand All @@ -209,6 +212,10 @@ async function extractParams (api: ApiPromise, address: string, options: Partial

assert(injected, `Unable to find a signer for ${address}`);

console.log('injected signer metadata: ',injected.metadata);
console.log('injected signer withST: ',options.withSignedTransaction);
console.log('injected signer mode: ', options.mode);

return ['signing', address, { ...options, signer: injected.signer }, false];
}

Expand Down

0 comments on commit 1924fcd

Please sign in to comment.