Skip to content

Orion v2 crt mappings#99

Closed
dobertRowneySr wants to merge 111 commits intoJoystream:masterfrom
dobertRowneySr:orion-v2_crt_mappings_with_metadata
Closed

Orion v2 crt mappings#99
dobertRowneySr wants to merge 111 commits intoJoystream:masterfrom
dobertRowneySr:orion-v2_crt_mappings_with_metadata

Conversation

@dobertRowneySr
Copy link
Copy Markdown
Collaborator

@dobertRowneySr dobertRowneySr commented Mar 30, 2023

Goal

Adds schema and mappings (handlers) for CRT extrinsic in orion v2.

Info

  • All code in src/mappings/token/index.ts has been pretty much tested via integration test except for:
    • metadata processing
    • processJoinWhitelistEvent
  • metadata is not yet supported in the current crt_release branch but there is plan for it (as the figma design documents prescribes it)
  • multiple event versions have been generated using an joystream.jsonl archive. Due to the different runtime spec versions since mainnet. How to do this is explained in Update developer-guide.md Lezek123/orion#2

References for this PR

@dobertRowneySr dobertRowneySr changed the title Orion v2 crt mappings with metadata Orion v2 crt mappings May 31, 2023
@dobertRowneySr dobertRowneySr force-pushed the orion-v2_crt_mappings_with_metadata branch from de33cf5 to 36f83fa Compare May 31, 2023 10:29
@dobertRowneySr dobertRowneySr requested a review from Lezek123 May 31, 2023 10:42
@dobertRowneySr dobertRowneySr marked this pull request as ready for review May 31, 2023 10:44
Copy link
Copy Markdown

@Lezek123 Lezek123 left a comment

Choose a reason for hiding this comment

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

  1. Update from master is needed
  2. db/migrations/2000000000000-Views.js should be adjusted (see the related tutorial at: https://github.com/Lezek123/orion/blob/user-accounts/docs/developer-guide/tutorials/entity-visibility.md), mainly:
    • All new entities related to excluded channels should be hidden, ie.:
      // db/migrations/2000000000000-Views.js
      // ...
          nft_activity: [`EXISTS(SELECT 1 FROM "event" WHERE "id"="event_id")`],
          token: [`EXISTS(SELECT 1 FROM "channel" WHERE "id"="channel_id")`],
          revenue_share: [`EXISTS(SELECT 1 FROM "token" WHERE "id"="token_id")`],
          benefit: [`EXISTS(SELECT 1 FROM "token" WHERE "id"="token_id")`],
          // ...and so on, there should basically be an entry for each new entity
      // ...
    • To avoid a situation in which a video which is set as Token.trailerVideo and then excluded causes errors (because in this case the video won't exist in the public schema so querying Token.trailerVideo will throw an error) you should either create a view which overrides this field (Token.trailerVideo) to NULL if the video doesn't exist (is excluded) or introduce a new entity like TrailerVideo such that TailerVideo has 1-to-1 relationship with video and token. You would be able to more easily exclude it in this case, ie.:
      // db/migrations/2000000000000-Views.js
      // ...
          trailer_video: [
              `EXISTS(SELECT 1 FROM "token" WHERE "id"="token_id")`,
              `EXISTS(SELECT 1 FROM "video" WHERE "id="video_id")`
          ],
      // ...
  3. It's difficult to retrieve the current sale associated with a given token, because Token.sale is a list of all sales. I suggest adding a field like Token.currentSale (or make Token.status an union with TokenStatusSale variant that would point to the current one). The same is true for AMMs and revenue splits.
  4. Token should have a field like lastTransactionPrice, because in many places in the current designs there is a JOY value associated with each token.
    Actually this value can easily be manipulated if the issuer creates a sale and just buys from themselves, so perhaps the designs should be adjusted instead (?) CC: @bedeho
  5. A query is needed that returns total portfolio value of a given member:
    • Liquid tokens value: aggregation like SUM(tokenAccount.transferrableAmount * token.lastTransactionPrice) for all owned tokens
    • Total tokens value: aggregation like SUM(tokenAccount.totalAmount * token.lastTransactionPrice) for all owned tokens
  6. A query / field is needed that returns total transaction volume of a given token:
    • SUM(sale.tokensSold * sale.unitPrice) for all token's sales + SUM(ammTransaction.pricePaid) for all token's amm transactions.
      Actually I'm not sure if this stat is worth displaying on the token page, since it can be very easily manipulated CC @bedeho
  7. AmmCurve should have termsAndConditions (same as Sale) according to the designs
  8. Notifications: New events need to be introduced in schema/events.graphql to facilitate new kinds of notifications:
    • Token holder notifications:
      • Upcoming revenue split
      • Revenue split started
      • Revenue split ended
      • AMM started
      • Sale started
    • Channel follower notifications:
      • Token issued
      • Token sale initialized
    • Token issuer:
      • Sale eneded
      • Someone bought tokens on sale
      • Someone bought / sold tokens on AMM
      • Rev. Split has ended
        The exact schema for those notifications should probably be discussed with the Atlas team (CC: @attemka @drillprop @WRadoslaw)

status: TokenStatus!

"avatar object (profile picture)"
avatar: TokenAvatar
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When I was reviewing the designs I was under the impression that tokens don't have their own avatars, instead the channel avatar is simultaneously a token avatar. Is this correct @KubaMikolajczyk ?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Still not entirely clear whether this field is needed. Probably worth asking @KubaMikolajczyk

Comment on lines +44 to +45
"revenue share ratio between creator and holder"
revenueShareRatioPercent: Int!
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

  1. The unit is permill (1 / 1000000), not percent (1 / 100)
  2. This field seems to be duplicated by channel.revenueShareRatioPercent

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The field is still called Percent while it's actuall Permill

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This file should be ignored as well

Lezek123

This comment was marked as duplicate.

@dobertRowneySr dobertRowneySr changed the base branch from orion-v2 to master June 12, 2023 13:42
@dobertRowneySr dobertRowneySr requested a review from Lezek123 June 12, 2023 14:21
Copy link
Copy Markdown

@Lezek123 Lezek123 left a comment

Choose a reason for hiding this comment

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

Besides the issues pointed out in the new comments, there are still some unresolved points from the list provided as part of the 1st review (ie. #99 (review)), like points 4. - 9. (although I realize some of them require external input)

deissued: Boolean!
}

type TokenChannel @entity @index(fields: ["token", "channel"], unique: true) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ok, but I think you now accidently removed creatorToken: TokenChannel @derivedFrom(field: "channel") field from the Channel entity

totalSupply: BigInt!

"sales issued for this token"
sale: [Sale!] @derivedFrom(field: "token")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I suggest renaming it to sales for better clarity

revenueShareRatioPercent: Int!

"revenue shares issued for this token"
revenueShare: [RevenueShare!] @derivedFrom(field: "token")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I suggest renaming it to revenueShares for better clarity

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

File accidently brought back?


- `make typegen` - generates event types (`src/types`) based on `typegen.json` (the archive endpoint provided in `specVersions` must be pointing to a running archive)
- `make codegen` - generates TypeORM models based on the [input schema](#input-schema)
- `make codegen` - granetes TypeORM models based on the [input schema](#input-schema)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Typo accidently re-introduced

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

File accidently re-introduced?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

File accidently re-introduced?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

File accidently re-introduced?

Ignazio Bovo and others added 24 commits September 5, 2023 14:28
this is required so we can simply make trailer video hidden if video is hidden
I have replaced the vesting schedule back to the original schema with:
- VestingSchedule: holding vesting schedule information such being amount agnostic
- VestedAccount: contains information regarded to a vested account, the goal is to mimic the
runtime logic
Co-authored-by: Leszek Wiesner <leszek@jsgenesis.com>
Co-authored-by: Leszek Wiesner <leszek@jsgenesis.com>
@dobertRowneySr dobertRowneySr force-pushed the orion-v2_crt_mappings_with_metadata branch from 2cc77fb to 175cb88 Compare September 5, 2023 17:43
This was referenced Sep 13, 2023
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