diff --git a/resources/js/api/mutations.ts b/resources/js/api/mutations.ts index 0e8f3659..e3307040 100644 --- a/resources/js/api/mutations.ts +++ b/resources/js/api/mutations.ts @@ -70,6 +70,14 @@ import FillListing from '~/graphql/mutation/marketplace/FillListing'; import PlaceBid from '~/graphql/mutation/marketplace/PlaceBid'; import FinalizeAuction from '~/graphql/mutation/marketplace/FinalizeAuction'; +import CreateTokenGroup from '~/graphql/mutation/token-group/CreateTokenGroup'; +import DestroyTokenGroup from '~/graphql/mutation/token-group/DestroyTokenGroup'; +import AddTokenToGroup from '~/graphql/mutation/token-group/AddTokenToGroup'; +import RemoveTokenFromGroup from '~/graphql/mutation/token-group/RemoveTokenFromGroup'; +import SetTokenGroups from '~/graphql/mutation/token-group/SetTokenGroups'; +import SetTokenGroupAttribute from '~/graphql/mutation/token-group/SetTokenGroupAttribute'; +import RemoveTokenGroupAttribute from '~/graphql/mutation/token-group/RemoveTokenGroupAttribute'; + export default { CreateCollection, ApproveCollection, @@ -142,4 +150,12 @@ export default { FillListing, PlaceBid, FinalizeAuction, + + CreateTokenGroup, + DestroyTokenGroup, + AddTokenToGroup, + RemoveTokenFromGroup, + SetTokenGroups, + SetTokenGroupAttribute, + RemoveTokenGroupAttribute, }; diff --git a/resources/js/api/queries.ts b/resources/js/api/queries.ts index d3507391..c2558fd4 100644 --- a/resources/js/api/queries.ts +++ b/resources/js/api/queries.ts @@ -30,6 +30,9 @@ import GetSales from '~/graphql/query/marketplace/GetSales'; import GetBlocks from '~/graphql/query/marketplace/GetBlocks'; import GetBanners from '~/graphql/query/GetBanners'; +import GetTokenGroup from '~/graphql/query/token-group/GetTokenGroup'; +import GetTokenGroups from '~/graphql/query/token-group/GetTokenGroups'; + export default { GetTransaction, GetCollections, @@ -62,4 +65,7 @@ export default { GetSales, GetBlocks, GetBanners, + + GetTokenGroup, + GetTokenGroups, }; diff --git a/resources/js/api/token-group.ts b/resources/js/api/token-group.ts new file mode 100644 index 00000000..09d2f87e --- /dev/null +++ b/resources/js/api/token-group.ts @@ -0,0 +1,137 @@ +import { ApiService } from '.'; +import mutations from './mutations'; +import queries from './queries'; + +export class TokenGroupApi { + static async getTokenGroup(collectionId: string, tokenGroupId: string) { + const data = { + query: queries.GetTokenGroup, + variables: { + collectionId, + tokenGroupId, + }, + }; + + return ApiService.sendPlatformRequest(data); + } + + static async getTokenGroups(collectionId: string | null = null, after: string | null = null) { + const data = { + query: queries.GetTokenGroups, + variables: { + collectionId, + after, + first: 20, + }, + }; + + return ApiService.sendPlatformRequest(data); + } + + static async createTokenGroup(tokenGroupData: Record) { + const data = { + query: mutations.CreateTokenGroup, + variables: { + collectionId: tokenGroupData.collectionId, + signingAccount: tokenGroupData.signingAccount, + idempotencyKey: tokenGroupData.idempotencyKey, + skipValidation: tokenGroupData.skipValidation, + }, + }; + + return ApiService.sendPlatformRequest(data); + } + + static async destroyTokenGroup(tokenGroupData: Record) { + const data = { + query: mutations.DestroyTokenGroup, + variables: { + tokenGroupId: tokenGroupData.tokenGroupId, + signingAccount: tokenGroupData.signingAccount, + idempotencyKey: tokenGroupData.idempotencyKey, + skipValidation: tokenGroupData.skipValidation, + }, + }; + + return ApiService.sendPlatformRequest(data); + } + + static async addTokenToGroup(tokenGroupData: Record) { + const data = { + query: mutations.AddTokenToGroup, + variables: { + collectionId: tokenGroupData.collectionId, + tokenId: tokenGroupData.tokenId, + tokenGroupId: tokenGroupData.tokenGroupId, + signingAccount: tokenGroupData.signingAccount, + idempotencyKey: tokenGroupData.idempotencyKey, + skipValidation: tokenGroupData.skipValidation, + }, + }; + + return ApiService.sendPlatformRequest(data); + } + + static async removeTokenFromGroup(tokenGroupData: Record) { + const data = { + query: mutations.RemoveTokenFromGroup, + variables: { + collectionId: tokenGroupData.collectionId, + tokenId: tokenGroupData.tokenId, + tokenGroupId: tokenGroupData.tokenGroupId, + signingAccount: tokenGroupData.signingAccount, + idempotencyKey: tokenGroupData.idempotencyKey, + skipValidation: tokenGroupData.skipValidation, + }, + }; + + return ApiService.sendPlatformRequest(data); + } + + static async setTokenGroups(tokenGroupData: Record) { + const data = { + query: mutations.SetTokenGroups, + variables: { + collectionId: tokenGroupData.collectionId, + tokenId: tokenGroupData.tokenId, + tokenGroups: tokenGroupData.tokenGroups, + signingAccount: tokenGroupData.signingAccount, + idempotencyKey: tokenGroupData.idempotencyKey, + skipValidation: tokenGroupData.skipValidation, + }, + }; + + return ApiService.sendPlatformRequest(data); + } + + static async setTokenGroupAttribute(tokenGroupData: Record) { + const data = { + query: mutations.SetTokenGroupAttribute, + variables: { + tokenGroupId: tokenGroupData.tokenGroupId, + key: tokenGroupData.key, + value: tokenGroupData.value, + signingAccount: tokenGroupData.signingAccount, + idempotencyKey: tokenGroupData.idempotencyKey, + skipValidation: tokenGroupData.skipValidation, + }, + }; + + return ApiService.sendPlatformRequest(data); + } + + static async removeTokenGroupAttribute(tokenGroupData: Record) { + const data = { + query: mutations.RemoveTokenGroupAttribute, + variables: { + tokenGroupId: tokenGroupData.tokenGroupId, + key: tokenGroupData.key, + signingAccount: tokenGroupData.signingAccount, + idempotencyKey: tokenGroupData.idempotencyKey, + skipValidation: tokenGroupData.skipValidation, + }, + }; + + return ApiService.sendPlatformRequest(data); + } +} diff --git a/resources/js/components/pages/TokenGroups.vue b/resources/js/components/pages/TokenGroups.vue new file mode 100644 index 00000000..ec7751df --- /dev/null +++ b/resources/js/components/pages/TokenGroups.vue @@ -0,0 +1,267 @@ + + + diff --git a/resources/js/components/slideovers/token-group/AddTokenToGroupSlideover.vue b/resources/js/components/slideovers/token-group/AddTokenToGroupSlideover.vue new file mode 100644 index 00000000..25e022de --- /dev/null +++ b/resources/js/components/slideovers/token-group/AddTokenToGroupSlideover.vue @@ -0,0 +1,163 @@ + + + diff --git a/resources/js/components/slideovers/token-group/AttributesTokenGroupSlideover.vue b/resources/js/components/slideovers/token-group/AttributesTokenGroupSlideover.vue new file mode 100644 index 00000000..a575dd6f --- /dev/null +++ b/resources/js/components/slideovers/token-group/AttributesTokenGroupSlideover.vue @@ -0,0 +1,236 @@ + + + diff --git a/resources/js/components/slideovers/token-group/CreateTokenGroupSlideover.vue b/resources/js/components/slideovers/token-group/CreateTokenGroupSlideover.vue new file mode 100644 index 00000000..ef332909 --- /dev/null +++ b/resources/js/components/slideovers/token-group/CreateTokenGroupSlideover.vue @@ -0,0 +1,131 @@ + + + diff --git a/resources/js/components/slideovers/token-group/DestroyTokenGroupSlideover.vue b/resources/js/components/slideovers/token-group/DestroyTokenGroupSlideover.vue new file mode 100644 index 00000000..60bc0943 --- /dev/null +++ b/resources/js/components/slideovers/token-group/DestroyTokenGroupSlideover.vue @@ -0,0 +1,141 @@ + + + diff --git a/resources/js/components/slideovers/token-group/DetailsTokenGroupSlideover.vue b/resources/js/components/slideovers/token-group/DetailsTokenGroupSlideover.vue new file mode 100644 index 00000000..2848922b --- /dev/null +++ b/resources/js/components/slideovers/token-group/DetailsTokenGroupSlideover.vue @@ -0,0 +1,126 @@ + + + diff --git a/resources/js/components/slideovers/token-group/RemoveTokenFromGroupSlideover.vue b/resources/js/components/slideovers/token-group/RemoveTokenFromGroupSlideover.vue new file mode 100644 index 00000000..7725adb8 --- /dev/null +++ b/resources/js/components/slideovers/token-group/RemoveTokenFromGroupSlideover.vue @@ -0,0 +1,163 @@ + + + diff --git a/resources/js/factory/token-group.ts b/resources/js/factory/token-group.ts new file mode 100644 index 00000000..3b13cbbd --- /dev/null +++ b/resources/js/factory/token-group.ts @@ -0,0 +1,30 @@ +export class DTOTokenGroupFactory { + public static buildTokenGroup(tokenGroup: any) { + return { + ...tokenGroup, + collectionId: tokenGroup.collection?.collectionId, + tokensCount: tokenGroup.tokens?.length ?? 0, + attributesCount: tokenGroup.attributes?.length ?? 0, + }; + } + + public static forTokenGroups(tokenGroupsData: any) { + const tokenGroups = tokenGroupsData.data.GetTokenGroups; + + return { + items: tokenGroups?.edges?.map((edge: any) => { + return DTOTokenGroupFactory.buildTokenGroup(edge.node); + }), + cursor: tokenGroups.pageInfo?.hasNextPage ? tokenGroups.pageInfo.endCursor : null, + }; + } + + public static forTokenGroup(tokenGroupData: any) { + const tokenGroup = tokenGroupData.data.GetTokenGroup; + + return { + items: [DTOTokenGroupFactory.buildTokenGroup(tokenGroup)], + cursor: null, + }; + } +} diff --git a/resources/js/graphql/mutation/token-group/AddTokenToGroup.ts b/resources/js/graphql/mutation/token-group/AddTokenToGroup.ts new file mode 100644 index 00000000..957cebe3 --- /dev/null +++ b/resources/js/graphql/mutation/token-group/AddTokenToGroup.ts @@ -0,0 +1,12 @@ +export default `mutation AddTokenToGroup($collectionId: BigInt!, $tokenId: EncodableTokenIdInput!, $tokenGroupId: BigInt!, $signingAccount: String, $idempotencyKey: String, $skipValidation: Boolean! = false) { + AddTokenToGroup( + collectionId: $collectionId + tokenId: $tokenId + tokenGroupId: $tokenGroupId + signingAccount: $signingAccount + idempotencyKey: $idempotencyKey + skipValidation: $skipValidation + ) { + id + } +}`; diff --git a/resources/js/graphql/mutation/token-group/CreateTokenGroup.ts b/resources/js/graphql/mutation/token-group/CreateTokenGroup.ts new file mode 100644 index 00000000..23a498e3 --- /dev/null +++ b/resources/js/graphql/mutation/token-group/CreateTokenGroup.ts @@ -0,0 +1,10 @@ +export default `mutation CreateTokenGroup($collectionId: BigInt!, $signingAccount: String, $idempotencyKey: String, $skipValidation: Boolean! = false) { + CreateTokenGroup( + collectionId: $collectionId + signingAccount: $signingAccount + idempotencyKey: $idempotencyKey + skipValidation: $skipValidation + ) { + id + } +}`; diff --git a/resources/js/graphql/mutation/token-group/DestroyTokenGroup.ts b/resources/js/graphql/mutation/token-group/DestroyTokenGroup.ts new file mode 100644 index 00000000..01e65fe7 --- /dev/null +++ b/resources/js/graphql/mutation/token-group/DestroyTokenGroup.ts @@ -0,0 +1,10 @@ +export default `mutation DestroyTokenGroup($tokenGroupId: BigInt!, $signingAccount: String, $idempotencyKey: String, $skipValidation: Boolean! = false) { + DestroyTokenGroup( + tokenGroupId: $tokenGroupId + signingAccount: $signingAccount + idempotencyKey: $idempotencyKey + skipValidation: $skipValidation + ) { + id + } +}`; diff --git a/resources/js/graphql/mutation/token-group/RemoveTokenFromGroup.ts b/resources/js/graphql/mutation/token-group/RemoveTokenFromGroup.ts new file mode 100644 index 00000000..6549a4a5 --- /dev/null +++ b/resources/js/graphql/mutation/token-group/RemoveTokenFromGroup.ts @@ -0,0 +1,12 @@ +export default `mutation RemoveTokenFromGroup($collectionId: BigInt!, $tokenId: EncodableTokenIdInput!, $tokenGroupId: BigInt!, $signingAccount: String, $idempotencyKey: String, $skipValidation: Boolean! = false) { + RemoveTokenFromGroup( + collectionId: $collectionId + tokenId: $tokenId + tokenGroupId: $tokenGroupId + signingAccount: $signingAccount + idempotencyKey: $idempotencyKey + skipValidation: $skipValidation + ) { + id + } +}`; diff --git a/resources/js/graphql/mutation/token-group/RemoveTokenGroupAttribute.ts b/resources/js/graphql/mutation/token-group/RemoveTokenGroupAttribute.ts new file mode 100644 index 00000000..acdbf9c0 --- /dev/null +++ b/resources/js/graphql/mutation/token-group/RemoveTokenGroupAttribute.ts @@ -0,0 +1,11 @@ +export default `mutation RemoveTokenGroupAttribute($tokenGroupId: BigInt!, $key: String!, $signingAccount: String, $idempotencyKey: String, $skipValidation: Boolean! = false) { + RemoveTokenGroupAttribute( + tokenGroupId: $tokenGroupId + key: $key + signingAccount: $signingAccount + idempotencyKey: $idempotencyKey + skipValidation: $skipValidation + ) { + id + } +}`; diff --git a/resources/js/graphql/mutation/token-group/SetTokenGroupAttribute.ts b/resources/js/graphql/mutation/token-group/SetTokenGroupAttribute.ts new file mode 100644 index 00000000..f7591e30 --- /dev/null +++ b/resources/js/graphql/mutation/token-group/SetTokenGroupAttribute.ts @@ -0,0 +1,12 @@ +export default `mutation SetTokenGroupAttribute($tokenGroupId: BigInt!, $key: String!, $value: String!, $signingAccount: String, $idempotencyKey: String, $skipValidation: Boolean! = false) { + SetTokenGroupAttribute( + tokenGroupId: $tokenGroupId + key: $key + value: $value + signingAccount: $signingAccount + idempotencyKey: $idempotencyKey + skipValidation: $skipValidation + ) { + id + } +}`; diff --git a/resources/js/graphql/mutation/token-group/SetTokenGroups.ts b/resources/js/graphql/mutation/token-group/SetTokenGroups.ts new file mode 100644 index 00000000..69521d2f --- /dev/null +++ b/resources/js/graphql/mutation/token-group/SetTokenGroups.ts @@ -0,0 +1,12 @@ +export default `mutation SetTokenGroups($collectionId: BigInt!, $tokenId: EncodableTokenIdInput!, $tokenGroups: [BigInt!]!, $signingAccount: String, $idempotencyKey: String, $skipValidation: Boolean! = false) { + SetTokenGroups( + collectionId: $collectionId + tokenId: $tokenId + tokenGroups: $tokenGroups + signingAccount: $signingAccount + idempotencyKey: $idempotencyKey + skipValidation: $skipValidation + ) { + id + } +}`; diff --git a/resources/js/graphql/query/token-group/GetTokenGroup.ts b/resources/js/graphql/query/token-group/GetTokenGroup.ts new file mode 100644 index 00000000..3a65aa2b --- /dev/null +++ b/resources/js/graphql/query/token-group/GetTokenGroup.ts @@ -0,0 +1,18 @@ +export default `query GetTokenGroup($collectionId: BigInt!, $tokenGroupId: BigInt!) { + GetTokenGroup(collectionId: $collectionId, tokenGroupId: $tokenGroupId) { + id + collection { + collectionId + } + attributes { + key + value + } + tokens { + token { + tokenId + } + position + } + } +}`; diff --git a/resources/js/graphql/query/token-group/GetTokenGroups.ts b/resources/js/graphql/query/token-group/GetTokenGroups.ts new file mode 100644 index 00000000..87044a58 --- /dev/null +++ b/resources/js/graphql/query/token-group/GetTokenGroups.ts @@ -0,0 +1,27 @@ +export default `query GetTokenGroups($collectionId: BigInt, $after: String, $first: Int) { + GetTokenGroups(collectionId: $collectionId, after: $after, first: $first) { + edges { + node { + id + collection { + collectionId + } + attributes { + key + value + } + tokens { + token { + tokenId + } + position + } + } + cursor + } + pageInfo { + hasNextPage + endCursor + } + } +}`; diff --git a/resources/js/router/index.ts b/resources/js/router/index.ts index f59bfc63..1a9307fb 100644 --- a/resources/js/router/index.ts +++ b/resources/js/router/index.ts @@ -34,6 +34,15 @@ const routes = [ requiresToken: true, }, }, + { + path: '/token-groups', + name: 'platform.token-groups', + component: () => import('../components/pages/TokenGroups.vue'), + meta: { + requiresAuth: true, + requiresToken: true, + }, + }, { path: '/transactions', name: 'platform.transactions', diff --git a/resources/js/store/index.ts b/resources/js/store/index.ts index 5cb40607..88d9b7f1 100644 --- a/resources/js/store/index.ts +++ b/resources/js/store/index.ts @@ -29,6 +29,7 @@ export const useAppStore = defineStore('app', { navigations: [ { name: 'Collections', to: { name: 'platform.collections' }, pos: 1 }, { name: 'Tokens', to: { name: 'platform.tokens' }, pos: 2 }, + { name: 'Token Groups', to: { name: 'platform.token-groups' }, pos: 3 }, { name: 'Transactions', to: { name: 'platform.transactions' }, count: true, pos: 6 }, { name: 'Wallets', to: { name: 'platform.wallets' }, pos: 7 }, ],