Skip to content

Commit c2caf22

Browse files
committed
linter
1 parent bcea6b3 commit c2caf22

5 files changed

Lines changed: 71 additions & 72 deletions

File tree

packages/extension/src/background.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ import '@polkadot/extension-inject/crossenv';
99

1010
import type { RequestSignatures, TransportRequestMessage } from '@polkadot/extension-base/background/types';
1111

12+
import { ksmcc3, polkadot, westend2 } from '@substrate/connect-known-chains';
13+
import { register } from '@substrate/light-client-extension-helpers/background';
14+
import { start } from '@substrate/light-client-extension-helpers/smoldot';
15+
1216
import { handlers, withErrorLog } from '@polkadot/extension-base/background';
1317
import { PORT_CONTENT, PORT_EXTENSION } from '@polkadot/extension-base/defaults';
1418
import { AccountsStore } from '@polkadot/extension-base/stores';
1519
import { keyring } from '@polkadot/ui-keyring';
1620
import { assert } from '@polkadot/util';
1721
import { cryptoWaitReady } from '@polkadot/util-crypto';
1822

19-
import { register } from "@substrate/light-client-extension-helpers/background"
20-
import { start } from "@substrate/light-client-extension-helpers/smoldot"
21-
import { polkadot, ksmcc3, westend2 } from "@substrate/connect-known-chains"
22-
2323
register({
2424
smoldotClient: start({ maxLogLevel: 4 }),
25-
getWellKnownChainSpecs: async () => [polkadot, ksmcc3, westend2],
26-
})
25+
getWellKnownChainSpecs: async () => [polkadot, ksmcc3, westend2]
26+
});
2727

2828
// setup the notification (same a FF default background, white text)
2929
withErrorLog(() => chrome.action.setBadgeBackgroundColor({ color: '#d90000' }));
@@ -38,7 +38,7 @@ chrome.runtime.onConnect.addListener((port): void => {
3838
port.onDisconnect.addListener(() => console.log(`Disconnected from ${port.name}`));
3939
});
4040

41-
function getActiveTabs() {
41+
function getActiveTabs () {
4242
// queriing the current active tab in the current window should only ever return 1 tab
4343
// although an array is specified here
4444
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,79 @@
11
// Copyright 2019-2024 @polkadot/extension authors & contributors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import type {
5-
LightClientProvider,
6-
RawChain,
7-
} from "@substrate/light-client-extension-helpers/web-page"
8-
import type {
9-
Chain,
10-
JsonRpcCallback,
11-
SmoldotExtensionAPI,
12-
WellKnownChain,
13-
} from "@substrate/smoldot-discovery/types"
4+
import type { LightClientProvider, RawChain } from '@substrate/light-client-extension-helpers/web-page';
5+
import type { Chain, JsonRpcCallback, SmoldotExtensionAPI, WellKnownChain } from '@substrate/smoldot-discovery/types';
146

157
const wellKnownChainGenesisHashes: Record<string, string> = {
168
polkadot:
17-
"0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3",
18-
ksmcc3: "0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe",
9+
'0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3',
10+
ksmcc3: '0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe',
1911
westend2:
20-
"0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e",
12+
'0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e',
2113
rococo_v2_2:
22-
"0x6408de7737c59c238890533af25896a2c20608d8b380bb01029acb392781063e",
23-
}
14+
'0x6408de7737c59c238890533af25896a2c20608d8b380bb01029acb392781063e'
15+
};
16+
17+
export type { LightClientProvider } from '@substrate/light-client-extension-helpers/web-page';
2418

2519
export const createScClient = (
26-
lightClientProvider: LightClientProvider,
20+
lightClientProvider: LightClientProvider
2721
): SmoldotExtensionAPI => {
2822
const internalAddChain = async (
2923
isWellKnown: boolean,
3024
chainSpecOrWellKnownName: string,
3125
jsonRpcCallback: JsonRpcCallback = () => {},
32-
relayChainGenesisHash?: string,
26+
relayChainGenesisHash?: string
3327
): Promise<Chain> => {
34-
let chain: RawChain
28+
let chain: RawChain;
29+
3530
if (isWellKnown) {
3631
const foundChain = Object.values(lightClientProvider.getChains()).find(
3732
({ genesisHash }) =>
38-
genesisHash === wellKnownChainGenesisHashes[chainSpecOrWellKnownName],
39-
)
40-
if (!foundChain) throw new Error("Unknown well-known chain")
41-
chain = foundChain
33+
genesisHash === wellKnownChainGenesisHashes[chainSpecOrWellKnownName]
34+
);
35+
36+
if (!foundChain) {
37+
throw new Error('Unknown well-known chain');
38+
}
39+
40+
chain = foundChain;
4241
} else {
4342
chain = await lightClientProvider.getChain(
4443
chainSpecOrWellKnownName,
45-
relayChainGenesisHash,
46-
)
44+
relayChainGenesisHash
45+
);
4746
}
4847

49-
const jsonRpcProvider = chain.connect(jsonRpcCallback)
48+
const jsonRpcProvider = chain.connect(jsonRpcCallback);
5049

5150
return {
52-
sendJsonRpc(rpc: string): void {
53-
jsonRpcProvider.send(rpc)
51+
sendJsonRpc (rpc: string): void {
52+
jsonRpcProvider.send(rpc);
5453
},
55-
remove() {
56-
jsonRpcProvider.disconnect()
54+
remove () {
55+
jsonRpcProvider.disconnect();
5756
},
5857
addChain: function (
5958
chainSpec: string,
60-
jsonRpcCallback?: JsonRpcCallback | undefined,
59+
jsonRpcCallback?: JsonRpcCallback | undefined
6160
): Promise<Chain> {
6261
return internalAddChain(
6362
false,
6463
chainSpec,
6564
jsonRpcCallback,
66-
chain.genesisHash,
67-
)
68-
},
69-
}
70-
}
65+
chain.genesisHash
66+
);
67+
}
68+
};
69+
};
7170

7271
return {
7372
addChain: (chainSpec: string, jsonRpcCallback?: JsonRpcCallback) =>
7473
internalAddChain(false, chainSpec, jsonRpcCallback),
7574
addWellKnownChain: (
7675
name: WellKnownChain,
77-
jsonRpcCallback?: JsonRpcCallback,
78-
) => internalAddChain(true, name, jsonRpcCallback),
79-
}
80-
}
76+
jsonRpcCallback?: JsonRpcCallback
77+
) => internalAddChain(true, name, jsonRpcCallback)
78+
};
79+
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Copyright 2019-2024 @polkadot/extension authors & contributors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
export const CHANNEL_ID = "polkadot-js-extension"
4+
export const CHANNEL_ID = 'polkadot-js-extension';

packages/extension/src/content.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33

44
import type { Message } from '@polkadot/extension-base/types';
55

6+
import { register } from '@substrate/light-client-extension-helpers/content-script';
7+
68
import { MESSAGE_ORIGIN_CONTENT, MESSAGE_ORIGIN_PAGE, PORT_CONTENT } from '@polkadot/extension-base/defaults';
79
import { chrome } from '@polkadot/extension-inject/chrome';
8-
import { register } from "@substrate/light-client-extension-helpers/content-script"
9-
import { CHANNEL_ID } from "./constants"
1010

11-
register(CHANNEL_ID)
11+
import { CHANNEL_ID } from './constants';
12+
13+
register(CHANNEL_ID);
1214

1315
// connect to the extension
1416
const port = chrome.runtime.connect({ name: PORT_CONTENT });

packages/extension/src/page.ts

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,49 @@
11
// Copyright 2019-2024 @polkadot/extension authors & contributors
22
// SPDX-License-Identifier: Apache-2.0
33

4+
import type { SmoldotExtensionProviderDetail } from '@substrate/smoldot-discovery/types';
45
import type { RequestSignatures, TransportRequestMessage } from '@polkadot/extension-base/background/types';
56
import type { Message } from '@polkadot/extension-base/types';
67

8+
import { getLightClientProvider } from '@substrate/light-client-extension-helpers/web-page';
9+
710
import { MESSAGE_ORIGIN_CONTENT } from '@polkadot/extension-base/defaults';
811
import { enable, handleResponse, redirectIfPhishing } from '@polkadot/extension-base/page';
912
import { injectExtension } from '@polkadot/extension-inject';
1013

11-
import { packageInfo } from './packageInfo.js';
12-
import { CHANNEL_ID } from './constants.js';
13-
14-
import {
15-
getLightClientProvider,
16-
} from "@substrate/light-client-extension-helpers/web-page"
1714
import { createScClient } from './connector.js';
18-
import type { SmoldotExtensionProviderDetail } from '@substrate/smoldot-discovery/types';
15+
import { CHANNEL_ID } from './constants.js';
16+
import { packageInfo } from './packageInfo.js';
1917

2018
const PROVIDER_INFO = {
2119
uuid: crypto.randomUUID(),
22-
name: "Polkadot JS Extension",
20+
name: 'Polkadot JS Extension',
2321
icon: "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'/>",
24-
rdns: "io.github.paritytech.Polkadot JS Extension",
25-
}
22+
rdns: 'io.github.paritytech.PolkadotJsExtension'
23+
};
2624

27-
const lightClientProvider = getLightClientProvider(CHANNEL_ID)
25+
const lightClientProvider = getLightClientProvider(CHANNEL_ID);
2826

2927
// #region Smoldot Discovery Provider
3028
{
31-
const provider = lightClientProvider.then(createScClient)
29+
const provider = lightClientProvider.then(createScClient);
3230

3331
const detail: SmoldotExtensionProviderDetail = Object.freeze({
34-
kind: "smoldot-v1",
32+
kind: 'smoldot-v1',
3533
info: PROVIDER_INFO,
36-
provider,
37-
})
34+
provider
35+
});
3836

3937
window.addEventListener(
40-
"substrateDiscovery:requestProvider",
41-
({ detail: { onProvider } }) => onProvider(detail),
42-
)
38+
'substrateDiscovery:requestProvider',
39+
({ detail: { onProvider } }) => onProvider(detail)
40+
);
4341

4442
window.dispatchEvent(
45-
new CustomEvent("substrateDiscovery:announceProvider", {
46-
detail,
47-
}),
48-
)
43+
new CustomEvent('substrateDiscovery:announceProvider', {
44+
detail
45+
})
46+
);
4947
}
5048
// #endregion
5149

0 commit comments

Comments
 (0)