Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
Remove lastUsedFeeCurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaonancy committed Jun 7, 2022
1 parent 3dd7b12 commit 8242e75
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 32 deletions.
8 changes: 0 additions & 8 deletions packages/react-celo/__tests__/connectors/ledger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ describe('LedgerConnector', () => {
});

it('remembers info in localStorage', () => {
expect(getTypedStorageKey(localStorageKeys.lastUsedFeeCurrency)).toEqual(
null
);

expect(getTypedStorageKey(localStorageKeys.lastUsedWalletType)).toEqual(
WalletTypes.Ledger
);
Expand All @@ -33,10 +29,6 @@ describe('LedgerConnector', () => {
it('clears out localStorage', () => {
connector.close();

expect(getTypedStorageKey(localStorageKeys.lastUsedFeeCurrency)).toEqual(
null
);

expect(getLastUsedWalletArgs()).toEqual(null);

expect(getTypedStorageKey(localStorageKeys.lastUsedNetwork)).toEqual(
Expand Down
4 changes: 0 additions & 4 deletions packages/react-celo/__tests__/connectors/private-key.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ describe('PrivateKeyConnector', () => {

connector.close();

expect(getTypedStorageKey(localStorageKeys.lastUsedFeeCurrency)).toEqual(
null
);

expect(
getTypedStorageKey(localStorageKeys.lastUsedWalletArguments)
).toEqual(null);
Expand Down
1 change: 0 additions & 1 deletion packages/react-celo/src/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export enum localStorageKeys {
lastUsedWalletType = 'react-celo/last-used-wallet',
lastUsedWalletId = 'react-celo/last-used-wallet-id',
lastUsedWalletArguments = 'react-celo/last-used-wallet-arguments',
lastUsedFeeCurrency = 'react-celo/last-used-fee-currency',
}

export enum SupportedProviders {
Expand Down
6 changes: 0 additions & 6 deletions packages/react-celo/src/react-celo-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ export function celoReactReducer(
connectorInitError: null,
address: null,
};
case 'setFeeCurrency':
if (action.payload === state.feeCurrency) {
return state;
}
setTypedStorageKey(lsKeys.lastUsedFeeCurrency, action.payload);
return { ...state, feeCurrency: action.payload };
case 'initialisedConnector': {
const newConnector = action.payload;
const address = newConnector.kit.connection.defaultAccount ?? null;
Expand Down
13 changes: 0 additions & 13 deletions packages/react-celo/src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,16 @@ import {

export const loadPreviousConfig = (
defaultNetworkProp: Network,
defaultFeeCurrencyProp: CeloTokenContract,
networks: Network[]
): {
address: Maybe<string>;
network: Maybe<Network>;
connector: Connector;
feeCurrency: Maybe<CeloTokenContract>;
} => {
let lastUsedNetworkName: Maybe<string> = null;
let lastUsedAddress: Maybe<string> = null;
let lastUsedWalletType: WalletTypes = WalletTypes.Unauthenticated;
let lastUsedWalletArguments: unknown[] = [];
let lastUsedFeeCurrency: CeloContract = defaultFeeCurrencyProp;
if (localStorageAvailable()) {
const localLastUsedNetworkName = getTypedStorageKey(
localStorageKeys.lastUsedNetwork
Expand All @@ -42,14 +39,6 @@ export const loadPreviousConfig = (
}

lastUsedWalletArguments = getLastUsedWalletArgs() || [];

const localLastUsedFeeCurrency = getTypedStorageKey(
localStorageKeys.lastUsedFeeCurrency
);

if (isValidFeeCurrency(localLastUsedFeeCurrency)) {
lastUsedFeeCurrency = localLastUsedFeeCurrency as CeloTokenContract;
}
}

const lastUsedNetwork = networks.find((n) => n.name === lastUsedNetworkName);
Expand All @@ -59,7 +48,6 @@ export const loadPreviousConfig = (
try {
initialConnector = new CONNECTOR_TYPES[lastUsedWalletType](
lastUsedNetwork,
lastUsedFeeCurrency,
...lastUsedWalletArguments
);
} catch (e) {
Expand All @@ -77,7 +65,6 @@ export const loadPreviousConfig = (
address: lastUsedAddress,
network: lastUsedNetwork || null,
connector: initialConnector,
feeCurrency: lastUsedFeeCurrency,
};
};

Expand Down

0 comments on commit 8242e75

Please sign in to comment.