Skip to content

Commit

Permalink
Fix some linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianBouron committed Jun 16, 2024
1 parent 04fb267 commit 5afb2ed
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 123 deletions.
2 changes: 1 addition & 1 deletion packages/extension/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from 'cypress';
export default defineConfig({
e2e: {
video: false,
setupNodeEvents(on, config) {
setupNodeEvents() {
// implement node event listeners here
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export const NetworkIndicator: FC = () => {
customNetworkServer: currentNetwork.server
});
setCurrentNetworkName(currentNetwork.name);
} catch (error) {}
} catch (error) {
/* empty */
}
// Show the error dialog
setErrorDialogOpen(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const ImportSecretNumbers: FC<ImportSecretNumbersProps> = ({
helperText={inputErrors.numbersA}
style={{
marginTop: '15px',
marginBottom: Boolean(inputErrors.numbersA) ? '0px' : '20px',
marginBottom: inputErrors.numbersA ? '0px' : '20px',
width: '110px'
}}
className={styles.textField}
Expand All @@ -129,7 +129,7 @@ export const ImportSecretNumbers: FC<ImportSecretNumbersProps> = ({
helperText={inputErrors.numbersB}
style={{
marginTop: '15px',
marginBottom: Boolean(inputErrors.numbersB) ? '0px' : '20px',
marginBottom: inputErrors.numbersB ? '0px' : '20px',
width: '110px'
}}
className={styles.textField}
Expand All @@ -147,7 +147,7 @@ export const ImportSecretNumbers: FC<ImportSecretNumbersProps> = ({
helperText={inputErrors.numbersC}
style={{
marginTop: '15px',
marginBottom: Boolean(inputErrors.numbersC) ? '0px' : '20px',
marginBottom: inputErrors.numbersC ? '0px' : '20px',
width: '110px'
}}
className={styles.textField}
Expand All @@ -165,7 +165,7 @@ export const ImportSecretNumbers: FC<ImportSecretNumbersProps> = ({
helperText={inputErrors.numbersD}
style={{
marginTop: '15px',
marginBottom: Boolean(inputErrors.numbersD) ? '0px' : '20px',
marginBottom: inputErrors.numbersD ? '0px' : '20px',
width: '110px'
}}
className={styles.textField}
Expand All @@ -183,7 +183,7 @@ export const ImportSecretNumbers: FC<ImportSecretNumbersProps> = ({
helperText={inputErrors.numbersE}
style={{
marginTop: '15px',
marginBottom: Boolean(inputErrors.numbersE) ? '0px' : '20px',
marginBottom: inputErrors.numbersE ? '0px' : '20px',
width: '110px'
}}
className={styles.textField}
Expand All @@ -201,7 +201,7 @@ export const ImportSecretNumbers: FC<ImportSecretNumbersProps> = ({
helperText={inputErrors.numbersF}
style={{
marginTop: '15px',
marginBottom: Boolean(inputErrors.numbersF) ? '0px' : '20px',
marginBottom: inputErrors.numbersF ? '0px' : '20px',
width: '110px'
}}
className={styles.textField}
Expand All @@ -219,7 +219,7 @@ export const ImportSecretNumbers: FC<ImportSecretNumbersProps> = ({
helperText={inputErrors.numbersG}
style={{
marginTop: '15px',
marginBottom: Boolean(inputErrors.numbersG) ? '0px' : '20px',
marginBottom: inputErrors.numbersG ? '0px' : '20px',
width: '110px'
}}
className={styles.textField}
Expand All @@ -237,7 +237,7 @@ export const ImportSecretNumbers: FC<ImportSecretNumbersProps> = ({
helperText={inputErrors.numbersH}
style={{
marginTop: '15px',
marginBottom: Boolean(inputErrors.numbersH) ? '0px' : '20px',
marginBottom: inputErrors.numbersH ? '0px' : '20px',
width: '110px'
}}
className={styles.textField}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,7 @@ export const SecretNumbers: FC<SecretNumbersProps> = ({ activeStep, steps, onBac
helperText={inputErrors.numbersA}
style={{
marginTop: '15px',
marginBottom: Boolean(inputErrors.numbersA)
? '0px'
: hasOfflineBanner
? '10px'
: '20px',
marginBottom: inputErrors.numbersA ? '0px' : hasOfflineBanner ? '10px' : '20px',
width: '110px'
}}
className={styles.textField}
Expand All @@ -130,11 +126,7 @@ export const SecretNumbers: FC<SecretNumbersProps> = ({ activeStep, steps, onBac
helperText={inputErrors.numbersB}
style={{
marginTop: '15px',
marginBottom: Boolean(inputErrors.numbersB)
? '0px'
: hasOfflineBanner
? '10px'
: '20px',
marginBottom: inputErrors.numbersB ? '0px' : hasOfflineBanner ? '10px' : '20px',
width: '110px'
}}
className={styles.textField}
Expand All @@ -152,11 +144,7 @@ export const SecretNumbers: FC<SecretNumbersProps> = ({ activeStep, steps, onBac
helperText={inputErrors.numbersC}
style={{
marginTop: '15px',
marginBottom: Boolean(inputErrors.numbersC)
? '0px'
: hasOfflineBanner
? '10px'
: '20px',
marginBottom: inputErrors.numbersC ? '0px' : hasOfflineBanner ? '10px' : '20px',
width: '110px'
}}
className={styles.textField}
Expand All @@ -174,11 +162,7 @@ export const SecretNumbers: FC<SecretNumbersProps> = ({ activeStep, steps, onBac
helperText={inputErrors.numbersD}
style={{
marginTop: '15px',
marginBottom: Boolean(inputErrors.numbersD)
? '0px'
: hasOfflineBanner
? '10px'
: '20px',
marginBottom: inputErrors.numbersD ? '0px' : hasOfflineBanner ? '10px' : '20px',
width: '110px'
}}
className={styles.textField}
Expand All @@ -196,11 +180,7 @@ export const SecretNumbers: FC<SecretNumbersProps> = ({ activeStep, steps, onBac
helperText={inputErrors.numbersE}
style={{
marginTop: '15px',
marginBottom: Boolean(inputErrors.numbersE)
? '0px'
: hasOfflineBanner
? '10px'
: '20px',
marginBottom: inputErrors.numbersE ? '0px' : hasOfflineBanner ? '10px' : '20px',
width: '110px'
}}
className={styles.textField}
Expand All @@ -218,11 +198,7 @@ export const SecretNumbers: FC<SecretNumbersProps> = ({ activeStep, steps, onBac
helperText={inputErrors.numbersF}
style={{
marginTop: '15px',
marginBottom: Boolean(inputErrors.numbersF)
? '0px'
: hasOfflineBanner
? '10px'
: '20px',
marginBottom: inputErrors.numbersF ? '0px' : hasOfflineBanner ? '10px' : '20px',
width: '110px'
}}
className={styles.textField}
Expand All @@ -240,11 +216,7 @@ export const SecretNumbers: FC<SecretNumbersProps> = ({ activeStep, steps, onBac
helperText={inputErrors.numbersG}
style={{
marginTop: '15px',
marginBottom: Boolean(inputErrors.numbersG)
? '0px'
: hasOfflineBanner
? '10px'
: '20px',
marginBottom: inputErrors.numbersG ? '0px' : hasOfflineBanner ? '10px' : '20px',
width: '110px'
}}
className={styles.textField}
Expand All @@ -262,11 +234,7 @@ export const SecretNumbers: FC<SecretNumbersProps> = ({ activeStep, steps, onBac
helperText={inputErrors.numbersH}
style={{
marginTop: '15px',
marginBottom: Boolean(inputErrors.numbersH)
? '0px'
: hasOfflineBanner
? '10px'
: '20px',
marginBottom: inputErrors.numbersH ? '0px' : hasOfflineBanner ? '10px' : '20px',
width: '110px'
}}
className={styles.textField}
Expand Down
4 changes: 2 additions & 2 deletions packages/extension/src/components/pages/ShareNFT/ShareNFT.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const ShareNFT: FC = () => {
type: 'RECEIVE_NFT',
payload: {
id,
nfts: !!messagePayload ? messagePayload.nfts : messagePayload
nfts: messagePayload ? messagePayload.nfts : messagePayload
}
};

Expand All @@ -74,7 +74,7 @@ export const ShareNFT: FC = () => {
payload: {
id,
type: ResponseType.Response,
result: !!messagePayload
result: messagePayload
? {
account_nfts: messagePayload.nfts,
marker: messagePayload.marker
Expand Down
12 changes: 9 additions & 3 deletions packages/extension/src/utils/NFTDataResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export const resolveNFTData = async (
NFTokenID,
image: URL
};
} catch (e) {}
} catch (e) {
/* empty */
}
}
} else {
// Case 2 - JSON URL
Expand All @@ -70,7 +72,9 @@ export const resolveNFTData = async (
// Case 2.1 - The URL is directly a JSON
// If it follows the XLS-24 standard, it will be automatically parsed
return parseJSON(URL, NFTokenID);
} catch (e) {}
} catch (e) {
/* empty */
}
// Case 2.2 - The URL is an IPFS hash
if (!URL.startsWith(IPFSResolverPrefix) && !URL.startsWith('http')) {
try {
Expand All @@ -89,7 +93,9 @@ export const resolveNFTData = async (
image: resourceURL
};
}
} catch (e) {}
} catch (e) {
/* empty */
}
}
}
// Case 3 - Return the raw NFT attributes
Expand Down
68 changes: 26 additions & 42 deletions packages/extension/src/utils/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,59 +19,39 @@ export const saveNetwork = (
customNetworkServer?: string
) => {
if (customNetworkName && customNetworkServer) {
try {
saveData(
STORAGE_NETWORK,
JSON.stringify({ chain, name: customNetworkName, server: customNetworkServer })
);
} catch (e) {
throw e;
}
saveData(
STORAGE_NETWORK,
JSON.stringify({ chain, name: customNetworkName, server: customNetworkServer })
);
} else {
try {
saveData(
STORAGE_NETWORK,
JSON.stringify({ chain, name: network, server: getNetwork(chain, network).server })
);
} catch (e) {
throw e;
}
saveData(
STORAGE_NETWORK,
JSON.stringify({ chain, name: network, server: getNetwork(chain, network).server })
);
}
};

export const loadCustomNetworks = (): Record<string, NetworkData> => {
try {
const data = loadData(STORAGE_CUSTOM_NETWORKS);
if (data) {
return JSON.parse(data);
}
return {};
} catch (error) {
throw error;
const data = loadData(STORAGE_CUSTOM_NETWORKS);
if (data) {
return JSON.parse(data);
}
return {};
};

export const replaceCustomNetworks = (networks: Record<string, any>) => {
try {
saveData(STORAGE_CUSTOM_NETWORKS, JSON.stringify(networks));
} catch (error) {
throw error;
}
export const replaceCustomNetworks = (networks: Record<string, NetworkData>) => {
saveData(STORAGE_CUSTOM_NETWORKS, JSON.stringify(networks));
};

export const saveCustomNetwork = (networkData: NetworkData) => {
try {
// Read existing custom networks from storage
let existingCustomNetworks = loadCustomNetworks();
// Read existing custom networks from storage
const existingCustomNetworks = loadCustomNetworks();

// Add new custom network to existing custom networks
existingCustomNetworks[networkData.name] = networkData;
// Add new custom network to existing custom networks
existingCustomNetworks[networkData.name] = networkData;

// Save custom networks to storage
replaceCustomNetworks(existingCustomNetworks);
} catch (e) {
throw e;
}
// Save custom networks to storage
replaceCustomNetworks(existingCustomNetworks);
};

export const loadNetwork = () => {
Expand All @@ -84,7 +64,9 @@ export const loadNetwork = () => {
const parsedData: NetworkNode = JSON.parse(data);
try {
return getNetwork(parsedData.chain as Chain, parsedData.name as Network);
} catch (error) {}
} catch (error) {
/* empty */
}

if ('chain' in parsedData && 'name' in parsedData && 'server' in parsedData) {
return {
Expand All @@ -95,7 +77,9 @@ export const loadNetwork = () => {
description: 'Custom network'
};
}
} catch (error) {}
} catch (error) {
/* empty */
}

return getNetwork(Chain.XRPL, XRPLNetwork.MAINNET);
};
Expand Down
20 changes: 4 additions & 16 deletions packages/extension/src/utils/trustedApps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ export const saveTrustedApp = (trustedApp: TrustedApp, walletIndex: number): voi

const stringifiedNewTrustedApps = JSON.stringify(trustedApps);

try {
saveData(STORAGE_TRUSTED_APPS, stringifiedNewTrustedApps);
} catch (e) {
throw e;
}
saveData(STORAGE_TRUSTED_APPS, stringifiedNewTrustedApps);
};

export const loadTrustedApps = (walletIndex: number): TrustedApp[] => {
Expand All @@ -66,7 +62,7 @@ export const loadTrustedApps = (walletIndex: number): TrustedApp[] => {
};

export const removeTrustedApp = (url: string, walletIndex: number): TrustedApp[] => {
let trustedApps: TrustedApp[][] = JSON.parse(loadData(STORAGE_TRUSTED_APPS) || '[[]]');
const trustedApps: TrustedApp[][] = JSON.parse(loadData(STORAGE_TRUSTED_APPS) || '[[]]');

if (!trustedApps[walletIndex]) {
throw new Error("Couldn't find the wallet while removing the trusted app");
Expand All @@ -79,11 +75,7 @@ export const removeTrustedApp = (url: string, walletIndex: number): TrustedApp[]
removeData(STORAGE_TRUSTED_APPS);
} else {
const stringifiedTrustedApps = JSON.stringify(trustedApps);
try {
saveData(STORAGE_TRUSTED_APPS, stringifiedTrustedApps);
} catch (e) {
throw e;
}
saveData(STORAGE_TRUSTED_APPS, stringifiedTrustedApps);
}

return trustedApps[walletIndex];
Expand All @@ -96,11 +88,7 @@ export const removeWalletFromTrustedApp = (walletIndex: number): void => {
trustedApps.splice(walletIndex, 1);
}

try {
saveData(STORAGE_TRUSTED_APPS, JSON.stringify(trustedApps));
} catch (e) {
throw e;
}
saveData(STORAGE_TRUSTED_APPS, JSON.stringify(trustedApps));
};

// Checks if the trustedApp includes all the permissions
Expand Down
Loading

0 comments on commit 5afb2ed

Please sign in to comment.