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

@0xsequence/utils

Package Overview
Dependencies
Maintainers
6
Versions
477
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@0xsequence/utils - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

68

dist/0xsequence-utils.cjs.dev.js

@@ -29,26 +29,2 @@ 'use strict';

const base64Encode = val => {
return jsBase64.Base64.encode(val, true);
};
const base64EncodeObject = obj => {
return jsBase64.Base64.encode(JSON.stringify(obj), true);
};
const base64Decode = encodedString => {
if (encodedString === null || encodedString === undefined) {
return undefined;
}
return jsBase64.Base64.decode(encodedString);
};
const base64DecodeObject = encodedObject => {
if (encodedObject === null || encodedObject === undefined) {
return undefined;
}
return JSON.parse(jsBase64.Base64.decode(encodedObject));
};
// Monkey patch toJSON on BigInt to return a string
BigInt.prototype.toJSON = function () {
return this.toString();
};
const MAX_UINT_256 = BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');

@@ -113,2 +89,44 @@

// JSON.stringify doesn't handle BigInts, so we need to replace them with objects
const bigintReplacer = (key, value) => {
if (typeof value === 'bigint') {
return {
$bigint: value.toString()
};
}
return value;
};
// JSON.parse will need to convert our serialized bigints back into BigInt
const bigintReviver = (key, value) => {
if (value !== null && typeof value === 'object' && '$bigint' in value && typeof value.$bigint === 'string') {
return BigInt(value.$bigint);
}
// BigNumber compatibility with older versions of sequence.js with ethers v5
if (value !== null && typeof value === 'object' && value.type === 'BigNumber' && ethers.ethers.isHexString(value.hex)) {
return BigInt(value.hex);
}
return value;
};
const base64Encode = val => {
return jsBase64.Base64.encode(val, true);
};
const base64EncodeObject = obj => {
return jsBase64.Base64.encode(JSON.stringify(obj, bigintReplacer), true);
};
const base64Decode = encodedString => {
if (encodedString === null || encodedString === undefined) {
return undefined;
}
return jsBase64.Base64.decode(encodedString);
};
const base64DecodeObject = encodedObject => {
if (encodedObject === null || encodedObject === undefined) {
return undefined;
}
return JSON.parse(jsBase64.Base64.decode(encodedObject), bigintReviver);
};
const encodeMessageDigest = message => {

@@ -683,2 +701,4 @@ if (typeof message === 'string') {

exports.base64EncodeObject = base64EncodeObject;
exports.bigintReplacer = bigintReplacer;
exports.bigintReviver = bigintReviver;
exports.configureLogger = configureLogger;

@@ -685,0 +705,0 @@ exports.defineProperties = defineProperties;

@@ -29,26 +29,2 @@ 'use strict';

const base64Encode = val => {
return jsBase64.Base64.encode(val, true);
};
const base64EncodeObject = obj => {
return jsBase64.Base64.encode(JSON.stringify(obj), true);
};
const base64Decode = encodedString => {
if (encodedString === null || encodedString === undefined) {
return undefined;
}
return jsBase64.Base64.decode(encodedString);
};
const base64DecodeObject = encodedObject => {
if (encodedObject === null || encodedObject === undefined) {
return undefined;
}
return JSON.parse(jsBase64.Base64.decode(encodedObject));
};
// Monkey patch toJSON on BigInt to return a string
BigInt.prototype.toJSON = function () {
return this.toString();
};
const MAX_UINT_256 = BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');

@@ -113,2 +89,44 @@

// JSON.stringify doesn't handle BigInts, so we need to replace them with objects
const bigintReplacer = (key, value) => {
if (typeof value === 'bigint') {
return {
$bigint: value.toString()
};
}
return value;
};
// JSON.parse will need to convert our serialized bigints back into BigInt
const bigintReviver = (key, value) => {
if (value !== null && typeof value === 'object' && '$bigint' in value && typeof value.$bigint === 'string') {
return BigInt(value.$bigint);
}
// BigNumber compatibility with older versions of sequence.js with ethers v5
if (value !== null && typeof value === 'object' && value.type === 'BigNumber' && ethers.ethers.isHexString(value.hex)) {
return BigInt(value.hex);
}
return value;
};
const base64Encode = val => {
return jsBase64.Base64.encode(val, true);
};
const base64EncodeObject = obj => {
return jsBase64.Base64.encode(JSON.stringify(obj, bigintReplacer), true);
};
const base64Decode = encodedString => {
if (encodedString === null || encodedString === undefined) {
return undefined;
}
return jsBase64.Base64.decode(encodedString);
};
const base64DecodeObject = encodedObject => {
if (encodedObject === null || encodedObject === undefined) {
return undefined;
}
return JSON.parse(jsBase64.Base64.decode(encodedObject), bigintReviver);
};
const encodeMessageDigest = message => {

@@ -683,2 +701,4 @@ if (typeof message === 'string') {

exports.base64EncodeObject = base64EncodeObject;
exports.bigintReplacer = bigintReplacer;
exports.bigintReviver = bigintReviver;
exports.configureLogger = configureLogger;

@@ -685,0 +705,0 @@ exports.defineProperties = defineProperties;

@@ -25,26 +25,2 @@ import { Base64 } from 'js-base64';

const base64Encode = val => {
return Base64.encode(val, true);
};
const base64EncodeObject = obj => {
return Base64.encode(JSON.stringify(obj), true);
};
const base64Decode = encodedString => {
if (encodedString === null || encodedString === undefined) {
return undefined;
}
return Base64.decode(encodedString);
};
const base64DecodeObject = encodedObject => {
if (encodedObject === null || encodedObject === undefined) {
return undefined;
}
return JSON.parse(Base64.decode(encodedObject));
};
// Monkey patch toJSON on BigInt to return a string
BigInt.prototype.toJSON = function () {
return this.toString();
};
const MAX_UINT_256 = BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');

@@ -109,2 +85,44 @@

// JSON.stringify doesn't handle BigInts, so we need to replace them with objects
const bigintReplacer = (key, value) => {
if (typeof value === 'bigint') {
return {
$bigint: value.toString()
};
}
return value;
};
// JSON.parse will need to convert our serialized bigints back into BigInt
const bigintReviver = (key, value) => {
if (value !== null && typeof value === 'object' && '$bigint' in value && typeof value.$bigint === 'string') {
return BigInt(value.$bigint);
}
// BigNumber compatibility with older versions of sequence.js with ethers v5
if (value !== null && typeof value === 'object' && value.type === 'BigNumber' && ethers.isHexString(value.hex)) {
return BigInt(value.hex);
}
return value;
};
const base64Encode = val => {
return Base64.encode(val, true);
};
const base64EncodeObject = obj => {
return Base64.encode(JSON.stringify(obj, bigintReplacer), true);
};
const base64Decode = encodedString => {
if (encodedString === null || encodedString === undefined) {
return undefined;
}
return Base64.decode(encodedString);
};
const base64DecodeObject = encodedObject => {
if (encodedObject === null || encodedObject === undefined) {
return undefined;
}
return JSON.parse(Base64.decode(encodedObject), bigintReviver);
};
const encodeMessageDigest = message => {

@@ -671,2 +689,2 @@ if (typeof message === 'string') {

export { Logger, MAX_UINT_256, MerkleTreeGenerator, PromiseCache, base64Decode, base64DecodeObject, base64Encode, base64EncodeObject, configureLogger, defineProperties, encodeMessageDigest, encodeTypedDataDigest, encodeTypedDataHash, extractProjectIdFromAccessKey, formatEther, formatUnits, getFetchRequest, getRandomInt, getSaleItemsLeaf, isBigNumberish, isBrowser, isNode, jwtDecodeClaims, logger, packMessageData, parseEther, parseUnits, promisify, queryStringFromObject, queryStringToObject, resolveProperties, sanitizeAlphanumeric, sanitizeHost, sanitizeNumberString, sleep, subDigestOf, toHexString, urlClean };
export { Logger, MAX_UINT_256, MerkleTreeGenerator, PromiseCache, base64Decode, base64DecodeObject, base64Encode, base64EncodeObject, bigintReplacer, bigintReviver, configureLogger, defineProperties, encodeMessageDigest, encodeTypedDataDigest, encodeTypedDataHash, extractProjectIdFromAccessKey, formatEther, formatUnits, getFetchRequest, getRandomInt, getSaleItemsLeaf, isBigNumberish, isBrowser, isNode, jwtDecodeClaims, logger, packMessageData, parseEther, parseUnits, promisify, queryStringFromObject, queryStringToObject, resolveProperties, sanitizeAlphanumeric, sanitizeHost, sanitizeNumberString, sleep, subDigestOf, toHexString, urlClean };
import { ethers } from 'ethers';
declare global {
interface BigInt {
toJSON(): string;
}
}
export declare const MAX_UINT_256: bigint;

@@ -14,1 +9,3 @@ export declare const isBigNumberish: (value: any) => value is ethers.BigNumberish;

export declare const formatEther: (value: bigint) => string;
export declare const bigintReplacer: (key: string, value: any) => any;
export declare const bigintReviver: (key: string, value: any) => any;
{
"name": "@0xsequence/utils",
"version": "2.0.0",
"version": "2.0.1",
"description": "utils sub-package for Sequence",

@@ -5,0 +5,0 @@ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/utils",

import { Base64 } from 'js-base64'
import { bigintReplacer, bigintReviver } from './bigint'

@@ -8,3 +9,3 @@ export const base64Encode = (val: string): string => {

export const base64EncodeObject = (obj: any): string => {
return Base64.encode(JSON.stringify(obj), true)
return Base64.encode(JSON.stringify(obj, bigintReplacer), true)
}

@@ -23,3 +24,3 @@

}
return JSON.parse(Base64.decode(encodedObject)) as T
return JSON.parse(Base64.decode(encodedObject), bigintReviver) as T
}
import { ethers } from 'ethers'
// Monkey patch toJSON on BigInt to return a string
declare global {
interface BigInt {
toJSON(): string
}
}
BigInt.prototype.toJSON = function () {
return this.toString()
}
export const MAX_UINT_256 = BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff')

@@ -97,1 +85,24 @@

export const formatEther = (value: bigint): string => formatUnits(value, 18)
// JSON.stringify doesn't handle BigInts, so we need to replace them with objects
export const bigintReplacer = (key: string, value: any): any => {
if (typeof value === 'bigint') {
return { $bigint: value.toString() }
}
return value
}
// JSON.parse will need to convert our serialized bigints back into BigInt
export const bigintReviver = (key: string, value: any): any => {
if (value !== null && typeof value === 'object' && '$bigint' in value && typeof value.$bigint === 'string') {
return BigInt(value.$bigint)
}
// BigNumber compatibility with older versions of sequence.js with ethers v5
if (value !== null && typeof value === 'object' && value.type === 'BigNumber' && ethers.isHexString(value.hex)) {
return BigInt(value.hex)
}
return value
}
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