New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@0xsequence/wallet

Package Overview
Dependencies
Maintainers
7
Versions
527
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@0xsequence/wallet - npm Package Compare versions

Comparing version 0.0.0-20240408185635 to 0.0.0-20240427232558

62

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

@@ -12,3 +12,3 @@ 'use strict';

// TODO: Move to account ?
class Signer extends ethers.ethers.AbstractSigner {
class Signer extends ethers.Signer {
static isSequenceSigner(cand) {

@@ -76,5 +76,5 @@ return isSequenceSigner(cand);

// T must include array type
return Promise.all(object.map(o => ethers.ethers.resolveProperties(o)));
return Promise.all(object.map(o => ethers.utils.resolveProperties(o)));
}
return ethers.ethers.resolveProperties(object);
return ethers.utils.resolveProperties(object);
}

@@ -109,4 +109,4 @@ async function findLatestLog(provider, filter) {

if (value.state === signhub.SignerState.SIGNED) {
const suffix = ethers.ethers.getBytes(value.suffix);
const suffixed = ethers.ethers.solidityPacked(['bytes', 'bytes'], [value.signature, suffix]);
const suffix = ethers.ethers.utils.arrayify(value.suffix);
const suffixed = ethers.ethers.utils.solidityPack(['bytes', 'bytes'], [value.signature, suffix]);
parts.set(signer, {

@@ -127,9 +127,8 @@ signature: suffixed,

*/
class Wallet extends ethers.ethers.AbstractSigner {
class Wallet extends ethers.ethers.Signer {
constructor(options) {
var _options$provider;
if (BigInt(options.chainId) === 0n && !options.coders.signature.supportsNoChainId) {
if (ethers.ethers.constants.Zero.eq(options.chainId) && !options.coders.signature.supportsNoChainId) {
throw new Error(`Sequence version ${options.config.version} doesn't support chainId 0`);
}
super((_options$provider = options.provider) != null ? _options$provider : null);
super();
this.context = void 0;

@@ -139,2 +138,3 @@ this.config = void 0;

this.chainId = void 0;
this.provider = void 0;
this.relayer = void 0;

@@ -150,2 +150,3 @@ this.coders = void 0;

this.chainId = options.chainId;
this.provider = options.provider;
this.relayer = options.relayer;

@@ -237,3 +238,3 @@ this._reader = options.reader;

intent: {
id: ethers.ethers.hexlify(ethers.ethers.randomBytes(32)),
id: ethers.ethers.utils.hexlify(ethers.ethers.utils.randomBytes(32)),
wallet: this.address

@@ -244,3 +245,3 @@ }

static buildDeployTransaction(context, imageHash) {
const factoryInterface = new ethers.ethers.Interface(abi.walletContracts.factory.abi);
const factoryInterface = new ethers.ethers.utils.Interface(abi.walletContracts.factory.abi);
return {

@@ -269,3 +270,3 @@ entrypoint: context.guestModule,

if (nonce === undefined) throw new Error('Unable to determine nonce');
return Number(nonce);
return nonce;
}

@@ -293,3 +294,3 @@ async signDigest(digest, metadata) {

// and we can encode the final signature
const subdigestBytes = ethers.ethers.getBytes(subdigest);
const subdigestBytes = ethers.ethers.utils.arrayify(subdigest);
const signature = await this.orchestrator.signMessage({

@@ -312,16 +313,6 @@ candidates: this.coders.config.signersOf(this.config).map(s => s.address),

signMessage(message) {
return this.signDigest(ethers.ethers.keccak256(message), {
return this.signDigest(ethers.ethers.utils.keccak256(message), {
message
});
}
// XXX This method is not implemented in the original code but required by the AbstractSigner interface
signTypedData(domain, types, value) {
const digest = utils.encodeTypedDataDigest({
domain,
types,
message: value
});
return this.signDigest(digest);
}
signTransactionBundle(bundle) {

@@ -337,3 +328,3 @@ if (bundle.entrypoint !== this.address) {

// specified nonce "space"
spaceValue = BigInt(nonce.space);
spaceValue = ethers.ethers.BigNumber.from(nonce.space);
} else if (nonce === undefined) {

@@ -356,3 +347,3 @@ // default is random, aka parallel

randomNonce() {
const randomNonceSpace = BigInt(ethers.ethers.hexlify(ethers.ethers.randomBytes(12)));
const randomNonceSpace = ethers.ethers.BigNumber.from(ethers.ethers.utils.hexlify(ethers.ethers.utils.randomBytes(12)));
const randomNonce = core.commons.transaction.encodeNonce(randomNonceSpace, 0);

@@ -434,3 +425,3 @@ return randomNonce;

return transactions.map((tx, i) => {
const gasLimit = tx.gasLimit ? Number(BigInt(tx.gasLimit)) : simulations[i].gasLimit;
const gasLimit = tx.gasLimit ? ethers.ethers.BigNumber.from(tx.gasLimit).toNumber() : simulations[i].gasLimit;
return _extends({}, tx, simulations[i], {

@@ -442,14 +433,5 @@ gasLimit

connect(provider, relayer) {
return new Wallet({
// Sequence version configurator
coders: this.coders,
context: this.context,
config: this.config,
chainId: this.chainId,
address: this.address,
orchestrator: this.orchestrator,
reader: this._reader,
provider,
relayer: relayer != null ? relayer : this.relayer
});
this.provider = provider;
this.relayer = relayer;
return this;
}

@@ -493,3 +475,3 @@ signTransaction(transaction) {

suffix() {
return new Uint8Array([3]);
return [3];
}

@@ -496,0 +478,0 @@ }

@@ -12,3 +12,3 @@ 'use strict';

// TODO: Move to account ?
class Signer extends ethers.ethers.AbstractSigner {
class Signer extends ethers.Signer {
static isSequenceSigner(cand) {

@@ -76,5 +76,5 @@ return isSequenceSigner(cand);

// T must include array type
return Promise.all(object.map(o => ethers.ethers.resolveProperties(o)));
return Promise.all(object.map(o => ethers.utils.resolveProperties(o)));
}
return ethers.ethers.resolveProperties(object);
return ethers.utils.resolveProperties(object);
}

@@ -109,4 +109,4 @@ async function findLatestLog(provider, filter) {

if (value.state === signhub.SignerState.SIGNED) {
const suffix = ethers.ethers.getBytes(value.suffix);
const suffixed = ethers.ethers.solidityPacked(['bytes', 'bytes'], [value.signature, suffix]);
const suffix = ethers.ethers.utils.arrayify(value.suffix);
const suffixed = ethers.ethers.utils.solidityPack(['bytes', 'bytes'], [value.signature, suffix]);
parts.set(signer, {

@@ -127,9 +127,8 @@ signature: suffixed,

*/
class Wallet extends ethers.ethers.AbstractSigner {
class Wallet extends ethers.ethers.Signer {
constructor(options) {
var _options$provider;
if (BigInt(options.chainId) === 0n && !options.coders.signature.supportsNoChainId) {
if (ethers.ethers.constants.Zero.eq(options.chainId) && !options.coders.signature.supportsNoChainId) {
throw new Error(`Sequence version ${options.config.version} doesn't support chainId 0`);
}
super((_options$provider = options.provider) != null ? _options$provider : null);
super();
this.context = void 0;

@@ -139,2 +138,3 @@ this.config = void 0;

this.chainId = void 0;
this.provider = void 0;
this.relayer = void 0;

@@ -150,2 +150,3 @@ this.coders = void 0;

this.chainId = options.chainId;
this.provider = options.provider;
this.relayer = options.relayer;

@@ -237,3 +238,3 @@ this._reader = options.reader;

intent: {
id: ethers.ethers.hexlify(ethers.ethers.randomBytes(32)),
id: ethers.ethers.utils.hexlify(ethers.ethers.utils.randomBytes(32)),
wallet: this.address

@@ -244,3 +245,3 @@ }

static buildDeployTransaction(context, imageHash) {
const factoryInterface = new ethers.ethers.Interface(abi.walletContracts.factory.abi);
const factoryInterface = new ethers.ethers.utils.Interface(abi.walletContracts.factory.abi);
return {

@@ -269,3 +270,3 @@ entrypoint: context.guestModule,

if (nonce === undefined) throw new Error('Unable to determine nonce');
return Number(nonce);
return nonce;
}

@@ -293,3 +294,3 @@ async signDigest(digest, metadata) {

// and we can encode the final signature
const subdigestBytes = ethers.ethers.getBytes(subdigest);
const subdigestBytes = ethers.ethers.utils.arrayify(subdigest);
const signature = await this.orchestrator.signMessage({

@@ -312,16 +313,6 @@ candidates: this.coders.config.signersOf(this.config).map(s => s.address),

signMessage(message) {
return this.signDigest(ethers.ethers.keccak256(message), {
return this.signDigest(ethers.ethers.utils.keccak256(message), {
message
});
}
// XXX This method is not implemented in the original code but required by the AbstractSigner interface
signTypedData(domain, types, value) {
const digest = utils.encodeTypedDataDigest({
domain,
types,
message: value
});
return this.signDigest(digest);
}
signTransactionBundle(bundle) {

@@ -337,3 +328,3 @@ if (bundle.entrypoint !== this.address) {

// specified nonce "space"
spaceValue = BigInt(nonce.space);
spaceValue = ethers.ethers.BigNumber.from(nonce.space);
} else if (nonce === undefined) {

@@ -356,3 +347,3 @@ // default is random, aka parallel

randomNonce() {
const randomNonceSpace = BigInt(ethers.ethers.hexlify(ethers.ethers.randomBytes(12)));
const randomNonceSpace = ethers.ethers.BigNumber.from(ethers.ethers.utils.hexlify(ethers.ethers.utils.randomBytes(12)));
const randomNonce = core.commons.transaction.encodeNonce(randomNonceSpace, 0);

@@ -434,3 +425,3 @@ return randomNonce;

return transactions.map((tx, i) => {
const gasLimit = tx.gasLimit ? Number(BigInt(tx.gasLimit)) : simulations[i].gasLimit;
const gasLimit = tx.gasLimit ? ethers.ethers.BigNumber.from(tx.gasLimit).toNumber() : simulations[i].gasLimit;
return _extends({}, tx, simulations[i], {

@@ -442,14 +433,5 @@ gasLimit

connect(provider, relayer) {
return new Wallet({
// Sequence version configurator
coders: this.coders,
context: this.context,
config: this.config,
chainId: this.chainId,
address: this.address,
orchestrator: this.orchestrator,
reader: this._reader,
provider,
relayer: relayer != null ? relayer : this.relayer
});
this.provider = provider;
this.relayer = relayer;
return this;
}

@@ -493,3 +475,3 @@ signTransaction(transaction) {

suffix() {
return new Uint8Array([3]);
return [3];
}

@@ -496,0 +478,0 @@ }

@@ -1,9 +0,9 @@

import { ethers } from 'ethers';
import { Signer as Signer$1, utils, ethers } from 'ethers';
import { commons } from '@0xsequence/core';
import { SignerState } from '@0xsequence/signhub';
import { subDigestOf, encodeTypedDataDigest } from '@0xsequence/utils';
import { subDigestOf } from '@0xsequence/utils';
import { walletContracts } from '@0xsequence/abi';
// TODO: Move to account ?
class Signer extends ethers.AbstractSigner {
class Signer extends Signer$1 {
static isSequenceSigner(cand) {

@@ -71,5 +71,5 @@ return isSequenceSigner(cand);

// T must include array type
return Promise.all(object.map(o => ethers.resolveProperties(o)));
return Promise.all(object.map(o => utils.resolveProperties(o)));
}
return ethers.resolveProperties(object);
return utils.resolveProperties(object);
}

@@ -104,4 +104,4 @@ async function findLatestLog(provider, filter) {

if (value.state === SignerState.SIGNED) {
const suffix = ethers.getBytes(value.suffix);
const suffixed = ethers.solidityPacked(['bytes', 'bytes'], [value.signature, suffix]);
const suffix = ethers.utils.arrayify(value.suffix);
const suffixed = ethers.utils.solidityPack(['bytes', 'bytes'], [value.signature, suffix]);
parts.set(signer, {

@@ -122,9 +122,8 @@ signature: suffixed,

*/
class Wallet extends ethers.AbstractSigner {
class Wallet extends ethers.Signer {
constructor(options) {
var _options$provider;
if (BigInt(options.chainId) === 0n && !options.coders.signature.supportsNoChainId) {
if (ethers.constants.Zero.eq(options.chainId) && !options.coders.signature.supportsNoChainId) {
throw new Error(`Sequence version ${options.config.version} doesn't support chainId 0`);
}
super((_options$provider = options.provider) != null ? _options$provider : null);
super();
this.context = void 0;

@@ -134,2 +133,3 @@ this.config = void 0;

this.chainId = void 0;
this.provider = void 0;
this.relayer = void 0;

@@ -145,2 +145,3 @@ this.coders = void 0;

this.chainId = options.chainId;
this.provider = options.provider;
this.relayer = options.relayer;

@@ -232,3 +233,3 @@ this._reader = options.reader;

intent: {
id: ethers.hexlify(ethers.randomBytes(32)),
id: ethers.utils.hexlify(ethers.utils.randomBytes(32)),
wallet: this.address

@@ -239,3 +240,3 @@ }

static buildDeployTransaction(context, imageHash) {
const factoryInterface = new ethers.Interface(walletContracts.factory.abi);
const factoryInterface = new ethers.utils.Interface(walletContracts.factory.abi);
return {

@@ -264,3 +265,3 @@ entrypoint: context.guestModule,

if (nonce === undefined) throw new Error('Unable to determine nonce');
return Number(nonce);
return nonce;
}

@@ -288,3 +289,3 @@ async signDigest(digest, metadata) {

// and we can encode the final signature
const subdigestBytes = ethers.getBytes(subdigest);
const subdigestBytes = ethers.utils.arrayify(subdigest);
const signature = await this.orchestrator.signMessage({

@@ -307,16 +308,6 @@ candidates: this.coders.config.signersOf(this.config).map(s => s.address),

signMessage(message) {
return this.signDigest(ethers.keccak256(message), {
return this.signDigest(ethers.utils.keccak256(message), {
message
});
}
// XXX This method is not implemented in the original code but required by the AbstractSigner interface
signTypedData(domain, types, value) {
const digest = encodeTypedDataDigest({
domain,
types,
message: value
});
return this.signDigest(digest);
}
signTransactionBundle(bundle) {

@@ -332,3 +323,3 @@ if (bundle.entrypoint !== this.address) {

// specified nonce "space"
spaceValue = BigInt(nonce.space);
spaceValue = ethers.BigNumber.from(nonce.space);
} else if (nonce === undefined) {

@@ -351,3 +342,3 @@ // default is random, aka parallel

randomNonce() {
const randomNonceSpace = BigInt(ethers.hexlify(ethers.randomBytes(12)));
const randomNonceSpace = ethers.BigNumber.from(ethers.utils.hexlify(ethers.utils.randomBytes(12)));
const randomNonce = commons.transaction.encodeNonce(randomNonceSpace, 0);

@@ -429,3 +420,3 @@ return randomNonce;

return transactions.map((tx, i) => {
const gasLimit = tx.gasLimit ? Number(BigInt(tx.gasLimit)) : simulations[i].gasLimit;
const gasLimit = tx.gasLimit ? ethers.BigNumber.from(tx.gasLimit).toNumber() : simulations[i].gasLimit;
return _extends({}, tx, simulations[i], {

@@ -437,14 +428,5 @@ gasLimit

connect(provider, relayer) {
return new Wallet({
// Sequence version configurator
coders: this.coders,
context: this.context,
config: this.config,
chainId: this.chainId,
address: this.address,
orchestrator: this.orchestrator,
reader: this._reader,
provider,
relayer: relayer != null ? relayer : this.relayer
});
this.provider = provider;
this.relayer = relayer;
return this;
}

@@ -488,3 +470,3 @@ signTransaction(transaction) {

suffix() {
return new Uint8Array([3]);
return [3];
}

@@ -491,0 +473,0 @@ }

@@ -12,5 +12,5 @@ import { commons } from '@0xsequence/core';

decorateTransactions(bundle: commons.transaction.IntendedTransactionBundle, _metadata: object): Promise<commons.transaction.IntendedTransactionBundle>;
sign(message: ethers.BytesLike, metadata: object): Promise<ethers.BytesLike>;
sign(message: ethers.utils.BytesLike, metadata: object): Promise<ethers.utils.BytesLike>;
notifyStatusChange(_i: string, _s: Status, _m: object): void;
suffix(): ethers.BytesLike;
suffix(): ethers.utils.BytesLike;
}

@@ -1,8 +0,9 @@

import { ethers } from 'ethers';
import { BytesLike, Signer as AbstractSigner, providers, TypedDataDomain, TypedDataField, ethers } from 'ethers';
import { NetworkConfig, ChainIdLike } from '@0xsequence/network';
import { FeeQuote, Relayer } from '@0xsequence/relayer';
import { Deferrable } from '@0xsequence/utils';
import { commons } from '@0xsequence/core';
export declare abstract class Signer extends ethers.AbstractSigner {
export declare abstract class Signer extends AbstractSigner {
static isSequenceSigner(cand: any): cand is Signer;
abstract getProvider(chainId?: number): Promise<ethers.JsonRpcProvider | undefined>;
abstract getProvider(chainId?: number): Promise<providers.JsonRpcProvider | undefined>;
abstract getRelayer(chainId?: number): Promise<Relayer | undefined>;

@@ -12,7 +13,7 @@ abstract getWalletConfig(chainId?: ChainIdLike): Promise<commons.config.Config>;

abstract getSigners(): Promise<string[]>;
abstract signMessage(message: ethers.BytesLike, chainId?: ChainIdLike, allSigners?: boolean, isDigest?: boolean): Promise<string>;
abstract signTypedData(domain: ethers.TypedDataDomain, types: Record<string, Array<ethers.TypedDataField>>, message: Record<string, any>, chainId?: ChainIdLike, allSigners?: boolean): Promise<string>;
abstract sendTransaction(transaction: commons.transaction.Transactionish, chainId?: ChainIdLike, allSigners?: boolean, quote?: FeeQuote): Promise<commons.transaction.TransactionResponse>;
abstract sendTransactionBatch(transactions: ethers.TransactionRequest[] | commons.transaction.Transaction[], chainId?: ChainIdLike, allSigners?: boolean, quote?: FeeQuote): Promise<commons.transaction.TransactionResponse>;
abstract signTransactions(txs: commons.transaction.Transactionish, chainId?: ChainIdLike, allSigners?: boolean): Promise<commons.transaction.SignedTransactionBundle>;
abstract signMessage(message: BytesLike, chainId?: ChainIdLike, allSigners?: boolean, isDigest?: boolean): Promise<string>;
abstract signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, message: Record<string, any>, chainId: ChainIdLike, allSigners?: boolean): Promise<string>;
abstract sendTransaction(transaction: Deferrable<commons.transaction.Transactionish>, chainId?: ChainIdLike, allSigners?: boolean, quote?: FeeQuote): Promise<commons.transaction.TransactionResponse>;
abstract sendTransactionBatch(transactions: Deferrable<ethers.providers.TransactionRequest[] | commons.transaction.Transaction[]>, chainId?: ChainIdLike, allSigners?: boolean, quote?: FeeQuote): Promise<commons.transaction.TransactionResponse>;
abstract signTransactions(txs: Deferrable<commons.transaction.Transactionish>, chainId?: ChainIdLike, allSigners?: boolean): Promise<commons.transaction.SignedTransactionBundle>;
abstract sendSignedTransactions(signedTxs: commons.transaction.SignedTransactionBundle, chainId?: ChainIdLike, quote?: FeeQuote): Promise<commons.transaction.TransactionResponse>;

@@ -24,3 +25,3 @@ abstract updateConfig(newConfig?: commons.config.Config): Promise<[commons.config.Config, commons.transaction.TransactionResponse | undefined]>;

export type SignedTransactionsCallback = (signedTxs: commons.transaction.SignedTransactionBundle, metaTxnHash: string) => void;
export declare function isSequenceSigner(signer: any): signer is Signer;
export declare function isSequenceSigner(signer: AbstractSigner): signer is Signer;
export declare class InvalidSigner extends Error {

@@ -27,0 +28,0 @@ }

@@ -1,3 +0,3 @@

import { ethers } from 'ethers';
export declare function resolveArrayProperties<T>(object: Readonly<T> | Readonly<T>[]): Promise<T>;
export declare function findLatestLog(provider: ethers.Provider, filter: ethers.Filter): Promise<ethers.Log | undefined>;
import { ethers, utils } from 'ethers';
export declare function resolveArrayProperties<T>(object: Readonly<utils.Deferrable<T>> | Readonly<utils.Deferrable<T>>[]): Promise<T>;
export declare function findLatestLog(provider: ethers.providers.Provider, filter: ethers.providers.Filter): Promise<ethers.providers.Log | undefined>;
import { ethers } from 'ethers';
import { commons, v1, v2 } from '@0xsequence/core';
import { SignatureOrchestrator } from '@0xsequence/signhub';
import { Deferrable } from '@0xsequence/utils';
import { FeeQuote, Relayer } from '@0xsequence/relayer';

@@ -16,3 +17,3 @@ export type WalletOptions<T extends commons.signature.Signature<Y>, Y extends commons.config.Config, Z extends commons.signature.UnrecoveredSignature> = {

reader?: commons.reader.Reader;
provider?: ethers.Provider;
provider?: ethers.providers.Provider;
relayer?: Relayer;

@@ -29,3 +30,3 @@ };

*/
export declare class Wallet<Y extends commons.config.Config = commons.config.Config, T extends commons.signature.Signature<Y> = commons.signature.Signature<Y>, Z extends commons.signature.UnrecoveredSignature = commons.signature.UnrecoveredSignature> extends ethers.AbstractSigner {
export declare class Wallet<Y extends commons.config.Config = commons.config.Config, T extends commons.signature.Signature<Y> = commons.signature.Signature<Y>, Z extends commons.signature.UnrecoveredSignature = commons.signature.UnrecoveredSignature> extends ethers.Signer {
context: commons.context.WalletContext;

@@ -35,2 +36,3 @@ config: Y;

chainId: ethers.BigNumberish;
provider?: ethers.providers.Provider;
relayer?: Relayer;

@@ -53,9 +55,8 @@ coders: {

buildDeployTransaction(metadata?: commons.WalletDeployMetadata): Promise<commons.transaction.TransactionBundle | undefined>;
deploy(metadata?: commons.WalletDeployMetadata): Promise<ethers.TransactionResponse | undefined>;
deploy(metadata?: commons.WalletDeployMetadata): Promise<ethers.providers.TransactionResponse | undefined>;
static buildDeployTransaction(context: commons.context.WalletContext, imageHash: string): commons.transaction.TransactionBundle;
buildUpdateConfigurationTransaction(config: Y): Promise<commons.transaction.TransactionBundle>;
getNonce(space?: ethers.BigNumberish): Promise<number>;
signDigest(digest: ethers.BytesLike, metadata?: object): Promise<string>;
getNonce(space?: ethers.BigNumberish): Promise<ethers.BigNumberish>;
signDigest(digest: ethers.utils.BytesLike, metadata?: object): Promise<string>;
signMessage(message: ethers.BytesLike): Promise<string>;
signTypedData(domain: ethers.TypedDataDomain, types: Record<string, ethers.TypedDataField[]>, value: Record<string, any>): Promise<string>;
signTransactionBundle(bundle: commons.transaction.TransactionBundle): Promise<commons.transaction.SignedTransactionBundle>;

@@ -68,3 +69,3 @@ fetchNonceOrSpace(nonce?: ethers.BigNumberish | {

randomNonce(): ethers.BigNumberish;
signTransactions(txs: commons.transaction.Transactionish, nonce?: ethers.BigNumberish | {
signTransactions(txs: Deferrable<commons.transaction.Transactionish>, nonce?: ethers.BigNumberish | {
space: ethers.BigNumberish;

@@ -74,11 +75,11 @@ } | {

}, metadata?: object): Promise<commons.transaction.SignedTransactionBundle>;
sendSignedTransaction(signedBundle: commons.transaction.IntendedTransactionBundle, quote?: FeeQuote): Promise<ethers.TransactionResponse>;
sendTransaction(txs: commons.transaction.Transactionish, options?: {
sendSignedTransaction(signedBundle: commons.transaction.IntendedTransactionBundle, quote?: FeeQuote): Promise<ethers.providers.TransactionResponse>;
sendTransaction(txs: Deferrable<commons.transaction.Transactionish>, options?: {
quote?: FeeQuote;
nonce?: ethers.BigNumberish;
serial?: boolean;
}): Promise<ethers.TransactionResponse>;
fillGasLimits(txs: commons.transaction.Transactionish): Promise<commons.transaction.SimulatedTransaction[]>;
connect(provider: ethers.Provider, relayer?: Relayer): Wallet<Y, T, Z>;
signTransaction(transaction: ethers.TransactionRequest): Promise<string>;
}): Promise<ethers.providers.TransactionResponse>;
fillGasLimits(txs: Deferrable<commons.transaction.Transactionish>): Promise<commons.transaction.SimulatedTransaction[]>;
connect(provider: ethers.providers.Provider, relayer?: Relayer): Wallet<Y, T, Z>;
signTransaction(transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>): Promise<string>;
}
{
"name": "@0xsequence/wallet",
"version": "0.0.0-20240408185635",
"version": "0.0.0-20240427232558",
"description": "wallet sub-package for Sequence",

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

"dependencies": {
"@0xsequence/abi": "0.0.0-20240408185635",
"@0xsequence/core": "0.0.0-20240408185635",
"@0xsequence/network": "0.0.0-20240408185635",
"@0xsequence/signhub": "0.0.0-20240408185635",
"@0xsequence/utils": "0.0.0-20240408185635",
"@0xsequence/relayer": "0.0.0-20240408185635"
"@0xsequence/abi": "0.0.0-20240427232558",
"@0xsequence/core": "0.0.0-20240427232558",
"@0xsequence/signhub": "0.0.0-20240427232558",
"@0xsequence/network": "0.0.0-20240427232558",
"@0xsequence/relayer": "0.0.0-20240427232558",
"@0xsequence/utils": "0.0.0-20240427232558"
},
"peerDependencies": {
"ethers": "corbanbrook/ethers.js"
"ethers": ">=5.5 < 6"
},
"devDependencies": {
"@0xsequence/ethauth": "0xsequence/ethauth.js#ethers-v6",
"@0xsequence/ethauth": "^0.8.1",
"@0xsequence/wallet-contracts": "^2.0.0",
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"ethers": "corbanbrook/ethers.js",
"ethers": "^5.7.2",
"web3": "^1.8.1",
"@0xsequence/tests": "0.0.0-20240408185635"
"@0xsequence/tests": "0.0.0-20240427232558"
},

@@ -31,0 +31,0 @@ "files": [

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

sign(message: ethers.BytesLike, metadata: object): Promise<ethers.BytesLike> {
sign(message: ethers.utils.BytesLike, metadata: object): Promise<ethers.utils.BytesLike> {
if (!commons.isWalletSignRequestMetadata(metadata)) {

@@ -44,5 +44,5 @@ throw new Error('SequenceOrchestratorWrapper only supports nested Sequence signatures')

suffix(): ethers.BytesLike {
return new Uint8Array([3])
suffix(): ethers.utils.BytesLike {
return [3]
}
}

@@ -1,8 +0,9 @@

import { ethers } from 'ethers'
import { BytesLike, Signer as AbstractSigner, providers, TypedDataDomain, TypedDataField, ethers } from 'ethers'
import { NetworkConfig, ChainIdLike } from '@0xsequence/network'
import { FeeQuote, Relayer } from '@0xsequence/relayer'
import { Deferrable } from '@0xsequence/utils'
import { commons } from '@0xsequence/core'
// TODO: Move to account ?
export abstract class Signer extends ethers.AbstractSigner {
export abstract class Signer extends AbstractSigner {
static isSequenceSigner(cand: any): cand is Signer {

@@ -12,3 +13,3 @@ return isSequenceSigner(cand)

abstract getProvider(chainId?: number): Promise<ethers.JsonRpcProvider | undefined>
abstract getProvider(chainId?: number): Promise<providers.JsonRpcProvider | undefined>
abstract getRelayer(chainId?: number): Promise<Relayer | undefined>

@@ -27,15 +28,10 @@

// signMessage .....
abstract signMessage(
message: ethers.BytesLike,
chainId?: ChainIdLike,
allSigners?: boolean,
isDigest?: boolean
): Promise<string>
abstract signMessage(message: BytesLike, chainId?: ChainIdLike, allSigners?: boolean, isDigest?: boolean): Promise<string>
// signTypedData ..
abstract signTypedData(
domain: ethers.TypedDataDomain,
types: Record<string, Array<ethers.TypedDataField>>,
domain: TypedDataDomain,
types: Record<string, Array<TypedDataField>>,
message: Record<string, any>,
chainId?: ChainIdLike,
chainId: ChainIdLike,
allSigners?: boolean

@@ -47,3 +43,3 @@ ): Promise<string>

abstract sendTransaction(
transaction: commons.transaction.Transactionish,
transaction: Deferrable<commons.transaction.Transactionish>,
chainId?: ChainIdLike,

@@ -57,3 +53,3 @@ allSigners?: boolean,

abstract sendTransactionBatch(
transactions: ethers.TransactionRequest[] | commons.transaction.Transaction[],
transactions: Deferrable<ethers.providers.TransactionRequest[] | commons.transaction.Transaction[]>,
chainId?: ChainIdLike,

@@ -68,3 +64,3 @@ allSigners?: boolean,

abstract signTransactions(
txs: commons.transaction.Transactionish,
txs: Deferrable<commons.transaction.Transactionish>,
chainId?: ChainIdLike,

@@ -97,3 +93,3 @@ allSigners?: boolean

export function isSequenceSigner(signer: any): signer is Signer {
export function isSequenceSigner(signer: AbstractSigner): signer is Signer {
const cand = signer as Signer

@@ -100,0 +96,0 @@ return cand && cand.updateConfig !== undefined && cand.publishConfig !== undefined && cand.getWalletConfig !== undefined

@@ -1,13 +0,18 @@

import { ethers } from 'ethers'
import { ethers, utils } from 'ethers'
export async function resolveArrayProperties<T>(object: Readonly<T> | Readonly<T>[]): Promise<T> {
export async function resolveArrayProperties<T>(
object: Readonly<utils.Deferrable<T>> | Readonly<utils.Deferrable<T>>[]
): Promise<T> {
if (Array.isArray(object)) {
// T must include array type
return Promise.all(object.map(o => ethers.resolveProperties(o))) as any
return Promise.all(object.map(o => utils.resolveProperties(o))) as any
}
return ethers.resolveProperties(object)
return utils.resolveProperties(object)
}
export async function findLatestLog(provider: ethers.Provider, filter: ethers.Filter): Promise<ethers.Log | undefined> {
export async function findLatestLog(
provider: ethers.providers.Provider,
filter: ethers.providers.Filter
): Promise<ethers.providers.Log | undefined> {
const toBlock = filter.toBlock === 'latest' ? await provider.getBlockNumber() : (filter.toBlock as number)

@@ -14,0 +19,0 @@ const fromBlock = filter.fromBlock as number

import { ethers } from 'ethers'
import { commons, v1, v2 } from '@0xsequence/core'
import { SignatureOrchestrator, SignerState, Status } from '@0xsequence/signhub'
import { encodeTypedDataDigest, subDigestOf } from '@0xsequence/utils'
import { Deferrable, subDigestOf } from '@0xsequence/utils'
import { FeeQuote, Relayer } from '@0xsequence/relayer'

@@ -30,3 +30,3 @@ import { walletContracts } from '@0xsequence/abi'

provider?: ethers.Provider
provider?: ethers.providers.Provider
relayer?: Relayer

@@ -41,4 +41,4 @@ }

if (value.state === SignerState.SIGNED) {
const suffix = ethers.getBytes(value.suffix)
const suffixed = ethers.solidityPacked(['bytes', 'bytes'], [value.signature, suffix])
const suffix = ethers.utils.arrayify(value.suffix)
const suffixed = ethers.utils.solidityPack(['bytes', 'bytes'], [value.signature, suffix])

@@ -66,3 +66,3 @@ parts.set(signer, { signature: suffixed, isDynamic: suffix.length !== 1 || suffix[0] !== 2 })

Z extends commons.signature.UnrecoveredSignature = commons.signature.UnrecoveredSignature
> extends ethers.AbstractSigner {
> extends ethers.Signer {
public context: commons.context.WalletContext

@@ -73,2 +73,3 @@ public config: Y

public provider?: ethers.providers.Provider
public relayer?: Relayer

@@ -85,7 +86,7 @@

constructor(options: WalletOptions<T, Y, Z>) {
if (BigInt(options.chainId) === 0n && !options.coders.signature.supportsNoChainId) {
if (ethers.constants.Zero.eq(options.chainId) && !options.coders.signature.supportsNoChainId) {
throw new Error(`Sequence version ${options.config.version} doesn't support chainId 0`)
}
super(options.provider ?? null)
super()

@@ -98,2 +99,3 @@ this.context = options.context

this.chainId = options.chainId
this.provider = options.provider
this.relayer = options.relayer

@@ -199,3 +201,3 @@

async deploy(metadata?: commons.WalletDeployMetadata): Promise<ethers.TransactionResponse | undefined> {
async deploy(metadata?: commons.WalletDeployMetadata): Promise<ethers.providers.TransactionResponse | undefined> {
const deployTx = await this.buildDeployTransaction(metadata)

@@ -211,3 +213,3 @@ if (deployTx === undefined) {

intent: {
id: ethers.hexlify(ethers.randomBytes(32)),
id: ethers.utils.hexlify(ethers.utils.randomBytes(32)),
wallet: this.address

@@ -222,3 +224,3 @@ }

): commons.transaction.TransactionBundle {
const factoryInterface = new ethers.Interface(walletContracts.factory.abi)
const factoryInterface = new ethers.utils.Interface(walletContracts.factory.abi)

@@ -230,3 +232,3 @@ return {

to: context.factory,
data: factoryInterface.encodeFunctionData(factoryInterface.getFunction('deploy')!, [context.mainModule, imageHash]),
data: factoryInterface.encodeFunctionData(factoryInterface.getFunction('deploy'), [context.mainModule, imageHash]),
gasLimit: 100000,

@@ -251,9 +253,9 @@ delegateCall: false,

async getNonce(space: ethers.BigNumberish = 0): Promise<number> {
async getNonce(space: ethers.BigNumberish = 0): Promise<ethers.BigNumberish> {
const nonce = await this.reader().nonce(this.address, space)
if (nonce === undefined) throw new Error('Unable to determine nonce')
return Number(nonce)
return nonce
}
async signDigest(digest: ethers.BytesLike, metadata?: object): Promise<string> {
async signDigest(digest: ethers.utils.BytesLike, metadata?: object): Promise<string> {
// The subdigest may be statically defined on the configuration

@@ -279,3 +281,3 @@ // in that case we just encode the proof, no need to sign anything

// and we can encode the final signature
const subdigestBytes = ethers.getBytes(subdigest)
const subdigestBytes = ethers.utils.arrayify(subdigest)
const signature = await this.orchestrator.signMessage({

@@ -300,15 +302,5 @@ candidates: this.coders.config.signersOf(this.config).map(s => s.address),

signMessage(message: ethers.BytesLike): Promise<string> {
return this.signDigest(ethers.keccak256(message), { message })
return this.signDigest(ethers.utils.keccak256(message), { message })
}
// XXX This method is not implemented in the original code but required by the AbstractSigner interface
signTypedData(
domain: ethers.TypedDataDomain,
types: Record<string, ethers.TypedDataField[]>,
value: Record<string, any>
): Promise<string> {
const digest = encodeTypedDataDigest({ domain, types, message: value })
return this.signDigest(digest)
}
signTransactionBundle(bundle: commons.transaction.TransactionBundle): Promise<commons.transaction.SignedTransactionBundle> {

@@ -329,3 +321,3 @@ if (bundle.entrypoint !== this.address) {

// specified nonce "space"
spaceValue = BigInt((nonce as any).space)
spaceValue = ethers.BigNumber.from((nonce as any).space)
} else if (nonce === undefined) {

@@ -349,3 +341,3 @@ // default is random, aka parallel

randomNonce(): ethers.BigNumberish {
const randomNonceSpace = BigInt(ethers.hexlify(ethers.randomBytes(12)))
const randomNonceSpace = ethers.BigNumber.from(ethers.utils.hexlify(ethers.utils.randomBytes(12)))
const randomNonce = commons.transaction.encodeNonce(randomNonceSpace, 0)

@@ -356,3 +348,3 @@ return randomNonce

async signTransactions(
txs: commons.transaction.Transactionish,
txs: Deferrable<commons.transaction.Transactionish>,
nonce?: ethers.BigNumberish | { space: ethers.BigNumberish } | { serial: boolean },

@@ -404,3 +396,3 @@ metadata?: object

quote?: FeeQuote
): Promise<ethers.TransactionResponse> {
): Promise<ethers.providers.TransactionResponse> {
if (!this.relayer) throw new Error('Wallet sendTransaction requires a relayer')

@@ -417,3 +409,3 @@ return this.relayer.relay(signedBundle, quote)

async sendTransaction(
txs: commons.transaction.Transactionish,
txs: Deferrable<commons.transaction.Transactionish>,
options?: {

@@ -424,3 +416,3 @@ quote?: FeeQuote

}
): Promise<ethers.TransactionResponse> {
): Promise<ethers.providers.TransactionResponse> {
let nonce: ethers.BigNumberish | { serial: boolean }

@@ -443,3 +435,3 @@ if (options?.nonce !== undefined) {

async fillGasLimits(txs: commons.transaction.Transactionish): Promise<commons.transaction.SimulatedTransaction[]> {
async fillGasLimits(txs: Deferrable<commons.transaction.Transactionish>): Promise<commons.transaction.SimulatedTransaction[]> {
const transaction = await resolveArrayProperties<commons.transaction.Transactionish>(txs)

@@ -452,3 +444,3 @@ const transactions = commons.transaction.fromTransactionish(this.address, transaction)

return transactions.map((tx, i) => {
const gasLimit = tx.gasLimit ? Number(BigInt(tx.gasLimit)) : simulations[i].gasLimit
const gasLimit = tx.gasLimit ? ethers.BigNumber.from(tx.gasLimit).toNumber() : simulations[i].gasLimit
return { ...tx, ...simulations[i], gasLimit }

@@ -458,24 +450,11 @@ })

connect(provider: ethers.Provider, relayer?: Relayer): Wallet<Y, T, Z> {
return new Wallet({
// Sequence version configurator
coders: this.coders,
context: this.context,
config: this.config,
chainId: this.chainId,
address: this.address,
orchestrator: this.orchestrator,
reader: this._reader,
provider,
relayer: relayer ?? this.relayer
})
connect(provider: ethers.providers.Provider, relayer?: Relayer): Wallet<Y, T, Z> {
this.provider = provider
this.relayer = relayer
return this
}
signTransaction(transaction: ethers.TransactionRequest): Promise<string> {
signTransaction(transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>): Promise<string> {
throw new Error('Method not implemented.')
}
}
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