FRE-600: Fix code review blockers

- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-04-25 00:08:01 -04:00
parent 65b552bb08
commit 7c684a42cc
48450 changed files with 5679671 additions and 383 deletions

View File

@@ -0,0 +1,37 @@
import type { Address } from 'abitype'
import { sign } from '../../accounts/utils/sign.js'
import type { Hex } from '../../types/misc.js'
import { concatHex } from '../../utils/index.js'
import type { ZksyncSmartAccount } from '../types/account.js'
import { toSmartAccount } from './toSmartAccount.js'
export type ToMultisigSmartAccountParameters = {
/** Address of the deployed Account's Contract implementation. */
address: Address
/** Array of Private Keys belonging to the owners. */
privateKeys: readonly Hex[]
}
/**
* Creates a [ZKsync Smart Account](https://docs.zksync.io/build/developer-reference/account-abstraction/building-smart-accounts)
* from a Contract Address and an array of Private Keys belonging to the owners.
*/
export function toMultisigSmartAccount(
parameters: ToMultisigSmartAccountParameters,
): ZksyncSmartAccount {
const { address, privateKeys } = parameters
return toSmartAccount({
address,
async sign({ hash }) {
return concatHex(
await Promise.all(
privateKeys.map((privateKey) =>
sign({ hash, privateKey, to: 'hex' }),
),
),
)
},
})
}

View File

@@ -0,0 +1,30 @@
import type { Address } from 'abitype'
import { sign } from '../../accounts/utils/sign.js'
import type { Hex } from '../../types/misc.js'
import type { ZksyncSmartAccount } from '../types/account.js'
import { toSmartAccount } from './toSmartAccount.js'
export type ToSinglesigSmartAccountParameters = {
/** Address of the deployed Account's Contract implementation. */
address: Address
/** Private Key of the owner. */
privateKey: Hex
}
/**
* Creates a [ZKsync Smart Account](https://docs.zksync.io/build/developer-reference/account-abstraction/building-smart-accounts)
* from a Contract Address and a Private Key belonging to the owner.
*/
export function toSinglesigSmartAccount(
parameters: ToSinglesigSmartAccountParameters,
): ZksyncSmartAccount {
const { address, privateKey } = parameters
return toSmartAccount({
address,
async sign({ hash }) {
return sign({ hash, privateKey, to: 'hex' })
},
})
}

63
node_modules/viem/zksync/accounts/toSmartAccount.ts generated vendored Normal file
View File

@@ -0,0 +1,63 @@
import type { Address } from 'abitype'
import { toAccount } from '../../accounts/toAccount.js'
import type { ErrorType } from '../../errors/utils.js'
import type { Hash, Hex } from '../../types/misc.js'
import { keccak256 } from '../../utils/index.js'
import { hashMessage } from '../../utils/signature/hashMessage.js'
import { hashTypedData } from '../../utils/signature/hashTypedData.js'
import { serializeTransaction } from '../serializers.js'
import type { ZksyncSmartAccount } from '../types/account.js'
import type { ZksyncTransactionSerializableEIP712 } from '../types/transaction.js'
export type ToSmartAccountParameters = {
/** Address of the deployed Account's Contract implementation. */
address: Address
/** Function to sign a hash. */
sign: (parameters: { hash: Hash }) => Promise<Hex>
}
export type ToSmartAccountErrorType = ErrorType
/**
* Creates a [ZKsync Smart Account](https://docs.zksync.io/build/developer-reference/account-abstraction/building-smart-accounts)
* from a Contract Address and a custom sign function.
*/
export function toSmartAccount(
parameters: ToSmartAccountParameters,
): ZksyncSmartAccount {
const { address, sign } = parameters
const account = toAccount({
address,
sign,
async signMessage({ message }) {
return sign({
hash: hashMessage(message),
})
},
async signTransaction(transaction) {
const signableTransaction = {
...transaction,
from: this.address!,
} as ZksyncTransactionSerializableEIP712
return serializeTransaction({
...signableTransaction,
customSignature: await sign({
hash: keccak256(serializeTransaction(signableTransaction)),
}),
})
},
async signTypedData(typedData) {
return sign({
hash: hashTypedData(typedData),
})
},
})
return {
...account,
source: 'smartAccountZksync',
} as ZksyncSmartAccount
}