Skip to content
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

Open
wants to merge 56 commits into
base: dev
Choose a base branch
from
Open

Feat: operations refactoring #2772

wants to merge 56 commits into from

Conversation

Asmadek
Copy link
Contributor

@Asmadek Asmadek commented Dec 4, 2024

feat: add transfer details
feat: add bond details
feat: add wallet info from tx

johnthecat and others added 30 commits November 6, 2024 15:50
# 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
Copy link
Contributor

github-actions bot commented Dec 4, 2024

Jest Unit tests results

Generic badge

Duration: 45.738 seconds
Start: 2024-12-09 10:00:32.564 UTC
Finish: 2024-12-09 10:01:18.302 UTC
Duration: 45.738 seconds
Outcome: Passed | Total Tests: 750 | Passed: 746 | Failed: 0
Total Test Suites: 156
Total Tests: 750
Failed Test Suites: 0
Failed Tests: 0
Passed Test Suites: 155
Passed Tests: 746
Pending Test Suites: 1
Pending Tests: 4

};

export const operationDetailsSlot = createSlot<SlotProps>();
export const operationTitleSlot = createSlot<SlotProps>();
Copy link
Contributor

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

@Asmadek Asmadek changed the title Feat: operations refactoring [part 1] Feat: operations refactoring Dec 9, 2024
@Asmadek Asmadek marked this pull request as ready for review December 9, 2024 10:00
@johnthecat johnthecat self-requested a review December 9, 2024 10:56
name: 'governance/operation-details',
});

governanceOperationDetailFeature.inject(multisigOperationsFeature.slots.operationDetails, {
Copy link
Contributor

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;
Copy link
Contributor

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]));
Copy link
Contributor

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) => {
Copy link
Contributor

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) => {
Copy link
Contributor

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]">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<Box width="160px"

Comment on lines +92 to +102
if (!transaction) {
return (
<>
<TransactionTitle className="flex-1 overflow-hidden" tx={transaction} />

<ChainTitle chainId={operation.chainId} className="w-[114px]" />
</>
);
}

return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)}</>;
Copy link
Contributor

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?

Comment on lines +36 to +37
const sender = operationDetailsUtils.getSender(operation);
const destinationChain = operationDetailsUtils.getDestinationChain(operation);
Copy link
Contributor

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>
Copy link
Contributor

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) => {
Copy link
Contributor

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);
Copy link
Contributor

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!

Base automatically changed from feat/flexible-multisig to dev December 17, 2024 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants