Socket
Socket
Sign inDemoInstall

@moralisweb3/sol-utils

Package Overview
Dependencies
Maintainers
7
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@moralisweb3/sol-utils - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

76

lib/dataTypes/SolNative/SolNative.d.ts
import { MoralisData, MoralisDataFormatted, BigNumberish, BigNumber } from '@moralisweb3/core';
/**
* Type containing valid Solana native units
*/
export declare type SolNativeUnit = 'solana' | 'lamports' | number;
/**
* Valid input for a new SolNative instance.
* This can be an existing {@link SolNative} or a valid {@link BigNumberish} type
*/
export declare type SolNativeish = SolNative | BigNumberish;
export declare class SolNative implements MoralisData {
private readonly rawValue;
/**
* Create a new instance of SolNative from any valid {@link SolNativeish} value.
* @param value - the value to create the SolNative from
* @param unit - the unit of the value (optional), defaults to `solana`
* @returns a new instance of SolNative
* @example
* ```ts
* const native = SolNative.create(2, 'lamports');
* const native = SolNative.create(2);
*```
*/
static create(value: SolNativeish, unit?: SolNativeUnit): SolNative;
private static parse;
get value(): BigNumber;
get solana(): string;
get lamports(): string;
private constructor();
/**
* Compares two SolNativeish values.
* @param valueA - the first value to compare
* @param valueB - the second value to compare
* @returns true if the values are equal
* @example
* ```ts
* SolNative.equals(SolNative.create(1), SolNative.create(1)); // true
* ```
*/
static equals(valueA: SolNativeish, valueB: SolNativeish): boolean;
/**
* Compares SolNative with current instance.
* @param value - the value to compare with
* @returns true if the values are equal
* @example
* ```ts
* const native = SolNative.create(2, 'lamports');
* native.equals(SolNative.create(1)); // false
* ```
*/
equals(value: SolNative): boolean;
/**
* Converts the SolNative to a string.
* @returns the value of the SolNative as a string
* @example `native.format()`
*/
format(): MoralisDataFormatted;
equals(value: SolNative): boolean;
/**
* Converts the SolNative to a string.
* @returns the value of the SolNative as a string
* @example `native.toJSON()`
*/
toJSON(): string;
/**
* Converts the SolNative to a string.
* @returns the value of the SolNative as a string
* @example `native.toString()`
*/
toString(): string;
/**
* @returns the value of the SolNative as a BigNumber
* @example `native.value`
*/
get value(): BigNumber;
/**
* Converts the SolNative to a solana unit.
* @returns the value of the SolNative as a solana string
* @example `native.solana`
*/
get solana(): string;
/**
* Converts the SolNative to a string.
* @returns the value of the SolNative as a string
* @example `native.lamports`
*/
get lamports(): string;
}
//# sourceMappingURL=SolNative.d.ts.map

@@ -13,2 +13,13 @@ "use strict";

}
/**
* Create a new instance of SolNative from any valid {@link SolNativeish} value.
* @param value - the value to create the SolNative from
* @param unit - the unit of the value (optional), defaults to `solana`
* @returns a new instance of SolNative
* @example
* ```ts
* const native = SolNative.create(2, 'lamports');
* const native = SolNative.create(2);
*```
*/
SolNative.create = function (value, unit) {

@@ -37,3 +48,60 @@ if (value instanceof SolNative) {

};
/**
* Compares two SolNativeish values.
* @param valueA - the first value to compare
* @param valueB - the second value to compare
* @returns true if the values are equal
* @example
* ```ts
* SolNative.equals(SolNative.create(1), SolNative.create(1)); // true
* ```
*/
SolNative.equals = function (valueA, valueB) {
var solNativeA = SolNative.create(valueA);
var solNativeB = SolNative.create(valueB);
return solNativeA.lamports === solNativeB.lamports;
};
/**
* Compares SolNative with current instance.
* @param value - the value to compare with
* @returns true if the values are equal
* @example
* ```ts
* const native = SolNative.create(2, 'lamports');
* native.equals(SolNative.create(1)); // false
* ```
*/
SolNative.prototype.equals = function (value) {
return SolNative.equals(this, value);
};
/**
* Converts the SolNative to a string.
* @returns the value of the SolNative as a string
* @example `native.format()`
*/
SolNative.prototype.format = function () {
// TODO: add `format` argument
return this.lamports;
};
/**
* Converts the SolNative to a string.
* @returns the value of the SolNative as a string
* @example `native.toJSON()`
*/
SolNative.prototype.toJSON = function () {
return this.lamports;
};
/**
* Converts the SolNative to a string.
* @returns the value of the SolNative as a string
* @example `native.toString()`
*/
SolNative.prototype.toString = function () {
return this.lamports;
};
Object.defineProperty(SolNative.prototype, "value", {
/**
* @returns the value of the SolNative as a BigNumber
* @example `native.value`
*/
get: function () {

@@ -46,2 +114,7 @@ return this.rawValue;

Object.defineProperty(SolNative.prototype, "solana", {
/**
* Converts the SolNative to a solana unit.
* @returns the value of the SolNative as a solana string
* @example `native.solana`
*/
get: function () {

@@ -54,2 +127,7 @@ return this.rawValue.toDecimal(unitToDecimals['solana']);

Object.defineProperty(SolNative.prototype, "lamports", {
/**
* Converts the SolNative to a string.
* @returns the value of the SolNative as a string
* @example `native.lamports`
*/
get: function () {

@@ -61,15 +139,2 @@ return this.rawValue.toString();

});
SolNative.prototype.format = function () {
// TODO: add `format` argument
return this.lamports;
};
SolNative.prototype.equals = function (value) {
return this.lamports === value.lamports;
};
SolNative.prototype.toJSON = function () {
return this.lamports;
};
SolNative.prototype.toString = function () {
return this.lamports;
};
return SolNative;

@@ -76,0 +141,0 @@ }());

4

package.json
{
"name": "@moralisweb3/sol-utils",
"author": "Moralis",
"version": "2.2.0",
"version": "2.3.0",
"license": "MIT",

@@ -28,5 +28,5 @@ "private": false,

"dependencies": {
"@moralisweb3/core": "^2.2.0",
"@moralisweb3/core": "^2.3.0",
"@solana/web3.js": "^1.55.0"
}
}

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