Skip to content

Commit

Permalink
Remove tez transfers from the assets slice
Browse files Browse the repository at this point in the history
  • Loading branch information
serjonya-trili committed Apr 8, 2024
1 parent 8b873b6 commit 5f460ea
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
12 changes: 11 additions & 1 deletion src/utils/redux/migrations.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import { accountsMigrations } from "./migrations";
import { accountsMigrations, mainStoreMigrations } from "./migrations";
import { mockLedgerAccount, mockMnemonicAccount } from "../../mocks/factories";

describe("migrations", () => {
describe("main store migrations", () => {
test("5", () => {
expect(
mainStoreMigrations[5]({
assets: { transfers: { tez: "something" } },
})
).toEqual({ assets: { transfers: {} } });
});
});

describe("account migrations", () => {
test("4", () => {
const ledgerAcc = { ...mockLedgerAccount(0), derivationPathTemplate: undefined };
Expand Down
6 changes: 5 additions & 1 deletion src/utils/redux/migrations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* istanbul ignore file */
import { produce } from "immer";
import { identity } from "lodash";

Expand Down Expand Up @@ -29,6 +28,10 @@ export const mainStoreMigrations = {
}

Check warning on line 28 in src/utils/redux/migrations.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}),

Check warning on line 29 in src/utils/redux/migrations.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
4: identity,
5: (state: any) =>
produce(state, (draft: any) => {
delete draft.assets.transfers["tez"];
}),
} as any;

export const accountsMigrations = {
Expand Down Expand Up @@ -56,4 +59,5 @@ export const accountsMigrations = {
}
});
}),
5: identity,
} as any;
12 changes: 6 additions & 6 deletions src/utils/redux/slices/assetsSlice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("assetsSlice", () => {
mutez: {},
tokens: {},
},
transfers: { tez: {}, tokens: {} },
transfers: { tokens: {} },
delegationLevels: {},
conversionRate: null,
bakers: [],
Expand All @@ -39,7 +39,7 @@ describe("assetsSlice", () => {

expect(store.getState().assets).toEqual({
balances: { mutez: {}, tokens: {} },
transfers: { tez: {}, tokens: {} },
transfers: { tokens: {} },
delegationLevels: {},
bakers: [],
conversionRate: null,
Expand All @@ -61,7 +61,7 @@ describe("assetsSlice", () => {
},
tokens: {},
},
transfers: { tez: {}, tokens: {} },
transfers: { tokens: {} },
delegationLevels: {},
conversionRate: null,
bakers: [],
Expand All @@ -86,7 +86,7 @@ describe("assetsSlice", () => {
},
tokens: {},
},
transfers: { tez: {}, tokens: {} },
transfers: { tokens: {} },
delegationLevels: {},
conversionRate: null,
bakers: [],
Expand Down Expand Up @@ -122,7 +122,7 @@ describe("assetsSlice", () => {
conversionRate: null,
delegationLevels: {},
bakers: [],
transfers: { tez: {}, tokens: {} },
transfers: { tokens: {} },
blockLevel: null,
refetchTrigger: 0,
lastTimeUpdated: null,
Expand Down Expand Up @@ -165,7 +165,7 @@ describe("assetsSlice", () => {
conversionRate: null,
delegationLevels: {},
bakers: [],
transfers: { tez: {}, tokens: {} },
transfers: { tokens: {} },
blockLevel: null,
refetchTrigger: 0,
lastTimeUpdated: null,
Expand Down
5 changes: 2 additions & 3 deletions src/utils/redux/slices/assetsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { accountsSlice } from "./accountsSlice";
import { RawPkh } from "../../../types/Address";
import { Delegate } from "../../../types/Delegate";
import { RawTokenBalance, TokenBalance, fromRaw } from "../../../types/TokenBalance";
import { TezTransfer, TokenTransfer } from "../../../types/Transfer";
import { TokenTransfer } from "../../../types/Transfer";
import { TzktAccount } from "../../tezos";

type TransactionId = number;
Expand All @@ -19,7 +19,6 @@ type State = {
// TODO: This is a crutch, has to be merged with balances.mutez into an account state
delegationLevels: Record<string, number | undefined>;
transfers: {
tez: Record<string, TezTransfer[] | undefined>; // TODO: remove, it's not used
tokens: Record<TransactionId, TokenTransfer | undefined>;
};
bakers: Delegate[];
Expand All @@ -35,7 +34,7 @@ export const initialState: State = {
mutez: {},
tokens: {},
},
transfers: { tez: {}, tokens: {} },
transfers: { tokens: {} },
delegationLevels: {},
bakers: [],
conversionRate: null,
Expand Down

1 comment on commit 5f460ea

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 86.05% 3059/3555
🟢 Branches 80.33% 1066/1327
🟢 Functions 83.58% 947/1133
🟢 Lines 85.81% 2896/3375

Test suite run success

1325 tests passing in 170 suites.

Report generated by 🧪jest coverage report action from 5f460ea

Please sign in to comment.