Skip to content

Commit

Permalink
feat: add getNonFungibleIDs query
Browse files Browse the repository at this point in the history
  • Loading branch information
AbstractFruitFactory committed Dec 20, 2022
1 parent 501dc51 commit 283da1d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/io/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export const TransactionReceiptIO = object({
})
})

export const NonFungibleIDsIO = object({
export const EntityNonFungibleIDsIO = object({
address: string(),
resource_address: string(),
non_fungible_ids: object({
Expand All @@ -243,6 +243,14 @@ export const NonFungibleIDsIO = object({
})
})

export const NonFungibleIDsIO = object({
items: array(
object({
non_fungible_id: string()
})
)
})

export const NonFungibleDataIO = object({
address: string(),
non_fungible_id_type: string(),
Expand Down
15 changes: 13 additions & 2 deletions src/query-lib/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ export const getEntityDetails = makeQueries({
transformationFn: (res) => res
})

export const getNonFungibleIDs = makeQueries({
export const getEntityNonFungibleIDs = makeQueries({
fn: (params: { accountAddress: string; nftAddress: string }) =>
stateApi.entityNonFungibleIds({
entityNonFungibleIdsRequest: {
address: params.accountAddress,
resource_address: params.nftAddress
}
}),
decoder: (res) => decoders('NonFungibleIDsIO', res),
decoder: (res) => decoders('EntityNonFungibleIDsIO', res),
transformationFn: (res) => res
})

Expand All @@ -119,3 +119,14 @@ export const getNonFungibleData = makeQueries({
decoder: (res) => decoders('NonFungibleDataIO', res),
transformationFn: (res) => res
})

export const getNonFungibleIDs = makeQueries({
fn: (address: string) =>
stateApi.nonFungibleIds({
nonFungibleIdsRequest: {
address
}
}),
decoder: (res) => decoders('NonFungibleIDsIO', res),
transformationFn: (res) => res
})

0 comments on commit 283da1d

Please sign in to comment.