atomicassets
Advanced tools
Comparing version 1.3.1 to 1.4.0
import ExplorerActionGenerator from '../../Actions/Explorer'; | ||
import { ApiAsset, ApiCollection, ApiConfig, ApiLog, ApiOffer, ApiSchema, ApiSchemaStats, ApiTemplate, ApiTemplateStats, ApiTransfer } from './Types'; | ||
import { IAccountCollectionStats, IAccountStats, IAsset, IAssetStats, ICollection, ICollectionStats, IConfig, ILog, IOffer, ISchema, ISchemaStats, ITemplate, ITemplateStats, ITransfer } from './Objects'; | ||
import { AccountApiParams, AssetsApiParams, CollectionApiParams, GreylistParams, HideOffersParams, OfferApiParams, SchemaApiParams, TemplateApiParams, TransferApiParams } from './Params'; | ||
declare type Fetch = (input?: Request | string, init?: RequestInit) => Promise<Response>; | ||
@@ -8,89 +9,7 @@ declare type ApiArgs = { | ||
}; | ||
interface GreylistParams { | ||
collection_blacklist?: string; | ||
collection_whitelist?: string; | ||
} | ||
interface HideOffersParams { | ||
hide_offers?: boolean; | ||
hide_sales?: boolean; | ||
} | ||
interface PrimaryBoundaryParams { | ||
ids?: string; | ||
lower_bound?: string; | ||
upper_bound?: string; | ||
} | ||
interface DateBoundaryParams { | ||
before?: number; | ||
after?: number; | ||
} | ||
export interface AssetParams extends GreylistParams, HideOffersParams, PrimaryBoundaryParams, DateBoundaryParams { | ||
owner?: string; | ||
burned?: boolean; | ||
collection_name?: string; | ||
schema_name?: string; | ||
template_id?: number; | ||
match?: string; | ||
authorized_account?: string; | ||
is_transferable?: boolean; | ||
is_burnable?: boolean; | ||
only_duplicate_templates?: boolean; | ||
order?: string; | ||
sort?: string; | ||
[key: string]: any; | ||
} | ||
export interface CollectionParams extends GreylistParams, PrimaryBoundaryParams, DateBoundaryParams { | ||
author?: string; | ||
match?: string; | ||
authorized_account?: string; | ||
notify_account?: string; | ||
order?: string; | ||
sort?: string; | ||
} | ||
export interface SchemaParams extends GreylistParams, PrimaryBoundaryParams, DateBoundaryParams { | ||
collection_name?: string; | ||
schema_name?: string; | ||
match?: string; | ||
authorized_account?: string; | ||
order?: string; | ||
sort?: string; | ||
} | ||
export interface TemplateParams extends GreylistParams, PrimaryBoundaryParams, DateBoundaryParams { | ||
collection_name?: string; | ||
schema_name?: string; | ||
authorized_account?: string; | ||
template_id?: string; | ||
max_supply?: number; | ||
issued_supply?: number; | ||
is_transferable?: boolean; | ||
is_burnable?: boolean; | ||
order?: string; | ||
sort?: string; | ||
[key: string]: any; | ||
} | ||
export interface TransferParams extends GreylistParams, PrimaryBoundaryParams, DateBoundaryParams { | ||
account?: string; | ||
sender?: string; | ||
recipient?: string; | ||
asset_id?: string; | ||
order?: string; | ||
sort?: string; | ||
} | ||
export interface OfferParams extends GreylistParams, PrimaryBoundaryParams, DateBoundaryParams { | ||
account?: string; | ||
sender?: string; | ||
recipient?: string; | ||
is_recipient_contract?: boolean; | ||
asset_id?: string; | ||
order?: string; | ||
sort?: string; | ||
} | ||
export interface AccountParams extends GreylistParams, PrimaryBoundaryParams, DateBoundaryParams { | ||
match?: string; | ||
collection_name?: string; | ||
schema_name?: string; | ||
template_id?: string; | ||
} | ||
export declare type DataOptions = { | ||
[key: string]: any; | ||
}; | ||
export declare type DataOptions = Array<{ | ||
key: string; | ||
value: any; | ||
type?: string; | ||
}>; | ||
export default class ExplorerApi { | ||
@@ -102,64 +21,43 @@ readonly action: Promise<ExplorerActionGenerator>; | ||
constructor(endpoint: string, namespace: string, args: ApiArgs); | ||
getConfig(): Promise<ApiConfig>; | ||
getAssets(options?: AssetParams, page?: number, limit?: number, data?: DataOptions): Promise<ApiAsset[]>; | ||
countAssets(options: AssetParams, data?: DataOptions): Promise<number>; | ||
getAsset(id: string): Promise<ApiAsset>; | ||
getAssetStats(id: string): Promise<ApiAsset>; | ||
getAssetLogs(id: string, page?: number, limit?: number, order?: string): Promise<ApiLog[]>; | ||
getCollections(options?: CollectionParams, page?: number, limit?: number): Promise<ApiCollection[]>; | ||
countCollections(options?: CollectionParams): Promise<number>; | ||
getCollection(name: string): Promise<ApiCollection>; | ||
getCollectionStats(name: string): Promise<ApiCollection>; | ||
getCollectionLogs(name: string, page?: number, limit?: number, order?: string): Promise<ApiLog[]>; | ||
getSchemas(options?: SchemaParams, page?: number, limit?: number): Promise<ApiSchema[]>; | ||
countSchemas(options?: SchemaParams): Promise<number>; | ||
getSchema(collection: string, name: string): Promise<ApiSchema>; | ||
getSchemaStats(collection: string, name: string): Promise<ApiSchemaStats>; | ||
getSchemaLogs(collection: string, name: string, page?: number, limit?: number, order?: string): Promise<ApiLog[]>; | ||
getTemplates(options?: TemplateParams, page?: number, limit?: number, data?: DataOptions): Promise<ApiTemplate[]>; | ||
countTemplates(options?: TemplateParams, data?: DataOptions): Promise<number>; | ||
getTemplate(collection: string, id: string): Promise<ApiTemplate>; | ||
getTemplateStats(collection: string, name: string): Promise<ApiTemplateStats>; | ||
getTemplateLogs(collection: string, id: string, page?: number, limit?: number, order?: string): Promise<ApiLog[]>; | ||
getTransfers(options?: TransferParams, page?: number, limit?: number): Promise<ApiTransfer[]>; | ||
countTransfers(options?: TransferParams): Promise<number>; | ||
getOffers(options?: OfferParams, page?: number, limit?: number): Promise<ApiOffer[]>; | ||
countOffers(options?: OfferParams): Promise<number>; | ||
getOffer(id: string): Promise<ApiOffer>; | ||
getAccounts(options?: AccountParams, page?: number, limit?: number): Promise<Array<{ | ||
getConfig(): Promise<IConfig>; | ||
getAssets(options?: AssetsApiParams, page?: number, limit?: number, data?: DataOptions): Promise<IAsset[]>; | ||
countAssets(options: AssetsApiParams, data?: DataOptions): Promise<number>; | ||
getAsset(id: string): Promise<IAsset>; | ||
getAssetStats(id: string): Promise<IAssetStats>; | ||
getAssetLogs(id: string, page?: number, limit?: number, order?: string): Promise<ILog[]>; | ||
getCollections(options?: CollectionApiParams, page?: number, limit?: number): Promise<ICollection[]>; | ||
countCollections(options?: CollectionApiParams): Promise<number>; | ||
getCollection(name: string): Promise<ICollection>; | ||
getCollectionStats(name: string): Promise<ICollectionStats>; | ||
getCollectionLogs(name: string, page?: number, limit?: number, order?: string): Promise<ILog[]>; | ||
getSchemas(options?: SchemaApiParams, page?: number, limit?: number): Promise<ISchema[]>; | ||
countSchemas(options?: SchemaApiParams): Promise<number>; | ||
getSchema(collection: string, name: string): Promise<ISchema>; | ||
getSchemaStats(collection: string, name: string): Promise<ISchemaStats>; | ||
getSchemaLogs(collection: string, name: string, page?: number, limit?: number, order?: string): Promise<ILog[]>; | ||
getTemplates(options?: TemplateApiParams, page?: number, limit?: number, data?: DataOptions): Promise<ITemplate[]>; | ||
countTemplates(options?: TemplateApiParams, data?: DataOptions): Promise<number>; | ||
getTemplate(collection: string, id: string): Promise<ITemplate>; | ||
getTemplateStats(collection: string, name: string): Promise<ITemplateStats>; | ||
getTemplateLogs(collection: string, id: string, page?: number, limit?: number, order?: string): Promise<ILog[]>; | ||
getTransfers(options?: TransferApiParams, page?: number, limit?: number): Promise<ITransfer[]>; | ||
countTransfers(options?: TransferApiParams): Promise<number>; | ||
getOffers(options?: OfferApiParams, page?: number, limit?: number): Promise<IOffer[]>; | ||
countOffers(options?: OfferApiParams): Promise<number>; | ||
getOffer(id: string): Promise<IOffer>; | ||
getAccounts(options?: AccountApiParams, page?: number, limit?: number): Promise<Array<{ | ||
account: string; | ||
assets: string; | ||
}>>; | ||
getBurns(options?: AccountParams, page?: number, limit?: number): Promise<Array<{ | ||
getBurns(options?: AccountApiParams, page?: number, limit?: number): Promise<Array<{ | ||
account: string; | ||
assets: string; | ||
}>>; | ||
countAccounts(options?: AccountParams): Promise<number>; | ||
getAccount(account: string, options?: GreylistParams & HideOffersParams): Promise<{ | ||
assets: string; | ||
collections: Array<{ | ||
collection: ApiCollection; | ||
assets: string; | ||
}>; | ||
}>; | ||
getAccountCollection(account: string, collection: string): Promise<{ | ||
templates: Array<{ | ||
template_id: string; | ||
assets: string; | ||
}>; | ||
schemas: Array<{ | ||
schema_name: string; | ||
assets: string; | ||
}>; | ||
}>; | ||
getAccountBurns(account: string, options?: GreylistParams & HideOffersParams): Promise<{ | ||
assets: string; | ||
collections: Array<{ | ||
collection: ApiCollection; | ||
assets: string; | ||
}>; | ||
}>; | ||
fetchEndpoint(path: string, args: any): Promise<any>; | ||
countAccounts(options?: AccountApiParams): Promise<number>; | ||
getAccount(account: string, options?: GreylistParams & HideOffersParams): Promise<IAccountStats>; | ||
getAccountCollection(account: string, collection: string): Promise<IAccountCollectionStats>; | ||
getAccountBurns(account: string, options?: GreylistParams & HideOffersParams): Promise<IAccountStats>; | ||
fetchEndpoint<T>(path: string, args: any): Promise<T>; | ||
countEndpoint(path: string, args: any): Promise<number>; | ||
} | ||
export {}; |
@@ -9,13 +9,14 @@ "use strict"; | ||
function buildDataOptions(options, data) { | ||
const dataKeys = Object.keys(data); | ||
var _a; | ||
const dataFields = {}; | ||
for (const key of dataKeys) { | ||
if (typeof data[key] === 'number') { | ||
dataFields['data:number.' + key] = data[key]; | ||
for (const row of data) { | ||
const dataType = (_a = row.type) !== null && _a !== void 0 ? _a : 'data'; | ||
if (typeof row.value === 'number') { | ||
dataFields[dataType + ':number.' + row.key] = String(row.value); | ||
} | ||
else if (typeof data[key] === 'boolean') { | ||
dataFields['data:bool.' + key] = data[key]; | ||
else if (typeof row.value === 'boolean') { | ||
dataFields[dataType + ':bool.' + row.key] = row.value ? 'true' : 'false'; | ||
} | ||
else { | ||
dataFields['data.' + key] = data[key]; | ||
dataFields[dataType + '.' + row.key] = row.value; | ||
} | ||
@@ -42,6 +43,6 @@ } | ||
} | ||
async getAssets(options = {}, page = 1, limit = 100, data = {}) { | ||
async getAssets(options = {}, page = 1, limit = 100, data = []) { | ||
return await this.fetchEndpoint('/v1/assets', Object.assign({ page, limit }, buildDataOptions(options, data))); | ||
} | ||
async countAssets(options, data = {}) { | ||
async countAssets(options, data = []) { | ||
return await this.countEndpoint('/v1/assets', buildDataOptions(options, data)); | ||
@@ -88,6 +89,6 @@ } | ||
} | ||
async getTemplates(options = {}, page = 1, limit = 100, data = {}) { | ||
async getTemplates(options = {}, page = 1, limit = 100, data = []) { | ||
return await this.fetchEndpoint('/v1/templates', Object.assign({ page, limit }, buildDataOptions(options, data))); | ||
} | ||
async countTemplates(options = {}, data = {}) { | ||
async countTemplates(options = {}, data = []) { | ||
return await this.countEndpoint('/v1/templates', buildDataOptions(options, data)); | ||
@@ -94,0 +95,0 @@ } |
@@ -12,3 +12,3 @@ { | ||
"license": "MIT", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"main": "build/index.js", | ||
@@ -15,0 +15,0 @@ "types": "build/index.d.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
154252
92
3544