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

@helium/spl-utils

Package Overview
Dependencies
Maintainers
7
Versions
232
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@helium/spl-utils - npm Package Compare versions

Comparing version 0.2.20 to 0.2.21

3

./lib/cjs/index.js

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.proofArgsAndAccounts = exports.searchAssets = exports.getAssetsByOwner = exports.getAssetProof = exports.getAsset = void 0;
exports.proofArgsAndAccounts = exports.searchAssets = exports.getAssetsByOwner = exports.getAssetProof = exports.getAssets = exports.getAsset = void 0;
__exportStar(require("./extendBorsh"), exports);

@@ -28,2 +28,3 @@ __exportStar(require("./transaction"), exports);

Object.defineProperty(exports, "getAsset", { enumerable: true, get: function () { return mplAssetAPI_1.getAsset; } });
Object.defineProperty(exports, "getAssets", { enumerable: true, get: function () { return mplAssetAPI_1.getAssets; } });
Object.defineProperty(exports, "getAssetProof", { enumerable: true, get: function () { return mplAssetAPI_1.getAssetProof; } });

@@ -30,0 +31,0 @@ Object.defineProperty(exports, "getAssetsByOwner", { enumerable: true, get: function () { return mplAssetAPI_1.getAssetsByOwner; } });

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.proofArgsAndAccounts = exports.searchAssets = exports.getAssetsByOwner = exports.getAssetProof = exports.getAsset = void 0;
exports.proofArgsAndAccounts = exports.searchAssets = exports.getAssetsByOwner = exports.getAssetProof = exports.getAssets = exports.getAsset = void 0;
__exportStar(require("./extendBorsh"), exports);

@@ -28,2 +28,3 @@ __exportStar(require("./transaction"), exports);

Object.defineProperty(exports, "getAsset", { enumerable: true, get: function () { return mplAssetAPI_1.getAsset; } });
Object.defineProperty(exports, "getAssets", { enumerable: true, get: function () { return mplAssetAPI_1.getAssets; } });
Object.defineProperty(exports, "getAssetProof", { enumerable: true, get: function () { return mplAssetAPI_1.getAssetProof; } });

@@ -30,0 +31,0 @@ Object.defineProperty(exports, "getAssetsByOwner", { enumerable: true, get: function () { return mplAssetAPI_1.getAssetsByOwner; } });

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.searchAssets = exports.getAssetsByOwner = exports.getAssetProof = exports.getAsset = void 0;
exports.searchAssets = exports.getAssetsByOwner = exports.getAssetProof = exports.getAssets = exports.getAsset = void 0;
const web3_js_1 = require("@solana/web3.js");

@@ -36,10 +36,10 @@ const axios_1 = __importDefault(require("axios"));

const response = yield axios_1.default.post(url, {
jsonrpc: "2.0",
method: "getAsset",
id: "rpd-op-123",
jsonrpc: '2.0',
method: 'getAsset',
id: 'rpd-op-123',
params: { id: assetId.toBase58() },
headers: {
"Cache-Control": "no-cache",
Pragma: "no-cache",
Expires: "0",
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0',
},

@@ -59,4 +59,46 @@ });

exports.getAsset = getAsset;
function getAssets(url, assetIds) {
return __awaiter(this, void 0, void 0, function* () {
try {
if (assetIds.length > 1000) {
throw new Error(`Can only batch 1000 at a time, was given ${assetIds.length}`);
}
const batch = assetIds.map((assetId, i) => ({
jsonrpc: '2.0',
id: `get-asset-${i}`,
method: 'getAsset',
params: {
id: assetId.toBase58(),
},
}));
const response = yield (0, axios_1.default)({
url,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0',
},
data: JSON.stringify(batch),
});
const result = response.data
? response.data.map((res) => (res === null || res === void 0 ? void 0 : res.result) || undefined)
: [];
return [
...(result
? result.map((x) => (x ? toAsset(x) : x))
: []),
];
}
catch (error) {
console.error(error);
throw error;
}
});
}
exports.getAssets = getAssets;
function toAsset(result) {
return Object.assign(Object.assign({}, result), { id: new web3_js_1.PublicKey(result.id), grouping: result.grouping && result.grouping.map((g) => (Object.assign(Object.assign({}, g), { group_value: new web3_js_1.PublicKey(g.group_value) }))), compression: Object.assign(Object.assign({}, result.compression), { leafId: result.compression.leaf_id, dataHash: result.compression.data_hash &&
return Object.assign(Object.assign({}, result), { id: new web3_js_1.PublicKey(result.id), grouping: result.grouping &&
result.grouping.map((g) => (Object.assign(Object.assign({}, g), { group_value: new web3_js_1.PublicKey(g.group_value) }))), compression: Object.assign(Object.assign({}, result.compression), { leafId: result.compression.leaf_id, dataHash: result.compression.data_hash &&
Buffer.from(bs58_1.default.decode(result.compression.data_hash)), creatorHash: result.compression.creator_hash &&

@@ -70,10 +112,10 @@ Buffer.from(bs58_1.default.decode(result.compression.creator_hash)), assetHash: result.compression.asset_hash &&

const response = yield axios_1.default.post(url, {
jsonrpc: "2.0",
method: "getAssetProof",
id: "rpd-op-123",
jsonrpc: '2.0',
method: 'getAssetProof',
id: 'rpd-op-123',
params: { id: assetId.toBase58() },
headers: {
"Cache-Control": "no-cache",
Pragma: "no-cache",
Expires: "0",
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0',
},

@@ -99,3 +141,3 @@ });

exports.getAssetProof = getAssetProof;
function getAssetsByOwner(url, wallet, { sortBy = { sortBy: "created", sortDirection: "asc" }, limit = 50, page = 1, before = "", after = "", } = {}) {
function getAssetsByOwner(url, wallet, { sortBy = { sortBy: 'created', sortDirection: 'asc' }, limit = 50, page = 1, before = '', after = '', } = {}) {
var _a;

@@ -105,10 +147,10 @@ return __awaiter(this, void 0, void 0, function* () {

const response = yield axios_1.default.post(url, {
jsonrpc: "2.0",
method: "getAssetsByOwner",
id: "rpd-op-123",
jsonrpc: '2.0',
method: 'getAssetsByOwner',
id: 'rpd-op-123',
params: [wallet, sortBy, limit, page, before, after],
headers: {
"Cache-Control": "no-cache",
Pragma: "no-cache",
Expires: "0",
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0',
},

@@ -127,9 +169,9 @@ });

var _b;
var { creatorVerified = true, sortBy = { sortBy: "created", sortDirection: "asc" }, page = 1 } = _a, rest = __rest(_a, ["creatorVerified", "sortBy", "page"]);
var { creatorVerified = true, sortBy = { sortBy: 'created', sortDirection: 'asc' }, page = 1 } = _a, rest = __rest(_a, ["creatorVerified", "sortBy", "page"]);
return __awaiter(this, void 0, void 0, function* () {
try {
const response = yield axios_1.default.post(url, {
jsonrpc: "2.0",
method: "searchAssets",
id: "get-assets-op-1",
jsonrpc: '2.0',
method: 'searchAssets',
id: 'get-assets-op-1',
params: Object.assign({ page,

@@ -139,5 +181,5 @@ creatorVerified,

headers: {
"Cache-Control": "no-cache",
Pragma: "no-cache",
Expires: "0",
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0',
},

@@ -144,0 +186,0 @@ });

@@ -1,10 +0,10 @@

export * from "./extendBorsh";
export * from "./transaction";
export * from "./anchorError";
export * from "./executeRemoteTxn";
export * from "./utils";
export * from "./token";
export * from "./constants";
export { getAsset, getAssetProof, getAssetsByOwner, searchAssets, } from "./mplAssetAPI";
export { proofArgsAndAccounts } from "./proofArgsAndAccounts";
export * from './extendBorsh';
export * from './transaction';
export * from './anchorError';
export * from './executeRemoteTxn';
export * from './utils';
export * from './token';
export * from './constants';
export { getAsset, getAssets, getAssetProof, getAssetsByOwner, searchAssets, } from './mplAssetAPI';
export { proofArgsAndAccounts } from './proofArgsAndAccounts';
//# sourceMappingURL=index.js.map

@@ -1,16 +0,16 @@

import { PublicKey } from "@solana/web3.js";
import axios from "axios";
import { PublicKey } from '@solana/web3.js';
import axios from 'axios';
// @ts-ignore
import base58 from "bs58";
import base58 from 'bs58';
export async function getAsset(url, assetId) {
try {
const response = await axios.post(url, {
jsonrpc: "2.0",
method: "getAsset",
id: "rpd-op-123",
jsonrpc: '2.0',
method: 'getAsset',
id: 'rpd-op-123',
params: { id: assetId.toBase58() },
headers: {
"Cache-Control": "no-cache",
Pragma: "no-cache",
Expires: "0",
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0',
},

@@ -28,2 +28,40 @@ });

}
export async function getAssets(url, assetIds) {
try {
if (assetIds.length > 1000) {
throw new Error(`Can only batch 1000 at a time, was given ${assetIds.length}`);
}
const batch = assetIds.map((assetId, i) => ({
jsonrpc: '2.0',
id: `get-asset-${i}`,
method: 'getAsset',
params: {
id: assetId.toBase58(),
},
}));
const response = await axios({
url,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0',
},
data: JSON.stringify(batch),
});
const result = response.data
? response.data.map((res) => res?.result || undefined)
: [];
return [
...(result
? result.map((x) => (x ? toAsset(x) : x))
: []),
];
}
catch (error) {
console.error(error);
throw error;
}
}
function toAsset(result) {

@@ -33,3 +71,7 @@ return {

id: new PublicKey(result.id),
grouping: result.grouping && result.grouping.map((g) => ({ ...g, group_value: new PublicKey(g.group_value) })),
grouping: result.grouping &&
result.grouping.map((g) => ({
...g,
group_value: new PublicKey(g.group_value),
})),
compression: {

@@ -56,10 +98,10 @@ ...result.compression,

const response = await axios.post(url, {
jsonrpc: "2.0",
method: "getAssetProof",
id: "rpd-op-123",
jsonrpc: '2.0',
method: 'getAssetProof',
id: 'rpd-op-123',
params: { id: assetId.toBase58() },
headers: {
"Cache-Control": "no-cache",
Pragma: "no-cache",
Expires: "0",
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0',
},

@@ -83,13 +125,13 @@ });

}
export async function getAssetsByOwner(url, wallet, { sortBy = { sortBy: "created", sortDirection: "asc" }, limit = 50, page = 1, before = "", after = "", } = {}) {
export async function getAssetsByOwner(url, wallet, { sortBy = { sortBy: 'created', sortDirection: 'asc' }, limit = 50, page = 1, before = '', after = '', } = {}) {
try {
const response = await axios.post(url, {
jsonrpc: "2.0",
method: "getAssetsByOwner",
id: "rpd-op-123",
jsonrpc: '2.0',
method: 'getAssetsByOwner',
id: 'rpd-op-123',
params: [wallet, sortBy, limit, page, before, after],
headers: {
"Cache-Control": "no-cache",
Pragma: "no-cache",
Expires: "0",
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0',
},

@@ -104,8 +146,8 @@ });

}
export async function searchAssets(url, { creatorVerified = true, sortBy = { sortBy: "created", sortDirection: "asc" }, page = 1, ...rest }) {
export async function searchAssets(url, { creatorVerified = true, sortBy = { sortBy: 'created', sortDirection: 'asc' }, page = 1, ...rest }) {
try {
const response = await axios.post(url, {
jsonrpc: "2.0",
method: "searchAssets",
id: "get-assets-op-1",
jsonrpc: '2.0',
method: 'searchAssets',
id: 'get-assets-op-1',
params: {

@@ -118,5 +160,5 @@ page,

headers: {
"Cache-Control": "no-cache",
Pragma: "no-cache",
Expires: "0",
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0',
},

@@ -123,0 +165,0 @@ });

@@ -1,12 +0,12 @@

export * from "./extendBorsh";
export * from "./transaction";
export * from "./anchorError";
export * from "./executeRemoteTxn";
export * from "./utils";
export * from "./token";
export * from "./constants";
export type { AssetProof, Asset, AssetsByOwnerOpts, SearchAssetsOpts, } from "./mplAssetAPI";
export { getAsset, getAssetProof, getAssetsByOwner, searchAssets, } from "./mplAssetAPI";
export { proofArgsAndAccounts } from "./proofArgsAndAccounts";
export type { ProofArgsAndAccountsArgs } from "./proofArgsAndAccounts";
export * from './extendBorsh';
export * from './transaction';
export * from './anchorError';
export * from './executeRemoteTxn';
export * from './utils';
export * from './token';
export * from './constants';
export type { AssetProof, Asset, AssetsByOwnerOpts, SearchAssetsOpts, } from './mplAssetAPI';
export { getAsset, getAssets, getAssetProof, getAssetsByOwner, searchAssets, } from './mplAssetAPI';
export { proofArgsAndAccounts } from './proofArgsAndAccounts';
export type { ProofArgsAndAccountsArgs } from './proofArgsAndAccounts';
//# sourceMappingURL=index.d.ts.map
/// <reference types="node" />
import { Creator, Uses } from "@metaplex-foundation/mpl-bubblegum";
import { PublicKey } from "@solana/web3.js";
import { Creator, Uses } from '@metaplex-foundation/mpl-bubblegum';
import { PublicKey } from '@solana/web3.js';
export type AssetProof = {

@@ -43,7 +43,8 @@ root: PublicKey;

export declare function getAsset(url: string, assetId: PublicKey): Promise<Asset | undefined>;
export declare function getAssets(url: string, assetIds: PublicKey[]): Promise<(Asset | undefined)[]>;
export declare function getAssetProof(url: string, assetId: PublicKey): Promise<AssetProof | undefined>;
export type AssetsByOwnerOpts = {
sortBy?: {
sortBy: "created";
sortDirection: "asc" | "desc";
sortBy: 'created';
sortDirection: 'asc' | 'desc';
};

@@ -58,4 +59,4 @@ limit?: number;

sortBy?: {
sortBy: "created";
sortDirection: "asc" | "desc";
sortBy: 'created';
sortDirection: 'asc' | 'desc';
};

@@ -62,0 +63,0 @@ page?: number;

{
"name": "@helium/spl-utils",
"version": "0.2.20",
"version": "0.2.21",
"description": "Utils shared across spl suite",

@@ -35,5 +35,5 @@ "publishConfig": {

"@coral-xyz/anchor": "^0.26.0",
"@helium/account-fetch-cache": "^0.2.20",
"@helium/account-fetch-cache": "^0.2.21",
"@helium/address": "^4.10.2",
"@helium/anchor-resolvers": "^0.2.20",
"@helium/anchor-resolvers": "^0.2.21",
"@metaplex-foundation/mpl-token-metadata": "^2.5.2",

@@ -53,3 +53,3 @@ "@solana/spl-account-compression": "^0.1.7",

},
"gitHead": "700d2c176ac2623300eccb6c741dd5775aa0c41e"
"gitHead": "be9f93a17b2a7193d9aa0326b815d336ae684343"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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