Skip to content

Commit 18161a5

Browse files
authored
chore: remove github warnings (#686)
1 parent 57a3ada commit 18161a5

File tree

9 files changed

+33
-273
lines changed

9 files changed

+33
-273
lines changed

source/routers/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect } from 'react';
1+
import React from 'react';
22
import { Routes, Route, Navigate } from 'react-router-dom';
33

44
import {

source/scripts/Background/controllers/message-handler/requests.ts

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ export const methodRequest = async (
4545
if (prefix === 'wallet' && methodName === 'isConnected')
4646
return dapp.isConnected(host);
4747
if (data.method && !isBitcoinBased && prefix !== 'sys') {
48-
const provider = EthProvider(host, activeNetwork);
48+
const provider = EthProvider(host);
4949
const resp = await provider.unrestrictedRPCMethods(
5050
data.method,
5151
data.params
5252
);
5353
if (resp !== false && resp !== undefined) {
54-
return resp; //Sending back to Dapp non restrictive method response
54+
return resp; //Sending back to Dapp non-restrictive method response
5555
}
5656
}
5757
const activeAccountData = accounts[activeAccount.type][activeAccount.id];
@@ -129,21 +129,13 @@ export const methodRequest = async (
129129
? [dapp.getAccount(host)?.address]
130130
: [];
131131
}
132-
// if (
133-
// !isRequestAllowed &&
134-
// methodName !== 'switchEthereumChain' &&
135-
// methodName !== 'getProviderState' &&
136-
// methodName !== 'getSysProviderState' &&
137-
// methodName !== 'getAccount' &&
138-
// methodName !== 'changeUTXOEVM'
139-
// )
140-
// throw cleanErrorStack(ethErrors.provider.unauthorized());
141132
const estimateFee = () => wallet.getRecommendedFee();
142133

143134
//* Wallet methods
144135
if (prefix === 'wallet') {
145136
let tryingToAdd = false;
146-
const { activeNetwork, networks: chains } = store.getState().vault;
137+
const { activeNetwork: currentNetwork, networks: chains } =
138+
store.getState().vault;
147139
switch (methodName) {
148140
case 'isLocked':
149141
return !wallet.isUnlocked();
@@ -257,17 +249,17 @@ export const methodRequest = async (
257249
tryingToAdd = true;
258250
case 'switchEthereumChain':
259251
if (isBitcoinBased) throw cleanErrorStack(ethErrors.rpc.internal());
260-
const chainId = tryingToAdd
252+
const chainIdToAdd = tryingToAdd
261253
? customRPCData.chainId
262254
: Number(data.params[0].chainId);
263255

264-
if (activeNetwork.chainId === chainId) return null;
265-
else if (chains.ethereum[chainId] && !isNetworkChanging) {
256+
if (currentNetwork.chainId === chainIdToAdd) return null;
257+
else if (chains.ethereum[chainIdToAdd] && !isNetworkChanging) {
266258
return popupPromise({
267259
host,
268260
route: 'switch-EthChain',
269261
eventName: 'wallet_switchEthereumChain',
270-
data: { chainId: chainId },
262+
data: { chainId: chainIdToAdd },
271263
});
272264
} else if (isNetworkChanging)
273265
throw cleanErrorStack(
@@ -286,25 +278,23 @@ export const methodRequest = async (
286278
},
287279
});
288280
case 'getProviderState':
289-
const providerState = {
281+
return {
290282
accounts: dapp.getAccount(host)
291283
? [dapp.getAccount(host).address]
292284
: [],
293-
chainId: `0x${activeNetwork.chainId.toString(16)}`,
285+
chainId: `0x${currentNetwork.chainId.toString(16)}`,
294286
isUnlocked: wallet.isUnlocked(),
295-
networkVersion: activeNetwork.chainId,
287+
networkVersion: currentNetwork.chainId,
296288
isBitcoinBased,
297289
};
298-
return providerState;
299290
case 'getSysProviderState':
300-
const blockExplorerURL = isBitcoinBased ? activeNetwork.url : null;
301-
const sysProviderState = {
291+
const blockExplorerURL = isBitcoinBased ? currentNetwork.url : null;
292+
return {
302293
xpub: dapp.getAccount(host)?.xpub ? dapp.getAccount(host).xpub : null,
303294
blockExplorerURL: blockExplorerURL,
304295
isUnlocked: wallet.isUnlocked(),
305296
isBitcoinBased,
306297
};
307-
return sysProviderState;
308298
default:
309299
throw cleanErrorStack(ethErrors.rpc.methodNotFound());
310300
}
@@ -375,7 +365,7 @@ export const methodRequest = async (
375365
dapp.getAccount(host)?.address &&
376366
prefix !== 'sys' &&
377367
!isBitcoinBased &&
378-
EthProvider(host, activeNetwork).checkIsBlocking(data.method) &&
368+
EthProvider(host).checkIsBlocking(data.method) &&
379369
accounts[activeAccount.type][activeAccount.id].address !==
380370
dapp.getAccount(host)?.address
381371
) {
@@ -400,7 +390,7 @@ export const methodRequest = async (
400390

401391
//* Providers methods
402392
if (prefix !== 'sys' && !isBitcoinBased) {
403-
const provider = EthProvider(host, activeNetwork);
393+
const provider = EthProvider(host);
404394
const resp = await provider.restrictedRPCMethods(data.method, data.params);
405395
console.log({ responseInside: resp });
406396
// if (!wallet.isUnlocked()) return false;

source/scripts/Background/controllers/promises/cancellablesPromises.ts

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export interface IPromiseProps {
33
promise: Promise<{}>;
44
}
55

6+
// eslint-disable-next-line no-shadow
67
export enum PromiseTargets {
78
ASSETS = 'assets',
89
BALANCE = 'balance',
@@ -29,7 +30,9 @@ export class CancellablePromises {
2930
reject: (reason?: any) => void
3031
) => void
3132
): { cancel: () => void; currentPromise: Promise<T> } => {
32-
let cancel = () => {};
33+
let cancel = () => {
34+
//noop
35+
};
3336

3437
const currentPromise: Promise<T> = new Promise((resolve, reject) => {
3538
cancel = () => {
@@ -41,50 +44,6 @@ export class CancellablePromises {
4144
return { currentPromise, cancel };
4245
};
4346

44-
public cancelAllPromises = () => {
45-
if (this.transactionPromise) {
46-
this.transactionPromise.cancel();
47-
this.transactionPromise = null;
48-
}
49-
50-
if (this.assetsPromise) {
51-
this.assetsPromise.cancel();
52-
this.assetsPromise = null;
53-
}
54-
if (this.nftsPromise) {
55-
this.nftsPromise.cancel();
56-
this.nftsPromise = null;
57-
}
58-
59-
if (this.balancePromise) {
60-
this.balancePromise.cancel();
61-
this.balancePromise = null;
62-
}
63-
};
64-
65-
public cancelPromise(target: PromiseTargets) {
66-
switch (target) {
67-
case PromiseTargets.TRANSACTION:
68-
this.transactionPromise.cancel();
69-
this.transactionPromise = null;
70-
break;
71-
72-
case PromiseTargets.ASSETS:
73-
this.assetsPromise.cancel();
74-
this.assetsPromise = null;
75-
break;
76-
case PromiseTargets.NFTS:
77-
this.nftsPromise.cancel();
78-
this.nftsPromise = null;
79-
break;
80-
81-
case PromiseTargets.BALANCE:
82-
this.balancePromise.cancel();
83-
this.balancePromise = null;
84-
break;
85-
}
86-
}
87-
8847
public setPromise(target: PromiseTargets, promiseState: any) {
8948
switch (target) {
9049
case PromiseTargets.TRANSACTION:

source/scripts/Background/controllers/transactions/queue.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ export class Queue {
4444
} else {
4545
this.queue.push(
4646
new Promise(async (resolve) => {
47-
await new Promise<void>((resolve) => this.waiting.push(resolve));
47+
await new Promise<void>((resolvePromise) =>
48+
this.waiting.push(resolvePromise)
49+
);
4850
const result = await this.runFn(fn);
4951
return resolve(result);
5052
})

source/scripts/Background/handlers/handleStateChanges.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ export function handleObserveStateChanges() {
1111
type: 'CONTROLLER_STATE_CHANGE',
1212
data: currentState,
1313
})
14-
.catch(() => {});
14+
.catch(() => {
15+
//no-op
16+
});
1517

1618
store.subscribe(() => {
1719
const nextState = store.getState();
@@ -32,7 +34,9 @@ export function handleObserveStateChanges() {
3234
type: 'CONTROLLER_STATE_CHANGE',
3335
data: nextState,
3436
})
35-
.catch(() => {}); // ignore errors when sending message and the extension is closed
37+
.catch(() => {
38+
//no-op
39+
}); // ignore errors when sending message and the extension is closed
3640
}
3741
});
3842
}

source/scripts/Provider/EthProvider.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { TypedData } from 'ethers-eip712';
22
import { ethErrors } from 'helpers/errors';
33

4-
import { INetwork } from '@pollum-io/sysweb3-network';
54
import { validateEOAAddress } from '@pollum-io/sysweb3-utils';
65

76
import { getController } from 'scripts/Background';
@@ -15,12 +14,11 @@ import cleanErrorStack from 'utils/cleanErrorStack';
1514
import { decodeTransactionData } from 'utils/ethUtil';
1615
import { verifyNetworkEIP1559Compatibility } from 'utils/network';
1716

18-
export const EthProvider = (host: string, network?: INetwork) => {
17+
export const EthProvider = (host: string) => {
1918
const sendTransaction = async (params: ITransactionParams) => {
2019
const {
2120
ethereumTransaction: { web3Provider },
2221
} = getController().wallet;
23-
// await setSignerNetwork(network, 'ethereum');
2422
const tx = params;
2523
const validateTxToAddress = await validateEOAAddress(tx.to, web3Provider);
2624
const isLegacyTx = !(await verifyNetworkEIP1559Compatibility(web3Provider));

source/state/vault/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export type PaliAccount = {
8787
[id: number]: IPaliAccount;
8888
};
8989

90+
// eslint-disable-next-line no-shadow
9091
export enum TransactionsType {
9192
Ethereum = 'ethereum',
9293
Syscoin = 'syscoin',

0 commit comments

Comments
 (0)