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

Commit

Permalink
fix prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
chloezxyy committed Sep 5, 2023
1 parent 49a3a8a commit 306c4ff
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions packages/walletkit-ui/src/store/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const unifiedDFI: WalletToken = {
*/
const getAllTokens = async (client: WhaleApiClient): Promise<TokenData[]> => {
const allTokens: TokenData[] = await getPaginatedResponse<TokenData>(
(limit, next) => client.tokens.list(limit, next),
(limit, next) => client.tokens.list(limit, next)
);
return allTokens.filter((token) => token.isDAT);
};
Expand Down Expand Up @@ -149,7 +149,7 @@ export const fetchPoolPairs = createAsyncThunk(
type: "available",
data,
}));
},
}
);

export const fetchDexPrice = createAsyncThunk(
Expand All @@ -167,7 +167,7 @@ export const fetchDexPrice = createAsyncThunk(
dexPrices,
denomination,
};
},
}
);

export const fetchTokens = createAsyncThunk(
Expand All @@ -193,7 +193,7 @@ export const fetchTokens = createAsyncThunk(
allTokens,
utxoBalance,
};
},
}
);

export const fetchSwappableTokens = createAsyncThunk(
Expand All @@ -205,7 +205,7 @@ export const fetchSwappableTokens = createAsyncThunk(
client: WhaleApiClient;
fromTokenId: string;
}): Promise<AllSwappableTokensResult> =>
client.poolpairs.getSwappableTokens(fromTokenId),
client.poolpairs.getSwappableTokens(fromTokenId)
);

export const wallet = createSlice({
Expand All @@ -222,9 +222,10 @@ export const wallet = createSlice({
(state, action: PayloadAction<DexItem[]>) => {
state.hasFetchedPoolpairData = true;
state.poolpairs = action.payload.filter(
({ data }) => !data.symbol.includes("/v1") && !data.symbol.includes("BURN2")
); // Filter out v1 pairs due to stock split
},
({ data }) =>
!data.symbol.includes("/v1") && !data.symbol.includes("BURN2")
); // Filter out v1 pairs due to stock split
}
);
builder.addCase(
fetchDexPrice.fulfilled,
Expand All @@ -233,13 +234,13 @@ export const wallet = createSlice({
action: PayloadAction<{
dexPrices: DexPricesProps;
denomination: string;
}>,
}>
) => {
state.dexPrices = {
...state.dexPrices,
[action.payload.denomination]: action.payload.dexPrices,
};
},
}
);
builder.addCase(
fetchTokens.fulfilled,
Expand All @@ -249,17 +250,17 @@ export const wallet = createSlice({
tokens: AddressToken[];
allTokens: TokenData[];
utxoBalance: string;
}>,
}>
) => {
state.hasFetchedToken = true;
state.tokens = action.payload.tokens.map(setTokenSymbol);
state.utxoBalance = action.payload.utxoBalance;
state.allTokens = associateTokens(
action.payload.allTokens.filter(
(token) => !token.symbol.includes("/v1"),
),
(token) => !token.symbol.includes("/v1")
)
); // Filter out v1 tokens due to stock split
},
}
);
builder.addCase(
fetchSwappableTokens.fulfilled,
Expand All @@ -271,7 +272,7 @@ export const wallet = createSlice({
[action.payload.fromToken.id]: action.payload,
},
};
},
}
);
},
});
Expand All @@ -290,15 +291,15 @@ const rawTokensSelector = createSelector(
rawTokens.push(unifiedDFI);
}
return [...rawTokens, ...tokens];
},
}
);

export const tokensSelector = createSelector(
[rawTokensSelector, (state: WalletState) => state.utxoBalance],
(tokens, utxoBalance) => {
const utxoAmount = new BigNumber(utxoBalance);
const tokenAmount = new BigNumber(
(tokens.find((t) => t.id === "0") ?? tokenDFI).amount,
(tokens.find((t) => t.id === "0") ?? tokenDFI).amount
);
return tokens.map((t) => {
if (t.id === "0_utxo") {
Expand All @@ -315,22 +316,22 @@ export const tokensSelector = createSelector(
}
return t;
});
},
}
);

export const DFITokenSelector = createSelector(
tokensSelector,
(tokens) => tokens.find((token) => token.id === "0") ?? tokenDFI,
(tokens) => tokens.find((token) => token.id === "0") ?? tokenDFI
);

export const DFIUtxoSelector = createSelector(
tokensSelector,
(tokens) => tokens.find((token) => token.id === "0_utxo") ?? utxoDFI,
(tokens) => tokens.find((token) => token.id === "0_utxo") ?? utxoDFI
);

export const unifiedDFISelector = createSelector(
tokensSelector,
(tokens) => tokens.find((token) => token.id === "0_unified") ?? unifiedDFI,
(tokens) => tokens.find((token) => token.id === "0_unified") ?? unifiedDFI
);

const selectTokenId = (state: WalletState, tokenId: string): string => tokenId;
Expand All @@ -347,29 +348,29 @@ export const tokenSelector = createSelector(
return token.id === "0_unified";
}
return token.id === tokenId;
}),
})
);

/**
* Get single token detail by `displaySymbol` from wallet store.
*/
export const tokenSelectorByDisplaySymbol = createSelector(
[(state: WalletState) => state.allTokens, selectTokenId],
(allTokens, displaySymbol) => allTokens[displaySymbol],
(allTokens, displaySymbol) => allTokens[displaySymbol]
);

/**
* Get dexprices by currency denomination
*/
export const dexPricesSelectorByDenomination = createSelector(
[(state: WalletState) => state.dexPrices, selectTokenId],
(dexPrices, denomination) => dexPrices[denomination] ?? {},
(dexPrices, denomination) => dexPrices[denomination] ?? {}
);

/**
* Get single poolpair by id
*/
export const poolPairSelector = createSelector(
[(state: WalletState) => state.poolpairs, selectTokenId],
(poolpairs, id) => poolpairs.find((pair) => pair.data.id === id),
(poolpairs, id) => poolpairs.find((pair) => pair.data.id === id)
);

0 comments on commit 306c4ff

Please sign in to comment.