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

feat: Using api to fetch stargate & meson config #218

Merged
merged 12 commits into from
Dec 24, 2024
Merged
6 changes: 6 additions & 0 deletions .release/.changeset/bright-impalas-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@bnb-chain/canonical-bridge-widget": patch
"@bnb-chain/canonical-bridge-sdk": patch
---

Use stargate & meson api to fetch chain & token config
12 changes: 12 additions & 0 deletions .release/.changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"mode": "pre",
"tag": "alpha",
"initialVersions": {
"@bnb-chain/canonical-bridge-sdk": "0.4.5",
"@bnb-chain/canonical-bridge-widget": "0.5.15"
},
"changesets": [
"bright-impalas-sniff",
"serious-cars-worry"
]
}
5 changes: 5 additions & 0 deletions .release/.changeset/serious-cars-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bnb-chain/canonical-bridge-widget": patch
---

Add more token info to token element
1 change: 0 additions & 1 deletion .release/scripts/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ process.chdir(rootDir);

console.log('Install changeset dependencies...');
exec('pnpm install', (err, stdout) => {
console.log('shshshshsh');
if (stdout) {
console.log(stdout);
}
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"tronwallet",
"tronweb",
"unauthenticate",
"vconsole",
"viem",
"Wagmi",
"walletkit"
Expand Down
2 changes: 1 addition & 1 deletion apps/canonical-bridge-server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ STARGATE_ENDPOINT='https://mainnet.stargate-api.com/v1/metadata?version=v2'
MESON_ENDPOINT=https://relayer.meson.fi/api/v1

REDIS_URL=http://127.0.0.1:6379
DATABASE_URL=mysql://test:xxx@localhost:3306/bridge
DATABASE_URL=
3 changes: 0 additions & 3 deletions apps/canonical-bridge-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
FROM busybox:1.36.1 as builder
FROM node:20-buster

RUN useradd -u 9000 appuser
USER appuser

WORKDIR /opt/deploy

COPY . .
Expand Down
15 changes: 15 additions & 0 deletions apps/canonical-bridge-ui/core/components/VConsole/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { useMemo } from 'react';

export function VConsole() {
useMemo(async () => {
if (typeof window !== 'undefined') {
try {
new (await import('vconsole')).default();
} catch (err) {
// eslint-disable-next-line no-console
console.log(`Init vconsole error!`, err);
}
}
}, []);
return null;
}
8 changes: 4 additions & 4 deletions apps/canonical-bridge-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@
"@solana/web3.js": "~1.95.4",
"@tanstack/react-query": "~5.50.1",
"@tronweb3/tronwallet-adapter-react-hooks": "~1.1.9",
"axios": "~1.6.8",
"next": "~14.1.1",
"axios": "~1.7.4",
"next": "~14.2.21",
"pino-pretty": "~11.2.1",
"polished": "~4.3.1",
"react": "~18.3.1",
"react-dom": "~18.3.1",
"supports-color": "~9.4.0",
"tronweb": "~6.0.0",
"viem": "~2.21.14",
"wagmi": "^2"
"wagmi": "^2",
"vconsole": "~3.15.1"
},
"devDependencies": {
"@babel/core": "^7.21.4",
Expand All @@ -51,7 +52,6 @@
"eslint-config-next": "14.2.3",
"lint-staged": "~13.0.3",
"prettier": "~2.7.1",
"supports-color": "8.1.1",
"typescript": "5.5.4"
},
"lint-staged": {
Expand Down
2 changes: 2 additions & 0 deletions apps/canonical-bridge-ui/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { AppProps } from 'next/app';

import { ThemeProvider } from '@/core/components/ThemeProvider';
import { SvgDefs } from '@/core/components/icons/SvgDefs';
import { VConsole } from '@/core/components/VConsole';

const queryClient = new QueryClient({
defaultOptions: {
Expand All @@ -19,6 +20,7 @@ const queryClient = new QueryClient({
export default function App({ Component, ...restProps }: AppProps) {
return (
<>
<VConsole />
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
</Head>
Expand Down
10 changes: 0 additions & 10 deletions apps/canonical-bridge-ui/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@ export default class Document extends NextDocument {
<Html lang="en">
<Head>
<link rel="stylesheet" href={`${env.ASSET_PREFIX}/fonts/index.css`} />
<script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js" defer></script>
<script
dangerouslySetInnerHTML={{
__html: `
window.onload = () => {
new window.VConsole();
}
`,
}}
/>
<style
dangerouslySetInnerHTML={{
__html: `
Expand Down
24 changes: 1 addition & 23 deletions apps/canonical-bridge-ui/pages/mainnet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import {
BridgeTransfer,
BridgeRoutes,
} from '@bnb-chain/canonical-bridge-widget';
import { useMemo } from 'react';
import { useAccount } from 'wagmi';

import { useTransferConfig } from '@/token-config/mainnet/useTransferConfig';
import { chains } from '@/token-config/mainnet/chains';
Expand All @@ -16,13 +14,6 @@ import { useWalletModal } from '@/core/wallet/hooks/useWalletModal';
import { WalletProvider } from '@/core/wallet/WalletProvider';
import { Layout } from '@/core/components/Layout';

const unsupportedChainsInWallets = [
{
wallets: ['BinanceW3WSDK', 'binanceWeb3Wallet'],
chains: [1101],
},
];

export const bridgeConfig: ICanonicalBridgeConfig = {
appName: env.APP_NAME,
assetPrefix: env.ASSET_PREFIX,
Expand Down Expand Up @@ -53,24 +44,11 @@ function BridgeWidget() {
const transferConfig = useTransferConfig();
const { onOpen } = useWalletModal();

const { connector } = useAccount();
const supportedChains = useMemo(() => {
return chains.filter((e) => {
if (connector) {
const unsupportedChains = unsupportedChainsInWallets.find((e) =>
e.wallets.includes(connector.id),
)?.chains;
return !unsupportedChains?.includes(e.id);
}
return true;
});
}, [connector]);

return (
<CanonicalBridgeProvider
config={bridgeConfig}
transferConfig={transferConfig}
chains={supportedChains}
chains={chains}
onClickConnectWalletButton={onOpen}
>
<Layout>
Expand Down
Loading
Loading