Skip to content
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@wharfkit/atomicassets",
"description": "AtomicAsset library for Wharf",
"version": "1.2.3",
"version": "1.2.4",
"homepage": "https://github.com/wharfkit/atomicassets",
"main": "lib/atomicassets.js",
"module": "lib/atomicassets.m.js",
Expand Down Expand Up @@ -62,4 +62,4 @@
"typedoc": "^0.23.14",
"typescript": "^4.4"
}
}
}
10 changes: 10 additions & 0 deletions src/endpoints/assets/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export class SchemaCount extends Struct {
@Struct.field(UInt64) declare assets: UInt64
}

@Struct.type('collection_schema')
export class CollectionSchema extends Struct {
@Struct.field(Name) declare schema_name: Name
}

@Struct.type('template_count')
export class TemplateCount extends Struct {
@Struct.field(Int32) declare template_id: Int32
Expand Down Expand Up @@ -82,6 +87,11 @@ export class GetCollectionStatsResponse extends ResponseStruct {
@Struct.field(CollectionStats) declare data: CollectionStats
}

@Struct.type('get_collection_schemas_resp')
export class GetCollectionSchemasResponse extends ResponseStruct {
@Struct.field(CollectionSchema, {array: true}) declare data: CollectionSchema[]
}

@Struct.type('get_schemas_resp')
export class GetSchemasResponse extends ResponseStruct {
@Struct.field(SchemaObject, {array: true}) declare data: SchemaObject[]
Expand Down
73 changes: 49 additions & 24 deletions src/endpoints/assets/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export interface GetAssetsOptions {
collection_whitelist?: NameType[]
only_duplicate_templates?: boolean
has_backed_tokens?: boolean
has_template_buyoffer?: boolean
template_mint?: UInt32Type
min_template_mint?: UInt32Type
max_template_mint?: UInt32Type
authorized_account?: NameType
template_whitelist?: Int32Type[]
template_blacklist?: Int32Type[]
Expand All @@ -45,12 +49,13 @@ export interface GetAssetsOptions {
export interface GetCollectionsOptions {
author?: NameType[]
match?: string
search?: string
authorized_account?: NameType
notify_account?: NameType
collection_blacklist?: NameType[]
collection_whitelist?: NameType[]
collection_name?: NameType[]
ids?: UInt64Type[]
ids?: NameType[]
lower_bound?: string
upper_bound?: string
before?: number
Expand All @@ -68,7 +73,7 @@ export interface GetSchemasOptions {
match?: string
collection_blacklist?: NameType[]
collection_whitelist?: NameType[]
ids?: UInt64Type[]
ids?: NameType[]
lower_bound?: string
upper_bound?: string
before?: number
Expand All @@ -91,6 +96,7 @@ export interface GetTemplatesOptions {
is_transferable?: boolean
authorized_account?: NameType
match?: string
search?: string
collection_blacklist?: NameType[]
collection_whitelist?: NameType[]
template_id?: Int32Type[]
Expand Down Expand Up @@ -127,8 +133,8 @@ export interface GetOffersOptions {
collection_whitelist?: NameType[]
hide_contracts?: boolean
hide_empty_offers?: boolean
offer_id?: UInt64Type
ids?: UInt64Type
offer_id?: UInt64Type[]
ids?: UInt64Type[]
lower_bound?: string
upper_bound?: string
before?: number
Expand Down Expand Up @@ -174,12 +180,28 @@ export interface GetAccountsOptions {
collection_blacklist?: NameType[]
collection_whitelist?: NameType[]
owner?: NameType[]
ids?: UInt64Type[]
ids?: NameType[]
lower_bound?: string
upper_bound?: string
page?: number
limit?: number
}

export interface GetBurnsOptions {
match_owner?: string
collection_name?: NameType[]
schema_name?: NameType[]
template_id?: Int32Type[]
burned?: boolean
hide_offers?: boolean
collection_blacklist?: NameType[]
collection_whitelist?: NameType[]
burned_by_account?: NameType[]
ids?: NameType[]
lower_bound?: string
upper_bound?: string
page?: number
limit?: number
order?: 'asc' | 'desc'
}

export class AssetsV1APIClient {
Expand Down Expand Up @@ -286,6 +308,14 @@ export class AssetsV1APIClient {
})
}

async get_collection_schemas(collection_name: NameType) {
return this.client.call({
path: `/atomicassets/v1/collections/${collection_name}/schemas`,
method: 'GET',
responseType: Assets.GetCollectionSchemasResponse,
})
}

async get_collection_logs(
collection_name: NameType,
options?: {
Expand Down Expand Up @@ -404,9 +434,19 @@ export class AssetsV1APIClient {
})
}

async get_template_stats(collection_name: NameType, template_id: Int32Type) {
async get_template_stats(template_id: Int32Type): Promise<any>
async get_template_stats(collection_name: NameType, template_id: Int32Type): Promise<any>
async get_template_stats(
collection_name_or_template_id: NameType | Int32Type,
template_id?: Int32Type
) {
const path =
typeof template_id === 'undefined'
? `/atomicassets/v1/templates/${collection_name_or_template_id}/stats`
: `/atomicassets/v1/templates/${collection_name_or_template_id}/${template_id}/stats`

return this.client.call({
path: `/atomicassets/v1/templates/${collection_name}/${template_id}/stats`,
path,
method: 'GET',
responseType: Assets.GetTemplateStatsResponse,
})
Expand Down Expand Up @@ -562,22 +602,7 @@ export class AssetsV1APIClient {
})
}

async get_burns(options?: {
match_owner?: string
collection_name?: NameType[]
schema_name?: NameType[]
template_id?: Int32Type[]
burned?: boolean
collection_blacklist?: NameType[]
collection_whitelist?: NameType[]
burned_by_account?: NameType[]
ids?: UInt64Type[]
lower_bound?: string
upper_bound?: string
page?: number
limit?: number
order?: 'asc' | 'desc'
}) {
async get_burns(options?: GetBurnsOptions) {
const bodyParams = buildBodyParams(options)

return this.client.call({
Expand Down
9 changes: 5 additions & 4 deletions src/endpoints/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export class CollectionObject extends Struct {
@Struct.type('schema_object')
export class SchemaObject extends Struct {
@Struct.field(Name) declare schema_name: Name
@Struct.field(UInt64, {optional: true}) declare assets: UInt64
@Struct.field(AtomicAssetsContract.Types.FORMAT, {array: true})
declare format: AtomicAssetsContract.Types.FORMAT[]
@Struct.field(Name, {optional: true}) declare contract: Name
Expand Down Expand Up @@ -505,8 +506,8 @@ export class BurnedBySchema extends Struct {

@Struct.type('collection_stats')
export class CollectionStats extends Struct {
@Struct.field(UInt64) declare assets: UInt64
@Struct.field(UInt64) declare burned: UInt64
@Struct.field(UInt64, {optional: true}) declare assets: UInt64
@Struct.field(UInt64, {optional: true}) declare burned: UInt64
@Struct.field(UInt64) declare templates: UInt64
@Struct.field(UInt64) declare schemas: UInt64
@Struct.field(BurnedByTemplate, {array: true})
Expand All @@ -528,8 +529,8 @@ export class TemplateStats extends Struct {

@Struct.type('schema_stats')
export class SchemaStats extends Struct {
@Struct.field(UInt64) declare assets: UInt64
@Struct.field(UInt64) declare burned: UInt64
@Struct.field(UInt64, {optional: true}) declare assets: UInt64
@Struct.field(UInt64, {optional: true}) declare burned: UInt64
@Struct.field(UInt64) declare templates: UInt64
}

Expand Down
2 changes: 1 addition & 1 deletion src/endpoints/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function buildBodyParams(
export function fixPostArguments(params) {
// https://github.com/pinknetworkx/eosio-contract-api/issues/131
const options = {...params}
for (const key of ['page', 'limit', 'before', 'after'])
for (const key of ['page', 'limit', 'before', 'after', 'burned'])
if (key in options) {
options[key] = String(options[key])
}
Expand Down
6 changes: 5 additions & 1 deletion src/objects/schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {Action, NameType} from '@wharfkit/antelope'
import {Name} from '@wharfkit/antelope'
import {Name, UInt64} from '@wharfkit/antelope'
import type {SchemaObject} from '../types'
import {Collection} from './collection'
import type * as AtomicAssetsContract from '../contracts/atomicassets'
Expand All @@ -25,6 +25,10 @@ export class Schema {
return Name.from(this.data.schema_name)
}

get assets() {
return UInt64.from(this.data.assets)
}

get format() {
return this.data.format
}
Expand Down
4 changes: 4 additions & 0 deletions test/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ suite('Schema', function () {
assert.isTrue(testSchema.schemaName.equals(schemaName))
})

test('assets', function () {
assert.isTrue(testSchema.assets.toNumber() > 0)
})

test('collection', function () {
assert.isTrue(testSchema.collection.collectionName.equals(collectionName))
})
Expand Down
Loading
Loading