Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some linting issues #372

Merged
merged 2 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
26 changes: 2 additions & 24 deletions packages/extension/src/utils/storageLocal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,7 @@
*/

export const saveData = (key: string, value: string) => {
try {
localStorage.setItem(key, value);
} catch (e) {
/*
* If localStorage is disabled or blocked by the browser,
* a SecurityError exception will be thrown when trying to access localStorage.
* If the key or value argument passed to localStorage.setItem() is not a string,
* a TypeError exception will be thrown.
* If the user has exceeded the storage quota for localStorage,
* a QuotaExceededError exception will be thrown.
*/
throw e;
}
localStorage.setItem(key, value);
};

export const loadData = (key: string) => {
Expand All @@ -35,15 +23,5 @@
};

export const removeData = (key: string) => {
try {
localStorage.removeItem(key);
} catch (e) {
/*
* If localStorage is disabled or blocked by the browser,
* a SecurityError exception will be thrown when trying to access localStorage.
* If the key argument passed to localStorage.removeItem() is not a string,
* a TypeError exception will be thrown.
*/
throw e;
}
localStorage.removeItem(key);
};
4 changes: 3 additions & 1 deletion packages/extension/src/utils/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ export const checkFee = (fee: string | null) => {
if (Number(fee) && dropsToXrp(fee)) {
return fee;
}
} catch (e) {}
} catch (e) {
/* empty */
}
}
return null;
};
Expand Down
Loading