Skip to content

Commit

Permalink
fix: set flow, improve comment + remove caching
Browse files Browse the repository at this point in the history
  • Loading branch information
iamacook committed Nov 23, 2023
1 parent 338d61e commit 09cad6f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/components/settings/Recovery/DelayModifierRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import DeleteIcon from '@/public/images/common/delete.svg'
import EditIcon from '@/public/images/common/edit.svg'
import CheckWallet from '@/components/common/CheckWallet'
import { ConfirmRemoveRecoveryModal } from './ConfirmRemoveRecoveryModal'
import { UpsertRecoveryFlow } from '@/components/tx-flow/flows/UpsertRecovery'
import type { RecoveryState } from '@/store/recoverySlice'

export function DelayModifierRow({ delayModifier }: { delayModifier: RecoveryState[number] }): ReactElement | null {
Expand All @@ -20,8 +21,7 @@ export function DelayModifierRow({ delayModifier }: { delayModifier: RecoverySta
}

const onEdit = () => {
// TODO: Display flow
setTxFlow(undefined)
setTxFlow(<UpsertRecoveryFlow delayModifier={delayModifier} />)
}

const onDelete = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings/Recovery/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const headCells = [
{ id: HeadCells.Actions, label: '', sticky: true },
]

// TODO: Migrate section
// TODO: Combine section with spending limits under "Security & Login" as per design
export function Recovery(): ReactElement {
const { setTxFlow } = useContext(TxModalContext)
const recovery = useAppSelector(selectRecovery)
Expand Down
10 changes: 5 additions & 5 deletions src/components/tx-flow/flows/UpsertRecovery/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ export type UpsertRecoveryFlowProps = {
[UpsertRecoveryFlowFields.emailAddress]: string
}

export function UpsertRecoveryFlow({ recovery }: { recovery?: RecoveryState[number] }): ReactElement {
export function UpsertRecoveryFlow({ delayModifier }: { delayModifier?: RecoveryState[number] }): ReactElement {
const { data, step, nextStep, prevStep } = useTxStepper<UpsertRecoveryFlowProps>({
[UpsertRecoveryFlowFields.guardian]: recovery?.guardians?.[0] ?? '',
[UpsertRecoveryFlowFields.txCooldown]: recovery?.txCooldown?.toString() ?? `${DAY_IN_SECONDS * 28}`, // 28 days in seconds
[UpsertRecoveryFlowFields.txExpiration]: recovery?.txExpiration?.toString() ?? '0',
[UpsertRecoveryFlowFields.guardian]: delayModifier?.guardians?.[0] ?? '',
[UpsertRecoveryFlowFields.txCooldown]: delayModifier?.txCooldown?.toString() ?? `${DAY_IN_SECONDS * 28}`, // 28 days in seconds
[UpsertRecoveryFlowFields.txExpiration]: delayModifier?.txExpiration?.toString() ?? '0',
[UpsertRecoveryFlowFields.emailAddress]: '',
})

const steps = [
<UpsertRecoveryFlowIntro key={0} onSubmit={() => nextStep(data)} />,
<UpsertRecoveryFlowSettings key={1} params={data} onSubmit={(formData) => nextStep({ ...data, ...formData })} />,
<UpsertRecoveryFlowReview key={2} params={data} moduleAddress={recovery?.address} />,
<UpsertRecoveryFlowReview key={2} params={data} moduleAddress={delayModifier?.address} />,
]

const isIntro = step === 0
Expand Down
3 changes: 1 addition & 2 deletions src/services/recovery/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ export async function _getEditRecoveryTransactions({
const enableModule = delayModifierContract.interface.encodeFunctionData('enableModule', [guardianToAdd])
txData.push(enableModule)

// Add guardian to cache
_guardians.push(guardianToAdd)
// Need not add guardian to cache as not relevant for prevModule
}

for (const guardianToRemove of guardiansToRemove) {
Expand Down

0 comments on commit 09cad6f

Please sign in to comment.