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

🦿 CRT marketplace changes #285

Merged
merged 12 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading