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

Main to injective #408

Merged
merged 29 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
11af60a
chore: More cleanup and stricter lint rules (#337)
jmrossy Nov 25, 2024
4868292
feat: Add NEXT_PUBLIC_REGISTRY_BRANCH (#341)
frank0528 Nov 29, 2024
6d2c88c
chore: Yet more cleanup of dead code / cruft (#344)
jmrossy Nov 30, 2024
b2c1d08
feat: use 5 decimals for the displayed balance (#345)
tkporter Dec 6, 2024
39cbd47
Fix: Bug with Tailwind gray color extension (#347)
jmrossy Dec 6, 2024
784a0c7
Typo fixed in: Update README.md
leonarddt05 Jan 3, 2025
f4c256c
Merge pull request #364 from leonarddt05/patch-1
jmrossy Jan 3, 2025
51cd772
Bump registry to 6.11.0
yorhodes Jan 6, 2025
564c93c
Merge pull request #367 from hyperlane-xyz/registry-6.11.0
yorhodes Jan 6, 2025
d31c8b1
Fix typo: "These are images" -> "These images"fix: update Twitter URL…
sergeypanin1994 Jan 8, 2025
9d90974
Up registry to 6.12
ltyu Jan 9, 2025
6f71fcd
Merge pull request #374 from hyperlane-xyz/ltyu/USDC/ethereum-ink
ltyu Jan 9, 2025
e09b194
chore: Updgrade registry to 6.19
jmrossy Jan 20, 2025
62c311b
Merge pull request #383 from hyperlane-xyz/reg-6.19
jmrossy Jan 20, 2025
e4c1fa3
chore: Add trump to CI branch configs (#384)
jmrossy Jan 20, 2025
6b3679f
feat: Setup vitest and ensure all whitelisted routes are in registry …
jmrossy Jan 22, 2025
70ac191
feat: sync chains with url
Xaroz Jan 23, 2025
06d71ab
feat: add token persistence and utils functions
Xaroz Jan 23, 2025
6eb7689
feat: update status machine to use browser defaults
Xaroz Jan 24, 2025
9d5c079
chore: clean up
Xaroz Jan 24, 2025
dd13742
chore: remove unused util function
Xaroz Jan 24, 2025
8818f75
fix: cycle dependency
Xaroz Jan 24, 2025
e2b9a55
chore: PR recommendations
Xaroz Jan 26, 2025
b3a3aed
feat: Add recipient confirmation modal (#402)
jmrossy Jan 27, 2025
3422674
chore: update file and function names
Xaroz Jan 27, 2025
57d99c4
Merge main into branch
Xaroz Jan 27, 2025
275a3df
Merge pull request #398 from hyperlane-xyz/feat/chains-sync
Xaroz Jan 27, 2025
57bf8e8
chore: Upgrade hyp packages to 8.5.0 (#404)
jmrossy Jan 28, 2025
f352636
chore: fix conflicts
Xaroz Jan 28, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: ci
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main, nautilus, nexus, injective, ezeth]
branches: [main, nautilus, nexus, injective, ezeth, trump]
pull_request:
branches: [main, nautilus, nexus, injective, ezeth]
branches: [main, nautilus, nexus, injective, ezeth, trump]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-merge-prs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
name: [ezeth, injective, nexus]
name: [ezeth, injective, nexus, trump]
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion CUSTOMIZE.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The logo images you should change are:
- `./src/images/logos/app-name.svg`
- `./src/images/logos/app-title.svg`

These are images are primarily used in the header and footer files:
These images are primarily used in the header and footer files:

- `./src/components/nav/Header.tsx`
- `./src/components/nav/Footer.tsx`
Expand Down
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Hyperlane Warp Route UI Template

This repo contains an example web interface for interchain tokens built with [Hyperlane Warp Route](https://docs.hyperlane.xyz/docs/reference/applications/warp-routes). Warp is a framework to permisionlessly bridge tokens to any chain.
This repo contains an example web interface for interchain tokens built with [Hyperlane Warp Route](https://docs.hyperlane.xyz/docs/reference/applications/warp-routes). Warp is a framework to permissionlessly bridge tokens to any chain.

## Architecture

Expand All @@ -18,7 +18,12 @@ See [CUSTOMIZE.md](./CUSTOMIZE.md) for details about adjusting the tokens and br

### Setup

#### Configure

You need a `projectId` from the WalletConnect Cloud to run the Hyperlane Warp Route UI. Sign up to [WalletConnect Cloud](https://cloud.walletconnect.com) to create a new project.

#### Build

```sh
# Install dependencies
yarn
Expand All @@ -27,22 +32,14 @@ yarn
yarn build
```

#### Configure

You need a `projectId` from the WalletConnect Cloud to run the Hyperlane Warp Route UI successfully.
Sign up to [WalletConnect Cloud](https://cloud.walletconnect.com/), create
new project with AppKit and Next.js and copy the `projectId` from there.

### Run

You can add `.env.local` file next to `.env.example` where you set `projectId` copied from WalletConnect Cloud.

```sh
# Start the Next dev server
yarn dev
```

Or you can set the WalletConnect Cloud `projectId` to use as follows:
```
# Or with a custom projectId
NEXT_PUBLIC_WALLET_CONNECT_ID=<projectId> yarn dev
```

Expand Down
9 changes: 7 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,18 @@ export default [
},

rules: {
'camelcase': ['error'],
'guard-for-in': ['error'],
'import/no-cycle': ['error'],
'import/no-self-import': ['error'],
'no-console': ['warn'],
'no-eval': ['error'],
'no-ex-assign': ['error'],
'no-extra-boolean-cast': ['error'],
'no-constant-condition': ['off'],
'guard-for-in': ['error'],
'no-multiple-empty-lines': ['error'],
'jsx-a11y/alt-text': ['off'],

'@typescript-eslint/ban-ts-comment': ['off'],
'@typescript-eslint/explicit-module-boundary-types': ['off'],
'@typescript-eslint/no-explicit-any': ['off'],
Expand All @@ -77,7 +83,6 @@ export default [
},
],

'jsx-a11y/alt-text': ['off'],
'@next/next/no-img-element': ['off'],
},
},
Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hyperlane-xyz/warp-ui-template",
"description": "A web app template for building Hyperlane Warp Route UIs",
"version": "7.1.0",
"version": "8.5.0",
"author": "J M Rossy",
"dependencies": {
"@chakra-ui/next-js": "^2.4.2",
Expand All @@ -17,12 +17,11 @@
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@headlessui/react": "^2.2.0",
"@hyperlane-xyz/registry": "6.10.0",
"@hyperlane-xyz/sdk": "7.1.0",
"@hyperlane-xyz/utils": "7.1.0",
"@hyperlane-xyz/widgets": "7.1.0",
"@hyperlane-xyz/registry": "7.2.2",
"@hyperlane-xyz/sdk": "8.5.0",
"@hyperlane-xyz/utils": "8.5.0",
"@hyperlane-xyz/widgets": "8.5.0",
"@interchain-ui/react": "^1.23.28",
"@metamask/jazzicon": "https://github.com/jmrossy/jazzicon#7a8df28974b4e81129bfbe3cab76308b889032a6",
"@metamask/post-message-stream": "6.1.2",
"@metamask/providers": "10.2.1",
"@rainbow-me/rainbowkit": "^2.2.0",
Expand Down Expand Up @@ -70,6 +69,8 @@
"tailwindcss": "^3.4.15",
"ts-node": "^10.9.2",
"typescript": "5.6.3",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^3.0.3",
"yaml": "^2.6.0",
"yaml-loader": "^0.8.1"
},
Expand All @@ -89,7 +90,7 @@
"typecheck": "tsc",
"lint": "next lint",
"start": "next start",
"test": "echo 'No tests'",
"test": "vitest --watch false",
"prettier": "prettier --write ./src"
},
"types": "dist/src/index.d.ts",
Expand Down
1 change: 0 additions & 1 deletion public/logos/cosmos.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/logos/cosmwasm.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/logos/solana.svg

This file was deleted.

Binary file removed public/logos/weth.png
Binary file not shown.
2 changes: 1 addition & 1 deletion src/components/buttons/ConnectAwareSubmitButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function ConnectAwareSubmitButton<FormValues = any>({ chainName, text, cl
useTimeout(clearErrors, 3500);

return (
<SolidButton type={type} color={color} onClick={onClick} classes={classes}>
<SolidButton type={type} color={color} onClick={onClick} className={classes}>
{content}
</SolidButton>
);
Expand Down
6 changes: 3 additions & 3 deletions src/components/buttons/SolidButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface ButtonProps {
type?: 'submit' | 'reset' | 'button';
color?: 'white' | 'primary' | 'accent' | 'green' | 'red' | 'gray'; // defaults to primary
bold?: boolean;
classes?: string;
className?: string;
icon?: ReactElement;
}

Expand All @@ -15,7 +15,7 @@ export function SolidButton(
type,
onClick,
color: _color,
classes,
className,
bold,
icon,
disabled,
Expand Down Expand Up @@ -48,7 +48,7 @@ export function SolidButton(
}
const onDisabled = 'disabled:bg-gray-300 disabled:text-gray-500';
const weight = bold ? 'font-semibold' : '';
const allClasses = `${base} ${baseColors} ${onHover} ${onDisabled} ${weight} ${classes}`;
const allClasses = `${base} ${baseColors} ${onHover} ${onDisabled} ${weight} ${className}`;

return (
<button
Expand Down
41 changes: 0 additions & 41 deletions src/components/icons/Identicon.tsx

This file was deleted.

6 changes: 0 additions & 6 deletions src/components/icons/types.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/consts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export const MAIN_FONT = Inter({
export const APP_NAME = 'Injective Token Bridge';
export const APP_DESCRIPTION = 'A token bridge for Injective powered by Hyperlane';
export const APP_URL = 'https://inevmbridge.com';
export const BRAND_COLOR = Color.primary;
export const BACKGROUND_COLOR = Color.primary;
export const BRAND_COLOR = Color.primary['500'];
export const BACKGROUND_COLOR = Color.primary['500'];
export const BACKGROUND_IMAGE = 'url(/backgrounds/main.svg)';
5 changes: 5 additions & 0 deletions src/consts/args.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum WARP_QUERY_PARAMS {
ORIGIN = 'origin',
DESTINATION = 'destination',
TOKEN = 'token',
}
9 changes: 3 additions & 6 deletions src/consts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,38 @@ import { ADDRESS_BLACKLIST } from './blacklist';
const isDevMode = process?.env?.NODE_ENV === 'development';
const version = process?.env?.NEXT_PUBLIC_VERSION || '0.0.0';
const registryUrl = process?.env?.NEXT_PUBLIC_REGISTRY_URL || undefined;
const registryBranch = process?.env?.NEXT_PUBLIC_REGISTRY_BRANCH || undefined;
const registryProxyUrl = process?.env?.NEXT_PUBLIC_GITHUB_PROXY || 'https://proxy.hyperlane.xyz';
const explorerApiKeys = JSON.parse(process?.env?.EXPLORER_API_KEYS || '{}');
const walletConnectProjectId = process?.env?.NEXT_PUBLIC_WALLET_CONNECT_ID || '';
const withdrawalWhitelist = process?.env?.NEXT_PUBLIC_BLOCK_WITHDRAWAL_WHITELIST || '';
const transferBlacklist = process?.env?.NEXT_PUBLIC_TRANSFER_BLACKLIST || '';
const chainWalletWhitelists = JSON.parse(process?.env?.NEXT_PUBLIC_CHAIN_WALLET_WHITELISTS || '{}');

interface Config {
addressBlacklist: string[]; // A list of addresses that are blacklisted and cannot be used in the app
chainWalletWhitelists: ChainMap<string[]>; // A map of chain names to a list of wallet names that work for it
enableExplorerLink: boolean; // Include a link to the hyperlane explorer in the transfer modal
explorerApiKeys: Record<string, string>; // Optional map of API keys for block explorer
isDevMode: boolean; // Enables some debug features in the app
registryUrl: string | undefined; // Optional URL to use a custom registry instead of the published canonical version
registryBranch?: string | undefined; // Optional customization of the registry branch instead of main
registryProxyUrl?: string; // Optional URL to use a custom proxy for the GithubRegistry
showDisabledTokens: boolean; // Show/Hide invalid token options in the selection modal
showTipBox: boolean; // Show/Hide the blue tip box above the transfer form
transferBlacklist: string; // comma-separated list of routes between which transfers are disabled. Expects Caip2Id-Caip2Id (e.g. ethereum:1-sealevel:1399811149)
version: string; // Matches version number in package.json
walletConnectProjectId: string; // Project ID provided by walletconnect
withdrawalWhitelist: string; // comma-separated list of CAIP2 chain IDs to which transfers are supported
}

export const config: Config = Object.freeze({
addressBlacklist: ADDRESS_BLACKLIST.map((address) => address.toLowerCase()),
chainWalletWhitelists,
enableExplorerLink: false,
explorerApiKeys,
isDevMode,
registryUrl,
registryBranch,
registryProxyUrl,
showDisabledTokens: false,
showTipBox: false,
version,
transferBlacklist,
walletConnectProjectId,
withdrawalWhitelist,
});
2 changes: 1 addition & 1 deletion src/consts/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const links = {
chains: 'https://docs.hyperlane.xyz/docs/resources/domains',
discord: 'https://discord.gg/hyperlane',
github: 'https://github.com/hyperlane-xyz/hyperlane-warp-ui-template',
twitter: 'https://twitter.com/hyperlane',
twitter: 'https://x.com/hyperlane',
blog: 'https://medium.com/hyperlane',
caldera: 'https://www.caldera.xyz',
tos: 'https://hyperlane.xyz/terms-of-service',
Expand Down
10 changes: 10 additions & 0 deletions src/consts/warpRouteWhitelist.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { warpRouteConfigs } from '@hyperlane-xyz/registry';
import { assert, test } from 'vitest';
import { warpRouteWhitelist } from './warpRouteWhitelist';

test('warpRouteWhitelist', () => {
if (!warpRouteWhitelist) return;
for (const id of warpRouteWhitelist) {
assert(warpRouteConfigs[id], `No route with id ${id} found in registry.`);
}
});
5 changes: 2 additions & 3 deletions src/features/chains/ChainSelectField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useChainDisplayName } from './hooks';
type Props = {
name: string;
label: string;
onChange?: (id: ChainName) => void;
onChange?: (id: ChainName, fieldName: string) => void;
disabled?: boolean;
customListItemField: ChainSearchMenuProps['customListItemField'];
};
Expand All @@ -25,8 +25,7 @@ export function ChainSelectField({ name, label, onChange, disabled, customListIt
// Reset other fields on chain change
setFieldValue('recipient', '');
setFieldValue('amount', '');
setFieldValue('tokenIndex', undefined);
if (onChange) onChange(chainName);
if (onChange) onChange(chainName, name);
};

const [isModalOpen, setIsModalOpen] = useState(false);
Expand Down
18 changes: 10 additions & 8 deletions src/features/chains/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ export function hasPermissionlessChain(multiProvider: MultiProtocolProvider, ids
return !ids.every((c) => !isPermissionlessChain(multiProvider, c));
}

export function getChainByRpcUrl(multiProvider: MultiProtocolProvider, url?: string) {
if (!url) return undefined;
const allMetadata = Object.values(multiProvider.metadata);
return allMetadata.find(
(m) => !!m.rpcUrls.find((rpc) => rpc.http.toLowerCase().includes(url.toLowerCase())),
);
}

/**
* Returns an object that contains the amount of
* routes from a single chain to every other chain
Expand Down Expand Up @@ -70,3 +62,13 @@ export function getNumRoutesWithSelectedChain(
data,
};
}

/**
* Return given chainName if it is valid, otherwise return undefined
*/
export function tryGetValidChainName(
chainName: string | null,
multiProvider: MultiProtocolProvider,
): string | undefined {
return chainName && multiProvider.tryGetChainName(chainName) ? chainName : undefined;
}
6 changes: 5 additions & 1 deletion src/features/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ export const useStore = create<AppState>()(
set({ chainMetadataOverrides: filtered, multiProvider });
},
multiProvider: new MultiProtocolProvider({}),
registry: new GithubRegistry({ uri: config.registryUrl, proxyUrl: config.registryProxyUrl }),
registry: new GithubRegistry({
uri: config.registryUrl,
branch: config.registryBranch,
proxyUrl: config.registryProxyUrl,
}),
warpCore: new WarpCore(new MultiProtocolProvider({}), []),
setWarpContext: ({ registry, chainMetadata, multiProvider, warpCore }) => {
logger.debug('Setting warp context in store');
Expand Down
Loading