Socket
Socket
Sign inDemoInstall

@moralisweb3/sol-utils

Package Overview
Dependencies
Maintainers
8
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.0.3 to 2.1.0

40

lib/dataTypes/SolAddress/SolAddress.d.ts
import { MoralisData, MoralisDataFormatted } from '@moralisweb3/core';
/**
* Valid input for a new SolAddress instance.
* This can be an existing SolAddress or a valid address string.
*
* @example "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM"
* @example SolAddress.create("9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM")
*/
export declare type SolAddressish = SolAddress | string;
/**
* A representation of an address on the Solana network.
*
* Use this class any time you work with an address.
*
* @category DataType
*/
export declare class SolAddress implements MoralisData {
readonly address: string;
/**
* Create a new instance of SolAddress from any valid address input.
*
* @example `const address = SolAddress.create("9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM")`
* @throws an error when a passed address is invalid.
*/
static create(address: SolAddressish): SolAddress;
private static parse;
constructor(address: string);
/**
* Formats the address to a specific format.
* Currently returns a string representing the address.
* @example "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM"
*/
format(): MoralisDataFormatted;
equals(address: SolAddress): boolean;
/**
* Checks the equality of the current address with another Solana address.
* @example `address.equals("9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM")`
* @example `address.equals(SolAddress.create("9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM"))`
*/
equals(address: SolAddressish): boolean;
/**
* @returns a string representing the address.
* @example "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM"
*/
toString(): string;
/**
* @returns a string representing the address.
* @example "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM"
*/
toJSON(): string;
}
//# sourceMappingURL=SolAddress.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SolAddress = void 0;
var core_1 = require("@moralisweb3/core");
var web3_js_1 = require("@solana/web3.js");
/**
* A representation of an address on the Solana network.
*
* Use this class any time you work with an address.
*
* @category DataType
*/
var SolAddress = /** @class */ (function () {

@@ -8,2 +17,8 @@ function SolAddress(address) {

}
/**
* Create a new instance of SolAddress from any valid address input.
*
* @example `const address = SolAddress.create("9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM")`
* @throws an error when a passed address is invalid.
*/
SolAddress.create = function (address) {

@@ -13,5 +28,15 @@ return address instanceof SolAddress ? address : new SolAddress(SolAddress.parse(address));

SolAddress.parse = function (address) {
// TODO: add address validation
if (!web3_js_1.PublicKey.isOnCurve(address)) {
throw new core_1.MoralisCoreError({
code: core_1.CoreErrorCode.INVALID_ARGUMENT,
message: 'Invalid Solana address provided',
});
}
return address;
};
/**
* Formats the address to a specific format.
* Currently returns a string representing the address.
* @example "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM"
*/
SolAddress.prototype.format = function () {

@@ -21,8 +46,21 @@ // TODO: add `format` argument

};
/**
* Checks the equality of the current address with another Solana address.
* @example `address.equals("9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM")`
* @example `address.equals(SolAddress.create("9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM"))`
*/
SolAddress.prototype.equals = function (address) {
return this.address === address.address;
return this.address === SolAddress.create(address).address;
};
/**
* @returns a string representing the address.
* @example "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM"
*/
SolAddress.prototype.toString = function () {
return this.address;
};
/**
* @returns a string representing the address.
* @example "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM"
*/
SolAddress.prototype.toJSON = function () {

@@ -29,0 +67,0 @@ return this.address;

8

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

@@ -17,7 +17,4 @@ "private": false,

"test:watch": "yarn run test --watch",
"format": "prettier . \"**/*.+(js|ts|json)\" --write",
"lint": "eslint . --ext .js,.ts,.tsx,jsx",
"format:check": "prettier . \"**/*.+(js|ts|json)\" --check",
"clean": "rm -rf lib && rm -rf lib.esm && rm -rf tsconfig.tsbuildinfo",
"gen:types": "openapi-typescript https://solana-gateway.moralis.io/api-json/ --output src/generated/types.ts",
"build": "tsc",

@@ -32,4 +29,5 @@ "dev": "tsc --watch"

"dependencies": {
"@moralisweb3/core": "^2.0.3"
"@moralisweb3/core": "^2.1.0",
"@solana/web3.js": "^1.53.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