Skip to content

Commit

Permalink
🦿 CRT marketplace changes (#285)
Browse files Browse the repository at this point in the history
* Add new field and index to creator token

* Add mutation to feature crts

* Schema typo fix

* Add is short field to video entity (#301)

* add isShort field to video entity

* regenerate db migrations

* remove @joystream/metadata-protobuf patch from assets/patches

* fix lint issue

* Disable both in Appp and eail notifications for video posted events (#299)

* bump package version and update CHANGELOG (#302)

* bump package version and update CHANGELOG

* change release version

* Simple public homefeed query and mutation (#304)

* update graphql schema

* add partial index on 'video.include_in_home_feed' field

* update video view definition to only include public videos

* regenerate migrations

* add dumbPublicFeedVideos custom query

* add setPublicFeedVideos mutation

* fix lint issue

* add arg to skip video IDs

* revert: update video view definition to only include public videos

* add feat. to unset public feed videos

* address requested change

* bump package version and update CHANGELOG

* Update `nara` from `master` (#300)

* Adds mappings for `ChannelAssetsDeletedByModerator` & `VideoAssetsDeletedByModerator` events (#199)

* mark 'VideoDeletedByModerator' & 'ChannelDeletedByModerator' events deprecated

* Implements mappings for 'Content.VideoAssetsDeletedByModerator and 'Content.ChannelAssetsDeletedByModerator' runtime events

* remove unused import

* Nara/crt update (#244)

* feat: build orion

* feat: start generating schema

* fix: extra entities

* fixup!

* fix: continue implementing design specs

* fix: review and fix foreign key relationships

* fix: formatting

* fix: generation errors

* fix: add comment

* fix: relations

* fix: final review

* fixup!

* fix: add ending blocks

* fix: generate type & set typegen to ipv4

* fix: add support for event backward compatibility

* feat: start adding mappings

* fix: continue with mappnigs

* feat: init sale

* feat: patronage decreased to & fixed build

* feat: claim patronage event

* feat: tokens bought on amm

* feat: tokens sold on amm

* fix: add relation between sales and vesting schedules

* feat: add Tokens sold on sale vente

* feat: update upcoming sale

* feat: revenue share issued

* feat: member joined whitelist

* feat: amm deactivated

* feat: burned token

* feat: transfer policy changed to permissionless

* feat: sale finalized

* feat: finish mappings

* fix: review

* fix: remove cascade deletions

* fix: renaming & formatting

* fixup!

* fixup!

* fix: patched protobuf packages with token proto

* feat: update metadata and add event handler scheleton

* feat: token metadata

* feat: sale metadata

* fix: review comments

* fix: formatting

* fix: revenue

* Revert "fix: revenue"

This reverts commit 0821abe.

* fix: token status after sale

* fix: fixmes

* fix: formatting

* fix: funds accounting during sale

* fix: amount accounting

* fix: linter

* fix: review

* fix: review 2

* fix: review

* fix: linter

* feat: migration for new db scheam

* fix: update event versions

* fix: patch types with crt_release types

* fix: patch types

* fix: generate all events versions since mainnet

* fix: temp fix after event version generation

* fix: event versioning

* fix: add migration

* fix: mignations

* fix: solve channel not being added

* fix: add id to TokenChannel

* fix: non-nullable deleted field set

* fix: format

* feat: creator token init sale re enabling

* feat: re enable sale init code

* fix: update types

* fix: amm id

* fix: id computation for revenue share

* fix: amm id computation for token

* fix: issuer transfer accounting

* fix: amm tx id

* fix: destination accounting

* feat: minor fix on holder transfer processing

* fix: re-enable metadata

* fix: metadata parsing

* fix: post reword cleanup

* fix: format

* fix: silence ci checks

* fix: event version

* fix: address PR changes

I edited all the entity that have a composite index like TokenAccount so that they have
a synthetic ID and an optionally unique @index

* fix: add hidden entities conditions

* fix: add extra fields to token in order to keep track of ongoing status

* fix: build errors

* fix: adapt mapping to new token fields

* fix: format

* feat: add trailer video entity

this is required so we can simply make trailer video hidden if video is hidden

* fix: linter

* chore: prettier

* fix: from PR review

* fix: vesting schedule schema & mappings

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

* fix: burning from vesting

* patch: metadata-protobuf package

* patch: metadata-protobuf package

* fix: generate migrations

* fix: purchase token on sale

* Update schema/token.graphql

Co-authored-by: Leszek Wiesner <leszek@jsgenesis.com>

* Update schema/token.graphql

Co-authored-by: Leszek Wiesner <leszek@jsgenesis.com>

* fix: address PR

* fix: hidden entities

* fix: migration ok

* feat: add extra check for migrations

* fix: docker network

* fix: format

* fix: remove unrequired constraint

* fix: 🐛 post rebase fixes

* feat: 🎨 add metadata processing for issue token

* feat(crt-v1): ✨ chain metadata for v 2003

* fix(crt-v1): 🚑 comment out view element for orion playgroud

* fix(crt-v1): 🎨 add playground config variable to .env

* feat: ✅ add tests

* fix(crt-v1): 📦 packages and patches

* fix(crt-v1): ✅ update entity id used and other minor fixes

* fix(crt-v1): ✅ update entity id used and other minor fixes

* test(crt-v1): 🐛 misc fixes to have tests working

* test(crt-v1): 🐛 misc fixes to have tests working

* fix(crt-v1): 🐛 metadata and trailer video

* feat(crt-v1): 🎨 update types

* fix(crt-v1): ✨ Add correct Ratio denomination (Permill)

* update with master

* fix: 🐛 metadata not being set

* fix: 🐛 parameters order

* test: 🧪 fixing integration tests

* test(crt-v1): 🧪 fix integration tests

* feat(crt-v1): ✨ last price for token and recovered field for rev share part

* feat: ✨ add resolver for dividend amount

* feat(crt-v1): ✨ start adding channel fields for trackingtotal revenue

* feat(crt-v1): ✨ add utils for royalty computation

* feat(crt-v1): ✨ cumulative revenue on channel

* feat(crt-v1): ✨ add resolver for transferrable amount

* fix(crt-v1): ✨ add `acquiredAt` to pinpoint latest vesting schedule for account

* Token metadata processing update

* Prettier

* chore(crt-v1): ⚡ dbgen

* fix(crt-v1): 🧪 fix integration tests

* fix(crt-v1): 🐛 missing fields in token sale vesting source

* test(crt-v1): 🧪 test for transferrable balance amount

* fix(crt-v1): 🐛 transferrable amount

* test: 🧪 update tests after resolver fix

* fix: 🐛 error on vesting schedules array

* fix: 🎨 CI fixes

* docs: update gitignore

* fix: 🚨 prettier

* build: 📌 chai depnedencies

---------

Co-authored-by: Leszek Wiesner <leszek@jsgenesis.com>
Co-authored-by: WRadoslaw <r.wyszynski00@gmail.com>

* Clear benefits even if not passed (#282)

* 🤑 Fix revenue share dividend estimation (#297)

* Fix on revenue share dividend estimation

* Fix type on result

* 🛕 Historical revenue share participants (#286)

* New field for revenue share

* Set potential revenue share particitants at the time of start

* fix: .gitignore not working

* fix lint issues

* re-generate db migrations

* commit register.html.mst file

* fix: notifications integration test

---------

Co-authored-by: Ignazio Bovo <ignazio@jsgenesis.com>
Co-authored-by: Leszek Wiesner <leszek@jsgenesis.com>
Co-authored-by: WRadoslaw <r.wyszynski00@gmail.com>
Co-authored-by: WRadoslaw <92513933+WRadoslaw@users.noreply.github.com>

* Revert "Update `nara` from `master` (#300)" (#306)

This reverts commit 887427c.

* generate auth api docs and types

---------

Co-authored-by: Zeeshan Akram <37098720+zeeshanakram3@users.noreply.github.com>
Co-authored-by: Ignazio Bovo <ignazio@jsgenesis.com>
Co-authored-by: Leszek Wiesner <leszek@jsgenesis.com>
Co-authored-by: Zeeshan Akram <97m.zeeshan@gmail.com>
  • Loading branch information
5 people authored Feb 27, 2024
1 parent ceba91d commit 61eb7cd
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 128 deletions.
1 change: 0 additions & 1 deletion db/migrations/1709038872576-Views.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const { getViewDefinitions } = require('../viewDefinitions')

module.exports = class Views1709038872576 {
Expand Down
1 change: 1 addition & 0 deletions schema/auth.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ enum OperatorPermission {
EXCLUDE_CONTENT
RESTORE_CONTENT
SET_PUBLIC_FEED_VIDEOS
SET_FEATURED_CRTS
}

type User @entity @schema(name: "admin") {
Expand Down
5 changes: 4 additions & 1 deletion schema/token.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ type CreatorToken @entity {
"total supply"
totalSupply: BigInt!

"Flag to indicate whether the CRT is featured or not"
isFeatured: Boolean!

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

Expand All @@ -51,7 +54,7 @@ type CreatorToken @entity {
ammCurves: [AmmCurve!] @derivedFrom(field: "token")

"date at which this token was created"
createdAt: DateTime!
createdAt: DateTime! @index

"channel from which the token is issued uniqueness guaranteed by runtime"
channel: TokenChannel @derivedFrom(field: "token")
Expand Down
5 changes: 2 additions & 3 deletions src/auth-server/docs/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ Models/ActionExecutionRequestData.md
Models/AnonymousUserAuthRequestData.md
Models/AnonymousUserAuthResponseData.md
Models/AnonymousUserAuthResponseData_allOf.md
Models/ChangeAccountRequestData.md
Models/ChangeAccountRequestData_allOf.md
Models/ConfirmEmailRequestData.md
Models/ConnectAccountRequestData.md
Models/ConnectAccountRequestData_allOf.md
Models/CreateAccountRequestData.md
Models/CreateAccountRequestData_allOf.md
Models/DisconnectAccountRequestData.md
Models/EncryptionArtifacts.md
Models/GenericErrorResponseData.md
Models/GenericOkResponseData.md
Expand Down
111 changes: 15 additions & 96 deletions src/auth-server/docs/Apis/DefaultApi.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
# DefaultApi

All URIs are relative to *http://localhost:4074/api/v1*
All URIs are relative to *http://localhost/api/v1*

| Method | HTTP request | Description |
|------------- | ------------- | -------------|
| [**anonymousAuth**](DefaultApi.md#anonymousAuth) | **POST** /anonymous-auth | |
| [**changeAccount**](DefaultApi.md#changeAccount) | **POST** /change-account | |
| [**confirmEmail**](DefaultApi.md#confirmEmail) | **POST** /confirm-email | |
| [**connectAccount**](DefaultApi.md#connectAccount) | **POST** /connect-account | |
| [**createAccount**](DefaultApi.md#createAccount) | **POST** /account | |
| [**deleteArtifacts**](DefaultApi.md#deleteArtifacts) | **DELETE** /artifacts | |
| [**disconnectAccount**](DefaultApi.md#disconnectAccount) | **POST** /disconnect-account | |
| [**getArtifacts**](DefaultApi.md#getArtifacts) | **GET** /artifacts | |
| [**getSessionArtifacts**](DefaultApi.md#getSessionArtifacts) | **GET** /session-artifacts | |
| [**login**](DefaultApi.md#login) | **POST** /login | |
| [**logout**](DefaultApi.md#logout) | **POST** /logout | |
| [**postArtifacts**](DefaultApi.md#postArtifacts) | **POST** /artifacts | |
| [**postSessionArtifacts**](DefaultApi.md#postSessionArtifacts) | **POST** /session-artifacts | |
| [**requestEmailConfirmationToken**](DefaultApi.md#requestEmailConfirmationToken) | **POST** /request-email-confirmation-token | |

Expand Down Expand Up @@ -46,54 +43,54 @@ No authorization required
- **Content-Type**: application/json
- **Accept**: application/json

<a name="confirmEmail"></a>
# **confirmEmail**
> GenericOkResponseData confirmEmail(ConfirmEmailRequestData)
<a name="changeAccount"></a>
# **changeAccount**
> GenericOkResponseData changeAccount(ChangeAccountRequestData)


Confirm account&#39;s e-mail address provided during registration.
Change the blockchain (Joystream) account associated with the Gateway account. Delete the old account&#39;s encryption artifacts and optionally set new ones.

### Parameters

|Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **ConfirmEmailRequestData** | [**ConfirmEmailRequestData**](../Models/ConfirmEmailRequestData.md)| | [optional] |
| **ChangeAccountRequestData** | [**ChangeAccountRequestData**](../Models/ChangeAccountRequestData.md)| | [optional] |

### Return type

[**GenericOkResponseData**](../Models/GenericOkResponseData.md)

### Authorization

No authorization required
[cookieAuth](../README.md#cookieAuth)

### HTTP request headers

- **Content-Type**: application/json
- **Accept**: application/json

<a name="connectAccount"></a>
# **connectAccount**
> GenericOkResponseData connectAccount(ConnectAccountRequestData)
<a name="confirmEmail"></a>
# **confirmEmail**
> GenericOkResponseData confirmEmail(ConfirmEmailRequestData)


Connect a Joystream account (key) with the Gateway acount by providing a signed proof of ownership.
Confirm account&#39;s e-mail address provided during registration.

### Parameters

|Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **ConnectAccountRequestData** | [**ConnectAccountRequestData**](../Models/ConnectAccountRequestData.md)| | [optional] |
| **ConfirmEmailRequestData** | [**ConfirmEmailRequestData**](../Models/ConfirmEmailRequestData.md)| | [optional] |

### Return type

[**GenericOkResponseData**](../Models/GenericOkResponseData.md)

### Authorization

[cookieAuth](../README.md#cookieAuth)
No authorization required

### HTTP request headers

Expand Down Expand Up @@ -127,57 +124,6 @@ No authorization required
- **Content-Type**: application/json
- **Accept**: application/json

<a name="deleteArtifacts"></a>
# **deleteArtifacts**
> GenericOkResponseData deleteArtifacts()


Delete wallet seed encryption artifacts in case they are no longer needed.

### Parameters
This endpoint does not need any parameter.

### Return type

[**GenericOkResponseData**](../Models/GenericOkResponseData.md)

### Authorization

[cookieAuth](../README.md#cookieAuth)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json

<a name="disconnectAccount"></a>
# **disconnectAccount**
> GenericOkResponseData disconnectAccount(DisconnectAccountRequestData)


Disconnect a Joystream account (key) from the Gateway acount.

### Parameters

|Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **DisconnectAccountRequestData** | [**DisconnectAccountRequestData**](../Models/DisconnectAccountRequestData.md)| | [optional] |

### Return type

[**GenericOkResponseData**](../Models/GenericOkResponseData.md)

### Authorization

[cookieAuth](../README.md#cookieAuth)

### HTTP request headers

- **Content-Type**: application/json
- **Accept**: application/json

<a name="getArtifacts"></a>
# **getArtifacts**
> EncryptionArtifacts getArtifacts(id, email)
Expand Down Expand Up @@ -236,7 +182,7 @@ This endpoint does not need any parameter.


Login to user&#39;s account by providing a message signed by one of the user&#39;s connected accounts.
Login to user&#39;s account by providing a message signed by the associated blockchain account.

### Parameters

Expand Down Expand Up @@ -281,33 +227,6 @@ This endpoint does not need any parameter.
- **Content-Type**: Not defined
- **Accept**: application/json

<a name="postArtifacts"></a>
# **postArtifacts**
> GenericOkResponseData postArtifacts(EncryptionArtifacts)


Save wallet seed encryption artifacts associated with the account (if not already saved).

### Parameters

|Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **EncryptionArtifacts** | [**EncryptionArtifacts**](../Models/EncryptionArtifacts.md)| | [optional] |

### Return type

[**GenericOkResponseData**](../Models/GenericOkResponseData.md)

### Authorization

[cookieAuth](../README.md#cookieAuth)

### HTTP request headers

- **Content-Type**: application/json
- **Accept**: application/json

<a name="postSessionArtifacts"></a>
# **postSessionArtifacts**
> GenericOkResponseData postSessionArtifacts(SessionEncryptionArtifacts)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ConnectAccountRequestData
# ChangeAccountRequestData
## Properties

| Name | Type | Description | Notes |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ConnectAccountRequestData_allOf
# ChangeAccountRequestData_allOf
## Properties

| Name | Type | Description | Notes |
Expand Down
9 changes: 0 additions & 9 deletions src/auth-server/docs/Models/DisconnectAccountRequestData.md

This file was deleted.

14 changes: 5 additions & 9 deletions src/auth-server/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@
<a name="documentation-for-api-endpoints"></a>
## Documentation for API Endpoints

All URIs are relative to *http://localhost:4074/api/v1*
All URIs are relative to *http://localhost/api/v1*

| Class | Method | HTTP request | Description |
|------------ | ------------- | ------------- | -------------|
| *DefaultApi* | [**anonymousAuth**](Apis/DefaultApi.md#anonymousauth) | **POST** /anonymous-auth | Authenticate as an anonymous user, either using an existing user identifier or creating a new one. |
*DefaultApi* | [**changeAccount**](Apis/DefaultApi.md#changeaccount) | **POST** /change-account | Change the blockchain (Joystream) account associated with the Gateway account. Delete the old account's encryption artifacts and optionally set new ones. |
*DefaultApi* | [**confirmEmail**](Apis/DefaultApi.md#confirmemail) | **POST** /confirm-email | Confirm account's e-mail address provided during registration. |
*DefaultApi* | [**connectAccount**](Apis/DefaultApi.md#connectaccount) | **POST** /connect-account | Connect a Joystream account (key) with the Gateway acount by providing a signed proof of ownership. |
*DefaultApi* | [**createAccount**](Apis/DefaultApi.md#createaccount) | **POST** /account | Create a new Gateway account. Requires anonymousAuth to be performed first. |
*DefaultApi* | [**deleteArtifacts**](Apis/DefaultApi.md#deleteartifacts) | **DELETE** /artifacts | Delete wallet seed encryption artifacts in case they are no longer needed. |
*DefaultApi* | [**disconnectAccount**](Apis/DefaultApi.md#disconnectaccount) | **POST** /disconnect-account | Disconnect a Joystream account (key) from the Gateway acount. |
*DefaultApi* | [**getArtifacts**](Apis/DefaultApi.md#getartifacts) | **GET** /artifacts | Get wallet seed encryption artifacts. |
*DefaultApi* | [**getSessionArtifacts**](Apis/DefaultApi.md#getsessionartifacts) | **GET** /session-artifacts | Get wallet seed encryption artifacts for the current session. |
*DefaultApi* | [**login**](Apis/DefaultApi.md#login) | **POST** /login | Login to user's account by providing a message signed by one of the user's connected accounts. |
*DefaultApi* | [**login**](Apis/DefaultApi.md#login) | **POST** /login | Login to user's account by providing a message signed by the associated blockchain account. |
*DefaultApi* | [**logout**](Apis/DefaultApi.md#logout) | **POST** /logout | Terminate the current session. |
*DefaultApi* | [**postArtifacts**](Apis/DefaultApi.md#postartifacts) | **POST** /artifacts | Save wallet seed encryption artifacts associated with the account (if not already saved). |
*DefaultApi* | [**postSessionArtifacts**](Apis/DefaultApi.md#postsessionartifacts) | **POST** /session-artifacts | Save wallet seed encryption artifacts for the current session on the server. |
*DefaultApi* | [**requestEmailConfirmationToken**](Apis/DefaultApi.md#requestemailconfirmationtoken) | **POST** /request-email-confirmation-token | Request a token to be sent to account's e-mail address, which will allow confirming the ownership of the e-mail by the user. |

Expand All @@ -30,12 +27,11 @@ All URIs are relative to *http://localhost:4074/api/v1*
- [AnonymousUserAuthRequestData](./Models/AnonymousUserAuthRequestData.md)
- [AnonymousUserAuthResponseData](./Models/AnonymousUserAuthResponseData.md)
- [AnonymousUserAuthResponseData_allOf](./Models/AnonymousUserAuthResponseData_allOf.md)
- [ChangeAccountRequestData](./Models/ChangeAccountRequestData.md)
- [ChangeAccountRequestData_allOf](./Models/ChangeAccountRequestData_allOf.md)
- [ConfirmEmailRequestData](./Models/ConfirmEmailRequestData.md)
- [ConnectAccountRequestData](./Models/ConnectAccountRequestData.md)
- [ConnectAccountRequestData_allOf](./Models/ConnectAccountRequestData_allOf.md)
- [CreateAccountRequestData](./Models/CreateAccountRequestData.md)
- [CreateAccountRequestData_allOf](./Models/CreateAccountRequestData_allOf.md)
- [DisconnectAccountRequestData](./Models/DisconnectAccountRequestData.md)
- [EncryptionArtifacts](./Models/EncryptionArtifacts.md)
- [GenericErrorResponseData](./Models/GenericErrorResponseData.md)
- [GenericOkResponseData](./Models/GenericOkResponseData.md)
Expand Down
1 change: 0 additions & 1 deletion src/auth-server/generated/api-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export interface components {
memberId: string
email: string
encryptionArtifacts?: components['schemas']['EncryptionArtifacts']
referrerChannelId?: string
}
}
ChangeAccountRequestData: components['schemas']['ActionExecutionRequestData'] & {
Expand Down
12 changes: 6 additions & 6 deletions src/auth-server/handlers/createAccount.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import express from 'express'
import { BadRequestError, ConflictError, NotFoundError } from '../errors'
import { components } from '../generated/api-types'
import { globalEm } from '../../utils/globalEm'
import { Account, EncryptionArtifacts, Membership, NextEntityId } from '../../model'
import { AuthContext } from '../../utils/auth'
import { globalEm } from '../../utils/globalEm'
import { idStringFromNumber } from '../../utils/misc'
import { verifyActionExecutionRequest } from '../utils'
import { defaultNotificationPreferences } from '../../utils/notification/helpers'
import { BadRequestError, ConflictError, NotFoundError } from '../errors'
import { components } from '../generated/api-types'
import { verifyActionExecutionRequest } from '../utils'

type ReqParams = Record<string, string>
type ResBody =
Expand All @@ -22,7 +22,7 @@ export const createAccount: (
) => Promise<void> = async (req, res, next) => {
try {
const {
payload: { email, memberId, joystreamAccountId, referrerChannelId },
payload: { email, memberId, joystreamAccountId },
} = req.body
const { authContext } = res.locals
const em = await globalEm
Expand Down Expand Up @@ -88,7 +88,7 @@ export const createAccount: (
joystreamAccount: joystreamAccountId,
membershipId: memberId.toString(),
notificationPreferences,
referrerChannelId: referrerChannelId || null,
referrerChannelId: null,
})

await em.save([
Expand Down
33 changes: 33 additions & 0 deletions src/server-extension/resolvers/AdminResolver/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
Account,
Channel,
ChannelRecipient,
CreatorToken,
NftFeaturedOnMarketPlace,
OperatorPermission,
OwnedNft,
Expand Down Expand Up @@ -50,6 +51,8 @@ import {
SetCategoryFeaturedVideosArgs,
SetCategoryFeaturedVideosResult,
SetChannelsWeightsArgs,
SetFeaturedCrtsInput,
SetFeaturedCrtsResult,
SetFeaturedNftsInput,
SetFeaturedNftsResult,
SetKillSwitchInput,
Expand Down Expand Up @@ -400,6 +403,36 @@ export class AdminResolver {
return await setFeaturedNftsInner(em, featuredNftsIds)
}

@UseMiddleware(OperatorOnly(OperatorPermission.SET_FEATURED_CRTS))
@Mutation(() => SetFeaturedCrtsResult)
async setFeaturedCrts(
@Args() { featuredCrtsIds }: SetFeaturedCrtsInput
): Promise<SetFeaturedCrtsResult> {
const em = await this.em()
let newNumberOfCrtsFeatured = 0

await em
.createQueryBuilder()
.update<CreatorToken>(CreatorToken)
.set({ isFeatured: false })
.where({ isFeatured: true })
.execute()

if (featuredCrtsIds.length) {
const result = await em
.createQueryBuilder()
.update<CreatorToken>(CreatorToken)
.set({ isFeatured: true })
.where({ id: In(featuredCrtsIds) })
.execute()
newNumberOfCrtsFeatured = result.affected || 0
}

return {
newNumberOfCrtsFeatured,
}
}

@UseMiddleware(OperatorOnly(OperatorPermission.EXCLUDE_CONTENT))
@Mutation(() => ExcludeContentResult)
async excludeContent(
Expand Down
Loading

0 comments on commit 61eb7cd

Please sign in to comment.