novasamatech / nova-spektr

Nova Spektr — All-in-one Polkadot desktop wallet supporting multisigs, staking, light clients, and more
https://novaspektr.io
Apache License 2.0
40 stars 16 forks source link

Operations. Split CallDecoder and details view to core and feature-specific modules. #2659

Open johnthecat opened 1 week ago

johnthecat commented 1 week ago

Operations page became bloated with different operation types handling and specific code for each of them. Our new approach address this problem by decoupling core logic (unwrapping batch and proxy) and render of feature-specific details about extrinsic. Main idea is to create DI slot for injecting details and pass unwrapped extrinsic as prop. Image DI handler in every feature should check if it's known extrinsic and if yes - render details. Pseudo-code:

governanceMultisigFeature.inject(operationDetailsSlot, ({ extrinsic }) => {
  if (!knownExtrinsic(extrinsic)) {
    return null;
  }
  const decodedData = decode(extrinsic);

  return (
    <DetailsRow label="Referendum">{decodedData.referendumId}</DetailsRow>
  );
});

Same way we should inject operation name, operation icon and details on confirm screen.

After this changes, operations page should become yet-another-feature with self contained logic. When new operation type appear, feature related to it should inject handlers and it should be enough.