@saberhq/solana-contrib
Advanced tools
Comparing version 1.12.71 to 1.12.72
@@ -185,2 +185,15 @@ /// <reference types="node" /> | ||
} | ||
/** | ||
* A parsed program-owned account. | ||
*/ | ||
export declare type ProgramAccount<T> = { | ||
/** | ||
* {@link PublicKey} of the account. | ||
*/ | ||
publicKey: PublicKey; | ||
/** | ||
* The parsed account data. | ||
*/ | ||
account: T; | ||
}; | ||
//# sourceMappingURL=interfaces.d.ts.map |
import { PublicKey } from "@solana/web3.js"; | ||
export { PublicKey } from "@solana/web3.js"; | ||
/** | ||
* Returns a {@link PublicKey} if it can be parsed, otherwise returns null. | ||
* @param pk | ||
* @returns | ||
*/ | ||
export declare const parsePublicKey: (pk: unknown) => PublicKey | null; | ||
/** | ||
* Returns true if the given value is a {@link PublicKey}. | ||
@@ -5,0 +11,0 @@ * @param pk |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isPublicKey = exports.PublicKey = void 0; | ||
exports.isPublicKey = exports.parsePublicKey = exports.PublicKey = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -10,12 +10,12 @@ const web3_js_1 = require("@solana/web3.js"); | ||
/** | ||
* Returns true if the given value is a {@link PublicKey}. | ||
* Returns a {@link PublicKey} if it can be parsed, otherwise returns null. | ||
* @param pk | ||
* @returns | ||
*/ | ||
const isPublicKey = (pk) => { | ||
const parsePublicKey = (pk) => { | ||
if (!pk) { | ||
return false; | ||
return null; | ||
} | ||
if (pk instanceof web3_js_1.PublicKey) { | ||
return true; | ||
return pk; | ||
} | ||
@@ -25,13 +25,21 @@ if (typeof pk !== "object" || | ||
("constructor" in pk && bn_js_1.default.isBN(pk))) { | ||
return false; | ||
return null; | ||
} | ||
try { | ||
new web3_js_1.PublicKey(pk); | ||
return true; | ||
return new web3_js_1.PublicKey(pk); | ||
} | ||
catch (e) { | ||
return false; | ||
return null; | ||
} | ||
}; | ||
exports.parsePublicKey = parsePublicKey; | ||
/** | ||
* Returns true if the given value is a {@link PublicKey}. | ||
* @param pk | ||
* @returns | ||
*/ | ||
const isPublicKey = (pk) => { | ||
return !!(0, exports.parsePublicKey)(pk); | ||
}; | ||
exports.isPublicKey = isPublicKey; | ||
//# sourceMappingURL=publicKey.js.map |
@@ -185,2 +185,15 @@ /// <reference types="node" /> | ||
} | ||
/** | ||
* A parsed program-owned account. | ||
*/ | ||
export declare type ProgramAccount<T> = { | ||
/** | ||
* {@link PublicKey} of the account. | ||
*/ | ||
publicKey: PublicKey; | ||
/** | ||
* The parsed account data. | ||
*/ | ||
account: T; | ||
}; | ||
//# sourceMappingURL=interfaces.d.ts.map |
import { PublicKey } from "@solana/web3.js"; | ||
export { PublicKey } from "@solana/web3.js"; | ||
/** | ||
* Returns a {@link PublicKey} if it can be parsed, otherwise returns null. | ||
* @param pk | ||
* @returns | ||
*/ | ||
export declare const parsePublicKey: (pk: unknown) => PublicKey | null; | ||
/** | ||
* Returns true if the given value is a {@link PublicKey}. | ||
@@ -5,0 +11,0 @@ * @param pk |
@@ -5,12 +5,12 @@ import { PublicKey } from "@solana/web3.js"; | ||
/** | ||
* Returns true if the given value is a {@link PublicKey}. | ||
* Returns a {@link PublicKey} if it can be parsed, otherwise returns null. | ||
* @param pk | ||
* @returns | ||
*/ | ||
export const isPublicKey = (pk) => { | ||
export const parsePublicKey = (pk) => { | ||
if (!pk) { | ||
return false; | ||
return null; | ||
} | ||
if (pk instanceof PublicKey) { | ||
return true; | ||
return pk; | ||
} | ||
@@ -20,12 +20,19 @@ if (typeof pk !== "object" || | ||
("constructor" in pk && BN.isBN(pk))) { | ||
return false; | ||
return null; | ||
} | ||
try { | ||
new PublicKey(pk); | ||
return true; | ||
return new PublicKey(pk); | ||
} | ||
catch (e) { | ||
return false; | ||
return null; | ||
} | ||
}; | ||
/** | ||
* Returns true if the given value is a {@link PublicKey}. | ||
* @param pk | ||
* @returns | ||
*/ | ||
export const isPublicKey = (pk) => { | ||
return !!parsePublicKey(pk); | ||
}; | ||
//# sourceMappingURL=publicKey.js.map |
{ | ||
"name": "@saberhq/solana-contrib", | ||
"version": "1.12.71", | ||
"version": "1.12.72", | ||
"description": "Common types and libraries for Solana", | ||
@@ -46,3 +46,3 @@ "author": "Ian Macalinao <ian@saber.so>", | ||
}, | ||
"gitHead": "e735e4e65e0f04a2d1f1950deddffeffa90ea04a", | ||
"gitHead": "077c79a1c0432ddd0fdc424e1e15a3f31d002d1d", | ||
"publishConfig": { | ||
@@ -49,0 +49,0 @@ "access": "public" |
@@ -245,1 +245,15 @@ import type { | ||
} | ||
/** | ||
* A parsed program-owned account. | ||
*/ | ||
export type ProgramAccount<T> = { | ||
/** | ||
* {@link PublicKey} of the account. | ||
*/ | ||
publicKey: PublicKey; | ||
/** | ||
* The parsed account data. | ||
*/ | ||
account: T; | ||
}; |
@@ -8,13 +8,13 @@ import type { PublicKeyData } from "@solana/web3.js"; | ||
/** | ||
* Returns true if the given value is a {@link PublicKey}. | ||
* Returns a {@link PublicKey} if it can be parsed, otherwise returns null. | ||
* @param pk | ||
* @returns | ||
*/ | ||
export const isPublicKey = (pk: unknown): pk is PublicKey => { | ||
export const parsePublicKey = (pk: unknown): PublicKey | null => { | ||
if (!pk) { | ||
return false; | ||
return null; | ||
} | ||
if (pk instanceof PublicKey) { | ||
return true; | ||
return pk; | ||
} | ||
@@ -27,11 +27,19 @@ | ||
) { | ||
return false; | ||
return null; | ||
} | ||
try { | ||
new PublicKey(pk as PublicKeyData); | ||
return true; | ||
return new PublicKey(pk as PublicKeyData); | ||
} catch (e) { | ||
return false; | ||
return null; | ||
} | ||
}; | ||
/** | ||
* Returns true if the given value is a {@link PublicKey}. | ||
* @param pk | ||
* @returns | ||
*/ | ||
export const isPublicKey = (pk: unknown): pk is PublicKey => { | ||
return !!parsePublicKey(pk); | ||
}; |
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
Sorry, the diff of this file is not supported yet
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
692069
9727