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

[SPE-283] feat: add tx history interface #60

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
ff36438
chore: dedupe
grikomsn Oct 25, 2023
8072645
feat: add raise util
grikomsn Oct 25, 2023
b76210d
refactor: rewrite codegen script
grikomsn Oct 25, 2023
7b51a34
feat: add clsx, zustand deps
grikomsn Oct 25, 2023
297166b
feat: create history button components
grikomsn Oct 18, 2023
37ee6f8
feat: init disclosures ctx/store
grikomsn Oct 20, 2023
9b36a04
feat: attach history button disclosure
grikomsn Oct 20, 2023
f5a778e
feat: create history clear button component
grikomsn Oct 25, 2023
13811b9
feat: add json disclosure
grikomsn Oct 25, 2023
717d8a0
feat: create AssetValue component
grikomsn Oct 25, 2023
763fdf5
feat: create ChainSymbol component
grikomsn Oct 25, 2023
69d86e6
feat: init randomId util
grikomsn Oct 26, 2023
3e844d1
feat: init txHistory store
grikomsn Oct 26, 2023
c2e294f
feat: attach history clear button action
grikomsn Oct 26, 2023
fe9c10a
feat: create JsonDialog
grikomsn Oct 26, 2023
94a20f5
feat: attach JsonDialog in SwapWidget
grikomsn Oct 26, 2023
fbffde6
feat: attach txHistory actions in TxDialogContent
grikomsn Oct 26, 2023
affa552
feat: init HistoryDialog components
grikomsn Oct 26, 2023
1775787
feat: attach HistoryButton in SwapWidget
grikomsn Oct 26, 2023
0611d4f
feat: attach HistoryDialog in SwapWidget
grikomsn Oct 26, 2023
ff68ee3
fix: remove invalid props
grikomsn Oct 26, 2023
7d64407
feat: open hash explorer in new tab
grikomsn Oct 26, 2023
c9a46b5
feat: add tailwind defs for radix accordion
grikomsn Oct 26, 2023
3db2a63
feat: improve HistoryList ux
grikomsn Oct 26, 2023
fe1373f
fix: remove tx history on throwed route error
grikomsn Oct 26, 2023
5c57548
feat: add AssetsProvider ready state
grikomsn Oct 26, 2023
7b563c0
fix: wait HistoryDialog for AssetsProvider to properly load
grikomsn Oct 26, 2023
801a007
feat: add chain registry submodule
grikomsn Oct 29, 2023
6cc0645
feat: add codegen deps
grikomsn Oct 30, 2023
9f541ae
refactor: rewrite codegen from scratch
grikomsn Oct 30, 2023
0dcbe5f
feat: suppress zustand vanilla store warning
grikomsn Oct 30, 2023
16b18fb
refactor: remove chain-registry usage
grikomsn Oct 30, 2023
eee656a
update chain record type
thal0x Oct 30, 2023
5ed58f3
chore: update chain-registry
grikomsn Oct 30, 2023
46a879a
fix: enable submodules on gh test workflow
grikomsn Oct 30, 2023
d853fca
fix: force typed chain provider values
grikomsn Oct 30, 2023
526499a
update submodule
thal0x Oct 30, 2023
3a09bdf
update submodule
thal0x Oct 30, 2023
be0994c
update submodule
thal0x Oct 30, 2023
6ebd53b
fix: force typed chain provider values
grikomsn Oct 30, 2023
4aea40b
update submodule
thal0x Oct 30, 2023
02bed20
Merge branch 'refactor/rewrite-codegen-2' of github.com:skip-mev/ibc-…
thal0x Oct 30, 2023
4acab36
update submodule
thal0x Oct 30, 2023
86a5cc9
refactor: drop chain-registry usage (#63)
Oct 30, 2023
cbc9452
feat: init AlertCollapse components
grikomsn Oct 30, 2023
29a95bf
refactor: use extracted AlertCollapse component
grikomsn Oct 30, 2023
7a09298
chore: TxDialogContent style housekeeping
grikomsn Oct 30, 2023
c88227f
chore: update chain-registry
grikomsn Oct 30, 2023
9c121e9
feat: add type variants for AlertCollapse
grikomsn Oct 30, 2023
2b9a5fd
refactor: update tx dialog content alert
grikomsn Oct 30, 2023
54f3d98
feat: adjust history dialog desc list sizing
grikomsn Oct 30, 2023
97cba87
feat: add history item component some pizzaz
grikomsn Oct 30, 2023
e30447a
chore: simplify null coalescing
grikomsn Oct 30, 2023
f91d06e
feat: add comp time in tx history
grikomsn Oct 30, 2023
dc0c2a2
fix: increase SwapWidget timeout
grikomsn Oct 30, 2023
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
8 changes: 7 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true

- name: Use Node 18.x
uses: actions/setup-node@v3
Expand All @@ -28,7 +30,11 @@ jobs:
container:
image: mcr.microsoft.com/playwright:v1.38.0-jammy
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- run: git config --system --add safe.directory /__w/ibc-dot-fun/ibc-dot-fun
- uses: actions/setup-node@v3
with:
node-version: 18
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "chain-registry"]
path = chain-registry
url = https://github.com/cosmos/chain-registry.git
1 change: 1 addition & 0 deletions chain-registry
Submodule chain-registry added at 5a391c
4 changes: 4 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ global.ResizeObserver = require("resize-observer-polyfill");

// eslint-disable-next-line @typescript-eslint/no-var-requires
global.TextEncoder = require("util").TextEncoder;

// suppress zustand deprecation notice to clear out logs
global.console.warn = (...args) =>
args[0]?.includes("vanilla store") ? void 0 : global.console.warn;
3,360 changes: 2,147 additions & 1,213 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"postinstall": "node ./scripts/generate.js",
"postinstall": "git submodule init && git submodule update && tsx ./src/scripts/codegen.ts",
"start": "next start",
"lint": "next lint",
"test": "jest",
Expand All @@ -31,6 +31,7 @@
"@evmos/proto": "^0.2.1",
"@evmos/provider": "^0.3.1",
"@evmos/transactions": "^0.3.2",
"@graz-sh/types": "^0.0.12",
"@headlessui/react": "^1.7.14",
"@heroicons/react": "^2.0.18",
"@injectivelabs/sdk-ts": "^1.11.0",
Expand All @@ -50,8 +51,8 @@
"@web3modal/ui": "^2.7.0",
"autoprefixer": "10.4.14",
"axios": "^1.4.0",
"chain-registry": "^1.18.0",
"classnames": "^2.3.2",
"clsx": "^2.0.0",
"cosmjs-types": "^0.7.2",
"download": "^8.0.0",
"eslint-config-next": "13.4.1",
Expand All @@ -66,30 +67,37 @@
"tailwindcss": "3.3.2",
"usehooks-ts": "^2.9.1",
"viem": "^1.14.0",
"wagmi": "^1.4.3"
"wagmi": "^1.4.3",
"zod": "^3.22.4",
"zustand": "^4.4.4"
},
"devDependencies": {
"@playwright/test": "^1.38.0",
"@tanstack/eslint-plugin-query": "^4.36.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"@types/degit": "^2.8.5",
"@types/download": "^8.0.2",
"@types/http-proxy": "^1.17.11",
"@types/jest": "^29.5.3",
"@types/testing-library__jest-dom": "^5.14.5",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"degit": "npm:tiged@^2.12.5",
"eslint": "^8.49.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"globby": "^13.2.2",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"msw": "^1.2.3",
"p-map": "^6.0.0",
"prettier": "^3.0.3",
"resize-observer-polyfill": "^1.5.1",
"ts-jest": "^29.1.1",
"tsx": "^3.14.0",
"typescript": "^5.0.4"
}
}
54 changes: 0 additions & 54 deletions scripts/generate.js

This file was deleted.

11 changes: 4 additions & 7 deletions src/api/queries.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Chain as SkipChain } from "@skip-router/core";
import { useQuery } from "@tanstack/react-query";
import * as chainRegistry from "chain-registry";

import { chainRecord } from "@/chains";
import { useSkipClient } from "@/solve";

export type Chain = {
prettyName: string;
record?: (typeof chainRegistry.chains)[number];
record?: (typeof chainRecord)[string];
} & SkipChain;

export type UseChainsQueryArgs<T = Chain[]> = {
Expand All @@ -26,11 +26,8 @@ export function useChains<T = Chain[]>(args: UseChainsQueryArgs<T> = {}) {
});

return chains
.map((chain) => {
const record = chainRegistry.chains.find(
(c) => c.chain_id === chain.chainID,
);

.map((chain): Chain => {
const record = chainRecord[chain.chainID];
return {
...chain,
prettyName: record?.pretty_name ?? chain.chainName,
Expand Down
3 changes: 3 additions & 0 deletions src/ast/_constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as os from "os";

export const concurrency = Math.max(1, (os.cpus() || { length: 1 }).length - 1);
15 changes: 15 additions & 0 deletions src/ast/_types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Asset, AssetList, Chain } from "@graz-sh/types";

export interface Variables {
assetlists: AssetList[];
chains: Chain[];

chainIds: string[];
chainNames: string[];

chainIdToName: Record<string, string>;
chainNameToId: Record<string, string>;

chainRecord: Record<string, Chain>;
assetsRecord: Record<string, Asset[]>;
}
17 changes: 17 additions & 0 deletions src/ast/get-chains-paths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { globby } from "globby";

interface Args {
registryPath: string;
}

export async function getChainsPaths({ registryPath }: Args) {
const mainnetGlobs = ["*", "!_*", "!testnets"];
const testnetGlobs = ["testnets/*", "!testnets/_*"];

const paths = await globby([...mainnetGlobs, ...testnetGlobs], {
cwd: registryPath,
onlyDirectories: true,
});

return paths;
}
26 changes: 26 additions & 0 deletions src/ast/parse-asset-list-json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { AssetList } from "@graz-sh/types";
import { assetListSchema } from "@graz-sh/types/zod";
import * as fs from "fs/promises";
import * as path from "path";

interface Args {
registryPath: string;
chainPath: string;
}

export async function parseAssetListJson({ registryPath, chainPath }: Args) {
const jsonPath = path.resolve(registryPath, chainPath, "assetlist.json");

let data: AssetList;
try {
const content = await fs.readFile(jsonPath, "utf-8");
data = await assetListSchema.parseAsync(JSON.parse(content));
} catch (error) {
data = {
chain_name: chainPath,
assets: [],
};
}

return data;
}
18 changes: 18 additions & 0 deletions src/ast/parse-chain-json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Chain } from "@graz-sh/types";
import { chainSchema } from "@graz-sh/types/zod";
import * as fs from "fs/promises";
import * as path from "path";

interface Args {
registryPath: string;
chainPath: string;
}

export async function parseChainJson({ registryPath, chainPath }: Args) {
const jsonPath = path.resolve(registryPath, chainPath, "chain.json");

const content = await fs.readFile(jsonPath, "utf-8");
const data: Chain = await chainSchema.parseAsync(JSON.parse(content));

return data;
}
63 changes: 63 additions & 0 deletions src/ast/parse-chain-paths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { Asset, AssetList, Chain } from "@graz-sh/types";
import pMap from "p-map";

import { concurrency } from "./_constants";
import { Variables } from "./_types";
import { parseAssetListJson } from "./parse-asset-list-json";
import { parseChainJson } from "./parse-chain-json";

interface Args {
registryPath: string;
chainPaths: string[];
}

export async function parseChainPaths({
registryPath,
chainPaths,
}: Args): Promise<Variables> {
const chains: Chain[] = [];
const assetlists: AssetList[] = [];

const chainIds: string[] = [];
const chainNames: string[] = [];

const chainIdToName: Record<string, string> = {};
const chainNameToId: Record<string, string> = {};
const chainRecord: Record<string, Chain> = {};
const assetsRecord: Record<string, Asset[]> = {};

async function loadChainPath(chainPath: string) {
const [assetlist, chain] = await Promise.all([
parseAssetListJson({ registryPath, chainPath }),
parseChainJson({ registryPath, chainPath }),
]);

chains.push(chain);
assetlists.push(assetlist);

chainIds.push(chain.chain_id);
chainNames.push(chain.chain_name);

chainIdToName[chain.chain_id] = chain.chain_name;
chainIdToName[chain.chain_name] = chain.chain_name;

chainNameToId[chain.chain_name] = chain.chain_id;
chainNameToId[chain.chain_id] = chain.chain_id;

chainRecord[chain.chain_id] = chain;
assetsRecord[chain.chain_id] = assetlist.assets;
}

await pMap(chainPaths, loadChainPath, { concurrency });

return {
chains,
assetlists,
chainIds,
chainNames,
chainIdToName,
chainNameToId,
chainRecord,
assetsRecord,
};
}
31 changes: 31 additions & 0 deletions src/ast/validate-chains-paths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as fs from "fs/promises";
import pMap, { pMapSkip } from "p-map";
import * as path from "path";

import { concurrency } from "./_constants";

interface Args {
registryPath: string;
chainPaths: string[];
}

export async function validateChainsPaths({ registryPath, chainPaths }: Args) {
const filesToCheck = ["chain.json"];

const checkFiles = async (chainPath: string) => {
try {
await Promise.all(
filesToCheck.map((file) => {
return fs.lstat(path.resolve(registryPath, chainPath, file));
}),
);
return chainPath;
} catch (error) {
return pMapSkip;
}
};

const validChainPaths = await pMap(chainPaths, checkFiles, { concurrency });

return validChainPaths;
}
Loading