Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish Stage #3303

Merged
merged 5 commits into from
Jun 7, 2024
Merged
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: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"prettier": "^2.8.8",
"ts-jest": "^29.1.2",
"turbo": "^1.13.3",
"typescript": "5.4.3"
"typescript": "5.4.5"
},
"packageManager": "[email protected]",
"resolutions": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import dayjs from "../../../../utils/dayjs";
import { dayjs } from "../../../../utils/dayjs";
import { AssetLists } from "../../../__tests__/mock-asset-lists";
import { isAssetInCategories } from "../categories";

Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/queries/complex/assets/categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import cachified, { CacheEntry } from "cachified";
import { LRUCache } from "lru-cache";

import { DEFAULT_LRU_OPTIONS } from "../../../utils";
import dayjs from "../../../utils/dayjs";
import { dayjs } from "../../../utils/dayjs";
import { queryUpcomingAssets } from "../../github";

/** Filters an asset for whether it is included in the given list of categories. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import cachified, { CacheEntry } from "cachified";
import { LRUCache } from "lru-cache";

import { DEFAULT_LRU_OPTIONS } from "../../../../utils/cache";
import dayjs from "../../../../utils/dayjs";
import { dayjs } from "../../../../utils/dayjs";
import { queryMarketChart } from "../../../coingecko";
import {
queryTokenHistoricalChart,
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/queries/complex/earn/strategies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from "../../../queries/data-services/earn";
import { queryOsmosisCMS } from "../../../queries/github";
import { DEFAULT_LRU_OPTIONS } from "../../../utils/cache";
import dayjs from "../../../utils/dayjs";
import { dayjs } from "../../../utils/dayjs";
import { captureIfError } from "../../../utils/error";
import { type Asset, getAsset } from "../assets";
import { DEFAULT_VS_CURRENCY } from "../assets/config";
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/queries/complex/osmosis/lockup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Chain } from "@osmosis-labs/types";
import { Duration } from "dayjs/plugin/duration";

import dayjs from "../../../utils/dayjs";
import { dayjs } from "../../../utils/dayjs";
import { queryAccountLockedLongerDuration } from "../../osmosis/lockup";

export type UserLock = {
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/queries/complex/pools/bonding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CoinPretty, PricePretty, RatePretty } from "@keplr-wallet/unit";
import { AssetList, Chain } from "@osmosis-labs/types";
import type { Duration } from "dayjs/plugin/duration";

import dayjs from "../../../utils/dayjs";
import { dayjs } from "../../../utils/dayjs";
import { captureErrorAndReturn } from "../../../utils/error";
import { querySyntheticLockupsByLockId } from "../../osmosis/lockup";
import {
Expand Down
3 changes: 1 addition & 2 deletions packages/server/src/utils/dayjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ import duration from "dayjs/plugin/duration";

dayjs.extend(duration);

// eslint-disable-next-line import/no-default-export
export default dayjs;
export { dayjs };
51 changes: 51 additions & 0 deletions packages/tx/src/__tests__/events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,35 @@ describe("getSumTotalSpenderCoinsSpent", () => {

expect(coins).toEqual([]);
});

it("should only total the amounts for the specified sender", () => {
const coins = getSumTotalSpenderCoinsSpent(
"osmo1gtgx92pxk6hvhc3c3g0xlkrwqq6knymu0e0caw",
mockMultipleEvents
);

// Expected result is the sum of the amounts for the specified sender, not for osmo13vhcd3xllpvz8tql4dzp8yszxeas8zxpzptyvjttdy7m64kuyz5sv6caqq
const expectedResult = [
{
denom:
"factory/osmo1z0qrq605sjgcqpylfl4aa6s90x738j7m58wyatt0tdzflg2ha26q67k743/wbtc",
amount: "58573",
},
{
denom:
"ibc/EA1D43981D5C9A1C4AAEA9C23BB1D4FA126BA9BC7020A25E0AE4AA841EA25DC5",
amount: "21083680327000100",
},
{
denom:
"ibc/F4A070A6D78496D53127EA85C094A9EC87DFC1F36071B8CCDDBD020F933D213D",
amount: "131211643845355500",
},
{ denom: "uosmo", amount: "95799380" },
];

expect(coins).toEqual(expectedResult);
});
});

describe("matchRawCoinValue", () => {
Expand Down Expand Up @@ -225,4 +254,26 @@ const mockMultipleEvents = [
},
],
},
{
type: "coin_spent",
attributes: [
{
key: "spender",
value:
"osmo13vhcd3xllpvz8tql4dzp8yszxeas8zxpzptyvjttdy7m64kuyz5sv6caqq",
index: true,
},
{
key: "amount",
value:
"2605ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4",
index: true,
},
{
key: "msg_index",
value: "0",
index: true,
},
],
},
];
3 changes: 2 additions & 1 deletion packages/tx/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export function getSumTotalSpenderCoinsSpent(
if (type !== "coin_spent") return;
if (attributes.length === 0) return;
const spendAttribute = attributes.find((attr) => attr.key === "spender");
if (spendAttribute && spendAttribute.value !== spenderBech32Address) return;
if (!spendAttribute || spendAttribute.value !== spenderBech32Address)
return;

// a comma separated list of coins spent
const coinsSpentRawAttribute = attributes.find(
Expand Down
12 changes: 9 additions & 3 deletions packages/tx/src/gas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,15 @@ export async function getGasFeeAmount({
bech32Address,
}),
]);
const feeBalances = balances.filter((balance) =>
chainFeeDenoms.includes(balance.denom)
);
const feeBalances: { denom: string; amount: string }[] = [];

// iterate in order of fee denoms
for (const denom of chainFeeDenoms) {
const balance = balances.find((balance) => balance.denom === denom);
if (balance) {
feeBalances.push(balance);
}
}

if (!feeBalances.length) {
throw new InsufficientFeeError(
Expand Down
15 changes: 13 additions & 2 deletions packages/web/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"unused-imports/no-unused-imports": "error",
"react/no-unescaped-entities": "off"
}
"react/no-unescaped-entities": "off",
"import/no-default-export": "error"
// see https://stackoverflow.com/questions/44378395/how-to-configure-eslint-so-that-it-disallows-default-exports
},
"overrides": [
// Pages router, config files
{
"files": ["pages/**/*", "playwright.config.ts"],
"rules": {
"import/no-default-export": "off"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { screen } from "@testing-library/react";
import { act, screen } from "@testing-library/react";

import { renderWithProviders } from "~/__tests__/test-utils";
import { SwapAdBannerResponse } from "~/pages";
Expand All @@ -21,7 +21,10 @@ test("renders ad banner content correctly", () => {
featured: true,
};

renderWithProviders(<AdBannerContent {...mockAd} localization={{}} />);
act(() => {
renderWithProviders(<AdBannerContent {...mockAd} localization={{}} />);
});

const headerElement = screen.getByText(mockAd.headerOrTranslationKey);
const subheaderElement = screen.getByText(mockAd.subheaderOrTranslationKey);
const imageElement = screen.getByAltText(mockAd.iconImageAltOrTranslationKey);
Expand Down Expand Up @@ -62,12 +65,15 @@ test("renders ad banner content with localization correctly", () => {

const ad = mockAdResponseWithLocalization.banners[0];

renderWithProviders(
<AdBannerContent
{...ad}
localization={mockAdResponseWithLocalization.localization}
/>
);
act(() => {
renderWithProviders(
<AdBannerContent
{...ad}
localization={mockAdResponseWithLocalization.localization}
/>
);
});

const headerElement = screen.getByText("Mock Header");
const subheaderElement = screen.getByText("Mock Subheader");
const imageElement = screen.getByAltText("Mock Icon");
Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/assets/highlights-categories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Link from "next/link";
import { FunctionComponent, ReactNode } from "react";

import { PriceChange } from "~/components/assets/price";
import SkeletonLoader from "~/components/loaders/skeleton-loader";
import { SkeletonLoader } from "~/components/loaders/skeleton-loader";
import { EventName } from "~/config";
import {
Breakpoint,
Expand Down
6 changes: 2 additions & 4 deletions packages/web/components/buttons/clipboard-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { useState } from "react";
import { Icon } from "~/components/assets";
import { SpriteIconId } from "~/config";

import IconButton from "./icon-button";
import { IconButton } from "./icon-button";

/**
* Renders an icon within a button.
*/
const ClipboardButton = forwardRef<
export const ClipboardButton = forwardRef<
HTMLButtonElement,
{
value?: string;
Expand Down Expand Up @@ -78,5 +78,3 @@ const ClipboardButton = forwardRef<
</IconButton>
);
});

export default ClipboardButton;
4 changes: 1 addition & 3 deletions packages/web/components/buttons/icon-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Button } from "~/components/buttons/button";
/**
* Renders an icon within a button.
*/
const IconButton = forwardRef<
export const IconButton = forwardRef<
HTMLButtonElement,
{
icon?: ReactNode;
Expand Down Expand Up @@ -41,5 +41,3 @@ const IconButton = forwardRef<
</Button>
);
});

export default IconButton;
2 changes: 1 addition & 1 deletion packages/web/components/buttons/link-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ReactElement } from "react";

import { Button } from "~/components/ui/button";

export default function LinkButton({
export function LinkButton({
label,
icon,
ariaLabel,
Expand Down
10 changes: 8 additions & 2 deletions packages/web/components/cards/my-position/expanded.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,17 @@ import { formatPretty, getPriceExtendedFormatOptions } from "~/utils/formatter";
import { RouterOutputs } from "~/utils/trpc";

const ConcentratedLiquidityDepthChart = dynamic(
() => import("~/components/chart/concentrated-liquidity-depth"),
() =>
import("~/components/chart/concentrated-liquidity-depth").then(
(module) => module.ConcentratedLiquidityDepthChart
),
{ ssr: false }
);
const HistoricalPriceChart = dynamic(
() => import("~/components/chart/price-historical"),
() =>
import("~/components/chart/price-historical").then(
(module) => module.HistoricalPriceChart
),
{ ssr: false }
);

Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/cards/my-position/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { FunctionComponent, ReactNode, useState } from "react";
import { Icon, PoolAssetsIcon, PoolAssetsName } from "~/components/assets";
import { MyPositionCardExpandedSection } from "~/components/cards/my-position/expanded";
import { MyPositionStatus } from "~/components/cards/my-position/status";
import SkeletonLoader from "~/components/loaders/skeleton-loader";
import { SkeletonLoader } from "~/components/loaders/skeleton-loader";
import { EventName } from "~/config";
import { useFeatureFlags, useTranslation } from "~/hooks";
import { useAmplitudeAnalytics } from "~/hooks";
Expand Down
2 changes: 0 additions & 2 deletions packages/web/components/cards/validator-squad-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,3 @@ const AvatarIcon: React.FC<{ extraValidators?: number }> = ({
</div>
);
};

export default AvatarIcon;
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type DepthData = {
depth: number;
};

const ConcentratedLiquidityDepthChart: FunctionComponent<{
export const ConcentratedLiquidityDepthChart: FunctionComponent<{
min?: number;
max?: number;
yRange: [number, number];
Expand Down Expand Up @@ -252,6 +252,3 @@ const DragContainer: FunctionComponent<{
/>
</Annotation>
);

// needed for next/dynamic to avoid including visx in main bundle
export default ConcentratedLiquidityDepthChart;
4 changes: 1 addition & 3 deletions packages/web/components/chart/pool-composition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CoinPretty } from "@keplr-wallet/unit";
import Image from "next/image";
import { FunctionComponent } from "react";

const PoolComposition: FunctionComponent<{
export const PoolComposition: FunctionComponent<{
assets: CoinPretty[];
}> = ({ assets }) => {
return (
Expand All @@ -28,5 +28,3 @@ const PoolComposition: FunctionComponent<{
</ul>
);
};

export default PoolComposition;
4 changes: 1 addition & 3 deletions packages/web/components/chart/price-historical-v2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const seriesOpt: DeepPartial<AreaSeriesOptions> = {
crosshairMarkerRadius: 8,
};

const HistoricalPriceChartV2: FunctionComponent<{
export const HistoricalPriceChartV2: FunctionComponent<{
data: { close: number; time: number }[];
onPointerHover?: (price: number) => void;
onPointerOut?: () => void;
Expand Down Expand Up @@ -50,5 +50,3 @@ const HistoricalPriceChartV2: FunctionComponent<{
/>
);
});

export default HistoricalPriceChartV2;
6 changes: 2 additions & 4 deletions packages/web/components/chart/price-historical.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { observer } from "mobx-react-lite";
import React, { FunctionComponent, memo, useCallback, useMemo } from "react";

import { Icon } from "~/components/assets";
import SkeletonLoader from "~/components/loaders/skeleton-loader";
import { SkeletonLoader } from "~/components/loaders/skeleton-loader";
import { ChartButton } from "~/components/ui/button";
import { type PriceRange, useTranslation } from "~/hooks";
import { theme } from "~/tailwind.config";
Expand All @@ -33,7 +33,7 @@ import {
} from "~/utils/formatter";
import { getDecimalCount } from "~/utils/number";

const HistoricalPriceChart: FunctionComponent<{
export const HistoricalPriceChart: FunctionComponent<{
data: { close: number; time: number }[];
margin?: Partial<Margin>;
annotations: Dec[];
Expand Down Expand Up @@ -246,8 +246,6 @@ const HistoricalPriceChart: FunctionComponent<{
)
);

export default HistoricalPriceChart;

export const PriceChartHeader: FunctionComponent<{
historicalRange: PriceRange;
setHistoricalRange: (pr: PriceRange) => void;
Expand Down
6 changes: 3 additions & 3 deletions packages/web/components/client-only.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { PropsWithChildren, useEffect, useState } from "react";

const ClientOnly = (props: PropsWithChildren<{ className?: string }>) => {
export const ClientOnly = (
props: PropsWithChildren<{ className?: string }>
) => {
const [hasMounted, setHasMounted] = useState(false);

useEffect(() => {
Expand All @@ -13,5 +15,3 @@ const ClientOnly = (props: PropsWithChildren<{ className?: string }>) => {

return <div {...props} />;
};

export default ClientOnly;
Loading
Loading