Skip to content

Commit

Permalink
Merge branch 'master' into aptos/contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
nicomiicro committed Oct 25, 2022
2 parents 333c481 + 58b95d9 commit 006370b
Show file tree
Hide file tree
Showing 81 changed files with 1,433 additions and 860 deletions.
18 changes: 9 additions & 9 deletions apps/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@
"@solana/spl-token": "^0.3.5",
"@solana/web3.js": "^1.62.0",
"@swim-io/aptos": "workspace:^",
"@swim-io/core": "^0.39.0",
"@swim-io/evm": "^0.39.0",
"@swim-io/evm-contracts": "^0.39.0",
"@swim-io/pool-math": "^0.39.0",
"@swim-io/solana": "^0.39.0",
"@swim-io/solana-contracts": "^0.39.0",
"@swim-io/token-projects": "workspace:^",
"@swim-io/utils": "^0.39.0",
"@swim-io/wormhole": "^0.39.0",
"@swim-io/core": "^0.40.0",
"@swim-io/evm": "^0.40.0",
"@swim-io/evm-contracts": "^0.40.0",
"@swim-io/pool-math": "^0.40.0",
"@swim-io/solana": "^0.40.0",
"@swim-io/solana-contracts": "^0.40.0",
"@swim-io/token-projects": "^0.40.0",
"@swim-io/utils": "^0.40.0",
"@swim-io/wormhole": "^0.40.0",
"bn.js": "^5.2.1",
"classnames": "^2.3.1",
"decimal.js": "^10.3.1",
Expand Down
4 changes: 2 additions & 2 deletions apps/ui/src/components/AddForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ import {
useMultipleUserBalances,
usePool,
usePoolMath,
useSplTokenAccountsQuery,
useUserBalanceAmount,
useUserNativeBalances,
useUserSolanaTokenAccountsQuery,
useWallets,
} from "../hooks";
import {
Expand Down Expand Up @@ -206,7 +206,7 @@ export const AddForm = ({
poolTokens,
poolSpec.isLegacyPool ? undefined : poolSpec.ecosystem,
);
const { data: splTokenAccounts = null } = useSplTokenAccountsQuery();
const { data: splTokenAccounts = null } = useUserSolanaTokenAccountsQuery();
const startNewInteraction = useStartNewInteraction(() => {
setFormInputAmounts(poolTokens.map(() => "0"));
});
Expand Down
5 changes: 3 additions & 2 deletions apps/ui/src/components/RecentInteractions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Fragment, useEffect } from "react";
import { useTranslation } from "react-i18next";

import { useEnvironment, useInteractionState } from "../core/store";
import { useSplTokenAccountsQuery, useWallets } from "../hooks";
import { useUserSolanaTokenAccountsQuery, useWallets } from "../hooks";
import { isEveryAddressConnected } from "../models";
import type { InteractionType } from "../models";

Expand All @@ -34,7 +34,8 @@ export const RecentInteractions = ({
loadInteractionStatesFromIdb(env).catch(console.error);
}, [env, loadInteractionStatesFromIdb]);

const { isSuccess: didLoadSplTokenAccounts } = useSplTokenAccountsQuery();
const { isSuccess: didLoadSplTokenAccounts } =
useUserSolanaTokenAccountsQuery();
const wallets = useWallets();
// Don’t display current interaction
const { recentInteractionId, interactionStates } = useInteractionState();
Expand Down
2 changes: 0 additions & 2 deletions apps/ui/src/components/RecentInteractionsV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { useWallets } from "../hooks";
import { isEveryAddressConnected } from "../models";
import type { InteractionType } from "../models";

import { MultiConnectButton } from "./ConnectButton";
import { ConnectedWallets } from "./ConnectedWallets";
import { InteractionStateComponentV2 } from "./molecules/InteractionStateComponentV2";

Expand Down Expand Up @@ -55,7 +54,6 @@ export const RecentInteractionsV2 = ({
<EuiAccordion
id="recent-interactions"
buttonContent={`${title} (${recentInteractions.length})`}
extraAction={<MultiConnectButton size="s" fullWidth />}
>
<EuiSpacer />
<EuiPanel color="subdued">
Expand Down
4 changes: 2 additions & 2 deletions apps/ui/src/components/RemoveForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ import {
usePoolMath,
useRemoveFeesEstimationQuery,
useRemoveFeesEstimationQueryV2,
useSplTokenAccountsQuery,
useUserLpBalances,
useUserNativeBalances,
useUserSolanaTokenAccountsQuery,
useWallets,
} from "../hooks";
import {
Expand Down Expand Up @@ -93,7 +93,7 @@ export const RemoveForm = ({
state: poolState,
} = usePool(poolSpec.id);
const poolMath = usePoolMath(poolSpec.id);
const { data: splTokenAccounts = null } = useSplTokenAccountsQuery();
const { data: splTokenAccounts = null } = useUserSolanaTokenAccountsQuery();
const startNewInteractionV1 = useStartNewInteraction(() => {
if (method === RemoveMethod.ExactOutput) {
setFormOutputAmounts(formOutputAmounts.map(() => "0"));
Expand Down
26 changes: 14 additions & 12 deletions apps/ui/src/components/SwapForm/SwapForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import {
useErc20BalanceQuery,
useGetSwapFormErrors,
useSolanaClient,
useSolanaLiquidityQueries,
useSplTokenAccountsQuery,
useSplUserBalance,
useSolanaTokenAccountQueries,
useStartNewInteraction,
useSwapFeesEstimationQuery,
useUserNativeBalances,
useUserSolanaTokenAccountsQuery,
useUserSolanaTokenBalance,
} from "../../hooks";
import { mockOf, renderWithAppContext } from "../../testUtils";

Expand All @@ -37,9 +37,9 @@ jest.mock(

jest.mock("../../hooks/solana", () => ({
...jest.requireActual("../../hooks/solana"),
useSplTokenAccountsQuery: jest.fn(),
useSplUserBalance: jest.fn(),
useSolanaLiquidityQueries: jest.fn(),
useUserSolanaTokenAccountsQuery: jest.fn(),
useUserSolanaTokenBalance: jest.fn(),
useSolanaTokenAccountQueries: jest.fn(),
}));

jest.mock("../../hooks/solana/useSolanaClient", () => ({
Expand All @@ -66,13 +66,15 @@ jest.mock("../../hooks", () => ({

const useGetSwapFormErrorsMock = mockOf(useGetSwapFormErrors);
const useSolanaClientMock = mockOf(useSolanaClient);
const useSplTokenAccountsQueryMock = mockOf(useSplTokenAccountsQuery);
const useUserSolanaTokenAccountsQueryMock = mockOf(
useUserSolanaTokenAccountsQuery,
);
const useStartNewInteractionMock = mockOf(useStartNewInteraction);
const useSwapFeesEstimationQueryMock = mockOf(useSwapFeesEstimationQuery);
const useErc20BalanceQueryMock = mockOf(useErc20BalanceQuery);
const useUserNativeBalancesMock = mockOf(useUserNativeBalances);
const useSplUserBalanceMock = mockOf(useSplUserBalance);
const useSolanaLiquidityQueriesMock = mockOf(useSolanaLiquidityQueries);
const useUserSolanaTokenBalanceMock = mockOf(useUserSolanaTokenBalance);
const useSolanaTokenAccountQueriesMock = mockOf(useSolanaTokenAccountQueries);

const findFromTokenButton = () => screen.queryAllByRole("button")[0];
const findToTokenButton = () => screen.queryAllByRole("button")[3];
Expand All @@ -86,7 +88,7 @@ describe("SwapForm", () => {
},
} as Partial<CustomConnection> as unknown as CustomConnection,
});
useSplTokenAccountsQueryMock.mockReturnValue({
useUserSolanaTokenAccountsQueryMock.mockReturnValue({
data: [],
});

Expand All @@ -107,8 +109,8 @@ describe("SwapForm", () => {
useSwapFeesEstimationQueryMock.mockReturnValue(null);
useGetSwapFormErrorsMock.mockReturnValue(() => []);
useErc20BalanceQueryMock.mockReturnValue({ data: zero });
useSplUserBalanceMock.mockReturnValue(zero);
useSolanaLiquidityQueriesMock.mockReturnValue([
useUserSolanaTokenBalanceMock.mockReturnValue(zero);
useSolanaTokenAccountQueriesMock.mockReturnValue([
{ data: [] },
] as unknown as readonly UseQueryResult<readonly TokenAccount[], Error>[]);
});
Expand Down
4 changes: 2 additions & 2 deletions apps/ui/src/components/SwapForm/SwapForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import {
useIsLargeSwap,
usePoolMaths,
usePools,
useSplTokenAccountsQuery,
useSwapFeesEstimationQuery,
useSwapOutputAmountEstimate,
useSwapTokensContext,
useUserBalanceAmount,
useUserNativeBalances,
useUserSolanaTokenAccountsQuery,
} from "../../hooks";
import {
useHasActiveInteraction,
Expand Down Expand Up @@ -59,7 +59,7 @@ export const SwapForm = ({ maxSlippageFraction }: Props): ReactElement => {
const { t } = useTranslation();
const config = useEnvironment(selectConfig, shallow);
const { notify } = useNotification();
const { data: splTokenAccounts = null } = useSplTokenAccountsQuery();
const { data: splTokenAccounts = null } = useUserSolanaTokenAccountsQuery();
const startNewInteraction = useStartNewInteraction(() => {
setFormInputAmount("");
});
Expand Down
7 changes: 5 additions & 2 deletions apps/ui/src/components/TokenSearchModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useTranslation } from "react-i18next";
import shallow from "zustand/shallow.js";

import type { EcosystemId, TokenConfig } from "../config";
import { ECOSYSTEM_LIST, isEcosystemEnabled } from "../config";
import { ECOSYSTEM_LIST, isEcosystemEnabled, isSwimUsd } from "../config";
import { selectConfig } from "../core/selectors";
import { useEnvironment } from "../core/store";
import { useUserBalanceAmount } from "../hooks";
Expand All @@ -40,6 +40,7 @@ interface Props {
readonly handleSelectEcosystem: (ecosystemId: EcosystemId) => void;
readonly tokenOptionIds: readonly string[];
readonly selectedEcosystemId: EcosystemId;
readonly showSwimUsd?: boolean;
}

interface TokenProps {
Expand All @@ -63,6 +64,7 @@ export const TokenSearchModal = ({
handleSelectEcosystem,
selectedEcosystemId,
tokenOptionIds,
showSwimUsd = false,
}: Props): ReactElement => {
const { t } = useTranslation();
const { tokens } = useEnvironment(selectConfig, shallow);
Expand All @@ -81,7 +83,8 @@ export const TokenSearchModal = ({
const filteredTokens = tokens.filter(
(token) =>
tokenOptionIds.includes(token.id) &&
token.nativeEcosystemId === selectedEcosystemId,
(token.nativeEcosystemId === selectedEcosystemId ||
(showSwimUsd && isSwimUsd(token))),
);

const options = filteredTokens.map((token) => {
Expand Down
106 changes: 0 additions & 106 deletions apps/ui/src/components/TokenSearchModalV2.tsx

This file was deleted.

Loading

0 comments on commit 006370b

Please sign in to comment.