@0xsequence/wallet
Advanced tools
Comparing version 0.0.0-20240704152116 to 0.0.0-20240709173026
@@ -12,3 +12,3 @@ 'use strict'; | ||
// TODO: Move to account ? | ||
class Signer extends ethers.Signer { | ||
class Signer extends ethers.ethers.AbstractSigner { | ||
static isSequenceSigner(cand) { | ||
@@ -76,5 +76,5 @@ return isSequenceSigner(cand); | ||
// T must include array type | ||
return Promise.all(object.map(o => ethers.utils.resolveProperties(o))); | ||
return Promise.all(object.map(o => ethers.ethers.resolveProperties(o))); | ||
} | ||
return ethers.utils.resolveProperties(object); | ||
return ethers.ethers.resolveProperties(object); | ||
} | ||
@@ -109,4 +109,4 @@ async function findLatestLog(provider, filter) { | ||
if (value.state === signhub.SignerState.SIGNED) { | ||
const suffix = ethers.ethers.utils.arrayify(value.suffix); | ||
const suffixed = ethers.ethers.utils.solidityPack(['bytes', 'bytes'], [value.signature, suffix]); | ||
const suffix = ethers.ethers.getBytes(value.suffix); | ||
const suffixed = ethers.ethers.solidityPacked(['bytes', 'bytes'], [value.signature, suffix]); | ||
parts.set(signer, { | ||
@@ -127,8 +127,9 @@ signature: suffixed, | ||
*/ | ||
class Wallet extends ethers.ethers.Signer { | ||
class Wallet extends ethers.ethers.AbstractSigner { | ||
constructor(options) { | ||
if (ethers.ethers.constants.Zero.eq(options.chainId) && !options.coders.signature.supportsNoChainId) { | ||
var _options$provider; | ||
if (BigInt(options.chainId) === 0n && !options.coders.signature.supportsNoChainId) { | ||
throw new Error(`Sequence version ${options.config.version} doesn't support chainId 0`); | ||
} | ||
super(); | ||
super((_options$provider = options.provider) != null ? _options$provider : null); | ||
this.context = void 0; | ||
@@ -138,3 +139,2 @@ this.config = void 0; | ||
this.chainId = void 0; | ||
this.provider = void 0; | ||
this.relayer = void 0; | ||
@@ -150,3 +150,2 @@ this.coders = void 0; | ||
this.chainId = options.chainId; | ||
this.provider = options.provider; | ||
this.relayer = options.relayer; | ||
@@ -238,3 +237,3 @@ this._reader = options.reader; | ||
intent: { | ||
id: ethers.ethers.utils.hexlify(ethers.ethers.utils.randomBytes(32)), | ||
id: ethers.ethers.hexlify(ethers.ethers.randomBytes(32)), | ||
wallet: this.address | ||
@@ -245,3 +244,3 @@ } | ||
static buildDeployTransaction(context, imageHash) { | ||
const factoryInterface = new ethers.ethers.utils.Interface(abi.walletContracts.factory.abi); | ||
const factoryInterface = new ethers.ethers.Interface(abi.walletContracts.factory.abi); | ||
return { | ||
@@ -270,3 +269,3 @@ entrypoint: context.guestModule, | ||
if (nonce === undefined) throw new Error('Unable to determine nonce'); | ||
return nonce; | ||
return Number(nonce); | ||
} | ||
@@ -294,3 +293,3 @@ async signDigest(digest, metadata) { | ||
// and we can encode the final signature | ||
const subdigestBytes = ethers.ethers.utils.arrayify(subdigest); | ||
const subdigestBytes = ethers.ethers.getBytes(subdigest); | ||
const signature = await this.orchestrator.signMessage({ | ||
@@ -313,6 +312,16 @@ candidates: this.coders.config.signersOf(this.config).map(s => s.address), | ||
signMessage(message) { | ||
return this.signDigest(ethers.ethers.utils.keccak256(message), { | ||
return this.signDigest(ethers.ethers.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) { | ||
@@ -328,3 +337,3 @@ if (bundle.entrypoint !== this.address) { | ||
// specified nonce "space" | ||
spaceValue = ethers.ethers.BigNumber.from(nonce.space); | ||
spaceValue = BigInt(nonce.space); | ||
} else if (nonce === undefined) { | ||
@@ -347,3 +356,3 @@ // default is random, aka parallel | ||
randomNonce() { | ||
const randomNonceSpace = ethers.ethers.BigNumber.from(ethers.ethers.utils.hexlify(ethers.ethers.utils.randomBytes(12))); | ||
const randomNonceSpace = BigInt(ethers.ethers.hexlify(ethers.ethers.randomBytes(12))); | ||
const randomNonce = core.commons.transaction.encodeNonce(randomNonceSpace, 0); | ||
@@ -425,3 +434,3 @@ return randomNonce; | ||
return transactions.map((tx, i) => { | ||
const gasLimit = tx.gasLimit ? ethers.ethers.BigNumber.from(tx.gasLimit).toNumber() : simulations[i].gasLimit; | ||
const gasLimit = tx.gasLimit ? Number(BigInt(tx.gasLimit)) : simulations[i].gasLimit; | ||
return _extends({}, tx, simulations[i], { | ||
@@ -433,5 +442,14 @@ gasLimit | ||
connect(provider, relayer) { | ||
this.provider = provider; | ||
this.relayer = relayer; | ||
return this; | ||
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 | ||
}); | ||
} | ||
@@ -475,3 +493,3 @@ signTransaction(transaction) { | ||
suffix() { | ||
return [3]; | ||
return new Uint8Array([3]); | ||
} | ||
@@ -478,0 +496,0 @@ } |
@@ -12,3 +12,3 @@ 'use strict'; | ||
// TODO: Move to account ? | ||
class Signer extends ethers.Signer { | ||
class Signer extends ethers.ethers.AbstractSigner { | ||
static isSequenceSigner(cand) { | ||
@@ -76,5 +76,5 @@ return isSequenceSigner(cand); | ||
// T must include array type | ||
return Promise.all(object.map(o => ethers.utils.resolveProperties(o))); | ||
return Promise.all(object.map(o => ethers.ethers.resolveProperties(o))); | ||
} | ||
return ethers.utils.resolveProperties(object); | ||
return ethers.ethers.resolveProperties(object); | ||
} | ||
@@ -109,4 +109,4 @@ async function findLatestLog(provider, filter) { | ||
if (value.state === signhub.SignerState.SIGNED) { | ||
const suffix = ethers.ethers.utils.arrayify(value.suffix); | ||
const suffixed = ethers.ethers.utils.solidityPack(['bytes', 'bytes'], [value.signature, suffix]); | ||
const suffix = ethers.ethers.getBytes(value.suffix); | ||
const suffixed = ethers.ethers.solidityPacked(['bytes', 'bytes'], [value.signature, suffix]); | ||
parts.set(signer, { | ||
@@ -127,8 +127,9 @@ signature: suffixed, | ||
*/ | ||
class Wallet extends ethers.ethers.Signer { | ||
class Wallet extends ethers.ethers.AbstractSigner { | ||
constructor(options) { | ||
if (ethers.ethers.constants.Zero.eq(options.chainId) && !options.coders.signature.supportsNoChainId) { | ||
var _options$provider; | ||
if (BigInt(options.chainId) === 0n && !options.coders.signature.supportsNoChainId) { | ||
throw new Error(`Sequence version ${options.config.version} doesn't support chainId 0`); | ||
} | ||
super(); | ||
super((_options$provider = options.provider) != null ? _options$provider : null); | ||
this.context = void 0; | ||
@@ -138,3 +139,2 @@ this.config = void 0; | ||
this.chainId = void 0; | ||
this.provider = void 0; | ||
this.relayer = void 0; | ||
@@ -150,3 +150,2 @@ this.coders = void 0; | ||
this.chainId = options.chainId; | ||
this.provider = options.provider; | ||
this.relayer = options.relayer; | ||
@@ -238,3 +237,3 @@ this._reader = options.reader; | ||
intent: { | ||
id: ethers.ethers.utils.hexlify(ethers.ethers.utils.randomBytes(32)), | ||
id: ethers.ethers.hexlify(ethers.ethers.randomBytes(32)), | ||
wallet: this.address | ||
@@ -245,3 +244,3 @@ } | ||
static buildDeployTransaction(context, imageHash) { | ||
const factoryInterface = new ethers.ethers.utils.Interface(abi.walletContracts.factory.abi); | ||
const factoryInterface = new ethers.ethers.Interface(abi.walletContracts.factory.abi); | ||
return { | ||
@@ -270,3 +269,3 @@ entrypoint: context.guestModule, | ||
if (nonce === undefined) throw new Error('Unable to determine nonce'); | ||
return nonce; | ||
return Number(nonce); | ||
} | ||
@@ -294,3 +293,3 @@ async signDigest(digest, metadata) { | ||
// and we can encode the final signature | ||
const subdigestBytes = ethers.ethers.utils.arrayify(subdigest); | ||
const subdigestBytes = ethers.ethers.getBytes(subdigest); | ||
const signature = await this.orchestrator.signMessage({ | ||
@@ -313,6 +312,16 @@ candidates: this.coders.config.signersOf(this.config).map(s => s.address), | ||
signMessage(message) { | ||
return this.signDigest(ethers.ethers.utils.keccak256(message), { | ||
return this.signDigest(ethers.ethers.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) { | ||
@@ -328,3 +337,3 @@ if (bundle.entrypoint !== this.address) { | ||
// specified nonce "space" | ||
spaceValue = ethers.ethers.BigNumber.from(nonce.space); | ||
spaceValue = BigInt(nonce.space); | ||
} else if (nonce === undefined) { | ||
@@ -347,3 +356,3 @@ // default is random, aka parallel | ||
randomNonce() { | ||
const randomNonceSpace = ethers.ethers.BigNumber.from(ethers.ethers.utils.hexlify(ethers.ethers.utils.randomBytes(12))); | ||
const randomNonceSpace = BigInt(ethers.ethers.hexlify(ethers.ethers.randomBytes(12))); | ||
const randomNonce = core.commons.transaction.encodeNonce(randomNonceSpace, 0); | ||
@@ -425,3 +434,3 @@ return randomNonce; | ||
return transactions.map((tx, i) => { | ||
const gasLimit = tx.gasLimit ? ethers.ethers.BigNumber.from(tx.gasLimit).toNumber() : simulations[i].gasLimit; | ||
const gasLimit = tx.gasLimit ? Number(BigInt(tx.gasLimit)) : simulations[i].gasLimit; | ||
return _extends({}, tx, simulations[i], { | ||
@@ -433,5 +442,14 @@ gasLimit | ||
connect(provider, relayer) { | ||
this.provider = provider; | ||
this.relayer = relayer; | ||
return this; | ||
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 | ||
}); | ||
} | ||
@@ -475,3 +493,3 @@ signTransaction(transaction) { | ||
suffix() { | ||
return [3]; | ||
return new Uint8Array([3]); | ||
} | ||
@@ -478,0 +496,0 @@ } |
@@ -1,9 +0,9 @@ | ||
import { Signer as Signer$1, utils, ethers } from 'ethers'; | ||
import { ethers } from 'ethers'; | ||
import { commons } from '@0xsequence/core'; | ||
import { SignerState } from '@0xsequence/signhub'; | ||
import { subDigestOf } from '@0xsequence/utils'; | ||
import { subDigestOf, encodeTypedDataDigest } from '@0xsequence/utils'; | ||
import { walletContracts } from '@0xsequence/abi'; | ||
// TODO: Move to account ? | ||
class Signer extends Signer$1 { | ||
class Signer extends ethers.AbstractSigner { | ||
static isSequenceSigner(cand) { | ||
@@ -71,5 +71,5 @@ return isSequenceSigner(cand); | ||
// T must include array type | ||
return Promise.all(object.map(o => utils.resolveProperties(o))); | ||
return Promise.all(object.map(o => ethers.resolveProperties(o))); | ||
} | ||
return utils.resolveProperties(object); | ||
return ethers.resolveProperties(object); | ||
} | ||
@@ -104,4 +104,4 @@ async function findLatestLog(provider, filter) { | ||
if (value.state === SignerState.SIGNED) { | ||
const suffix = ethers.utils.arrayify(value.suffix); | ||
const suffixed = ethers.utils.solidityPack(['bytes', 'bytes'], [value.signature, suffix]); | ||
const suffix = ethers.getBytes(value.suffix); | ||
const suffixed = ethers.solidityPacked(['bytes', 'bytes'], [value.signature, suffix]); | ||
parts.set(signer, { | ||
@@ -122,8 +122,9 @@ signature: suffixed, | ||
*/ | ||
class Wallet extends ethers.Signer { | ||
class Wallet extends ethers.AbstractSigner { | ||
constructor(options) { | ||
if (ethers.constants.Zero.eq(options.chainId) && !options.coders.signature.supportsNoChainId) { | ||
var _options$provider; | ||
if (BigInt(options.chainId) === 0n && !options.coders.signature.supportsNoChainId) { | ||
throw new Error(`Sequence version ${options.config.version} doesn't support chainId 0`); | ||
} | ||
super(); | ||
super((_options$provider = options.provider) != null ? _options$provider : null); | ||
this.context = void 0; | ||
@@ -133,3 +134,2 @@ this.config = void 0; | ||
this.chainId = void 0; | ||
this.provider = void 0; | ||
this.relayer = void 0; | ||
@@ -145,3 +145,2 @@ this.coders = void 0; | ||
this.chainId = options.chainId; | ||
this.provider = options.provider; | ||
this.relayer = options.relayer; | ||
@@ -233,3 +232,3 @@ this._reader = options.reader; | ||
intent: { | ||
id: ethers.utils.hexlify(ethers.utils.randomBytes(32)), | ||
id: ethers.hexlify(ethers.randomBytes(32)), | ||
wallet: this.address | ||
@@ -240,3 +239,3 @@ } | ||
static buildDeployTransaction(context, imageHash) { | ||
const factoryInterface = new ethers.utils.Interface(walletContracts.factory.abi); | ||
const factoryInterface = new ethers.Interface(walletContracts.factory.abi); | ||
return { | ||
@@ -265,3 +264,3 @@ entrypoint: context.guestModule, | ||
if (nonce === undefined) throw new Error('Unable to determine nonce'); | ||
return nonce; | ||
return Number(nonce); | ||
} | ||
@@ -289,3 +288,3 @@ async signDigest(digest, metadata) { | ||
// and we can encode the final signature | ||
const subdigestBytes = ethers.utils.arrayify(subdigest); | ||
const subdigestBytes = ethers.getBytes(subdigest); | ||
const signature = await this.orchestrator.signMessage({ | ||
@@ -308,6 +307,16 @@ candidates: this.coders.config.signersOf(this.config).map(s => s.address), | ||
signMessage(message) { | ||
return this.signDigest(ethers.utils.keccak256(message), { | ||
return this.signDigest(ethers.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) { | ||
@@ -323,3 +332,3 @@ if (bundle.entrypoint !== this.address) { | ||
// specified nonce "space" | ||
spaceValue = ethers.BigNumber.from(nonce.space); | ||
spaceValue = BigInt(nonce.space); | ||
} else if (nonce === undefined) { | ||
@@ -342,3 +351,3 @@ // default is random, aka parallel | ||
randomNonce() { | ||
const randomNonceSpace = ethers.BigNumber.from(ethers.utils.hexlify(ethers.utils.randomBytes(12))); | ||
const randomNonceSpace = BigInt(ethers.hexlify(ethers.randomBytes(12))); | ||
const randomNonce = commons.transaction.encodeNonce(randomNonceSpace, 0); | ||
@@ -420,3 +429,3 @@ return randomNonce; | ||
return transactions.map((tx, i) => { | ||
const gasLimit = tx.gasLimit ? ethers.BigNumber.from(tx.gasLimit).toNumber() : simulations[i].gasLimit; | ||
const gasLimit = tx.gasLimit ? Number(BigInt(tx.gasLimit)) : simulations[i].gasLimit; | ||
return _extends({}, tx, simulations[i], { | ||
@@ -428,5 +437,14 @@ gasLimit | ||
connect(provider, relayer) { | ||
this.provider = provider; | ||
this.relayer = relayer; | ||
return this; | ||
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 | ||
}); | ||
} | ||
@@ -470,3 +488,3 @@ signTransaction(transaction) { | ||
suffix() { | ||
return [3]; | ||
return new Uint8Array([3]); | ||
} | ||
@@ -473,0 +491,0 @@ } |
@@ -12,5 +12,5 @@ import { commons } from '@0xsequence/core'; | ||
decorateTransactions(bundle: commons.transaction.IntendedTransactionBundle, _metadata: object): Promise<commons.transaction.IntendedTransactionBundle>; | ||
sign(message: ethers.utils.BytesLike, metadata: object): Promise<ethers.utils.BytesLike>; | ||
sign(message: ethers.BytesLike, metadata: object): Promise<ethers.BytesLike>; | ||
notifyStatusChange(_i: string, _s: Status, _m: object): void; | ||
suffix(): ethers.utils.BytesLike; | ||
suffix(): ethers.BytesLike; | ||
} |
@@ -1,9 +0,8 @@ | ||
import { BytesLike, Signer as AbstractSigner, providers, TypedDataDomain, TypedDataField, ethers } from 'ethers'; | ||
import { 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 AbstractSigner { | ||
export declare abstract class Signer extends ethers.AbstractSigner { | ||
static isSequenceSigner(cand: any): cand is Signer; | ||
abstract getProvider(chainId?: number): Promise<providers.JsonRpcProvider | undefined>; | ||
abstract getProvider(chainId?: number): Promise<ethers.JsonRpcProvider | undefined>; | ||
abstract getRelayer(chainId?: number): Promise<Relayer | undefined>; | ||
@@ -13,7 +12,7 @@ abstract getWalletConfig(chainId?: ChainIdLike): Promise<commons.config.Config>; | ||
abstract getSigners(): Promise<string[]>; | ||
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 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 sendSignedTransactions(signedTxs: commons.transaction.SignedTransactionBundle, chainId?: ChainIdLike, quote?: FeeQuote): Promise<commons.transaction.TransactionResponse>; | ||
@@ -25,3 +24,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: AbstractSigner): signer is Signer; | ||
export declare function isSequenceSigner(signer: any): signer is Signer; | ||
export declare class InvalidSigner extends Error { | ||
@@ -28,0 +27,0 @@ } |
@@ -1,3 +0,3 @@ | ||
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'; | ||
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 } 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'; | ||
@@ -17,3 +16,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.providers.Provider; | ||
provider?: ethers.Provider; | ||
relayer?: Relayer; | ||
@@ -30,3 +29,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.Signer { | ||
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 { | ||
context: commons.context.WalletContext; | ||
@@ -36,3 +35,2 @@ config: Y; | ||
chainId: ethers.BigNumberish; | ||
provider?: ethers.providers.Provider; | ||
relayer?: Relayer; | ||
@@ -55,8 +53,9 @@ coders: { | ||
buildDeployTransaction(metadata?: commons.WalletDeployMetadata): Promise<commons.transaction.TransactionBundle | undefined>; | ||
deploy(metadata?: commons.WalletDeployMetadata): Promise<ethers.providers.TransactionResponse | undefined>; | ||
deploy(metadata?: commons.WalletDeployMetadata): Promise<ethers.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<ethers.BigNumberish>; | ||
signDigest(digest: ethers.utils.BytesLike, metadata?: object): Promise<string>; | ||
getNonce(space?: ethers.BigNumberish): Promise<number>; | ||
signDigest(digest: ethers.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>; | ||
@@ -69,3 +68,3 @@ fetchNonceOrSpace(nonce?: ethers.BigNumberish | { | ||
randomNonce(): ethers.BigNumberish; | ||
signTransactions(txs: Deferrable<commons.transaction.Transactionish>, nonce?: ethers.BigNumberish | { | ||
signTransactions(txs: commons.transaction.Transactionish, nonce?: ethers.BigNumberish | { | ||
space: ethers.BigNumberish; | ||
@@ -75,11 +74,11 @@ } | { | ||
}, metadata?: object): Promise<commons.transaction.SignedTransactionBundle>; | ||
sendSignedTransaction(signedBundle: commons.transaction.IntendedTransactionBundle, quote?: FeeQuote): Promise<ethers.providers.TransactionResponse>; | ||
sendTransaction(txs: Deferrable<commons.transaction.Transactionish>, options?: { | ||
sendSignedTransaction(signedBundle: commons.transaction.IntendedTransactionBundle, quote?: FeeQuote): Promise<ethers.TransactionResponse>; | ||
sendTransaction(txs: commons.transaction.Transactionish, options?: { | ||
quote?: FeeQuote; | ||
nonce?: ethers.BigNumberish; | ||
serial?: boolean; | ||
}): 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>; | ||
}): 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>; | ||
} |
{ | ||
"name": "@0xsequence/wallet", | ||
"version": "0.0.0-20240704152116", | ||
"version": "0.0.0-20240709173026", | ||
"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-20240704152116", | ||
"@0xsequence/core": "0.0.0-20240704152116", | ||
"@0xsequence/network": "0.0.0-20240704152116", | ||
"@0xsequence/signhub": "0.0.0-20240704152116", | ||
"@0xsequence/relayer": "0.0.0-20240704152116", | ||
"@0xsequence/utils": "0.0.0-20240704152116" | ||
"@0xsequence/abi": "0.0.0-20240709173026", | ||
"@0xsequence/core": "0.0.0-20240709173026", | ||
"@0xsequence/network": "0.0.0-20240709173026", | ||
"@0xsequence/signhub": "0.0.0-20240709173026", | ||
"@0xsequence/relayer": "0.0.0-20240709173026", | ||
"@0xsequence/utils": "0.0.0-20240709173026" | ||
}, | ||
"peerDependencies": { | ||
"ethers": ">=5.5 < 6" | ||
"ethers": ">=6" | ||
}, | ||
"devDependencies": { | ||
"@0xsequence/ethauth": "^0.8.1", | ||
"@0xsequence/wallet-contracts": "^2.0.0", | ||
"@0xsequence/ethauth": "^1.0.0", | ||
"@0xsequence/wallet-contracts": "^3.0.1", | ||
"@istanbuljs/nyc-config-typescript": "^1.0.1", | ||
"ethers": "^5.7.2", | ||
"ethers": "^6.13.0", | ||
"web3": "^1.8.1", | ||
"@0xsequence/tests": "0.0.0-20240704152116" | ||
"@0xsequence/tests": "0.0.0-20240709173026" | ||
}, | ||
@@ -31,0 +31,0 @@ "files": [ |
@@ -31,3 +31,3 @@ import { commons } from '@0xsequence/core' | ||
sign(message: ethers.utils.BytesLike, metadata: object): Promise<ethers.utils.BytesLike> { | ||
sign(message: ethers.BytesLike, metadata: object): Promise<ethers.BytesLike> { | ||
if (!commons.isWalletSignRequestMetadata(metadata)) { | ||
@@ -44,5 +44,5 @@ throw new Error('SequenceOrchestratorWrapper only supports nested Sequence signatures') | ||
suffix(): ethers.utils.BytesLike { | ||
return [3] | ||
suffix(): ethers.BytesLike { | ||
return new Uint8Array([3]) | ||
} | ||
} |
@@ -1,9 +0,8 @@ | ||
import { BytesLike, Signer as AbstractSigner, providers, TypedDataDomain, TypedDataField, ethers } from 'ethers' | ||
import { 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 AbstractSigner { | ||
export abstract class Signer extends ethers.AbstractSigner { | ||
static isSequenceSigner(cand: any): cand is Signer { | ||
@@ -13,3 +12,3 @@ return isSequenceSigner(cand) | ||
abstract getProvider(chainId?: number): Promise<providers.JsonRpcProvider | undefined> | ||
abstract getProvider(chainId?: number): Promise<ethers.JsonRpcProvider | undefined> | ||
abstract getRelayer(chainId?: number): Promise<Relayer | undefined> | ||
@@ -28,10 +27,15 @@ | ||
// signMessage ..... | ||
abstract signMessage(message: BytesLike, chainId?: ChainIdLike, allSigners?: boolean, isDigest?: boolean): Promise<string> | ||
abstract signMessage( | ||
message: ethers.BytesLike, | ||
chainId?: ChainIdLike, | ||
allSigners?: boolean, | ||
isDigest?: boolean | ||
): Promise<string> | ||
// signTypedData .. | ||
abstract signTypedData( | ||
domain: TypedDataDomain, | ||
types: Record<string, Array<TypedDataField>>, | ||
domain: ethers.TypedDataDomain, | ||
types: Record<string, Array<ethers.TypedDataField>>, | ||
message: Record<string, any>, | ||
chainId: ChainIdLike, | ||
chainId?: ChainIdLike, | ||
allSigners?: boolean | ||
@@ -43,3 +47,3 @@ ): Promise<string> | ||
abstract sendTransaction( | ||
transaction: Deferrable<commons.transaction.Transactionish>, | ||
transaction: commons.transaction.Transactionish, | ||
chainId?: ChainIdLike, | ||
@@ -53,3 +57,3 @@ allSigners?: boolean, | ||
abstract sendTransactionBatch( | ||
transactions: Deferrable<ethers.providers.TransactionRequest[] | commons.transaction.Transaction[]>, | ||
transactions: ethers.TransactionRequest[] | commons.transaction.Transaction[], | ||
chainId?: ChainIdLike, | ||
@@ -64,3 +68,3 @@ allSigners?: boolean, | ||
abstract signTransactions( | ||
txs: Deferrable<commons.transaction.Transactionish>, | ||
txs: commons.transaction.Transactionish, | ||
chainId?: ChainIdLike, | ||
@@ -93,3 +97,3 @@ allSigners?: boolean | ||
export function isSequenceSigner(signer: AbstractSigner): signer is Signer { | ||
export function isSequenceSigner(signer: any): signer is Signer { | ||
const cand = signer as Signer | ||
@@ -96,0 +100,0 @@ return cand && cand.updateConfig !== undefined && cand.publishConfig !== undefined && cand.getWalletConfig !== undefined |
@@ -1,18 +0,13 @@ | ||
import { ethers, utils } from 'ethers' | ||
import { ethers } from 'ethers' | ||
export async function resolveArrayProperties<T>( | ||
object: Readonly<utils.Deferrable<T>> | Readonly<utils.Deferrable<T>>[] | ||
): Promise<T> { | ||
export async function resolveArrayProperties<T>(object: Readonly<T> | Readonly<T>[]): Promise<T> { | ||
if (Array.isArray(object)) { | ||
// T must include array type | ||
return Promise.all(object.map(o => utils.resolveProperties(o))) as any | ||
return Promise.all(object.map(o => ethers.resolveProperties(o))) as any | ||
} | ||
return utils.resolveProperties(object) | ||
return ethers.resolveProperties(object) | ||
} | ||
export async function findLatestLog( | ||
provider: ethers.providers.Provider, | ||
filter: ethers.providers.Filter | ||
): Promise<ethers.providers.Log | undefined> { | ||
export async function findLatestLog(provider: ethers.Provider, filter: ethers.Filter): Promise<ethers.Log | undefined> { | ||
const toBlock = filter.toBlock === 'latest' ? await provider.getBlockNumber() : (filter.toBlock as number) | ||
@@ -19,0 +14,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 { Deferrable, subDigestOf } from '@0xsequence/utils' | ||
import { encodeTypedDataDigest, subDigestOf } from '@0xsequence/utils' | ||
import { FeeQuote, Relayer } from '@0xsequence/relayer' | ||
@@ -30,3 +30,3 @@ import { walletContracts } from '@0xsequence/abi' | ||
provider?: ethers.providers.Provider | ||
provider?: ethers.Provider | ||
relayer?: Relayer | ||
@@ -41,4 +41,4 @@ } | ||
if (value.state === SignerState.SIGNED) { | ||
const suffix = ethers.utils.arrayify(value.suffix) | ||
const suffixed = ethers.utils.solidityPack(['bytes', 'bytes'], [value.signature, suffix]) | ||
const suffix = ethers.getBytes(value.suffix) | ||
const suffixed = ethers.solidityPacked(['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.Signer { | ||
> extends ethers.AbstractSigner { | ||
public context: commons.context.WalletContext | ||
@@ -73,3 +73,2 @@ public config: Y | ||
public provider?: ethers.providers.Provider | ||
public relayer?: Relayer | ||
@@ -86,7 +85,7 @@ | ||
constructor(options: WalletOptions<T, Y, Z>) { | ||
if (ethers.constants.Zero.eq(options.chainId) && !options.coders.signature.supportsNoChainId) { | ||
if (BigInt(options.chainId) === 0n && !options.coders.signature.supportsNoChainId) { | ||
throw new Error(`Sequence version ${options.config.version} doesn't support chainId 0`) | ||
} | ||
super() | ||
super(options.provider ?? null) | ||
@@ -99,3 +98,2 @@ this.context = options.context | ||
this.chainId = options.chainId | ||
this.provider = options.provider | ||
this.relayer = options.relayer | ||
@@ -201,3 +199,3 @@ | ||
async deploy(metadata?: commons.WalletDeployMetadata): Promise<ethers.providers.TransactionResponse | undefined> { | ||
async deploy(metadata?: commons.WalletDeployMetadata): Promise<ethers.TransactionResponse | undefined> { | ||
const deployTx = await this.buildDeployTransaction(metadata) | ||
@@ -213,3 +211,3 @@ if (deployTx === undefined) { | ||
intent: { | ||
id: ethers.utils.hexlify(ethers.utils.randomBytes(32)), | ||
id: ethers.hexlify(ethers.randomBytes(32)), | ||
wallet: this.address | ||
@@ -224,3 +222,3 @@ } | ||
): commons.transaction.TransactionBundle { | ||
const factoryInterface = new ethers.utils.Interface(walletContracts.factory.abi) | ||
const factoryInterface = new ethers.Interface(walletContracts.factory.abi) | ||
@@ -232,3 +230,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, | ||
@@ -253,9 +251,9 @@ delegateCall: false, | ||
async getNonce(space: ethers.BigNumberish = 0): Promise<ethers.BigNumberish> { | ||
async getNonce(space: ethers.BigNumberish = 0): Promise<number> { | ||
const nonce = await this.reader().nonce(this.address, space) | ||
if (nonce === undefined) throw new Error('Unable to determine nonce') | ||
return nonce | ||
return Number(nonce) | ||
} | ||
async signDigest(digest: ethers.utils.BytesLike, metadata?: object): Promise<string> { | ||
async signDigest(digest: ethers.BytesLike, metadata?: object): Promise<string> { | ||
// The subdigest may be statically defined on the configuration | ||
@@ -281,3 +279,3 @@ // in that case we just encode the proof, no need to sign anything | ||
// and we can encode the final signature | ||
const subdigestBytes = ethers.utils.arrayify(subdigest) | ||
const subdigestBytes = ethers.getBytes(subdigest) | ||
const signature = await this.orchestrator.signMessage({ | ||
@@ -302,5 +300,15 @@ candidates: this.coders.config.signersOf(this.config).map(s => s.address), | ||
signMessage(message: ethers.BytesLike): Promise<string> { | ||
return this.signDigest(ethers.utils.keccak256(message), { message }) | ||
return this.signDigest(ethers.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> { | ||
@@ -321,3 +329,3 @@ if (bundle.entrypoint !== this.address) { | ||
// specified nonce "space" | ||
spaceValue = ethers.BigNumber.from((nonce as any).space) | ||
spaceValue = BigInt((nonce as any).space) | ||
} else if (nonce === undefined) { | ||
@@ -341,3 +349,3 @@ // default is random, aka parallel | ||
randomNonce(): ethers.BigNumberish { | ||
const randomNonceSpace = ethers.BigNumber.from(ethers.utils.hexlify(ethers.utils.randomBytes(12))) | ||
const randomNonceSpace = BigInt(ethers.hexlify(ethers.randomBytes(12))) | ||
const randomNonce = commons.transaction.encodeNonce(randomNonceSpace, 0) | ||
@@ -348,3 +356,3 @@ return randomNonce | ||
async signTransactions( | ||
txs: Deferrable<commons.transaction.Transactionish>, | ||
txs: commons.transaction.Transactionish, | ||
nonce?: ethers.BigNumberish | { space: ethers.BigNumberish } | { serial: boolean }, | ||
@@ -396,3 +404,3 @@ metadata?: object | ||
quote?: FeeQuote | ||
): Promise<ethers.providers.TransactionResponse> { | ||
): Promise<ethers.TransactionResponse> { | ||
if (!this.relayer) throw new Error('Wallet sendTransaction requires a relayer') | ||
@@ -409,3 +417,3 @@ return this.relayer.relay(signedBundle, quote) | ||
async sendTransaction( | ||
txs: Deferrable<commons.transaction.Transactionish>, | ||
txs: commons.transaction.Transactionish, | ||
options?: { | ||
@@ -416,3 +424,3 @@ quote?: FeeQuote | ||
} | ||
): Promise<ethers.providers.TransactionResponse> { | ||
): Promise<ethers.TransactionResponse> { | ||
let nonce: ethers.BigNumberish | { serial: boolean } | ||
@@ -435,3 +443,3 @@ if (options?.nonce !== undefined) { | ||
async fillGasLimits(txs: Deferrable<commons.transaction.Transactionish>): Promise<commons.transaction.SimulatedTransaction[]> { | ||
async fillGasLimits(txs: commons.transaction.Transactionish): Promise<commons.transaction.SimulatedTransaction[]> { | ||
const transaction = await resolveArrayProperties<commons.transaction.Transactionish>(txs) | ||
@@ -444,3 +452,3 @@ const transactions = commons.transaction.fromTransactionish(this.address, transaction) | ||
return transactions.map((tx, i) => { | ||
const gasLimit = tx.gasLimit ? ethers.BigNumber.from(tx.gasLimit).toNumber() : simulations[i].gasLimit | ||
const gasLimit = tx.gasLimit ? Number(BigInt(tx.gasLimit)) : simulations[i].gasLimit | ||
return { ...tx, ...simulations[i], gasLimit } | ||
@@ -450,11 +458,24 @@ }) | ||
connect(provider: ethers.providers.Provider, relayer?: Relayer): Wallet<Y, T, Z> { | ||
this.provider = provider | ||
this.relayer = relayer | ||
return this | ||
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 | ||
}) | ||
} | ||
signTransaction(transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>): Promise<string> { | ||
signTransaction(transaction: ethers.TransactionRequest): Promise<string> { | ||
throw new Error('Method not implemented.') | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100861
2039
+ Added@0xsequence/abi@0.0.0-20240709173026(transitive)
+ Added@0xsequence/core@0.0.0-20240709173026(transitive)
+ Added@0xsequence/indexer@0.0.0-20240709173026(transitive)
+ Added@0xsequence/network@0.0.0-20240709173026(transitive)
+ Added@0xsequence/relayer@0.0.0-20240709173026(transitive)
+ Added@0xsequence/signhub@0.0.0-20240709173026(transitive)
+ Added@0xsequence/utils@0.0.0-20240709173026(transitive)
+ Added@adraffy/ens-normalize@1.10.1(transitive)
+ Added@noble/curves@1.2.0(transitive)
+ Added@noble/hashes@1.3.2(transitive)
+ Added@types/node@22.7.5(transitive)
+ Addedaes-js@4.0.0-beta.5(transitive)
+ Addedethers@6.13.5(transitive)
+ Addedtslib@2.7.0(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addedws@8.17.1(transitive)
- Removed@0xsequence/abi@0.0.0-20240704152116(transitive)
- Removed@0xsequence/core@0.0.0-20240704152116(transitive)
- Removed@0xsequence/indexer@0.0.0-20240704152116(transitive)
- Removed@0xsequence/network@0.0.0-20240704152116(transitive)
- Removed@0xsequence/relayer@0.0.0-20240704152116(transitive)
- Removed@0xsequence/signhub@0.0.0-20240704152116(transitive)
- Removed@0xsequence/utils@0.0.0-20240704152116(transitive)
- Removed@ethersproject/abi@5.7.0(transitive)
- Removed@ethersproject/abstract-provider@5.7.0(transitive)
- Removed@ethersproject/abstract-signer@5.7.0(transitive)
- Removed@ethersproject/address@5.7.0(transitive)
- Removed@ethersproject/base64@5.7.0(transitive)
- Removed@ethersproject/basex@5.7.0(transitive)
- Removed@ethersproject/bignumber@5.7.0(transitive)
- Removed@ethersproject/bytes@5.7.0(transitive)
- Removed@ethersproject/constants@5.7.0(transitive)
- Removed@ethersproject/contracts@5.7.0(transitive)
- Removed@ethersproject/hash@5.7.0(transitive)
- Removed@ethersproject/hdnode@5.7.0(transitive)
- Removed@ethersproject/json-wallets@5.7.0(transitive)
- Removed@ethersproject/keccak256@5.7.0(transitive)
- Removed@ethersproject/logger@5.7.0(transitive)
- Removed@ethersproject/networks@5.7.1(transitive)
- Removed@ethersproject/pbkdf2@5.7.0(transitive)
- Removed@ethersproject/properties@5.7.0(transitive)
- Removed@ethersproject/providers@5.7.2(transitive)
- Removed@ethersproject/random@5.7.0(transitive)
- Removed@ethersproject/rlp@5.7.0(transitive)
- Removed@ethersproject/sha2@5.7.0(transitive)
- Removed@ethersproject/signing-key@5.7.0(transitive)
- Removed@ethersproject/solidity@5.7.0(transitive)
- Removed@ethersproject/strings@5.7.0(transitive)
- Removed@ethersproject/transactions@5.7.0(transitive)
- Removed@ethersproject/units@5.7.0(transitive)
- Removed@ethersproject/wallet@5.7.0(transitive)
- Removed@ethersproject/web@5.7.1(transitive)
- Removed@ethersproject/wordlists@5.7.0(transitive)
- Removedaes-js@3.0.0(transitive)
- Removedbech32@1.1.4(transitive)
- Removedbn.js@4.12.15.2.1(transitive)
- Removedbrorand@1.1.0(transitive)
- Removedelliptic@6.5.4(transitive)
- Removedethers@5.7.2(transitive)
- Removedhash.js@1.1.7(transitive)
- Removedhmac-drbg@1.0.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedjs-sha3@0.8.0(transitive)
- Removedminimalistic-assert@1.0.1(transitive)
- Removedminimalistic-crypto-utils@1.0.1(transitive)
- Removedscrypt-js@3.0.1(transitive)
- Removedws@7.4.6(transitive)