Skip to content

Commit

Permalink
Merge branch 'main' into feat/devwallet/profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
sstraatemans committed Nov 8, 2024
2 parents 80db521 + 75ae180 commit 5f9ba5c
Show file tree
Hide file tree
Showing 17 changed files with 390 additions and 186 deletions.
2 changes: 2 additions & 0 deletions .changeset/pretty-terms-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
MonoLoading,
} from '@kadena/kode-icons/system';
import { Button, Notification, Stack, TextField } from '@kadena/kode-ui';
import { useState } from 'react';
import { useEffect, useState } from 'react';
import { KeySetDialog } from '../KeysetDialog/KeySetDialog';

export function AccountInput({
Expand All @@ -31,6 +31,44 @@ export function AccountInput({
const [discovering, setDiscovering] = useState(false);
const selectedAccount =
discoveredAccounts.length === 1 ? discoveredAccounts[0] : undefined;

useEffect(() => {
if (account?.address) {
setAddress(account.address);
handleDiscover(account.address);
}
}, [account?.address]);

const handleDiscover = async (addressArg?: string) => {
const innerAddress = typeof addressArg === 'string' ? addressArg : address;
try {
if (!innerAddress) {
return;
}
setDiscovering(true);
setNeedToAddKeys(false);
const accounts = await discoverReceiver(
innerAddress,
networkId,
contract,
(key) => key,
);
setDiscovering(false);
if (accounts.length > 1) {
setDiscoveredAccounts(accounts);
return;
}
if (accounts.length === 0) {
setNeedToAddKeys(true);
return;
}
setDiscoveredAccounts(accounts);
onAccount(accounts[0]);
} catch (e: any) {
setError(e && e.message ? e : JSON.stringify(e));
}
};

return (
<Stack flexDirection={'column'}>
{showKeysetDialog && (
Expand Down Expand Up @@ -78,34 +116,7 @@ export function AccountInput({
}
value={address}
onChange={(e) => setAddress(e.target.value)}
onBlur={async () => {
try {
if (!address || address === account?.address) {
return;
}
setDiscovering(true);
setNeedToAddKeys(false);
const accounts = await discoverReceiver(
address,
networkId,
contract,
(key) => key,
);
setDiscovering(false);
if (accounts.length > 1) {
setDiscoveredAccounts(accounts);
return;
}
if (accounts.length === 0) {
setNeedToAddKeys(true);
return;
}
setDiscoveredAccounts(accounts);
onAccount(accounts[0]);
} catch (e: any) {
setError(e && e.message ? e : JSON.stringify(e));
}
}}
onBlur={() => handleDiscover()}
/>
{selectedAccount && selectedAccount.keyset.guard && (
<Keyset guard={selectedAccount.keyset.guard} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ export async function syncTransactionStatus(
tx: ITransaction,
client: IClient,
): Promise<ITransaction> {
if (tx.status === 'initiated') {
return tx;
}
if (tx.status === 'failure') {
return tx;
}
Expand All @@ -64,7 +61,11 @@ export async function syncTransactionStatus(
) {
return tx;
}
if (tx.status === 'signed' || tx.status === 'preflight') {
if (
tx.status === 'signed' ||
tx.status === 'preflight' ||
tx.status === 'initiated'
) {
const network = await networkRepository.getNetwork(tx.networkUUID);
if (!network) {
throw new Error('Network not found');
Expand All @@ -80,6 +81,12 @@ export async function syncTransactionStatus(
if (result) {
const updatedTx: ITransaction = {
...tx,
sigs: tx.sigs.map((sigData) => ({
...sigData,
sig:
sigData?.sig ||
'Signed by other party (Signature is not available)',
})),
status: result.result.status,
result: result,
preflight: result,
Expand Down
154 changes: 88 additions & 66 deletions packages/apps/dev-wallet/src/pages/account/account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ConfirmDeletion } from '@/Components/ConfirmDeletion/ConfirmDeletion';
import { FundOnTestnetButton } from '@/Components/FundOnTestnet/FundOnTestnet';
import { usePrompt } from '@/Components/PromptProvider/Prompt';
import { QRCode } from '@/Components/QRCode/QRCode';
import { SideBarBreadcrumbs } from '@/Components/SideBarBreadcrumbs/SideBarBreadcrumbs';
import {
accountRepository,
isWatchedAccount,
Expand All @@ -19,9 +20,10 @@ import {
MonoCreate,
MonoKey,
MonoRemoveRedEye,
MonoWallet,
} from '@kadena/kode-icons/system';
import { Button, Heading, Stack, TabItem, Tabs, Text } from '@kadena/kode-ui';
import { useLayout } from '@kadena/kode-ui/patterns';
import { SideBarBreadcrumbsItem, useLayout } from '@kadena/kode-ui/patterns';
import { useMemo, useState } from 'react';
import { Link, useNavigate, useParams } from 'react-router-dom';
import { noStyleLinkClass, panelClass } from '../home/style.css';
Expand Down Expand Up @@ -99,20 +101,16 @@ export function AccountPage() {

return (
<Stack flexDirection={'column'} gap={'lg'}>
<SideBarBreadcrumbs icon={<MonoWallet />}>
<SideBarBreadcrumbsItem href="/">Dashboard</SideBarBreadcrumbsItem>
<SideBarBreadcrumbsItem href={`/account/${accountId}`}>
Account ({account.alias || account.address})
</SideBarBreadcrumbsItem>
</SideBarBreadcrumbs>
<AliasForm show={isRightAsideExpanded} account={account} />
<Stack flexDirection={'column'} gap={'sm'}>
<Stack gap={'sm'} alignItems={'center'}>
<Heading variant="h3">{account.alias || '{ No Alias }'}</Heading>
{account.profileId === profile?.uuid && (
<Button
isCompact
variant="transparent"
startVisual={<MonoCreate />}
onPress={() => {
setIsRightAsideExpanded(!isRightAsideExpanded);
}}
/>
)}
</Stack>

<Stack justifyContent={'space-between'}>
Expand Down Expand Up @@ -249,62 +247,86 @@ export function AccountPage() {
)}
{activities.length > 0 && <ActivityTable activities={activities} />}
</TabItem>
{
(isOwnedAccount && (
<TabItem key="settings" title="Settings">
<Stack flexDirection={'column'} gap={'xxl'}>
<Stack
flexDirection={'column'}
gap={'md'}
className={panelClass}
alignItems={'flex-start'}
>
<Heading variant="h4">Migrate Account</Heading>
<Text>
You can use account migration to transfer all balances to a
newly created account with a new keyset, even though the
keyset guard for this account cannot be changed.
</Text>
<Button variant="outlined">Migrate</Button>
</Stack>
<Stack
flexDirection={'column'}
gap={'md'}
className={panelClass}
alignItems={'flex-start'}
>
<Heading variant="h4">Delete Account</Heading>
<Text>
You don't want to use this account anymore? You can delete
it from your wallet. This will be deleted locally not from
the blockchain.
</Text>
<Button
variant="negative"
onClick={async () => {
const confirm = await prompt((resolve) => {
return (
<ConfirmDeletion
onCancel={() => resolve(false)}
onDelete={() => resolve(true)}
title="Delete Account"
description=" Are you sure you want to delete this account? If you need to add it again you will need to use account creation process."
/>
);
});
if (confirm) {
await accountRepository.deleteAccount(account.uuid);
navigate('/');
}
}}

<TabItem key="settings" title="Settings">
<Stack flexDirection={'column'} gap={'xxl'}>
<Stack
flexDirection={'column'}
gap={'md'}
className={panelClass}
alignItems={'flex-start'}
>
<Heading variant="h4">Account Alias</Heading>
<Text>
You can set or change the alias for this account. This will help
you to identify this account easily.
</Text>
<Button
variant="outlined"
startVisual={<MonoCreate />}
onPress={() => {
setIsRightAsideExpanded(!isRightAsideExpanded);
}}
>
Edit Alias
</Button>
</Stack>
{
(isOwnedAccount && (
<>
<Stack
flexDirection={'column'}
gap={'md'}
className={panelClass}
alignItems={'flex-start'}
>
Delete
</Button>
</Stack>
</Stack>
</TabItem>
)) as any
}
<Heading variant="h4">Migrate Account</Heading>
<Text>
You can use account migration to transfer all balances to
a newly created account with a new keyset, even though the
keyset guard for this account cannot be changed.
</Text>
<Button variant="outlined">Migrate</Button>
</Stack>
<Stack
flexDirection={'column'}
gap={'md'}
className={panelClass}
alignItems={'flex-start'}
>
<Heading variant="h4">Delete Account</Heading>
<Text>
You don't want to use this account anymore? You can delete
it from your wallet. This will be deleted locally not from
the blockchain.
</Text>
<Button
variant="negative"
onClick={async () => {
const confirm = await prompt((resolve) => {
return (
<ConfirmDeletion
onCancel={() => resolve(false)}
onDelete={() => resolve(true)}
title="Delete Account"
description=" Are you sure you want to delete this account? If you need to add it again you will need to use account creation process."
/>
);
});
if (confirm) {
await accountRepository.deleteAccount(account.uuid);
navigate('/');
}
}}
>
Delete
</Button>
</Stack>
</>
)) as any
}
</Stack>
</TabItem>
</Tabs>
</Stack>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import { MonoDashboardCustomize } from '@kadena/kode-icons/system';
import { Box, Button, Heading, Stack, Text } from '@kadena/kode-ui';
import { SideBarBreadcrumbsItem } from '@kadena/kode-ui/patterns';
import { Link } from 'react-router-dom';
<SideBarBreadcrumbs icon={<MonoDashboardCustomize />}>
<SideBarBreadcrumbsItem href="/">Dashboard</SideBarBreadcrumbsItem>
<SideBarBreadcrumbsItem href="/terminal">Dev Console</SideBarBreadcrumbsItem>
</SideBarBreadcrumbs>;

export function BackupRecoveryPhrase() {
return (
<>
Expand Down
Loading

0 comments on commit 5f9ba5c

Please sign in to comment.