-
Notifications
You must be signed in to change notification settings - Fork 17
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: operations refactoring #2772
base: dev
Are you sure you want to change the base?
Conversation
# Conflicts: # src/renderer/features/wallet-select/model/__tests__/wallet-select-model.test.ts # src/renderer/features/wallets/WalletSelect/ui/WalletSelect.tsx # src/renderer/widgets/WalletDetails/model/__tests__/wallet-provider-model.test.ts
# Conflicts: # src/renderer/features/wallet-details/model/wc-details-model.ts
# Conflicts: # src/renderer/app/index.tsx
# Conflicts: # src/renderer/widgets/CreateWallet/ui/MultisigWallet/components/Signatory.tsx
# Conflicts: # src/renderer/features/proxy-remove-pure/model/remove-pure-proxy-model.ts # src/renderer/features/proxy-remove/model/remove-proxy-model.ts
…into feat/flexible-multisig
feat: add bond details feat: add wallet info from tx
Jest Unit tests resultsDuration: 45.738 seconds
Outcome: Passed | Total Tests: 750 | Passed: 746 | Failed: 0
|
}; | ||
|
||
export const operationDetailsSlot = createSlot<SlotProps>(); | ||
export const operationTitleSlot = createSlot<SlotProps>(); |
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 think slot should be defined in same file, where it's used in the first place
# Conflicts: # src/renderer/features/fellowship-members/components/MembersModal.tsx
# Conflicts: # src/renderer/widgets/AssetTransactionModal/ui/AssetTransactionModal.tsx
…et/omni-enterprise into feat/operations-refactoring
…et/omni-enterprise into feat/operations-refactoring
name: 'governance/operation-details', | ||
}); | ||
|
||
governanceOperationDetailFeature.inject(multisigOperationsFeature.slots.operationDetails, { |
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.
For simplicity you can separate injections by transaction type, one for each
blockCreated?: number, | ||
explorers?: Explorer[], | ||
): string | undefined => { | ||
if (!callHash || !indexCreated || !blockCreated || !explorers) return; |
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 function cannot execute if at least one argument is absent, looks pretty strange to me.
Let's check data existence before calling the function
signatories: Signatory[], | ||
chainId: ChainId, | ||
): Account[] => { | ||
const walletsMap = new Map(wallets.map((wallet) => [wallet.id, wallet])); |
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.
Could use dictionary
method instead
dictionary(wallets, 'id');
): Account[] => { | ||
const walletsMap = new Map(wallets.map((wallet) => [wallet.id, wallet])); | ||
|
||
return signatories.reduce((acc: Account[], signatory) => { |
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.
Let's stick to for_of
😌
operations?: MultisigTransaction[]; | ||
}; | ||
|
||
export const OperationList = memo(({ operations }: Props) => { |
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.
List will be a new reference every time, there cannot be any memoization
<TransactionTitle className="flex-1 overflow-hidden" tx={tx.transaction} /> | ||
|
||
{asset && amount && ( | ||
<div className="w-[160px]"> |
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.
<Box width="160px"
if (!transaction) { | ||
return ( | ||
<> | ||
<TransactionTitle className="flex-1 overflow-hidden" tx={transaction} /> | ||
|
||
<ChainTitle chainId={operation.chainId} className="w-[114px]" /> | ||
</> | ||
); | ||
} | ||
|
||
return null; |
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.
if (!transaction) { | |
return ( | |
<> | |
<TransactionTitle className="flex-1 overflow-hidden" tx={transaction} /> | |
<ChainTitle chainId={operation.chainId} className="w-[114px]" /> | |
</> | |
); | |
} | |
return null; | |
if (transaction) return null; | |
return ( | |
<> | |
<TransactionTitle className="flex-1 overflow-hidden" tx={transaction} /> | |
<ChainTitle chainId={operation.chainId} className="w-[114px]" /> | |
</> | |
); |
); | ||
} | ||
|
||
return <>{result.map((e) => e)}</>; |
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.
Any point to use array with a single element?
const sender = operationDetailsUtils.getSender(operation); | ||
const destinationChain = operationDetailsUtils.getDestinationChain(operation); |
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.
Let's move these line up to const destination
for better group composition
@@ -70,7 +77,7 @@ export const OperationFullInfo = ({ tx, account }: Props) => { | |||
)} | |||
</div> | |||
|
|||
<OperationCardDetails tx={tx} account={account} extendedChain={extendedChain} /> | |||
<div className="flex w-full flex-col gap-y-1">{operationDetails}</div> |
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.
Looks great!
|
||
export const registerFeatures = (features: Feature<unknown>[]) => { | ||
// Basically groupBy | ||
const domains = features.reduce<Record<string, Feature<unknown>[]>>((acc, feature) => { |
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.
Suggest to use for_of
|
||
const delegationTarget = operationDetailsUtils.getDelegationTarget(operation); | ||
const delegationTracks = operationDetailsUtils.getDelegationTracks(operation); | ||
const delegationVotes = operationDetailsUtils.getDelegationVotes(operation); |
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 think we can keep it as is for now, but main idea is to fully decouple views and logic, so parsing of particular transaction info should be bounded to related context (domain or feature). In this case parsing of delegation details should be somewhere in governance services, not in operations utils.
Add TODO
please!
feat: add transfer details
feat: add bond details
feat: add wallet info from tx