Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Apr 16, 2024
1 parent d230610 commit af784aa
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@polkadot/extension-dapp": "^0.46.9",
"@polkadot/extension-inject": "^0.46.9",
"@polkadot/keyring": "^12.6.2",
"@polkadot/types": "^10.12.6",
"@polkadot/util": "^12.6.2",
"@tabler/icons-react": "^2.47.0",
"axios": "^1.6.8",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@ import './App.css';
import {
MantineProvider,
Image,
NavLink,
createTheme,
MantineColorsTuple,
Button,
Modal,
Stack,
} from '@mantine/core';
import { BrowserRouter, Routes, Route, NavLink as RouterNavLink } from 'react-router-dom';
import RouterTransferPage from './routes/RouterTransferPage';
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import { useDisclosure } from '@mantine/hooks';
import { AppShell, Burger, Group } from '@mantine/core';
import { IconHome2 } from '@tabler/icons-react';
import { Group } from '@mantine/core';
import { web3Accounts, web3Enable } from '@polkadot/extension-dapp';
import { InjectedAccountWithMeta } from '@polkadot/extension-inject/types';
import { useState } from 'react';
Expand Down Expand Up @@ -42,7 +39,6 @@ const theme = createTheme({
});

const App = () => {
const [opened, { toggle }] = useDisclosure();
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);

const [accounts, setAccounts] = useState<InjectedAccountWithMeta[]>([]);
Expand Down
22 changes: 11 additions & 11 deletions src/components/TransferForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {Button, Grid, Stack, TextInput} from '@mantine/core';
import {createApiInstanceForNode, TNodeWithRelayChains} from '@paraspell/sdk';
import {useWallet} from "../providers/WalletProvider.tsx";
import {formatBalance} from "@polkadot/util";
import { AccountInfo } from '@polkadot/types/interfaces';

export type FormValues = {
from: TNodeWithRelayChains;
Expand All @@ -25,8 +26,8 @@ const TransferForm: FC<Props> = ({ onSubmit, loading }) => {
const encointerApi = createApiInstanceForNode('Encointer')
const kusamaApi = createApiInstanceForNode('Kusama')

const [encointerBalance, setEncointerBalance] = useState();
const [kusamaBalance, setKusamaBalance] = useState();
const [encointerBalance, setEncointerBalance] = useState<string | undefined>(undefined);
const [kusamaBalance, setKusamaBalance] = useState<string | undefined>(undefined);

formatBalance.setDefaults({
decimals: 12,
Expand All @@ -38,36 +39,35 @@ const TransferForm: FC<Props> = ({ onSubmit, loading }) => {
}, [selectedAccount]);

useEffect(() => {
let unsubscribe
encointerApi.then((api) => {
let unsubscribe: AccountInfo | undefined;
// If the user has selected an address, create a new subscription
selectedAccount &&
api.query.system
.account(selectedAccount.address, balance =>
.account<AccountInfo>(selectedAccount.address, (balance: AccountInfo) =>
{
setEncointerBalance(formatBalance(balance.data.free))
form.values.amount = Math.max(0, balance.data.free * Math.pow(10, -12) - 0.001)
}
)
form.values.amount = Math.max(0, Number(balance.data.free) * Math.pow(10, -12) - 0.001)
})
.then(unsub => (unsubscribe = unsub))
.catch(console.error)
return () => unsubscribe && unsubscribe()
return () => unsubscribe
})
}, [selectedAccount, encointerApi]);

useEffect(() => {
let unsubscribe
if (selectedAccount) form.values.address = selectedAccount.address;
let unsubscribe: AccountInfo | undefined;
kusamaApi.then((api) => {
// If the user has selected an address, create a new subscription
selectedAccount &&
api.query.system
.account(selectedAccount.address, balance =>
.account<AccountInfo>(selectedAccount.address, (balance: AccountInfo) =>
setKusamaBalance(formatBalance(balance.data.free))
)
.then(unsub => (unsubscribe = unsub))
.catch(console.error)
return () => unsubscribe && unsubscribe()
return () => unsubscribe
})
}, [selectedAccount, kusamaApi]);

Expand Down
3 changes: 1 addition & 2 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import WalletProvider, {useWallet} from './providers/WalletProvider';
import {createApiInstanceForNode} from "@paraspell/sdk";
import WalletProvider from './providers/WalletProvider';

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
Expand Down

0 comments on commit af784aa

Please sign in to comment.