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.22-next.37 to 0.2.22-next.41

4

./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.getAssets = exports.getAsset = void 0;
exports.proofArgsAndAccounts = exports.getAssetProofBatch = exports.getAssetBatch = exports.searchAssets = exports.getAssetsByOwner = exports.getAssetProof = exports.getAssets = exports.getAsset = void 0;
__exportStar(require("./extendBorsh"), exports);

@@ -32,4 +32,6 @@ __exportStar(require("./transaction"), exports);

Object.defineProperty(exports, "searchAssets", { enumerable: true, get: function () { return mplAssetAPI_1.searchAssets; } });
Object.defineProperty(exports, "getAssetBatch", { enumerable: true, get: function () { return mplAssetAPI_1.getAssetBatch; } });
Object.defineProperty(exports, "getAssetProofBatch", { enumerable: true, get: function () { return mplAssetAPI_1.getAssetProofBatch; } });
var proofArgsAndAccounts_1 = require("./proofArgsAndAccounts");
Object.defineProperty(exports, "proofArgsAndAccounts", { enumerable: true, get: function () { return proofArgsAndAccounts_1.proofArgsAndAccounts; } });
//# sourceMappingURL=index.js.map

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

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

@@ -32,4 +32,6 @@ __exportStar(require("./transaction"), exports);

Object.defineProperty(exports, "searchAssets", { enumerable: true, get: function () { return mplAssetAPI_1.searchAssets; } });
Object.defineProperty(exports, "getAssetBatch", { enumerable: true, get: function () { return mplAssetAPI_1.getAssetBatch; } });
Object.defineProperty(exports, "getAssetProofBatch", { enumerable: true, get: function () { return mplAssetAPI_1.getAssetProofBatch; } });
var proofArgsAndAccounts_1 = require("./proofArgsAndAccounts");
Object.defineProperty(exports, "proofArgsAndAccounts", { enumerable: true, get: function () { return proofArgsAndAccounts_1.proofArgsAndAccounts; } });
//# sourceMappingURL=index.js.map

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.searchAssets = exports.getAssetsByOwner = exports.getAssetProof = exports.getAssets = exports.getAsset = void 0;
exports.searchAssets = exports.getAssetsByOwner = exports.getAssetProofBatch = exports.getAssetProof = exports.getAssets = exports.getAssetBatch = 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,2 +59,28 @@ });

exports.getAsset = getAsset;
function getAssetBatch(url, assetIds) {
return __awaiter(this, void 0, void 0, function* () {
try {
const response = yield axios_1.default.post(url, {
jsonrpc: "2.0",
method: "getAssetBatch",
id: "rpd-op-123",
params: { ids: assetIds.map((assetId) => assetId.toBase58()) },
headers: {
"Cache-Control": "no-cache",
Pragma: "no-cache",
Expires: "0",
},
});
const result = response.data.result;
if (result) {
return result.map(toAsset);
}
}
catch (error) {
console.error(error);
throw error;
}
});
}
exports.getAssetBatch = getAssetBatch;
function getAssets(url, assetIds) {

@@ -67,5 +93,5 @@ return __awaiter(this, void 0, void 0, function* () {

const batch = assetIds.map((assetId, i) => ({
jsonrpc: '2.0',
jsonrpc: "2.0",
id: `get-asset-${i}`,
method: 'getAsset',
method: "getAsset",
params: {

@@ -77,8 +103,8 @@ id: assetId.toBase58(),

url,
method: 'POST',
method: "POST",
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0',
"Content-Type": "application/json",
"Cache-Control": "no-cache",
Pragma: "no-cache",
Expires: "0",
},

@@ -114,10 +140,10 @@ data: JSON.stringify(batch),

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",
},

@@ -143,3 +169,38 @@ });

exports.getAssetProof = getAssetProof;
function getAssetsByOwner(url, wallet, { sortBy = { sortBy: 'created', sortDirection: 'asc' }, limit = 50, page = 1, before = '', after = '', } = {}) {
function getAssetProofBatch(url, assetIds) {
return __awaiter(this, void 0, void 0, function* () {
try {
const response = yield axios_1.default.post(url, {
jsonrpc: "2.0",
method: "getAssetProofBatch",
id: "rpd-op-123",
params: { ids: assetIds.map((assetId) => assetId.toBase58()) },
headers: {
"Cache-Control": "no-cache",
Pragma: "no-cache",
Expires: "0",
},
});
const result = response.data.result;
if (result) {
return Object.entries(result).reduce((acc, [k, r]) => {
acc[k] = {
root: new web3_js_1.PublicKey(r.root),
proof: r.proof.map((p) => new web3_js_1.PublicKey(p)),
nodeIndex: r.node_index,
leaf: new web3_js_1.PublicKey(r.leaf),
treeId: new web3_js_1.PublicKey(r.tree_id),
};
return acc;
}, {});
}
}
catch (error) {
console.error(error);
throw error;
}
});
}
exports.getAssetProofBatch = getAssetProofBatch;
function getAssetsByOwner(url, wallet, { sortBy = { sortBy: "created", sortDirection: "asc" }, limit = 50, page = 1, before = "", after = "", } = {}) {
var _a;

@@ -149,10 +210,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",
},

@@ -171,9 +232,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,

@@ -183,5 +244,5 @@ creatorVerified,

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

@@ -188,0 +249,0 @@ });

@@ -8,4 +8,4 @@ export * from './extendBorsh';

export * from './constants';
export { getAsset, getAssets, getAssetProof, getAssetsByOwner, searchAssets, } from './mplAssetAPI';
export { getAsset, getAssets, getAssetProof, getAssetsByOwner, searchAssets, getAssetBatch, getAssetProofBatch, } 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,25 @@ });

}
export async function getAssetBatch(url, assetIds) {
try {
const response = await axios.post(url, {
jsonrpc: "2.0",
method: "getAssetBatch",
id: "rpd-op-123",
params: { ids: assetIds.map((assetId) => assetId.toBase58()) },
headers: {
"Cache-Control": "no-cache",
Pragma: "no-cache",
Expires: "0",
},
});
const result = response.data.result;
if (result) {
return result.map(toAsset);
}
}
catch (error) {
console.error(error);
throw error;
}
}
export async function getAssets(url, assetIds) {

@@ -35,5 +58,5 @@ try {

const batch = assetIds.map((assetId, i) => ({
jsonrpc: '2.0',
jsonrpc: "2.0",
id: `get-asset-${i}`,
method: 'getAsset',
method: "getAsset",
params: {

@@ -45,8 +68,8 @@ id: assetId.toBase58(),

url,
method: 'POST',
method: "POST",
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0',
"Content-Type": "application/json",
"Cache-Control": "no-cache",
Pragma: "no-cache",
Expires: "0",
},

@@ -99,10 +122,10 @@ data: JSON.stringify(batch),

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",
},

@@ -126,13 +149,45 @@ });

}
export async function getAssetsByOwner(url, wallet, { sortBy = { sortBy: 'created', sortDirection: 'asc' }, limit = 50, page = 1, before = '', after = '', } = {}) {
export async function getAssetProofBatch(url, assetIds) {
try {
const response = await axios.post(url, {
jsonrpc: '2.0',
method: 'getAssetsByOwner',
id: 'rpd-op-123',
jsonrpc: "2.0",
method: "getAssetProofBatch",
id: "rpd-op-123",
params: { ids: assetIds.map((assetId) => assetId.toBase58()) },
headers: {
"Cache-Control": "no-cache",
Pragma: "no-cache",
Expires: "0",
},
});
const result = response.data.result;
if (result) {
return Object.entries(result).reduce((acc, [k, r]) => {
acc[k] = {
root: new PublicKey(r.root),
proof: r.proof.map((p) => new PublicKey(p)),
nodeIndex: r.node_index,
leaf: new PublicKey(r.leaf),
treeId: new PublicKey(r.tree_id),
};
return acc;
}, {});
}
}
catch (error) {
console.error(error);
throw error;
}
}
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",
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",
},

@@ -147,8 +202,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: {

@@ -161,5 +216,5 @@ page,

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

@@ -166,0 +221,0 @@ });

@@ -9,5 +9,5 @@ export * from './extendBorsh';

export type { AssetProof, Asset, AssetsByOwnerOpts, SearchAssetsOpts, } from './mplAssetAPI';
export { getAsset, getAssets, getAssetProof, getAssetsByOwner, searchAssets, } from './mplAssetAPI';
export { getAsset, getAssets, getAssetProof, getAssetsByOwner, searchAssets, getAssetBatch, getAssetProofBatch, } 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,8 +43,10 @@ root: PublicKey;

export declare function getAsset(url: string, assetId: PublicKey): Promise<Asset | undefined>;
export declare function getAssetBatch(url: string, assetIds: 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 declare function getAssetProofBatch(url: string, assetIds: PublicKey[]): Promise<Record<string, AssetProof> | undefined>;
export type AssetsByOwnerOpts = {
sortBy?: {
sortBy: 'created';
sortDirection: 'asc' | 'desc';
sortBy: "created";
sortDirection: "asc" | "desc";
};

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

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

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

{
"name": "@helium/spl-utils",
"version": "0.2.22-next.37+e92a511f",
"version": "0.2.22-next.41+70ab6b51",
"description": "Utils shared across spl suite",

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

"@coral-xyz/anchor": "^0.26.0",
"@helium/account-fetch-cache": "^0.2.22-next.37+e92a511f",
"@helium/account-fetch-cache": "^0.2.22-next.41+70ab6b51",
"@helium/address": "^4.10.2",
"@helium/anchor-resolvers": "^0.2.22-next.37+e92a511f",
"@helium/anchor-resolvers": "^0.2.22-next.41+70ab6b51",
"@metaplex-foundation/mpl-token-metadata": "^2.10.0",

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

},
"gitHead": "e92a511fce1fb7d9f44223e0ec455e2d9c1b84b0"
"gitHead": "70ab6b5137ffd7467ae656d083b00a041367c470"
}

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