From 9c042b264954017f6cedbdda295662bb4b3c9d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Mas=C5=82owski?= Date: Wed, 17 Jul 2024 13:56:09 +0200 Subject: [PATCH] refactor: shared wallets related naming improvements (#1290) * refactor: naming improvements * test: fix broken unit tests --- .../src/routes/wallet-paths.ts | 2 +- .../features/shared-wallet/SharedWallet.tsx | 31 +++-- packages/core/src/index.ts | 1 + .../AddCoSigners/AddCoSignerInput.tsx | 28 ++--- .../AddCoSigners/AddCoSigners.stories.tsx | 4 +- .../AddCoSigners/AddCoSigners.tsx | 12 +- .../creation-flow/AddCoSigners/type.ts | 6 +- .../SetupSharedDetails.stories.ts | 4 +- .../creation-flow/ShareWalletDetails/utils.ts | 8 +- .../SharedWalletCreationStore.tsx | 25 ++-- .../co-signers-data-structure.ts | 6 +- .../creation-flow/validateCoSigners.test.ts | 30 ++--- .../creation-flow/validateCoSigners.ts | 16 +-- .../CopyKey/CopyKey.tsx} | 28 ++--- .../CopyKey}/CopyKeys.module.scss | 2 +- .../generate-key-flow/CopyKey/index.ts | 1 + .../EnterPassword/EnterPassword.module.scss | 0 .../EnterPassword/EnterPassword.tsx | 14 +-- .../EnterPassword/index.ts | 0 .../GenerateSharedWalletKeyFlow.tsx} | 26 ++-- .../Store/Store.tsx | 30 ++--- .../Store/index.ts | 4 +- .../Store/machine.ts | 32 ++--- .../generate-key-flow/Store/state.ts | 38 ++++++ .../generate-key-flow/index.ts | 2 + .../generate-key-flow/timelineSteps.ts | 10 ++ .../generate-keys-flow/CopyKeys/index.ts | 1 - .../generate-keys-flow/Store/state.ts | 38 ------ .../generate-keys-flow/index.ts | 2 - .../generate-keys-flow/timelineSteps.ts | 10 -- .../shared-wallets/add-shared-wallet/index.ts | 4 +- .../AddSharedWalletMainPageFlow.tsx | 14 +-- .../SharedWalletEntry.stories.tsx | 13 +- .../SharedWalletEntry/SharedWalletEntry.tsx | 34 ++--- .../SharedWalletRestorationFlow.tsx | 4 +- .../add-shared-wallet/restore-flow/types.ts | 2 +- .../restore-flow/validateJson.ts | 4 +- .../AddSharedWalletStorybookHelper.tsx | 53 ++++---- .../add-shared-wallet-create-flow.stories.tsx | 52 ++++---- .../add-shared-wallet-import-flow.stories.tsx | 8 +- ...ed-wallet-keys-derivation-flow.stories.tsx | 34 ++--- .../add-shared-wallet.stories.tsx | 8 +- .../transaction/TransactionDetails.tsx | 4 +- .../components/Activity/AssetActivityItem.tsx | 10 +- .../Activity/AssetActivityList.stories.tsx | 2 +- .../__tests__/AssetActivityItem.test.tsx | 4 +- .../__tests__/AssetActivityList.test.tsx | 3 +- .../GroupedAssetActivityList.test.tsx | 2 +- .../ActivityDetail/ActivityTypeIcon.tsx | 3 +- .../ActivityDetail/RewardsDetails.tsx | 2 +- .../ActivityDetail/TransactionDetailAsset.ts | 40 ------ .../TransactionDetails.stories.tsx | 2 +- .../ActivityDetail/TransactionDetails.tsx | 71 +---------- .../ActivityDetail/TransactionInputOutput.tsx | 2 +- .../__tests__/RewardsDetails.test.tsx | 2 +- .../__tests__/TransactionDetails.test.tsx | 3 +- .../src/ui/components/ActivityDetail/index.ts | 2 - .../src/ui/components/ActivityDetail/types.ts | 8 +- .../DappTransaction/DappTransaction.tsx | 3 +- .../TransactionFee.module.scss | 0 .../TransactionFee.tsx | 0 .../src/ui/components/Transaction/TxHash.tsx | 2 +- .../Transaction/TxSummarySection.tsx | 2 +- .../src/ui/components/Transaction/index.ts | 3 + .../src/ui/components/Transaction/types.ts | 119 ++++++++++++++++++ .../lib/translations/shared-wallets/en.json | 38 +++--- 66 files changed, 494 insertions(+), 474 deletions(-) rename packages/core/src/shared-wallets/add-shared-wallet/{generate-keys-flow/CopyKeys/CopyKeys.tsx => generate-key-flow/CopyKey/CopyKey.tsx} (53%) rename packages/core/src/shared-wallets/add-shared-wallet/{generate-keys-flow/CopyKeys => generate-key-flow/CopyKey}/CopyKeys.module.scss (87%) create mode 100644 packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/CopyKey/index.ts rename packages/core/src/shared-wallets/add-shared-wallet/{generate-keys-flow => generate-key-flow}/EnterPassword/EnterPassword.module.scss (100%) rename packages/core/src/shared-wallets/add-shared-wallet/{generate-keys-flow => generate-key-flow}/EnterPassword/EnterPassword.tsx (79%) rename packages/core/src/shared-wallets/add-shared-wallet/{generate-keys-flow => generate-key-flow}/EnterPassword/index.ts (100%) rename packages/core/src/shared-wallets/add-shared-wallet/{generate-keys-flow/GenerateSharedKeysFlow.tsx => generate-key-flow/GenerateSharedWalletKeyFlow.tsx} (58%) rename packages/core/src/shared-wallets/add-shared-wallet/{generate-keys-flow => generate-key-flow}/Store/Store.tsx (55%) rename packages/core/src/shared-wallets/add-shared-wallet/{generate-keys-flow => generate-key-flow}/Store/index.ts (51%) rename packages/core/src/shared-wallets/add-shared-wallet/{generate-keys-flow => generate-key-flow}/Store/machine.ts (69%) create mode 100644 packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/Store/state.ts create mode 100644 packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/index.ts create mode 100644 packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/timelineSteps.ts delete mode 100644 packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/CopyKeys/index.ts delete mode 100644 packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/Store/state.ts delete mode 100644 packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/index.ts delete mode 100644 packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/timelineSteps.ts delete mode 100644 packages/core/src/ui/components/ActivityDetail/TransactionDetailAsset.ts rename packages/core/src/ui/components/{ActivityDetail => Transaction}/TransactionFee.module.scss (100%) rename packages/core/src/ui/components/{ActivityDetail => Transaction}/TransactionFee.tsx (100%) create mode 100644 packages/core/src/ui/components/Transaction/types.ts diff --git a/apps/browser-extension-wallet/src/routes/wallet-paths.ts b/apps/browser-extension-wallet/src/routes/wallet-paths.ts index 80e3000e3..7e7b0ffb6 100644 --- a/apps/browser-extension-wallet/src/routes/wallet-paths.ts +++ b/apps/browser-extension-wallet/src/routes/wallet-paths.ts @@ -29,7 +29,7 @@ export const walletRoutePaths = { }, sharedWallet: { root: '/shared-wallet', - generateKeys: '/shared-wallet/generate-keys', + generateKeys: '/shared-wallet/generate-key', create: '/shared-wallet/create', import: '/shared-wallet/import' } diff --git a/apps/browser-extension-wallet/src/views/browser-view/features/shared-wallet/SharedWallet.tsx b/apps/browser-extension-wallet/src/views/browser-view/features/shared-wallet/SharedWallet.tsx index f51a384d4..2d3fc4139 100644 --- a/apps/browser-extension-wallet/src/views/browser-view/features/shared-wallet/SharedWallet.tsx +++ b/apps/browser-extension-wallet/src/views/browser-view/features/shared-wallet/SharedWallet.tsx @@ -5,7 +5,7 @@ import { AddSharedWalletMainPageFlow, AddSharedWalletModal, CoSigner, - GenerateSharedKeysFlow, + GenerateSharedWalletKeyFlow, LinkedWalletType, QuorumOptionValue, SharedWalletCreationFlow, @@ -34,7 +34,7 @@ export const SharedWallet = (): JSX.Element => { const { walletInfo, cardanoWallet } = useWalletStore(); const { page, setBackgroundPage } = useBackgroundPage(); - const [sharedKey, setSharedKey] = useState(); + const [sharedWalletKey, setSharedWalletKey] = useState(); const [initialWalletName, setInitialWalletName] = useState(''); const [activeWalletType, setActiveWalletType] = useState(); @@ -45,7 +45,7 @@ export const SharedWallet = (): JSX.Element => { const activeWalletId = cardanoWallet.source.wallet.walletId; const activeWallet = wallets.find(({ walletId }) => walletId === activeWalletId); - setSharedKey(activeWallet.metadata.extendedAccountPublicKey); + setSharedWalletKey(activeWallet.metadata.extendedAccountPublicKey); if (!activeWallet || activeWallet.type === WalletType.Script) return; setActiveWalletType(activeWallet.type); })(); @@ -53,8 +53,7 @@ export const SharedWallet = (): JSX.Element => { const handleCreateWallet = async (data: CreateWalletParams) => { const activeWalletId = cardanoWallet.source.wallet.walletId; - - const publicKeys = data.coSigners.map(({ keys }: CoSigner) => Wallet.Crypto.Bip32PublicKeyHex(keys)); + const publicKeys = data.coSigners.map((c: CoSigner) => Wallet.Crypto.Bip32PublicKeyHex(c.sharedWalletKey)); await createInMemorySharedWallet({ name: data.name, @@ -65,11 +64,11 @@ export const SharedWallet = (): JSX.Element => { }); }; - const generateKeys = async (enteredPassword: string) => { - if (sharedKey) return sharedKey; - const sharedWalletKey = await generateSharedWalletKey(enteredPassword, cardanoWallet.source.wallet.walletId); - setSharedKey(sharedWalletKey); - return sharedWalletKey; + const generateKey = async (enteredPassword: string) => { + if (sharedWalletKey) return sharedWalletKey; + const key = await generateSharedWalletKey(enteredPassword, cardanoWallet.source.wallet.walletId); + setSharedWalletKey(key); + return key; }; return ( @@ -84,15 +83,15 @@ export const SharedWallet = (): JSX.Element => { exact path={walletRoutePaths.sharedWallet.generateKeys} render={() => ( - history.push(walletRoutePaths.sharedWallet.root)} /> )} /> - {sharedKey && ( + {sharedWalletKey && ( { initialWalletName={initialWalletName} navigateToAppHome={() => setBackgroundPage()} exitTheFlow={() => history.push(walletRoutePaths.sharedWallet.root)} - sharedKeys={sharedKey} + sharedWalletKey={sharedWalletKey} onCreateSharedWallet={handleCreateWallet} /> )} /> )} - {sharedKey && ( + {sharedWalletKey && ( { onCreateSharedWalletClick={() => history.push(walletRoutePaths.sharedWallet.create)} onImportSharedWalletClick={() => history.push(walletRoutePaths.sharedWallet.import)} onKeysGenerateClick={() => history.push(walletRoutePaths.sharedWallet.generateKeys)} - sharedKeys={sharedKey} + sharedWalletKey={sharedWalletKey} /> )} /> diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index e7a431415..4fd26a4bb 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -46,3 +46,4 @@ export * from '@ui/components/ListEmptyState'; export * from '@ui/components/MidnightEventBanner'; export * from '@ui/components/MidnightPreLaunchSettingsBanner'; export * from '@ui/components/ImageWithFallback'; +export * from '@ui/components/Transaction'; diff --git a/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/AddCoSigners/AddCoSignerInput.tsx b/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/AddCoSigners/AddCoSignerInput.tsx index ea3160e6d..284310218 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/AddCoSigners/AddCoSignerInput.tsx +++ b/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/AddCoSigners/AddCoSignerInput.tsx @@ -5,12 +5,12 @@ import { useTranslation } from 'react-i18next'; import { CoSigner, CoSignerDirty, CoSignerError, CoSignerErrorKeys, CoSignerErrorName } from './type'; export const maxCoSignerNameLength = 20; -type FieldName = 'keys' | 'name'; +type FieldName = 'sharedWalletKey' | 'name'; interface AddCoSignerInputProps { dirty?: CoSignerDirty; error?: CoSignerError; - keysFieldDisabled: boolean; + keyFieldDisabled: boolean; labels: Record; onChange: (coSigner: CoSigner) => void; value: CoSigner; @@ -32,24 +32,24 @@ const parseError = (error: CoSignerError | undefined, t: TFunction): Partial diff --git a/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/AddCoSigners/AddCoSigners.stories.tsx b/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/AddCoSigners/AddCoSigners.stories.tsx index 4e4052d12..e969fd67e 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/AddCoSigners/AddCoSigners.stories.tsx +++ b/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/AddCoSigners/AddCoSigners.stories.tsx @@ -16,8 +16,8 @@ export default meta; export const Overview = (): JSX.Element => { const [coSigners, setCoSigners] = useState([ - { id: uuid(), keys: '', name: '' }, - { id: uuid(), keys: '', name: '' }, + { id: uuid(), name: '', sharedWalletKey: '' }, + { id: uuid(), name: '', sharedWalletKey: '' }, ]); return ( diff --git a/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/AddCoSigners/AddCoSigners.tsx b/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/AddCoSigners/AddCoSigners.tsx index 1dbc1e850..013802175 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/AddCoSigners/AddCoSigners.tsx +++ b/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/AddCoSigners/AddCoSigners.tsx @@ -27,7 +27,7 @@ export const AddCoSigners = ({ coSignersDirty, }: Props): JSX.Element => { const { t } = useTranslation(); - const atLeastOneValidCoSigner = coSigners.some((c) => c.keys && c.name) && errors.length === 0; + const atLeastOneValidCoSigner = coSigners.some((c) => c.sharedWalletKey && c.name) && errors.length === 0; return ( { case QuorumRadioOption.AllAddresses: { nativeScript = { scripts: coSigners.map((coSigner) => ({ - pubkey: coSigner.keys, + pubkey: coSigner.sharedWalletKey, tag: 'pubkey', })), tag: 'all', @@ -29,7 +29,7 @@ const mapStateToSchema = (state: CreationFlowState): SharedWalletSchema => { case QuorumRadioOption.Any: { nativeScript = { scripts: coSigners.map((coSigner) => ({ - pubkey: coSigner.keys, + pubkey: coSigner.sharedWalletKey, tag: 'pubkey', })), tag: 'any', @@ -40,7 +40,7 @@ const mapStateToSchema = (state: CreationFlowState): SharedWalletSchema => { nativeScript = { n: quorumRules.numberOfCosigner, scripts: coSigners.map((coSigner) => ({ - pubkey: coSigner.keys, + pubkey: coSigner.sharedWalletKey, tag: 'pubkey', })), tag: 'n_of_k', @@ -56,7 +56,7 @@ const mapStateToSchema = (state: CreationFlowState): SharedWalletSchema => { metadata: { participants: coSigners.map((coSigner) => ({ name: coSigner.name, - publicKey: coSigner.keys, + publicKey: coSigner.sharedWalletKey, })), sharedWalletName: walletName || '', }, diff --git a/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/SharedWalletCreationStore.tsx b/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/SharedWalletCreationStore.tsx index 6d7517cd4..ff9c2c78f 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/SharedWalletCreationStore.tsx +++ b/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/SharedWalletCreationStore.tsx @@ -86,8 +86,9 @@ const getNextCoSignersDirtyValue = ({ dirty.id === action.coSigner.id ? { id: dirty.id, - keys: matchingPrevCoSigner.keys !== action.coSigner.keys ? true : dirty.keys, name: matchingPrevCoSigner.name !== action.coSigner.name ? true : dirty.name, + sharedWalletKey: + matchingPrevCoSigner.sharedWalletKey !== action.coSigner.sharedWalletKey ? true : dirty.sharedWalletKey, } : dirty, ); @@ -96,12 +97,12 @@ const makeStateMachine = ({ exitTheFlow, navigateToAppHome, onCreateSharedWallet, - sharedKeys, + sharedWalletKey, }: { exitTheFlow: () => void; navigateToAppHome: () => void; onCreateSharedWallet: (data: { coSigners: CoSigner[]; name: string; quorumRules: QuorumOptionValue }) => void; - sharedKeys: string; + sharedWalletKey: string; }): SharedWalletCreationStateMachine => ({ [SharedWalletCreationStep.Setup]: (prevState, action) => { if (action.type === SharedWalletCreationActionType.CHANGE_WALLET_NAME) { @@ -116,10 +117,10 @@ const makeStateMachine = ({ } if (action.type === SharedWalletCreationActionType.NEXT) { if (!prevState.walletName) return prevState; - const coSigners = ensureCorrectCoSignersDataShape([createCoSignerObject(sharedKeys)]); + const coSigners = ensureCorrectCoSignersDataShape([createCoSignerObject(sharedWalletKey)]); return stateCoSigners({ ...prevState, - coSignerInputsDirty: coSigners.map(({ id }) => ({ id, keys: false, name: false })), + coSignerInputsDirty: coSigners.map(({ id }) => ({ id, name: false, sharedWalletKey: false })), coSignerInputsErrors: [], coSigners, step: SharedWalletCreationStep.CoSigners, @@ -138,8 +139,8 @@ const makeStateMachine = ({ ); if ( - prevState.coSigners[indexOfCoSignersDataOfCurrentUser].keys !== - nextCoSigners[indexOfCoSignersDataOfCurrentUser].keys + prevState.coSigners[indexOfCoSignersDataOfCurrentUser].sharedWalletKey !== + nextCoSigners[indexOfCoSignersDataOfCurrentUser].sharedWalletKey ) { return prevState; } @@ -155,7 +156,7 @@ const makeStateMachine = ({ // fields should stay empty and should not show errors. // This filter should be removed once we enable the "add cosigner" button const filteredCosignerErrors = coSignersErrors.filter( - ({ id }) => !nextCoSigners.some((c) => c.id === id && !c.keys && !c.name), + ({ id }) => !nextCoSigners.some((c) => c.id === id && !c.sharedWalletKey && !c.name), ); return stateCoSigners({ @@ -192,7 +193,7 @@ const makeStateMachine = ({ }); } if (action.type === SharedWalletCreationActionType.NEXT) { - const coSigners = prevState.coSigners.filter((c) => c.keys && c.name); + const coSigners = prevState.coSigners.filter((c) => c.sharedWalletKey && c.name); const minCoSignersCount = 2; if (coSigners.length < minCoSignersCount) return prevState; @@ -251,7 +252,7 @@ export type SharedWalletCreationStoreSharedProps = { initialWalletName: string; navigateToAppHome: () => void; onCreateSharedWallet: (data: { coSigners: CoSigner[]; name: string; quorumRules: QuorumOptionValue }) => void; - sharedKeys: string; + sharedWalletKey: string; }; export type SharedWalletCreationStoreProps = SharedWalletCreationStoreSharedProps & { @@ -265,7 +266,7 @@ export const SharedWalletCreationStore = ({ initialWalletName, navigateToAppHome, onCreateSharedWallet, - sharedKeys, + sharedWalletKey, }: SharedWalletCreationStoreProps): ReactElement => { const initialState = useInitialState(makeInitialState(activeWalletName)); const [state, dispatch] = useReducer( @@ -274,7 +275,7 @@ export const SharedWalletCreationStore = ({ exitTheFlow, navigateToAppHome, onCreateSharedWallet, - sharedKeys, + sharedWalletKey, }); const handler = stateMachine[prevState.step] as Handler; return handler(prevState, action); diff --git a/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/co-signers-data-structure.ts b/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/co-signers-data-structure.ts index 602a58695..989c29a0e 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/co-signers-data-structure.ts +++ b/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/co-signers-data-structure.ts @@ -5,11 +5,11 @@ import { CoSigner } from './AddCoSigners'; // The coSignersIndexOfCurrentUser helps to identify that data to differentiate them in the UI. export const indexOfCoSignersDataOfCurrentUser = 0; -export const createCoSignerObject = (keys = ''): CoSigner => ({ id: uuid(), keys, name: '' }); +export const createCoSignerObject = (sharedWalletKey = ''): CoSigner => ({ id: uuid(), name: '', sharedWalletKey }); export const ensureCorrectCoSignersDataShape = (inputCoSigners: CoSigner[]) => { - if (!inputCoSigners[indexOfCoSignersDataOfCurrentUser]?.keys) { - throw new Error('CoSigner data of current user missing keys'); + if (!inputCoSigners[indexOfCoSignersDataOfCurrentUser]?.sharedWalletKey) { + throw new Error('CoSigner data of current user missing sharedWalletKey'); } return Array.from({ length: 3 }, (_, index) => inputCoSigners[index] || createCoSignerObject()); }; diff --git a/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/validateCoSigners.test.ts b/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/validateCoSigners.test.ts index f12a3f5e1..3b4a3bdb8 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/validateCoSigners.test.ts +++ b/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/validateCoSigners.test.ts @@ -8,8 +8,8 @@ describe('validateCoSigners', () => { test('name duplicated', () => { expect( validateCoSigners([ - { id: '1', keys: fakeSharedKey, name: 'John Doe' }, - { id: '2', keys: fakeSharedKey, name: 'John Doe' }, + { id: '1', name: 'John Doe', sharedWalletKey: fakeSharedKey }, + { id: '2', name: 'John Doe', sharedWalletKey: fakeSharedKey }, ]), ).toEqual([ { id: '1', name: CoSignerErrorName.Duplicated }, @@ -18,42 +18,44 @@ describe('validateCoSigners', () => { }); test('name empty', () => { - expect(validateCoSigners([{ id: '1', keys: fakeSharedKey, name: '' }])).toEqual([ + expect(validateCoSigners([{ id: '1', name: '', sharedWalletKey: fakeSharedKey }])).toEqual([ { id: '1', name: CoSignerErrorName.Required }, ] as CoSignerError[]); }); test('name to long', () => { - expect(validateCoSigners([{ id: '1', keys: fakeSharedKey, name: '123456789012345678901' }])).toEqual([ + expect(validateCoSigners([{ id: '1', name: '123456789012345678901', sharedWalletKey: fakeSharedKey }])).toEqual([ { id: '1', name: CoSignerErrorName.TooLong }, ] as CoSignerError[]); }); - test('keys empty', () => { - expect(validateCoSigners([{ id: '1', keys: '', name: 'John Doe' }])).toEqual([ - { id: '1', keys: CoSignerErrorKeys.Required }, + test('sharedWalletKey empty', () => { + expect(validateCoSigners([{ id: '1', name: 'John Doe', sharedWalletKey: '' }])).toEqual([ + { id: '1', sharedWalletKey: CoSignerErrorKeys.Required }, ] as CoSignerError[]); }); - test('keys incorrect', () => { - expect(validateCoSigners([{ id: '1', keys: 'incorrect', name: 'John Doe' }])).toEqual([ - { id: '1', keys: CoSignerErrorKeys.Invalid }, + test('sharedWalletKey incorrect', () => { + expect(validateCoSigners([{ id: '1', name: 'John Doe', sharedWalletKey: 'incorrect' }])).toEqual([ + { id: '1', sharedWalletKey: CoSignerErrorKeys.Invalid }, ] as CoSignerError[]); }); test('no errors', () => { - expect(validateCoSigners([{ id: '1', keys: fakeSharedKey, name: 'John Doe' }])).toEqual([] as CoSignerError[]); + expect(validateCoSigners([{ id: '1', name: 'John Doe', sharedWalletKey: fakeSharedKey }])).toEqual( + [] as CoSignerError[], + ); }); test('two errors on a single co-signer', () => { expect( validateCoSigners([ - { id: '1', keys: fakeSharedKey, name: '123456789012345678901' }, - { id: '2', keys: 'incorrect', name: 'John Doe' }, + { id: '1', name: '123456789012345678901', sharedWalletKey: fakeSharedKey }, + { id: '2', name: 'John Doe', sharedWalletKey: 'incorrect' }, ]), ).toEqual([ { id: '1', name: CoSignerErrorName.TooLong }, - { id: '2', keys: CoSignerErrorKeys.Invalid }, + { id: '2', sharedWalletKey: CoSignerErrorKeys.Invalid }, ] as CoSignerError[]); }); }); diff --git a/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/validateCoSigners.ts b/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/validateCoSigners.ts index fee4a71eb..928362ad3 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/validateCoSigners.ts +++ b/packages/core/src/shared-wallets/add-shared-wallet/creation-flow/validateCoSigners.ts @@ -1,16 +1,16 @@ import { CoSigner, CoSignerError, CoSignerErrorKeys, CoSignerErrorName, maxCoSignerNameLength } from './AddCoSigners'; -const keysRegex = /^[\dA-Fa-f]{128}$/; +const keyRegex = /^[\dA-Fa-f]{128}$/; export const validateCoSigners = (coSigners: CoSigner[]): CoSignerError[] => { let coSignersErrors: CoSignerError[] = []; - coSigners.forEach(({ id, keys, name }) => { - let keysError: CoSignerErrorKeys | undefined; + coSigners.forEach(({ id, sharedWalletKey, name }) => { + let keyError: CoSignerErrorKeys | undefined; let nameError: CoSignerErrorName | undefined; - const keysValidationResult = keysRegex.exec(keys); - if (!keys) keysError = CoSignerErrorKeys.Required; - else if (!keysValidationResult) keysError = CoSignerErrorKeys.Invalid; + const keyValidationResult = keyRegex.exec(sharedWalletKey); + if (!sharedWalletKey) keyError = CoSignerErrorKeys.Required; + else if (!keyValidationResult) keyError = CoSignerErrorKeys.Invalid; if (!name) nameError = CoSignerErrorName.Required; else if (name.length > maxCoSignerNameLength) nameError = CoSignerErrorName.TooLong; @@ -18,8 +18,8 @@ export const validateCoSigners = (coSigners: CoSigner[]): CoSignerError[] => { nameError = CoSignerErrorName.Duplicated; } - if (keysError || nameError) { - coSignersErrors = [...coSignersErrors, { id, keys: keysError, name: nameError }]; + if (keyError || nameError) { + coSignersErrors = [...coSignersErrors, { id, name: nameError, sharedWalletKey: keyError }]; } }); diff --git a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/CopyKeys/CopyKeys.tsx b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/CopyKey/CopyKey.tsx similarity index 53% rename from packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/CopyKeys/CopyKeys.tsx rename to packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/CopyKey/CopyKey.tsx index 83534bd96..de7a28ff0 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/CopyKeys/CopyKeys.tsx +++ b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/CopyKey/CopyKey.tsx @@ -3,38 +3,38 @@ import { toast } from '@lace/common'; import React, { VFC } from 'react'; import { useTranslation } from 'react-i18next'; import { SharedWalletLayout } from '../../SharedWalletLayout'; -import { keysGenerationTimelineSteps } from '../timelineSteps'; +import { keyGenerationTimelineSteps } from '../timelineSteps'; import styles from './CopyKeys.module.scss'; const TOAST_DURATION = 3; type CopyKeysProps = { onClose: () => void; - onCopyKeys: () => Promise; - sharedKeys: string; + onCopyKey: () => Promise; + sharedWalletKey: string; }; -export const CopyKeys: VFC = ({ onClose, onCopyKeys, sharedKeys }) => { +export const CopyKey: VFC = ({ onClose, onCopyKey, sharedWalletKey }) => { const { t } = useTranslation(); const copyKeys = async () => { - await onCopyKeys(); + await onCopyKey(); toast.notify({ duration: TOAST_DURATION, icon: CopyIcon, - text: t('sharedWallets.addSharedWallet.keysGeneration.copyKeys.toastText'), + text: t('sharedWallets.addSharedWallet.keyGeneration.copyKeys.toastText'), }); }; return ( } onClick={copyKeys} /> @@ -42,16 +42,16 @@ export const CopyKeys: VFC = ({ onClose, onCopyKeys, sharedKeys } customNextButton={ } > - {t('sharedWallets.addSharedWallet.keysGeneration.copyKeys.keysBoxTitle')} + {t('sharedWallets.addSharedWallet.keyGeneration.copyKeys.keyBoxTitle')} - {sharedKeys} + {sharedWalletKey} diff --git a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/CopyKeys/CopyKeys.module.scss b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/CopyKey/CopyKeys.module.scss similarity index 87% rename from packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/CopyKeys/CopyKeys.module.scss rename to packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/CopyKey/CopyKeys.module.scss index 3a2e28355..1498adc2b 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/CopyKeys/CopyKeys.module.scss +++ b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/CopyKey/CopyKeys.module.scss @@ -1,3 +1,3 @@ -.keysBox { +.keyBox { color: var(--light-mode-dark-grey, var(--dark-mode-light-grey, #a9a9a9)); } diff --git a/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/CopyKey/index.ts b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/CopyKey/index.ts new file mode 100644 index 000000000..042b9c554 --- /dev/null +++ b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/CopyKey/index.ts @@ -0,0 +1 @@ +export { CopyKey } from './CopyKey'; diff --git a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/EnterPassword/EnterPassword.module.scss b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/EnterPassword/EnterPassword.module.scss similarity index 100% rename from packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/EnterPassword/EnterPassword.module.scss rename to packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/EnterPassword/EnterPassword.module.scss diff --git a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/EnterPassword/EnterPassword.tsx b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/EnterPassword/EnterPassword.tsx similarity index 79% rename from packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/EnterPassword/EnterPassword.tsx rename to packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/EnterPassword/EnterPassword.tsx index eae6734bf..3dc3ea0ba 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/EnterPassword/EnterPassword.tsx +++ b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/EnterPassword/EnterPassword.tsx @@ -9,7 +9,7 @@ import cn from 'classnames'; import React, { ReactElement, VFC, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { SharedWalletLayout } from '../../SharedWalletLayout'; -import { keysGenerationTimelineSteps } from '../timelineSteps'; +import { keyGenerationTimelineSteps } from '../timelineSteps'; import styles from './EnterPassword.module.scss'; export type WalletKind = 'hot' | 'cold'; @@ -47,15 +47,15 @@ export const EnterPassword: VFC = ({ return ( @@ -71,14 +71,14 @@ export const EnterPassword: VFC = ({ - {t('sharedWallets.addSharedWallet.keysGeneration.enterPassword.activeWalletLabel')} + {t('sharedWallets.addSharedWallet.keyGeneration.enterPassword.activeWalletLabel')} {walletName} setPassword(event.target.value)} onSubmit={(event) => { event.preventDefault(); diff --git a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/EnterPassword/index.ts b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/EnterPassword/index.ts similarity index 100% rename from packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/EnterPassword/index.ts rename to packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/EnterPassword/index.ts diff --git a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/GenerateSharedKeysFlow.tsx b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/GenerateSharedWalletKeyFlow.tsx similarity index 58% rename from packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/GenerateSharedKeysFlow.tsx rename to packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/GenerateSharedWalletKeyFlow.tsx index 0167e6792..7e976520f 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/GenerateSharedKeysFlow.tsx +++ b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/GenerateSharedWalletKeyFlow.tsx @@ -1,11 +1,11 @@ import { WalletType } from '@cardano-sdk/web-extension'; import React, { VFC } from 'react'; -import { CopyKeys } from './CopyKeys'; +import { CopyKey } from './CopyKey'; import { EnterPassword, WalletKind } from './EnterPassword'; -import { ActionType, GenerateSharedKeysStep, Store, StoreSharedProps } from './Store'; +import { ActionType, GenerateSharedWalletKeyStep, Store, StoreSharedProps } from './Store'; -const makeCopyKeysToClipboard = (sharedKeys: string) => async () => { - await navigator.clipboard.writeText(sharedKeys); +const makeCopyKeysToClipboard = (sharedWalletKey: string) => async () => { + await navigator.clipboard.writeText(sharedWalletKey); }; export type LinkedWalletType = Exclude<`${WalletType}`, `${WalletType.Script}`>; @@ -16,21 +16,21 @@ const mapWalletType: Record = { Trezor: 'cold', }; -type GenerateSharedKeysFlowProps = StoreSharedProps & { +type GenerateSharedWalletKeyFlowProps = StoreSharedProps & { activeWalletName: string; activeWalletType: LinkedWalletType; }; -export const GenerateSharedKeysFlow: VFC = ({ +export const GenerateSharedWalletKeyFlow: VFC = ({ activeWalletName, activeWalletType, - generateKeys, + generateKey, navigateToParentFlow, }) => ( - + {({ dispatch, state }) => ( <> - {state.step === GenerateSharedKeysStep.EnterPassword && ( + {state.step === GenerateSharedWalletKeyStep.EnterPassword && ( dispatch({ type: ActionType.Back })} @@ -40,11 +40,11 @@ export const GenerateSharedKeysFlow: VFC = ({ walletName={activeWalletName} /> )} - {state.step === GenerateSharedKeysStep.CopyKeys && ( - dispatch({ type: ActionType.CloseFlow })} - onCopyKeys={makeCopyKeysToClipboard(state.sharedKeys)} - sharedKeys={state.sharedKeys} + onCopyKey={makeCopyKeysToClipboard(state.sharedWalletKey)} + sharedWalletKey={state.sharedWalletKey} /> )} diff --git a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/Store/Store.tsx b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/Store/Store.tsx similarity index 55% rename from packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/Store/Store.tsx rename to packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/Store/Store.tsx index 9a5e388a6..9382f67e9 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/Store/Store.tsx +++ b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/Store/Store.tsx @@ -1,47 +1,47 @@ import { Dispatch, FC, ReactElement, useReducer } from 'react'; import { makeInitialStateProvider } from '../../../initial-state-provider'; import { Action, ActionType, Handler, makeStateMachine } from './machine'; -import { GenerateSharedKeysState, GenerateSharedKeysStep, stateEnterPassword } from './state'; +import { GenerateSharedWalletKeyState, GenerateSharedWalletKeyStep, stateEnterPassword } from './state'; -const { InitialStateProvider, useInitialState } = makeInitialStateProvider(); +const { InitialStateProvider, useInitialState } = makeInitialStateProvider(); -export const GenerateSharedKeysInitialStateProvider = InitialStateProvider; +export const GenerateSharedWalletKeyInitialStateProvider = InitialStateProvider; -type GenerateSharedKeysStoreValue = { +type GenerateSharedWalletKeyStoreValue = { dispatch: Dispatch; - state: GenerateSharedKeysState; + state: GenerateSharedWalletKeyState; }; export type StoreSharedProps = { - generateKeys: (password: string) => Promise; + generateKey: (password: string) => Promise; navigateToParentFlow: () => void; }; type StoreProps = StoreSharedProps & { - children: (store: GenerateSharedKeysStoreValue) => ReactElement; + children: (store: GenerateSharedWalletKeyStoreValue) => ReactElement; }; export const makeInitialState = () => stateEnterPassword({ loading: false, passwordErrorMessage: undefined, - sharedKeys: undefined, - sharedKeysCollapsed: undefined, - step: GenerateSharedKeysStep.EnterPassword, + sharedWalletKey: undefined, + sharedWalletKeyCollapsed: undefined, + step: GenerateSharedWalletKeyStep.EnterPassword, }); -export const Store: FC = ({ children, generateKeys, navigateToParentFlow }) => { +export const Store: FC = ({ children, generateKey, navigateToParentFlow }) => { const initialState = useInitialState(makeInitialState()); - const [state, dispatch] = useReducer((prevState: GenerateSharedKeysState, action: Action) => { + const [state, dispatch] = useReducer((prevState: GenerateSharedWalletKeyState, action: Action) => { const stateMachine = makeStateMachine({ navigateToParentFlow, triggerKeysGeneration: (password) => { - generateKeys(password) - .then((sharedKeys) => dispatch({ sharedKeys, type: ActionType.KeysGenerationCompleted })) + generateKey(password) + .then((sharedWalletKey) => dispatch({ sharedWalletKey, type: ActionType.KeysGenerationCompleted })) .catch((error) => dispatch({ errorMessage: error.message, type: ActionType.KeysGenerationFailed })); }, }); - const handler = stateMachine[prevState.step] as Handler; + const handler = stateMachine[prevState.step] as Handler; return handler(prevState, action); }, initialState); diff --git a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/Store/index.ts b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/Store/index.ts similarity index 51% rename from packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/Store/index.ts rename to packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/Store/index.ts index 40c4f4153..b92cecbce 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/Store/index.ts +++ b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/Store/index.ts @@ -1,5 +1,5 @@ export { ActionType } from './machine'; -export { GenerateSharedKeysStep } from './state'; -export type { GenerateSharedKeysState } from './state'; +export { GenerateSharedWalletKeyStep } from './state'; +export type { GenerateSharedWalletKeyState } from './state'; export { Store } from './Store'; export type { StoreSharedProps } from './Store'; diff --git a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/Store/machine.ts b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/Store/machine.ts similarity index 69% rename from packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/Store/machine.ts rename to packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/Store/machine.ts index 0a7bf3dfa..598904b39 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/Store/machine.ts +++ b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/Store/machine.ts @@ -1,10 +1,10 @@ import { TransitionHandler } from '../../../state-utils'; import { - GenerateSharedKeysState, - GenerateSharedKeysStep, - StateCopyKeys, + GenerateSharedWalletKeyState, + GenerateSharedWalletKeyStep, + StateCopyKey, StateEnterPassword, - stateCopyKeys, + stateCopyKey, stateEnterPassword, } from './state'; @@ -19,15 +19,19 @@ export enum ActionType { export type Action = | { type: ActionType.Back } | { password: string; type: ActionType.KeysGenerationTriggered } - | { sharedKeys: string; type: ActionType.KeysGenerationCompleted } + | { sharedWalletKey: string; type: ActionType.KeysGenerationCompleted } | { errorMessage: string; type: ActionType.KeysGenerationFailed } | { type: ActionType.CloseFlow }; -export type Handler = TransitionHandler; +export type Handler = TransitionHandler< + S, + GenerateSharedWalletKeyState, + Action +>; type StateMachine = { - [GenerateSharedKeysStep.EnterPassword]: Handler; - [GenerateSharedKeysStep.CopyKeys]: Handler; + [GenerateSharedWalletKeyStep.EnterPassword]: Handler; + [GenerateSharedWalletKeyStep.CopyKey]: Handler; }; type MakeStateMachineParams = { @@ -39,7 +43,7 @@ export const makeStateMachine = ({ navigateToParentFlow, triggerKeysGeneration, }: MakeStateMachineParams): StateMachine => ({ - [GenerateSharedKeysStep.EnterPassword]: (prevState, action) => { + [GenerateSharedWalletKeyStep.EnterPassword]: (prevState, action) => { if (action.type === ActionType.Back) { navigateToParentFlow(); return prevState; @@ -62,18 +66,18 @@ export const makeStateMachine = ({ } if (action.type === ActionType.KeysGenerationCompleted) { - return stateCopyKeys({ + return stateCopyKey({ loading: undefined, passwordErrorMessage: undefined, - sharedKeys: action.sharedKeys, - sharedKeysCollapsed: true, - step: GenerateSharedKeysStep.CopyKeys, + sharedWalletKey: action.sharedWalletKey, + sharedWalletKeyCollapsed: true, + step: GenerateSharedWalletKeyStep.CopyKey, }); } return prevState; }, - [GenerateSharedKeysStep.CopyKeys]: (prevState, action) => { + [GenerateSharedWalletKeyStep.CopyKey]: (prevState, action) => { if (action.type === ActionType.CloseFlow) { navigateToParentFlow(); return prevState; diff --git a/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/Store/state.ts b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/Store/state.ts new file mode 100644 index 000000000..637e4033c --- /dev/null +++ b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/Store/state.ts @@ -0,0 +1,38 @@ +import { StateType, defineStateShape } from '../../../state-utils'; + +export enum GenerateSharedWalletKeyStep { + CopyKey = 'CopyKey', + EnterPassword = 'EnterPassword', +} + +const makeState = defineStateShape<{ + mainPart: { + step: GenerateSharedWalletKeyStep; + }; + variableDataPart: { + loading: boolean; + passwordErrorMessage: string; + sharedWalletKey: string; + sharedWalletKeyCollapsed: boolean; + }; +}>(); + +export const stateEnterPassword = makeState<{ + loading: boolean; + passwordErrorMessage: string | undefined; + sharedWalletKey: undefined; + sharedWalletKeyCollapsed: undefined; + step: GenerateSharedWalletKeyStep.EnterPassword; +}>(); +export type StateEnterPassword = StateType; + +export const stateCopyKey = makeState<{ + loading: undefined; + passwordErrorMessage: undefined; + sharedWalletKey: string; + sharedWalletKeyCollapsed: boolean; + step: GenerateSharedWalletKeyStep.CopyKey; +}>(); +export type StateCopyKey = StateType; + +export type GenerateSharedWalletKeyState = StateEnterPassword | StateCopyKey; diff --git a/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/index.ts b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/index.ts new file mode 100644 index 000000000..46678c21a --- /dev/null +++ b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/index.ts @@ -0,0 +1,2 @@ +export { GenerateSharedWalletKeyFlow } from './GenerateSharedWalletKeyFlow'; +export type { LinkedWalletType } from './GenerateSharedWalletKeyFlow'; diff --git a/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/timelineSteps.ts b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/timelineSteps.ts new file mode 100644 index 000000000..e6fce3fcb --- /dev/null +++ b/packages/core/src/shared-wallets/add-shared-wallet/generate-key-flow/timelineSteps.ts @@ -0,0 +1,10 @@ +export const keyGenerationTimelineSteps = [ + { + key: 'enter-password', + name: 'Enter password', + }, + { + key: 'copy-key', + name: 'Copy key', + }, +]; diff --git a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/CopyKeys/index.ts b/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/CopyKeys/index.ts deleted file mode 100644 index 8ea01b975..000000000 --- a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/CopyKeys/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { CopyKeys } from './CopyKeys'; diff --git a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/Store/state.ts b/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/Store/state.ts deleted file mode 100644 index 8ebf94561..000000000 --- a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/Store/state.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { StateType, defineStateShape } from '../../../state-utils'; - -export enum GenerateSharedKeysStep { - CopyKeys = 'CopyKeys', - EnterPassword = 'EnterPassword', -} - -const makeState = defineStateShape<{ - mainPart: { - step: GenerateSharedKeysStep; - }; - variableDataPart: { - loading: boolean; - passwordErrorMessage: string; - sharedKeys: string; - sharedKeysCollapsed: boolean; - }; -}>(); - -export const stateEnterPassword = makeState<{ - loading: boolean; - passwordErrorMessage: string | undefined; - sharedKeys: undefined; - sharedKeysCollapsed: undefined; - step: GenerateSharedKeysStep.EnterPassword; -}>(); -export type StateEnterPassword = StateType; - -export const stateCopyKeys = makeState<{ - loading: undefined; - passwordErrorMessage: undefined; - sharedKeys: string; - sharedKeysCollapsed: boolean; - step: GenerateSharedKeysStep.CopyKeys; -}>(); -export type StateCopyKeys = StateType; - -export type GenerateSharedKeysState = StateEnterPassword | StateCopyKeys; diff --git a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/index.ts b/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/index.ts deleted file mode 100644 index 650214272..000000000 --- a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { GenerateSharedKeysFlow } from './GenerateSharedKeysFlow'; -export type { LinkedWalletType } from './GenerateSharedKeysFlow'; diff --git a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/timelineSteps.ts b/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/timelineSteps.ts deleted file mode 100644 index 0fa75a05b..000000000 --- a/packages/core/src/shared-wallets/add-shared-wallet/generate-keys-flow/timelineSteps.ts +++ /dev/null @@ -1,10 +0,0 @@ -export const keysGenerationTimelineSteps = [ - { - key: 'enter-password', - name: 'Enter password', - }, - { - key: 'copy-keys', - name: 'Copy keys', - }, -]; diff --git a/packages/core/src/shared-wallets/add-shared-wallet/index.ts b/packages/core/src/shared-wallets/add-shared-wallet/index.ts index ee3000736..7a16dc61c 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/index.ts +++ b/packages/core/src/shared-wallets/add-shared-wallet/index.ts @@ -2,7 +2,7 @@ import '@lace/translation'; export { AddSharedWalletModal } from './AddSharedWalletModal'; export { SharedWalletCreationFlow, QuorumRadioOption } from './creation-flow'; export type { CoSigner, QuorumOptionValue } from './creation-flow'; -export { GenerateSharedKeysFlow } from './generate-keys-flow'; -export type { LinkedWalletType } from './generate-keys-flow'; +export { GenerateSharedWalletKeyFlow } from './generate-key-flow'; +export type { LinkedWalletType } from './generate-key-flow'; export { AddSharedWalletMainPageFlow, SharedWalletEntry } from './main-page-flow'; export { SharedWalletRestorationFlow } from './restore-flow'; diff --git a/packages/core/src/shared-wallets/add-shared-wallet/main-page-flow/AddSharedWalletMainPageFlow.tsx b/packages/core/src/shared-wallets/add-shared-wallet/main-page-flow/AddSharedWalletMainPageFlow.tsx index ec5f48b06..46c622a8f 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/main-page-flow/AddSharedWalletMainPageFlow.tsx +++ b/packages/core/src/shared-wallets/add-shared-wallet/main-page-flow/AddSharedWalletMainPageFlow.tsx @@ -2,19 +2,19 @@ import React, { VFC } from 'react'; import { SharedWalletEntry, SharedWalletEntrySharedProps } from './SharedWalletEntry'; type AddSharedWalletMainPageFlowProps = SharedWalletEntrySharedProps & { - sharedKeys?: string; + sharedWalletKey?: string; }; -export const AddSharedWalletMainPageFlow: VFC = ({ sharedKeys, ...restProps }) => - sharedKeys ? ( +export const AddSharedWalletMainPageFlow: VFC = ({ sharedWalletKey, ...restProps }) => + sharedWalletKey ? ( { - await navigator.clipboard.writeText(sharedKeys); + onKeysCopyClick={async () => { + await navigator.clipboard.writeText(sharedWalletKey); }} {...restProps} /> ) : ( - + ); diff --git a/packages/core/src/shared-wallets/add-shared-wallet/main-page-flow/SharedWalletEntry/SharedWalletEntry.stories.tsx b/packages/core/src/shared-wallets/add-shared-wallet/main-page-flow/SharedWalletEntry/SharedWalletEntry.stories.tsx index 63447b417..3a331cb6c 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/main-page-flow/SharedWalletEntry/SharedWalletEntry.stories.tsx +++ b/packages/core/src/shared-wallets/add-shared-wallet/main-page-flow/SharedWalletEntry/SharedWalletEntry.stories.tsx @@ -1,6 +1,6 @@ import { action } from '@storybook/addon-actions'; import type { Meta, StoryObj } from '@storybook/react'; -import { SharedWalletEntry } from '@src/shared-wallets'; +import { SharedWalletEntry } from './SharedWalletEntry'; const meta: Meta = { component: SharedWalletEntry, @@ -13,21 +13,20 @@ type Story = StoryObj; export const NoKeys: Story = { args: { createAndImportOptionsDisabled: true, - keysMode: 'generate', onCreateSharedWalletClick: action('create click'), onImportSharedWalletClick: action('import click'), - onKeysCopyClick: action('keys copy'), - onKeysGenerateClick: action('keys generate'), + onKeysGenerateClick: action('key generate'), + sharedWalletKeyMode: 'generate', }, }; export const KeysAvailable: Story = { args: { createAndImportOptionsDisabled: false, - keysMode: 'copy', onCreateSharedWalletClick: action('create click'), onImportSharedWalletClick: action('import click'), - onKeysCopyClick: action('keys copy'), - onKeysGenerateClick: action('keys generate'), + onKeysCopyClick: action('key copy'), + onKeysGenerateClick: action('key generate'), + sharedWalletKeyMode: 'copy', }, }; diff --git a/packages/core/src/shared-wallets/add-shared-wallet/main-page-flow/SharedWalletEntry/SharedWalletEntry.tsx b/packages/core/src/shared-wallets/add-shared-wallet/main-page-flow/SharedWalletEntry/SharedWalletEntry.tsx index cae03a491..a393b4679 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/main-page-flow/SharedWalletEntry/SharedWalletEntry.tsx +++ b/packages/core/src/shared-wallets/add-shared-wallet/main-page-flow/SharedWalletEntry/SharedWalletEntry.tsx @@ -27,12 +27,12 @@ type SharedWalletEntryProps = SharedWalletEntrySharedProps & ( | { createAndImportOptionsDisabled: true; - keysMode: 'generate'; + sharedWalletKeyMode: 'generate'; } | { - copyKeysToClipboard?: () => Promise; createAndImportOptionsDisabled: false; - keysMode: 'copy'; + onKeysCopyClick: () => Promise; + sharedWalletKeyMode: 'copy'; } ); @@ -48,9 +48,9 @@ export const SharedWalletEntry = ({ const commonKeysOptionCopies = useMemo( () => ({ description: ( - }} /> + }} /> ), - title: t('sharedWallets.addSharedWallet.getStarted.keysOption.title'), + title: t('sharedWallets.addSharedWallet.getStarted.keyOption.title'), }), [t], ); @@ -77,14 +77,14 @@ export const SharedWalletEntry = ({ ), title: t('sharedWallets.addSharedWallet.getStarted.importSharedWalletOption.title'), }, - keysCopyOption: { + keyCopyOption: { ...commonKeysOptionCopies, - button: t('sharedWallets.addSharedWallet.getStarted.keysOption.button.copy'), + button: t('sharedWallets.addSharedWallet.getStarted.keyOption.button.copy'), }, - keysCopyToastText: t('sharedWallets.addSharedWallet.getStarted.keysOption.copyToast'), - keysGenerateOption: { + keyCopyToastText: t('sharedWallets.addSharedWallet.getStarted.keyOption.copyToast'), + keyGenerateOption: { ...commonKeysOptionCopies, - button: t('sharedWallets.addSharedWallet.getStarted.keysOption.button.generate'), + button: t('sharedWallets.addSharedWallet.getStarted.keyOption.button.generate'), }, subTitle: t('sharedWallets.addSharedWallet.getStarted.subTitle'), title: t('sharedWallets.addSharedWallet.getStarted.title'), @@ -93,12 +93,12 @@ export const SharedWalletEntry = ({ ); const onKeysCopyClick = async () => { - if (restProps.keysMode !== 'copy') return; - await restProps.copyKeysToClipboard?.(); + if (restProps.sharedWalletKeyMode !== 'copy') return; + await restProps.onKeysCopyClick(); toast.notify({ duration: TOAST_DURATION, icon: CopyIcon, - text: translations.keysCopyToastText, + text: translations.keyCopyToastText, }); }; @@ -139,17 +139,17 @@ export const SharedWalletEntry = ({
- {restProps.keysMode === 'generate' && ( + {restProps.sharedWalletKeyMode === 'generate' && ( )} - {restProps.keysMode === 'copy' && ( + {restProps.sharedWalletKeyMode === 'copy' && ( = ({ /> - void 0}> + void 0}> {translations.incorrectWalletError.title} {translations.incorrectWalletError.description} @@ -119,7 +119,7 @@ export const SharedWalletRestorationFlow: VFC = ({ autoFocus label={translations.incorrectWalletError.exit} onClick={navigateToAppHome} - testId="error-invalid-keys-exit-btn" + testId="error-invalid-shared-wallet-key-exit-btn" /> diff --git a/packages/core/src/shared-wallets/add-shared-wallet/restore-flow/types.ts b/packages/core/src/shared-wallets/add-shared-wallet/restore-flow/types.ts index 75af8dc4a..0106a8756 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/restore-flow/types.ts +++ b/packages/core/src/shared-wallets/add-shared-wallet/restore-flow/types.ts @@ -1,5 +1,5 @@ export enum FileErrorMessage { - INVALID_KEYS = 'Invalid keys', + INVALID_KEY = 'Invalid key', UNRECOGNIZED = 'File is unrecognized', } diff --git a/packages/core/src/shared-wallets/add-shared-wallet/restore-flow/validateJson.ts b/packages/core/src/shared-wallets/add-shared-wallet/restore-flow/validateJson.ts index efe5ad3d4..7b6ea32ae 100644 --- a/packages/core/src/shared-wallets/add-shared-wallet/restore-flow/validateJson.ts +++ b/packages/core/src/shared-wallets/add-shared-wallet/restore-flow/validateJson.ts @@ -19,10 +19,10 @@ export const validateJson = ( } // change json file in this directory to test happy path or mismatch error modal - const isAddrMatch = json.cosigners.findIndex((item: CoSigner) => item.keys === sharedKeys); + const isAddrMatch = json.cosigners.findIndex((item: CoSigner) => item.sharedWalletKey === sharedKeys); if (isAddrMatch === -1) { - reject({ message: FileErrorMessage.INVALID_KEYS }); + reject({ message: FileErrorMessage.INVALID_KEY }); } resolve({ isFileValid: true }); diff --git a/packages/core/src/shared-wallets/flow-stories/AddSharedWalletStorybookHelper.tsx b/packages/core/src/shared-wallets/flow-stories/AddSharedWalletStorybookHelper.tsx index c142503d3..af6df7a75 100644 --- a/packages/core/src/shared-wallets/flow-stories/AddSharedWalletStorybookHelper.tsx +++ b/packages/core/src/shared-wallets/flow-stories/AddSharedWalletStorybookHelper.tsx @@ -10,56 +10,57 @@ import { makeInitialState as makeSharedWalletCreationInitialState, } from '../add-shared-wallet/creation-flow/SharedWalletCreationStore'; import { CreationFlowState } from '../add-shared-wallet/creation-flow/state-and-types'; -import { GenerateSharedKeysFlow } from '../add-shared-wallet/generate-keys-flow'; -import { LinkedWalletType } from '../add-shared-wallet/generate-keys-flow/GenerateSharedKeysFlow'; -import { GenerateSharedKeysState } from '../add-shared-wallet/generate-keys-flow/Store'; +import { GenerateSharedWalletKeyFlow } from '../add-shared-wallet/generate-key-flow'; +import { LinkedWalletType } from '../add-shared-wallet/generate-key-flow/GenerateSharedWalletKeyFlow'; +import { GenerateSharedWalletKeyState } from '../add-shared-wallet/generate-key-flow/Store'; import { - GenerateSharedKeysInitialStateProvider, - makeInitialState as makeGenerateSharedKeysInitialState, -} from '../add-shared-wallet/generate-keys-flow/Store/Store'; + GenerateSharedWalletKeyInitialStateProvider, + makeInitialState as makeGenerateSharedWalletKeyInitialState, +} from '../add-shared-wallet/generate-key-flow/Store/Store'; export enum AddSharedWalletFlowType { Creation = 'Creation', GetStarted = 'GetStarted', Import = 'Import', - KeysDerivation = 'KeysDerivation', + KeyDerivation = 'KeyDerivation', } type AddSharedWalletFlowProps = { - activeWalletSharedKeys?: string; + activeWalletSharedKey?: string; activeWalletType?: LinkedWalletType; creationInitialState?: CreationFlowState; - generateKeys?: (password: string) => Promise; + generateKey?: (password: string) => Promise; initialFlow?: AddSharedWalletFlowType; - keysGenerationInitialState?: GenerateSharedKeysState; + keyGenerationInitialState?: GenerateSharedWalletKeyState; modalOpen?: boolean; }; -export const sharedKeys = 'addr_shared_vksdhgfsft578s6tf68tdsf,stake_shared_vkgyufieus65cuv76s5vrs7'; +export const sharedWalletKey = + '979693650bb44f26010e9f7b3b550b0602c748d1d00981747bac5c34cf5b945fe01a39317b9b701e58ee16b5ed16aa4444704b98cc997bdd6c5a9502a8b7d70d'; export const activeWalletName = 'My wallet'; export const AddSharedWalletStorybookHelper: VFC = ({ - activeWalletSharedKeys, + activeWalletSharedKey, activeWalletType = 'InMemory', modalOpen = false, initialFlow = AddSharedWalletFlowType.GetStarted, creationInitialState: providedCreationInitialState = makeSharedWalletCreationInitialState(activeWalletName), - keysGenerationInitialState: providedKeysGenerationInitialState = makeGenerateSharedKeysInitialState(), - generateKeys = async () => sharedKeys, + keyGenerationInitialState: providedKeysGenerationInitialState = makeGenerateSharedWalletKeyInitialState(), + generateKey = async () => sharedWalletKey, }) => { const [open, setOpen] = useState(modalOpen); const [flow, setFlow] = useState(initialFlow); - const [generatedKeys, setGeneratedKeys] = useState(activeWalletSharedKeys); + const [generatedKeys, setGeneratedKeys] = useState(activeWalletSharedKey); const [creationInitialState, setCreationInitialState] = useState( providedCreationInitialState, ); - const [keysGenerationInitialState, setKeysGenerationInitialState] = useState( + const [keyGenerationInitialState, setKeyGenerationInitialState] = useState( providedKeysGenerationInitialState, ); useEffect(() => { setCreationInitialState(null); - setKeysGenerationInitialState(null); + setKeyGenerationInitialState(null); }, []); return ( @@ -76,22 +77,22 @@ export const AddSharedWalletStorybookHelper: VFC = ({ setFlow(AddSharedWalletFlowType.Creation)} onImportSharedWalletClick={() => setFlow(AddSharedWalletFlowType.Import)} - onKeysGenerateClick={() => setFlow(AddSharedWalletFlowType.KeysDerivation)} - sharedKeys={generatedKeys} + onKeysGenerateClick={() => setFlow(AddSharedWalletFlowType.KeyDerivation)} + sharedWalletKey={generatedKeys} /> )} - {flow === AddSharedWalletFlowType.KeysDerivation && ( - - + { - setGeneratedKeys(sharedKeys); + setGeneratedKeys(sharedWalletKey); setFlow(AddSharedWalletFlowType.GetStarted); }} activeWalletName={activeWalletName} activeWalletType={activeWalletType} /> - + )} {flow === AddSharedWalletFlowType.Creation && ( @@ -103,7 +104,7 @@ export const AddSharedWalletStorybookHelper: VFC = ({ setFlow(AddSharedWalletFlowType.GetStarted); }} exitTheFlow={() => setFlow(AddSharedWalletFlowType.GetStarted)} - sharedKeys={generatedKeys} + sharedWalletKey={generatedKeys} onCreateSharedWallet={() => void 0} /> diff --git a/packages/core/src/shared-wallets/flow-stories/add-shared-wallet-create-flow.stories.tsx b/packages/core/src/shared-wallets/flow-stories/add-shared-wallet-create-flow.stories.tsx index 2ae2d3237..16038556e 100644 --- a/packages/core/src/shared-wallets/flow-stories/add-shared-wallet-create-flow.stories.tsx +++ b/packages/core/src/shared-wallets/flow-stories/add-shared-wallet-create-flow.stories.tsx @@ -8,7 +8,11 @@ import { QuorumRadioOption } from '../add-shared-wallet/creation-flow/Quorum'; import { makeInitialState } from '../add-shared-wallet/creation-flow/SharedWalletCreationStore'; import { CreationFlowState, SharedWalletCreationStep } from '../add-shared-wallet/creation-flow/state-and-types'; import { validateCoSigners } from '../add-shared-wallet/creation-flow/validateCoSigners'; -import { AddSharedWalletFlowType, AddSharedWalletStorybookHelper, sharedKeys } from './AddSharedWalletStorybookHelper'; +import { + AddSharedWalletFlowType, + AddSharedWalletStorybookHelper, + sharedWalletKey, +} from './AddSharedWalletStorybookHelper'; const meta: Meta = { component: AddSharedWalletStorybookHelper, @@ -29,7 +33,7 @@ export const Setup: Story = { name: 'Setup', render: () => ( ({ id: signer.id, keys: true, name: true })), + coSignerInputsDirty: coSignersData.map((signer) => ({ id: signer.id, name: true, sharedWalletKey: true })), coSignerInputsErrors: [], coSigners: coSignersData, quorumRules: undefined, @@ -65,16 +69,16 @@ export const CoSigners: Story = { name: 'CoSigners', render: () => { const coSigners: CreationFlowState['coSigners'] = ensureCorrectCoSignersDataShape([ - createCoSignerObject(sharedKeys), + createCoSignerObject(sharedWalletKey), ]); return ( ({ id: signer.id, keys: false, name: false })), + coSignerInputsDirty: coSigners.map((signer) => ({ id: signer.id, name: false, sharedWalletKey: false })), coSigners, }} /> @@ -88,28 +92,32 @@ export const CoSignersUserPlus2: Story = { const coSigners: CreationFlowState['coSigners'] = ensureCorrectCoSignersDataShape([ { id: 'cosigner1', - keys: sharedKeys, name: 'Initiator', + sharedWalletKey, }, { id: 'cosigner2', - keys: sharedKeys, name: 'Sophia', + sharedWalletKey, }, { id: 'cosigner3', - keys: sharedKeys, name: 'Martha', + sharedWalletKey, }, ]); return ( ({ id: signer.id, keys: !!signer.keys, name: !!signer.name })), + coSignerInputsDirty: coSigners.map((signer) => ({ + id: signer.id, + name: !!signer.name, + sharedWalletKey: !!signer.sharedWalletKey, + })), coSigners, }} /> @@ -123,23 +131,23 @@ export const CoSignersWithErrors: Story = { const coSigners: CreationFlowState['coSigners'] = ensureCorrectCoSignersDataShape([ { id: 'cosigner1', - keys: 'invalid keys', name: 'Sophia', + sharedWalletKey: 'invalid sharedWalletKey', }, { id: 'cosigner2', - keys: '', name: 'Sophia', + sharedWalletKey: '', }, ]); return ( ({ id: signer.id, keys: true, name: true })), + coSignerInputsDirty: coSigners.map((signer) => ({ id: signer.id, name: true, sharedWalletKey: true })), coSignerInputsErrors: validateCoSigners(coSigners), coSigners, }} @@ -152,7 +160,7 @@ export const CoSignersConfirmation: Story = { name: 'CoSigners - confirmation', render: () => ( c.keys && c.name); +const filteredCosigners = coSignersStateData.coSigners.filter((c) => c.sharedWalletKey && c.name); export const Quorum: Story = { name: 'Quorum', render: () => ( ({ id: signer.id, keys: true, name: true })), + coSignerInputsDirty: filteredCosigners.map((signer) => ({ id: signer.id, name: true, sharedWalletKey: true })), coSigners: filteredCosigners, quorumRules: { numberOfCosigner: 1, @@ -188,7 +196,7 @@ export const ShareDetails: Story = { name: 'ShareDetails', render: () => ( = { component: AddSharedWalletStorybookHelper, @@ -21,7 +25,7 @@ export const Import: Story = { name: 'Import', render: () => ( diff --git a/packages/core/src/shared-wallets/flow-stories/add-shared-wallet-keys-derivation-flow.stories.tsx b/packages/core/src/shared-wallets/flow-stories/add-shared-wallet-keys-derivation-flow.stories.tsx index 1bf406301..473ab3e60 100644 --- a/packages/core/src/shared-wallets/flow-stories/add-shared-wallet-keys-derivation-flow.stories.tsx +++ b/packages/core/src/shared-wallets/flow-stories/add-shared-wallet-keys-derivation-flow.stories.tsx @@ -1,11 +1,15 @@ import { Meta, StoryObj } from '@storybook/react'; import React from 'react'; import { - GenerateSharedKeysStep, - stateCopyKeys, + GenerateSharedWalletKeyStep, + stateCopyKey, stateEnterPassword, -} from '../add-shared-wallet/generate-keys-flow/Store/state'; -import { AddSharedWalletFlowType, AddSharedWalletStorybookHelper, sharedKeys } from './AddSharedWalletStorybookHelper'; +} from '../add-shared-wallet/generate-key-flow/Store/state'; +import { + AddSharedWalletFlowType, + AddSharedWalletStorybookHelper, + sharedWalletKey, +} from './AddSharedWalletStorybookHelper'; const meta: Meta = { component: AddSharedWalletStorybookHelper, @@ -24,7 +28,7 @@ type Story = StoryObj; export const EnterPassword: Story = { name: 'EnterPassword', - render: () => , + render: () => , }; export const EnterIncorrectPassword: Story = { @@ -32,13 +36,13 @@ export const EnterIncorrectPassword: Story = { render: () => ( ), @@ -49,13 +53,13 @@ export const CopyKeys: Story = { render: () => ( ), diff --git a/packages/core/src/shared-wallets/flow-stories/add-shared-wallet.stories.tsx b/packages/core/src/shared-wallets/flow-stories/add-shared-wallet.stories.tsx index db073150e..11d74a0eb 100644 --- a/packages/core/src/shared-wallets/flow-stories/add-shared-wallet.stories.tsx +++ b/packages/core/src/shared-wallets/flow-stories/add-shared-wallet.stories.tsx @@ -1,6 +1,6 @@ import { Meta, StoryObj } from '@storybook/react'; import React from 'react'; -import { AddSharedWalletStorybookHelper, sharedKeys } from './AddSharedWalletStorybookHelper'; +import { AddSharedWalletStorybookHelper, sharedWalletKey } from './AddSharedWalletStorybookHelper'; const meta: Meta = { component: AddSharedWalletStorybookHelper, @@ -22,11 +22,11 @@ export const Closed: Story = { }; export const OpenNoKeys: Story = { - name: 'Open - no keys', + name: 'Open - no key', render: () => , }; export const OpenKeysAvailable: Story = { - name: 'Open - keys available', - render: () => , + name: 'Open - key available', + render: () => , }; diff --git a/packages/core/src/shared-wallets/transaction/TransactionDetails.tsx b/packages/core/src/shared-wallets/transaction/TransactionDetails.tsx index 0a264d4a6..91605e3c4 100644 --- a/packages/core/src/shared-wallets/transaction/TransactionDetails.tsx +++ b/packages/core/src/shared-wallets/transaction/TransactionDetails.tsx @@ -3,9 +3,7 @@ import { Box, SummaryExpander, TransactionSummary } from '@input-output-hk/lace- import { Wallet } from '@lace/cardano'; import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { ActivityStatus } from '@src/ui/components/Activity'; -import { TransactionFee, TxSummary } from '@src/ui/components/ActivityDetail'; -import { Transaction } from '@src/ui/components/Transaction'; +import { ActivityStatus, Transaction, TransactionFee, TxSummary } from '@src/ui/components/Transaction'; import { CosignersList, CosignersListItem } from './CosignersList'; import { InfoBar } from './InfoBar'; import styles from './TransactionDetails.module.scss'; diff --git a/packages/core/src/ui/components/Activity/AssetActivityItem.tsx b/packages/core/src/ui/components/Activity/AssetActivityItem.tsx index d278ff572..099427ea8 100644 --- a/packages/core/src/ui/components/Activity/AssetActivityItem.tsx +++ b/packages/core/src/ui/components/Activity/AssetActivityItem.tsx @@ -11,23 +11,17 @@ import { ReactComponent as PendingIcon } from '../../assets/icons/pending.compon import { ReactComponent as ErrorIcon } from '../../assets/icons/error.component.svg'; import pluralize from 'pluralize'; import { txIconSize } from '@src/ui/utils/icon-size'; -import { DelegationActivityType, TransactionActivityType, ConwayEraCertificatesTypes } from '../ActivityDetail/types'; +import { DelegationActivityType, ConwayEraCertificatesTypes } from '../ActivityDetail/types'; import type { ActivityType } from '../ActivityDetail/types'; import styles from './AssetActivityItem.module.scss'; import { ActivityTypeIcon } from '../ActivityDetail/ActivityTypeIcon'; import { useTranslation } from 'react-i18next'; import { CoreTranslationKey } from '@lace/translation'; +import { ActivityStatus, TransactionActivityType } from '@ui/components/Transaction'; export type ActivityAssetInfo = { ticker: string }; export type ActivityAssetProp = { id: string; val: string; info?: ActivityAssetInfo }; -export enum ActivityStatus { - SUCCESS = 'success', - PENDING = 'sending', - ERROR = 'error', - SPENDABLE = 'spendable' -} - const DEFAULT_DEBOUNCE = 200; export interface AssetActivityItemProps { diff --git a/packages/core/src/ui/components/Activity/AssetActivityList.stories.tsx b/packages/core/src/ui/components/Activity/AssetActivityList.stories.tsx index 2de6bd4e5..5cb59cf8e 100644 --- a/packages/core/src/ui/components/Activity/AssetActivityList.stories.tsx +++ b/packages/core/src/ui/components/Activity/AssetActivityList.stories.tsx @@ -7,7 +7,7 @@ import { Cip1694GovernanceActivityType, ConwayEraCertificatesTypes } from '../ActivityDetail'; -import { ActivityStatus } from './AssetActivityItem'; +import { ActivityStatus } from '../Transaction'; const meta: Meta = { title: 'Sanchonet/ActivityHistory/AssetActivityList', diff --git a/packages/core/src/ui/components/Activity/__tests__/AssetActivityItem.test.tsx b/packages/core/src/ui/components/Activity/__tests__/AssetActivityItem.test.tsx index a8007f593..403967a19 100644 --- a/packages/core/src/ui/components/Activity/__tests__/AssetActivityItem.test.tsx +++ b/packages/core/src/ui/components/Activity/__tests__/AssetActivityItem.test.tsx @@ -2,8 +2,8 @@ import * as React from 'react'; import { render, within, fireEvent, queryByTestId } from '@testing-library/react'; import '@testing-library/jest-dom'; -import { AssetActivityItem, AssetActivityItemProps, ActivityStatus } from '../AssetActivityItem'; -import { TransactionActivityType } from '../../ActivityDetail/types'; +import { AssetActivityItem, AssetActivityItemProps } from '../AssetActivityItem'; +import { ActivityStatus, TransactionActivityType } from '../../Transaction'; import { ActivityType } from '../../ActivityDetail'; const assetsAmountTestId = 'asset-amount'; diff --git a/packages/core/src/ui/components/Activity/__tests__/AssetActivityList.test.tsx b/packages/core/src/ui/components/Activity/__tests__/AssetActivityList.test.tsx index 9c7b8e2e7..8e1ccc5d9 100644 --- a/packages/core/src/ui/components/Activity/__tests__/AssetActivityList.test.tsx +++ b/packages/core/src/ui/components/Activity/__tests__/AssetActivityList.test.tsx @@ -3,8 +3,7 @@ import * as React from 'react'; import { render, fireEvent } from '@testing-library/react'; import '@testing-library/jest-dom'; import { AssetActivityList, AssetActivityListProps } from '../AssetActivityList'; -import { ActivityStatus } from '../AssetActivityItem'; -import { TransactionActivityType } from '../../ActivityDetail'; +import { ActivityStatus, TransactionActivityType } from '../../Transaction'; const activityTranslations = { asset: 'asset', diff --git a/packages/core/src/ui/components/Activity/__tests__/GroupedAssetActivityList.test.tsx b/packages/core/src/ui/components/Activity/__tests__/GroupedAssetActivityList.test.tsx index a3655b908..56bd558d1 100644 --- a/packages/core/src/ui/components/Activity/__tests__/GroupedAssetActivityList.test.tsx +++ b/packages/core/src/ui/components/Activity/__tests__/GroupedAssetActivityList.test.tsx @@ -4,7 +4,7 @@ import { render } from '@testing-library/react'; import '@testing-library/jest-dom'; import { GroupedAssetActivityList, GroupedAssetActivityListProps } from '../GroupedAssetActivityList'; import { AssetActivityItemProps } from '../AssetActivityItem'; -import { TransactionActivityType } from '../../ActivityDetail'; +import { TransactionActivityType } from '../../Transaction'; const activityItem: AssetActivityItemProps = { type: TransactionActivityType.outgoing, diff --git a/packages/core/src/ui/components/ActivityDetail/ActivityTypeIcon.tsx b/packages/core/src/ui/components/ActivityDetail/ActivityTypeIcon.tsx index fa02b22ef..704352338 100644 --- a/packages/core/src/ui/components/ActivityDetail/ActivityTypeIcon.tsx +++ b/packages/core/src/ui/components/ActivityDetail/ActivityTypeIcon.tsx @@ -30,10 +30,9 @@ import { ConwayEraCertificatesTypes, ConwayEraGovernanceActions, DelegationActivityType, - TransactionActivityType, Cip1694GovernanceActivityType } from './types'; - +import { TransactionActivityType } from '../Transaction'; import styles from './ActivityTypeIcon.module.scss'; import { Flex } from '@input-output-hk/lace-ui-toolkit'; diff --git a/packages/core/src/ui/components/ActivityDetail/RewardsDetails.tsx b/packages/core/src/ui/components/ActivityDetail/RewardsDetails.tsx index 0561fe1ef..abbecc977 100644 --- a/packages/core/src/ui/components/ActivityDetail/RewardsDetails.tsx +++ b/packages/core/src/ui/components/ActivityDetail/RewardsDetails.tsx @@ -1,7 +1,7 @@ import React from 'react'; import cn from 'classnames'; import styles from './TransactionDetails.module.scss'; -import { ActivityStatus } from '../Activity/AssetActivityItem'; +import { ActivityStatus } from '../Transaction'; import { Ellipsis } from '@lace/common'; import { ActivityDetailHeader } from './ActivityDetailHeader'; import { useTranslation } from 'react-i18next'; diff --git a/packages/core/src/ui/components/ActivityDetail/TransactionDetailAsset.ts b/packages/core/src/ui/components/ActivityDetail/TransactionDetailAsset.ts deleted file mode 100644 index bd00d0813..000000000 --- a/packages/core/src/ui/components/ActivityDetail/TransactionDetailAsset.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { TransactionActivityType } from '@ui/components/ActivityDetail/types'; - -export interface TransactionDetailAsset { - icon?: string; - title: string; - subtitle?: string; -} - -export interface CoinItemProps { - amount: string; - fiatBalance?: string; - handleClick: () => unknown; - id: number | string; - logo?: string; - name: string; - symbol?: string; -} - -export interface TxOutputInput { - addr: string; - amount: string; - assetList?: CoinItemProps[]; -} - -export interface TxSummary extends Omit { - addr: string[]; - type: TransactionActivityType; -} - -interface TxMetadata { - key: string; - value: string | unknown[]; -} - -export interface TransactionMetadataProps { - /** - * List of key/value pairs with the transaction metadata - */ - metadata: TxMetadata[]; -} diff --git a/packages/core/src/ui/components/ActivityDetail/TransactionDetails.stories.tsx b/packages/core/src/ui/components/ActivityDetail/TransactionDetails.stories.tsx index 1bcc6e07d..97e414581 100644 --- a/packages/core/src/ui/components/ActivityDetail/TransactionDetails.stories.tsx +++ b/packages/core/src/ui/components/ActivityDetail/TransactionDetails.stories.tsx @@ -4,7 +4,7 @@ import type { Meta, StoryObj } from '@storybook/react'; import { TransactionDetails } from './TransactionDetails'; import { ComponentProps } from 'react'; -import { ActivityStatus } from '../Activity/AssetActivityItem'; +import { ActivityStatus } from '../Transaction'; import { Wallet } from '@lace/cardano'; import { mockProposalProcedure } from '@src/ui/utils'; import { mockVotingProcedures } from '@src/ui/utils/voting-procedures-mock'; diff --git a/packages/core/src/ui/components/ActivityDetail/TransactionDetails.tsx b/packages/core/src/ui/components/ActivityDetail/TransactionDetails.tsx index eaed66a06..ae558d71f 100644 --- a/packages/core/src/ui/components/ActivityDetail/TransactionDetails.tsx +++ b/packages/core/src/ui/components/ActivityDetail/TransactionDetails.tsx @@ -3,88 +3,19 @@ import React from 'react'; import cn from 'classnames'; import { Ellipsis } from '@lace/common'; import { Box } from '@input-output-hk/lace-ui-toolkit'; -import { TransactionDetailAsset, TransactionMetadataProps, TxOutputInput, TxSummary } from './TransactionDetailAsset'; -import { ActivityStatus } from '../Activity'; +import { ActivityStatus, Transaction, TransactionDetailsProps, TransactionFee } from '../Transaction'; import styles from './TransactionDetails.module.scss'; import { TransactionInputOutput } from './TransactionInputOutput'; -import { TransactionFee } from './TransactionFee'; import { ActivityDetailHeader } from './ActivityDetailHeader'; import { Collateral, CollateralStatus } from './Collateral'; -import { Wallet } from '@lace/cardano'; import { TxDetailsCertificates } from './components/TxDetailsCertificates/TxDetailsCertificates'; import { TxDetailsVotingProcedures } from './components/TxDetailsVotingProcedures'; import { TxDetailsProposalProcedures } from './components/TxDetailsProposalProcedures'; import { useTranslation } from 'react-i18next'; -import { Transaction } from '../Transaction'; // eslint-disable-next-line @typescript-eslint/no-explicit-any const displayMetadataMsg = (value: any[]): string => value?.find((val: any) => val.hasOwnProperty('msg'))?.msg || ''; -export interface TransactionDetailsProps { - hash?: string; - name: string; - status?: ActivityStatus; - /** - * Transaction generation date - */ - includedDate?: string; - /** - * Transaction generation time - */ - includedTime?: string; - assets?: TransactionDetailAsset[]; - /** - * Input address list - */ - addrInputs?: TxOutputInput[]; - /** - * Output address list - */ - addrOutputs?: TxOutputInput[]; - /** - * Transaction total output - */ - totalOutput?: string; - /** - * Transaction collateral - */ - collateral?: string; - /** - * Transaction fee - */ - fee?: string; - pools?: { name: string; ticker: string; id: string }[]; - /** - * Transaction deposit - */ - deposit?: string; - /** - * Transaction returned deposit - */ - depositReclaim?: string; - /** - * Transaction metadata - */ - metadata?: TransactionMetadataProps['metadata']; - amountTransformer: (amount: string) => string; - headerDescription?: string; - txSummary?: TxSummary[]; - coinSymbol: string; - tooltipContent?: string; - ownAddresses: string[]; - addressToNameMap: Map; - isPopupView?: boolean; - handleOpenExternalHashLink?: () => void; - sendAnalyticsInputs?: () => void; - sendAnalyticsOutputs?: () => void; - votingProcedures?: Wallet.Cardano.VotingProcedures; - proposalProcedures?: Wallet.Cardano.ProposalProcedure[]; - certificates?: Wallet.Cardano.Certificate[]; - chainNetworkId: Wallet.Cardano.NetworkId; - cardanoCoin: Wallet.CoinId; - explorerBaseUrl: string; -} - export const TransactionDetails = ({ hash, name, diff --git a/packages/core/src/ui/components/ActivityDetail/TransactionInputOutput.tsx b/packages/core/src/ui/components/ActivityDetail/TransactionInputOutput.tsx index 0ef4ea271..ad27511a9 100644 --- a/packages/core/src/ui/components/ActivityDetail/TransactionInputOutput.tsx +++ b/packages/core/src/ui/components/ActivityDetail/TransactionInputOutput.tsx @@ -6,7 +6,7 @@ import cn from 'classnames'; import { InfoCircleOutlined, DownOutlined } from '@ant-design/icons'; import { addEllipsis, Button } from '@lace/common'; -import { TxOutputInput } from './TransactionDetailAsset'; +import { TxOutputInput } from '../Transaction'; import { TranslationsFor } from '../../utils/types'; import { ReactComponent as BracketDown } from '../../assets/icons/bracket-down.component.svg'; diff --git a/packages/core/src/ui/components/ActivityDetail/__tests__/RewardsDetails.test.tsx b/packages/core/src/ui/components/ActivityDetail/__tests__/RewardsDetails.test.tsx index b00f5723d..0f2468235 100644 --- a/packages/core/src/ui/components/ActivityDetail/__tests__/RewardsDetails.test.tsx +++ b/packages/core/src/ui/components/ActivityDetail/__tests__/RewardsDetails.test.tsx @@ -3,7 +3,7 @@ import * as React from 'react'; import { render } from '@testing-library/react'; import '@testing-library/jest-dom'; import { RewardsDetails, RewardsDetailsProps } from '../RewardsDetails'; -import { ActivityStatus } from '../../Activity/AssetActivityItem'; +import { ActivityStatus } from '../../Transaction'; describe('Testing ActivityDetailsBrowser component', () => { const rewardsDetailsProps: RewardsDetailsProps = { diff --git a/packages/core/src/ui/components/ActivityDetail/__tests__/TransactionDetails.test.tsx b/packages/core/src/ui/components/ActivityDetail/__tests__/TransactionDetails.test.tsx index 35d1dc545..c1bbd7292 100644 --- a/packages/core/src/ui/components/ActivityDetail/__tests__/TransactionDetails.test.tsx +++ b/packages/core/src/ui/components/ActivityDetail/__tests__/TransactionDetails.test.tsx @@ -2,8 +2,9 @@ import * as React from 'react'; import { render, within, fireEvent } from '@testing-library/react'; import '@testing-library/jest-dom'; -import { TransactionDetails, TransactionDetailsProps } from '../TransactionDetails'; +import { TransactionDetails } from '../TransactionDetails'; import { Wallet } from '@lace/cardano'; +import { TransactionDetailsProps } from '../../Transaction'; const transactionDate = '2021/09/10'; diff --git a/packages/core/src/ui/components/ActivityDetail/index.ts b/packages/core/src/ui/components/ActivityDetail/index.ts index b694c44a0..7b5893fea 100644 --- a/packages/core/src/ui/components/ActivityDetail/index.ts +++ b/packages/core/src/ui/components/ActivityDetail/index.ts @@ -2,7 +2,5 @@ export * from './TransactionDetails'; export * from './RewardsDetails'; export * from './ActivityTypeIcon'; export * from './types'; -export * from './TransactionDetailAsset'; export * from './TransactionInputOutput'; -export * from './TransactionFee'; export * from './Collateral'; diff --git a/packages/core/src/ui/components/ActivityDetail/types.ts b/packages/core/src/ui/components/ActivityDetail/types.ts index 1c88cebf6..2b8e9f933 100644 --- a/packages/core/src/ui/components/ActivityDetail/types.ts +++ b/packages/core/src/ui/components/ActivityDetail/types.ts @@ -1,4 +1,5 @@ import { Wallet } from '@lace/cardano'; +import { TransactionActivityType } from '../Transaction'; // supported certificates actions export enum ConwayEraCertificatesTypes { @@ -37,13 +38,6 @@ export enum DelegationActivityType { 'delegationDeregistration' = 'delegationDeregistration' } -export enum TransactionActivityType { - 'outgoing' = 'outgoing', - 'incoming' = 'incoming', - 'self' = 'self', - 'rewards' = 'rewards' -} - export type TxDetailsCertificateTitles = | 'certificateType' | 'coldCredential' diff --git a/packages/core/src/ui/components/DappTransaction/DappTransaction.tsx b/packages/core/src/ui/components/DappTransaction/DappTransaction.tsx index dc3262734..a25b1206d 100644 --- a/packages/core/src/ui/components/DappTransaction/DappTransaction.tsx +++ b/packages/core/src/ui/components/DappTransaction/DappTransaction.tsx @@ -7,7 +7,8 @@ import { Cardano, TransactionSummaryInspection, TokenTransferValue, AssetInfoWit import { DappTransactionHeader, DappTransactionHeaderProps, TransactionTypes } from '../DappTransactionHeader'; import styles from './DappTransaction.module.scss'; -import { TransactionFee, Collateral } from '@ui/components/ActivityDetail'; +import { Collateral } from '@ui/components/ActivityDetail'; +import { TransactionFee } from '@ui/components/Transaction'; import { TransactionType, diff --git a/packages/core/src/ui/components/ActivityDetail/TransactionFee.module.scss b/packages/core/src/ui/components/Transaction/TransactionFee.module.scss similarity index 100% rename from packages/core/src/ui/components/ActivityDetail/TransactionFee.module.scss rename to packages/core/src/ui/components/Transaction/TransactionFee.module.scss diff --git a/packages/core/src/ui/components/ActivityDetail/TransactionFee.tsx b/packages/core/src/ui/components/Transaction/TransactionFee.tsx similarity index 100% rename from packages/core/src/ui/components/ActivityDetail/TransactionFee.tsx rename to packages/core/src/ui/components/Transaction/TransactionFee.tsx diff --git a/packages/core/src/ui/components/Transaction/TxHash.tsx b/packages/core/src/ui/components/Transaction/TxHash.tsx index 79fab5ea2..a4c7753cc 100644 --- a/packages/core/src/ui/components/Transaction/TxHash.tsx +++ b/packages/core/src/ui/components/Transaction/TxHash.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import cn from 'classnames'; -import { TransactionDetailsProps } from '../ActivityDetail'; +import { TransactionDetailsProps } from './types'; import styles from '../ActivityDetail/TransactionDetails.module.scss'; import { CopiableHash } from './CopiableHash'; diff --git a/packages/core/src/ui/components/Transaction/TxSummarySection.tsx b/packages/core/src/ui/components/Transaction/TxSummarySection.tsx index 272e0546a..dd5e7822d 100644 --- a/packages/core/src/ui/components/Transaction/TxSummarySection.tsx +++ b/packages/core/src/ui/components/Transaction/TxSummarySection.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import cn from 'classnames'; -import { TransactionActivityType, TransactionDetailsProps } from '../ActivityDetail'; +import { TransactionDetailsProps, TransactionActivityType } from './types'; import styles from '../ActivityDetail/TransactionDetails.module.scss'; import { Ellipsis } from '@lace/common'; import { Text } from '@input-output-hk/lace-ui-toolkit'; diff --git a/packages/core/src/ui/components/Transaction/index.ts b/packages/core/src/ui/components/Transaction/index.ts index 90022c426..67751e943 100644 --- a/packages/core/src/ui/components/Transaction/index.ts +++ b/packages/core/src/ui/components/Transaction/index.ts @@ -21,3 +21,6 @@ export const Transaction = { Timestamp, CopiableHash }; + +export * from './types'; +export { TransactionFee } from './TransactionFee'; diff --git a/packages/core/src/ui/components/Transaction/types.ts b/packages/core/src/ui/components/Transaction/types.ts new file mode 100644 index 000000000..26c865fdf --- /dev/null +++ b/packages/core/src/ui/components/Transaction/types.ts @@ -0,0 +1,119 @@ +import { Wallet } from '@lace/cardano'; + +export enum ActivityStatus { + SUCCESS = 'success', + PENDING = 'sending', + ERROR = 'error', + SPENDABLE = 'spendable' +} + +export enum TransactionActivityType { + 'outgoing' = 'outgoing', + 'incoming' = 'incoming', + 'self' = 'self', + 'rewards' = 'rewards' +} + +export interface TransactionDetailAsset { + icon?: string; + title: string; + subtitle?: string; +} + +export interface CoinItemProps { + amount: string; + fiatBalance?: string; + handleClick: () => unknown; + id: number | string; + logo?: string; + name: string; + symbol?: string; +} + +export interface TxOutputInput { + addr: string; + amount: string; + assetList?: CoinItemProps[]; +} + +export interface TxSummary extends Omit { + addr: string[]; + type: TransactionActivityType; +} + +interface TxMetadata { + key: string; + value: string | unknown[]; +} + +export interface TransactionMetadataProps { + /** + * List of key/value pairs with the transaction metadata + */ + metadata: TxMetadata[]; +} + +export interface TransactionDetailsProps { + hash?: string; + name: string; + status?: ActivityStatus; + /** + * Transaction generation date + */ + includedDate?: string; + /** + * Transaction generation time + */ + includedTime?: string; + assets?: TransactionDetailAsset[]; + /** + * Input address list + */ + addrInputs?: TxOutputInput[]; + /** + * Output address list + */ + addrOutputs?: TxOutputInput[]; + /** + * Transaction total output + */ + totalOutput?: string; + /** + * Transaction collateral + */ + collateral?: string; + /** + * Transaction fee + */ + fee?: string; + pools?: { name: string; ticker: string; id: string }[]; + /** + * Transaction deposit + */ + deposit?: string; + /** + * Transaction returned deposit + */ + depositReclaim?: string; + /** + * Transaction metadata + */ + metadata?: TransactionMetadataProps['metadata']; + amountTransformer: (amount: string) => string; + headerDescription?: string; + txSummary?: TxSummary[]; + coinSymbol: string; + tooltipContent?: string; + ownAddresses: string[]; + addressToNameMap: Map; + isPopupView?: boolean; + handleOpenExternalHashLink?: () => void; + sendAnalyticsInputs?: () => void; + sendAnalyticsOutputs?: () => void; + votingProcedures?: Wallet.Cardano.VotingProcedures; + proposalProcedures?: Wallet.Cardano.ProposalProcedure[]; + certificates?: Wallet.Cardano.Certificate[]; + chainNetworkId: Wallet.Cardano.NetworkId; + cardanoCoin: Wallet.CoinId; + explorerBaseUrl: string; +} diff --git a/packages/translation/src/lib/translations/shared-wallets/en.json b/packages/translation/src/lib/translations/shared-wallets/en.json index 7fb11879a..f9991fbf9 100644 --- a/packages/translation/src/lib/translations/shared-wallets/en.json +++ b/packages/translation/src/lib/translations/shared-wallets/en.json @@ -6,11 +6,11 @@ "sharedWallets.addSharedWallet.getStarted.importSharedWalletOption.button": "Connect", "sharedWallets.addSharedWallet.getStarted.importSharedWalletOption.description": "Upload a JSON file to
join a shared wallet", "sharedWallets.addSharedWallet.getStarted.importSharedWalletOption.title": "Import shared wallet", - "sharedWallets.addSharedWallet.getStarted.keysOption.description": "Generate keys to take
part in a shared wallet", - "sharedWallets.addSharedWallet.getStarted.keysOption.title": "Shared wallet keys", - "sharedWallets.addSharedWallet.getStarted.keysOption.button.generate": "Generate", - "sharedWallets.addSharedWallet.getStarted.keysOption.button.copy": "Copy to clipboard", - "sharedWallets.addSharedWallet.getStarted.keysOption.copyToast": "Shared keys copied to clipboard", + "sharedWallets.addSharedWallet.getStarted.keyOption.description": "Generate key to take
part in a shared wallet", + "sharedWallets.addSharedWallet.getStarted.keyOption.title": "Shared wallet key", + "sharedWallets.addSharedWallet.getStarted.keyOption.button.generate": "Generate", + "sharedWallets.addSharedWallet.getStarted.keyOption.button.copy": "Copy to clipboard", + "sharedWallets.addSharedWallet.getStarted.keyOption.copyToast": "Shared wallet key copied to clipboard", "sharedWallets.addSharedWallet.getStarted.subTitle": "Choose an option to get started", "sharedWallets.addSharedWallet.getStarted.title": "Shared Wallets", "sharedWallets.addSharedWallet.layout.timelineStep.walletName": "Wallet name", @@ -43,8 +43,8 @@ "sharedWallets.addSharedWallet.addCosigners.nameInputError.required": "Name is required", "sharedWallets.addSharedWallet.addCosigners.nameInputError.duplicated": "Provided name is duplicated", "sharedWallets.addSharedWallet.addCosigners.nameInputError.tooLong": "Max. {{amount}} characters", - "sharedWallets.addSharedWallet.addCosigners.keysInputError.required": "Shared wallet key is required", - "sharedWallets.addSharedWallet.addCosigners.keysInputError.invalid": "Incorrect key format", + "sharedWallets.addSharedWallet.addCosigners.keyInputError.required": "Shared wallet key is required", + "sharedWallets.addSharedWallet.addCosigners.keyInputError.invalid": "Incorrect key format", "sharedWallets.addSharedWallet.importantInfo.title": "Important information about shared wallets", "sharedWallets.addSharedWallet.importantInfo.subtitle": "When a shared wallet is created its settings, including the keys of each co-signer, are no longer editable. Inputing of incorrect keys may prevent operation of the shared wallet and funds it receives may be unrecoverable.", "sharedWallets.addSharedWallet.importantInfo.checkBoxLabel": "I understand that upon creating the shared wallet I will be unable to change its configuration", @@ -67,19 +67,19 @@ "sharedWallets.addSharedWallet.import.error.unrecognized.exit": "Exit", "sharedWallets.addSharedWallet.import.error.unrecognized.retry": "Upload new file", "sharedWallets.addSharedWallet.import.error.incorrectWallet.title": "Incorrect active wallet", - "sharedWallets.addSharedWallet.import.error.incorrectWallet.description": "This shared wallet setup file does not reference shared wallet keys of your currently active wallet. Please ensure the correct personal wallet is active in Lace before attempting to add this shared wallet.", + "sharedWallets.addSharedWallet.import.error.incorrectWallet.description": "This shared wallet setup file does not reference shared wallet key of your currently active wallet. Please ensure the correct personal wallet is active in Lace before attempting to add this shared wallet.", "sharedWallets.addSharedWallet.import.error.incorrectWallet.exit": "Exit shared wallet setup", - "sharedWallets.addSharedWallet.keysGeneration.enterPassword.title": "Generate shared wallet keys", - "sharedWallets.addSharedWallet.keysGeneration.enterPassword.subtitle": "Enter your personal wallet password to generate shared wallet keys within this wallet.", - "sharedWallets.addSharedWallet.keysGeneration.enterPassword.nextButtonLabel": "Generate keys", - "sharedWallets.addSharedWallet.keysGeneration.enterPassword.activeWalletLabel": "Personal Wallet", - "sharedWallets.addSharedWallet.keysGeneration.enterPassword.passwordInputLabel": "Password", - "sharedWallets.addSharedWallet.keysGeneration.copyKeys.toastText": "Shared keys copied to clipboard", - "sharedWallets.addSharedWallet.keysGeneration.copyKeys.title": "Copy shared wallet keys", - "sharedWallets.addSharedWallet.keysGeneration.copyKeys.subtitle": "Copy and send these keys to someone setting up a new shared wallet. You can review these keys at any time.", - "sharedWallets.addSharedWallet.keysGeneration.copyKeys.backButtonLabel": "Copy keys to clipboard", - "sharedWallets.addSharedWallet.keysGeneration.copyKeys.nextButtonLabel": "Close", - "sharedWallets.addSharedWallet.keysGeneration.copyKeys.keysBoxTitle": "Shared Wallet Keys", + "sharedWallets.addSharedWallet.keyGeneration.enterPassword.title": "Generate shared wallet key", + "sharedWallets.addSharedWallet.keyGeneration.enterPassword.subtitle": "Enter your personal wallet password to generate shared wallet key within this wallet.", + "sharedWallets.addSharedWallet.keyGeneration.enterPassword.nextButtonLabel": "Generate key", + "sharedWallets.addSharedWallet.keyGeneration.enterPassword.activeWalletLabel": "Personal Wallet", + "sharedWallets.addSharedWallet.keyGeneration.enterPassword.passwordInputLabel": "Password", + "sharedWallets.addSharedWallet.keyGeneration.copyKeys.toastText": "Shared wallet key copied to clipboard", + "sharedWallets.addSharedWallet.keyGeneration.copyKeys.title": "Copy shared wallet key", + "sharedWallets.addSharedWallet.keyGeneration.copyKeys.subtitle": "Copy and send this key to someone setting up a new shared wallet. You can review this key at any time.", + "sharedWallets.addSharedWallet.keyGeneration.copyKeys.backButtonLabel": "Copy key to clipboard", + "sharedWallets.addSharedWallet.keyGeneration.copyKeys.nextButtonLabel": "Close", + "sharedWallets.addSharedWallet.keyGeneration.copyKeys.keyBoxTitle": "Shared Wallet Keys", "sharedWallets.transaction.cosignerList.title.signed": "Signed", "sharedWallets.transaction.cosignerList.title.unsigned": "Unsigned", "sharedWallets.transaction.cosignerList.signed": "Signed",