Skip to content

Conversation

@Lezek123
Copy link
Contributor

@Lezek123 Lezek123 commented Aug 28, 2020

This PR contains all Pioneer upgrade changes after the joy-members package upgrade (#1156).

Covered issues:

joy-election (from 5d4a194 to 9fadcaf)

  • Continued joy-utils reactivation and upgrading - added transport provider for all packages that use the api (currently just members transport)
  • Reactivated joy-election and did all the necessary adjustments.
  • Fixed some UI issues with actions beeing displayed even though not available in given stage (ie. Applying form, Voting form, Reveal Vote buttons)
  • Added a few more adjustments to polkadot-js/apps core packages (ie. allowing council election stage as sidebar tab subtitle, just like before)
  • Fixed linter issues accoring to the new rules

joy-proposals (from f7d87da to e19eb61 + 673855f)

  • Reactivating more of joy-utils - all transports inside joy-utils should now be compatible with the new runtime and api
  • Reactivated joy-proposals
  • Refactored joy-proposals to be typesafe (new linter rules are very strict when it comes to the use of any type, but this is good, since we can usually avoid that now that @joystream/types have been refactored)
  • Adjusted some components like our custom TxButton to allow them to be used in more customizable way (introduced SemanticTxButton and DefaultTxButton) since they lost(?) some of the customizability due to changes in @polkadot/react-components
  • Fixed linter issues accoring to the new rules

joy-roles (from 17933d4 to a9e4448)

  • Moved some more code into the new joy-utils
  • Reactivated joy-roles
  • All the necessary adjustments (creating types, replaced linked maps usages in the transports etc.)
  • Did some refactorization of the components structure inside joy-utils to avoid unnecessary re-renders that could lead to loss of data in the forms, problems when resizing the page and generally poor UX and optimalization. The main issue was that custom "render functions" were used in a few places instead of standard React components. When those functions were called after some state update - everything that they previously rendered was getting re-rendered from scratch and all the previous state in child components was lost.
  • Fixed lots of linter issues (mostly regarding the abuse of any type)
  • Some minor adjustments to linter rules
  • Some minor tooling adjustments (made jest available again which allows running yarn workspace @polkadot/joy-roles test, added generate:json-schemas scripting in @joystream/types to allow updating hiring/schemas/role.schema.json, configured webapck to handle .scss files, added back tsconfig-paths-webpack-plugin to allow running storybook in the future)

joy-media (from 03bd123 to 83a225c)

  • Reactivated joy-media
  • Added back some missing utils to the new joy-utils (ie. withCurationActor which I also had to upgrade to work with the new runtime)
  • All the necessary adjustments in joy-media (creating types, linked maps usages in the transports etc.)
  • FIX: problems with instanceof due to mismatching versions of bn.js in the monorepo (fixed by adding to resolutions)
  • FIX: problems with instanceof due to api.createType('ChannelId', 1) (and some other ids) returning u64 (which caused instanceof ChannelId to return false in those cases)
  • Minor UI improvements (ie. displaying a loader while upload video extrinsic is waiting for the confirmation)
  • Fixed linter issues according to the new rules

joy-forum (from ad0377e to 5ce833f)

  • Reactivated joy-forum + implemented the necessary adjustments
  • Added last missing pieces to the new joy-utils
  • Extended member preview components in joy-utils (ie. allowing to specify the size, displaying council badge etc.) to prevent imports between joy-members and joy-forum.
  • Minor styling changes
  • Linter fixes

Remaining commits (after 5ce833f)

  • Fixed storybook (not all of the components are working, which was already a problem before the upgrade, but now it's at least possible to succesfully run yarn workspace pioneer storybook again)
  • Re-introduced a component to update the account memo (MemoForm) which was previously part of app-accounts
  • Finalized the process of joy-utils migration
  • Removed the no longer necessary direcotires (old-apps, joy-utils-old)
  • Minor styling fixes
  • Minor apps configuration fixes (default ui mode, removed unnecessary endpoints etc.)
  • FIX: Fixed the problem with RuntimePropsal details by changing the type from Vec<u8> to Bytes (which works the same way, but doesn't have the 32768 length limit)

@Lezek123 Lezek123 marked this pull request as ready for review September 2, 2020 06:39
@mnaamani
Copy link
Member

mnaamani commented Sep 2, 2020

There is a minor merge conflict in yarn.lock after merging #1189

).map((x) => x.id);

const isPublicAndNotCurated = (video: VideoType) => {
const isPublic = video.publicationStatus.id === idOfPublicPS;
Copy link
Member

Choose a reason for hiding this comment

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

I populated the content directory with some content and I'm seeing this error:

Screen Shot 2020-09-02 at 10 10 18 AM

Copy link
Member

Choose a reason for hiding this comment

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

For context, while exporting state from current chain, some items were dropped and their property values were dropped. This could explain this error for some particular videos: https://github.com/Joystream/joystream-api-examples/pull/12/files#diff-6d0009198c779316ce8a37be5c378e3cR118

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps the media transport needs some improvement to determine when the property values don't exist and just exclude it from the array (similarly to where we did this check entity.in_class_schema_indexes.toArray().length)

@Lezek123
Copy link
Contributor Author

Lezek123 commented Sep 2, 2020

Changed the implementation of allChannelIds, allClassIds and allEntityIds to use .keys() instead of returing all ids between first and last id, which should allow us to safely skip some entities during the export.

@Lezek123
Copy link
Contributor Author

Lezek123 commented Sep 2, 2020

Fixed RuntimeUpgrade and Text proposal validation to make use of exposed runtime consts instead of using validationSchema.js hardcoded values (in preparation for coming #1216 fix)

@mnaamani
Copy link
Member

mnaamani commented Sep 2, 2020

Just some feedback so far, as I'm still going through the PR:

  • Suggestion to change react-api/src/typeRegistry.ts to use registry created in @joystream/types
import { mockRegistry } from '@joystream/types';
export default mockRegistry;

Reason: In some components we grab the {createMock} from joystream/types and in other places we use api.createType
So this will at least ensure the same instance of the registry is used in both those instances.

  • Suggested renaming in @joystream/types/src/index

rename createMock to createType, and mockRegistry to registry

The term "Mock" in the name is misleading but the approach is perfectly reasonable, and that is in fact how react-api initializes the Api and types registry.

  • Drop the EditForumSudo component in the forum app (which we don’t render anyway)
    Reason: It was never implemented correctly. Only the system sudo account via the sudo module can set the new forum sudo. This can be easily done in the sudo app.

I tested media app again with dropped entities work nicely and I was able to navigate and play content.
Uploaded a new media file to my channel, but after media upload, the form to fill details has a field Explicit.

  • Explicit field should be treated as boolean but displays as a string input field. Was expecting a drop-down with true, false options.

Screen Shot 2020-09-02 at 6 20 27 PM

return {
Component: Media,
display: {
needsApi: ['query.storageWorkingGroup.workerById', 'query.dataObjectStorageRegistry.relationshipsByContentId']
Copy link
Member

Choose a reason for hiding this comment

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

media does need a few additional apis from other modules, should we be more comprehensive? I suppose this applies to other joy-* apps as well.

Copy link
Contributor Author

@Lezek123 Lezek123 Sep 3, 2020

Choose a reason for hiding this comment

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

Those are not very strict even in the original polkadot-js/apps I think.
The needsApi itself is required as it affects how components are rendered by apps/src/Content/index.tsx, but including all the methods that are actually used by given module would be hard to maintain.
It makes sense only if there are multiple chains user can connect to, which have different runtime modules.

} else {
this.setState({ file, computingHash: true });
this.startComputingHash();
void this.startComputingHash();
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the presence of this void here? Is it to drop or ignore the return value of the call ?

Copy link
Contributor Author

@Lezek123 Lezek123 Sep 2, 2020

Choose a reason for hiding this comment

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

This is a way to mark a promise which we intentionally don't await. It's required by the new no-floating-promises rule (see: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-floating-promises.md#ignorevoid)

I think it's a good rule, because it prevents omitting await by accident. Marking with void also gives a a nice hint that the function/method we execute is async.

return;
}

const activeProviders = (await transport.workingGroups.allWorkers('Storage')).map(([id]) => id);
Copy link
Member

Choose a reason for hiding this comment

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

In this implementation we need to filter out the Storage Group Lead id, so we get only the storage providers.

Copy link
Member

Choose a reason for hiding this comment

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

After raising this in chat, we can ignore this comment.

ref: #1211

);

for (const groupOpening of groupOpenings.linked_values) {
for (const [/* id */, groupOpening] of groupOpenings) {
Copy link
Member

Choose a reason for hiding this comment

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

If we don't need the key (id), which we get from value.hiring_opening_id.id, perhaps better to get .values() from map only instead of .entries(). Its a minor point, but it would give a cleaner Destructuring assignment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dind't notice .values() method to be available. We could write an implementation similar to entiresByIds, but it would actually do the same thing (execute entiresByIds and then throw away ids), since we still need ids to sort the entries (by default they are returned in unpredictable order)

requiredApplicationStake: stakes.application,
requiredRoleStake: stakes.role,
defactoMinimumStake: new u128(0)
defactoMinimumStake: this.api.createType('u128', 0)
Copy link
Member

Choose a reason for hiding this comment

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

Balance instead of u128 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 728bb4c

@Lezek123
Copy link
Contributor Author

Lezek123 commented Sep 3, 2020

Suggestion to change react-api/src/typeRegistry.ts to use registry created in @joystream/types

Done in 7edff5e

rename createMock to createType, and mockRegistry to registry

Done in 1d7d84d

@Lezek123
Copy link
Contributor Author

Lezek123 commented Sep 3, 2020

Explicit field should be treated as boolean but displays as a string input field. Was expecting a drop-down with true, false options.

This was an issue before the upgrade too, but fixed it now in 8b2b484

Drop the EditForumSudo component in the forum app (which we don’t render anyway)

Done in c8f2d1f

@Lezek123 Lezek123 requested a review from mnaamani September 3, 2020 11:48
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.

2 participants