Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rarible/types

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rarible/types - npm Package Compare versions

Comparing version 0.10.0-alpha.38 to 0.10.0-alpha.39

build/blockchains/aptos/fn/index.d.ts

41

build/blockchains/aptos/address/index.d.ts
import type { AbstractAddress } from "../../common/address.js";
import { BlockchainLayer1Enum } from "../../union/enum/domain.js";
/**
* Represents normalized (64chars with 0-pad) address of resource
* in Aptos blockchain
*
* @example 0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b
* @see https://aptos.dev/concepts/accounts
*/
export type AptosAddress = AbstractAddress<BlockchainLayer1Enum.APTOS>;
export declare const aptosAddressRegExp: RegExp;
/**
* Checks Short AND Long formats of address with or without 0-pad
*
* @example 0x1
* @example 0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b
*/
export declare function isAptosAddress(address: string): address is AptosAddress;
export declare const aptosAddressLongRegExp: RegExp;
/**
* Checks Long formats of address with or without 0-pad
*
* @example 0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b
*/
export declare function isAptosLongAddress(address: string): address is AptosAddress;
/**
* Checks Long format of address with 0-pad
*/
export declare const aptosAddressValidator: import("../../common/common.js").ILayer1fulValidator<BlockchainLayer1Enum.APTOS, AptosAddress>;
/**
* Check and convert Aptos-compatible addresses
*
* @note it does normalization (0-pad and lowercase)
* @example 0x1
* @example 0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b
* @see https://aptos.dev/concepts/accounts
*/
export declare function toAptosAddress(address: string): AptosAddress;
export declare function toAptosAddressSafe(address: string): AptosAddress | undefined;
/**
* Removes 0-pad from address
*/
export declare function shortenAptosAddress(address: AptosAddress): AptosAddress;
/**
* Generates random Aptos address
*
* @example 0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b
*/
export declare function randomAptosAddress(): AptosAddress;

60

build/blockchains/aptos/address/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.randomAptosAddress = exports.toAptosAddressSafe = exports.toAptosAddress = exports.aptosAddressValidator = exports.isAptosAddress = void 0;
exports.randomAptosAddress = exports.shortenAptosAddress = exports.toAptosAddressSafe = exports.toAptosAddress = exports.aptosAddressValidator = exports.isAptosLongAddress = exports.aptosAddressLongRegExp = exports.isAptosAddress = exports.aptosAddressRegExp = void 0;
const index_js_1 = require("../../../common/binary/index.js");

@@ -8,10 +8,35 @@ const address_js_1 = require("../../common/address.js");

const domain_js_1 = require("../../union/enum/domain.js");
// Regular expression to validate an Aptos address.
// eslint-disable-next-line no-useless-escape
const aptosAddressRegExp = new RegExp(/^0[xX][0-9a-fA-F]{1,66}(\:\:[^:\s]+){0,2}$/);
exports.aptosAddressRegExp = new RegExp(/^0x[a-fA-F0-9]{1,64}$/);
/**
* Checks Short AND Long formats of address with or without 0-pad
*
* @example 0x1
* @example 0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b
*/
function isAptosAddress(address) {
return aptosAddressRegExp.test(address);
return exports.aptosAddressRegExp.test(address);
}
exports.isAptosAddress = isAptosAddress;
exports.aptosAddressLongRegExp = new RegExp(/^0x[a-fA-F0-9]{64}$/);
/**
* Checks Long formats of address with or without 0-pad
*
* @example 0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b
*/
function isAptosLongAddress(address) {
return exports.aptosAddressLongRegExp.test(address);
}
exports.isAptosLongAddress = isAptosLongAddress;
/**
* Checks Long format of address with 0-pad
*/
exports.aptosAddressValidator = (0, common_js_1.createLayer1fulValidator)(domain_js_1.BlockchainLayer1Enum.APTOS, isAptosAddress);
/**
* Check and convert Aptos-compatible addresses
*
* @note it does normalization (0-pad and lowercase)
* @example 0x1
* @example 0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b
* @see https://aptos.dev/concepts/accounts
*/
function toAptosAddress(address) {

@@ -25,7 +50,28 @@ const safe = toAptosAddressSafe(address);

function toAptosAddressSafe(address) {
if (isAptosAddress(address))
return address;
if (isAptosAddress(address)) {
const lowercaseAddress = address.toLowerCase();
const addressWithoutPrefix = lowercaseAddress.startsWith("0x") ? lowercaseAddress.slice(2) : lowercaseAddress;
const addressWithPadding = addressWithoutPrefix.padStart(64, "0");
return `0x${addressWithPadding}`;
}
return undefined;
}
exports.toAptosAddressSafe = toAptosAddressSafe;
/**
* Removes 0-pad from address
*/
function shortenAptosAddress(address) {
if (address.startsWith("0x")) {
// Remove the '0x' prefix and then strip leading zeros
let trimmedAddress = address.slice(2).replace(/^0+/, "");
return ("0x" + (trimmedAddress || "0"));
}
return address;
}
exports.shortenAptosAddress = shortenAptosAddress;
/**
* Generates random Aptos address
*
* @example 0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b
*/
function randomAptosAddress() {

@@ -32,0 +78,0 @@ return toAptosAddress((0, index_js_1.randomBinary)(32));

export * from "./address/index.js";
export * from "./hash/index.js";
export * from "./fn/index.js";
export * from "./module/index.js";

@@ -6,1 +6,3 @@ "use strict";

tslib_1.__exportStar(require("./hash/index.js"), exports);
tslib_1.__exportStar(require("./fn/index.js"), exports);
tslib_1.__exportStar(require("./module/index.js"), exports);

4

build/blockchains/evm/address/index.d.ts

@@ -16,7 +16,7 @@ import type { AbstractAddress } from "../../common/address.js";

* Check and convert EVM-compatible addresses
* @note instead of toEVMAddress it return original value
* @deprecated please use toEVMAddress instead
*/
export declare function toEVMAddressStrict(value: string): EVMAddress;
export declare const toEVMAddressStrict: typeof toEVMAddress;
export declare function toEVMAddressSafe(raw: string): EVMAddress | undefined;
export declare const EVM_ZERO_ADDRESS: EVMAddress;
export declare function randomEVMAddress(): EVMAddress;

@@ -19,19 +19,19 @@ "use strict";

function toEVMAddress(value) {
return toEVMAddressStrict(value).toLowerCase();
const parsed = toEVMAddressSafe(value);
if (!parsed)
throw new address_js_1.InvalidAddressError(index_js_2.BlockchainLayer1Enum.ETHEREUM, value);
return parsed;
}
exports.toEVMAddress = toEVMAddress;
function normalizeEVMAddress(str) {
return str.toLowerCase();
}
/**
* Check and convert EVM-compatible addresses
* @note instead of toEVMAddress it return original value
* @deprecated please use toEVMAddress instead
*/
function toEVMAddressStrict(value) {
const safe = toEVMAddressSafe(value);
if (!safe)
throw new address_js_1.InvalidAddressError(index_js_2.BlockchainLayer1Enum.ETHEREUM, value);
return safe;
}
exports.toEVMAddressStrict = toEVMAddressStrict;
exports.toEVMAddressStrict = toEVMAddress;
function toEVMAddressSafe(raw) {
if (isEVMAddress(raw))
return raw;
return normalizeEVMAddress(raw);
return undefined;

@@ -38,0 +38,0 @@ }

import type { AbstractAddress } from "../../common/address.js";
import { BlockchainLayer1Enum } from "../../union/enum/domain.js";
/**
* Represents normalized (64chars with 0-pad) address of resource
* in Aptos blockchain
*
* @example 0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b
* @see https://aptos.dev/concepts/accounts
*/
export type AptosAddress = AbstractAddress<BlockchainLayer1Enum.APTOS>;
export declare const aptosAddressRegExp: RegExp;
/**
* Checks Short AND Long formats of address with or without 0-pad
*
* @example 0x1
* @example 0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b
*/
export declare function isAptosAddress(address: string): address is AptosAddress;
export declare const aptosAddressLongRegExp: RegExp;
/**
* Checks Long formats of address with or without 0-pad
*
* @example 0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b
*/
export declare function isAptosLongAddress(address: string): address is AptosAddress;
/**
* Checks Long format of address with 0-pad
*/
export declare const aptosAddressValidator: import("../../common/common.js").ILayer1fulValidator<BlockchainLayer1Enum.APTOS, AptosAddress>;
/**
* Check and convert Aptos-compatible addresses
*
* @note it does normalization (0-pad and lowercase)
* @example 0x1
* @example 0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b
* @see https://aptos.dev/concepts/accounts
*/
export declare function toAptosAddress(address: string): AptosAddress;
export declare function toAptosAddressSafe(address: string): AptosAddress | undefined;
/**
* Removes 0-pad from address
*/
export declare function shortenAptosAddress(address: AptosAddress): AptosAddress;
/**
* Generates random Aptos address
*
* @example 0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b
*/
export declare function randomAptosAddress(): AptosAddress;

@@ -5,9 +5,33 @@ import { randomBinary } from "../../../common/binary/index.js";

import { BlockchainLayer1Enum } from "../../union/enum/domain.js";
// Regular expression to validate an Aptos address.
// eslint-disable-next-line no-useless-escape
const aptosAddressRegExp = new RegExp(/^0[xX][0-9a-fA-F]{1,66}(\:\:[^:\s]+){0,2}$/);
export const aptosAddressRegExp = new RegExp(/^0x[a-fA-F0-9]{1,64}$/);
/**
* Checks Short AND Long formats of address with or without 0-pad
*
* @example 0x1
* @example 0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b
*/
export function isAptosAddress(address) {
return aptosAddressRegExp.test(address);
}
export const aptosAddressLongRegExp = new RegExp(/^0x[a-fA-F0-9]{64}$/);
/**
* Checks Long formats of address with or without 0-pad
*
* @example 0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b
*/
export function isAptosLongAddress(address) {
return aptosAddressLongRegExp.test(address);
}
/**
* Checks Long format of address with 0-pad
*/
export const aptosAddressValidator = createLayer1fulValidator(BlockchainLayer1Enum.APTOS, isAptosAddress);
/**
* Check and convert Aptos-compatible addresses
*
* @note it does normalization (0-pad and lowercase)
* @example 0x1
* @example 0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b
* @see https://aptos.dev/concepts/accounts
*/
export function toAptosAddress(address) {

@@ -20,8 +44,28 @@ const safe = toAptosAddressSafe(address);

export function toAptosAddressSafe(address) {
if (isAptosAddress(address))
return address;
if (isAptosAddress(address)) {
const lowercaseAddress = address.toLowerCase();
const addressWithoutPrefix = lowercaseAddress.startsWith("0x") ? lowercaseAddress.slice(2) : lowercaseAddress;
const addressWithPadding = addressWithoutPrefix.padStart(64, "0");
return `0x${addressWithPadding}`;
}
return undefined;
}
/**
* Removes 0-pad from address
*/
export function shortenAptosAddress(address) {
if (address.startsWith("0x")) {
// Remove the '0x' prefix and then strip leading zeros
let trimmedAddress = address.slice(2).replace(/^0+/, "");
return ("0x" + (trimmedAddress || "0"));
}
return address;
}
/**
* Generates random Aptos address
*
* @example 0xeeff357ea5c1a4e7bc11b2b17ff2dc2dcca69750bfef1e1ebcaccf8c8018175b
*/
export function randomAptosAddress() {
return toAptosAddress(randomBinary(32));
}
export * from "./address/index.js";
export * from "./hash/index.js";
export * from "./fn/index.js";
export * from "./module/index.js";
export * from "./address/index.js";
export * from "./hash/index.js";
export * from "./fn/index.js";
export * from "./module/index.js";

@@ -16,7 +16,7 @@ import type { AbstractAddress } from "../../common/address.js";

* Check and convert EVM-compatible addresses
* @note instead of toEVMAddress it return original value
* @deprecated please use toEVMAddress instead
*/
export declare function toEVMAddressStrict(value: string): EVMAddress;
export declare const toEVMAddressStrict: typeof toEVMAddress;
export declare function toEVMAddressSafe(raw: string): EVMAddress | undefined;
export declare const EVM_ZERO_ADDRESS: EVMAddress;
export declare function randomEVMAddress(): EVMAddress;

@@ -15,17 +15,18 @@ import { randomBinary } from "../../../common/binary/index.js";

export function toEVMAddress(value) {
return toEVMAddressStrict(value).toLowerCase();
const parsed = toEVMAddressSafe(value);
if (!parsed)
throw new InvalidAddressError(BlockchainLayer1Enum.ETHEREUM, value);
return parsed;
}
function normalizeEVMAddress(str) {
return str.toLowerCase();
}
/**
* Check and convert EVM-compatible addresses
* @note instead of toEVMAddress it return original value
* @deprecated please use toEVMAddress instead
*/
export function toEVMAddressStrict(value) {
const safe = toEVMAddressSafe(value);
if (!safe)
throw new InvalidAddressError(BlockchainLayer1Enum.ETHEREUM, value);
return safe;
}
export const toEVMAddressStrict = toEVMAddress;
export function toEVMAddressSafe(raw) {
if (isEVMAddress(raw))
return raw;
return normalizeEVMAddress(raw);
return undefined;

@@ -32,0 +33,0 @@ }

{
"name": "@rarible/types",
"version": "0.10.0-alpha.38",
"version": "0.10.0-alpha.39",
"keywords": [

@@ -54,3 +54,3 @@ "rarible",

"dependencies": {
"@rarible/utils": "^0.10.0-alpha.38"
"@rarible/utils": "^0.10.0-alpha.39"
},

@@ -70,3 +70,3 @@ "peerDependencies": {

},
"gitHead": "3e57373df83facf46158f93d55c284d9f5504204"
"gitHead": "6f97458bd0c8dfe59b044daff6f6b69aee05aa84"
}

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