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

@0xsequence/core

Package Overview
Dependencies
Maintainers
5
Versions
299
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@0xsequence/core - npm Package Compare versions

Comparing version 0.0.0-20230217200148 to 0.0.0-20230301184215

1

dist/declarations/src/commons/config.d.ts

@@ -35,2 +35,3 @@ import { ethers } from 'ethers';

}) => T;
buildStubSignature: (config: T, overrides: Map<string, string>) => string;
update: {

@@ -37,0 +38,0 @@ isKindUsed: boolean;

@@ -22,2 +22,3 @@ import { ethers } from "ethers";

} | undefined;
private isDeployedCache;
constructor(provider: ethers.providers.Provider, contexts?: {

@@ -24,0 +25,0 @@ [key: number]: commons.context.WalletContext;

@@ -10,2 +10,10 @@ import { BigNumberish, BytesLike, ethers } from "ethers";

}
export interface SimulatedTransaction extends Transaction {
succeeded: boolean;
executed: boolean;
gasUsed: number;
gasLimit: number;
result?: string;
reason?: string;
}
export interface TransactionEncoded {

@@ -65,1 +73,4 @@ delegateCall: boolean;

export declare function encodeBundleExecData(bundle: TransactionBundle): string;
export declare const selfExecuteSelector = "0x61c2926c";
export declare const selfExecuteAbi = "tuple(\n bool delegateCall,\n bool revertOnError,\n uint256 gasLimit,\n address target,\n uint256 value,\n bytes data\n)[]";
export declare const unwind: (wallet: string, transactions: Transaction[]) => Transaction[];

4

package.json
{
"name": "@0xsequence/core",
"version": "0.0.0-20230217200148",
"version": "0.0.0-20230301184215",
"description": "core primitives for interacting with the sequence wallet contracts",

@@ -23,3 +23,3 @@ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/core",

"dependencies": {
"@0xsequence/abi": "0.0.0-20230217200148"
"@0xsequence/abi": "0.0.0-20230301184215"
},

@@ -26,0 +26,0 @@ "scripts": {

@@ -42,2 +42,7 @@

buildStubSignature: (
config: T,
overrides: Map<string, string>
) => string
// isValid: (config: T) => boolean

@@ -44,0 +49,0 @@

@@ -26,2 +26,4 @@ import { walletContracts } from "@0xsequence/abi"

export class OnChainReader implements Reader {
// Simple cache to avoid re-fetching the same data
private isDeployedCache: Set<string> = new Set()

@@ -46,4 +48,14 @@ constructor(

async isDeployed(wallet: string): Promise<boolean> {
// This is safe to cache because the wallet cannot be undeployed once deployed
if (this.isDeployedCache.has(wallet)) {
return true
}
const code = await this.provider.getCode(wallet).then((c) => ethers.utils.arrayify(c))
return code.length !== 0
const isDeployed = code.length !== 0
if (isDeployed) {
this.isDeployedCache.add(wallet)
}
return isDeployed
}

@@ -50,0 +62,0 @@

@@ -14,2 +14,11 @@ import { BigNumberish, BytesLike, ethers } from "ethers"

export interface SimulatedTransaction extends Transaction {
succeeded: boolean
executed: boolean
gasUsed: number
gasLimit: number
result?: string
reason?: string
}
export interface TransactionEncoded {

@@ -266,1 +275,43 @@ delegateCall: boolean

}
// TODO: Use Sequence ABI package
export const selfExecuteSelector = '0x61c2926c'
export const selfExecuteAbi = `tuple(
bool delegateCall,
bool revertOnError,
uint256 gasLimit,
address target,
uint256 value,
bytes data
)[]`
// Splits Sequence batch transactions into individual parts
export const unwind = (wallet: string, transactions: Transaction[]): Transaction[] => {
const unwound: Transaction[] = []
const walletInterface = new ethers.utils.Interface(walletContracts.mainModule.abi)
for (const tx of transactions) {
const txData = ethers.utils.arrayify(tx.data || '0x')
if (tx.to === wallet && ethers.utils.hexlify(txData.slice(0, 4)) === selfExecuteSelector) {
// Decode as selfExecute call
const data = txData.slice(4)
const decoded = ethers.utils.defaultAbiCoder.decode([selfExecuteAbi], data)[0]
unwound.push(...decoded.map((d: TransactionEncoded) => ({ ...d, to: d.target })))
} else {
try {
const innerTransactions = walletInterface.decodeFunctionData('execute', txData)[0]
const unwoundTransactions = unwind(
wallet,
innerTransactions.map((tx: TransactionEncoded) => ({ ...tx, to: tx.target }))
)
unwound.push(...unwoundTransactions)
} catch {
unwound.push(tx)
}
}
}
return unwound
}

@@ -5,2 +5,3 @@

import { commons } from '..'
import { encodeSigners } from './signature'

@@ -198,3 +199,35 @@

}
},
buildStubSignature: function (
config: WalletConfig,
overrides: Map<string, string>
) {
const parts = new Map<string, commons.signature.SignaturePart>()
for (const [signer, signature] of overrides.entries()) {
parts.set(signer, { signature, isDynamic: true })
const { encoded, weight } = encodeSigners(config, parts, [], 0)
if (weight.gte(config.threshold)) {
return encoded
}
}
const signers = config.signers
for (const { address } of signers.sort(({ weight: a }, { weight: b }) => ethers.BigNumber.from(a).sub(b).toNumber())) {
const signature = '0x4e82f02f388a12b5f9d29eaf2452dd040c0ee5804b4e504b4dd64e396c6c781f2c7624195acba242dd825bfd25a290912e3c230841fd55c9a734c4de8d9899451b02'
parts.set(address, { signature, isDynamic: false })
const { encoded, weight } = encodeSigners(config, parts, [], 0)
if (weight.gte(config.threshold)) {
return encoded
}
}
return encodeSigners(config, parts, [], 0).encoded
}
}

@@ -5,2 +5,3 @@

import { commons } from ".."
import { encodeSigners } from "./signature"

@@ -597,3 +598,35 @@ //

}
},
buildStubSignature: function (
config: WalletConfig,
overrides: Map<string, string>
) {
const parts = new Map<string, commons.signature.SignaturePart>()
for (const [signer, signature] of overrides.entries()) {
parts.set(signer, { signature, isDynamic: true })
const { encoded, weight } = encodeSigners(config, parts, [], 0)
if (weight.gte(config.threshold)) {
return encoded
}
}
const signers = signersOf(config.tree)
for (const { address } of signers.sort(({ weight: a }, { weight: b }) => a - b)) {
const signature = '0x4e82f02f388a12b5f9d29eaf2452dd040c0ee5804b4e504b4dd64e396c6c781f2c7624195acba242dd825bfd25a290912e3c230841fd55c9a734c4de8d9899451b02'
parts.set(address, { signature, isDynamic: false })
const { encoded, weight } = encodeSigners(config, parts, [], 0)
if (weight.gte(config.threshold)) {
return encoded
}
}
return encodeSigners(config, parts, [], 0).encoded
}
}

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

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc