Skip to content

Commit

Permalink
Merge pull request #14 from matter-labs/UEXP-4541-display-unknown-tokens
Browse files Browse the repository at this point in the history
fix: display unknown for transfers with unknown tokens
  • Loading branch information
Romsters authored Sep 22, 2023
2 parents 2f9430d + 03ad1e9 commit 0ca1390
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/app/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
7 changes: 7 additions & 0 deletions packages/app/src/composables/useTransfers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ export default (address: ComputedRef<string>, context = useContext()) => {
),
(transfer: Api.Response.Transfer): Transfer => ({
...transfer,
token: transfer.token || {
l2Address: transfer.tokenAddress,
l1Address: null,
name: null,
symbol: null,
decimals: 0,
},
fromNetwork: transfer.type === "deposit" ? "L1" : "L2",
toNetwork: transfer.type === "withdrawal" ? "L1" : "L2",
})
Expand Down
18 changes: 16 additions & 2 deletions packages/app/tests/composables/useTransfers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ vi.mock("ohmyfetch", () => {
Promise.resolve({
items: [
{ ...baseTransferPayload, type: "transfer" },
{ ...baseTransferPayload, token: null, type: "transfer" },
{ ...baseTransferPayload, type: "deposit" },
{ ...baseTransferPayload, type: "withdrawal" },
],
meta: {
totalItems: 3,
totalItems: 4,
page: 1,
pageSize: 10,
totalPages: 1,
Expand Down Expand Up @@ -73,14 +74,27 @@ describe("useTransfers:", () => {
const composable = useTransfers(address);
await composable.load(1);
const transfers = composable.data.value;
expect(composable.data.value?.length).toBe(3);
expect(composable.data.value?.length).toBe(4);
expect(transfers).toEqual([
{
...baseTransferPayload,
type: "transfer",
fromNetwork: "L2",
toNetwork: "L2",
},
{
...baseTransferPayload,
token: {
decimals: 0,
l1Address: null,
l2Address: "tokenAddress",
name: null,
symbol: null,
},
type: "transfer",
fromNetwork: "L2",
toNetwork: "L2",
},
{
...baseTransferPayload,
type: "deposit",
Expand Down

0 comments on commit 0ca1390

Please sign in to comment.