Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

atomicassets

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atomicassets - npm Package Compare versions

Comparing version 0.8.1 to 0.9.0

37

build/API/Explorer/index.d.ts
import ExplorerActionGenerator from '../../Actions/Explorer';
import { ApiAsset, ApiCollection, ApiConfig, ApiLog, ApiOffer, ApiSchema, ApiTemplate, ApiTransfer } from './types';
import { ApiAsset, ApiCollection, ApiConfig, ApiLog, ApiOffer, ApiSchema, ApiSchemaStats, ApiTemplate, ApiTemplateStats, ApiTransfer } from './types';
declare type Fetch = (input?: Request | string, init?: RequestInit) => Promise<Response>;

@@ -25,5 +25,7 @@ declare type ApiArgs = {

[key: string]: any;
}, page?: number, limit?: number): Promise<ApiAsset[]>;
}, page?: number, limit?: number, data?: {
[key: string]: any;
}): Promise<ApiAsset[]>;
getAsset(id: string): Promise<ApiAsset>;
getAssetLogs(id: string, page?: number, limit?: number): Promise<ApiLog[]>;
getAssetLogs(id: string, page?: number, limit?: number, order?: string): Promise<ApiLog[]>;
getCollections(options?: {

@@ -38,5 +40,6 @@ author?: string;

getCollection(name: string): Promise<ApiCollection>;
getCollectionLogs(name: string, page?: number, limit?: number): Promise<ApiLog[]>;
getCollectionLogs(name: string, page?: number, limit?: number, order?: string): Promise<ApiLog[]>;
getSchemas(options?: {
collection_name?: string;
schema_name?: string;
match?: string;

@@ -48,13 +51,18 @@ authorized_account?: string;

getSchema(collection: string, name: string): Promise<ApiSchema>;
getSchemaLogs(collection: string, name: string, page?: number, limit?: number): Promise<ApiLog[]>;
getTemplates(options?: {
collection_name?: string;
schema_name?: string;
authorized_account?: string;
order?: string;
sort?: string;
getSchemaStats(collection: string, name: string): Promise<ApiSchemaStats>;
getSchemaLogs(collection: string, name: string, page?: number, limit?: number, order?: string): Promise<ApiLog[]>;
getTemplates(options: {
[key: string]: any;
}, page?: number, limit?: number): Promise<ApiTemplate[]>;
collection_name?: string | undefined;
schema_name?: string | undefined;
authorized_account?: string | undefined;
template_id?: string | undefined;
order?: string | undefined;
sort?: string | undefined;
} | undefined, page: number | undefined, limit: number | undefined, data: {
[key: string]: any;
}): Promise<ApiTemplate[]>;
getTemplate(collection: string, id: string): Promise<ApiTemplate>;
getTemplateLogs(collection: string, id: string, page?: number, limit?: number): Promise<ApiLog[]>;
getTemplateStats(collection: string, name: string): Promise<ApiTemplateStats>;
getTemplateLogs(collection: string, id: string, page?: number, limit?: number, order?: string): Promise<ApiLog[]>;
getTransfers(options?: {

@@ -64,2 +72,3 @@ account?: string;

recipient?: string;
asset_id?: string;
order?: string;

@@ -72,2 +81,4 @@ sort?: string;

recipient?: string;
is_recipient_contract?: boolean;
asset_id?: string;
order?: string;

@@ -74,0 +85,0 @@ sort?: string;

@@ -25,4 +25,8 @@ "use strict";

}
async getAssets(options = {}, page = 1, limit = 100) {
return await this.fetchEndpoint('/v1/assets', { page, limit, ...options });
async getAssets(options = {}, page = 1, limit = 100, data = {}) {
const dataKeys = Object.keys(data);
for (const key of dataKeys) {
options['data.' + key] = data[key];
}
return await this.fetchEndpoint('/v1/assets', Object.assign({ page, limit }, options));
}

@@ -32,7 +36,7 @@ async getAsset(id) {

}
async getAssetLogs(id, page = 1, limit = 100) {
return await this.fetchEndpoint('/v1/assets/' + id + '/logs', { page, limit });
async getAssetLogs(id, page = 1, limit = 100, order = 'desc') {
return await this.fetchEndpoint('/v1/assets/' + id + '/logs', { page, limit, order });
}
async getCollections(options = {}, page = 1, limit = 100) {
return await this.fetchEndpoint('/v1/collections', { page, limit, ...options });
return await this.fetchEndpoint('/v1/collections', Object.assign({ page, limit }, options));
}

@@ -42,7 +46,7 @@ async getCollection(name) {

}
async getCollectionLogs(name, page = 1, limit = 100) {
return await this.fetchEndpoint('/v1/collections/' + name + '/logs', { page, limit });
async getCollectionLogs(name, page = 1, limit = 100, order = 'desc') {
return await this.fetchEndpoint('/v1/collections/' + name + '/logs', { page, limit, order });
}
async getSchemas(options = {}, page = 1, limit = 100) {
return await this.fetchEndpoint('/v1/schemas', { page, limit, ...options });
return await this.fetchEndpoint('/v1/schemas', Object.assign({ page, limit }, options));
}

@@ -52,19 +56,29 @@ async getSchema(collection, name) {

}
async getSchemaLogs(collection, name, page = 1, limit = 100) {
return await this.fetchEndpoint('/v1/schemas/' + collection + '/' + name + '/logs', { page, limit });
async getSchemaStats(collection, name) {
return await this.fetchEndpoint('/v1/schemas/' + collection + '/' + name + '/stats', {});
}
async getTemplates(options = {}, page = 1, limit = 100) {
return await this.fetchEndpoint('/v1/templates', { page, limit, ...options });
async getSchemaLogs(collection, name, page = 1, limit = 100, order = 'desc') {
return await this.fetchEndpoint('/v1/schemas/' + collection + '/' + name + '/logs', { page, limit, order });
}
async getTemplates(options = {}, page = 1, limit = 100, data) {
const dataKeys = Object.keys(data);
for (const key of dataKeys) {
options['data.' + key] = data[key];
}
return await this.fetchEndpoint('/v1/templates', Object.assign({ page, limit }, options));
}
async getTemplate(collection, id) {
return await this.fetchEndpoint('/v1/templates/' + collection + '/' + id, {});
}
async getTemplateLogs(collection, id, page = 1, limit = 100) {
return await this.fetchEndpoint('/v1/templates/' + collection + '/' + id + '/logs', { page, limit });
async getTemplateStats(collection, name) {
return await this.fetchEndpoint('/v1/templates/' + collection + '/' + name + '/stats', {});
}
async getTemplateLogs(collection, id, page = 1, limit = 100, order = 'desc') {
return await this.fetchEndpoint('/v1/templates/' + collection + '/' + id + '/logs', { page, limit, order });
}
async getTransfers(options = {}, page = 1, limit = 100) {
return await this.fetchEndpoint('/v1/transfers', { page, limit, ...options });
return await this.fetchEndpoint('/v1/transfers', Object.assign({ page, limit }, options));
}
async getOffers(options = {}, page = 1, limit = 100) {
return await this.fetchEndpoint('/v1/offers', { page, limit, ...options });
return await this.fetchEndpoint('/v1/offers', Object.assign({ page, limit }, options));
}

@@ -76,3 +90,3 @@ async getOffer(id) {

let response;
let json;
let json = null;
try {

@@ -84,3 +98,5 @@ const f = this.fetchBuiltin;

response = await f(this.endpoint + '/' + this.namespace + path + (queryString.length > 0 ? '?' + queryString : ''));
json = await response.json();
if (response.status === 200) {
json = await response.json();
}
}

@@ -91,2 +107,5 @@ catch (e) {

}
if (json === null) {
throw new Error('Invalid status code received');
}
if (!json.success) {

@@ -93,0 +112,0 @@ throw new ExplorerError_1.default(json.message);

@@ -93,2 +93,6 @@ import { SchemaObject } from '../../Schema';

};
export declare type ApiSchemaStats = {
assets: number;
templates: number;
};
export declare type ApiTemplate = {

@@ -124,2 +128,5 @@ contract: string;

};
export declare type ApiTemplateStats = {
assets: number;
};
export declare type ApiOffer = {

@@ -162,2 +169,7 @@ contract: string;

collection_format: SchemaObject[];
supported_tokens: Array<{
token_contract: string;
token_symbol: string;
token_precision: number;
}>;
};

@@ -8,2 +8,3 @@ import { IAssetRow } from './Cache';

private readonly api;
readonly owner: string;
readonly id: string;

@@ -10,0 +11,0 @@ private readonly _data;

@@ -13,2 +13,3 @@ "use strict";

this.api = api;
this.owner = owner;
this.id = id;

@@ -21,3 +22,3 @@ this._data = new Promise(async (resolve, reject) => {

try {
resolve(await api.queue.asset(owner, id, cache));
resolve(await api.queue.fetchAsset(owner, id, cache));
}

@@ -24,0 +25,0 @@ catch (e) {

@@ -20,3 +20,2 @@ export declare type SchemaFormat = Array<{

template_id: number;
collection_name: string;
schema_name: string;

@@ -53,13 +52,16 @@ transferable: boolean;

export default class RpcCache {
private readonly assets;
private readonly templates;
private readonly schemas;
private readonly collections;
private readonly offers;
private static access;
asset(assetID: string, data?: any | null | false): IAssetRow | undefined;
template(templateID: string, data?: any | null | false): ITemplateRow | undefined;
schema(schema: string, data?: any | null | false): ISchemaRow | undefined;
collection(collection: string, data?: any | null | false): ICollectionRow | undefined;
offer(offerID: string, data?: any | null | false): IOfferRow | undefined;
private readonly cache;
constructor();
getAsset(assetID: string, data?: IAssetRow): IAssetRow | null;
deleteAsset(assetID: string): void;
getTemplate(collectionName: string, templateID: string, data?: ITemplateRow): ITemplateRow | null;
deleteTemplate(collectionName: string, templateID: string): void;
getSchema(collectionName: string, schemaName: string, data?: ISchemaRow): ISchemaRow | null;
deleteSchema(collectionName: string, schemaName: string): void;
getCollection(collectionName: string, data?: ICollectionRow): ICollectionRow | null;
deleteCollection(collectionName: string): void;
getOffer(offerID: string, data?: IOfferRow): IOfferRow | null;
deleteOffer(offerID: string): void;
private access;
private delete;
}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
// @ts-ignore
const pure_cache_1 = __importDefault(require("pure-cache"));
class RpcCache {
constructor() {
this.assets = {};
this.templates = {};
this.schemas = {};
this.collections = {};
this.offers = {};
this.cache = new pure_cache_1.default({ expiryCheckInterval: 60 * 1000 });
}
static access(identifier, cache, data) {
if (data === null) {
delete cache[String(identifier)];
return;
}
getAsset(assetID, data) {
if (data) {
cache[String(identifier)] = { expiration: Date.now() + 15 * 60 * 1000, updated: Date.now(), data };
return data;
}
if (typeof cache[String(identifier)] === 'undefined' || cache[String(identifier)].expiration < Date.now()) {
return;
}
// if data is false then only return cache if it is not older than 5 seconds
if (data === false && Date.now() - cache[String(identifier)].updated > 5 * 1000) {
return;
}
return cache[String(identifier)].data;
}
asset(assetID, data) {
if (data) {
data.mutable_serialized_data = new Uint8Array(data.mutable_serialized_data);
data.immutable_serialized_data = new Uint8Array(data.immutable_serialized_data);
}
return RpcCache.access(assetID, this.assets, data);
return this.access('assets', assetID, data);
}
template(templateID, data) {
deleteAsset(assetID) {
this.delete('assets', assetID);
}
getTemplate(collectionName, templateID, data) {
if (data) {
data.immutable_serialized_data = new Uint8Array(data.immutable_serialized_data);
}
return RpcCache.access(templateID, this.templates, data);
return this.access('templates', collectionName + ':' + templateID, data);
}
schema(schema, data) {
return RpcCache.access(schema, this.schemas, data);
deleteTemplate(collectionName, templateID) {
this.delete('templates', collectionName + ':' + templateID);
}
collection(collection, data) {
return RpcCache.access(collection, this.collections, data);
getSchema(collectionName, schemaName, data) {
return this.access('schemas', collectionName + ':' + schemaName, data);
}
offer(offerID, data) {
return RpcCache.access(offerID, this.offers, data);
deleteSchema(collectionName, schemaName) {
this.delete('schemas', collectionName + ':' + schemaName);
}
getCollection(collectionName, data) {
return this.access('collections', collectionName, data);
}
deleteCollection(collectionName) {
this.delete('collections', collectionName);
}
getOffer(offerID, data) {
return this.access('offers', offerID, data);
}
deleteOffer(offerID) {
this.delete('offers', offerID);
}
access(namespace, identifier, data) {
if (typeof data === 'undefined') {
const cache = this.cache.get(namespace + ':' + identifier);
return cache === null ? null : cache.value;
}
this.cache.put(namespace + ':' + identifier, data, 15 * 60 * 1000);
return data;
}
delete(namespace, identifier) {
this.cache.remove(namespace + ':' + identifier);
}
}
exports.default = RpcCache;

@@ -15,3 +15,3 @@ "use strict";

try {
resolve(await api.queue.collection(name, cache));
resolve(await api.queue.fetchCollection(name, cache));
}

@@ -18,0 +18,0 @@ catch (e) {

@@ -25,10 +25,10 @@ import RpcActionGenerator from '../../Actions/Rpc';

getAsset(owner: string, id: string, cache?: boolean): Promise<RpcAsset>;
getTemplate(collection: string, id: string, cache?: boolean): Promise<RpcTemplate>;
getCollection(name: string, cache?: boolean): Promise<RpcCollection>;
getCollectionTemplates(collection: string, cache?: boolean): Promise<RpcTemplate[]>;
getCollectionsSchemas(collection: string, cache?: boolean): Promise<RpcSchema[]>;
getSchema(collection: string, name: string, cache?: boolean): Promise<RpcSchema>;
getOffer(id: string, cache?: boolean): Promise<RpcOffer>;
getAccountOffers(account: string, cache?: boolean): Promise<RpcOffer[]>;
getAccountAssets(account: string, cache?: boolean): Promise<RpcAsset[]>;
getTemplate(collectionName: string, templateID: string, cache?: boolean): Promise<RpcTemplate>;
getCollection(collectionName: string, cache?: boolean): Promise<RpcCollection>;
getCollectionTemplates(collectionName: string): Promise<RpcTemplate[]>;
getCollectionsSchemas(collectionName: string): Promise<RpcSchema[]>;
getSchema(collectionName: string, schemaName: string, cache?: boolean): Promise<RpcSchema>;
getOffer(offerID: string, cache?: boolean): Promise<RpcOffer>;
getAccountOffers(account: string): Promise<RpcOffer[]>;
getAccountAssets(account: string): Promise<RpcAsset[]>;
getTableRows({ code, scope, table, table_key, lower_bound, upper_bound, index_position, key_type }: any): Promise<any>;

@@ -35,0 +35,0 @@ fetchRpc(path: string, body: any): Promise<any>;

@@ -48,48 +48,48 @@ "use strict";

if (!cache) {
this.cache.asset(id, null);
this.cache.deleteAsset(id);
}
return new Asset_1.default(this, owner, id, undefined, undefined, undefined, undefined, cache);
}
async getTemplate(collection, id, cache = true) {
async getTemplate(collectionName, templateID, cache = true) {
if (!cache) {
this.cache.template(id, null);
this.cache.deleteTemplate(collectionName, templateID);
}
return new Template_1.default(this, collection, id, undefined, undefined, cache);
return new Template_1.default(this, collectionName, templateID, undefined, undefined, cache);
}
async getCollection(name, cache = true) {
async getCollection(collectionName, cache = true) {
if (!cache) {
this.cache.collection(name, null);
this.cache.deleteCollection(collectionName);
}
return new Collection_1.default(this, name, undefined, cache);
return new Collection_1.default(this, collectionName, undefined, cache);
}
async getCollectionTemplates(collection, cache = true) {
return (await this.queue.collection_templates(collection)).map((templateRow) => {
return new Template_1.default(this, collection, String(templateRow.template_id), templateRow, undefined, cache);
async getCollectionTemplates(collectionName) {
return (await this.queue.fetchCollectionTemplates(collectionName)).map((templateRow) => {
return new Template_1.default(this, collectionName, String(templateRow.template_id), templateRow, undefined);
});
}
async getCollectionsSchemas(collection, cache = true) {
return (await this.queue.collection_schemas(collection)).map((schemaRow) => {
return new Schema_1.default(this, collection, schemaRow.schema_name, undefined, cache);
async getCollectionsSchemas(collectionName) {
return (await this.queue.fetchCollectionSchemas(collectionName)).map((schemaRow) => {
return new Schema_1.default(this, collectionName, schemaRow.schema_name, undefined);
});
}
async getSchema(collection, name, cache = true) {
async getSchema(collectionName, schemaName, cache = true) {
if (!cache) {
this.cache.schema(name, null);
this.cache.deleteSchema(collectionName, schemaName);
}
return new Schema_1.default(this, collection, name, undefined, cache);
return new Schema_1.default(this, collectionName, schemaName, undefined, cache);
}
async getOffer(id, cache = true) {
async getOffer(offerID, cache = true) {
if (!cache) {
this.cache.offer(id, null);
this.cache.deleteOffer(offerID);
}
return new Offer_1.default(this, id, undefined, undefined, undefined, cache);
return new Offer_1.default(this, offerID, undefined, undefined, undefined, cache);
}
async getAccountOffers(account, cache = true) {
return (await this.queue.account_offers(account)).map((offerRow) => {
return new Offer_1.default(this, offerRow.offer_id, offerRow, undefined, undefined, cache);
async getAccountOffers(account) {
return (await this.queue.fetchAccountOffers(account)).map((offerRow) => {
return new Offer_1.default(this, offerRow.offer_id, offerRow, undefined, undefined);
});
}
async getAccountAssets(account, cache = true) {
return (await this.queue.account_assets(account)).map((assetRow) => {
return new Asset_1.default(this, account, assetRow.asset_id, assetRow, undefined, undefined, undefined, cache);
async getAccountAssets(account) {
return (await this.queue.fetchAccountAssets(account)).map((assetRow) => {
return new Asset_1.default(this, account, assetRow.asset_id, assetRow, undefined, undefined, undefined);
});

@@ -96,0 +96,0 @@ }

@@ -17,3 +17,3 @@ "use strict";

try {
resolve(await this.api.queue.offer(id, cache));
resolve(await this.api.queue.fetchOffer(id, cache));
}

@@ -32,3 +32,3 @@ catch (e) {

const row = await this._data;
const inventory = await this.api.queue.account_assets(row.sender, cache);
const inventory = await this.api.queue.fetchAccountAssets(row.sender);
return resolve(row.sender_asset_ids.map((assetID) => {

@@ -51,3 +51,3 @@ const asset = inventory.find((assetRow) => assetRow.asset_id === assetID);

const row = await this._data;
const inventory = await this.api.queue.account_assets(row.recipient, cache);
const inventory = await this.api.queue.fetchAccountAssets(row.recipient);
return resolve(row.recipient_asset_ids.map((assetID) => {

@@ -54,0 +54,0 @@ const asset = inventory.find((assetRow) => assetRow.asset_id === assetID);

@@ -9,11 +9,11 @@ import { IAssetRow, ICollectionRow, IOfferRow, ISchemaRow, ITemplateRow } from './Cache';

constructor(api: RpcApi, requestLimit?: number);
asset(owner: string, id: string, useCache?: boolean): Promise<IAssetRow>;
account_assets(account: string, useCache?: boolean): Promise<IAssetRow[]>;
template(collection: string, id: string, useCache?: boolean): Promise<ITemplateRow>;
collection_templates(collection: string, useCache?: boolean): Promise<ITemplateRow[]>;
schema(collection: string, name: string, useCache?: boolean): Promise<ISchemaRow>;
collection_schemas(collection: string, useCache?: boolean): Promise<ISchemaRow[]>;
collection(name: string, useCache?: boolean): Promise<ICollectionRow>;
offer(id: string, useCache?: boolean): Promise<IOfferRow>;
account_offers(account: string, useCache?: boolean): Promise<IOfferRow[]>;
fetchAsset(owner: string, assetID: string, useCache?: boolean): Promise<IAssetRow>;
fetchAccountAssets(account: string): Promise<IAssetRow[]>;
fetchTemplate(collectionName: string, templateID: string, useCache?: boolean): Promise<ITemplateRow>;
fetchCollectionTemplates(collectionName: string): Promise<ITemplateRow[]>;
fetchSchema(collectionName: string, schemaName: string, useCache?: boolean): Promise<ISchemaRow>;
fetchCollectionSchemas(collectionName: string): Promise<ISchemaRow[]>;
fetchCollection(collectionName: string, useCache?: boolean): Promise<ICollectionRow>;
fetchOffer(offerID: string, useCache?: boolean): Promise<IOfferRow>;
fetchAccountOffers(account: string): Promise<IOfferRow[]>;
private dequeue;

@@ -20,0 +20,0 @@ private fetch_single_row;

@@ -14,32 +14,54 @@ "use strict";

}
async asset(owner, id, useCache = true) {
return this.fetch_single_row('assets', owner, id, this.api.cache.asset.bind(this.api.cache), useCache);
async fetchAsset(owner, assetID, useCache = true) {
return await this.fetch_single_row('assets', owner, assetID, (data) => {
return (useCache || typeof data !== 'undefined') ? this.api.cache.getAsset(assetID, data) : null;
});
}
async account_assets(account, useCache = true) {
return this.fetch_all_rows('assets', account, 'id', '', '', this.api.cache.asset.bind(this.api.cache), useCache);
async fetchAccountAssets(account) {
const rows = await this.fetch_all_rows('assets', account, 'asset_id');
return rows.map((asset) => {
return this.api.cache.getAsset(asset.asset_id, asset);
});
}
async template(collection, id, useCache = true) {
return this.fetch_single_row('templates', collection, id, this.api.cache.template.bind(this.api.cache), useCache);
async fetchTemplate(collectionName, templateID, useCache = true) {
return await this.fetch_single_row('templates', collectionName, templateID, (data) => {
return (useCache || typeof data !== 'undefined') ? this.api.cache.getTemplate(collectionName, templateID, data) : null;
});
}
async collection_templates(collection, useCache = true) {
return this.fetch_all_rows('templates', collection, 'template_id', '', '', this.api.cache.template.bind(this.api.cache), useCache);
async fetchCollectionTemplates(collectionName) {
const rows = await this.fetch_all_rows('templates', collectionName, 'template_id');
return rows.map((template) => {
return this.api.cache.getTemplate(collectionName, String(template.template_id), template);
});
}
async schema(collection, name, useCache = true) {
return this.fetch_single_row('schemas', collection, name, this.api.cache.schema.bind(this.api.cache), useCache);
async fetchSchema(collectionName, schemaName, useCache = true) {
return await this.fetch_single_row('schemas', collectionName, schemaName, (data) => {
return (useCache || typeof data !== 'undefined') ? this.api.cache.getSchema(collectionName, schemaName, data) : null;
});
}
async collection_schemas(collection, useCache = true) {
return this.fetch_all_rows('schemas', collection, 'schema_name', '', '', this.api.cache.schema.bind(this.api.cache), useCache);
async fetchCollectionSchemas(collectionName) {
const rows = await this.fetch_all_rows('schemas', collectionName, 'schema_name');
return rows.map((schema) => {
return this.api.cache.getSchema(collectionName, schema.schema_name, schema);
});
}
async collection(name, useCache = true) {
return this.fetch_single_row('collections', this.api.contract, name, this.api.cache.collection.bind(this.api.cache), useCache);
async fetchCollection(collectionName, useCache = true) {
return await this.fetch_single_row('collections', this.api.contract, collectionName, (data) => {
return (useCache || typeof data !== 'undefined') ? this.api.cache.getCollection(collectionName, data) : null;
});
}
async offer(id, useCache = true) {
return this.fetch_single_row('offers', this.api.contract, id, this.api.cache.offer.bind(this.api.cache), useCache);
async fetchOffer(offerID, useCache = true) {
return await this.fetch_single_row('offers', this.api.contract, offerID, (data) => {
return (useCache || typeof data !== 'undefined') ? this.api.cache.getOffer(offerID, data) : null;
});
}
async account_offers(account, useCache = true) {
async fetchAccountOffers(account) {
const rows = await Promise.all([
this.fetch_all_rows('offers', this.api.contract, 'offer_sender', account, account, this.api.cache.offer.bind(this.api.cache), useCache, 2, 'name'),
this.fetch_all_rows('offers', this.api.contract, 'offer_recipient', account, account, this.api.cache.offer.bind(this.api.cache), useCache, 3, 'name')
this.fetch_all_rows('offers', this.api.contract, 'offer_sender', account, account, 2, 'name'),
this.fetch_all_rows('offers', this.api.contract, 'offer_recipient', account, account, 3, 'name')
]);
return rows[0].concat(rows[1]);
const offers = rows[0].concat(rows[1]);
return offers.map((offer) => {
return this.api.cache.getOffer(offer.offer_id, offer);
});
}

@@ -60,14 +82,11 @@ dequeue() {

}
async fetch_single_row(table, scope, match, cache = null, useCache = true, indexPosition = 1, keyType = '') {
let data = cache(match, useCache ? undefined : false);
async fetch_single_row(table, scope, match, cacheFn, indexPosition = 1, keyType = '') {
return new Promise((resolve, reject) => {
if (data) {
let data = cacheFn();
if (data !== null) {
return resolve(data);
}
this.elements.push(async () => {
data = cache(match, useCache ? undefined : false);
if (data) {
if (this.elements.length > 0) {
this.elements.shift()();
}
data = cacheFn();
if (data !== null) {
return resolve(data);

@@ -81,6 +100,6 @@ }

});
if (resp.rows.length !== 1) {
if (resp.rows.length === 0) {
return reject(new RpcError_1.default('row not found \'' + match + '\''));
}
return resolve(cache(match, resp.rows[0]));
return resolve(cacheFn(resp.rows[0]));
}

@@ -94,3 +113,3 @@ catch (e) {

}
async fetch_all_rows(table, scope, tableKey, lowerBound = '', upperBound = '', cache, useCache = true, indexPosition = 1, keyType = '') {
async fetch_all_rows(table, scope, tableKey, lowerBound = '', upperBound = '', indexPosition = 1, keyType = '') {
return new Promise(async (resolve, reject) => {

@@ -106,7 +125,6 @@ this.elements.push(async () => {

try {
let next = await this.fetch_all_rows(table, scope, tableKey, resp.rows[resp.rows.length - 1][tableKey], upperBound, cache, useCache);
next.shift();
next = next.map((element) => {
return cache(element[tableKey], element);
});
const next = await this.fetch_all_rows(table, scope, tableKey, resp.rows[resp.rows.length - 1][tableKey], upperBound, indexPosition, keyType);
if (next.length > 0) {
next.shift();
}
resolve(resp.rows.concat(next));

@@ -113,0 +131,0 @@ }

import { ISchema, SchemaObject } from '../../Schema';
import { ISchemaRow } from './Cache';
import RpcCollection from './Collection';
import RpcApi from './index';
export default class RpcSchema {
private readonly api;
readonly collection: string;
readonly name: string;

@@ -11,3 +11,2 @@ private readonly _data;

constructor(api: RpcApi, collection: string, name: string, data?: ISchemaRow, cache?: boolean);
collection(): Promise<RpcCollection>;
format(): Promise<ISchema>;

@@ -14,0 +13,0 @@ rawFormat(): Promise<SchemaObject[]>;

@@ -11,2 +11,3 @@ "use strict";

this.api = api;
this.collection = collection;
this.name = name;

@@ -19,3 +20,3 @@ this._data = new Promise(async (resolve, reject) => {

try {
resolve(await api.queue.schema(collection, name, cache));
resolve(await api.queue.fetchSchema(collection, name, cache));
}

@@ -36,5 +37,2 @@ catch (e) {

}
async collection() {
return await this._collection;
}
async format() {

@@ -49,4 +47,3 @@ return Schema_1.ObjectSchema((await this._data).format);

schema_name: this.name,
collection: await (await this._collection).toObject(),
format: (await this._data).format
format: await this.rawFormat()
};

@@ -53,0 +50,0 @@ }

@@ -6,2 +6,3 @@ import { ITemplateRow } from './Cache';

private readonly api;
readonly collection: string;
readonly id: string;

@@ -8,0 +9,0 @@ private readonly _data;

@@ -11,2 +11,3 @@ "use strict";

this.api = api;
this.collection = collection;
this.id = id;

@@ -19,3 +20,3 @@ this._data = new Promise(async (resolve, reject) => {

try {
resolve(await api.queue.template(collection, id, cache));
resolve(await api.queue.fetchTemplate(collection, id, cache));
}

@@ -22,0 +23,0 @@ catch (e) {

@@ -70,3 +70,3 @@ "use strict";

const n = big_integer_1.default(input);
if (n.lesserOrEquals(0)) {
if (n.lesser(0)) {
return n.plus(1).multiply(-2).plus(1);

@@ -73,0 +73,0 @@ }

@@ -12,3 +12,3 @@ {

"license": "MIT",
"version": "0.8.1",
"version": "0.9.0",
"main": "build/index.js",

@@ -24,3 +24,4 @@ "types": "build/index.d.ts",

"dependencies": {
"big-integer": "^1.6.48"
"big-integer": "^1.6.48",
"pure-cache": "^1.0.5"
},

@@ -27,0 +28,0 @@ "devDependencies": {

@@ -5,3 +5,3 @@ # AtomicAssets JavaScript

Contract / General Documentation can be found on [https://github.com/pinknetworkx/atomicassets-contracts/wiki](https://github.com/pinknetworkx/atomicassets-contracts/wiki)
Contract / General Documentation can be found on [https://github.com/pinknetworkx/atomicassets-contract/wiki](https://github.com/pinknetworkx/atomicassets-contract/wiki)

@@ -35,3 +35,3 @@ ## Usage

More information can be found [here](https://github.com/pinknetworkx/atomicassets-contracts/wiki/Serialization)
More information can be found [here](https://github.com/pinknetworkx/atomicassets-contract/wiki/Serialization)

@@ -111,3 +111,3 @@ #### Example

##### Assets
`async getAssets(options, page: number = 1, limit: number = 100): Promise<ApiAsset[]>`
`async getAssets(options, page: number = 1, limit: number = 100, data = {}): Promise<ApiAsset[]>`
options

@@ -123,5 +123,8 @@ * **owner**: string

data
* query for specific asset attributes
`async getAsset(id: string): Promise<ApiAsset>`
`async getAssetLogs(id: string, page: number = 1, limit: number = 100): Promise<ApiLog[]>`
`async getAssetLogs(id: string, page: number = 1, limit: number = 100, order: string = 'desc'): Promise<ApiLog[]>`

@@ -141,3 +144,3 @@ ##### Collections

`async getCollectionLogs(name: string, page: number = 1, limit: number = 100): Promise<ApiLog[]>`
`async getCollectionLogs(name: string, page: number = 1, limit: number = 100, order: string = 'desc'): Promise<ApiLog[]>`

@@ -149,2 +152,3 @@ ##### Schemas

* **collection_name**: string
* **schema_name**: string
* **match**: search for input in name

@@ -157,6 +161,8 @@ * **authorized_account**: string

`async getSchemaLogs(collection: string, name: string, page: number = 1, limit: number = 100): Promise<ApiLog[]>`
`async getSchemaStats(collection: string, name: string): Promise<ApiSchemaStats[]>`
`async getSchemaLogs(collection: string, name: string, page: number = 1, limit: number = 100, order: string = 'desc'): Promise<ApiLog[]>`
##### Templates
`async getTemplates(options, page: number = 1, limit: number = 100): Promise<ApiTemplate[]>`
`async getTemplates(options, page: number = 1, limit: number = 100, data = {}): Promise<ApiTemplate[]>`

@@ -170,6 +176,11 @@ options

data
* filter for specific template attributes
`async getTemplate(collection: string, id: string): Promise<ApiTemplate>`
`async getTemplateLogs(collection: string, id: string, page: number = 1, limit: number = 100): Promise<ApiLog[]>`
`async getTemplateStats(collection: string, id: string): Promise<ApiTemplateStats[]>`
`async getTemplateLogs(collection: string, id: string, page: number = 1, limit: number = 100, order: string = 'desc'): Promise<ApiLog[]>`
##### Trading

@@ -182,2 +193,3 @@ `async getTransfers(options, page: number = 1, limit: number = 100): Promise<ApiTransfe[]>`

* **recipient**: string
* **asset_id**: asset id which should be included in the offer
* **order**: field which is used to sort result

@@ -192,2 +204,4 @@ * **sort**: asc | desc

* **recipient**: recipient of offer
* **is_recipient_contract**: filter if recipient is contract or not
* **asset_id**: asset_id included in offer
* **order**: field which is used to sort result

@@ -203,3 +217,3 @@ * **sort**: asc | desc

Detailed information about each action can be found [here](https://github.com/pinknetworkx/atomicassets-contracts/wiki/Actions)
Detailed information about each action can be found [here](https://github.com/pinknetworkx/atomicassets-contract/wiki/Actions)

@@ -280,3 +294,3 @@ #### Types

Detailed information about each action can be found [here](https://github.com/pinknetworkx/atomicassets-contracts/wiki/Actions)
Detailed information about each action can be found [here](https://github.com/pinknetworkx/atomicassets-contract/wiki/Actions)

@@ -283,0 +297,0 @@ #### Types

{
"compilerOptions": {
"noImplicitAny": true,
"target": "es2020",
"target": "es2017",
"module": "commonjs",

@@ -6,0 +6,0 @@ "declaration": true,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc