You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

@orca-so/token-sdk

Package Overview
Dependencies
Maintainers
6
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@orca-so/token-sdk - npm Package Compare versions

Comparing version

to
0.3.2-beta.1

4

dist/metadata/client/metaplex-client.d.ts

@@ -47,3 +47,3 @@ /// <reference types="node" />

parseOnChainMetadata(mint: PublicKey, buffer: Buffer | Uint8Array): OnChainMetadata | null;
getOffChainMetadata(metadata: OnChainMetadata): Promise<OffChainMetadata | null>;
getOffChainMetadata(metadata: OnChainMetadata, timeoutMs?: number): Promise<OffChainMetadata | null>;
}

@@ -53,4 +53,4 @@ export declare class MetaplexHttpClient implements MetaplexClient {

parseOnChainMetadata(mint: PublicKey, data: Uint8Array | Buffer): OnChainMetadata | null;
getOffChainMetadata(metadata: OnChainMetadata): Promise<OffChainMetadata | null>;
getOffChainMetadata(metadata: OnChainMetadata, timeoutMs?: number): Promise<OffChainMetadata | null>;
}
export {};

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

const METADATA_PROGRAM_ID = new web3_js_1.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
// Metadata should be a just tiny JSON file, 5000ms should be sufficient for most cases
const DEFAULT_GET_OFF_CHAIN_METADATA_TIMEOUT_MS = 5000;
class MetaplexHttpClient {

@@ -30,3 +32,3 @@ getMetadataAddress(mint) {

}
async getOffChainMetadata(metadata) {
async getOffChainMetadata(metadata, timeoutMs = DEFAULT_GET_OFF_CHAIN_METADATA_TIMEOUT_MS) {
try {

@@ -36,3 +38,3 @@ if (metadata.uri === "") {

}
const response = await (0, isomorphic_unfetch_1.default)(metadata.uri);
const response = await (0, isomorphic_unfetch_1.default)(metadata.uri, { signal: AbortSignal.timeout(timeoutMs) });
if (response.status === 404) {

@@ -39,0 +41,0 @@ return null;

@@ -13,2 +13,3 @@ import { Connection } from "@solana/web3.js";

loadImage?: boolean;
getOffChainMetadataTimeoutMs?: number;
}

@@ -15,0 +16,0 @@ export declare class MetaplexProvider implements MetadataProvider {

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

if (this.opts.loadImage ?? true) {
const json = await this.client.getOffChainMetadata(meta);
const json = await this.client.getOffChainMetadata(meta, this.opts.getOffChainMetadataTimeoutMs);
if (json) {

@@ -69,3 +69,3 @@ image = json.image;

jsonHandlers.push(async () => {
const json = await this.client.getOffChainMetadata(meta);
const json = await this.client.getOffChainMetadata(meta, this.opts.getOffChainMetadataTimeoutMs);
jsons[i] = json;

@@ -72,0 +72,0 @@ });

{
"name": "@orca-so/token-sdk",
"version": "0.3.1",
"version": "0.3.2-beta.1",
"description": "SPL Token Utilities",

@@ -27,3 +27,3 @@ "repository": "https://github.com/orca-so/orca-sdks",

"prettier-format": "prettier --config .prettierrc 'src/**/*.ts' --write",
"test": "jest --detectOpenHandles"
"test": "jest --verbose --detectOpenHandles"
},

@@ -30,0 +30,0 @@ "lint-staged": {

Sorry, the diff of this file is not supported yet