Socket
Socket
Sign inDemoInstall

@0xsequence/sessions

Package Overview
Dependencies
Maintainers
0
Versions
255
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@0xsequence/sessions - npm Package Compare versions

Comparing version 0.0.0-20240812142652 to 0.0.0-20240814043648

2

dist/declarations/src/tracker.d.ts

@@ -57,3 +57,3 @@ import { commons } from '@0xsequence/core';

digest: string;
chainId: bigint;
chainId: ethers.BigNumber;
signature: string;

@@ -60,0 +60,0 @@ };

import { commons } from '@0xsequence/core';
import { migrator } from '@0xsequence/migration';
import { ethers } from 'ethers';
import { ConfigTracker, PresignedConfig, PresignedConfigLink } from "../tracker.js";
import { ethers } from 'ethers';
export declare class CachedTracker implements migrator.PresignedMigrationTracker, ConfigTracker {

@@ -41,3 +41,3 @@ private readonly tracker;

digest: string;
chainId: bigint;
chainId: ethers.BigNumber;
signature: string;

@@ -44,0 +44,0 @@ };

import { commons } from '@0xsequence/core';
import { migrator } from '@0xsequence/migration';
import { ethers } from 'ethers';
import { ConfigTracker, PresignedConfig, PresignedConfigLink } from "../tracker.js";
import { ethers } from 'ethers';
export declare class DebugConfigTracker implements ConfigTracker, migrator.PresignedMigrationTracker {

@@ -42,3 +42,3 @@ private readonly tracker;

digest: string;
chainId: bigint;
chainId: ethers.BigNumber;
signature: string;

@@ -45,0 +45,0 @@ };

import { commons } from '@0xsequence/core';
import { migrator } from '@0xsequence/migration';
import { ethers } from 'ethers';
import { BigNumber, BigNumberish, ethers } from 'ethers';
import { ConfigTracker, PresignedConfig, PresignedConfigLink } from "../tracker.js";

@@ -16,3 +16,3 @@ export declare function isDedupedTracker(tracker: any): tracker is DedupedTracker;

}): Promise<commons.config.Config | undefined>;
getMigration(address: string, fromImageHash: string, fromVersion: number, chainId: ethers.BigNumberish): Promise<migrator.SignedMigration | undefined>;
getMigration(address: string, fromImageHash: string, fromVersion: number, chainId: BigNumberish): Promise<migrator.SignedMigration | undefined>;
saveMigration(address: string, signed: migrator.SignedMigration, contexts: commons.context.VersionedContext): Promise<void>;

@@ -28,3 +28,3 @@ loadPresignedConfiguration(args: {

digest: string;
chainId: ethers.BigNumberish;
chainId: BigNumberish;
signatures: string[];

@@ -51,7 +51,7 @@ }): Promise<void>;

digest: string;
chainId: bigint;
chainId: BigNumber;
signature: string;
};
}[]>;
updateProvider(provider: ethers.Provider): void;
updateProvider(provider: ethers.providers.Provider): void;
}

@@ -8,7 +8,7 @@

export declare class LocalConfigTracker implements ConfigTracker, migrator.PresignedMigrationTracker {
provider: ethers.Provider;
provider: ethers.providers.Provider;
private store;
useEIP5719: boolean;
private cachedEIP5719;
constructor(provider: ethers.Provider, store?: TrackerStore, useEIP5719?: boolean);
constructor(provider: ethers.providers.Provider, store?: TrackerStore, useEIP5719?: boolean);
private loadTopology;

@@ -58,3 +58,3 @@ private saveTopology;

digest: string;
chainId: bigint;
chainId: ethers.BigNumber;
signature: string;

@@ -65,3 +65,3 @@ };

getMigration(address: string, fromImageHash: string, fromVersion: number, chainId: ethers.BigNumberish): Promise<migrator.SignedMigration | undefined>;
updateProvider(provider: ethers.Provider): void;
updateProvider(provider: ethers.providers.Provider): void;
}
import { ConfigTracker, PresignedConfig, PresignedConfigLink } from "../tracker.js";
import { migrator } from '@0xsequence/migration';
import { BigNumber, BigNumberish } from 'ethers';
import { commons } from '@0xsequence/core';
import { ethers } from 'ethers';
export declare function raceUntil<T>(promises: Promise<T>[], fallback: T, evalRes: (val: T) => boolean): Promise<T>;

@@ -34,3 +34,3 @@ export declare function allSafe<T>(promises: Promise<T>[], fallback: T): Promise<T[]>;

digest: string;
chainId: bigint;
chainId: BigNumber;
signature: string;

@@ -42,3 +42,3 @@ };

digest: string;
chainId: ethers.BigNumberish;
chainId: BigNumberish;
signatures: string[];

@@ -52,4 +52,4 @@ }): Promise<void>;

savePresignedConfiguration(args: PresignedConfig): Promise<void>;
getMigration(address: string, fromImageHash: string, fromVersion: number, chainId: ethers.BigNumberish): Promise<migrator.SignedMigration | undefined>;
getMigration(address: string, fromImageHash: string, fromVersion: number, chainId: BigNumberish): Promise<migrator.SignedMigration | undefined>;
saveMigration(address: string, signed: migrator.SignedMigration, contexts: commons.context.VersionedContext): Promise<void>;
}

@@ -43,3 +43,3 @@ import { commons } from '@0xsequence/core';

digest: string;
chainId: bigint;
chainId: ethers.BigNumber;
signature: string;

@@ -46,0 +46,0 @@ };

{
"name": "@0xsequence/sessions",
"version": "0.0.0-20240812142652",
"version": "0.0.0-20240814043648",
"description": "tools for migrating sequence wallets to new versions",

@@ -12,7 +12,7 @@ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/sessions",

"dependencies": {
"ethers": "^6.13.0",
"ethers": "^5.5.2",
"idb": "^7.1.1",
"@0xsequence/core": "0.0.0-20240812142652",
"@0xsequence/migration": "0.0.0-20240812142652",
"@0xsequence/replacer": "0.0.0-20240812142652"
"@0xsequence/core": "0.0.0-20240814043648",
"@0xsequence/migration": "0.0.0-20240814043648",
"@0xsequence/replacer": "0.0.0-20240814043648"
},

@@ -23,4 +23,4 @@ "devDependencies": {

"nyc": "^15.1.0",
"@0xsequence/signhub": "0.0.0-20240812142652",
"@0xsequence/tests": "0.0.0-20240812142652"
"@0xsequence/signhub": "0.0.0-20240814043648",
"@0xsequence/tests": "0.0.0-20240814043648"
},

@@ -33,5 +33,5 @@ "files": [

"test": "pnpm test:file tests/**/*.spec.ts",
"test:file": "TS_NODE_PROJECT=../../tsconfig.test.json mocha -r ts-node/register --timeout 60000",
"test:file": "TS_NODE_PROJECT=../../tsconfig.test.json mocha -r ts-node/register --timeout 30000",
"test:coverage": "nyc pnpm test"
}
}

@@ -51,3 +51,3 @@ import { commons } from '@0xsequence/core'

digest: string
chainId: bigint
chainId: ethers.BigNumber
signature: string

@@ -54,0 +54,0 @@ }

import { commons, universal } from '@0xsequence/core'
import { migrator } from '@0xsequence/migration'
import { ethers } from 'ethers'
import { ConfigTracker, PresignedConfig, PresignedConfigLink } from '../tracker'
import { ethers } from 'ethers'

@@ -61,3 +61,3 @@ export class CachedTracker implements migrator.PresignedMigrationTracker, ConfigTracker {

if (!acc) return val
if (val.checkpoint > acc.checkpoint) return val
if (val.checkpoint.gt(acc.checkpoint)) return val
return acc

@@ -129,3 +129,3 @@ })?.result ?? []

noCache?: boolean
}): Promise<{ wallet: string; proof: { digest: string; chainId: bigint; signature: string } }[]> {
}): Promise<{ wallet: string; proof: { digest: string; chainId: ethers.BigNumber; signature: string } }[]> {
if (args.noCache) {

@@ -138,3 +138,3 @@ return this.tracker.walletsOfSigner(args)

const results = await Promise.all([this.tracker.walletsOfSigner(args), this.cache.walletsOfSigner(args)])
const wallets = new Map<string, { wallet: string; proof: { digest: string; chainId: bigint; signature: string } }>()
const wallets = new Map<string, { wallet: string; proof: { digest: string; chainId: ethers.BigNumber; signature: string } }>()

@@ -141,0 +141,0 @@ for (const result of results) {

import { commons } from '@0xsequence/core'
import { migrator } from '@0xsequence/migration'
import { ethers } from 'ethers'
import { ConfigTracker, PresignedConfig, PresignedConfigLink } from '../tracker'
import { ethers } from 'ethers'

@@ -59,3 +59,3 @@ export class DebugConfigTracker implements ConfigTracker, migrator.PresignedMigrationTracker {

signer: string
}): Promise<{ wallet: string; proof: { digest: string; chainId: bigint; signature: string } }[]> {
}): Promise<{ wallet: string; proof: { digest: string; chainId: ethers.BigNumber; signature: string } }[]> {
console.debug('? walletsOfSigner')

@@ -62,0 +62,0 @@ debug(args, '? ')

import { commons } from '@0xsequence/core'
import { migrator } from '@0xsequence/migration'
import { ethers } from 'ethers'
import { BigNumber, BigNumberish, ethers } from 'ethers'
import { ConfigTracker, PresignedConfig, PresignedConfigLink } from '../tracker'

@@ -37,3 +36,3 @@ import { PromiseCache } from './promise-cache'

fromVersion: number,
chainId: ethers.BigNumberish
chainId: BigNumberish
): Promise<migrator.SignedMigration | undefined> {

@@ -67,3 +66,3 @@ return this.cache.do(

saveWitnesses(args: { wallet: string; digest: string; chainId: ethers.BigNumberish; signatures: string[] }): Promise<void> {
saveWitnesses(args: { wallet: string; digest: string; chainId: BigNumberish; signatures: string[] }): Promise<void> {
return this.cache.do('saveWitnesses', undefined, args => this.tracker.saveWitnesses(args), args)

@@ -93,7 +92,7 @@ }

signer: string
}): Promise<{ wallet: string; proof: { digest: string; chainId: bigint; signature: string } }[]> {
}): Promise<{ wallet: string; proof: { digest: string; chainId: BigNumber; signature: string } }[]> {
return this.cache.do('walletsOfSigner', this.window, args => this.tracker.walletsOfSigner(args), args)
}
updateProvider(provider: ethers.Provider) {
updateProvider(provider: ethers.providers.Provider) {
if (this.tracker instanceof LocalConfigTracker) {

@@ -100,0 +99,0 @@ this.tracker.updateProvider(provider)

@@ -15,3 +15,3 @@ import { commons, universal, v1, v2 } from '@0xsequence/core'

// For now, it's recommended to use Mainnet as the provider.
public provider: ethers.Provider,
public provider: ethers.providers.Provider,
private store: TrackerStore = new MemoryTrackerStore(),

@@ -34,4 +34,4 @@ public useEIP5719: boolean = false

return {
weight: BigInt(node.weight),
threshold: BigInt(node.threshold),
weight: ethers.BigNumber.from(node.weight),
threshold: ethers.BigNumber.from(node.threshold),
tree: await this.loadTopology(node.tree)

@@ -67,4 +67,4 @@ }

const saveThis = this.store.saveV2Node(hash, {
weight: BigInt(node.weight).toString(),
threshold: BigInt(node.threshold).toString(),
weight: ethers.BigNumber.from(node.weight).toString(),
threshold: ethers.BigNumber.from(node.threshold).toString(),
tree: v2.config.hashNode(node.tree)

@@ -121,4 +121,4 @@ } as PlainNested)

// version: 2,
// threshold: BigInt(config.threshold).toString(),
// checkpoint: BigInt(config.checkpoint).toString(),
// threshold: ethers.BigNumber.from(config.threshold).toString(),
// checkpoint: ethers.BigNumber.from(config.checkpoint).toString(),
// tree: v2.config.hashNode(config.tree)

@@ -155,4 +155,4 @@ // })

version: 2,
threshold: BigInt(config.threshold),
checkpoint: BigInt(config.checkpoint),
threshold: ethers.BigNumber.from(config.threshold),
checkpoint: ethers.BigNumber.from(config.checkpoint),
tree: await this.loadTopology(config.tree)

@@ -232,3 +232,3 @@ } as v2.config.WalletConfig

const message = v2.chained.messageSetImageHash(nextImageHash)
const digest = ethers.keccak256(message)
const digest = ethers.utils.keccak256(message)
const payload = {

@@ -292,3 +292,3 @@ message,

nextImageHash: string
checkpoint: bigint
checkpoint: ethers.BigNumber
signature: string

@@ -302,3 +302,3 @@ }

if (!nextConfig || !v2.config.isWalletConfig(nextConfig)) return undefined
const nextCheckpoint = BigInt(nextConfig.checkpoint)
const nextCheckpoint = ethers.BigNumber.from(nextConfig.checkpoint)
return { nextConfig, nextCheckpoint, nextImageHash, payload }

@@ -310,3 +310,3 @@ })

.filter(c => c !== undefined)
.filter(c => c!.nextCheckpoint > BigInt(fromConfig.checkpoint))
.filter(c => c!.nextCheckpoint.gt(fromConfig.checkpoint))
.sort((a, b) =>

@@ -321,3 +321,3 @@ // If we are looking for the longest path, sort by ascending checkpoint

// But we can try to optimize for the most common case.
a!.nextCheckpoint > b!.nextCheckpoint ? (longestPath ? 1 : -1) : longestPath ? -1 : 1
a!.nextCheckpoint.gt(b!.nextCheckpoint) ? (longestPath ? 1 : -1) : longestPath ? -1 : 1
)

@@ -332,6 +332,6 @@

// Only consider candidates earlier than our current best
if (nextCheckpoint >= bestCheckpoint) continue
if (nextCheckpoint.gte(bestCheckpoint)) continue
} else {
// Only consider candidates later than our current best
if (nextCheckpoint <= bestCheckpoint) continue
if (nextCheckpoint.lte(bestCheckpoint)) continue
}

@@ -350,3 +350,3 @@ }

const replacedSignature = ethers.hexlify(
const replacedSignature = ethers.utils.hexlify(
this.useEIP5719 ? await this.cachedEIP5719.runByEIP5719(signer, payload.subdigest, signature) : signature

@@ -368,3 +368,3 @@ )

const encoded = v2.signature.SignatureCoder.encodeSigners(fromConfig, signatures, [], 0)
if (encoded.weight < BigInt(fromConfig.threshold)) continue
if (encoded.weight.lt(fromConfig.threshold)) continue

@@ -374,3 +374,3 @@ // Save the new best candidate

nextImageHash,
checkpoint: BigInt(nextConfig.checkpoint),
checkpoint: ethers.BigNumber.from(nextConfig.checkpoint),
signature: encoded.encoded

@@ -437,3 +437,3 @@ }

digest: string
chainId: bigint
chainId: ethers.BigNumber
signature: string

@@ -453,3 +453,3 @@ }

digest: string
chainId: bigint
chainId: ethers.BigNumber
signature: string

@@ -471,4 +471,4 @@ }

digest: payload.digest,
chainId: BigInt(payload.chainId),
signature: ethers.hexlify(signature)
chainId: ethers.BigNumber.from(payload.chainId),
signature: ethers.utils.hexlify(signature)
}

@@ -498,3 +498,3 @@ })

const message = commons.transaction.packMetaTransactionsData(signed.tx.nonce, signed.tx.transactions)
const digest = ethers.keccak256(message)
const digest = ethers.utils.keccak256(message)
const payload = { chainId: signed.tx.chainId, message, address, digest }

@@ -553,3 +553,3 @@ const subdigest = commons.signature.subdigestOf(payload)

if (!payload || !payload.message) return undefined
if (BigInt(chainId) !== BigInt(payload.chainId)) return undefined
if (!ethers.BigNumber.from(chainId).eq(payload.chainId)) return undefined

@@ -568,3 +568,3 @@ const signers = coder.config.signersOf(currentConfig as any).map(s => s.address)

const replacedSignature = ethers.hexlify(
const replacedSignature = ethers.utils.hexlify(
this.useEIP5719 ? await this.cachedEIP5719.runByEIP5719(signer, subdigest, signature) : signature

@@ -583,3 +583,3 @@ )

const encoded = coder.signature.encodeSigners(currentConfig as any, signatures, [], chainId)
if (!encoded || encoded.weight < BigInt(currentConfig.threshold)) return undefined
if (!encoded || encoded.weight < currentConfig.threshold) return undefined

@@ -612,5 +612,5 @@ // Unpack payload (it should have transactions)

updateProvider(provider: ethers.Provider) {
updateProvider(provider: ethers.providers.Provider) {
this.provider = provider
}
}
import { ConfigTracker, PresignedConfig, PresignedConfigLink } from '../tracker'
import { migrator } from '@0xsequence/migration'
import { BigNumber, BigNumberish, ethers } from 'ethers'
import { commons, universal } from '@0xsequence/core'
import { LocalConfigTracker } from './local'
import { ethers } from 'ethers'

@@ -117,3 +116,3 @@ export function raceUntil<T>(promises: Promise<T>[], fallback: T, evalRes: (val: T) => boolean): Promise<T> {

signer: string
}): Promise<{ wallet: string; proof: { digest: string; chainId: bigint; signature: string } }[]> {
}): Promise<{ wallet: string; proof: { digest: string; chainId: BigNumber; signature: string } }[]> {
// We can't race here, because there is no "correct" response

@@ -126,3 +125,3 @@ // we just return the union of all results, skipping duplicates

const wallets: { [wallet: string]: { digest: string; chainId: bigint; signature: string } } = {}
const wallets: { [wallet: string]: { digest: string; chainId: BigNumber; signature: string } } = {}
for (const r of results) {

@@ -137,3 +136,3 @@ wallets[r.wallet] = r.proof

const witnesses = new Map<string, { wallet: string; digest: string; chainId: bigint; signatures: string[] }>()
const witnesses = new Map<string, { wallet: string; digest: string; chainId: BigNumber; signatures: string[] }>()
result.forEach(({ wallet, proof: { digest, chainId, signature } }) => {

@@ -153,8 +152,3 @@ const key = `${wallet}-${digest}-${chainId}`

async saveWitnesses(args: {
wallet: string
digest: string
chainId: ethers.BigNumberish
signatures: string[]
}): Promise<void> {
async saveWitnesses(args: { wallet: string; digest: string; chainId: BigNumberish; signatures: string[] }): Promise<void> {
await Promise.all(this.trackers.map(t => t.saveWitnesses(args)))

@@ -191,3 +185,3 @@ }

if (!acc) return val
if (val.checkpoint > acc.checkpoint) return val
if (val.checkpoint.gt(acc.checkpoint)) return val
return acc

@@ -227,3 +221,3 @@ })

fromVersion: number,
chainId: ethers.BigNumberish
chainId: BigNumberish
): Promise<migrator.SignedMigration | undefined> {

@@ -230,0 +224,0 @@ // TODO: Backfeed migration results to other trackers

@@ -16,3 +16,3 @@ import { ethers } from 'ethers'

): Promise<T> {
key = `${key}:${ethers.id(JSON.stringify(args, deterministically))}`
key = `${key}:${ethers.utils.keccak256(ethers.utils.toUtf8Bytes(JSON.stringify(args, deterministically)))}`

@@ -56,4 +56,2 @@ let entry = this.cache.get(key)

return Object.fromEntries(Object.entries(value).sort())
} else if (typeof value === 'bigint') {
return value.toString()
}

@@ -60,0 +58,0 @@

@@ -43,3 +43,3 @@ import { commons, universal, v1, v2 } from '@0xsequence/core'

const message = v2.signature.setImageHashStruct(imageHash)
const digest = ethers.keccak256(message)
const digest = ethers.utils.keccak256(message)

@@ -119,3 +119,3 @@ await this.sessions.saveSignature({

signer: string
}): Promise<{ wallet: string; proof: { digest: string; chainId: bigint; signature: string } }[]> {
}): Promise<{ wallet: string; proof: { digest: string; chainId: ethers.BigNumber; signature: string } }[]> {
const { wallets } = await this.sessions.wallets(args)

@@ -125,9 +125,9 @@ return Object.entries(wallets).map(([wallet, { digest, chainID, type, signature }]) => {

case SignatureType.EIP712:
signature += ethers.toBeHex(commons.signer.SigType.EIP712).slice(2)
signature += ethers.utils.hexlify(commons.signer.SigType.EIP712).slice(2)
break
case SignatureType.EthSign:
signature += ethers.toBeHex(commons.signer.SigType.ETH_SIGN).slice(2)
signature += ethers.utils.hexlify(commons.signer.SigType.ETH_SIGN).slice(2)
break
case SignatureType.EIP1271:
signature += ethers.toBeHex(commons.signer.SigType.WALLET_BYTES32).slice(2)
signature += ethers.utils.hexlify(commons.signer.SigType.WALLET_BYTES32).slice(2)
break

@@ -141,3 +141,3 @@ }

signature,
chainId: BigInt(chainID)
chainId: ethers.BigNumber.from(chainID)
}

@@ -346,3 +346,3 @@ }

value: transaction.value !== undefined ? numberString(transaction.value) : undefined,
data: transaction.data !== undefined ? ethers.hexlify(transaction.data) : undefined,
data: transaction.data !== undefined ? ethers.utils.hexlify(transaction.data) : undefined,
gasLimit: transaction.gasLimit !== undefined ? numberString(transaction.gasLimit) : undefined,

@@ -355,7 +355,7 @@ delegateCall: transaction.delegateCall,

function numberNumber(n: ethers.BigNumberish): number {
return Number(n)
return ethers.BigNumber.from(n).toNumber()
}
function numberString(n: ethers.BigNumberish): string {
return BigInt(n).toString()
return ethers.BigNumber.from(n).toString()
}

@@ -362,0 +362,0 @@

@@ -62,3 +62,3 @@ import { commons, v1, v2 } from '@0xsequence/core'

// Entry is a big number
result[key] = BigInt(val)
result[key] = ethers.BigNumber.from(val)
} else if (Array.isArray(val)) {

@@ -65,0 +65,0 @@ // Entry is an array, recurse

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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