@0xsequence/core
Advanced tools
Comparing version 0.0.0-20240703210534 to 0.0.0-20240704152116
@@ -21,3 +21,3 @@ import { ethers } from 'ethers'; | ||
isWalletConfig: (config: Config) => config is T; | ||
checkpointOf: (config: T) => bigint; | ||
checkpointOf: (config: T) => ethers.BigNumber; | ||
fromSimple: (config: SimpleConfig) => T; | ||
@@ -24,0 +24,0 @@ signersOf: (config: T) => { |
@@ -11,3 +11,3 @@ import { ethers } from 'ethers'; | ||
export declare function addressOf(context: WalletContext, imageHash: ethers.BytesLike): string; | ||
export declare function isValidCounterfactual(wallet: string, digest: ethers.BytesLike, signature: ethers.BytesLike, chainId: ethers.BigNumberish, provider: ethers.Provider, contexts: { | ||
export declare function isValidCounterfactual(wallet: string, digest: ethers.BytesLike, signature: ethers.BytesLike, chainId: ethers.BigNumberish, provider: ethers.providers.Provider, contexts: { | ||
[key: number]: WalletContext; | ||
@@ -14,0 +14,0 @@ }): Promise<boolean>; |
@@ -9,7 +9,7 @@ import { ethers } from 'ethers'; | ||
address: string; | ||
digest: ethers.BytesLike; | ||
digest: ethers.utils.BytesLike; | ||
chainId: ethers.BigNumberish; | ||
config: Config; | ||
parts?: Map<string, commons.signature.SignaturePart>; | ||
message?: ethers.BytesLike; | ||
message?: ethers.utils.BytesLike; | ||
transactions?: commons.transaction.Transaction[]; | ||
@@ -16,0 +16,0 @@ parent?: WalletSignRequestMetadata; |
@@ -17,5 +17,5 @@ import { ethers } from 'ethers'; | ||
export declare class OnChainReader implements Reader { | ||
readonly provider: ethers.Provider; | ||
readonly provider: ethers.providers.Provider; | ||
private isDeployedCache; | ||
constructor(provider: ethers.Provider); | ||
constructor(provider: ethers.providers.Provider); | ||
private module; | ||
@@ -22,0 +22,0 @@ isDeployed(wallet: string): Promise<boolean>; |
@@ -26,7 +26,7 @@ import { ethers } from 'ethers'; | ||
trim: (data: string) => Promise<string>; | ||
recover: (data: Z, payload: SignedPayload, provider: ethers.Provider) => Promise<T>; | ||
recover: (data: Z, payload: SignedPayload, provider: ethers.providers.Provider) => Promise<T>; | ||
supportsNoChainId: boolean; | ||
encodeSigners: (config: Y, signatures: Map<string, SignaturePart>, subdigests: string[], chainId: ethers.BigNumberish) => { | ||
encoded: string; | ||
weight: bigint; | ||
weight: ethers.BigNumber; | ||
}; | ||
@@ -33,0 +33,0 @@ hasEnoughSigningPower: (config: Y, signatures: Map<string, SignaturePart>) => boolean; |
@@ -9,3 +9,3 @@ import { ethers } from 'ethers'; | ||
export declare function recoverSigner(digest: ethers.BytesLike, signature: ethers.BytesLike): string; | ||
export declare function isValidSignature(address: string, digest: ethers.BytesLike, signature: ethers.BytesLike, provider: ethers.Provider): boolean | Promise<boolean>; | ||
export declare function isValidSignature(address: string, digest: ethers.BytesLike, signature: ethers.BytesLike, provider: ethers.providers.Provider): boolean | Promise<boolean>; | ||
export declare function tryRecoverSigner(digest: ethers.BytesLike, signature: ethers.BytesLike): string | undefined; |
@@ -1,7 +0,7 @@ | ||
import { ethers } from 'ethers'; | ||
import { BigNumberish, BytesLike, ethers } from 'ethers'; | ||
export interface Transaction { | ||
to: string; | ||
value?: ethers.BigNumberish; | ||
data?: string; | ||
gasLimit?: ethers.BigNumberish; | ||
value?: BigNumberish; | ||
data?: BytesLike; | ||
gasLimit?: BigNumberish; | ||
delegateCall?: boolean; | ||
@@ -21,9 +21,9 @@ revertOnError?: boolean; | ||
revertOnError: boolean; | ||
gasLimit: ethers.BigNumberish; | ||
gasLimit: BigNumberish; | ||
target: string; | ||
value: ethers.BigNumberish; | ||
data: string; | ||
value: BigNumberish; | ||
data: BytesLike; | ||
} | ||
export type Transactionish = ethers.TransactionRequest | ethers.TransactionRequest[] | Transaction | Transaction[]; | ||
export interface TransactionResponse<R = any> extends ethers.TransactionResponse { | ||
export type Transactionish = ethers.providers.TransactionRequest | ethers.providers.TransactionRequest[] | Transaction | Transaction[]; | ||
export interface TransactionResponse<R = any> extends ethers.providers.TransactionResponse { | ||
receipt?: R; | ||
@@ -34,6 +34,6 @@ } | ||
transactions: Transaction[]; | ||
nonce?: ethers.BigNumberish; | ||
nonce?: BigNumberish; | ||
}; | ||
export type IntendedTransactionBundle = TransactionBundle & { | ||
chainId: ethers.BigNumberish; | ||
chainId: BigNumberish; | ||
intent: { | ||
@@ -46,18 +46,18 @@ id: string; | ||
signature: string; | ||
nonce: ethers.BigNumberish; | ||
nonce: BigNumberish; | ||
}; | ||
export type RelayReadyTransactionBundle = SignedTransactionBundle | IntendedTransactionBundle; | ||
export declare const MetaTransactionsType = "tuple(\n bool delegateCall,\n bool revertOnError,\n uint256 gasLimit,\n address target,\n uint256 value,\n bytes data\n)[]"; | ||
export declare function intendTransactionBundle(bundle: TransactionBundle, wallet: string, chainId: ethers.BigNumberish, id: string): IntendedTransactionBundle; | ||
export declare function intendTransactionBundle(bundle: TransactionBundle, wallet: string, chainId: BigNumberish, id: string): IntendedTransactionBundle; | ||
export declare function intendedTransactionID(bundle: IntendedTransactionBundle): string; | ||
export declare function unpackMetaTransactionsData(data: ethers.BytesLike): [bigint, TransactionEncoded[]]; | ||
export declare function unpackMetaTransactionsData(data: BytesLike): [ethers.BigNumber, TransactionEncoded[]]; | ||
export declare function packMetaTransactionsData(nonce: ethers.BigNumberish, txs: Transaction[]): string; | ||
export declare function digestOfTransactions(nonce: ethers.BigNumberish, txs: Transaction[]): string; | ||
export declare function subdigestOfTransactions(address: string, chainId: ethers.BigNumberish, nonce: ethers.BigNumberish, txs: Transaction[]): string; | ||
export declare function subdigestOfGuestModuleTransactions(guestModule: string, chainId: ethers.BigNumberish, txs: Transaction[]): string; | ||
export declare function toSequenceTransactions(wallet: string, txs: ethers.TransactionRequest[]): { | ||
export declare function digestOfTransactions(nonce: BigNumberish, txs: Transaction[]): string; | ||
export declare function subdigestOfTransactions(address: string, chainId: BigNumberish, nonce: ethers.BigNumberish, txs: Transaction[]): string; | ||
export declare function subdigestOfGuestModuleTransactions(guestModule: string, chainId: BigNumberish, txs: Transaction[]): string; | ||
export declare function toSequenceTransactions(wallet: string, txs: (Transaction | ethers.providers.TransactionRequest)[]): { | ||
nonce?: ethers.BigNumberish; | ||
transaction: Transaction; | ||
}[]; | ||
export declare function toSequenceTransaction(wallet: string, tx: ethers.TransactionRequest): { | ||
export declare function toSequenceTransaction(wallet: string, tx: ethers.providers.TransactionRequest): { | ||
nonce?: ethers.BigNumberish; | ||
@@ -70,4 +70,4 @@ transaction: Transaction; | ||
export declare function fromTxAbiEncode(txs: TransactionEncoded[]): Transaction[]; | ||
export declare function encodeNonce(space: ethers.BigNumberish, nonce: ethers.BigNumberish): bigint; | ||
export declare function decodeNonce(nonce: ethers.BigNumberish): [bigint, bigint]; | ||
export declare function encodeNonce(space: BigNumberish, nonce: BigNumberish): ethers.BigNumber; | ||
export declare function decodeNonce(nonce: BigNumberish): [ethers.BigNumber, ethers.BigNumber]; | ||
export declare function fromTransactionish(wallet: string, transaction: Transactionish): Transaction[]; | ||
@@ -74,0 +74,0 @@ export declare function isTransactionBundle(cand: any): cand is TransactionBundle; |
import { ethers } from 'ethers'; | ||
export declare function isValidEIP1271Signature(address: string, digest: string, signature: ethers.BytesLike, provider: ethers.Provider): Promise<boolean>; | ||
export declare function isValidEIP1271Signature(address: string, digest: string, signature: ethers.BytesLike, provider: ethers.providers.Provider): Promise<boolean>; |
import { ethers } from 'ethers'; | ||
export declare const EIP_6492_OFFCHAIN_DEPLOY_CODE = "0x608060405234801561001057600080fd5b5060405161124a38038061124a83398101604081905261002f91610124565b600060405161003d906100dd565b604051809103906000f080158015610059573d6000803e3d6000fd5b5090506000816001600160a01b0316638f0684308686866040518463ffffffff1660e01b815260040161008e939291906101fb565b6020604051808303816000875af11580156100ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100d19190610244565b9050806000526001601ff35b610fdc8061026e83390190565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561011b578181015183820152602001610103565b50506000910152565b60008060006060848603121561013957600080fd5b83516001600160a01b038116811461015057600080fd5b6020850151604086015191945092506001600160401b038082111561017457600080fd5b818601915086601f83011261018857600080fd5b81518181111561019a5761019a6100ea565b604051601f8201601f19908116603f011681019083821181831017156101c2576101c26100ea565b816040528281528960208487010111156101db57600080fd5b6101ec836020830160208801610100565b80955050505050509250925092565b60018060a01b0384168152826020820152606060408201526000825180606084015261022e816080850160208701610100565b601f01601f191691909101608001949350505050565b60006020828403121561025657600080fd5b8151801515811461026657600080fd5b939250505056fe608060405234801561001057600080fd5b50610fbc806100206000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c806376be4cea1161005057806376be4cea146100a65780638f068430146100b957806398ef1ed8146100cc57600080fd5b80631c6453271461006c5780633d787b6314610093575b600080fd5b61007f61007a366004610ad4565b6100df565b604051901515815260200160405180910390f35b61007f6100a1366004610ad4565b61023d565b61007f6100b4366004610b3e565b61031e565b61007f6100c7366004610ad4565b6108e1565b61007f6100da366004610ad4565b61096e565b6040517f76be4cea00000000000000000000000000000000000000000000000000000000815260009030906376be4cea9061012890889088908890889088908190600401610bc3565b6020604051808303816000875af1925050508015610181575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820190925261017e91810190610c45565b60015b610232573d8080156101af576040519150601f19603f3d011682016040523d82523d6000602084013e6101b4565b606091505b508051600181900361022757816000815181106101d3576101d3610c69565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167f0100000000000000000000000000000000000000000000000000000000000000149250610235915050565b600092505050610235565b90505b949350505050565b6040517f76be4cea00000000000000000000000000000000000000000000000000000000815260009030906376be4cea906102879088908890889088906001908990600401610bc3565b6020604051808303816000875af19250505080156102e0575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526102dd91810190610c45565b60015b610232573d80801561030e576040519150601f19603f3d011682016040523d82523d6000602084013e610313565b606091505b506000915050610235565b600073ffffffffffffffffffffffffffffffffffffffff87163b6060827f64926492649264926492649264926492649264926492649264926492649264928888610369602082610c98565b610375928b9290610cd8565b61037e91610d02565b1490508015610484576000606089828a610399602082610c98565b926103a693929190610cd8565b8101906103b39190610e18565b955090925090508415806103c45750865b1561047d576000808373ffffffffffffffffffffffffffffffffffffffff16836040516103f19190610eb2565b6000604051808303816000865af19150503d806000811461042e576040519150601f19603f3d011682016040523d82523d6000602084013e610433565b606091505b50915091508161047a57806040517f9d0d6e2d0000000000000000000000000000000000000000000000000000000081526004016104719190610f18565b60405180910390fd5b50505b50506104be565b87878080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509294505050505b80806104ca5750600083115b156106bb576040517f1626ba7e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8b1690631626ba7e90610523908c908690600401610f2b565b602060405180830381865afa92505050801561057a575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820190925261057791810190610f44565b60015b61060f573d8080156105a8576040519150601f19603f3d011682016040523d82523d6000602084013e6105ad565b606091505b50851580156105bc5750600084115b156105db576105d08b8b8b8b8b600161031e565b9450505050506108d7565b806040517f6f2a95990000000000000000000000000000000000000000000000000000000081526004016104719190610f18565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f1626ba7e000000000000000000000000000000000000000000000000000000001480158161065f575086155b801561066b5750600085115b1561068b5761067f8c8c8c8c8c600161031e565b955050505050506108d7565b841580156106965750825b80156106a0575087155b156106af57806000526001601ffd5b94506108d79350505050565b6041871461074b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603a60248201527f5369676e617475726556616c696461746f72237265636f7665725369676e657260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610471565b600061075a6020828a8c610cd8565b61076391610d02565b90506000610775604060208b8d610cd8565b61077e91610d02565b905060008a8a604081811061079557610795610c69565b919091013560f81c915050601b81148015906107b557508060ff16601c14155b15610842576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f5369676e617475726556616c696461746f723a20696e76616c6964207369676e60448201527f617475726520762076616c7565000000000000000000000000000000000000006064820152608401610471565b6040805160008152602081018083528e905260ff831691810191909152606081018490526080810183905273ffffffffffffffffffffffffffffffffffffffff8e169060019060a0016020604051602081039080840390855afa1580156108ad573d6000803e3d6000fd5b5050506020604051035173ffffffffffffffffffffffffffffffffffffffff161496505050505050505b9695505050505050565b6040517f76be4cea00000000000000000000000000000000000000000000000000000000815260009030906376be4cea9061092b9088908890889088906001908990600401610bc3565b6020604051808303816000875af115801561094a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102329190610c45565b6040517f76be4cea00000000000000000000000000000000000000000000000000000000815260009030906376be4cea906109b790889088908890889088908190600401610bc3565b6020604051808303816000875af1925050508015610a10575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252610a0d91810190610c45565b60015b610232573d808015610a3e576040519150601f19603f3d011682016040523d82523d6000602084013e610a43565b606091505b5080516001819003610a6257816000815181106101d3576101d3610c69565b8082fd5b73ffffffffffffffffffffffffffffffffffffffff81168114610a8857600080fd5b50565b60008083601f840112610a9d57600080fd5b50813567ffffffffffffffff811115610ab557600080fd5b602083019150836020828501011115610acd57600080fd5b9250929050565b60008060008060608587031215610aea57600080fd5b8435610af581610a66565b935060208501359250604085013567ffffffffffffffff811115610b1857600080fd5b610b2487828801610a8b565b95989497509550505050565b8015158114610a8857600080fd5b60008060008060008060a08789031215610b5757600080fd5b8635610b6281610a66565b955060208701359450604087013567ffffffffffffffff811115610b8557600080fd5b610b9189828a01610a8b565b9095509350506060870135610ba581610b30565b91506080870135610bb581610b30565b809150509295509295509295565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a060408201528360a0820152838560c0830137600060c085830181019190915292151560608201529015156080820152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016909101019392505050565b600060208284031215610c5757600080fd5b8151610c6281610b30565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b81810381811115610cd2577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b60008085851115610ce857600080fd5b83861115610cf557600080fd5b5050820193919092039150565b80356020831015610cd2577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff602084900360031b1b1692915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f830112610d7e57600080fd5b813567ffffffffffffffff80821115610d9957610d99610d3e565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908282118183101715610ddf57610ddf610d3e565b81604052838152866020858801011115610df857600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600060608486031215610e2d57600080fd5b8335610e3881610a66565b9250602084013567ffffffffffffffff80821115610e5557600080fd5b610e6187838801610d6d565b93506040860135915080821115610e7757600080fd5b50610e8486828701610d6d565b9150509250925092565b60005b83811015610ea9578181015183820152602001610e91565b50506000910152565b60008251610ec4818460208701610e8e565b9190910192915050565b60008151808452610ee6816020860160208601610e8e565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000610c626020830184610ece565b8281526040602082015260006102356040830184610ece565b600060208284031215610f5657600080fd5b81517fffffffff0000000000000000000000000000000000000000000000000000000081168114610c6257600080fdfea26469706673582212201a72aed4b15ffb05b6502997a9bb655992e06590bd26b336dfbb153d7ff6f34b64736f6c63430008120033"; | ||
export declare const EIP_6492_SUFFIX = "0x6492649264926492649264926492649264926492649264926492649264926492"; | ||
export declare function validateEIP6492Offchain(provider: ethers.Provider, signer: string, hash: ethers.BytesLike, signature: ethers.BytesLike): Promise<boolean>; | ||
export declare function validateEIP6492Offchain(provider: ethers.providers.Provider, signer: string, hash: ethers.utils.BytesLike, signature: ethers.utils.BytesLike): Promise<boolean>; |
@@ -7,3 +7,2 @@ export * as v1 from "./v1/index.js"; | ||
import * as v2 from "./v2/index.js"; | ||
export { VERSION } from "./version.js"; | ||
export declare const allVersions: (typeof v1 | typeof v2)[]; |
import { WalletContext } from "../commons/context.js"; | ||
export * as config from "./config.js"; | ||
export * as context from "./context.js"; | ||
export * as signature from "./signature.js"; | ||
export declare const version = 1; | ||
export declare const DeployedWalletContext: WalletContext; |
@@ -27,7 +27,7 @@ import { ethers } from 'ethers'; | ||
export declare function encodeSignature(signature: Signature | UnrecoveredSignature | ethers.BytesLike): string; | ||
export declare function recoverSignature(data: UnrecoveredSignature, payload: base.SignedPayload, provider: ethers.Provider): Promise<Signature>; | ||
export declare function recoverSignature(data: UnrecoveredSignature, payload: base.SignedPayload, provider: ethers.providers.Provider): Promise<Signature>; | ||
export declare function encodeSigners(config: WalletConfig, signatures: Map<string, base.SignaturePart>, subdigests: string[], _: ethers.BigNumberish): { | ||
encoded: string; | ||
weight: bigint; | ||
weight: ethers.BigNumber; | ||
}; | ||
export declare const SignatureCoder: base.SignatureCoder<WalletConfig, Signature, UnrecoveredSignature>; |
import { WalletContext as BaseContext } from "../commons/context.js"; | ||
export type WalletContext = BaseContext & { | ||
version: 2; | ||
universalSigValidator: string; | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { ethers } from 'ethers'; | ||
import { BigNumberish, ethers } from 'ethers'; | ||
import { Leaf, WalletConfig, SignerLeaf, Topology } from "./config.js"; | ||
@@ -29,4 +29,4 @@ import * as base from "../commons/signature.js"; | ||
tree: UnrecoveredTopology; | ||
weight: ethers.BigNumberish; | ||
threshold: ethers.BigNumberish; | ||
weight: BigNumberish; | ||
threshold: BigNumberish; | ||
}; | ||
@@ -47,3 +47,3 @@ export type UnrecoveredLeaf = UnrecoveredNestedLeaf | UnrecoveredSignatureLeaf | Leaf; | ||
} | ||
export declare function recoverTopology(unrecovered: UnrecoveredTopology, subdigest: string, provider: ethers.Provider): Promise<Topology>; | ||
export declare function recoverTopology(unrecovered: UnrecoveredTopology, subdigest: string, provider: ethers.providers.Provider): Promise<Topology>; | ||
export declare const partEncoder: { | ||
@@ -65,7 +65,7 @@ concat: (a: ethers.BytesLike, b: ethers.BytesLike) => string; | ||
encoded: string; | ||
weight: bigint; | ||
weight: ethers.BigNumber; | ||
}; | ||
export declare function encodeTree(topology: Topology, parts: Map<string, base.SignaturePart>, subdigests: string[], options?: EncodingOptions): { | ||
encoded: string; | ||
weight: bigint; | ||
weight: ethers.BigNumber; | ||
}; | ||
@@ -101,3 +101,3 @@ export type UnrecoveredConfig = { | ||
subdigest: string; | ||
}, provider: ethers.Provider): Promise<Signature | ChainedSignature>; | ||
}, provider: ethers.providers.Provider): Promise<Signature | ChainedSignature>; | ||
export declare function encodeChain(main: ethers.BytesLike, suffix: ethers.BytesLike[]): string; | ||
@@ -104,0 +104,0 @@ export declare function encodeSignature(decoded: UnrecoveredChainedSignature | ChainedSignature | UnrecoveredSignature | Signature | ethers.BytesLike): string; |
{ | ||
"name": "@0xsequence/core", | ||
"version": "0.0.0-20240703210534", | ||
"version": "0.0.0-20240704152116", | ||
"description": "core primitives for interacting with the sequence wallet contracts", | ||
@@ -12,3 +12,3 @@ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/core", | ||
"peerDependencies": { | ||
"ethers": ">=6" | ||
"ethers": ">=5.5" | ||
}, | ||
@@ -24,4 +24,3 @@ "devDependencies": { | ||
"dependencies": { | ||
"@0xsequence/utils": "0.0.0-20240703210534", | ||
"@0xsequence/abi": "0.0.0-20240703210534" | ||
"@0xsequence/abi": "0.0.0-20240704152116" | ||
}, | ||
@@ -31,4 +30,4 @@ "scripts": { | ||
"test:file": "TS_NODE_PROJECT=../../tsconfig.test.json mocha -r ts-node/register --timeout 30000", | ||
"test:coverage": "nyc pnpm test" | ||
"test:coverage": "nyc yarn test" | ||
} | ||
} |
@@ -24,3 +24,3 @@ import { ethers } from 'ethers' | ||
checkpointOf: (config: T) => bigint | ||
checkpointOf: (config: T) => ethers.BigNumber | ||
@@ -27,0 +27,0 @@ fromSimple: (config: SimpleConfig) => T |
@@ -18,11 +18,11 @@ import { ethers } from 'ethers' | ||
export function addressOf(context: WalletContext, imageHash: ethers.BytesLike) { | ||
const codeHash = ethers.keccak256( | ||
ethers.solidityPacked(['bytes', 'bytes32'], [context.walletCreationCode, ethers.zeroPadValue(context.mainModule, 32)]) | ||
const codeHash = ethers.utils.keccak256( | ||
ethers.utils.solidityPack(['bytes', 'bytes32'], [context.walletCreationCode, ethers.utils.hexZeroPad(context.mainModule, 32)]) | ||
) | ||
const hash = ethers.keccak256( | ||
ethers.solidityPacked(['bytes1', 'address', 'bytes32', 'bytes32'], ['0xff', context.factory, imageHash, codeHash]) | ||
const hash = ethers.utils.keccak256( | ||
ethers.utils.solidityPack(['bytes1', 'address', 'bytes32', 'bytes32'], ['0xff', context.factory, imageHash, codeHash]) | ||
) | ||
return ethers.getAddress(ethers.dataSlice(hash, 12)) | ||
return ethers.utils.getAddress(ethers.utils.hexDataSlice(hash, 12)) | ||
} | ||
@@ -35,3 +35,3 @@ | ||
chainId: ethers.BigNumberish, | ||
provider: ethers.Provider, | ||
provider: ethers.providers.Provider, | ||
contexts: { [key: number]: WalletContext } | ||
@@ -44,3 +44,3 @@ ) { | ||
try { | ||
const decoded = version.signature.SignatureCoder.decode(ethers.hexlify(signature)) | ||
const decoded = version.signature.SignatureCoder.decode(ethers.utils.hexlify(signature)) | ||
@@ -51,3 +51,3 @@ const recovered1 = await version.signature.SignatureCoder.recover( | ||
address: wallet, | ||
digest: ethers.hexlify(digest), | ||
digest: ethers.utils.hexlify(digest), | ||
chainId | ||
@@ -71,3 +71,3 @@ }, | ||
address: wallet, | ||
digest: ethers.hexlify(digest), | ||
digest: ethers.utils.hexlify(digest), | ||
chainId | ||
@@ -74,0 +74,0 @@ }, |
@@ -10,3 +10,3 @@ import { ethers } from 'ethers' | ||
address: string | ||
digest: ethers.BytesLike | ||
digest: ethers.utils.BytesLike | ||
chainId: ethers.BigNumberish | ||
@@ -22,3 +22,3 @@ | ||
message?: ethers.BytesLike | ||
message?: ethers.utils.BytesLike | ||
transactions?: commons.transaction.Transaction[] | ||
@@ -25,0 +25,0 @@ |
import { walletContracts } from '@0xsequence/abi' | ||
import { ethers } from 'ethers' | ||
import { commons } from '..' | ||
import { validateEIP6492Offchain } from './validateEIP6492' | ||
@@ -24,3 +25,3 @@ | ||
constructor(public readonly provider: ethers.Provider) {} | ||
constructor(public readonly provider: ethers.providers.Provider) {} | ||
@@ -41,3 +42,3 @@ private module(address: string) { | ||
const code = await this.provider.getCode(wallet).then(c => ethers.getBytes(c)) | ||
const code = await this.provider.getCode(wallet).then(c => ethers.utils.arrayify(c)) | ||
const isDeployed = code.length !== 0 | ||
@@ -52,11 +53,11 @@ if (isDeployed) { | ||
async implementation(wallet: string): Promise<string | undefined> { | ||
const position = ethers.AbiCoder.defaultAbiCoder().encode(['address'], [wallet]) | ||
const val = await this.provider.getStorage(wallet, position).then(c => ethers.getBytes(c)) | ||
const position = ethers.utils.defaultAbiCoder.encode(['address'], [wallet]) | ||
const val = await this.provider.getStorageAt(wallet, position).then(c => ethers.utils.arrayify(c)) | ||
if (val.length === 20) { | ||
return ethers.getAddress(ethers.hexlify(val)) | ||
return ethers.utils.getAddress(ethers.utils.hexlify(val)) | ||
} | ||
if (val.length === 32) { | ||
return ethers.AbiCoder.defaultAbiCoder().decode(['address'], val)[0] | ||
return ethers.utils.defaultAbiCoder.decode(['address'], val)[0] | ||
} | ||
@@ -63,0 +64,0 @@ |
@@ -37,3 +37,3 @@ import { ethers } from 'ethers' | ||
recover: (data: Z, payload: SignedPayload, provider: ethers.Provider) => Promise<T> | ||
recover: (data: Z, payload: SignedPayload, provider: ethers.providers.Provider) => Promise<T> | ||
@@ -49,3 +49,3 @@ supportsNoChainId: boolean | ||
encoded: string | ||
weight: bigint | ||
weight: ethers.BigNumber | ||
} | ||
@@ -65,3 +65,3 @@ | ||
export function subdigestOf(payload: SignedPayload) { | ||
return ethers.solidityPackedKeccak256( | ||
return ethers.utils.solidityKeccak256( | ||
['bytes', 'uint256', 'address', 'bytes32'], | ||
@@ -68,0 +68,0 @@ ['0x1901', payload.chainId, payload.address, payload.digest] |
@@ -11,3 +11,3 @@ import { ethers } from 'ethers' | ||
export function canRecover(signature: ethers.BytesLike) { | ||
const bytes = ethers.getBytes(signature) | ||
const bytes = ethers.utils.arrayify(signature) | ||
const type = bytes[bytes.length - 1] | ||
@@ -19,4 +19,4 @@ | ||
export function recoverSigner(digest: ethers.BytesLike, signature: ethers.BytesLike) { | ||
const bytes = ethers.getBytes(signature) | ||
const digestBytes = ethers.getBytes(digest) | ||
const bytes = ethers.utils.arrayify(signature) | ||
const digestBytes = ethers.utils.arrayify(digest) | ||
@@ -27,5 +27,5 @@ // type is last byte | ||
// Split r:s:v | ||
const r = ethers.hexlify(bytes.slice(0, 32)) | ||
const s = ethers.hexlify(bytes.slice(32, 64)) | ||
const v = Number(BigInt(ethers.hexlify(bytes.slice(64, 65)))) | ||
const r = ethers.utils.hexlify(bytes.slice(0, 32)) | ||
const s = ethers.utils.hexlify(bytes.slice(32, 64)) | ||
const v = ethers.BigNumber.from(bytes.slice(64, 65)).toNumber() | ||
@@ -35,7 +35,7 @@ const splitSignature = { r, s, v } | ||
if (type === SigType.EIP712) { | ||
return ethers.recoverAddress(digestBytes, splitSignature) | ||
return ethers.utils.recoverAddress(digestBytes, splitSignature) | ||
} | ||
if (type === SigType.ETH_SIGN) { | ||
return ethers.recoverAddress(ethers.hashMessage(digestBytes), splitSignature) | ||
return ethers.utils.recoverAddress(ethers.utils.hashMessage(digestBytes), splitSignature) | ||
} | ||
@@ -50,5 +50,5 @@ | ||
signature: ethers.BytesLike, | ||
provider: ethers.Provider | ||
provider: ethers.providers.Provider | ||
) { | ||
const bytes = ethers.getBytes(signature) | ||
const bytes = ethers.utils.arrayify(signature) | ||
@@ -63,3 +63,3 @@ // type is last byte | ||
if (type === SigType.WALLET_BYTES32) { | ||
return isValidEIP1271Signature(address, ethers.hexlify(digest), bytes.slice(0, -1), provider) | ||
return isValidEIP1271Signature(address, ethers.utils.hexlify(digest), bytes.slice(0, -1), provider) | ||
} | ||
@@ -71,3 +71,3 @@ | ||
export function tryRecoverSigner(digest: ethers.BytesLike, signature: ethers.BytesLike): string | undefined { | ||
const bytes = ethers.getBytes(signature) | ||
const bytes = ethers.utils.arrayify(signature) | ||
if (bytes.length !== 66) return undefined | ||
@@ -74,0 +74,0 @@ |
@@ -1,3 +0,2 @@ | ||
import { ethers } from 'ethers' | ||
import { BigNumberish, BytesLike, ethers } from 'ethers' | ||
import { subdigestOf } from './signature' | ||
@@ -8,5 +7,5 @@ import { walletContracts } from '@0xsequence/abi' | ||
to: string | ||
value?: ethers.BigNumberish | ||
data?: string | ||
gasLimit?: ethers.BigNumberish | ||
value?: BigNumberish | ||
data?: BytesLike | ||
gasLimit?: BigNumberish | ||
delegateCall?: boolean | ||
@@ -28,11 +27,15 @@ revertOnError?: boolean | ||
revertOnError: boolean | ||
gasLimit: ethers.BigNumberish | ||
gasLimit: BigNumberish | ||
target: string | ||
value: ethers.BigNumberish | ||
data: string | ||
value: BigNumberish | ||
data: BytesLike | ||
} | ||
export type Transactionish = ethers.TransactionRequest | ethers.TransactionRequest[] | Transaction | Transaction[] | ||
export type Transactionish = | ||
| ethers.providers.TransactionRequest | ||
| ethers.providers.TransactionRequest[] | ||
| Transaction | ||
| Transaction[] | ||
export interface TransactionResponse<R = any> extends ethers.TransactionResponse { | ||
export interface TransactionResponse<R = any> extends ethers.providers.TransactionResponse { | ||
receipt?: R | ||
@@ -44,7 +47,7 @@ } | ||
transactions: Transaction[] | ||
nonce?: ethers.BigNumberish | ||
nonce?: BigNumberish | ||
} | ||
export type IntendedTransactionBundle = TransactionBundle & { | ||
chainId: ethers.BigNumberish | ||
chainId: BigNumberish | ||
intent: { | ||
@@ -58,3 +61,3 @@ id: string | ||
signature: string | ||
nonce: ethers.BigNumberish | ||
nonce: BigNumberish | ||
} | ||
@@ -76,3 +79,3 @@ | ||
wallet: string, | ||
chainId: ethers.BigNumberish, | ||
chainId: BigNumberish, | ||
id: string | ||
@@ -88,4 +91,4 @@ ): IntendedTransactionBundle { | ||
export function intendedTransactionID(bundle: IntendedTransactionBundle) { | ||
return ethers.keccak256( | ||
ethers.AbiCoder.defaultAbiCoder().encode( | ||
return ethers.utils.keccak256( | ||
ethers.utils.defaultAbiCoder.encode( | ||
['address', 'uint256', 'bytes32'], | ||
@@ -97,4 +100,4 @@ [bundle.intent.wallet, bundle.chainId, bundle.intent.id] | ||
export function unpackMetaTransactionsData(data: ethers.BytesLike): [bigint, TransactionEncoded[]] { | ||
const res = ethers.AbiCoder.defaultAbiCoder().decode(['uint256', MetaTransactionsType], data) | ||
export function unpackMetaTransactionsData(data: BytesLike): [ethers.BigNumber, TransactionEncoded[]] { | ||
const res = ethers.utils.defaultAbiCoder.decode(['uint256', MetaTransactionsType], data) | ||
if (res.length !== 2 || !res[0] || !res[1]) throw new Error('Invalid meta transaction data') | ||
@@ -105,7 +108,7 @@ return [res[0], res[1]] | ||
export function packMetaTransactionsData(nonce: ethers.BigNumberish, txs: Transaction[]): string { | ||
return ethers.AbiCoder.defaultAbiCoder().encode(['uint256', MetaTransactionsType], [nonce, sequenceTxAbiEncode(txs)]) | ||
return ethers.utils.defaultAbiCoder.encode(['uint256', MetaTransactionsType], [nonce, sequenceTxAbiEncode(txs)]) | ||
} | ||
export function digestOfTransactions(nonce: ethers.BigNumberish, txs: Transaction[]) { | ||
return ethers.keccak256(packMetaTransactionsData(nonce, txs)) | ||
export function digestOfTransactions(nonce: BigNumberish, txs: Transaction[]) { | ||
return ethers.utils.keccak256(packMetaTransactionsData(nonce, txs)) | ||
} | ||
@@ -115,3 +118,3 @@ | ||
address: string, | ||
chainId: ethers.BigNumberish, | ||
chainId: BigNumberish, | ||
nonce: ethers.BigNumberish, | ||
@@ -123,12 +126,8 @@ txs: Transaction[] | ||
export function subdigestOfGuestModuleTransactions( | ||
guestModule: string, | ||
chainId: ethers.BigNumberish, | ||
txs: Transaction[] | ||
): string { | ||
export function subdigestOfGuestModuleTransactions(guestModule: string, chainId: BigNumberish, txs: Transaction[]): string { | ||
return subdigestOf({ | ||
address: guestModule, | ||
chainId, | ||
digest: ethers.keccak256( | ||
ethers.AbiCoder.defaultAbiCoder().encode(['string', MetaTransactionsType], ['guest:', sequenceTxAbiEncode(txs)]) | ||
digest: ethers.utils.keccak256( | ||
ethers.utils.defaultAbiCoder.encode(['string', MetaTransactionsType], ['guest:', sequenceTxAbiEncode(txs)]) | ||
) | ||
@@ -140,3 +139,3 @@ }) | ||
wallet: string, | ||
txs: ethers.TransactionRequest[] | ||
txs: (Transaction | ethers.providers.TransactionRequest)[] | ||
): { nonce?: ethers.BigNumberish; transaction: Transaction }[] { | ||
@@ -148,15 +147,13 @@ return txs.map(tx => toSequenceTransaction(wallet, tx)) | ||
wallet: string, | ||
tx: ethers.TransactionRequest | ||
tx: ethers.providers.TransactionRequest | ||
): { nonce?: ethers.BigNumberish; transaction: Transaction } { | ||
if (tx.to && tx.to !== ethers.ZeroAddress) { | ||
if (tx.to && tx.to !== ethers.constants.AddressZero) { | ||
return { | ||
nonce: tx.nonce ? BigInt(tx.nonce) : undefined, | ||
nonce: tx.nonce, | ||
transaction: { | ||
delegateCall: false, | ||
revertOnError: false, | ||
gasLimit: BigInt(tx.gasLimit || 0), | ||
// XXX: `tx.to` could also be ethers Addressable type which returns a getAddress promise | ||
// Keeping this as is for now so we don't have to change everything to async | ||
to: tx.to as string, | ||
value: BigInt(tx.value || 0), | ||
gasLimit: tx.gasLimit || 0, | ||
to: tx.to, | ||
value: tx.value || 0, | ||
data: tx.data || '0x' | ||
@@ -166,13 +163,13 @@ } | ||
} else { | ||
const walletInterface = new ethers.Interface(walletContracts.mainModule.abi) | ||
const data = walletInterface.encodeFunctionData(walletInterface.getFunction('createContract')!, [tx.data]) | ||
const walletInterface = new ethers.utils.Interface(walletContracts.mainModule.abi) | ||
const data = walletInterface.encodeFunctionData(walletInterface.getFunction('createContract'), [tx.data]) | ||
return { | ||
nonce: tx.nonce ? BigInt(tx.nonce) : undefined, | ||
nonce: tx.nonce, | ||
transaction: { | ||
delegateCall: false, | ||
revertOnError: false, | ||
gasLimit: tx.gasLimit ? BigInt(tx.gasLimit) : undefined, | ||
gasLimit: tx.gasLimit, | ||
to: wallet, | ||
value: BigInt(tx.value || 0), | ||
value: tx.value || 0, | ||
data: data | ||
@@ -197,6 +194,6 @@ } | ||
revertOnError: t.revertOnError === true, | ||
gasLimit: t.gasLimit !== undefined ? t.gasLimit : 0n, | ||
target: t.to ?? ethers.ZeroAddress, | ||
value: t.value !== undefined ? t.value : 0n, | ||
data: t.data !== undefined ? t.data : '0x' | ||
gasLimit: t.gasLimit !== undefined ? t.gasLimit : ethers.constants.Zero, | ||
target: t.to ?? ethers.constants.AddressZero, | ||
value: t.value !== undefined ? t.value : ethers.constants.Zero, | ||
data: t.data !== undefined ? t.data : [] | ||
})) | ||
@@ -216,24 +213,24 @@ } | ||
// export function appendNonce(txs: Transaction[], nonce: ethers.BigNumberish): Transaction[] { | ||
// export function appendNonce(txs: Transaction[], nonce: BigNumberish): Transaction[] { | ||
// return txs.map((t: Transaction) => ({ ...t, nonce })) | ||
// } | ||
export function encodeNonce(space: ethers.BigNumberish, nonce: ethers.BigNumberish): bigint { | ||
const bspace = BigInt(space) | ||
const bnonce = BigInt(nonce) | ||
export function encodeNonce(space: BigNumberish, nonce: BigNumberish): ethers.BigNumber { | ||
const bspace = ethers.BigNumber.from(space) | ||
const bnonce = ethers.BigNumber.from(nonce) | ||
const shl = 2n ** 96n | ||
const shl = ethers.constants.Two.pow(ethers.BigNumber.from(96)) | ||
if (bnonce / shl !== 0n) { | ||
if (!bnonce.div(shl).eq(ethers.constants.Zero)) { | ||
throw new Error('Space already encoded') | ||
} | ||
return bnonce + bspace * shl | ||
return bnonce.add(bspace.mul(shl)) | ||
} | ||
export function decodeNonce(nonce: ethers.BigNumberish): [bigint, bigint] { | ||
const bnonce = BigInt(nonce) | ||
const shr = 2n ** 96n | ||
export function decodeNonce(nonce: BigNumberish): [ethers.BigNumber, ethers.BigNumber] { | ||
const bnonce = ethers.BigNumber.from(nonce) | ||
const shr = ethers.constants.Two.pow(ethers.BigNumber.from(96)) | ||
return [bnonce / shr, bnonce % shr] | ||
return [bnonce.div(shr), bnonce.mod(shr)] | ||
} | ||
@@ -276,5 +273,5 @@ | ||
export function encodeBundleExecData(bundle: TransactionBundle): string { | ||
const walletInterface = new ethers.Interface(walletContracts.mainModule.abi) | ||
const walletInterface = new ethers.utils.Interface(walletContracts.mainModule.abi) | ||
return walletInterface.encodeFunctionData( | ||
walletInterface.getFunction('execute')!, | ||
walletInterface.getFunction('execute'), | ||
isSignedTransactionBundle(bundle) | ||
@@ -291,3 +288,3 @@ ? [ | ||
0, | ||
new Uint8Array([]) | ||
[] | ||
] | ||
@@ -312,11 +309,11 @@ ) | ||
const walletInterface = new ethers.Interface(walletContracts.mainModule.abi) | ||
const walletInterface = new ethers.utils.Interface(walletContracts.mainModule.abi) | ||
for (const tx of transactions) { | ||
const txData = ethers.getBytes(tx.data || '0x') | ||
const txData = ethers.utils.arrayify(tx.data || '0x') | ||
if (tx.to === wallet && ethers.hexlify(txData.slice(0, 4)) === selfExecuteSelector) { | ||
if (tx.to === wallet && ethers.utils.hexlify(txData.slice(0, 4)) === selfExecuteSelector) { | ||
// Decode as selfExecute call | ||
const data = txData.slice(4) | ||
const decoded = ethers.AbiCoder.defaultAbiCoder().decode([selfExecuteAbi], data)[0] | ||
const decoded = ethers.utils.defaultAbiCoder.decode([selfExecuteAbi], data)[0] | ||
unwound.push( | ||
@@ -330,6 +327,6 @@ ...unwind( | ||
try { | ||
const innerTransactions = walletInterface.decodeFunctionData('execute', txData)[0] as ethers.Result | ||
const innerTransactions = walletInterface.decodeFunctionData('execute', txData)[0] | ||
const unwoundTransactions = unwind( | ||
wallet, | ||
innerTransactions.map((tx: ethers.Result) => ({ ...tx.toObject(), to: tx.target })) | ||
innerTransactions.map((tx: TransactionEncoded) => ({ ...tx, to: tx.target })) | ||
) | ||
@@ -336,0 +333,0 @@ unwound.push(...unwoundTransactions) |
@@ -33,3 +33,3 @@ import { ethers } from 'ethers' | ||
signature: ethers.BytesLike, | ||
provider: ethers.Provider | ||
provider: ethers.providers.Provider | ||
): Promise<boolean> { | ||
@@ -36,0 +36,0 @@ const contract = new ethers.Contract(address, EIP1271_ABI, provider) |
@@ -183,19 +183,16 @@ import { ethers } from 'ethers' | ||
export async function validateEIP6492Offchain( | ||
provider: ethers.Provider, | ||
provider: ethers.providers.Provider, | ||
signer: string, | ||
hash: ethers.BytesLike, | ||
signature: ethers.BytesLike | ||
hash: ethers.utils.BytesLike, | ||
signature: ethers.utils.BytesLike | ||
): Promise<boolean> { | ||
try { | ||
const result = await provider.call({ | ||
data: ethers.concat([ | ||
return ( | ||
'0x01' === | ||
(await provider.call({ | ||
data: ethers.utils.concat([ | ||
EIP_6492_OFFCHAIN_DEPLOY_CODE, | ||
new ethers.AbiCoder().encode(['address', 'bytes32', 'bytes'], [signer, hash, signature]) | ||
new ethers.utils.AbiCoder().encode(['address', 'bytes32', 'bytes'], [signer, hash, signature]) | ||
]) | ||
}) | ||
return result === '0x01' | ||
} catch (err) { | ||
return false | ||
} | ||
})) | ||
) | ||
} |
@@ -9,4 +9,2 @@ export * as v1 from './v1' | ||
export { VERSION } from './version' | ||
export const allVersions = [v1, v2] |
@@ -28,6 +28,6 @@ import { ethers } from 'ethers' | ||
(imageHash, signer) => | ||
ethers.keccak256( | ||
ethers.AbiCoder.defaultAbiCoder().encode(['bytes32', 'uint8', 'address'], [imageHash, signer.weight, signer.address]) | ||
ethers.utils.keccak256( | ||
ethers.utils.defaultAbiCoder.encode(['bytes32', 'uint8', 'address'], [imageHash, signer.weight, signer.address]) | ||
), | ||
ethers.solidityPacked(['uint256'], [config.threshold]) | ||
ethers.utils.solidityPack(['uint256'], [config.threshold]) | ||
) | ||
@@ -46,12 +46,12 @@ }, | ||
checkpointOf: (_config: WalletConfig): bigint => { | ||
return 0n | ||
checkpointOf: (_config: WalletConfig): ethers.BigNumber => { | ||
return ethers.BigNumber.from(0) | ||
}, | ||
signersOf: (config: WalletConfig): { address: string; weight: number }[] => { | ||
return config.signers.map(s => ({ address: s.address, weight: Number(BigInt(s.weight)) })) | ||
return config.signers.map(s => ({ address: s.address, weight: ethers.BigNumber.from(s.weight).toNumber() })) | ||
}, | ||
fromSimple: (config: SimpleConfig): WalletConfig => { | ||
if (BigInt(config.checkpoint) !== 0n) { | ||
if (!ethers.constants.Zero.eq(config.checkpoint)) { | ||
throw new Error('v1 wallet config does not support checkpoint') | ||
@@ -80,3 +80,3 @@ } | ||
): commons.transaction.TransactionBundle => { | ||
const module = new ethers.Interface([...walletContracts.mainModule.abi, ...walletContracts.mainModuleUpgradable.abi]) | ||
const module = new ethers.utils.Interface([...walletContracts.mainModule.abi, ...walletContracts.mainModuleUpgradable.abi]) | ||
@@ -88,3 +88,3 @@ const transactions: commons.transaction.Transaction[] = [] | ||
to: wallet, | ||
data: module.encodeFunctionData(module.getFunction('updateImplementation')!, [context.mainModuleUpgradable]), | ||
data: module.encodeFunctionData(module.getFunction('updateImplementation'), [context.mainModuleUpgradable]), | ||
gasLimit: 0, | ||
@@ -99,3 +99,3 @@ delegateCall: false, | ||
to: wallet, | ||
data: module.encodeFunctionData(module.getFunction('updateImageHash')!, [ConfigCoder.imageHashOf(config)]), | ||
data: module.encodeFunctionData(module.getFunction('updateImageHash'), [ConfigCoder.imageHashOf(config)]), | ||
gasLimit: 0, | ||
@@ -124,3 +124,3 @@ delegateCall: false, | ||
return { | ||
weight: BigInt(signer.weight).toString(), | ||
weight: ethers.BigNumber.from(signer.weight).toString(), | ||
address: signer.address | ||
@@ -132,3 +132,3 @@ } | ||
version: config.version, | ||
threshold: BigInt(config.threshold).toString(), | ||
threshold: ethers.BigNumber.from(config.threshold).toString(), | ||
signers: plainMembers | ||
@@ -143,3 +143,3 @@ }) | ||
return { | ||
weight: BigInt(signer.weight), | ||
weight: ethers.BigNumber.from(signer.weight), | ||
address: signer.address | ||
@@ -151,3 +151,3 @@ } | ||
version: parsed.version, | ||
threshold: BigInt(parsed.threshold), | ||
threshold: ethers.BigNumber.from(parsed.threshold), | ||
signers | ||
@@ -168,3 +168,3 @@ } | ||
if (action.checkpoint && BigInt(action.checkpoint) !== 0n) { | ||
if (action.checkpoint && !ethers.constants.Zero.eq(action.checkpoint)) { | ||
throw new Error('v1 wallet config does not support checkpoint') | ||
@@ -210,3 +210,3 @@ } | ||
if (weight >= BigInt(config.threshold)) { | ||
if (weight.gte(config.threshold)) { | ||
return encoded | ||
@@ -218,3 +218,3 @@ } | ||
for (const { address } of signers.sort(({ weight: a }, { weight: b }) => Number(BigInt(a) - BigInt(b)))) { | ||
for (const { address } of signers.sort(({ weight: a }, { weight: b }) => ethers.BigNumber.from(a).sub(b).toNumber())) { | ||
const signature = | ||
@@ -226,3 +226,3 @@ '0x4e82f02f388a12b5f9d29eaf2452dd040c0ee5804b4e504b4dd64e396c6c781f2c7624195acba242dd825bfd25a290912e3c230841fd55c9a734c4de8d9899451b02' | ||
if (weight >= BigInt(config.threshold)) { | ||
if (weight.gte(config.threshold)) { | ||
return encoded | ||
@@ -229,0 +229,0 @@ } |
import { WalletContext } from '../commons/context' | ||
export * as config from './config' | ||
export * as context from './context' | ||
export * as signature from './signature' | ||
@@ -6,0 +5,0 @@ |
@@ -46,3 +46,3 @@ import { ethers } from 'ethers' | ||
export function decodeSignature(signature: ethers.BytesLike): UnrecoveredSignature { | ||
const bytes = ethers.getBytes(signature) | ||
const bytes = ethers.utils.arrayify(signature) | ||
@@ -61,3 +61,3 @@ const threshold = (bytes[0] << 8) | bytes[1] | ||
weight, | ||
signature: ethers.hexlify(bytes.slice(i, i + 66)), | ||
signature: ethers.utils.hexlify(bytes.slice(i, i + 66)), | ||
isDynamic: false | ||
@@ -71,3 +71,3 @@ }) | ||
weight, | ||
address: ethers.getAddress(ethers.hexlify(bytes.slice(i, i + 20))) | ||
address: ethers.utils.getAddress(ethers.utils.hexlify(bytes.slice(i, i + 20))) | ||
}) | ||
@@ -78,3 +78,3 @@ i += 20 | ||
case SignaturePartType.DynamicSignature: | ||
const address = ethers.getAddress(ethers.hexlify(bytes.slice(i, i + 20))) | ||
const address = ethers.utils.getAddress(ethers.utils.hexlify(bytes.slice(i, i + 20))) | ||
i += 20 | ||
@@ -88,3 +88,3 @@ | ||
weight, | ||
signature: ethers.hexlify(bytes.slice(i, i + size)), | ||
signature: ethers.utils.hexlify(bytes.slice(i, i + size)), | ||
address, | ||
@@ -105,5 +105,3 @@ isDynamic: true | ||
export function encodeSignature(signature: Signature | UnrecoveredSignature | ethers.BytesLike): string { | ||
if (ethers.isBytesLike(signature)) { | ||
return ethers.hexlify(signature) | ||
} | ||
if (ethers.utils.isBytesLike(signature)) return ethers.utils.hexlify(signature) | ||
@@ -114,8 +112,8 @@ const { signers, threshold } = isUnrecoveredSignature(signature) ? signature : signature.config | ||
if (isAddressMember(s)) { | ||
return ethers.solidityPacked(['uint8', 'uint8', 'address'], [SignaturePartType.Address, s.weight, s.address]) | ||
return ethers.utils.solidityPack(['uint8', 'uint8', 'address'], [SignaturePartType.Address, s.weight, s.address]) | ||
} | ||
if (s.isDynamic) { | ||
const bytes = ethers.getBytes(s.signature) | ||
return ethers.solidityPacked( | ||
const bytes = ethers.utils.arrayify(s.signature) | ||
return ethers.utils.solidityPack( | ||
['uint8', 'uint8', 'address', 'uint16', 'bytes'], | ||
@@ -126,6 +124,6 @@ [SignaturePartType.DynamicSignature, s.weight, s.address, bytes.length, bytes] | ||
return ethers.solidityPacked(['uint8', 'uint8', 'bytes'], [SignaturePartType.EOASignature, s.weight, s.signature]) | ||
return ethers.utils.solidityPack(['uint8', 'uint8', 'bytes'], [SignaturePartType.EOASignature, s.weight, s.signature]) | ||
}) | ||
return ethers.solidityPacked(['uint16', ...new Array(encodedSigners.length).fill('bytes')], [threshold, ...encodedSigners]) | ||
return ethers.utils.solidityPack(['uint16', ...new Array(encodedSigners.length).fill('bytes')], [threshold, ...encodedSigners]) | ||
} | ||
@@ -136,3 +134,3 @@ | ||
payload: base.SignedPayload, | ||
provider: ethers.Provider | ||
provider: ethers.providers.Provider | ||
): Promise<Signature> { | ||
@@ -177,3 +175,3 @@ const subdigest = base.subdigestOf(payload) | ||
_: ethers.BigNumberish | ||
): { encoded: string; weight: bigint } { | ||
): { encoded: string; weight: ethers.BigNumber } { | ||
if (subdigests.length !== 0) { | ||
@@ -183,3 +181,3 @@ throw new Error('Explicit subdigests not supported on v1') | ||
let weight = 0n | ||
let weight = ethers.BigNumber.from(0) | ||
const parts = config.signers.map(s => { | ||
@@ -191,5 +189,5 @@ if (!signatures.has(s.address)) { | ||
const signature = signatures.get(s.address)! | ||
const bytes = ethers.getBytes(signature.signature) | ||
const bytes = ethers.utils.arrayify(signature.signature) | ||
weight = weight + BigInt(s.weight) | ||
weight = weight.add(s.weight) | ||
@@ -231,3 +229,3 @@ if (signature.isDynamic || bytes.length !== 66) { | ||
recover: (data: UnrecoveredSignature, payload: base.SignedPayload, provider: ethers.Provider): Promise<Signature> => { | ||
recover: (data: UnrecoveredSignature, payload: base.SignedPayload, provider: ethers.providers.Provider): Promise<Signature> => { | ||
return recoverSignature(data, payload, provider) | ||
@@ -243,3 +241,3 @@ }, | ||
encoded: string | ||
weight: bigint | ||
weight: ethers.BigNumber | ||
} => { | ||
@@ -251,3 +249,3 @@ return encodeSigners(config, signatures, subdigests, chainId) | ||
const { weight } = SignatureCoder.encodeSigners(config, signatures, [], 0) | ||
return weight >= BigInt(config.threshold) | ||
return weight.gte(config.threshold) | ||
}, | ||
@@ -254,0 +252,0 @@ |
@@ -7,14 +7,14 @@ import { ethers } from 'ethers' | ||
export function hashSetImageHash(imageHash: string): string { | ||
return ethers.keccak256(messageSetImageHash(imageHash)) | ||
return ethers.utils.keccak256(messageSetImageHash(imageHash)) | ||
} | ||
export function messageSetImageHash(imageHash: string) { | ||
return ethers.solidityPacked(['bytes32', 'bytes32'], [SetImageHashPrefix, imageHash]) | ||
return ethers.utils.solidityPack(['bytes32', 'bytes32'], [SetImageHashPrefix, imageHash]) | ||
} | ||
export function decodeMessageSetImageHash(message: ethers.BytesLike): string | undefined { | ||
const arr = ethers.getBytes(message) | ||
const arr = ethers.utils.arrayify(message) | ||
if (arr.length !== 64) return undefined | ||
if (ethers.hexlify(arr.slice(0, 32)) !== SetImageHashPrefix) return undefined | ||
return ethers.hexlify(arr.slice(32, 64)) | ||
if (ethers.utils.hexlify(arr.slice(0, 32)) !== SetImageHashPrefix) return undefined | ||
return ethers.utils.hexlify(arr.slice(32, 64)) | ||
} | ||
@@ -21,0 +21,0 @@ |
@@ -54,4 +54,4 @@ import { ethers } from 'ethers' | ||
return JSON.stringify({ | ||
weight: BigInt(tree.weight).toString(), | ||
threshold: BigInt(tree.threshold).toString(), | ||
weight: ethers.BigNumber.from(tree.weight).toString(), | ||
threshold: ethers.BigNumber.from(tree.threshold).toString(), | ||
tree: topologyToJSON(tree.tree) | ||
@@ -64,3 +64,3 @@ }) | ||
address: tree.address, | ||
weight: BigInt(tree.weight).toString() | ||
weight: ethers.BigNumber.from(tree.weight).toString() | ||
}) | ||
@@ -84,4 +84,4 @@ } | ||
return { | ||
weight: BigInt(parsed.weight), | ||
threshold: BigInt(parsed.threshold), | ||
weight: ethers.BigNumber.from(parsed.weight), | ||
threshold: ethers.BigNumber.from(parsed.threshold), | ||
tree: topologyFromJSON(parsed.tree) | ||
@@ -94,3 +94,3 @@ } | ||
address: parsed.address, | ||
weight: BigInt(parsed.weight) | ||
weight: ethers.BigNumber.from(parsed.weight) | ||
} | ||
@@ -138,7 +138,7 @@ } | ||
export function encodeSignerLeaf(leaf: SignerLeaf): string { | ||
return ethers.solidityPacked(['uint96', 'address'], [leaf.weight, leaf.address]) | ||
return ethers.utils.solidityPack(['uint96', 'address'], [leaf.weight, leaf.address]) | ||
} | ||
export function decodeSignerLeaf(encoded: string): SignerLeaf { | ||
const bytes = ethers.getBytes(encoded) | ||
const bytes = ethers.utils.arrayify(encoded) | ||
@@ -149,4 +149,4 @@ if (bytes.length !== 32) { | ||
const weight = BigInt(ethers.hexlify(bytes.slice(0, 12))) | ||
const address = ethers.getAddress(ethers.hexlify(bytes.slice(12))) | ||
const weight = ethers.BigNumber.from(bytes.slice(0, 12)) | ||
const address = ethers.utils.getAddress(ethers.utils.hexlify(bytes.slice(12))) | ||
@@ -157,3 +157,3 @@ return { weight, address } | ||
export function isEncodedSignerLeaf(encoded: string): boolean { | ||
const bytes = ethers.getBytes(encoded) | ||
const bytes = ethers.utils.arrayify(encoded) | ||
@@ -174,3 +174,3 @@ if (bytes.length !== 32) { | ||
if (isSubdigestLeaf(node)) { | ||
return ethers.solidityPackedKeccak256(['string', 'bytes32'], ['Sequence static digest:\n', node.subdigest]) | ||
return ethers.utils.solidityKeccak256(['string', 'bytes32'], ['Sequence static digest:\n', node.subdigest]) | ||
} | ||
@@ -180,3 +180,3 @@ | ||
const nested = hashNode(node.tree) | ||
return ethers.solidityPackedKeccak256( | ||
return ethers.utils.solidityKeccak256( | ||
['string', 'bytes32', 'uint256', 'uint256'], | ||
@@ -191,3 +191,3 @@ ['Sequence nested config:\n', nested, node.threshold, node.weight] | ||
return ethers.solidityPackedKeccak256(['bytes32', 'bytes32'], [hashNode(node.left), hashNode(node.right)]) | ||
return ethers.utils.solidityKeccak256(['bytes32', 'bytes32'], [hashNode(node.left), hashNode(node.right)]) | ||
} | ||
@@ -230,5 +230,5 @@ | ||
export function imageHash(config: WalletConfig): string { | ||
return ethers.solidityPackedKeccak256( | ||
return ethers.utils.solidityKeccak256( | ||
['bytes32', 'uint256'], | ||
[ethers.solidityPackedKeccak256(['bytes32', 'uint256'], [hashNode(config.tree), config.threshold]), config.checkpoint] | ||
[ethers.utils.solidityKeccak256(['bytes32', 'uint256'], [hashNode(config.tree), config.threshold]), config.checkpoint] | ||
) | ||
@@ -413,3 +413,3 @@ } | ||
} else if (isSignerLeaf(node)) { | ||
signers.add({ address: node.address, weight: Number(BigInt(node.weight)) }) | ||
signers.add({ address: node.address, weight: ethers.BigNumber.from(node.weight).toNumber() }) | ||
} | ||
@@ -442,4 +442,4 @@ } | ||
checkpointOf: (config: WalletConfig): bigint => { | ||
return BigInt(config.checkpoint) | ||
checkpointOf: (config: WalletConfig): ethers.BigNumber => { | ||
return ethers.BigNumber.from(config.checkpoint) | ||
}, | ||
@@ -479,3 +479,3 @@ | ||
): commons.transaction.TransactionBundle => { | ||
const module = new ethers.Interface(walletContracts.mainModuleUpgradable.abi) | ||
const module = new ethers.utils.Interface(walletContracts.mainModuleUpgradable.abi) | ||
@@ -487,3 +487,3 @@ return { | ||
to: wallet, | ||
data: module.encodeFunctionData(module.getFunction('updateImageHash')!, [ConfigCoder.imageHashOf(config)]), | ||
data: module.encodeFunctionData(module.getFunction('updateImageHash'), [ConfigCoder.imageHashOf(config)]), | ||
gasLimit: 0, | ||
@@ -502,3 +502,3 @@ delegateCall: false, | ||
} { | ||
const module = new ethers.Interface(walletContracts.mainModuleUpgradable.abi) | ||
const module = new ethers.utils.Interface(walletContracts.mainModuleUpgradable.abi) | ||
@@ -514,3 +514,3 @@ if (tx.transactions.length !== 1) { | ||
const decoded = module.decodeFunctionData(module.getFunction('updateImageHash')!, data) | ||
const decoded = module.decodeFunctionData(module.getFunction('updateImageHash'), data) | ||
if (!decoded) { | ||
@@ -532,7 +532,7 @@ throw new Error('Invalid transaction bundle, expected valid data') | ||
if (BigInt(tx.transactions[0]?.value ?? 0) !== 0n) { | ||
if (!ethers.constants.Zero.eq(tx.transactions[0]?.value ?? 0)) { | ||
throw new Error('Invalid transaction bundle, expected value to be 0') | ||
} | ||
if (BigInt(tx.transactions[0]?.gasLimit ?? 0) !== 0n) { | ||
if (!ethers.constants.Zero.eq(tx.transactions[0]?.gasLimit ?? 0)) { | ||
throw new Error('Invalid transaction bundle, expected value to be 0') | ||
@@ -552,4 +552,4 @@ } | ||
version: config.version, | ||
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: topologyToJSON(config.tree) | ||
@@ -563,4 +563,4 @@ }) | ||
version: config.version, | ||
threshold: BigInt(config.threshold), | ||
checkpoint: BigInt(config.checkpoint), | ||
threshold: ethers.BigNumber.from(config.threshold), | ||
checkpoint: ethers.BigNumber.from(config.checkpoint), | ||
tree: topologyFromJSON(config.tree) | ||
@@ -619,3 +619,3 @@ } | ||
if (weight >= BigInt(config.threshold)) { | ||
if (weight.gte(config.threshold)) { | ||
return encoded | ||
@@ -634,3 +634,3 @@ } | ||
if (weight >= BigInt(config.threshold)) { | ||
if (weight.gte(config.threshold)) { | ||
return encoded | ||
@@ -637,0 +637,0 @@ } |
@@ -5,3 +5,2 @@ import { WalletContext as BaseContext } from '../commons/context' | ||
version: 2 | ||
universalSigValidator: string | ||
} |
@@ -1,4 +0,3 @@ | ||
import { ethers } from 'ethers' | ||
import { MAX_UINT_256 } from '@0xsequence/utils' | ||
import { isValidSignature, recoverSigner } from '../commons/signer' | ||
import { BigNumberish, ethers } from 'ethers' | ||
import { isValidSignature, recoverSigner, tryRecoverSigner } from '../commons/signer' | ||
import { | ||
@@ -54,4 +53,4 @@ hashNode, | ||
tree: UnrecoveredTopology | ||
weight: ethers.BigNumberish | ||
threshold: ethers.BigNumberish | ||
weight: BigNumberish | ||
threshold: BigNumberish | ||
} | ||
@@ -85,3 +84,3 @@ | ||
export function decodeSignatureTree(body: ethers.BytesLike): UnrecoveredTopology { | ||
let arr = ethers.getBytes(body) | ||
let arr = ethers.utils.arrayify(body) | ||
@@ -118,3 +117,3 @@ let pointer: undefined | (Omit<UnrecoveredNode, 'right'> & Pick<Partial<UnrecoveredNode>, 'right'>) | ||
const weight = arr[0] | ||
const signature = ethers.hexlify(arr.slice(1, SignaturePartTypeLength + 1)) | ||
const signature = ethers.utils.hexlify(arr.slice(1, SignaturePartTypeLength + 1)) | ||
@@ -134,3 +133,3 @@ pointer = append(pointer, { | ||
const weight = arr[0] | ||
const address = ethers.getAddress(ethers.hexlify(arr.slice(1, 21))) | ||
const address = ethers.utils.getAddress(ethers.utils.hexlify(arr.slice(1, 21))) | ||
@@ -148,5 +147,5 @@ pointer = append(pointer, { | ||
const weight = arr[0] | ||
const address = ethers.getAddress(ethers.hexlify(arr.slice(1, 21))) | ||
const address = ethers.utils.getAddress(ethers.utils.hexlify(arr.slice(1, 21))) | ||
const size = (arr[21] << 16) | (arr[22] << 8) | arr[23] | ||
const signature = ethers.hexlify(arr.slice(24, 24 + size)) | ||
const signature = ethers.utils.hexlify(arr.slice(24, 24 + size)) | ||
@@ -166,3 +165,3 @@ pointer = append(pointer, { | ||
{ | ||
const nodeHash = ethers.hexlify(arr.slice(0, 32)) | ||
const nodeHash = ethers.utils.hexlify(arr.slice(0, 32)) | ||
@@ -186,3 +185,3 @@ pointer = append(pointer, { nodeHash }) | ||
{ | ||
const subdigest = ethers.hexlify(arr.slice(0, 32)) | ||
const subdigest = ethers.utils.hexlify(arr.slice(0, 32)) | ||
@@ -212,3 +211,3 @@ pointer = append(pointer, { subdigest }) | ||
default: | ||
throw new Error(`Unknown signature part type: ${type}: ${ethers.hexlify(arr)}`) | ||
throw new Error(`Unknown signature part type: ${type}: ${ethers.utils.hexlify(arr)}`) | ||
} | ||
@@ -237,3 +236,3 @@ } | ||
subdigest: string, | ||
provider: ethers.Provider | ||
provider: ethers.providers.Provider | ||
): Promise<Topology> { | ||
@@ -291,14 +290,14 @@ if (isUnrecoveredNode(unrecovered)) { | ||
concat: (a: ethers.BytesLike, b: ethers.BytesLike) => { | ||
return ethers.solidityPacked(['bytes', 'bytes'], [a, b]) | ||
return ethers.utils.solidityPack(['bytes', 'bytes'], [a, b]) | ||
}, | ||
node: (nodeHash: ethers.BytesLike): string => { | ||
return ethers.solidityPacked(['uint8', 'bytes32'], [SignaturePartType.Node, nodeHash]) | ||
return ethers.utils.solidityPack(['uint8', 'bytes32'], [SignaturePartType.Node, nodeHash]) | ||
}, | ||
branch: (tree: ethers.BytesLike): string => { | ||
const arr = ethers.getBytes(tree) | ||
return ethers.solidityPacked(['uint8', 'uint24', 'bytes'], [SignaturePartType.Branch, arr.length, arr]) | ||
const arr = ethers.utils.arrayify(tree) | ||
return ethers.utils.solidityPack(['uint8', 'uint24', 'bytes'], [SignaturePartType.Branch, arr.length, arr]) | ||
}, | ||
nested: (weight: ethers.BigNumberish, threshold: ethers.BigNumberish, tree: ethers.BytesLike): string => { | ||
const arr = ethers.getBytes(tree) | ||
return ethers.solidityPacked( | ||
const arr = ethers.utils.arrayify(tree) | ||
return ethers.utils.solidityPack( | ||
['uint8', 'uint8', 'uint16', 'uint24', 'bytes'], | ||
@@ -309,10 +308,10 @@ [SignaturePartType.Nested, weight, threshold, arr.length, arr] | ||
subdigest: (subdigest: ethers.BytesLike): string => { | ||
return ethers.solidityPacked(['uint8', 'bytes32'], [SignaturePartType.Subdigest, subdigest]) | ||
return ethers.utils.solidityPack(['uint8', 'bytes32'], [SignaturePartType.Subdigest, subdigest]) | ||
}, | ||
signature: (weight: ethers.BigNumberish, signature: ethers.BytesLike): string => { | ||
return ethers.solidityPacked(['uint8', 'uint8', 'bytes'], [SignaturePartType.Signature, weight, signature]) | ||
return ethers.utils.solidityPack(['uint8', 'uint8', 'bytes'], [SignaturePartType.Signature, weight, signature]) | ||
}, | ||
dynamicSignature: (weight: ethers.BigNumberish, address: ethers.BytesLike, signature: ethers.BytesLike): string => { | ||
const arrSignature = ethers.getBytes(signature) | ||
return ethers.solidityPacked( | ||
const arrSignature = ethers.utils.arrayify(signature) | ||
return ethers.utils.solidityPack( | ||
['uint8', 'uint8', 'address', 'uint24', 'bytes'], | ||
@@ -323,3 +322,3 @@ [SignaturePartType.DynamicSignature, weight, address, arrSignature.length, arrSignature] | ||
address: (weight: ethers.BigNumberish, address: ethers.BytesLike): string => { | ||
return ethers.solidityPacked(['uint8', 'uint8', 'address'], [SignaturePartType.Address, weight, address]) | ||
return ethers.utils.solidityPack(['uint8', 'uint8', 'address'], [SignaturePartType.Address, weight, address]) | ||
} | ||
@@ -341,9 +340,9 @@ } | ||
encoded: string | ||
weight: bigint | ||
weight: ethers.BigNumber | ||
} { | ||
const tree = encodeTree(config.tree, parts, subdigests, options) | ||
if (BigInt(chainId) === 0n) { | ||
if (ethers.BigNumber.from(chainId).isZero()) { | ||
return { | ||
encoded: ethers.solidityPacked( | ||
encoded: ethers.utils.solidityPack( | ||
['uint8', 'uint16', 'uint32', 'bytes'], | ||
@@ -356,5 +355,5 @@ [SignatureType.NoChainIdDynamic, config.threshold, config.checkpoint, tree.encoded] | ||
if (BigInt(config.threshold) > 255n) { | ||
if (ethers.BigNumber.from(config.threshold).gt(255)) { | ||
return { | ||
encoded: ethers.solidityPacked( | ||
encoded: ethers.utils.solidityPack( | ||
['uint8', 'uint16', 'uint32', 'bytes'], | ||
@@ -368,3 +367,3 @@ [SignatureType.Dynamic, config.threshold, config.checkpoint, tree.encoded] | ||
return { | ||
encoded: ethers.solidityPacked( | ||
encoded: ethers.utils.solidityPack( | ||
['uint8', 'uint8', 'uint32', 'bytes'], | ||
@@ -384,3 +383,3 @@ [SignatureType.Legacy, config.threshold, config.checkpoint, tree.encoded] | ||
encoded: string | ||
weight: bigint | ||
weight: ethers.BigNumber | ||
} { | ||
@@ -396,3 +395,3 @@ const trim = !options.disableTrim | ||
if (trim && left.weight === 0n && right.weight === 0n && !isLeftSigner && !isRightSigner) { | ||
if (trim && left.weight.eq(0) && right.weight.eq(0) && !isLeftSigner && !isRightSigner) { | ||
return { | ||
@@ -402,7 +401,7 @@ // We don't need to include anything for this node | ||
encoded: partEncoder.node(hashNode(topology)), | ||
weight: 0n | ||
weight: ethers.constants.Zero | ||
} | ||
} | ||
if (trim && right.weight === 0n && !isRightSigner) { | ||
if (trim && right.weight.eq(0) && !isRightSigner) { | ||
return { | ||
@@ -416,3 +415,3 @@ // The right node doesn't have any weight | ||
if (trim && left.weight === 0n && !isLeftSigner) { | ||
if (trim && left.weight.eq(0) && !isLeftSigner) { | ||
return { | ||
@@ -431,3 +430,3 @@ // The left node doesn't have any weight | ||
encoded: partEncoder.concat(left.encoded, partEncoder.branch(right.encoded)), | ||
weight: left.weight + right.weight | ||
weight: left.weight.add(right.weight) | ||
} | ||
@@ -439,6 +438,6 @@ } | ||
if (trim && tree.weight === 0n) { | ||
if (trim && tree.weight.eq(0)) { | ||
return { | ||
encoded: partEncoder.node(hashNode(topology)), | ||
weight: 0n | ||
weight: ethers.constants.Zero | ||
} | ||
@@ -456,3 +455,3 @@ } | ||
encoded: partEncoder.node(hashNode(topology)), | ||
weight: 0n | ||
weight: ethers.constants.Zero | ||
} | ||
@@ -465,3 +464,3 @@ } | ||
encoded: partEncoder.subdigest(topology.subdigest), | ||
weight: include ? MAX_UINT_256 : 0n | ||
weight: include ? ethers.constants.MaxUint256 : ethers.constants.Zero | ||
} | ||
@@ -480,3 +479,3 @@ } | ||
encoded: partEncoder.dynamicSignature(topology.weight, topology.address, signature), | ||
weight: BigInt(topology.weight) | ||
weight: ethers.BigNumber.from(topology.weight) | ||
} | ||
@@ -486,3 +485,3 @@ } else { | ||
encoded: partEncoder.signature(topology.weight, signature), | ||
weight: BigInt(topology.weight) | ||
weight: ethers.BigNumber.from(topology.weight) | ||
} | ||
@@ -493,3 +492,3 @@ } | ||
encoded: partEncoder.address(topology.weight, topology.address), | ||
weight: 0n | ||
weight: ethers.constants.Zero | ||
} | ||
@@ -554,3 +553,3 @@ } | ||
export function decodeSignature(signature: ethers.BytesLike): UnrecoveredSignature | UnrecoveredChainedSignature { | ||
const bytes = ethers.getBytes(signature) | ||
const bytes = ethers.utils.arrayify(signature) | ||
const type = bytes[0] | ||
@@ -577,3 +576,3 @@ | ||
export function decodeSignatureBody(signature: ethers.BytesLike): UnrecoveredConfig { | ||
const bytes = ethers.getBytes(signature) | ||
const bytes = ethers.utils.arrayify(signature) | ||
@@ -589,3 +588,3 @@ const threshold = (bytes[0] << 8) | bytes[1] | ||
export function decodeChainedSignature(signature: ethers.BytesLike): UnrecoveredChainedSignature { | ||
const arr = ethers.getBytes(signature) | ||
const arr = ethers.utils.arrayify(signature) | ||
const type = arr[0] | ||
@@ -621,5 +620,5 @@ | ||
export function setImageHashStruct(imageHash: string) { | ||
return ethers.solidityPacked( | ||
return ethers.utils.solidityPack( | ||
['bytes32', 'bytes32'], | ||
[ethers.solidityPackedKeccak256(['string'], ['SetImageHash(bytes32 imageHash)']), imageHash] | ||
[ethers.utils.solidityKeccak256(['string'], ['SetImageHash(bytes32 imageHash)']), imageHash] | ||
) | ||
@@ -631,3 +630,3 @@ } | ||
payload: base.SignedPayload | { subdigest: string }, | ||
provider: ethers.Provider | ||
provider: ethers.providers.Provider | ||
): Promise<Signature | ChainedSignature> { | ||
@@ -667,3 +666,3 @@ const signedPayload = (payload as { subdigest: string }).subdigest === undefined ? (payload as base.SignedPayload) : undefined | ||
message: nextMessage, | ||
digest: ethers.keccak256(nextMessage) | ||
digest: ethers.utils.keccak256(nextMessage) | ||
} | ||
@@ -680,7 +679,10 @@ } | ||
const allSignatures = [main, ...(suffix || [])] | ||
const encodedMap = allSignatures.map(s => ethers.getBytes(encodeSignature(s))) | ||
const encodedMap = allSignatures.map(s => ethers.utils.arrayify(encodeSignature(s))) | ||
const body = ethers.solidityPacked(encodedMap.map(() => ['uint24', 'bytes']).flat(), encodedMap.map(s => [s.length, s]).flat()) | ||
const body = ethers.utils.solidityPack( | ||
encodedMap.map(() => ['uint24', 'bytes']).flat(), | ||
encodedMap.map(s => [s.length, s]).flat() | ||
) | ||
return ethers.solidityPacked(['uint8', 'bytes'], [SignatureType.Chained, body]) | ||
return ethers.utils.solidityPack(['uint8', 'bytes'], [SignatureType.Chained, body]) | ||
} | ||
@@ -691,3 +693,3 @@ | ||
): string { | ||
if (ethers.isBytesLike(decoded)) return ethers.hexlify(decoded) | ||
if (ethers.utils.isBytesLike(decoded)) return ethers.utils.hexlify(decoded) | ||
@@ -702,3 +704,3 @@ if (isUnrecoveredChainedSignature(decoded) || isChainedSignature(decoded)) { | ||
case SignatureType.Legacy: | ||
if (BigInt(body.threshold) > 255n) { | ||
if (ethers.BigNumber.from(body.threshold).gt(255)) { | ||
throw new Error(`Legacy signature threshold is too large: ${body.threshold} (max 255)`) | ||
@@ -711,3 +713,3 @@ } | ||
case SignatureType.Dynamic: | ||
return ethers.solidityPacked(['uint8', 'bytes'], [decoded.type, encodeSignatureBody(body)]) | ||
return ethers.utils.solidityPack(['uint8', 'bytes'], [decoded.type, encodeSignatureBody(body)]) | ||
@@ -723,3 +725,3 @@ case SignatureType.Chained: | ||
export function encodeSignatureBody(decoded: WalletConfig | UnrecoveredConfig): string { | ||
return ethers.solidityPacked( | ||
return ethers.utils.solidityPack( | ||
['uint16', 'uint32', 'bytes'], | ||
@@ -732,8 +734,8 @@ [decoded.threshold, decoded.checkpoint, encodeSignatureTree(decoded.tree)] | ||
if (isNode(tree) || isUnrecoveredNode(tree)) { | ||
const encodedRight = ethers.getBytes(encodeSignatureTree(tree.right)) | ||
const encodedLeft = ethers.getBytes(encodeSignatureTree(tree.left)) | ||
const encodedRight = ethers.utils.arrayify(encodeSignatureTree(tree.right)) | ||
const encodedLeft = ethers.utils.arrayify(encodeSignatureTree(tree.left)) | ||
const isBranching = isNode(tree.right) || isUnrecoveredNode(tree.right) | ||
if (isBranching) { | ||
return ethers.solidityPacked( | ||
return ethers.utils.solidityPack( | ||
['bytes', 'uint8', 'uint24', 'bytes'], | ||
@@ -743,3 +745,3 @@ [encodedLeft, SignaturePartType.Branch, encodedRight.length, encodedRight] | ||
} else { | ||
return ethers.solidityPacked(['bytes', 'bytes'], [encodedLeft, encodedRight]) | ||
return ethers.utils.solidityPack(['bytes', 'bytes'], [encodedLeft, encodedRight]) | ||
} | ||
@@ -749,5 +751,5 @@ } | ||
if (isNestedLeaf(tree) || isUnrecoveredNestedLeaf(tree)) { | ||
const nested = ethers.getBytes(encodeSignatureTree(tree.tree)) | ||
const nested = ethers.utils.arrayify(encodeSignatureTree(tree.tree)) | ||
return ethers.solidityPacked( | ||
return ethers.utils.solidityPack( | ||
['uint8', 'uint8', 'uint16', 'uint24', 'bytes'], | ||
@@ -759,7 +761,7 @@ [SignaturePartType.Nested, tree.weight, tree.threshold, nested.length, nested] | ||
if (isUnrecoveredSignatureLeaf(tree) || (isSignerLeaf(tree) && tree.signature !== undefined)) { | ||
const signature = ethers.getBytes(tree.signature!) | ||
const signature = ethers.utils.arrayify(tree.signature!) | ||
if ((tree as { isDynamic?: boolean }).isDynamic || signature.length !== SignaturePartTypeLength) { | ||
if (!tree.address) throw new Error(`Dynamic signature leaf must have address`) | ||
return ethers.solidityPacked( | ||
return ethers.utils.solidityPack( | ||
['uint8', 'uint8', 'address', 'uint24', 'bytes'], | ||
@@ -769,3 +771,3 @@ [SignaturePartType.DynamicSignature, tree.weight, tree.address, signature.length, signature] | ||
} else { | ||
return ethers.solidityPacked(['uint8', 'uint8', 'bytes'], [SignaturePartType.Signature, tree.weight, signature]) | ||
return ethers.utils.solidityPack(['uint8', 'uint8', 'bytes'], [SignaturePartType.Signature, tree.weight, signature]) | ||
} | ||
@@ -775,11 +777,11 @@ } | ||
if (isSignerLeaf(tree)) { | ||
return ethers.solidityPacked(['uint8', 'uint8', 'address'], [SignaturePartType.Address, tree.weight, tree.address]) | ||
return ethers.utils.solidityPack(['uint8', 'uint8', 'address'], [SignaturePartType.Address, tree.weight, tree.address]) | ||
} | ||
if (isNodeLeaf(tree)) { | ||
return ethers.solidityPacked(['uint8', 'bytes32'], [SignaturePartType.Node, tree.nodeHash]) | ||
return ethers.utils.solidityPack(['uint8', 'bytes32'], [SignaturePartType.Node, tree.nodeHash]) | ||
} | ||
if (isSubdigestLeaf(tree)) { | ||
return ethers.solidityPacked(['uint8', 'bytes32'], [SignaturePartType.Subdigest, tree.subdigest]) | ||
return ethers.utils.solidityPack(['uint8', 'bytes32'], [SignaturePartType.Subdigest, tree.subdigest]) | ||
} | ||
@@ -870,3 +872,3 @@ | ||
// and still get the valid node hash (there shouldn't be any signatures to verify) | ||
const recovered = await recoverTopology(tree, ethers.ZeroHash, undefined as any) | ||
const recovered = await recoverTopology(tree, ethers.constants.HashZero, undefined as any) | ||
@@ -901,3 +903,3 @@ return { | ||
// and still get the valid node hash (there shouldn't be any signatures to verify) | ||
const recovered = await recoverTopology(tree, ethers.ZeroHash, undefined as any) | ||
const recovered = await recoverTopology(tree, ethers.constants.HashZero, undefined as any) | ||
@@ -939,3 +941,3 @@ return { | ||
return { | ||
weight: Number(BigInt(tree.weight)), | ||
weight: ethers.BigNumber.from(tree.weight).toNumber(), | ||
trimmed: tree | ||
@@ -976,3 +978,3 @@ } | ||
payload: base.SignedPayload, | ||
provider: ethers.Provider | ||
provider: ethers.providers.Provider | ||
): Promise<Signature> => { | ||
@@ -989,3 +991,3 @@ return recoverSignature(data, payload, provider) | ||
encoded: string | ||
weight: bigint | ||
weight: ethers.BigNumber | ||
} => { | ||
@@ -997,3 +999,3 @@ return encodeSigners(config, signatures, subdigests, chainId) | ||
const { weight } = SignatureCoder.encodeSigners(config, signatures, [], 0) | ||
return weight >= BigInt(config.threshold) | ||
return weight.gte(config.threshold) | ||
}, | ||
@@ -1008,4 +1010,4 @@ | ||
const reversed = suffix.reverse() | ||
const mraw = ethers.isBytesLike(main) ? main : encodeSignature(main) | ||
const sraw = reversed.map(s => (ethers.isBytesLike(s) ? s : encodeSignature(s))) | ||
const mraw = ethers.utils.isBytesLike(main) ? main : encodeSignature(main) | ||
const sraw = reversed.map(s => (ethers.utils.isBytesLike(s) ? s : encodeSignature(s))) | ||
return encodeChain(mraw, sraw) | ||
@@ -1012,0 +1014,0 @@ }, |
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
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
429788
2
47
10386
+ Added@0xsequence/abi@0.0.0-20240704152116(transitive)
- Removed@0xsequence/abi@0.0.0-20240703210534(transitive)
- Removed@0xsequence/utils@0.0.0-20240703210534(transitive)
- Removedjs-base64@3.7.7(transitive)