Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ test-results
.github/test-data
junit.xml

# Leap extension local storage for e2e tests with playwright
apps/deploy-web/tests/ui/fixture/leapExtensionLocalStorage.*.json

# Clinic.js diagnostic artifacts
.clinic
Expand Down
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
@leapwallet:registry=https://registry.npmjs.org/
2 changes: 0 additions & 2 deletions apps/deploy-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"@cosmos-kit/cosmos-extension-metamask": "~0.15.1",
"@cosmos-kit/cosmostation-extension": "~2.18.1",
"@cosmos-kit/keplr": "~2.17.1",
"@cosmos-kit/leap": "~2.17.1",
"@cosmos-kit/react": "^2.24.1",
"@emotion/cache": "^11.7.1",
"@emotion/css": "^11.7.1",
Expand Down Expand Up @@ -127,7 +126,6 @@
"@chain-registry/types": "^0.50.12",
"@cosmjs/amino": "~0.38.0",
"@faker-js/faker": "^9.4.0",
"@keplr-wallet/types": "^0.12.111",
"@next/bundle-analyzer": "^15.5.18",
"@octokit/openapi-types": "^22.2.0",
"@playwright/test": "~1.57.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { describe, expect, it, vi } from "vitest";

import { DEPENDENCIES, GetStartedStepper } from "./GetStartedStepper";

import { render, screen } from "@testing-library/react";
import { MockComponents } from "@tests/unit/mocks";

describe(GetStartedStepper.name, () => {
it("displays AKT and ACT balance for custodial wallet", () => {
setup({
isWalletConnected: true,
isManagedWallet: false,
balanceUAKT: 10_000_000,
balanceUACT: 7_000_000
});

expect(screen.queryByText((_, el) => el?.tagName === "SPAN" && /You have 10 AKT and 7 ACT/.test(el.textContent ?? ""))).toBeInTheDocument();
});

it("displays USD balance for managed wallet", () => {
setup({
isWalletConnected: true,
isManagedWallet: true,
balanceUAKT: 10_000_000,
balanceUUSDC: 5_000_000
});

expect(screen.queryByText(/\$/)).toBeInTheDocument();
expect(screen.queryByText(/AKT and/)).not.toBeInTheDocument();
});

it("shows billing not set up when wallet is disconnected", () => {
setup({ isWalletConnected: false });

expect(screen.queryByText("Billing is not set up")).toBeInTheDocument();
});

function setup(input?: {
isWalletConnected?: boolean;
isManagedWallet?: boolean;
isTrialing?: boolean;
balanceUAKT?: number;
balanceUUSDC?: number;
balanceUACT?: number;
}) {
const deps = MockComponents(DEPENDENCIES, {
useWallet: vi.fn(() => ({
isWalletConnected: input?.isWalletConnected ?? false,
isManaged: input?.isManagedWallet ?? false,
isTrialing: input?.isTrialing ?? false,
address: "akash1test"
})) as unknown as (typeof DEPENDENCIES)["useWallet"],
useWalletBalance: vi.fn(() => ({
balance:
input?.balanceUAKT !== undefined || input?.balanceUUSDC !== undefined || input?.balanceUACT !== undefined
? {
balanceUAKT: input?.balanceUAKT ?? 0,
balanceUUSDC: input?.balanceUUSDC ?? 0,
balanceUACT: input?.balanceUACT ?? 0
}
: undefined,
refetch: vi.fn()
})) as unknown as (typeof DEPENDENCIES)["useWalletBalance"],
useChainParam: vi.fn(() => ({
minDeposit: { akt: 5, act: 5 }
})) as unknown as (typeof DEPENDENCIES)["useChainParam"]
});

return render(<GetStartedStepper dependencies={deps} />);
}
});
26 changes: 16 additions & 10 deletions apps/deploy-web/src/components/get-started/GetStartedStepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,23 @@ import { RouteStep } from "@src/types/route-steps.type";
import { udenomToDenom } from "@src/utils/mathHelpers";
import { uaktToAKT } from "@src/utils/priceUtils";
import { UrlService } from "@src/utils/urlUtils";
import LiquidityModal from "../liquidity-modal";
import { ExternalLink } from "../shared/ExternalLink";
import { WalletConnectionButtons } from "../wallet/WalletConnectionButtons";
import { QontoConnector, QontoStepIcon } from "./Stepper";

export const GetStartedStepper: React.FunctionComponent = () => {
export const DEPENDENCIES = {
useWallet,
useWalletBalance,
useChainParam,
WalletConnectionButtons,
AddFundsLink
};

export const GetStartedStepper: React.FunctionComponent<{ dependencies?: typeof DEPENDENCIES }> = ({ dependencies: d = DEPENDENCIES }) => {
const [activeStep, setActiveStep] = useState(0);
const { isWalletConnected, address, isManaged: isManagedWallet, isTrialing } = useWallet();
const { refetch: refetchBalances, balance: walletBalance } = useWalletBalance();
const { minDeposit } = useChainParam();
const { isWalletConnected, isManaged: isManagedWallet, isTrialing } = d.useWallet();
const { balance: walletBalance } = d.useWalletBalance();
const { minDeposit } = d.useChainParam();
const aktBalance = walletBalance ? uaktToAKT(walletBalance.balanceUAKT) : 0;
const usdcBalance = walletBalance ? udenomToDenom(walletBalance.balanceUUSDC) : 0;
const actBalance = walletBalance ? udenomToDenom(walletBalance.balanceUACT) : 0;
Expand Down Expand Up @@ -98,10 +105,10 @@ export const GetStartedStepper: React.FunctionComponent = () => {
<div className="flex items-center space-x-4">
{isManagedWallet && (
<div className="flex items-start gap-2">
<AddFundsLink className={cn("hover:no-underline", buttonVariants({ variant: "default" }))} href={UrlService.billing({ openPayment: true })}>
<d.AddFundsLink className={cn("hover:no-underline", buttonVariants({ variant: "default" }))} href={UrlService.billing({ openPayment: true })}>
<HandCard className="text-xs" />
<span className="m-2 whitespace-nowrap">Add Funds</span>
</AddFundsLink>
</d.AddFundsLink>
</div>
)}
</div>
Expand Down Expand Up @@ -136,7 +143,7 @@ export const GetStartedStepper: React.FunctionComponent = () => {
<span>Billing is not set up</span>
</div>

<WalletConnectionButtons className="gap-2" connectManagedWalletButtonClassName="mr-2 w-full md:w-auto" />
<d.WalletConnectionButtons className="gap-2" connectManagedWalletButtonClassName="mr-2 w-full md:w-auto" />
</div>
)}

Expand All @@ -162,10 +169,9 @@ export const GetStartedStepper: React.FunctionComponent = () => {
</span>
) : (
<span>
You have <strong>{aktBalance}</strong> AKT and <strong>{usdcBalance}</strong> USDC
You have <strong>{aktBalance}</strong> AKT and <strong>{actBalance}</strong> ACT
</span>
)}
{!isManagedWallet && isWalletConnected && <LiquidityModal address={address} aktBalance={aktBalance} refreshBalances={refetchBalances} />}
</div>
)}
</StepContent>
Expand Down
225 changes: 0 additions & 225 deletions apps/deploy-web/src/components/liquidity-modal/index.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ describe(CustomChainProvider.name, () => {
const call = vi.mocked(dependencies.ChainStoreProvider).mock.calls[0][0];
expect(call.walletsRegistry).toEqual([
{ names: ["keplr-extension", "keplr-mobile"], loader: expect.any(Function) },
{ names: ["leap-extension", "leap-mobile", "leap-metamask-cosmos-snap"], loader: expect.any(Function) },
{ names: ["cosmostation-extension"], loader: expect.any(Function) },
{ names: ["cosmos-extension-metamask"], loader: expect.any(Function) }
]);
Expand Down
Loading
Loading