Skip to content

Commit

Permalink
Revert "Add some sample files so linting can be tested"
Browse files Browse the repository at this point in the history
This reverts commit 173af2a.
  • Loading branch information
mcmire committed Mar 21, 2022
1 parent fe41d72 commit ade7789
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 60 deletions.
5 changes: 0 additions & 5 deletions dependencies.d.ts

This file was deleted.

23 changes: 23 additions & 0 deletions ui/helpers/utils/storage-helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import localforage from 'localforage';

export async function getStorageItem(key) {
try {
const serializedData = await localforage.getItem(key);
if (serializedData === null) {
return undefined;
}

return JSON.parse(serializedData);
} catch (err) {
return undefined;
}
}

export async function setStorageItem(key, value) {
try {
const serializedData = JSON.stringify(value);
await localforage.setItem(key, serializedData);
} catch (err) {
console.warn(err);
}
}
30 changes: 0 additions & 30 deletions ui/helpers/utils/storage-helpers.ts

This file was deleted.

41 changes: 16 additions & 25 deletions ui/helpers/utils/tx-helper.ts → ui/helpers/utils/tx-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,16 @@ import log from 'loglevel';
import { transactionMatchesNetwork } from '../../../shared/modules/transaction.utils';
import { valuesFor } from './util';

type Message = {
metamaskNetworkId: string;
time: number;
};

type MessagesByKey = Record<string, Message> | null | undefined;

export default function txHelper(
unapprovedTxs: MessagesByKey,
unapprovedMsgs: MessagesByKey,
personalMsgs: MessagesByKey,
decryptMsgs: MessagesByKey,
encryptionPublicKeyMsgs: MessagesByKey,
typedMessages: MessagesByKey,
network: string,
chainId: string,
): Message[] {
unapprovedTxs,
unapprovedMsgs,
personalMsgs,
decryptMsgs,
encryptionPublicKeyMsgs,
typedMessages,
network,
chainId,
) {
log.debug('tx-helper called with params:');
log.debug({
unapprovedTxs,
Expand All @@ -32,35 +25,33 @@ export default function txHelper(
});

const txValues = network
? (valuesFor(unapprovedTxs) as Message[]).filter((txMeta) =>
? valuesFor(unapprovedTxs).filter((txMeta) =>
transactionMatchesNetwork(txMeta, chainId, network),
)
: (valuesFor(unapprovedTxs) as Message[]);
: valuesFor(unapprovedTxs);
log.debug(`tx helper found ${txValues.length} unapproved txs`);

const msgValues = valuesFor(unapprovedMsgs) as Message[];
const msgValues = valuesFor(unapprovedMsgs);
log.debug(`tx helper found ${msgValues.length} unsigned messages`);
let allValues = txValues.concat(msgValues);

const personalValues = valuesFor(personalMsgs) as Message[];
const personalValues = valuesFor(personalMsgs);
log.debug(
`tx helper found ${personalValues.length} unsigned personal messages`,
);
allValues = allValues.concat(personalValues);

const decryptValues = valuesFor(decryptMsgs) as Message[];
const decryptValues = valuesFor(decryptMsgs);
log.debug(`tx helper found ${decryptValues.length} decrypt requests`);
allValues = allValues.concat(decryptValues);

const encryptionPublicKeyValues = valuesFor(
encryptionPublicKeyMsgs,
) as Message[];
const encryptionPublicKeyValues = valuesFor(encryptionPublicKeyMsgs);
log.debug(
`tx helper found ${encryptionPublicKeyValues.length} encryptionPublicKey requests`,
);
allValues = allValues.concat(encryptionPublicKeyValues);

const typedValues = valuesFor(typedMessages) as Message[];
const typedValues = valuesFor(typedMessages);
log.debug(`tx helper found ${typedValues.length} unsigned typed messages`);
allValues = allValues.concat(typedValues);

Expand Down

0 comments on commit ade7789

Please sign in to comment.