-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add StepperFactory and new tx layout #2040
Conversation
Branch preview✅ Deploy successful! |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
import TokenTransferFlow from '@/components/TxFlow/TokenTransfer/TokenTransferFlow' | ||
import RejectTx from '@/components/TxFlow/RejectTx' | ||
import NewTxMenu from '@/components/TxFlow/NewTx' | ||
import ReplaceTxMenu from '@/components/TxFlow/ReplaceTx' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part can be extracted into another module. Which could be imported and inserted here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a new file and exported all components from there. Is this what you have envisioned?
export enum ModalType { | ||
SendTokens = 'sendTokens', | ||
RejectTx = 'rejectTx', | ||
ReplaceTx = 'replaceTx', | ||
NewTx = 'newTx', | ||
} | ||
|
||
const ModalTypes = { | ||
[ModalType.SendTokens]: TokenTransferFlow, | ||
[ModalType.RejectTx]: RejectTx, | ||
[ModalType.ReplaceTx]: ReplaceTxMenu, | ||
[ModalType.NewTx]: NewTxMenu, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just realized it's probably easier to just let modal-opening buttons pass TokenTransferFlow
directly instead of a string. That would make the dependency explicit.
So instead of
onClick={() => setVisibleModal({ type: ModalType.SendTokens, props: {} })}
they would do
onClick={() => setVisibleModal(<TokenTransferFlow nonce={nonce} />)}
Not 100% convinced tho.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation we opted for aimed to narrow the possible components we want to show in the modal. It comes at the cost of maintaining the map but setting a component in the dispatcher would make harder to reinforce the types.
We are also not sold on storing the component as state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can still limit the type of components setVisibleModal accepts.
Something like T extends TxFlowComponent
, so that it accepts any component whose signature satisfies TxFlowComponent.
type: SendTxType.multiSig, | ||
} | ||
|
||
const TokenTransferFlow = ({ txNonce }: { txNonce?: number }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming is a bit inconsistent, this is the only transaction type named with "Flow" at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were also thinking of naming RejectTx
to RejectTxFlow
but it only has one step and we didn't use the Stepper there so we left it as RejectTx
.
What it solves
Part of #2021
How this PR fixes it
ModalProvider
for orchestrating modals in the appTxFlow
NewTxMenu
,ReplaceTxMenu
,RejectTx
,TokenTransfer
to the providerTxLayout
componentStepperFactory
and uses it forTokenTransferFlow
ToDos
How to test it
New Transaction
in the sidebarNewTxMenu
opening as a fullscreen modalSend Tokens
TokenTransferFlow
opening as a fullscreen modal/queue
ReplaceTxMenu
opening as a fullscreen modalSend Tokens
orReject Transaction
TokenTransferFlow
orRejectTx
opening as a fullscreen modalScreenshots
Checklist