Skip to content

Commit

Permalink
Merge pull request #1001 from alleslabs/fix/nft-collection-query
Browse files Browse the repository at this point in the history
fix: handle pre and post db schema on nft, collections
  • Loading branch information
evilpeach committed Jul 2, 2024
2 parents 25765a6 + c957c4a commit 6e9dfcd
Show file tree
Hide file tree
Showing 11 changed files with 1,276 additions and 40 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Improvements

- [#1001](https://github.com/alleslabs/celatone-frontend/pull/1001) Support pre and post db schema on nft & collection queries
- [#1000](https://github.com/alleslabs/celatone-frontend/pull/1000) Query module info from lcd directly
- [#998](https://github.com/alleslabs/celatone-frontend/pull/998) Use expression on Nft query
- [#996](https://github.com/alleslabs/celatone-frontend/pull/996) Allow disable voting period tally config
Expand Down
221 changes: 221 additions & 0 deletions src/lib/query/collectionOld.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
import { gql } from "graphql-request";

export const getCollectionsQueryOld = gql`
query getCollectionsQuery(
$offset: Int!
$pageSize: Int!
$expression: collections_bool_exp!
) {
collections(
limit: $pageSize
offset: $offset
where: $expression
order_by: { name: asc }
) {
name
uri
description
vm_address {
vm_address
}
vmAddressByCreator {
vm_address
}
}
collections_aggregate(where: $expression) {
aggregate {
count
}
}
}
`;

export const getCollectionByCollectionAddressQueryOld = gql`
query getCollectionByCollectionAddressQuery($vmAddress: String!) {
collections(where: { vm_address: { vm_address: { _eq: $vmAddress } } }) {
name
uri
description
vmAddressByCreator {
collectionsByCreator {
block_height
name
vmAddressByCreator {
vm_address
}
}
}
}
}
`;

export const getCollectionTotalBurnedCountQueryOld = gql`
query getCollectionTotalBurnedCountQuery($vmAddress: String!) {
nfts_aggregate(
where: {
collectionByCollection: {
vm_address: { vm_address: { _eq: $vmAddress } }
}
is_burned: { _eq: true }
}
) {
aggregate {
count
}
}
}
`;

export const getCollectionCreatorQueryOld = gql`
query getCollectionCreatorQuery($vmAddress: String!) {
collections(where: { vm_address: { vm_address: { _eq: $vmAddress } } }) {
vmAddressByCreator {
vm_address
}
collection_transactions(
order_by: { block_height: asc }
where: { is_collection_create: { _eq: true } }
) {
transaction {
hash
block {
height
timestamp
}
}
}
}
}
`;

export const getCollectionActivitiesCountQueryOld = gql`
query getCollectionActivitiesCountQuery($vmAddress: String!) {
collection_transactions_aggregate(
where: { collection: { vm_address: { vm_address: { _eq: $vmAddress } } } }
) {
aggregate {
count
}
}
}
`;

export const getCollectionMutateEventsCountQueryOld = gql`
query getCollectionMutateEventsCountQuery($vmAddress: String!) {
collection_mutation_events_aggregate(
where: { collection: { vm_address: { vm_address: { _eq: $vmAddress } } } }
) {
aggregate {
count
}
}
}
`;

export const getCollectionUniqueHoldersCountQueryOld = gql`
query getCollectionUniqueHoldersCountQuery($vmAddress: String!) {
nfts_aggregate(
where: {
collectionByCollection: {
vm_address: { vm_address: { _eq: $vmAddress } }
}
}
distinct_on: owner
) {
aggregate {
count
}
}
}
`;

export const getCollectionActivitiesQueryOld = gql`
query getCollectionActivitiesQuery(
$expression: collection_transactions_bool_exp
$offset: Int!
$pageSize: Int!
) {
collection_transactions(
limit: $pageSize
offset: $offset
where: $expression
order_by: [
{ block_height: desc }
{ nft: { token_id: desc } }
{ is_nft_burn: desc }
{ is_nft_transfer: desc }
{ is_nft_mint: desc }
{ is_collection_create: desc }
]
) {
transaction {
hash
block {
timestamp
}
}
is_nft_burn
is_nft_mint
is_nft_transfer
nft {
token_id
vm_address {
vm_address
}
}
is_collection_create
}
}
`;

export const getCollectionMutateEventsQueryOld = gql`
query getCollectionMutateEventsQuery(
$collectionAddress: String!
$offset: Int!
$pageSize: Int!
) {
collection_mutation_events(
limit: $pageSize
offset: $offset
where: {
collection: { vm_address: { vm_address: { _eq: $collectionAddress } } }
}
order_by: { block_height: desc }
) {
mutated_field_name
new_value
old_value
remark
block {
timestamp
}
}
}
`;

export const getCollectionsByAccountQueryOld = gql`
query getCollectionsByAccountQuery($accountAddress: String!) {
collections(
where: {
nfts: { vmAddressByOwner: { vm_address: { _eq: $accountAddress } } }
}
order_by: { name: asc }
) {
name
uri
vm_address {
vm_address
}
nfts_aggregate(
where: {
vmAddressByOwner: { vm_address: { _eq: $accountAddress } }
is_burned: { _eq: false }
}
) {
aggregate {
count
}
}
}
}
`;
2 changes: 2 additions & 0 deletions src/lib/query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ export * from "./pool";
export * from "./tx";
export * from "./account";
export * from "./collection";
export * from "./collectionOld";
export * from "./nft";
export * from "./nftOld";
Loading

0 comments on commit 6e9dfcd

Please sign in to comment.