Socket
Socket
Sign inDemoInstall

@moralisweb3/common-sol-utils

Package Overview
Dependencies
Maintainers
8
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@moralisweb3/common-sol-utils - npm Package Compare versions

Comparing version 2.21.0 to 2.22.0

152

lib/esm/index.js

@@ -105,2 +105,5 @@ import { CoreError, CoreErrorCode, BigNumber, CoreProvider, Module, MoralisApiError, ApiErrorCode } from '@moralisweb3/common-core';

};
SolAddress.fromJSON = function (address) {
return SolAddress.create(address);
};
SolAddress.parse = function (address) {

@@ -193,2 +196,5 @@ try {

};
SolNetwork.fromJSON = function (network) {
return SolNetwork.create(network);
};
SolNetwork.parse = function (network) {

@@ -266,2 +272,5 @@ if (typeof network === 'string') {

};
SolNative.fromJSON = function (json) {
return SolNative.create(json, 'lamports');
};
SolNative.parse = function (value, unit) {

@@ -373,2 +382,114 @@ if (unit === void 0) { unit = 'solana'; }

// $ref: #/components/schemas/SPLNativePrice
// type: SPLNativePrice
// properties:
// - value ($ref: #/components/schemas/SPLNativePrice/properties/value)
// - decimals ($ref: #/components/schemas/SPLNativePrice/properties/decimals)
// - name ($ref: #/components/schemas/SPLNativePrice/properties/name)
// - symbol ($ref: #/components/schemas/SPLNativePrice/properties/symbol)
var SolSPLNativePrice = /** @class */ (function () {
function SolSPLNativePrice(input) {
this.value = input.value;
this.decimals = input.decimals;
this.name = input.name;
this.symbol = input.symbol;
}
SolSPLNativePrice.create = function (input) {
if (input instanceof SolSPLNativePrice) {
return input;
}
return new SolSPLNativePrice(input);
};
SolSPLNativePrice.fromJSON = function (json) {
var input = {
value: json.value,
decimals: json.decimals,
name: json.name,
symbol: json.symbol,
};
return SolSPLNativePrice.create(input);
};
SolSPLNativePrice.prototype.toJSON = function () {
return {
value: this.value,
decimals: this.decimals,
name: this.name,
symbol: this.symbol,
};
};
return SolSPLNativePrice;
}());
var SolSPLTokenPrice = /** @class */ (function () {
function SolSPLTokenPrice(input) {
this.nativePrice = input.nativePrice ? SolSPLNativePrice.create(input.nativePrice) : undefined;
this.usdPrice = input.usdPrice;
this.exchangeAddress = SolAddress.create(input.exchangeAddress);
this.exchangeName = input.exchangeName;
}
SolSPLTokenPrice.create = function (input) {
if (input instanceof SolSPLTokenPrice) {
return input;
}
return new SolSPLTokenPrice(input);
};
SolSPLTokenPrice.fromJSON = function (json) {
var input = {
nativePrice: json.nativePrice ? SolSPLNativePrice.fromJSON(json.nativePrice) : undefined,
usdPrice: json.usdPrice,
exchangeAddress: SolAddress.fromJSON(json.exchangeAddress),
exchangeName: json.exchangeName,
};
return SolSPLTokenPrice.create(input);
};
SolSPLTokenPrice.prototype.toJSON = function () {
return {
nativePrice: this.nativePrice ? this.nativePrice.toJSON() : undefined,
usdPrice: this.usdPrice,
exchangeAddress: this.exchangeAddress.toJSON(),
exchangeName: this.exchangeName,
};
};
return SolSPLTokenPrice;
}());
var GetTokenPriceOperation = {
operationId: "getTokenPrice",
groupName: "token",
httpMethod: "get",
routePattern: "/token/{network}/{address}/price",
parameterNames: ["network", "address"],
hasResponse: true,
hasBody: false,
parseResponse: function (json) {
return SolSPLTokenPrice.fromJSON(json);
},
serializeRequest: function (request) {
var network = SolNetwork.create(request.network);
var address = SolAddress.create(request.address);
return {
network: network.toJSON(),
address: address.toJSON(),
};
},
};
var operations = [
GetTokenPriceOperation,
];
// $ref: #/paths/~1token~1{network}~1{address}~1price/get/parameters/0/schema
// typeName: getTokenPrice_network_Enum
var SolGetTokenPriceNetworkEnum = /** @class */ (function () {
function SolGetTokenPriceNetworkEnum() {
}
SolGetTokenPriceNetworkEnum.create = function (input) {
return input;
};
SolGetTokenPriceNetworkEnum.fromJSON = function (json) {
return json;
};
return SolGetTokenPriceNetworkEnum;
}());
/******************************************************************************

@@ -405,2 +526,12 @@ Copyright (c) Microsoft Corporation.

function __spreadArray(to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
}
var CommonSolUtilsConfig = {

@@ -728,13 +859,3 @@ defaultSolNetwork: {

function deserializeResponse(jsonResponse) {
return {
nativePrice: {
value: SolNative.create(jsonResponse.nativePrice.value, 'solana'),
decimals: jsonResponse.nativePrice.decimals,
name: jsonResponse.nativePrice.name,
symbol: jsonResponse.nativePrice.symbol,
},
usdPrice: jsonResponse.usdPrice,
exchangeAddress: SolAddress.create(jsonResponse.exchangeAddress),
exchangeName: jsonResponse.exchangeName,
};
return SolSPLTokenPrice.fromJSON(jsonResponse);
}

@@ -754,3 +875,3 @@ function serializeRequest(request, core) {

var operations = [
var operationsV2 = [
getBalanceOperation,

@@ -761,5 +882,8 @@ getNFTsOperation,

getNFTMetadataOperation,
getTokenPriceOperation,
];
/**
* @deprecated This list includes upgraded operations to the hybrid approach in the old format.
*/
var operationsV2All = __spreadArray(__spreadArray([], operationsV2, true), [getTokenPriceOperation], false);
export { CommonSolUtils, CommonSolUtilsConfig, CommonSolUtilsConfigSetup, SolAddress, SolNative, SolNetwork, SolNetworkResolver, getBalanceOperation, getNFTMetadataOperation, getNFTsOperation, getPortfolioOperation, getSPLOperation, getTokenPriceOperation, operations };
export { CommonSolUtils, CommonSolUtilsConfig, CommonSolUtilsConfigSetup, GetTokenPriceOperation, SolAddress, SolGetTokenPriceNetworkEnum, SolNative, SolNetwork, SolNetworkResolver, SolSPLNativePrice, SolSPLTokenPrice, getBalanceOperation, getNFTMetadataOperation, getNFTsOperation, getPortfolioOperation, getSPLOperation, getTokenPriceOperation, operations, operationsV2, operationsV2All };

225

lib/index.d.ts

@@ -11,3 +11,5 @@ import * as _moralisweb3_common_core from '@moralisweb3/common-core';

*/
type SolAddressish = SolAddress | string;
type SolAddressish = SolAddressInput;
type SolAddressInput = SolAddress | string;
type SolAddressJSON = string;
/**

@@ -28,3 +30,4 @@ * A representation of an address on the Solana network.

*/
static create(address: SolAddressish): SolAddress;
static create(address: SolAddressInput): SolAddress;
static fromJSON(address: SolAddressJSON): SolAddress;
private static parse;

@@ -51,3 +54,3 @@ constructor(address: string);

*/
toJSON(): string;
toJSON(): SolAddressJSON;
}

@@ -63,10 +66,5 @@

type SolNetworkName = typeof solNetworkNames[number];
type SolNetworkInput = SolNetwork | SolNetworkName | string;
type SolNetworkJSON = string;
/**
* A name of Solana network.
*
* @example "mainnet"
* @example "devnet"
*/
type SolNetworkNameish = SolNetworkName | string;
/**
* Valid input for a new SolNetwork instance.

@@ -79,3 +77,3 @@ * This can be an existing SolNetwork or a valid network name.

*/
type SolNetworkish = SolNetwork | SolNetworkNameish;
type SolNetworkish = SolNetworkInput;
/**

@@ -107,2 +105,3 @@ * A representation of a Solana network.

static create(network: SolNetworkish): SolNetwork;
static fromJSON(network: SolNetworkJSON): SolNetwork;
private static parse;

@@ -124,3 +123,3 @@ private constructor();

*/
toJSON(): string;
toJSON(): SolNetworkJSON;
/**

@@ -141,3 +140,5 @@ * @returns a string representing the network.

*/
type SolNativeish = SolNative | BigNumberish;
type SolNativeish = SolNativeInput;
type SolNativeInput = SolNative | BigNumberish;
type SolNativeJSON = string;
/**

@@ -162,2 +163,3 @@ * The SolNative class is a MoralisData that references to the value of Solana native currency SOL

static create(value: SolNativeish, unit?: SolNativeUnit): SolNative;
static fromJSON(json: SolNativeJSON): SolNative;
private static parse;

@@ -196,3 +198,3 @@ private constructor();

*/
toJSON(): string;
toJSON(): SolNativeJSON;
/**

@@ -223,2 +225,96 @@ * Converts the SolNative to a string.

interface SolSPLNativePriceJSON {
readonly value: string;
readonly decimals: number;
readonly name: string;
readonly symbol: string;
}
interface SolSPLNativePriceInput {
readonly value: string;
readonly decimals: number;
readonly name: string;
readonly symbol: string;
}
declare class SolSPLNativePrice {
static create(input: SolSPLNativePriceInput | SolSPLNativePrice): SolSPLNativePrice;
static fromJSON(json: SolSPLNativePriceJSON): SolSPLNativePrice;
readonly value: string;
readonly decimals: number;
readonly name: string;
readonly symbol: string;
private constructor();
toJSON(): SolSPLNativePriceJSON;
}
interface SolSPLTokenPriceJSON {
readonly nativePrice?: SolSPLNativePriceJSON;
readonly usdPrice: number;
readonly exchangeAddress: SolAddressJSON;
readonly exchangeName: string;
}
interface SolSPLTokenPriceInput {
readonly nativePrice?: SolSPLNativePriceInput | SolSPLNativePrice;
readonly usdPrice: number;
readonly exchangeAddress: SolAddressInput | SolAddress;
readonly exchangeName: string;
}
declare class SolSPLTokenPrice {
static create(input: SolSPLTokenPriceInput | SolSPLTokenPrice): SolSPLTokenPrice;
static fromJSON(json: SolSPLTokenPriceJSON): SolSPLTokenPrice;
readonly nativePrice?: SolSPLNativePrice;
readonly usdPrice: number;
readonly exchangeAddress: SolAddress;
readonly exchangeName: string;
private constructor();
toJSON(): SolSPLTokenPriceJSON;
}
interface GetTokenPriceOperationRequest {
/**
* @description The network to query
*/
readonly network: SolNetworkInput | SolNetwork;
/**
* @description The address of the token contract
*/
readonly address: SolAddressInput | SolAddress;
}
interface GetTokenPriceOperationRequestJSON {
readonly network: SolNetworkJSON;
readonly address: SolAddressJSON;
}
type GetTokenPriceOperationResponse = SolSPLTokenPrice;
type GetTokenPriceOperationResponseJSON = SolSPLTokenPriceJSON;
declare const GetTokenPriceOperation: {
operationId: string;
groupName: string;
httpMethod: string;
routePattern: string;
parameterNames: string[];
hasResponse: boolean;
hasBody: boolean;
parseResponse(json: SolSPLTokenPriceJSON): SolSPLTokenPrice;
serializeRequest(request: GetTokenPriceOperationRequest): GetTokenPriceOperationRequestJSON;
};
declare const operations$1: {
operationId: string;
groupName: string;
httpMethod: string;
routePattern: string;
parameterNames: string[];
hasResponse: boolean;
hasBody: boolean;
parseResponse(json: SolSPLTokenPriceJSON): SolSPLTokenPrice;
serializeRequest(request: GetTokenPriceOperationRequest): GetTokenPriceOperationRequestJSON;
}[];
type SolGetTokenPriceNetworkEnumJSON = "mainnet";
type SolGetTokenPriceNetworkEnumInput = "mainnet";
type SolGetTokenPriceNetworkEnumValue = "mainnet";
declare abstract class SolGetTokenPriceNetworkEnum {
static create(input: SolGetTokenPriceNetworkEnumInput | SolGetTokenPriceNetworkEnumValue): SolGetTokenPriceNetworkEnumValue;
static fromJSON(json: SolGetTokenPriceNetworkEnumJSON): SolGetTokenPriceNetworkEnumValue;
}
declare class CommonSolUtils extends Module {

@@ -283,3 +379,3 @@ static readonly moduleName = "solUtils";

SPLTokenPrice: {
nativePrice: components["schemas"]["SPLNativePrice"];
nativePrice?: components["schemas"]["SPLNativePrice"];
usdPrice: number;

@@ -291,3 +387,3 @@ exchangeAddress: string;

}
interface operations$1 {
interface operations {
/** Gets the native balance owned by a given network and address. */

@@ -434,4 +530,4 @@ balance: {

type OperationId$5 = 'balance';
type PathParams$5 = operations$1[OperationId$5]['parameters']['path'];
type SuccessResponse$5 = operations$1[OperationId$5]['responses']['200']['content']['application/json'];
type PathParams$5 = operations[OperationId$5]['parameters']['path'];
type SuccessResponse$5 = operations[OperationId$5]['responses']['200']['content']['application/json'];
interface GetBalanceRequest extends Camelize<Omit<PathParams$5, 'network' | 'address'>> {

@@ -456,4 +552,4 @@ network?: SolNetworkish;

type OperationId$4 = 'getNFTs';
type PathParams$4 = operations$1[OperationId$4]['parameters']['path'];
type SuccessResponse$4 = operations$1[OperationId$4]['responses']['200']['content']['application/json'];
type PathParams$4 = operations[OperationId$4]['parameters']['path'];
type SuccessResponse$4 = operations[OperationId$4]['responses']['200']['content']['application/json'];
interface GetNFTsRequest extends Camelize<Omit<PathParams$4, 'network' | 'address'>> {

@@ -483,4 +579,4 @@ network?: SolNetworkish;

type OperationId$3 = 'getPortfolio';
type PathParams$3 = operations$1[OperationId$3]['parameters']['path'];
type SuccessResponse$3 = operations$1[OperationId$3]['responses']['200']['content']['application/json'];
type PathParams$3 = operations[OperationId$3]['parameters']['path'];
type SuccessResponse$3 = operations[OperationId$3]['responses']['200']['content']['application/json'];
interface GetPortfolioRequest extends Camelize<Omit<PathParams$3, 'network' | 'address'>> {

@@ -520,4 +616,4 @@ network?: SolNetworkish;

type OperationId$2 = 'getSPL';
type PathParams$2 = operations$1[OperationId$2]['parameters']['path'];
type SuccessResponse$2 = operations$1[OperationId$2]['responses']['200']['content']['application/json'];
type PathParams$2 = operations[OperationId$2]['parameters']['path'];
type SuccessResponse$2 = operations[OperationId$2]['responses']['200']['content']['application/json'];
interface GetSPLRequest extends Camelize<Omit<PathParams$2, 'network' | 'address'>> {

@@ -548,4 +644,4 @@ network?: SolNetworkish;

type OperationId$1 = 'getNFTMetadata';
type PathParams$1 = operations$1[OperationId$1]['parameters']['path'];
type SuccessResponse$1 = operations$1[OperationId$1]['responses']['200']['content']['application/json'];
type PathParams$1 = operations[OperationId$1]['parameters']['path'];
type SuccessResponse$1 = operations[OperationId$1]['responses']['200']['content']['application/json'];
interface GetNFTMetadataRequest extends Camelize<Omit<PathParams$1, 'network' | 'address'>> {

@@ -583,4 +679,4 @@ network?: SolNetworkish;

type OperationId = 'getTokenPrice';
type PathParams = operations$1[OperationId]['parameters']['path'];
type SuccessResponse = operations$1[OperationId]['responses']['200']['content']['application/json'];
type PathParams = operations[OperationId]['parameters']['path'];
type SuccessResponse = operations[OperationId]['responses']['200']['content']['application/json'];
interface GetTokenPriceRequest extends Camelize<Omit<PathParams, 'network' | 'address'>> {

@@ -598,13 +694,3 @@ network?: SolNetworkish;

declare const getTokenPriceOperation: Operation<GetTokenPriceRequest, GetTokenPriceJSONRequest, GetTokenPriceResponse, GetTokenPriceJSONResponse>;
declare function deserializeResponse(jsonResponse: GetTokenPriceJSONResponse): {
nativePrice: {
value: SolNative;
decimals: number;
name: string;
symbol: string;
};
usdPrice: number;
exchangeAddress: SolAddress;
exchangeName: string;
};
declare function deserializeResponse(jsonResponse: GetTokenPriceJSONResponse): SolSPLTokenPrice;
declare function serializeRequest(request: GetTokenPriceRequest, core: Core): {

@@ -615,3 +701,3 @@ address: string;

declare const operations: (_moralisweb3_common_core.Operation<GetBalanceRequest, {
declare const operationsV2: (_moralisweb3_common_core.Operation<GetBalanceRequest, {
address: string;

@@ -661,16 +747,55 @@ network: "mainnet" | "devnet";

};
}, GetNFTMetadataJSONResponse> | _moralisweb3_common_core.Operation<GetTokenPriceRequest, {
}, GetNFTMetadataJSONResponse>)[];
/**
* @deprecated This list includes upgraded operations to the hybrid approach in the old format.
*/
declare const operationsV2All: (_moralisweb3_common_core.Operation<GetBalanceRequest, {
address: string;
network: "mainnet" | "devnet";
}, SolNative, GetBalanceJSONResponse> | _moralisweb3_common_core.Operation<GetNFTsRequest, {
address: string;
network: "mainnet" | "devnet";
}, {
nativePrice: {
value: SolNative;
decimals: number;
associatedTokenAddress: SolAddress;
mint: SolAddress;
name: string;
symbol: string;
}[], GetNFTsJSONResponse> | _moralisweb3_common_core.Operation<GetPortfolioRequest, {
address: string;
network: "mainnet" | "devnet";
}, {
nativeBalance: SolNative;
nfts: {
associatedTokenAddress: SolAddress;
mint: SolAddress;
name: string;
symbol: string;
}[];
tokens: {
associatedTokenAddress: SolAddress;
mint: SolAddress;
amount: SolNative;
name: string;
symbol: string;
}[];
}, GetPortfolioJSONResponse> | _moralisweb3_common_core.Operation<GetNFTMetadataRequest, {
address: string;
network: "mainnet" | "devnet";
}, {
mint: SolAddress;
standard: string;
name: string;
symbol: string;
metaplex: {
metadataUri: string;
updateAuthority: SolAddress;
sellerFeeBasisPoints: number;
primarySaleHappened: boolean;
isMutable: boolean;
masterEdition: boolean;
};
usdPrice: number;
exchangeAddress: SolAddress;
exchangeName: string;
}, GetTokenPriceJSONResponse>)[];
}, GetNFTMetadataJSONResponse> | _moralisweb3_common_core.Operation<GetTokenPriceRequest, {
address: string;
network: "mainnet" | "devnet";
}, SolSPLTokenPrice, GetTokenPriceJSONResponse>)[];

@@ -682,3 +807,3 @@ declare class CommonSolUtilsConfigSetup {

declare const CommonSolUtilsConfig: {
defaultSolNetwork: ConfigKey<SolNetworkish>;
defaultSolNetwork: ConfigKey<SolNetworkInput>;
};

@@ -690,2 +815,2 @@

export { CommonSolUtils, CommonSolUtilsConfig, CommonSolUtilsConfigSetup, GetBalanceJSONRequest, GetBalanceJSONResponse, GetBalanceRequest, GetBalanceResponse, GetBalanceResponseAdapter, GetNFTMetadataJSONRequest, GetNFTMetadataJSONResponse, GetNFTMetadataRequest, GetNFTMetadataResponse, GetNFTMetadataResponseAdapter, GetNFTsJSONRequest, GetNFTsJSONResponse, GetNFTsRequest, GetNFTsResponse, GetNFTsResponseAdapter, GetPortfolioJSONRequest, GetPortfolioJSONResponse, GetPortfolioRequest, GetPortfolioResponse, GetPortfolioResponseAdapter, GetSPLJSONRequest, GetSPLJSONResponse, GetSPLRequest, GetSPLResponse, GetSPLResponseAdapter, GetTokenPriceJSONRequest, GetTokenPriceJSONResponse, GetTokenPriceRequest, GetTokenPriceResponse, GetTokenPriceResponseAdapter, SolAddress, SolAddressish, SolNative, SolNativeUnit, SolNativeish, SolNetwork, SolNetworkName, SolNetworkNameish, SolNetworkResolver, SolNetworkish, getBalanceOperation, getNFTMetadataOperation, getNFTsOperation, getPortfolioOperation, getSPLOperation, getTokenPriceOperation, operations };
export { CommonSolUtils, CommonSolUtilsConfig, CommonSolUtilsConfigSetup, GetBalanceJSONRequest, GetBalanceJSONResponse, GetBalanceRequest, GetBalanceResponse, GetBalanceResponseAdapter, GetNFTMetadataJSONRequest, GetNFTMetadataJSONResponse, GetNFTMetadataRequest, GetNFTMetadataResponse, GetNFTMetadataResponseAdapter, GetNFTsJSONRequest, GetNFTsJSONResponse, GetNFTsRequest, GetNFTsResponse, GetNFTsResponseAdapter, GetPortfolioJSONRequest, GetPortfolioJSONResponse, GetPortfolioRequest, GetPortfolioResponse, GetPortfolioResponseAdapter, GetSPLJSONRequest, GetSPLJSONResponse, GetSPLRequest, GetSPLResponse, GetSPLResponseAdapter, GetTokenPriceJSONRequest, GetTokenPriceJSONResponse, GetTokenPriceOperation, GetTokenPriceOperationRequest, GetTokenPriceOperationRequestJSON, GetTokenPriceOperationResponse, GetTokenPriceOperationResponseJSON, GetTokenPriceRequest, GetTokenPriceResponse, GetTokenPriceResponseAdapter, SolAddress, SolAddressInput, SolAddressJSON, SolAddressish, SolGetTokenPriceNetworkEnum, SolGetTokenPriceNetworkEnumInput, SolGetTokenPriceNetworkEnumJSON, SolGetTokenPriceNetworkEnumValue, SolNative, SolNativeInput, SolNativeJSON, SolNativeUnit, SolNativeish, SolNetwork, SolNetworkInput, SolNetworkJSON, SolNetworkName, SolNetworkResolver, SolNetworkish, SolSPLNativePrice, SolSPLNativePriceInput, SolSPLNativePriceJSON, SolSPLTokenPrice, SolSPLTokenPriceInput, SolSPLTokenPriceJSON, getBalanceOperation, getNFTMetadataOperation, getNFTsOperation, getPortfolioOperation, getSPLOperation, getTokenPriceOperation, operations$1 as operations, operationsV2, operationsV2All };
{
"name": "@moralisweb3/common-sol-utils",
"author": "Moralis",
"version": "2.21.0",
"version": "2.22.0",
"license": "MIT",

@@ -57,3 +57,3 @@ "type": "module",

"dependencies": {
"@moralisweb3/common-core": "^2.21.0",
"@moralisweb3/common-core": "^2.22.0",
"bn.js": "^5.2.1",

@@ -60,0 +60,0 @@ "bs58": "^5.0.0",

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