Skip to content

Commit

Permalink
fix(dw): Fund btn + networkId
Browse files Browse the repository at this point in the history
  • Loading branch information
javadkh2 committed Oct 25, 2024
1 parent cb02e7e commit dfd165b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,11 @@ export const ChainBalance: FC<IProps> = ({
Chain {chainId}
</Text>
{!editable && activeNetwork?.faucetContract && fundAccount && (
<span className={fundButtonClass}>
<FundOnTestnetButton
fundAccountHandler={fundAccount}
chainId={chainId}
/>
</span>
<FundOnTestnetButton
className={fundButtonClass}
fundAccountHandler={fundAccount}
chainId={chainId}
/>
)}
</Stack>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export const fundButtonClass = style({
'&:focus': {
opacity: 1,
},
'&.pending': {
opacity: 1,
},
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,32 @@ import { ITransaction } from '@/modules/transaction/transaction.repository';
import { useWallet } from '@/modules/wallet/wallet.hook';
import { TxContainer } from '@/pages/transaction/components/TxContainer';
import { ChainId } from '@kadena/client';
import { Button } from '@kadena/kode-ui';
import { MonoAutorenew } from '@kadena/kode-icons/system';
import { Button, Stack } from '@kadena/kode-ui';
import classNames from 'classnames';
import { useState } from 'react';

export function FundOnTestnetButton({
account,
chainId,
fundAccountHandler,
className,
}: {
account?: IAccount;
chainId?: ChainId;
fundAccountHandler: (chainId: ChainId) => Promise<ITransaction>;
className?: string;
}) {
const [fundTx, setFundTx] = useState<ITransaction>();
const { syncAllAccounts } = useWallet();
const [done, setDone] = useState(false);

return (
<>
<Stack
gap={'sm'}
alignItems={'center'}
className={classNames(className, fundTx && 'pending')}
>
{!fundTx && (
<Button
variant="outlined"
Expand All @@ -46,12 +55,22 @@ export function FundOnTestnetButton({
} else {
syncAllAccounts();
}
if (tx.result?.result.status === 'success') {
setTimeout(() => setFundTx(undefined), 2000);
}
setDone(true);
}}
/>
)}
</>
{fundTx && done && (
<Button
isCompact
variant="transparent"
onClick={() => {
setFundTx(undefined);
setDone(false);
}}
>
<MonoAutorenew />
</Button>
)}
</Stack>
);
}
2 changes: 1 addition & 1 deletion packages/apps/dev-wallet/src/modules/db/db.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const setupDatabase = execInSequence(async (): Promise<IDBDatabase> => {
unique: true,
},
]);
create('network', 'uuid', [{ index: 'networkId' }]);
create('network', 'uuid', [{ index: 'networkId', unique: true }]);
create('fungible', 'contract', [{ index: 'symbol', unique: true }]);
create('keyset', 'uuid', [
{ index: 'profileId' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export const labelClass = style({
background: tokens.kda.foundation.color.background.surface.default,
padding: '8px',
marginLeft: '-12px',
fontWeight: '700',
});

0 comments on commit dfd165b

Please sign in to comment.