Skip to content

Commit

Permalink
fix: can't create new mutisig if hidden exists (#2713)
Browse files Browse the repository at this point in the history
* fix: can't create new mutisig if hidden exists

* fix: wallet select
  • Loading branch information
sokolova-an authored Nov 22, 2024
1 parent 856db7a commit 6add1b6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ sample({
target: walletModel.events.selectWallet,
});

sample({
clock: walletModel.events.walletRestoredSuccess,
fn: ({ result }) => result.id,
target: walletModel.events.selectWallet,
});

sample({
clock: walletModel.events.selectWallet,
source: walletModel.$activeWallet,
Expand Down
19 changes: 1 addition & 18 deletions src/renderer/widgets/CreateWallet/model/flow-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { networkModel, networkUtils } from '@/entities/network';
import { transactionService } from '@/entities/transaction';
import { accountUtils, walletModel, walletUtils } from '@/entities/wallet';
import { signModel } from '@/features/operations/OperationSign/model/sign-model';
import { ExtrinsicResult, submitModel, submitUtils } from '@/features/operations/OperationSubmit';
import { submitModel, submitUtils } from '@/features/operations/OperationSubmit';
import { type AddMultisigStore, type FormSubmitEvent, Step } from '../lib/types';

import { confirmModel } from './confirm-model';
Expand Down Expand Up @@ -386,23 +386,6 @@ sample({
}),
});

sample({
clock: submitModel.output.formSubmitted,
source: {
step: $step,
hiddenMultisig: formModel.$hiddenMultisig,
},
filter: ({ step, hiddenMultisig }, results) => {
const isSubmitStep = isStep(step, Step.SUBMIT);
const isNonNullable = nonNullable(hiddenMultisig);
const isSuccessResult = results[0]?.result === ExtrinsicResult.SUCCESS;

return isSubmitStep && isNonNullable && isSuccessResult;
},
fn: ({ hiddenMultisig }) => hiddenMultisig!.id,
target: walletModel.events.walletRemoved,
});

sample({
clock: delay(submitModel.output.formSubmitted, 2000),
source: $step,
Expand Down
11 changes: 2 additions & 9 deletions src/renderer/widgets/CreateWallet/model/form-model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { combine, createEvent, sample } from 'effector';
import { combine, sample } from 'effector';
import { createForm } from 'effector-forms';

import { type Chain, type ChainId, CryptoType, type Wallet } from '@/shared/core';
import { type Chain, type ChainId, CryptoType } from '@/shared/core';
import { nonNullable, toAccountId } from '@/shared/lib/utils';
import { networkModel, networkUtils } from '@/entities/network';
import { accountUtils, walletModel, walletUtils } from '@/entities/wallet';
Expand All @@ -11,8 +11,6 @@ import { signatoryModel } from './signatory-model';

const DEFAULT_CHAIN: ChainId = '0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3'; // Polkadot

const restoreWallet = createEvent<Wallet>();

const $createMultisigForm = createForm<FormParams>({
fields: {
threshold: {
Expand Down Expand Up @@ -139,11 +137,6 @@ sample({
target: $createMultisigForm.fields.threshold.reset,
});

sample({
clock: restoreWallet,
target: walletModel.events.walletRestored,
});

export const formModel = {
$chain,
$createMultisigForm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export const SelectSignatoriesThreshold = () => {
!hasEmptySignatories &&
!hasEmptySignatoryName &&
isThresholdValid &&
!hasDuplicateSignatories;
!hasDuplicateSignatories &&
!hiddenMultisig;

const onSubmit = (event: FormEvent) => {
if (!hasClickedNext) {
Expand Down Expand Up @@ -160,9 +161,9 @@ export const SelectSignatoriesThreshold = () => {
</Alert>

<Alert
active={!multisigAlreadyExists && Boolean(hiddenMultisig)}
active={nonNullable(hiddenMultisig)}
title={t('createMultisigAccount.multisigExistTitle')}
variant="info"
variant="error"
>
<Alert.Item withDot={false}>{t('createMultisigAccount.multisigHiddenExistText')}</Alert.Item>
<Alert.Item withDot={false}>
Expand Down

0 comments on commit 6add1b6

Please sign in to comment.