From dfd165b24f34d61c199ab2081467b6e58457b80a Mon Sep 17 00:00:00 2001 From: Javad Khalilian Date: Fri, 25 Oct 2024 19:49:07 +0200 Subject: [PATCH 1/3] fix(dw): Fund btn + networkId --- .../components/ChainBalance.tsx | 11 +++---- .../components/style.css.ts | 3 ++ .../FundOnTestnet/FundOnTestnet.tsx | 31 +++++++++++++++---- .../dev-wallet/src/modules/db/db.service.tsx | 2 +- .../src/pages/transfer-v2/Steps/style.css.ts | 1 + 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/packages/apps/dev-wallet/src/Components/AccountBalanceDistribution/components/ChainBalance.tsx b/packages/apps/dev-wallet/src/Components/AccountBalanceDistribution/components/ChainBalance.tsx index 93e9981958..c887211992 100644 --- a/packages/apps/dev-wallet/src/Components/AccountBalanceDistribution/components/ChainBalance.tsx +++ b/packages/apps/dev-wallet/src/Components/AccountBalanceDistribution/components/ChainBalance.tsx @@ -63,12 +63,11 @@ export const ChainBalance: FC = ({ Chain {chainId} {!editable && activeNetwork?.faucetContract && fundAccount && ( - - - + )} diff --git a/packages/apps/dev-wallet/src/Components/AccountBalanceDistribution/components/style.css.ts b/packages/apps/dev-wallet/src/Components/AccountBalanceDistribution/components/style.css.ts index 56edff9766..cb68c86dd1 100644 --- a/packages/apps/dev-wallet/src/Components/AccountBalanceDistribution/components/style.css.ts +++ b/packages/apps/dev-wallet/src/Components/AccountBalanceDistribution/components/style.css.ts @@ -44,6 +44,9 @@ export const fundButtonClass = style({ '&:focus': { opacity: 1, }, + '&.pending': { + opacity: 1, + }, }, }); diff --git a/packages/apps/dev-wallet/src/Components/FundOnTestnet/FundOnTestnet.tsx b/packages/apps/dev-wallet/src/Components/FundOnTestnet/FundOnTestnet.tsx index 2180cf0db4..a55b2fb986 100644 --- a/packages/apps/dev-wallet/src/Components/FundOnTestnet/FundOnTestnet.tsx +++ b/packages/apps/dev-wallet/src/Components/FundOnTestnet/FundOnTestnet.tsx @@ -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; + className?: string; }) { const [fundTx, setFundTx] = useState(); const { syncAllAccounts } = useWallet(); + const [done, setDone] = useState(false); return ( - <> + {!fundTx && ( + )} + ); } diff --git a/packages/apps/dev-wallet/src/modules/db/db.service.tsx b/packages/apps/dev-wallet/src/modules/db/db.service.tsx index 5fbd7dfaed..cda91f04f1 100644 --- a/packages/apps/dev-wallet/src/modules/db/db.service.tsx +++ b/packages/apps/dev-wallet/src/modules/db/db.service.tsx @@ -93,7 +93,7 @@ export const setupDatabase = execInSequence(async (): Promise => { 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' }, diff --git a/packages/apps/dev-wallet/src/pages/transfer-v2/Steps/style.css.ts b/packages/apps/dev-wallet/src/pages/transfer-v2/Steps/style.css.ts index e054d238be..e52045df43 100644 --- a/packages/apps/dev-wallet/src/pages/transfer-v2/Steps/style.css.ts +++ b/packages/apps/dev-wallet/src/pages/transfer-v2/Steps/style.css.ts @@ -7,4 +7,5 @@ export const labelClass = style({ background: tokens.kda.foundation.color.background.surface.default, padding: '8px', marginLeft: '-12px', + fontWeight: '700', }); From d43b102f60ba3125353cef1f313d99999509e962 Mon Sep 17 00:00:00 2001 From: Javad Khalilian Date: Fri, 25 Oct 2024 20:25:01 +0200 Subject: [PATCH 2/3] fix(dw): sig builder --- .../dev-wallet/src/modules/db/db.service.tsx | 7 +- .../transaction/transaction.repository.ts | 20 ++ .../signature-builder/signature-builder.tsx | 285 +++++------------- .../src/pages/signature-builder/style.css.ts | 9 + 4 files changed, 110 insertions(+), 211 deletions(-) diff --git a/packages/apps/dev-wallet/src/modules/db/db.service.tsx b/packages/apps/dev-wallet/src/modules/db/db.service.tsx index cda91f04f1..2ad92bfc36 100644 --- a/packages/apps/dev-wallet/src/modules/db/db.service.tsx +++ b/packages/apps/dev-wallet/src/modules/db/db.service.tsx @@ -105,10 +105,15 @@ export const setupDatabase = execInSequence(async (): Promise => { }, ]); create('transaction', 'uuid', [ - { index: 'hash', unique: true }, + { index: 'hash' }, { index: 'profileId' }, { index: 'groupId' }, { index: 'network', indexKeyPath: ['profileId', 'networkUUID'] }, + { + index: 'unique-tx', + indexKeyPath: ['profileId', 'networkUUID', 'hash'], + unique: true, + }, { index: 'network-status', indexKeyPath: ['profileId', 'networkUUID', 'status'], diff --git a/packages/apps/dev-wallet/src/modules/transaction/transaction.repository.ts b/packages/apps/dev-wallet/src/modules/transaction/transaction.repository.ts index 182d00504c..a2e09f4a21 100644 --- a/packages/apps/dev-wallet/src/modules/transaction/transaction.repository.ts +++ b/packages/apps/dev-wallet/src/modules/transaction/transaction.repository.ts @@ -70,6 +70,11 @@ export interface TransactionRepository { getTransaction: (uuid: string) => Promise; getTransactionByHash: (hash: string) => Promise; getTransactionsByGroup: (groupId: string) => Promise; + getTransactionByHashNetworkProfile: ( + profileId: string, + networkUUID: UUID, + hash: string, + ) => Promise; addTransaction: (transaction: ITransaction) => Promise; updateTransaction: (transaction: ITransaction) => Promise; deleteTransaction: (transactionId: string) => Promise; @@ -108,6 +113,21 @@ const createTransactionRepository = ({ const tx = getAll('transaction', hash, 'hash'); return Array.isArray(tx) ? tx[0] : undefined; }, + getTransactionByHashNetworkProfile: async ( + profileId: string, + networkUUID: UUID, + hash: string, + ) => { + const txs = (await getAll( + 'transaction', + IDBKeyRange.only([profileId, networkUUID, hash]), + 'unique-tx', + )) as ITransaction[]; + if (txs.length > 1) { + throw new Error('Multiple transactions with the same hash'); + } + return txs[0]; + }, getTransactionsByGroup: async ( groupId: string, ): Promise => { diff --git a/packages/apps/dev-wallet/src/pages/signature-builder/signature-builder.tsx b/packages/apps/dev-wallet/src/pages/signature-builder/signature-builder.tsx index f8ccc7a6ec..e0c8edad28 100644 --- a/packages/apps/dev-wallet/src/pages/signature-builder/signature-builder.tsx +++ b/packages/apps/dev-wallet/src/pages/signature-builder/signature-builder.tsx @@ -9,12 +9,23 @@ import { import { PactCodeView } from '@/Components/PactCodeView/PactCodeView'; import { Wizard } from '@/Components/Wizard/Wizard'; +import { transactionRepository } from '@/modules/transaction/transaction.repository'; import * as transactionService from '@/modules/transaction/transaction.service'; import { useWallet } from '@/modules/wallet/wallet.hook'; -import { Box, Button, Card, Heading, Text } from '@kadena/kode-ui'; +import { + Box, + Button, + Card, + Heading, + Notification, + Stack, + Text, +} from '@kadena/kode-ui'; import { execCodeParser } from '@kadena/pactjs-generator'; +import classNames from 'classnames'; import { useMemo, useState } from 'react'; import { useNavigate } from 'react-router-dom'; +import { panelClass } from '../home/style.css'; import { codeArea } from './style.css'; import { normalizeSigs, normalizeTx } from './utils/normalizeSigs'; @@ -125,225 +136,79 @@ export function SignatureBuilder() { setSchema(schema); } - async function signTransaction() { - if (unsignedTx) { - const normalizedTx = { ...unsignedTx, sigs: normalizeSigs(unsignedTx) }; - const tx = (await sign(normalizedTx)) as ICommand; - setSignedTx(tx); - } - } - return ( - <> - - - {({ step, goTo }) => ( - - - {schema === 'signingRequest' && ( - - )} - - - - )} - - - {({ goTo }) => ( + + Paste SigData, CommandSigData, or Payload +