Skip to content

Commit

Permalink
walletkit
Browse files Browse the repository at this point in the history
  • Loading branch information
canonbrother committed Oct 9, 2024
1 parent 5b66675 commit d4db060
Show file tree
Hide file tree
Showing 188 changed files with 10,368 additions and 2,617 deletions.
10 changes: 0 additions & 10 deletions .lintstagedrc.js

This file was deleted.

7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ node_modules
jest-coverage
web-build
mobile-app/coverage
.husky
.idea
.vscode
.contented
dist
package-lock.json
pnpm-lock.yaml
2 changes: 1 addition & 1 deletion mobile-app/app/api/transaction/dfi_converter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { translate } from "@translations";
import BigNumber from "bignumber.js";
import { DfTxSigner } from "@waveshq/walletkit-ui/dist/store";
import { DfTxSigner } from "@waveshq/walletkit-ui/store";
import { WhaleWalletAccount } from "@defichain/whale-api-wallet";
import {
CTransactionSegWit,
Expand Down
2 changes: 1 addition & 1 deletion mobile-app/app/api/transaction/transfer_domain.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { translate } from "@translations";
import BigNumber from "bignumber.js";
import { ethers, providers, utils } from "ethers";
import { DfTxSigner } from "@waveshq/walletkit-ui/dist/store";
import { DfTxSigner } from "@waveshq/walletkit-ui/store";
import { WhaleWalletAccount } from "@defichain/whale-api-wallet";
import {
CTransactionSegWit,
Expand Down
12 changes: 6 additions & 6 deletions mobile-app/app/components/ConfirmSummaryTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { tailwind } from "@tailwind";
import { getNativeIcon } from "@components/icons/assets";
import { translate } from "@translations";
import { RandomAvatar } from "@screens/AppNavigator/screens/Portfolio/components/RandomAvatar";
import { AddressType } from "@waveshq/walletkit-ui/dist/store";
import { AddressType } from "@waveshq/walletkit-ui/store";
import { View } from "react-native";
import { ThemedTextV2, ThemedViewV2 } from "./themed";

Expand All @@ -25,7 +25,7 @@ interface ConfirmSummaryTitleV2Props {
}

export function ConfirmSummaryTitle(
props: ConfirmSummaryTitleV2Props
props: ConfirmSummaryTitleV2Props,
): JSX.Element {
const IconA = getNativeIcon(props.iconA);
const IconB = getNativeIcon(props.iconB);
Expand Down Expand Up @@ -85,7 +85,7 @@ export function ConfirmSummaryTitle(
{translate(
"screens/ConfirmCompositeSwapScreen",
"Settlement value {{percentageChange}}",
{ percentageChange: props.oraclePrice }
{ percentageChange: props.oraclePrice },
)}
</ThemedTextV2>
</View>
Expand All @@ -95,7 +95,7 @@ export function ConfirmSummaryTitle(
renderText={(value) => (
<ThemedTextV2
style={tailwind(
"text-xl font-semibold-v2 flex-wrap pr-1 pl-2"
"text-xl font-semibold-v2 flex-wrap pr-1 pl-2",
)}
testID={`${props.testID}_to`}
>
Expand All @@ -121,7 +121,7 @@ export function ConfirmSummaryTitle(
dark={tailwind("bg-mono-dark-v2-200")}
light={tailwind("bg-mono-light-v2-200")}
style={tailwind(
"rounded-full pl-1 pr-2.5 py-1 flex flex-row items-center overflow-hidden ml-2"
"rounded-full pl-1 pr-2.5 py-1 flex flex-row items-center overflow-hidden ml-2",
)}
>
<RandomAvatar name={props.fromAddress} size={20} />
Expand Down Expand Up @@ -163,7 +163,7 @@ export function ConfirmSummaryTitle(
{
"pl-1": props.addressType === AddressType.WalletAddress,
"pl-2.5": props.addressType !== AddressType.WalletAddress,
}
},
)}
>
{props.addressType === AddressType.WalletAddress && (
Expand Down
2 changes: 1 addition & 1 deletion mobile-app/app/components/HeaderTitle.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { configureStore } from "@reduxjs/toolkit";
import { Provider } from "react-redux";
import { render } from "@testing-library/react-native";
import { RootState } from "@store";
import { block } from "@waveshq/walletkit-ui/dist/store/block";
import { block } from "@waveshq/walletkit-ui/store/block";
import { HeaderTitle } from "./HeaderTitle";

jest.mock("@contexts/CustomServiceProvider");
Expand Down
4 changes: 2 additions & 2 deletions mobile-app/app/components/OceanInterface/OceanInterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useWalletContext } from "@shared-contexts/WalletContext";
import {
useNetworkContext,
useWhaleApiClient,
} from "@waveshq/walletkit-ui/dist/contexts";
} from "@waveshq/walletkit-ui/contexts";
import { CTransactionSegWit } from "@defichain/jellyfish-transaction/dist";
import { WhaleApiClient } from "@defichain/whale-api-client";
import { Transaction } from "@defichain/whale-api-client/dist/api/transactions";
Expand All @@ -17,7 +17,7 @@ import {
ocean,
OceanTransaction,
TransactionStatusCode,
} from "@waveshq/walletkit-ui/dist/store";
} from "@waveshq/walletkit-ui/store";
import { tailwind } from "@tailwind";
import { translate } from "@translations";
import { useCallback, useEffect, useRef, useState } from "react";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ThemedTextV2,
ThemedViewV2,
} from "@components/themed";
import { TransactionStatusCode } from "@waveshq/walletkit-ui/dist/store";
import { TransactionStatusCode } from "@waveshq/walletkit-ui/store";
import { TransactionCloseButton } from "./TransactionCloseButton";
import { TransactionIDButton } from "./TransactionIDButton";

Expand Down
2 changes: 1 addition & 1 deletion mobile-app/app/components/SummaryTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { tailwind } from "@tailwind";
import { getNativeIcon } from "@components/icons/assets";
import { translate } from "@translations";
import { RandomAvatar } from "@screens/AppNavigator/screens/Portfolio/components/RandomAvatar";
import { AddressType } from "@waveshq/walletkit-ui/dist/store";
import { AddressType } from "@waveshq/walletkit-ui/store";
import { LocalAddress, WhitelistedAddress } from "@store/userPreferences";
import { DomainType } from "@contexts/DomainContext";

Expand Down
4 changes: 2 additions & 2 deletions mobile-app/app/components/icons/assets/_Default.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RootState } from "@store";
import { tokenSelectorByDisplaySymbol } from "@waveshq/walletkit-ui/dist/store";
import { tokenSelectorByDisplaySymbol } from "@waveshq/walletkit-ui/store";
import { SvgProps } from "react-native-svg";
import { useSelector } from "react-redux";
import { DefaultLoanToken } from "./DefaultLoanToken";
Expand All @@ -8,7 +8,7 @@ import { DefaultToken } from "./DefaultToken";

export function _Default(symbol: string): (props: SvgProps) => JSX.Element {
const tokenDetail = useSelector((state: RootState) =>
tokenSelectorByDisplaySymbol(state.wallet, symbol)
tokenSelectorByDisplaySymbol(state.wallet, symbol),
);

if (tokenDetail?.isLoanToken) {
Expand Down
2 changes: 1 addition & 1 deletion mobile-app/app/components/icons/assets/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { configureStore } from "@reduxjs/toolkit";
import { RootState } from "@store";
import { wallet } from "@waveshq/walletkit-ui/dist/store";
import { wallet } from "@waveshq/walletkit-ui/store";
import { render, RenderAPI } from "@testing-library/react-native";
import { Provider } from "react-redux";
import { AppIcon } from "../AppIcon";
Expand Down
2 changes: 1 addition & 1 deletion mobile-app/app/contexts/CustomServiceProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EnvironmentNetwork } from "@waveshq/walletkit-core";
import { useNetworkContext } from "@waveshq/walletkit-ui";
import { BaseLogger } from "@waveshq/walletkit-ui/dist/contexts/logger";
import { BaseLogger } from "@waveshq/walletkit-ui/contexts/logger";
import React, {
createContext,
PropsWithChildren,
Expand Down
2 changes: 1 addition & 1 deletion mobile-app/app/contexts/EVMProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React, {
} from "react";
import { providers } from "ethers";
import { useNetworkContext } from "@waveshq/walletkit-ui";
import { BaseLogger } from "@waveshq/walletkit-ui/dist/contexts/logger";
import { BaseLogger } from "@waveshq/walletkit-ui/contexts/logger";
import { useCustomServiceProviderContext } from "./CustomServiceProvider";

interface EVMProviderContextI {
Expand Down
2 changes: 1 addition & 1 deletion mobile-app/app/contexts/FeatureFlagContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import {
useGetFeatureFlagsQuery,
usePrefetch,
} from "@waveshq/walletkit-ui/dist/store";
} from "@waveshq/walletkit-ui/store";
import { nativeApplicationVersion } from "expo-application";
import {
createContext,
Expand Down
8 changes: 4 additions & 4 deletions mobile-app/app/hooks/useApiStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import dayjs from "dayjs";
import {
useGetBlockchainStatusQuery,
useGetOceanStatusQuery,
} from "@waveshq/walletkit-ui/dist/store";
} from "@waveshq/walletkit-ui/store";

// MAX_TIME_DIFF set to 45 mins to display warning message (in AnnouncementBanner) when blockchain is down only in Production mode, else 5 seconds for local runs
const MAX_TIME_DIFF = getEnvironment(getReleaseChannel()).debug
Expand All @@ -19,14 +19,14 @@ export function useApiStatus(): {
isOceanDown: boolean;
} {
const { lastSync, lastSuccessfulSync } = useSelector(
(state: RootState) => state.block
(state: RootState) => state.block,
);
const { data: blockchainStatus, isSuccess: isBlockchainSuccess } =
useGetBlockchainStatusQuery(
{},
{
pollingInterval: 1000 * 60 * 5, // every 5mins
}
},
);

const { data: oceanStatus, isSuccess: isOceanSuccess } =
Expand All @@ -37,7 +37,7 @@ export function useApiStatus(): {

function getBlockStatus(
lastSync?: string,
lastSuccessfulSync?: string
lastSuccessfulSync?: string,
): void {
if (lastSync !== undefined && lastSuccessfulSync !== undefined) {
// stats api is down - if syncing time is more than MAX_TIME_DIFF - checks which api is down
Expand Down
2 changes: 1 addition & 1 deletion mobile-app/app/hooks/wallet/Conversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
DFIUtxoSelector,
unifiedDFISelector,
transactionQueue,
} from "@waveshq/walletkit-ui/dist/store";
} from "@waveshq/walletkit-ui/store";
import { dfiConversionCrafter } from "@api/transaction/dfi_converter";
import { NativeLoggingProps } from "@shared-contexts/NativeLoggingProvider";
import { ConvertDirection } from "@screens/enum";
Expand Down
15 changes: 6 additions & 9 deletions mobile-app/app/hooks/wallet/DisplayUtxoWarning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@ import { useCallback } from "react";
import BigNumber from "bignumber.js";
import { useSelector } from "react-redux";
import { RootState } from "@store";
import {
DFITokenSelector,
DFIUtxoSelector,
} from "@waveshq/walletkit-ui/dist/store";
import { DFITokenSelector, DFIUtxoSelector } from "@waveshq/walletkit-ui/store";

export function useDisplayUtxoWarning(): {
getDisplayUtxoWarningStatus: (
amountInDFI: BigNumber,
displaySymbol: string
displaySymbol: string,
) => boolean;
} {
const DFIToken = useSelector((state: RootState) =>
DFITokenSelector(state.wallet)
DFITokenSelector(state.wallet),
);
const DFIUtxo = useSelector((state: RootState) =>
DFIUtxoSelector(state.wallet)
DFIUtxoSelector(state.wallet),
);
const reservedDFI = 0.1;

Expand All @@ -33,13 +30,13 @@ export function useDisplayUtxoWarning(): {

const toLessInUtxo = BigNumber.max(
new BigNumber(amountInDFI).minus(DFIToken.amount),
0
0,
);
return new BigNumber(DFIUtxo.amount)
.minus(toLessInUtxo)
.isLessThanOrEqualTo(reservedDFI);
},
[DFIToken, DFIUtxo]
[DFIToken, DFIUtxo],
);

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from "@store/auctions";
import { useIsFocused } from "@react-navigation/native";
import { useAppDispatch } from "@hooks/useAppDispatch";
import { useWhaleApiClient } from "@waveshq/walletkit-ui/dist/contexts";
import { useWhaleApiClient } from "@waveshq/walletkit-ui/contexts";
import { fetchVaults } from "@store/loans";
import { useWalletContext } from "@shared-contexts/WalletContext";
import {
Expand All @@ -35,7 +35,7 @@ type Props = StackScreenProps<AuctionsParamList, "AuctionScreen">;

export function AuctionScreen({ navigation }: Props): JSX.Element {
const { hasFetchAuctionsData } = useSelector(
(state: RootState) => state.auctions
(state: RootState) => state.auctions,
);
const [showLoader, setShowLoader] = useState(true);
const [isFirstLoad, setIsFirstLoad] = useState(false);
Expand All @@ -45,7 +45,7 @@ export function AuctionScreen({ navigation }: Props): JSX.Element {
const [searchString, setSearchString] = useState("");
const [isSearching, setIsSearching] = useState(false);
const batches = useSelector((state: RootState) =>
getAuctionBatches(state.auctions)
getAuctionBatches(state.auctions),
);
const handleFilter = useCallback(
debounce((searchString: string) => {
Expand All @@ -59,20 +59,23 @@ export function AuctionScreen({ navigation }: Props): JSX.Element {
.split(" ")
.filter((e) => e !== "")
.every((i) =>
batch.collateralTokenSymbols.join(" ").toLowerCase().includes(i)
)
)
batch.collateralTokenSymbols
.join(" ")
.toLowerCase()
.includes(i),
),
),
);
} else {
setFilteredAuctionBatches([]);
}
}, 500),
[batches]
[batches],
);
const [filteredAuctionBatches, setFilteredAuctionBatches] =
useState<Array<AuctionBatchProps>>(batches);
const [activeButtonGroup, setActiveButtonGroup] = useState<ButtonGroupTabKey>(
ButtonGroupTabKey.AllBids
ButtonGroupTabKey.AllBids,
);
const blockCount = useSelector((state: RootState) => state.block.count);

Expand Down Expand Up @@ -176,7 +179,7 @@ export function AuctionScreen({ navigation }: Props): JSX.Element {
});
setFilteredAuctionBatches(filteredAuctions);
},
[batches, address]
[batches, address],
);

if (hasFetchAuctionsData && batches?.length === 0 && !showSearchInput) {
Expand Down Expand Up @@ -212,11 +215,11 @@ export function AuctionScreen({ navigation }: Props): JSX.Element {
? translate(
"screens/AuctionScreen",
"Search results for “{{input}}”",
{ input: searchString?.trim() }
{ input: searchString?.trim() },
)
: translate(
"screens/AuctionScreen",
"Search for auctions using collateral token names i.e. DFI DUSD dBTC."
"Search for auctions using collateral token names i.e. DFI DUSD dBTC.",
)}
</ThemedTextV2>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { render } from "@testing-library/react-native";
import { configureStore } from "@reduxjs/toolkit";
import { Provider } from "react-redux";
import { RootState } from "@store";
import { block } from "@waveshq/walletkit-ui/dist/store/block";
import { block } from "@waveshq/walletkit-ui/store/block";
import {
LoanVaultLiquidated,
LoanVaultState,
} from "@defichain/whale-api-client/dist/api/loan";
import { wallet } from "@waveshq/walletkit-ui/dist/store";
import { wallet } from "@waveshq/walletkit-ui/store";
import BigNumber from "bignumber.js";
import { BatchCard } from "./BatchCard";

Expand Down Expand Up @@ -307,7 +307,7 @@ describe("Batch Card", () => {
onQuickBid={() => {}}
testID="batch_card"
/>
</Provider>
</Provider>,
);
expect(rendered.toJSON()).toMatchSnapshot();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RootState } from "@store";
import { block } from "@waveshq/walletkit-ui/dist/store/block";
import { block } from "@waveshq/walletkit-ui/store/block";
import { render } from "@testing-library/react-native";

import { Provider } from "react-redux";
Expand Down Expand Up @@ -82,7 +82,7 @@ describe("Bid Card", () => {
const rendered = render(
<Provider store={store}>
<BidCard vaultId={vaultId} batch={batch} liquidationHeight={9870} />
</Provider>
</Provider>,
);
expect(rendered.toJSON()).toMatchSnapshot();
});
Expand Down
Loading

0 comments on commit d4db060

Please sign in to comment.