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,17 @@
import { sign } from '../../accounts/utils/sign.js';
import { concatHex } from '../../utils/index.js';
import { toSmartAccount } from './toSmartAccount.js';
/**
* 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) {
const { address, privateKeys } = parameters;
return toSmartAccount({
address,
async sign({ hash }) {
return concatHex(await Promise.all(privateKeys.map((privateKey) => sign({ hash, privateKey, to: 'hex' }))));
},
});
}
//# sourceMappingURL=toMultisigSmartAccount.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"toMultisigSmartAccount.js","sourceRoot":"","sources":["../../../zksync/accounts/toMultisigSmartAccount.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAA;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AASpD;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,UAA4C;IAE5C,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,UAAU,CAAA;IAE3C,OAAO,cAAc,CAAC;QACpB,OAAO;QACP,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE;YACjB,OAAO,SAAS,CACd,MAAM,OAAO,CAAC,GAAG,CACf,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAC7B,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CACtC,CACF,CACF,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}

View File

@@ -0,0 +1,16 @@
import { sign } from '../../accounts/utils/sign.js';
import { toSmartAccount } from './toSmartAccount.js';
/**
* 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) {
const { address, privateKey } = parameters;
return toSmartAccount({
address,
async sign({ hash }) {
return sign({ hash, privateKey, to: 'hex' });
},
});
}
//# sourceMappingURL=toSinglesigSmartAccount.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"toSinglesigSmartAccount.js","sourceRoot":"","sources":["../../../zksync/accounts/toSinglesigSmartAccount.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAA;AAGnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AASpD;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,UAA6C;IAE7C,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,UAAU,CAAA;IAE1C,OAAO,cAAc,CAAC;QACpB,OAAO;QACP,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE;YACjB,OAAO,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;QAC9C,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}

View File

@@ -0,0 +1,43 @@
import { toAccount } from '../../accounts/toAccount.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';
/**
* 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) {
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,
};
return serializeTransaction({
...signableTransaction,
customSignature: await sign({
hash: keccak256(serializeTransaction(signableTransaction)),
}),
});
},
async signTypedData(typedData) {
return sign({
hash: hashTypedData(typedData),
});
},
});
return {
...account,
source: 'smartAccountZksync',
};
}
//# sourceMappingURL=toSmartAccount.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"toSmartAccount.js","sourceRoot":"","sources":["../../../zksync/accounts/toSmartAccount.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAGvD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAA;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAaxD;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,UAAoC;IAEpC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,UAAU,CAAA;IAEpC,MAAM,OAAO,GAAG,SAAS,CAAC;QACxB,OAAO;QACP,IAAI;QACJ,KAAK,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE;YAC3B,OAAO,IAAI,CAAC;gBACV,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC;aAC3B,CAAC,CAAA;QACJ,CAAC;QACD,KAAK,CAAC,eAAe,CAAC,WAAW;YAC/B,MAAM,mBAAmB,GAAG;gBAC1B,GAAG,WAAW;gBACd,IAAI,EAAE,IAAI,CAAC,OAAQ;aACmB,CAAA;YAExC,OAAO,oBAAoB,CAAC;gBAC1B,GAAG,mBAAmB;gBACtB,eAAe,EAAE,MAAM,IAAI,CAAC;oBAC1B,IAAI,EAAE,SAAS,CAAC,oBAAoB,CAAC,mBAAmB,CAAC,CAAC;iBAC3D,CAAC;aACH,CAAC,CAAA;QACJ,CAAC;QACD,KAAK,CAAC,aAAa,CAAC,SAAS;YAC3B,OAAO,IAAI,CAAC;gBACV,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC;aAC/B,CAAC,CAAA;QACJ,CAAC;KACF,CAAC,CAAA;IAEF,OAAO;QACL,GAAG,OAAO;QACV,MAAM,EAAE,oBAAoB;KACP,CAAA;AACzB,CAAC"}

View File

@@ -0,0 +1,199 @@
import { parseAbi } from 'abitype';
import { getTransaction } from '../../actions/public/getTransaction.js';
import { getTransactionReceipt } from '../../actions/public/getTransactionReceipt.js';
import { readContract } from '../../actions/public/readContract.js';
import { sendTransaction, } from '../../actions/wallet/sendTransaction.js';
import { zeroHash } from '../../constants/bytes.js';
import { AccountNotFoundError } from '../../errors/account.js';
import { ClientChainNotConfiguredError } from '../../errors/chain.js';
import { decodeAbiParameters, decodeFunctionData, encodeAbiParameters, encodeFunctionData, isAddressEqual, parseAccount, } from '../../utils/index.js';
import { bootloaderFormalAddress } from '../constants/address.js';
import { CannotClaimSuccessfulDepositError, L2BridgeNotFoundError, LogProofNotFoundError, } from '../errors/bridge.js';
import { undoL1ToL2Alias } from '../utils/bridge/undoL1ToL2Alias.js';
import { getDefaultBridgeAddresses } from './getDefaultBridgeAddresses.js';
import { getLogProof } from './getLogProof.js';
/**
* Withdraws funds from the initiated deposit, which failed when finalizing on L2.
* If the deposit L2 transaction has failed, it sends an L1 transaction calling `claimFailedDeposit` method of the
* L1 bridge, which results in returning L1 tokens back to the depositor.
*
* @param client - Client to use
* @param parameters - {@link ClaimFailedDepositParameters}
* @returns hash - The [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash. {@link ClaimFailedDepositReturnType}
*
* @example
* import { createPublicClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { zksync, mainnet } from 'viem/chains'
* import { claimFailedDeposit, publicActionsL2 } from 'viem/zksync'
*
* const client = createPublicClient({
* chain: mainnet,
* transport: http(),
* })
*
* const clientL2 = createPublicClient({
* chain: zksync,
* transport: http(),
* }).extend(publicActionsL2())
*
* const account = privateKeyToAccount('0x…')
*
* const hash = await claimFailedDeposit(client, {
* client: clientL2,
* account,
* depositHash: <L2_HASH_OF_FAILED_DEPOSIT>,
* })
*
* @example Account Hoisting
* import { createPublicClient, createWalletClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { zksync, mainnet } from 'viem/chains'
* import { publicActionsL2 } from 'viem/zksync'
*
* const walletClient = createWalletClient({
* chain: mainnet,
* transport: http(),
* account: privateKeyToAccount('0x…'),
* })
*
* const clientL2 = createPublicClient({
* chain: zksync,
* transport: http(),
* }).extend(publicActionsL2())
*
* const hash = await claimFailedDeposit(walletClient, {
* client: clientL2,
* depositHash: <L2_HASH_OF_FAILED_DEPOSIT>,
* })
*/
export async function claimFailedDeposit(client, parameters) {
const { account: account_ = client.account, chain: chain_ = client.chain, client: l2Client, depositHash, ...rest } = parameters;
const account = account_ ? parseAccount(account_) : client.account;
if (!account)
throw new AccountNotFoundError({
docsPath: '/docs/actions/wallet/sendTransaction',
});
if (!l2Client.chain)
throw new ClientChainNotConfiguredError();
const receipt = (await getTransactionReceipt(l2Client, { hash: depositHash }));
const successL2ToL1LogIndex = receipt.l2ToL1Logs.findIndex((l2ToL1log) => isAddressEqual(l2ToL1log.sender, bootloaderFormalAddress) &&
l2ToL1log.key === depositHash);
const successL2ToL1Log = receipt.l2ToL1Logs[successL2ToL1LogIndex];
if (successL2ToL1Log?.value !== zeroHash)
throw new CannotClaimSuccessfulDepositError({ hash: depositHash });
const tx = await getTransaction(l2Client, { hash: depositHash });
// Undo the aliasing, since the Mailbox contract set it as for contract address.
const l1BridgeAddress = undoL1ToL2Alias(receipt.from);
const l2BridgeAddress = receipt.to;
if (!l2BridgeAddress)
throw new L2BridgeNotFoundError();
const l1NativeTokenVault = (await getBridgeAddresses(client, l2Client))
.l1NativeTokenVault;
let depositSender;
let assetId;
let assetData;
try {
const { args } = decodeFunctionData({
abi: parseAbi([
'function finalizeDeposit(address _l1Sender, address _l2Receiver, address _l1Token, uint256 _amount, bytes _data)',
]),
data: tx.input,
});
assetData = encodeAbiParameters([{ type: 'uint256' }, { type: 'address' }, { type: 'address' }], [args[3], args[1], args[2]]);
assetId = await readContract(client, {
address: l1NativeTokenVault,
abi: parseAbi(['function assetId(address token) view returns (bytes32)']),
functionName: 'assetId',
args: [args[2]],
});
depositSender = args[0];
if (assetId === zeroHash)
throw new Error(`Token ${args[2]} not registered in NTV`);
}
catch (_e) {
const { args } = decodeFunctionData({
abi: parseAbi([
'function finalizeDeposit(uint256 _chainId, bytes32 _assetId, bytes _transferData)',
]),
data: tx.input,
});
assetId = args[1];
const transferData = args[2];
const l1TokenAddress = await readContract(client, {
address: l1NativeTokenVault,
abi: parseAbi([
'function tokenAddress(bytes32 assetId) view returns (address)',
]),
functionName: 'tokenAddress',
args: [assetId],
});
const transferDataDecoded = decodeAbiParameters([
{ type: 'address' },
{ type: 'address' },
{ type: 'address' },
{ type: 'uint256' },
{ type: 'bytes' },
], transferData);
assetData = encodeAbiParameters([{ type: 'uint256' }, { type: 'address' }, { type: 'address' }], [transferDataDecoded[3], transferDataDecoded[1], l1TokenAddress]);
depositSender = transferDataDecoded[0];
}
const proof = await getLogProof(l2Client, {
txHash: depositHash,
index: successL2ToL1LogIndex,
});
if (!proof)
throw new LogProofNotFoundError({
hash: depositHash,
index: successL2ToL1LogIndex,
});
const data = encodeFunctionData({
abi: parseAbi([
'function bridgeRecoverFailedTransfer(uint256 _chainId, address _depositSender, bytes32 _assetId, bytes _assetData, bytes32 _l2TxHash, uint256 _l2BatchNumber, uint256 _l2MessageIndex, uint16 _l2TxNumberInBatch, bytes32[] _merkleProof)',
]),
functionName: 'bridgeRecoverFailedTransfer',
args: [
BigInt(l2Client.chain.id),
depositSender,
assetId,
assetData,
depositHash,
receipt.l1BatchNumber,
BigInt(proof.id),
Number(receipt.l1BatchTxIndex),
proof.proof,
],
});
return await sendTransaction(client, {
chain: chain_,
account,
to: l1BridgeAddress,
data,
...rest,
});
}
async function getBridgeAddresses(client, l2Client) {
const addresses = await getDefaultBridgeAddresses(l2Client);
let l1Nullifier = addresses.l1Nullifier;
let l1NativeTokenVault = addresses.l1NativeTokenVault;
if (!l1Nullifier)
l1Nullifier = await readContract(client, {
address: addresses.sharedL1,
abi: parseAbi(['function L1_NULLIFIER() view returns (address)']),
functionName: 'L1_NULLIFIER',
args: [],
});
if (!l1NativeTokenVault)
l1NativeTokenVault = await readContract(client, {
address: addresses.sharedL1,
abi: parseAbi(['function nativeTokenVault() view returns (address)']),
functionName: 'nativeTokenVault',
args: [],
});
return {
...addresses,
l1Nullifier,
l1NativeTokenVault,
};
}
//# sourceMappingURL=claimFailedDeposit.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,54 @@
import { contract2FactoryAddress, contractDeployerAddress, } from '../constants/address.js';
import { encodeDeployData, } from '../utils/abi/encodeDeployData.js';
import { sendEip712Transaction, } from './sendEip712Transaction.js';
/**
* Deploys a contract to the network, given bytecode and constructor arguments using EIP712 transaction.
*
* - Docs: https://viem.sh/docs/contract/deployContract
*
* @param walletClient - Client to use
* @param parameters - {@link DeployContractParameters}
* @returns The [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash. {@link DeployContractReturnType}
*
* @example
* import { createWalletClient, custom } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { zksync } from 'viem/chains'
* import { deployContract } from 'viem/zksync'
*
* const client = createWalletClient({
* account: privateKeyToAccount('0x…'),
* chain: zksync,
* transport: custom(provider),
* })
* const hash = await deployContract(client, {
* abi: [],
* account: '0x…,
* deploymentType: 'create',
* bytecode: '0x608060405260405161083e38038061083e833981016040819052610...',
* factoryDeps: ['0x608060405260405161083e38038061083e833981016040819052610...'],
* gasPerPubdata: 50000n
* })
*/
export function deployContract(walletClient, parameters) {
const { abi, args, bytecode, deploymentType, salt, ...request } = parameters;
const data = encodeDeployData({
abi,
args,
bytecode,
deploymentType,
salt,
});
// Add the bytecode to the factoryDeps if it's not already there
request.factoryDeps = request.factoryDeps || [];
if (!request.factoryDeps.includes(bytecode))
request.factoryDeps.push(bytecode);
return sendEip712Transaction(walletClient, {
...request,
data,
to: deploymentType === 'create2' || deploymentType === 'create2Account'
? contract2FactoryAddress
: contractDeployerAddress,
});
}
//# sourceMappingURL=deployContract.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"deployContract.js","sourceRoot":"","sources":["../../../zksync/actions/deployContract.ts"],"names":[],"mappings":"AASA,OAAO,EACL,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,yBAAyB,CAAA;AAGhC,OAAO,EAEL,gBAAgB,GACjB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAIL,qBAAqB,GACtB,MAAM,4BAA4B,CAAA;AAqBnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,cAAc,CAM5B,YAA+C,EAC/C,UAAwE;IAExE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,GAC7D,UAAsC,CAAA;IAExC,MAAM,IAAI,GAAG,gBAAgB,CAAC;QAC5B,GAAG;QACH,IAAI;QACJ,QAAQ;QACR,cAAc;QACd,IAAI;KACL,CAAC,CAAA;IAEF,gEAAgE;IAChE,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,EAAE,CAAA;IAC/C,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACzC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAEpC,OAAO,qBAAqB,CAAC,YAAY,EAAE;QACzC,GAAG,OAAO;QACV,IAAI;QACJ,EAAE,EACA,cAAc,KAAK,SAAS,IAAI,cAAc,KAAK,gBAAgB;YACjE,CAAC,CAAC,uBAAuB;YACzB,CAAC,CAAC,uBAAuB;KAK9B,CAAC,CAAA;AACJ,CAAC"}

561
node_modules/viem/_esm/zksync/actions/deposit.js generated vendored Normal file
View File

@@ -0,0 +1,561 @@
import { parseAbi } from 'abitype';
import { estimateGas, } from '../../actions/public/estimateGas.js';
import { readContract } from '../../actions/public/readContract.js';
import { waitForTransactionReceipt } from '../../actions/public/waitForTransactionReceipt.js';
import { sendTransaction, } from '../../actions/wallet/sendTransaction.js';
import { writeContract, } from '../../actions/wallet/writeContract.js';
import { publicActions } from '../../clients/decorators/public.js';
import { erc20Abi } from '../../constants/abis.js';
import { zeroAddress } from '../../constants/address.js';
import { zeroHash } from '../../constants/bytes.js';
import { AccountNotFoundError } from '../../errors/account.js';
import { ClientChainNotConfiguredError } from '../../errors/chain.js';
import { concatHex, encodeAbiParameters, encodeFunctionData, isAddressEqual, keccak256, parseAccount, } from '../../utils/index.js';
import { bridgehubAbi } from '../constants/abis.js';
import { ethAddressInContracts, l2NativeTokenVaultAddress, legacyEthAddress, } from '../constants/address.js';
import { requiredL1ToL2GasPerPubdataLimit } from '../constants/number.js';
import { BaseFeeHigherThanValueError, } from '../errors/bridge.js';
import { applyL1ToL2Alias } from '../utils/bridge/applyL1ToL2Alias.js';
import { estimateGasL1ToL2 } from './estimateGasL1ToL2.js';
import { getBridgehubContractAddress } from './getBridgehubContractAddress.js';
import { getDefaultBridgeAddresses } from './getDefaultBridgeAddresses.js';
import { getL1Allowance } from './getL1Allowance.js';
/**
* Transfers the specified token from the associated account on the L1 network to the target account on the L2 network.
* The token can be either ETH or any ERC20 token. For ERC20 tokens, enough approved tokens must be associated with
* the specified L1 bridge (default one or the one defined in `bridgeAddress`).
* In this case, depending on is the chain ETH-based or not `approveToken` or `approveBaseToken`
* can be enabled to perform token approval. If there are already enough approved tokens for the L1 bridge,
* token approval will be skipped.
*
* @param client - Client to use
* @param parameters - {@link DepositParameters}
* @returns hash - The [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash. {@link DepositReturnType}
*
* @example
* import { createPublicClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { zksync, mainnet } from 'viem/chains'
* import { deposit, legacyEthAddress, publicActionsL2 } from 'viem/zksync'
*
* const client = createPublicClient({
* chain: mainnet,
* transport: http(),
* })
*
* const clientL2 = createPublicClient({
* chain: zksync,
* transport: http(),
* }).extend(publicActionsL2())
*
* const account = privateKeyToAccount('0x…')
*
* const hash = await deposit(client, {
* client: clientL2,
* account,
* token: legacyEthAddress,
* to: account.address,
* amount: 1_000_000_000_000_000_000n,
* refundRecipient: account.address,
* })
*
* @example Account Hoisting
* import { createPublicClient, createWalletClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { zksync, mainnet } from 'viem/chains'
* import { legacyEthAddress, publicActionsL2 } from 'viem/zksync'
*
* const walletClient = createWalletClient({
* chain: mainnet,
* transport: http(),
* account: privateKeyToAccount('0x…'),
* })
*
* const clientL2 = createPublicClient({
* chain: zksync,
* transport: http(),
* }).extend(publicActionsL2())
*
* const hash = await deposit(walletClient, {
* client: clientL2,
* token: legacyEthAddress,
* to: walletClient.account.address,
* amount: 1_000_000_000_000_000_000n,
* refundRecipient: walletClient.account.address,
* })
*/
export async function deposit(client, parameters) {
let { account: account_ = client.account, chain: chain_ = client.chain, client: l2Client, token, amount, approveToken, approveBaseToken, gas, } = parameters;
const account = account_ ? parseAccount(account_) : client.account;
if (!account)
throw new AccountNotFoundError({
docsPath: '/docs/actions/wallet/sendTransaction',
});
if (!l2Client.chain)
throw new ClientChainNotConfiguredError();
if (isAddressEqual(token, legacyEthAddress))
token = ethAddressInContracts;
const bridgeAddresses = await getBridgeAddresses(client, l2Client);
const bridgehub = await getBridgehubContractAddress(l2Client);
const baseToken = await readContract(client, {
address: bridgehub,
abi: bridgehubAbi,
functionName: 'baseToken',
args: [BigInt(l2Client.chain.id)],
});
const { mintValue, tx } = await getL1DepositTx(client, account, { ...parameters, token }, bridgeAddresses, bridgehub, baseToken);
await approveTokens(client, chain_, tx.bridgeAddress, baseToken, mintValue, account, token, amount, approveToken, approveBaseToken);
if (!gas) {
const baseGasLimit = await estimateGas(client, {
account: account.address,
to: bridgehub,
value: tx.value,
data: tx.data,
});
gas = scaleGasLimit(baseGasLimit);
}
return await sendTransaction(client, {
chain: chain_,
account,
gas,
...tx,
});
}
async function getL1DepositTx(client, account, parameters, bridgeAddresses, bridgehub, baseToken) {
let { account: _account, chain: _chain, client: l2Client, token, amount, to, operatorTip = 0n, l2GasLimit, gasPerPubdataByte = requiredL1ToL2GasPerPubdataLimit, refundRecipient = zeroAddress, bridgeAddress, customBridgeData, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, approveToken: _approveToken, approveBaseToken: _approveBaseToken, ...rest } = parameters;
if (!l2Client.chain)
throw new ClientChainNotConfiguredError();
to ??= account.address;
let gasPriceForEstimation = maxFeePerGas || gasPrice;
if (!gasPriceForEstimation) {
const estimatedFee = await getFeePrice(client);
gasPriceForEstimation = estimatedFee.maxFeePerGas;
maxFeePerGas = estimatedFee.maxFeePerGas;
maxPriorityFeePerGas ??= estimatedFee.maxPriorityFeePerGas;
}
const { l2GasLimit_, baseCost } = await getL2BridgeTxFeeParams(client, l2Client, bridgehub, gasPriceForEstimation, account.address, token, amount, to, gasPerPubdataByte, baseToken, l2GasLimit, bridgeAddress, customBridgeData);
l2GasLimit = l2GasLimit_;
let mintValue;
let data;
const isETHBasedChain = isAddressEqual(baseToken, ethAddressInContracts);
if ((isETHBasedChain && isAddressEqual(token, ethAddressInContracts)) || // ETH on ETH-based chain
isAddressEqual(token, baseToken) // base token on custom chain
) {
// Deposit base token
mintValue = baseCost + operatorTip + amount;
let providedValue = isETHBasedChain ? value : mintValue;
if (!providedValue || providedValue === 0n)
providedValue = mintValue;
if (baseCost > providedValue)
throw new BaseFeeHigherThanValueError(baseCost, providedValue);
value = isETHBasedChain ? providedValue : 0n;
bridgeAddress = bridgeAddresses.sharedL1; // required for approval of base token on custom chain
data = encodeFunctionData({
abi: bridgehubAbi,
functionName: 'requestL2TransactionDirect',
args: [
{
chainId: BigInt(l2Client.chain.id),
mintValue: providedValue,
l2Contract: to,
l2Value: amount,
l2Calldata: '0x',
l2GasLimit,
l2GasPerPubdataByteLimit: gasPerPubdataByte,
factoryDeps: [],
refundRecipient,
},
],
});
}
else if (isAddressEqual(baseToken, ethAddressInContracts)) {
// Deposit token on ETH-based chain
mintValue = baseCost + BigInt(operatorTip);
value = mintValue;
if (baseCost > mintValue)
throw new BaseFeeHigherThanValueError(baseCost, mintValue);
bridgeAddress ??= bridgeAddresses.sharedL1;
data = encodeFunctionData({
abi: bridgehubAbi,
functionName: 'requestL2TransactionTwoBridges',
args: [
{
chainId: BigInt(l2Client.chain.id),
mintValue,
l2Value: 0n,
l2GasLimit,
l2GasPerPubdataByteLimit: gasPerPubdataByte,
refundRecipient,
secondBridgeAddress: bridgeAddress,
secondBridgeValue: 0n,
secondBridgeCalldata: await getSecondBridgeCalldata(client, bridgeAddresses.l1NativeTokenVault, token, amount, to),
},
],
});
}
else if (isAddressEqual(token, ethAddressInContracts)) {
// Deposit ETH on custom chain
mintValue = baseCost + operatorTip;
value = amount;
if (baseCost > mintValue)
throw new BaseFeeHigherThanValueError(baseCost, mintValue);
bridgeAddress = bridgeAddresses.sharedL1;
data = encodeFunctionData({
abi: bridgehubAbi,
functionName: 'requestL2TransactionTwoBridges',
args: [
{
chainId: BigInt(l2Client.chain.id),
mintValue,
l2Value: 0n,
l2GasLimit,
l2GasPerPubdataByteLimit: gasPerPubdataByte,
refundRecipient,
secondBridgeAddress: bridgeAddress,
secondBridgeValue: amount,
secondBridgeCalldata: await getSecondBridgeCalldata(client, bridgeAddresses.l1NativeTokenVault, ethAddressInContracts, amount, to),
},
],
});
}
else {
// Deposit token on custom chain
mintValue = baseCost + operatorTip;
value ??= 0n;
if (baseCost > mintValue)
throw new BaseFeeHigherThanValueError(baseCost, mintValue);
bridgeAddress ??= bridgeAddresses.sharedL1;
data = encodeFunctionData({
abi: bridgehubAbi,
functionName: 'requestL2TransactionTwoBridges',
args: [
{
chainId: BigInt(l2Client.chain.id),
mintValue,
l2Value: 0n,
l2GasLimit,
l2GasPerPubdataByteLimit: gasPerPubdataByte,
refundRecipient,
secondBridgeAddress: bridgeAddress,
secondBridgeValue: 0n,
secondBridgeCalldata: await getSecondBridgeCalldata(client, bridgeAddresses.l1NativeTokenVault, token, amount, to),
},
],
});
}
return {
mintValue,
tx: {
bridgeAddress,
to: bridgehub,
data,
value,
gasPrice,
maxFeePerGas,
maxPriorityFeePerGas,
...rest,
},
};
}
async function approveTokens(client, chain, bridgeAddress, baseToken, mintValue, account, token, amount, approveToken, approveBaseToken) {
if (isAddressEqual(baseToken, ethAddressInContracts)) {
// Deposit token on ETH-based chain
if (approveToken) {
const overrides = typeof approveToken === 'boolean' ? {} : approveToken;
const allowance = await getL1Allowance(client, {
token,
bridgeAddress,
account,
});
if (allowance < amount) {
const hash = await writeContract(client, {
chain,
account,
address: token,
abi: erc20Abi,
functionName: 'approve',
args: [bridgeAddress, amount],
...overrides,
});
await waitForTransactionReceipt(client, { hash });
}
}
return;
}
if (isAddressEqual(token, ethAddressInContracts)) {
// Deposit ETH on custom chain
if (approveBaseToken) {
const overrides = typeof approveToken === 'boolean' ? {} : approveToken;
const allowance = await getL1Allowance(client, {
token: baseToken,
bridgeAddress,
account,
});
if (allowance < mintValue) {
const hash = await writeContract(client, {
chain,
account,
address: baseToken,
abi: erc20Abi,
functionName: 'approve',
args: [bridgeAddress, mintValue],
...overrides,
});
await waitForTransactionReceipt(client, { hash });
}
return;
}
}
if (isAddressEqual(token, baseToken)) {
// Deposit base token on custom chain
if (approveToken || approveBaseToken) {
const overrides = typeof approveToken === 'boolean'
? {}
: (approveToken ?? typeof approveBaseToken === 'boolean')
? {}
: approveBaseToken;
const allowance = await getL1Allowance(client, {
token: baseToken,
bridgeAddress,
account,
});
if (allowance < mintValue) {
const hash = await writeContract(client, {
chain,
account,
address: baseToken,
abi: erc20Abi,
functionName: 'approve',
args: [bridgeAddress, mintValue],
...overrides,
});
await waitForTransactionReceipt(client, { hash });
}
}
return;
}
// Deposit token on custom chain
if (approveBaseToken) {
const overrides = typeof approveToken === 'boolean' ? {} : approveToken;
const allowance = await getL1Allowance(client, {
token: baseToken,
bridgeAddress,
account,
});
if (allowance < mintValue) {
const hash = await writeContract(client, {
chain,
account,
address: baseToken,
abi: erc20Abi,
functionName: 'approve',
args: [bridgeAddress, mintValue],
...overrides,
});
await waitForTransactionReceipt(client, { hash });
}
}
if (approveToken) {
const overrides = typeof approveToken === 'boolean' ? {} : approveToken;
const allowance = await getL1Allowance(client, {
token,
bridgeAddress,
account,
});
if (allowance < amount) {
const hash = await writeContract(client, {
chain,
account,
address: token,
abi: erc20Abi,
functionName: 'approve',
args: [bridgeAddress, amount],
...overrides,
});
await waitForTransactionReceipt(client, { hash });
}
}
}
async function getL2BridgeTxFeeParams(client, l2Client, bridgehub, gasPrice, from, token, amount, to, gasPerPubdataByte, baseToken, l2GasLimit, bridgeAddress, customBridgeData) {
if (!l2Client.chain)
throw new ClientChainNotConfiguredError();
let l2GasLimit_ = l2GasLimit;
if (!l2GasLimit_)
l2GasLimit_ = bridgeAddress
? await getL2GasLimitFromCustomBridge(client, l2Client, from, token, amount, to, gasPerPubdataByte, bridgeAddress, customBridgeData)
: await getL2GasLimitFromDefaultBridge(client, l2Client, from, token, amount, to, gasPerPubdataByte, baseToken);
const baseCost = await readContract(client, {
address: bridgehub,
abi: bridgehubAbi,
functionName: 'l2TransactionBaseCost',
args: [BigInt(l2Client.chain.id), gasPrice, l2GasLimit_, gasPerPubdataByte],
});
return { l2GasLimit_, baseCost };
}
async function getL2GasLimitFromDefaultBridge(client, l2Client, from, token, amount, to, gasPerPubdataByte, baseToken) {
if (isAddressEqual(token, baseToken)) {
return await estimateGasL1ToL2(l2Client, {
chain: l2Client.chain,
account: from,
from,
to,
value: amount,
data: '0x',
gasPerPubdata: gasPerPubdataByte,
});
}
const value = 0n;
const bridgeAddresses = await getDefaultBridgeAddresses(l2Client);
const l1BridgeAddress = bridgeAddresses.sharedL1;
const l2BridgeAddress = bridgeAddresses.sharedL2;
const bridgeData = await encodeDefaultBridgeData(client, token);
const calldata = encodeFunctionData({
abi: parseAbi([
'function finalizeDeposit(address _l1Sender, address _l2Receiver, address _l1Token, uint256 _amount, bytes _data)',
]),
functionName: 'finalizeDeposit',
args: [
from,
to,
isAddressEqual(token, legacyEthAddress) ? ethAddressInContracts : token,
amount,
bridgeData,
],
});
return await estimateGasL1ToL2(l2Client, {
chain: l2Client.chain,
account: applyL1ToL2Alias(l1BridgeAddress),
to: l2BridgeAddress,
data: calldata,
gasPerPubdata: gasPerPubdataByte,
value,
});
}
async function getL2GasLimitFromCustomBridge(client, l2Client, from, token, amount, to, gasPerPubdataByte, bridgeAddress, customBridgeData) {
let customBridgeData_ = customBridgeData;
if (!customBridgeData_ || customBridgeData_ === '0x')
customBridgeData_ = await encodeDefaultBridgeData(client, token);
const l2BridgeAddress = await readContract(client, {
address: token,
abi: parseAbi([
'function l2BridgeAddress(uint256 _chainId) view returns (address)',
]),
functionName: 'l2BridgeAddress',
args: [BigInt(l2Client.chain.id)],
});
const calldata = encodeFunctionData({
abi: parseAbi([
'function finalizeDeposit(address _l1Sender, address _l2Receiver, address _l1Token, uint256 _amount, bytes _data)',
]),
functionName: 'finalizeDeposit',
args: [from, to, token, amount, customBridgeData_],
});
return await estimateGasL1ToL2(l2Client, {
chain: l2Client.chain,
account: from,
from: applyL1ToL2Alias(bridgeAddress),
to: l2BridgeAddress,
data: calldata,
gasPerPubdata: gasPerPubdataByte,
});
}
async function encodeDefaultBridgeData(client, token) {
let token_ = token;
if (isAddressEqual(token, legacyEthAddress))
token_ = ethAddressInContracts;
let name = 'Ether';
let symbol = 'ETH';
let decimals = 18n;
if (!isAddressEqual(token_, ethAddressInContracts)) {
name = await readContract(client, {
address: token_,
abi: erc20Abi,
functionName: 'name',
args: [],
});
symbol = await readContract(client, {
address: token_,
abi: erc20Abi,
functionName: 'symbol',
args: [],
});
decimals = BigInt(await readContract(client, {
address: token_,
abi: erc20Abi,
functionName: 'decimals',
args: [],
}));
}
const nameBytes = encodeAbiParameters([{ type: 'string' }], [name]);
const symbolBytes = encodeAbiParameters([{ type: 'string' }], [symbol]);
const decimalsBytes = encodeAbiParameters([{ type: 'uint256' }], [decimals]);
return encodeAbiParameters([{ type: 'bytes' }, { type: 'bytes' }, { type: 'bytes' }], [nameBytes, symbolBytes, decimalsBytes]);
}
async function getSecondBridgeCalldata(client, l1NativeTokenVault, token, amount, to) {
let assetId;
let token_ = token;
if (isAddressEqual(token, legacyEthAddress))
token_ = ethAddressInContracts;
const assetIdFromNTV = await readContract(client, {
address: l1NativeTokenVault,
abi: parseAbi(['function assetId(address token) view returns (bytes32)']),
functionName: 'assetId',
args: [token_],
});
if (assetIdFromNTV && assetIdFromNTV !== zeroHash)
assetId = assetIdFromNTV;
else {
// Okay, the token have not been registered within the Native token vault.
// There are two cases when it is possible:
// - The token is native to L1 (it may or may not be bridged), but it has not been
// registered within NTV after the Gateway upgrade. We assume that this is not the case
// as the SDK is expected to work only after the full migration is done.
// - The token is native to the current chain and it has never been bridged.
if (!client.chain)
throw new ClientChainNotConfiguredError();
assetId = keccak256(encodeAbiParameters([{ type: 'uint256' }, { type: 'address' }, { type: 'address' }], [BigInt(client.chain.id), l2NativeTokenVaultAddress, token_]));
}
const ntvData = encodeAbiParameters([{ type: 'uint256' }, { type: 'address' }, { type: 'address' }], [BigInt(amount), to, token_]);
const data = encodeAbiParameters([{ type: 'bytes32' }, { type: 'bytes' }], [assetId, ntvData]);
return concatHex(['0x01', data]);
}
async function getBridgeAddresses(client, l2Client) {
const addresses = await getDefaultBridgeAddresses(l2Client);
let l1Nullifier = addresses.l1Nullifier;
let l1NativeTokenVault = addresses.l1NativeTokenVault;
if (!l1Nullifier)
l1Nullifier = await readContract(client, {
address: addresses.sharedL1,
abi: parseAbi(['function L1_NULLIFIER() view returns (address)']),
functionName: 'L1_NULLIFIER',
args: [],
});
if (!l1NativeTokenVault)
l1NativeTokenVault = await readContract(client, {
address: addresses.sharedL1,
abi: parseAbi(['function nativeTokenVault() view returns (address)']),
functionName: 'nativeTokenVault',
args: [],
});
return {
...addresses,
l1Nullifier,
l1NativeTokenVault,
};
}
function scaleGasLimit(gasLimit) {
return (gasLimit * BigInt(12)) / BigInt(10);
}
async function getFeePrice(client) {
const client_ = client.extend(publicActions);
const block = await client_.getBlock();
const baseFee = typeof block.baseFeePerGas !== 'bigint'
? await client_.getGasPrice()
: block.baseFeePerGas;
const maxPriorityFeePerGas = await client_.estimateMaxPriorityFeePerGas();
return {
maxFeePerGas: (baseFee * 3n) / 2n + maxPriorityFeePerGas,
maxPriorityFeePerGas: maxPriorityFeePerGas,
};
}
//# sourceMappingURL=deposit.js.map

1
node_modules/viem/_esm/zksync/actions/deposit.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

23
node_modules/viem/_esm/zksync/actions/estimateFee.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
import { parseAccount } from '../../accounts/utils/parseAccount.js';
import { hexToBigInt } from '../../utils/encoding/fromHex.js';
/* @deprecated Use `eth_gasPrice` for `maxFeePerGas`, `eth_estimateGas` to get the `gasLimit`, set `maxPriorityFeePerGas` to `0`, and use `zks_gasPerPubdata` for `gasPerPubdataLimit` instead. */
export async function estimateFee(client, parameters) {
const { account: account_, ...request } = parameters;
const account = account_ ? parseAccount(account_) : client.account;
const formatters = client.chain?.formatters;
const formatted = formatters?.transactionRequest?.format({
...request,
from: account?.address,
}, 'estimateFee');
const result = await client.request({
method: 'zks_estimateFee',
params: [formatted],
});
return {
gasLimit: hexToBigInt(result.gas_limit),
gasPerPubdataLimit: hexToBigInt(result.gas_per_pubdata_limit),
maxPriorityFeePerGas: hexToBigInt(result.max_priority_fee_per_gas),
maxFeePerGas: hexToBigInt(result.max_fee_per_gas),
};
}
//# sourceMappingURL=estimateFee.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"estimateFee.js","sourceRoot":"","sources":["../../../zksync/actions/estimateFee.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AAKnE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAY7D,kMAAkM;AAClM,MAAM,CAAC,KAAK,UAAU,WAAW,CAI/B,MAAgE,EAChE,UAAiD;IAEjD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,GAAG,UAAU,CAAA;IACpD,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAA;IAElE,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,EAAE,UAAU,CAAA;IAC3C,MAAM,SAAS,GAAG,UAAU,EAAE,kBAAkB,EAAE,MAAM,CACtD;QACE,GAAG,OAAO;QACV,IAAI,EAAE,OAAO,EAAE,OAAO;KACvB,EACD,aAAa,CACd,CAAA;IAED,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClC,MAAM,EAAE,iBAAiB;QACzB,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAA;IAEF,OAAO;QACL,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC;QACvC,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAAC,qBAAqB,CAAC;QAC7D,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAAC,wBAAwB,CAAC;QAClE,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,eAAe,CAAC;KAClD,CAAA;AACH,CAAC"}

View File

@@ -0,0 +1,16 @@
import { parseAccount } from '../../accounts/utils/parseAccount.js';
export async function estimateGasL1ToL2(client, parameters) {
const { account: account_, ...request } = parameters;
const account = account_ ? parseAccount(account_) : client.account;
const formatters = client.chain?.formatters;
const formatted = formatters?.transactionRequest?.format({
...request,
from: account?.address,
}, 'estimateGasL1ToL2');
const result = await client.request({
method: 'zks_estimateGasL1ToL2',
params: [formatted],
});
return result;
}
//# sourceMappingURL=estimateGasL1ToL2.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"estimateGasL1ToL2.js","sourceRoot":"","sources":["../../../zksync/actions/estimateGasL1ToL2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AAenE,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAIrC,MAAgE,EAChE,UAAuD;IAEvD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,GAAG,UAAU,CAAA;IACpD,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAA;IAElE,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,EAAE,UAAU,CAAA;IAC3C,MAAM,SAAS,GAAG,UAAU,EAAE,kBAAkB,EAAE,MAAM,CACtD;QACE,GAAG,OAAO;QACV,IAAI,EAAE,OAAO,EAAE,OAAO;KACvB,EACD,mBAAmB,CACpB,CAAA;IAED,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClC,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC"}

View File

@@ -0,0 +1,147 @@
import { parseAbi } from 'abitype';
import { readContract } from '../../actions/public/readContract.js';
import { sendTransaction, } from '../../actions/wallet/sendTransaction.js';
import { AccountNotFoundError } from '../../errors/account.js';
import { ChainNotFoundError, } from '../../errors/chain.js';
import { decodeAbiParameters, encodeFunctionData, parseAccount, slice, } from '../../utils/index.js';
import { WithdrawalLogNotFoundError, } from '../errors/bridge.js';
import { getWithdrawalL2ToL1Log } from '../utils/bridge/getWithdrawalL2ToL1Log.js';
import { getWithdrawalLog } from '../utils/bridge/getWithdrawalLog.js';
import { getDefaultBridgeAddresses } from './getDefaultBridgeAddresses.js';
import { getLogProof } from './getLogProof.js';
/**
* Proves the inclusion of the `L2->L1` withdrawal message.
*
* @param client - Client to use
* @param parameters - {@link FinalizeWithdrawalParameters}
* @returns hash - The [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash. {@link FinalizeWithdrawalReturnType}
*
* @example
* import { createPublicClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { mainnet, zksync } from 'viem/chains'
* import { finalizeWithdrawal, publicActionsL2 } from 'viem/zksync'
*
* const client = createPublicClient({
* chain: mainnet,
* transport: http(),
* })
*
* const clientL2 = createPublicClient({
* chain: zksync,
* transport: http(),
* }).extend(publicActionsL2())
*
* const hash = await finalizeWithdrawal(client, {
* account: privateKeyToAccount('0x…'),
* client: clientL2,
* hash: '0x...',
* })
*
* @example Account Hoisting
* import { createPublicClient, createWalletClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { mainnet, zksync } from 'viem/chains'
* import { finalizeWithdrawal, publicActionsL2 } from 'viem/zksync'
*
* const client = createWalletClient({
* account: privateKeyToAccount('0x…'),
* chain: mainnet,
* transport: http(),
* })
*
* const clientL2 = createPublicClient({
* chain: zksync,
* transport: http(),
* }).extend(publicActionsL2())
*
* const hash = await finalizeWithdrawal(client, {
* client: clientL2,
* hash: '0x…',
* })
*/
export async function finalizeWithdrawal(client, parameters) {
const { account: account_ = client.account, client: l2Client, hash, index = 0, ...rest } = parameters;
const account = account_ ? parseAccount(account_) : client.account;
if (!account)
throw new AccountNotFoundError({
docsPath: '/docs/actions/wallet/sendTransaction',
});
if (!l2Client.chain)
throw new ChainNotFoundError();
const finalizeWithdrawalParams = await getFinalizeWithdrawalParams(l2Client, {
hash,
index,
});
const l1Nullifier = (await getBridgeAddresses(client, l2Client)).l1Nullifier;
const data = encodeFunctionData({
abi: parseAbi([
'function finalizeDeposit((uint256 chainId, uint256 l2BatchNumber, uint256 l2MessageIndex, address l2Sender, uint16 l2TxNumberInBatch, bytes message, bytes32[] merkleProof) _finalizeWithdrawalParams)',
]),
functionName: 'finalizeDeposit',
args: [
{
chainId: BigInt(l2Client.chain.id),
l2BatchNumber: finalizeWithdrawalParams.l1BatchNumber,
l2MessageIndex: BigInt(finalizeWithdrawalParams.l2MessageIndex),
l2Sender: finalizeWithdrawalParams.sender,
l2TxNumberInBatch: Number(finalizeWithdrawalParams.l2TxNumberInBlock),
message: finalizeWithdrawalParams.message,
merkleProof: finalizeWithdrawalParams.proof,
},
],
});
return await sendTransaction(client, {
account,
to: l1Nullifier,
data,
...rest,
});
}
async function getFinalizeWithdrawalParams(client, parameters) {
const { hash } = parameters;
const { log, l1BatchTxId } = await getWithdrawalLog(client, parameters);
const { l2ToL1LogIndex } = await getWithdrawalL2ToL1Log(client, parameters);
const sender = slice(log.topics[1], 12);
const proof = await getLogProof(client, {
txHash: hash,
index: l2ToL1LogIndex,
});
if (!proof) {
throw new WithdrawalLogNotFoundError({ hash });
}
const [message] = decodeAbiParameters([{ type: 'bytes' }], log.data);
return {
l1BatchNumber: log.l1BatchNumber,
l2MessageIndex: proof.id,
l2TxNumberInBlock: l1BatchTxId,
message,
sender,
proof: proof.proof,
};
}
async function getBridgeAddresses(client, l2Client) {
const addresses = await getDefaultBridgeAddresses(l2Client);
let l1Nullifier = addresses.l1Nullifier;
let l1NativeTokenVault = addresses.l1NativeTokenVault;
if (!l1Nullifier)
l1Nullifier = await readContract(client, {
address: addresses.sharedL1,
abi: parseAbi(['function L1_NULLIFIER() view returns (address)']),
functionName: 'L1_NULLIFIER',
args: [],
});
if (!l1NativeTokenVault)
l1NativeTokenVault = await readContract(client, {
address: addresses.sharedL1,
abi: parseAbi(['function nativeTokenVault() view returns (address)']),
functionName: 'nativeTokenVault',
args: [],
});
return {
...addresses,
l1Nullifier,
l1NativeTokenVault,
};
}
//# sourceMappingURL=finalizeWithdrawal.js.map

View File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,EAAE,QAAQ,CAAC,CAAC,oDAAoD,CAAC,CAAC;YACrE,YAAY,EAAE,kBAAkB;YAChC,IAAI,EAAE,EAAE;SACT,CAAC,CAAA;IAEJ,OAAO;QACL,GAAG,SAAS;QACZ,WAAW;QACX,kBAAkB;KACnB,CAAA;AACH,CAAC"}

View File

@@ -0,0 +1,16 @@
import { parseAccount } from '../../accounts/utils/parseAccount.js';
import { hexToBigInt } from '../../utils/encoding/fromHex.js';
/* @deprecated This method has been removed from the node API. */
export async function getAllBalances(client, parameters) {
const { account: account_ } = parameters;
const account = account_ ? parseAccount(account_) : client.account;
const balances = await client.request({
method: 'zks_getAllAccountBalances',
params: [account.address],
});
const convertedBalances = {};
for (const token in balances)
convertedBalances[token] = hexToBigInt(balances[token]);
return convertedBalances;
}
//# sourceMappingURL=getAllBalances.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getAllBalances.js","sourceRoot":"","sources":["../../../zksync/actions/getAllBalances.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AAKnE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAS7D,iEAAiE;AACjE,MAAM,CAAC,KAAK,UAAU,cAAc,CAIlC,MAAgE,EAChE,UAA6C;IAE7C,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAA;IACxC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAA;IAClE,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACpC,MAAM,EAAE,2BAA2B;QACnC,MAAM,EAAE,CAAC,OAAQ,CAAC,OAAO,CAAC;KAC3B,CAAC,CAAA;IACF,MAAM,iBAAiB,GAA6B,EAAE,CAAA;IACtD,KAAK,MAAM,KAAK,IAAI,QAAQ;QACzB,iBAAyB,CAAC,KAAK,CAAC,GAAG,WAAW,CAAE,QAAgB,CAAC,KAAK,CAAC,CAAC,CAAA;IAC3E,OAAO,iBAAiB,CAAA;AAC1B,CAAC"}

View File

@@ -0,0 +1,6 @@
/* @deprecated Use `getBridgeHubContractAddress` and call `baseToken(chainId)` instead. */
export async function getBaseTokenL1Address(client) {
const result = await client.request({ method: 'zks_getBaseTokenL1Address' });
return result;
}
//# sourceMappingURL=getBaseTokenL1Address.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getBaseTokenL1Address.js","sourceRoot":"","sources":["../../../zksync/actions/getBaseTokenL1Address.ts"],"names":[],"mappings":"AASA,0FAA0F;AAC1F,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAIzC,MAAgE;IAEhE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,2BAA2B,EAAE,CAAC,CAAA;IAC5E,OAAO,MAAM,CAAA;AACf,CAAC"}

View File

@@ -0,0 +1,8 @@
export async function getBlockDetails(client, parameters) {
const result = await client.request({
method: 'zks_getBlockDetails',
params: [parameters.number],
});
return result;
}
//# sourceMappingURL=getBlockDetails.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getBlockDetails.js","sourceRoot":"","sources":["../../../zksync/actions/getBlockDetails.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,KAAK,UAAU,eAAe,CAInC,MAAgE,EAChE,UAAqC;IAErC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClC,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;KAC5B,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACf,CAAC"}

View File

@@ -0,0 +1,5 @@
export async function getBridgehubContractAddress(client) {
const result = await client.request({ method: 'zks_getBridgehubContract' });
return result;
}
//# sourceMappingURL=getBridgehubContractAddress.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getBridgehubContractAddress.js","sourceRoot":"","sources":["../../../zksync/actions/getBridgehubContractAddress.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAI/C,MAAgE;IAEhE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,0BAA0B,EAAE,CAAC,CAAA;IAC3E,OAAO,MAAM,CAAA;AACf,CAAC"}

View File

@@ -0,0 +1,11 @@
export async function getDefaultBridgeAddresses(client) {
const addresses = await client.request({ method: 'zks_getBridgeContracts' });
return {
erc20L1: addresses.l1Erc20DefaultBridge,
sharedL1: addresses.l1SharedDefaultBridge,
sharedL2: addresses.l2SharedDefaultBridge,
l1Nullifier: addresses.l1Nullifier,
l1NativeTokenVault: addresses.l1NativeTokenVault,
};
}
//# sourceMappingURL=getDefaultBridgeAddresses.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getDefaultBridgeAddresses.js","sourceRoot":"","sources":["../../../zksync/actions/getDefaultBridgeAddresses.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAI7C,MAAgE;IAEhE,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,wBAAwB,EAAE,CAAC,CAAA;IAE5E,OAAO;QACL,OAAO,EAAE,SAAS,CAAC,oBAAoB;QACvC,QAAQ,EAAE,SAAS,CAAC,qBAAqB;QACzC,QAAQ,EAAE,SAAS,CAAC,qBAAqB;QACzC,WAAW,EAAE,SAAS,CAAC,WAAW;QAClC,kBAAkB,EAAE,SAAS,CAAC,kBAAkB;KACjD,CAAA;AACH,CAAC"}

View File

@@ -0,0 +1,10 @@
import { hexToBigInt } from '../../utils/encoding/fromHex.js';
export async function getGasPerPubdata(client) {
const result = await client.request({
method: 'zks_gasPerPubdata',
}, {
dedupe: true,
});
return hexToBigInt(result);
}
//# sourceMappingURL=getGasPerPubdata.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getGasPerPubdata.js","sourceRoot":"","sources":["../../../zksync/actions/getGasPerPubdata.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAM7D,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAIpC,MAAgE;IAEhE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CACjC;QACE,MAAM,EAAE,mBAAmB;KAC5B,EACD;QACE,MAAM,EAAE,IAAI;KACb,CACF,CAAA;IAED,OAAO,WAAW,CAAC,MAAM,CAAC,CAAA;AAC5B,CAAC"}

View File

@@ -0,0 +1,15 @@
import { parseAccount } from '../../accounts/utils/parseAccount.js';
import { readContract } from '../../actions/public/readContract.js';
import { erc20Abi } from '../../constants/abis.js';
export async function getL1Allowance(client, parameters) {
const { token, bridgeAddress, blockTag, account: account_ } = parameters;
const account = account_ ? parseAccount(account_) : client.account;
return await readContract(client, {
abi: erc20Abi,
address: token,
functionName: 'allowance',
args: [account.address, bridgeAddress],
blockTag: blockTag,
});
}
//# sourceMappingURL=getL1Allowance.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getL1Allowance.js","sourceRoot":"","sources":["../../../zksync/actions/getL1Allowance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AAGnE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAmBlD,MAAM,CAAC,KAAK,UAAU,cAAc,CAIlC,MAAyC,EACzC,UAA6C;IAE7C,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAA;IAExE,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAA;IAElE,OAAO,MAAM,YAAY,CAAC,MAAM,EAAE;QAChC,GAAG,EAAE,QAAQ;QACb,OAAO,EAAE,KAAK;QACd,YAAY,EAAE,WAAW;QACzB,IAAI,EAAE,CAAC,OAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;QACvC,QAAQ,EAAE,QAAQ;KACnB,CAAC,CAAA;AACJ,CAAC"}

19
node_modules/viem/_esm/zksync/actions/getL1Balance.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
import { parseAccount } from '../../accounts/utils/parseAccount.js';
import { getBalance, } from '../../actions/public/getBalance.js';
import { legacyEthAddress } from '../constants/address.js';
import { isEth } from '../utils/isEth.js';
import { getL1TokenBalance, } from './getL1TokenBalance.js';
export async function getL1Balance(client, ...[parameters = {}]) {
const { account: account_ = client.account, blockNumber, blockTag, token = legacyEthAddress, } = parameters;
const account = account_ ? parseAccount(account_) : undefined;
if (isEth(token))
return await getBalance(client, {
address: account.address,
blockNumber,
blockTag,
});
return await getL1TokenBalance(client, {
...parameters,
});
}
//# sourceMappingURL=getL1Balance.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getL1Balance.js","sourceRoot":"","sources":["../../../zksync/actions/getL1Balance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AACnE,OAAO,EAEL,UAAU,GACX,MAAM,oCAAoC,CAAA;AAQ3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAEL,iBAAiB,GAClB,MAAM,wBAAwB,CAAA;AAqB/B,MAAM,CAAC,KAAK,UAAU,YAAY,CAIhC,MAAyC,EACzC,GAAG,CAAC,UAAU,GAAG,EAAE,CAEuB;IAE1C,MAAM,EACJ,OAAO,EAAE,QAAQ,GAAG,MAAM,CAAC,OAAO,EAClC,WAAW,EACX,QAAQ,EACR,KAAK,GAAG,gBAAgB,GACzB,GAAG,UAAU,CAAA;IAEd,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAE7D,IAAI,KAAK,CAAC,KAAK,CAAC;QACd,OAAO,MAAM,UAAU,CAAC,MAAM,EAAE;YAC9B,OAAO,EAAE,OAAQ,CAAC,OAAO;YACzB,WAAW;YACX,QAAQ;SACe,CAAC,CAAA;IAE5B,OAAO,MAAM,iBAAiB,CAAC,MAAM,EAAE;QACrC,GAAI,UAAmD;KACxD,CAAC,CAAA;AACJ,CAAC"}

View File

@@ -0,0 +1,9 @@
import { hexToNumber } from '../../utils/encoding/fromHex.js';
export async function getL1BatchBlockRange(client, parameters) {
const [number_1, number_2] = await client.request({
method: 'zks_getL1BatchBlockRange',
params: [parameters.l1BatchNumber],
});
return [hexToNumber(number_1), hexToNumber(number_2)];
}
//# sourceMappingURL=getL1BatchBlockRange.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getL1BatchBlockRange.js","sourceRoot":"","sources":["../../../zksync/actions/getL1BatchBlockRange.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAS7D,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAIxC,MAAgE,EAChE,UAA0C;IAE1C,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAChD,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC;KACnC,CAAC,CAAA;IACF,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAA;AACvD,CAAC"}

View File

@@ -0,0 +1,8 @@
export async function getL1BatchDetails(client, parameters) {
const result = await client.request({
method: 'zks_getL1BatchDetails',
params: [parameters.number],
});
return result;
}
//# sourceMappingURL=getL1BatchDetails.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getL1BatchDetails.js","sourceRoot":"","sources":["../../../zksync/actions/getL1BatchDetails.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAIrC,MAAgE,EAChE,UAAuC;IAEvC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClC,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;KAC5B,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACf,CAAC"}

View File

@@ -0,0 +1,5 @@
export async function getL1BatchNumber(client) {
const result = await client.request({ method: 'zks_L1BatchNumber' });
return result;
}
//# sourceMappingURL=getL1BatchNumber.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getL1BatchNumber.js","sourceRoot":"","sources":["../../../zksync/actions/getL1BatchNumber.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAIpC,MAAgE;IAEhE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAA;IACpE,OAAO,MAAM,CAAA;AACf,CAAC"}

View File

@@ -0,0 +1,6 @@
/* @deprecated Use the `L1_CHAIN_ID()` method on the `L2AssetRouter` contract (deployed on `0x0000000000000000000000000000000000010003` address) */
export async function getL1ChainId(client) {
const result = await client.request({ method: 'zks_L1ChainId' });
return result;
}
//# sourceMappingURL=getL1ChainId.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getL1ChainId.js","sourceRoot":"","sources":["../../../zksync/actions/getL1ChainId.ts"],"names":[],"mappings":"AASA,mJAAmJ;AACnJ,MAAM,CAAC,KAAK,UAAU,YAAY,CAIhC,MAAgE;IAEhE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC,CAAA;IAChE,OAAO,MAAM,CAAA;AACf,CAAC"}

View File

@@ -0,0 +1,40 @@
import { readContract } from '../../actions/public/readContract.js';
import { isAddressEqual } from '../../utils/index.js';
import { l2SharedBridgeAbi } from '../constants/abis.js';
import { legacyEthAddress } from '../constants/address.js';
import { getDefaultBridgeAddresses } from './getDefaultBridgeAddresses.js';
/**
* Returns the L1 token address equivalent for a L2 token address as they are not equal.
* ETH address is set to zero address.
*
* @remarks Only works for tokens bridged on default ZKsync Era bridges.
*
* @param client - Client to use
* @param parameters - {@link GetL1TokenAddressParameters}
* @returns The L1 token address equivalent for a L2 token address.
*
*
* @example
* import { createPublicClient, http } from 'viem'
* import { zksync } from 'viem/chains'
*
* const client = createPublicClient({
* chain: zksync,
* transport: http(),
* })
*
* const address = await getL1TokenAddress(client, {token: '0x...'});
*/
export async function getL1TokenAddress(client, parameters) {
const { token } = parameters;
if (isAddressEqual(token, legacyEthAddress))
return legacyEthAddress;
const bridgeAddress = (await getDefaultBridgeAddresses(client)).sharedL2;
return await readContract(client, {
address: bridgeAddress,
abi: l2SharedBridgeAbi,
functionName: 'l1TokenAddress',
args: [token],
});
}
//# sourceMappingURL=getL1TokenAddress.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getL1TokenAddress.js","sourceRoot":"","sources":["../../../zksync/actions/getL1TokenAddress.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AAKnE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAS1E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAIrC,MAAyC,EACzC,UAAuC;IAEvC,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,CAAA;IAC5B,IAAI,cAAc,CAAC,KAAK,EAAE,gBAAgB,CAAC;QAAE,OAAO,gBAAgB,CAAA;IAEpE,MAAM,aAAa,GAAG,CAAC,MAAM,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAA;IAExE,OAAO,MAAM,YAAY,CAAC,MAAM,EAAE;QAChC,OAAO,EAAE,aAAa;QACtB,GAAG,EAAE,iBAAiB;QACtB,YAAY,EAAE,gBAAgB;QAC9B,IAAI,EAAE,CAAC,KAAK,CAAC;KACd,CAAC,CAAA;AACJ,CAAC"}

View File

@@ -0,0 +1,20 @@
import { parseAccount } from '../../accounts/utils/parseAccount.js';
import { readContract } from '../../actions/index.js';
import { erc20Abi } from '../../constants/abis.js';
import { TokenIsEthError, } from '../errors/token-is-eth.js';
import { isEth } from '../utils/isEth.js';
export async function getL1TokenBalance(client, parameters) {
const { account: account_ = client.account, blockTag, blockNumber, token, } = parameters;
if (isEth(token))
throw new TokenIsEthError();
const account = account_ ? parseAccount(account_) : client.account;
return await readContract(client, {
abi: erc20Abi,
address: token,
functionName: 'balanceOf',
args: [account.address],
blockNumber: blockNumber,
blockTag: blockTag,
});
}
//# sourceMappingURL=getL1TokenBalance.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getL1TokenBalance.js","sourceRoot":"","sources":["../../../zksync/actions/getL1TokenBalance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAGrD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAMlD,OAAO,EACL,eAAe,GAEhB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAwBzC,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAIrC,MAAyC,EACzC,UAAgD;IAEhD,MAAM,EACJ,OAAO,EAAE,QAAQ,GAAG,MAAM,CAAC,OAAO,EAClC,QAAQ,EACR,WAAW,EACX,KAAK,GACN,GAAG,UAAU,CAAA;IAEd,IAAI,KAAK,CAAC,KAAM,CAAC;QAAE,MAAM,IAAI,eAAe,EAAE,CAAA;IAE9C,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAA;IAElE,OAAO,MAAM,YAAY,CAAC,MAAM,EAAE;QAChC,GAAG,EAAE,QAAQ;QACb,OAAO,EAAE,KAAM;QACf,YAAY,EAAE,WAAW;QACzB,IAAI,EAAE,CAAC,OAAQ,CAAC,OAAO,CAAC;QACxB,WAAW,EAAE,WAAW;QACxB,QAAQ,EAAE,QAAQ;KACnB,CAAC,CAAA;AACJ,CAAC"}

View File

@@ -0,0 +1,45 @@
import { readContract } from '../../actions/public/readContract.js';
import { isAddressEqual } from '../../utils/index.js';
import { l2SharedBridgeAbi } from '../constants/abis.js';
import { ethAddressInContracts, l2BaseTokenAddress, legacyEthAddress, } from '../constants/address.js';
import { getBaseTokenL1Address } from './getBaseTokenL1Address.js';
import { getDefaultBridgeAddresses } from './getDefaultBridgeAddresses.js';
/**
* Returns the L2 token address equivalent for a L1 token address as they are not equal.
* ETH address is set to zero address.
*
* @remarks Only works for tokens bridged on default ZKsync Era bridges.
*
* @param client - Client to use
* @param parameters - {@link GetL2TokenAddressParameters}
* @returns The L2 token address equivalent for a L1 token address.
*
*
* @example
* import { createPublicClient, http } from 'viem'
* import { zksync } from 'viem/chains'
* import { publicActionsL2 } from 'viem/zksync'
*
* const client = createPublicClient({
* chain: zksync,
* transport: http(),
* }).extend(publicActionsL2())
*
* const address = await getL2TokenAddress(client, {token: '0x...'});
*/
export async function getL2TokenAddress(client, parameters) {
let { token, bridgeAddress } = parameters;
if (isAddressEqual(token, legacyEthAddress))
token = ethAddressInContracts;
const baseToken = await getBaseTokenL1Address(client);
if (isAddressEqual(token, baseToken))
return l2BaseTokenAddress;
bridgeAddress ??= (await getDefaultBridgeAddresses(client)).sharedL2;
return await readContract(client, {
address: bridgeAddress,
abi: l2SharedBridgeAbi,
functionName: 'l2TokenAddress',
args: [token],
});
}
//# sourceMappingURL=getL2TokenAddress.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getL2TokenAddress.js","sourceRoot":"","sources":["../../../zksync/actions/getL2TokenAddress.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AAKnE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAW1E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAIrC,MAAyC,EACzC,UAAuC;IAEvC,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,UAAU,CAAA;IACzC,IAAI,cAAc,CAAC,KAAK,EAAE,gBAAgB,CAAC;QAAE,KAAK,GAAG,qBAAqB,CAAA;IAE1E,MAAM,SAAS,GAAG,MAAM,qBAAqB,CAAC,MAAM,CAAC,CAAA;IACrD,IAAI,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC;QAAE,OAAO,kBAAkB,CAAA;IAE/D,aAAa,KAAK,CAAC,MAAM,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAA;IAEpE,OAAO,MAAM,YAAY,CAAC,MAAM,EAAE;QAChC,OAAO,EAAE,aAAa;QACtB,GAAG,EAAE,iBAAiB;QACtB,YAAY,EAAE,gBAAgB;QAC9B,IAAI,EAAE,CAAC,KAAK,CAAC;KACd,CAAC,CAAA;AACJ,CAAC"}

8
node_modules/viem/_esm/zksync/actions/getLogProof.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
export async function getLogProof(client, parameters) {
const result = await client.request({
method: 'zks_getL2ToL1LogProof',
params: [parameters.txHash, parameters.index],
});
return result;
}
//# sourceMappingURL=getLogProof.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getLogProof.js","sourceRoot":"","sources":["../../../zksync/actions/getLogProof.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,KAAK,UAAU,WAAW,CAI/B,MAAgE,EAChE,UAAiC;IAEjC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClC,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC;KAC9C,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACf,CAAC"}

View File

@@ -0,0 +1,6 @@
/* @deprecated Use `getBridgeHubContractAddress` and call `getZKChain(chainId)` instead. */
export async function getMainContractAddress(client) {
const address = await client.request({ method: 'zks_getMainContract' });
return address;
}
//# sourceMappingURL=getMainContractAddress.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getMainContractAddress.js","sourceRoot":"","sources":["../../../zksync/actions/getMainContractAddress.ts"],"names":[],"mappings":"AASA,2FAA2F;AAC3F,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAI1C,MAAgE;IAEhE,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC,CAAA;IACvE,OAAO,OAAO,CAAA;AAChB,CAAC"}

View File

@@ -0,0 +1,10 @@
import { camelCaseKeys } from '../utils/camelCaseKeys.js';
/* @deprecated Use `debug_getRawTransaction` and `debug_getRawTransactions` instead. */
export async function getRawBlockTransactions(client, parameters) {
const result = await client.request({
method: 'zks_getRawBlockTransactions',
params: [parameters.number],
});
return camelCaseKeys(result);
}
//# sourceMappingURL=getRawBlockTransactions.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getRawBlockTransactions.js","sourceRoot":"","sources":["../../../zksync/actions/getRawBlockTransactions.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAMzD,uFAAuF;AACvF,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAI3C,MAAgE,EAChE,UAA6C;IAE7C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClC,MAAM,EAAE,6BAA6B;QACrC,MAAM,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;KAC5B,CAAC,CAAA;IACF,OAAO,aAAa,CAAC,MAAM,CAAsC,CAAA;AACnE,CAAC"}

View File

@@ -0,0 +1,6 @@
/* @deprecated Check the corresponding ZKsync chain technical documentation to find the testnet paymaster address */
export async function getTestnetPaymasterAddress(client) {
const result = await client.request({ method: 'zks_getTestnetPaymaster' });
return result;
}
//# sourceMappingURL=getTestnetPaymasterAddress.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getTestnetPaymasterAddress.js","sourceRoot":"","sources":["../../../zksync/actions/getTestnetPaymasterAddress.ts"],"names":[],"mappings":"AASA,oHAAoH;AACpH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAI9C,MAAgE;IAEhE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,yBAAyB,EAAE,CAAC,CAAA;IAC1E,OAAO,MAAM,CAAA;AACf,CAAC"}

View File

@@ -0,0 +1,8 @@
export async function getTransactionDetails(client, parameters) {
const result = await client.request({
method: 'zks_getTransactionDetails',
params: [parameters.txHash],
});
return result;
}
//# sourceMappingURL=getTransactionDetails.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getTransactionDetails.js","sourceRoot":"","sources":["../../../zksync/actions/getTransactionDetails.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAIzC,MAAgE,EAChE,UAA2C;IAE3C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClC,MAAM,EAAE,2BAA2B;QACnC,MAAM,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;KAC5B,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACf,CAAC"}

View File

@@ -0,0 +1,62 @@
import { readContract } from '../../actions/public/readContract.js';
import { ChainNotFoundError, } from '../../errors/chain.js';
import { l1SharedBridgeAbi } from '../constants/abis.js';
import { WithdrawalLogNotFoundError, } from '../errors/bridge.js';
import { getWithdrawalL2ToL1Log } from '../utils/bridge/getWithdrawalL2ToL1Log.js';
import { getWithdrawalLog } from '../utils/bridge/getWithdrawalLog.js';
import { getDefaultBridgeAddresses } from './getDefaultBridgeAddresses.js';
import { getLogProof } from './getLogProof.js';
/**
* Returns whether the withdrawal transaction is finalized on the L1 network.
*
* @param client - Client to use
* @param parameters - {@link IsWithdrawalFinalizedParameters}
* @returns bool - Whether the withdrawal transaction is finalized on the L1 network. {@link IsWithdrawalFinalizedReturnType}
*
* @example
* import { createPublicClient, http } from 'viem'
* import { mainnet, zksync } from 'viem/chains'
* import { isWithdrawalFinalized } from 'viem/zksync'
*
* const client = createPublicClient({
* chain: mainnet,
* transport: http(),
* })
*
* const clientL2 = createPublicClient({
* chain: zksync,
* transport: http(),
* })
*
* const hash = await isWithdrawalFinalized(client, {
* client: clientL2,
* hash: '0x...',
* })
*/
export async function isWithdrawalFinalized(client, parameters) {
const { client: l2Client, hash, index = 0 } = parameters;
if (!l2Client.chain)
throw new ChainNotFoundError();
const { log } = await getWithdrawalLog(l2Client, { hash, index });
const { l2ToL1LogIndex } = await getWithdrawalL2ToL1Log(l2Client, {
hash,
index,
});
// `getLogProof` is called not to get proof but
// to get the index of the corresponding L2->L1 log,
// which is returned as `proof.id`.
const proof = await getLogProof(l2Client, {
txHash: hash,
index: l2ToL1LogIndex,
});
if (!proof)
throw new WithdrawalLogNotFoundError({ hash });
const l1Bridge = (await getDefaultBridgeAddresses(l2Client)).sharedL1;
return await readContract(client, {
address: l1Bridge,
abi: l1SharedBridgeAbi,
functionName: 'isWithdrawalFinalized',
args: [BigInt(l2Client.chain.id), log.l1BatchNumber, BigInt(proof.id)],
});
}
//# sourceMappingURL=isWithdrawalFinalized.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"isWithdrawalFinalized.js","sourceRoot":"","sources":["../../../zksync/actions/isWithdrawalFinalized.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AAGnE,OAAO,EACL,kBAAkB,GAEnB,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EACL,0BAA0B,GAE3B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAA;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAA;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAqB9C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAMzC,MAAyC,EACzC,UAA+D;IAE/D,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,UAAU,CAAA;IAExD,IAAI,CAAC,QAAQ,CAAC,KAAK;QAAE,MAAM,IAAI,kBAAkB,EAAE,CAAA;IAEnD,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,gBAAgB,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IACjE,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,sBAAsB,CAAC,QAAQ,EAAE;QAChE,IAAI;QACJ,KAAK;KACN,CAAC,CAAA;IAEF,+CAA+C;IAC/C,oDAAoD;IACpD,mCAAmC;IACnC,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,QAAQ,EAAE;QACxC,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,cAAe;KACvB,CAAC,CAAA;IACF,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,0BAA0B,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;IAE1D,MAAM,QAAQ,GAAG,CAAC,MAAM,yBAAyB,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAA;IAErE,OAAO,MAAM,YAAY,CAAC,MAAM,EAAE;QAChC,OAAO,EAAE,QAAQ;QACjB,GAAG,EAAE,iBAAiB;QACtB,YAAY,EAAE,uBAAuB;QACrC,IAAI,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,aAAc,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;KACxE,CAAC,CAAA;AACJ,CAAC"}

167
node_modules/viem/_esm/zksync/actions/requestExecute.js generated vendored Normal file
View File

@@ -0,0 +1,167 @@
import { generatePrivateKey } from '../../accounts/generatePrivateKey.js';
import { privateKeyToAddress } from '../../accounts/utils/privateKeyToAddress.js';
import { readContract } from '../../actions/public/readContract.js';
import { sendTransaction, } from '../../actions/wallet/sendTransaction.js';
import { publicActions } from '../../clients/decorators/public.js';
import { AccountNotFoundError } from '../../errors/account.js';
import { ClientChainNotConfiguredError } from '../../errors/chain.js';
import { encodeFunctionData, isAddressEqual, parseAccount, } from '../../utils/index.js';
import { bridgehubAbi } from '../constants/abis.js';
import { ethAddressInContracts } from '../constants/address.js';
import { requiredL1ToL2GasPerPubdataLimit } from '../constants/number.js';
import { BaseFeeHigherThanValueError, } from '../errors/bridge.js';
import { estimateGasL1ToL2 } from './estimateGasL1ToL2.js';
import { getBridgehubContractAddress } from './getBridgehubContractAddress.js';
/**
* Requests execution of a L2 transaction from L1.
*
* @param client - Client to use
* @param parameters - {@link RequestExecuteParameters}
* @returns hash - The [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash. {@link RequestExecuteReturnType}
*
* @example
* import { createPublicClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { zksync, mainnet } from 'viem/chains'
* import { requestExecute, publicActionsL2 } from 'viem/zksync'
*
* const client = createPublicClient({
* chain: mainnet,
* transport: http(),
* })
*
* const clientL2 = createPublicClient({
* chain: zksync,
* transport: http(),
* }).extend(publicActionsL2())
*
* const hash = await requestExecute(client, {
* client: clientL2,
* account: privateKeyToAccount('0x…'),
* contractAddress: '0x43020e6e11cef7dce8e37baa09d9a996ac722057'
* calldata: '0x',
* l2Value: 1_000_000_000_000_000_000n,
* })
*
* @example Account Hoisting
* import { createPublicClient, createWalletClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { zksync, mainnet } from 'viem/chains'
* import { requestExecute, publicActionsL2 } from 'viem/zksync'
*
* const client = createWalletClient({
* account: privateKeyToAccount('0x…'),
* chain: mainnet,
* transport: http(),
* })
*
* const clientL2 = createPublicClient({
* chain: zksync,
* transport: http(),
* }).extend(publicActionsL2())
*
* const hash = await requestExecute(client, {
* client: clientL2,
* contractAddress: '0x43020e6e11cef7dce8e37baa09d9a996ac722057'
* calldata: '0x',
* l2Value: 1_000_000_000_000_000_000n,
* })
*/
export async function requestExecute(client, parameters) {
let { account: account_ = client.account, chain: chain_ = client.chain, client: l2Client, contractAddress, calldata, l2Value = 0n, mintValue = 0n, operatorTip = 0n, factoryDeps = [], gasPerPubdataByte = requiredL1ToL2GasPerPubdataLimit, refundRecipient, l2GasLimit, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, ...rest } = parameters;
const account = account_ ? parseAccount(account_) : client.account;
if (!account)
throw new AccountNotFoundError({
docsPath: '/docs/actions/wallet/sendTransaction',
});
if (!l2Client.chain)
throw new ClientChainNotConfiguredError();
const bridgehub = await getBridgehubContractAddress(l2Client);
const baseToken = await readContract(client, {
address: bridgehub,
abi: bridgehubAbi,
functionName: 'baseToken',
args: [BigInt(l2Client.chain.id)],
});
const isETHBasedChain = isAddressEqual(baseToken, ethAddressInContracts);
refundRecipient ??= account.address;
l2GasLimit ??= await estimateGasL1ToL2(l2Client, {
chain: l2Client.chain,
// If the `from` address is not provided, we use a random address, because
// due to storage slot aggregation, the gas estimation will depend on the address
// and so estimation for the zero address may be smaller than for the sender.
account: l2Client.account ??
parseAccount(privateKeyToAddress(generatePrivateKey())),
data: calldata,
to: contractAddress,
value: l2Value,
gasPerPubdata: gasPerPubdataByte,
factoryDeps,
});
let gasPriceForEstimation = maxFeePerGas || gasPrice;
if (!gasPriceForEstimation) {
const estimatedFee = await getFeePrice(client);
gasPriceForEstimation = estimatedFee.maxFeePerGas;
maxFeePerGas = estimatedFee.maxFeePerGas;
maxPriorityFeePerGas ??= estimatedFee.maxPriorityFeePerGas;
}
const baseCost = await readContract(client, {
address: bridgehub,
abi: bridgehubAbi,
functionName: 'l2TransactionBaseCost',
args: [
BigInt(l2Client.chain.id),
gasPriceForEstimation,
l2GasLimit,
gasPerPubdataByte,
],
});
const l2Costs = baseCost + operatorTip + l2Value;
let providedValue = isETHBasedChain ? value : mintValue;
if (!providedValue || providedValue === 0n) {
providedValue = l2Costs;
}
if (baseCost > providedValue)
throw new BaseFeeHigherThanValueError(baseCost, providedValue);
const data = encodeFunctionData({
abi: bridgehubAbi,
functionName: 'requestL2TransactionDirect',
args: [
{
chainId: BigInt(l2Client.chain.id),
mintValue: providedValue,
l2Contract: contractAddress,
l2Value: l2Value,
l2Calldata: calldata,
l2GasLimit: l2GasLimit,
l2GasPerPubdataByteLimit: gasPerPubdataByte,
factoryDeps: factoryDeps,
refundRecipient: refundRecipient,
},
],
});
return await sendTransaction(client, {
chain: chain_,
account: account,
to: bridgehub,
value: isETHBasedChain ? providedValue : value,
data,
gasPrice,
maxFeePerGas,
maxPriorityFeePerGas,
...rest,
});
}
async function getFeePrice(client) {
const client_ = client.extend(publicActions);
const block = await client_.getBlock();
const baseFee = typeof block.baseFeePerGas !== 'bigint'
? await client_.getGasPrice()
: block.baseFeePerGas;
const maxPriorityFeePerGas = await client_.estimateMaxPriorityFeePerGas();
return {
maxFeePerGas: (baseFee * 3n) / 2n + maxPriorityFeePerGas,
maxPriorityFeePerGas: maxPriorityFeePerGas,
};
}
//# sourceMappingURL=requestExecute.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"requestExecute.js","sourceRoot":"","sources":["../../../zksync/actions/requestExecute.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAA;AAEzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AACnE,OAAO,EAIL,eAAe,GAChB,MAAM,yCAAyC,CAAA;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAElE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAA;AASrE,OAAO,EACL,kBAAkB,EAElB,cAAc,EACd,YAAY,GACb,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAA;AACzE,OAAO,EACL,2BAA2B,GAE5B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAA;AA4C9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAOlC,MAAyC,EACzC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AI,EAAE;YACJ;gBACE,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAClC,SAAS,EAAE,aAAa;gBACxB,UAAU,EAAE,eAAe;gBAC3B,OAAO,EAAE,OAAO;gBAChB,UAAU,EAAE,QAAQ;gBACpB,UAAU,EAAE,UAAU;gBACtB,wBAAwB,EAAE,iBAAiB;gBAC3C,WAAW,EAAE,WAAW;gBACxB,eAAe,EAAE,eAAe;aACjC;SACF;KACF,CAAC,CAAA;IAEF,OAAO,MAAM,eAAe,CAAC,MAAM,EAAE;QACnC,KAAK,EAAE,MAAM;QACb,OAAO,EAAE,OAAO;QAChB,EAAE,EAAE,SAAS;QACb,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK;QAC9C,IAAI;QACJ,QAAQ;QACR,YAAY;QACZ,oBAAoB;QACpB,GAAG,IAAI;KACqB,CAAC,CAAA;AACjC,CAAC;AAED,KAAK,UAAU,WAAW,CACxB,MAAgC;IAEhC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;IAC5C,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAA;IACtC,MAAM,OAAO,GACX,OAAO,KAAK,CAAC,aAAa,KAAK,QAAQ;QACrC,CAAC,CAAC,MAAM,OAAO,CAAC,WAAW,EAAE;QAC7B,CAAC,CAAC,KAAK,CAAC,aAAa,CAAA;IACzB,MAAM,oBAAoB,GAAG,MAAM,OAAO,CAAC,4BAA4B,EAAE,CAAA;IAEzE,OAAO;QACL,YAAY,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,oBAAoB;QACxD,oBAAoB,EAAE,oBAAoB;KAC3C,CAAA;AACH,CAAC"}

View File

@@ -0,0 +1,90 @@
import { parseAccount } from '../../accounts/utils/parseAccount.js';
import { getChainId } from '../../actions/public/getChainId.js';
import { prepareTransactionRequest } from '../../actions/wallet/prepareTransactionRequest.js';
import { sendRawTransaction } from '../../actions/wallet/sendRawTransaction.js';
import { AccountNotFoundError } from '../../errors/account.js';
import { assertCurrentChain } from '../../utils/chain/assertCurrentChain.js';
import { getTransactionError, } from '../../utils/errors/getTransactionError.js';
import { getAction } from '../../utils/getAction.js';
import { assertEip712Request } from '../utils/assertEip712Request.js';
import { signTransaction } from './signTransaction.js';
/**
* Creates, signs, and sends a new EIP712 transaction to the network.
*
* @param client - Client to use
* @param parameters - {@link SendEip712TransactionParameters}
* @returns The [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash. {@link SendTransactionReturnType}
*
* @example
* import { createWalletClient, custom } from 'viem'
* import { zksync } from 'viem/chains'
* import { sendEip712Transaction } from 'viem/zksync'
*
* const client = createWalletClient({
* chain: zksync,
* transport: custom(window.ethereum),
* })
* const hash = await sendEip712Transaction(client, {
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
* value: 1000000000000000000n,
* })
*
* @example
* // Account Hoisting
* import { createWalletClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { zksync } from 'viem/chains'
* import { sendEip712Transaction } from 'viem/zksync'
*
* const client = createWalletClient({
* account: privateKeyToAccount('0x…'),
* chain: zksync,
* transport: http(),
* })
*
* const hash = await sendEip712Transaction(client, {
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
* value: 1000000000000000000n,
* })
*/
export async function sendEip712Transaction(client, parameters) {
const { account: account_ = client.account, chain = client.chain } = parameters;
const account = account_ ? parseAccount(account_) : client.account;
if (!account)
throw new AccountNotFoundError({
docsPath: '/docs/actions/wallet/sendTransaction',
});
try {
assertEip712Request(parameters);
// Prepare the request for signing (assign appropriate fees, etc.)
const request = await prepareTransactionRequest(client, {
...parameters,
nonceManager: account.nonceManager,
parameters: ['gas', 'nonce', 'fees'],
});
let chainId;
if (chain !== null) {
chainId = await getAction(client, getChainId, 'getChainId')({});
assertCurrentChain({
currentChainId: chainId,
chain,
});
}
const serializedTransaction = await signTransaction(client, {
...request,
chainId,
});
return await getAction(client, sendRawTransaction, 'sendRawTransaction')({
serializedTransaction,
});
}
catch (err) {
throw getTransactionError(err, {
...parameters,
account,
chain: chain,
});
}
}
//# sourceMappingURL=sendEip712Transaction.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"sendEip712Transaction.js","sourceRoot":"","sources":["../../../zksync/actions/sendEip712Transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAA;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,mDAAmD,CAAA;AAC7F,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAA;AAS/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAG9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAEL,mBAAmB,GACpB,MAAM,2CAA2C,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAEpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAgBtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAMzC,MAAyC,EACzC,UAKC;IAED,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,GAChE,UAAU,CAAA;IAEZ,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAA;IAElE,IAAI,CAAC,OAAO;QACV,MAAM,IAAI,oBAAoB,CAAC;YAC7B,QAAQ,EAAE,sCAAsC;SACjD,CAAC,CAAA;IAEJ,IAAI,CAAC;QACH,mBAAmB,CAAC,UAAU,CAAC,CAAA;QAE/B,kEAAkE;QAClE,MAAM,OAAO,GAAG,MAAM,yBAAyB,CAAC,MAAM,EAAE;YACtD,GAAG,UAAU;YACb,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,UAAU,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC;SAC9B,CAAC,CAAA;QAET,IAAI,OAA2B,CAAA;QAC/B,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,OAAO,GAAG,MAAM,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAA;YAC/D,kBAAkB,CAAC;gBACjB,cAAc,EAAE,OAAO;gBACvB,KAAK;aACN,CAAC,CAAA;QACJ,CAAC;QAED,MAAM,qBAAqB,GAAG,MAAM,eAAe,CAAC,MAAM,EAAE;YAC1D,GAAG,OAAO;YACV,OAAO;SACD,CAAC,CAAA;QAET,OAAO,MAAM,SAAS,CACpB,MAAM,EACN,kBAAkB,EAClB,oBAAoB,CACrB,CAAC;YACA,qBAAqB;SACtB,CAAC,CAAA;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,mBAAmB,CAAC,GAAgB,EAAE;YAC1C,GAAI,UAA4C;YAChD,OAAO;YACP,KAAK,EAAE,KAAc;SACtB,CAAC,CAAA;IACJ,CAAC;AACH,CAAC"}

View File

@@ -0,0 +1,53 @@
import { sendTransaction as core_sendTransaction } from '../../actions/wallet/sendTransaction.js';
import { isEIP712Transaction } from '../utils/isEip712Transaction.js';
import { sendEip712Transaction, } from './sendEip712Transaction.js';
/**
* Creates, signs, and sends a new transaction to the network.
*
* - Docs: https://viem.sh/docs/zksync/actions/sendTransaction
* - JSON-RPC Methods:
* - JSON-RPC Accounts: [`eth_sendTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendtransaction)
* - Local Accounts: [`eth_sendRawTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction)
*
* @param client - Client to use
* @param parameters - {@link SendTransactionParameters}
* @returns The [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash. {@link SendTransactionReturnType}
*
* @example
* import { createWalletClient, custom } from 'viem'
* import { zksync } from 'viem/chains'
* import { sendTransaction } from 'viem/zksync'
*
* const client = createWalletClient({
* chain: zksync,
* transport: custom(window.ethereum),
* })
* const hash = await sendTransaction(client, {
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
* value: 1000000000000000000n,
* })
*
* @example
* // Account Hoisting
* import { createWalletClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { zksync } from 'viem/chains'
* import { sendTransaction } from 'viem/zksync'
*
* const client = createWalletClient({
* account: privateKeyToAccount('0x…'),
* chain: zksync,
* transport: http(),
* })
* const hash = await sendTransaction(client, {
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
* value: 1000000000000000000n,
* })
*/
export async function sendTransaction(client, parameters) {
if (isEIP712Transaction(parameters))
return sendEip712Transaction(client, parameters);
return core_sendTransaction(client, parameters);
}
//# sourceMappingURL=sendTransaction.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"sendTransaction.js","sourceRoot":"","sources":["../../../zksync/actions/sendTransaction.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,IAAI,oBAAoB,EAAE,MAAM,yCAAyC,CAAA;AAIjG,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAEL,qBAAqB,GACtB,MAAM,4BAA4B,CAAA;AAgBnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAMnC,MAAyC,EACzC,UAA6E;IAE7E,IAAI,mBAAmB,CAAC,UAAU,CAAC;QACjC,OAAO,qBAAqB,CAC1B,MAAM,EACN,UAA6C,CAC9C,CAAA;IACH,OAAO,oBAAoB,CACzB,MAAM,EACN,UAA4C,CAC7C,CAAA;AACH,CAAC"}

View File

@@ -0,0 +1,88 @@
import { parseAccount } from '../../accounts/utils/parseAccount.js';
import { getChainId } from '../../actions/public/getChainId.js';
import { signTypedData } from '../../actions/wallet/signTypedData.js';
import { AccountNotFoundError } from '../../errors/account.js';
import { BaseError } from '../../errors/base.js';
import { assertCurrentChain } from '../../utils/chain/assertCurrentChain.js';
import { getAction } from '../../utils/getAction.js';
import { assertEip712Request, } from '../utils/assertEip712Request.js';
/**
* Signs an EIP712 transaction.
*
*
* @param client - Client to use
* @param args - {@link SignTransactionParameters}
* @returns The signed serialized transaction. {@link SignTransactionReturnType}
*
* @example
* import { createWalletClient, custom } from 'viem'
* import { zksync } from 'viem/chains'
* import { signEip712Transaction } from 'viem/zksync'
*
* const client = createWalletClient({
* chain: zksync,
* transport: custom(window.ethereum),
* })
* const signature = await signEip712Transaction(client, {
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
* to: '0x0000000000000000000000000000000000000000',
* value: 1n,
* })
*
* @example
* // Account Hoisting
* import { createWalletClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { zksync } from 'viem/chains'
* import { signEip712Transaction } from 'viem/zksync'
*
* const client = createWalletClient({
* account: privateKeyToAccount('0x…'),
* chain: zksync,
* transport: custom(window.ethereum),
* })
* const signature = await signEip712Transaction(client, {
* to: '0x0000000000000000000000000000000000000000',
* value: 1n,
* })
*/
export async function signEip712Transaction(client, args) {
const { account: account_ = client.account, chain = client.chain, ...transaction } = args;
const account = account_ ? parseAccount(account_) : client.account;
if (!account)
throw new AccountNotFoundError({
docsPath: '/docs/actions/wallet/signTransaction',
});
assertEip712Request({
account,
chain,
...args,
});
if (!chain?.custom?.getEip712Domain)
throw new BaseError('`getEip712Domain` not found on chain.');
if (!chain?.serializers?.transaction)
throw new BaseError('transaction serializer not found on chain.');
const chainId = await getAction(client, getChainId, 'getChainId')({});
if (chain !== null)
assertCurrentChain({
currentChainId: chainId,
chain: chain,
});
const eip712Domain = chain?.custom.getEip712Domain({
...transaction,
chainId,
from: account.address,
type: 'eip712',
});
const customSignature = await signTypedData(client, {
...eip712Domain,
account,
});
return chain?.serializers?.transaction({
chainId,
...transaction,
customSignature,
type: 'eip712',
}, { r: '0x0', s: '0x0', v: 0n });
}
//# sourceMappingURL=signEip712Transaction.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"signEip712Transaction.js","sourceRoot":"","sources":["../../../zksync/actions/signEip712Transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAA;AAK/D,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAA;AAGrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAOhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAGpD,OAAO,EAEL,mBAAmB,GACpB,MAAM,iCAAiC,CAAA;AA2BxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAKzC,MAAyC,EACzC,IAAoE;IAEpE,MAAM,EACJ,OAAO,EAAE,QAAQ,GAAG,MAAM,CAAC,OAAO,EAClC,KAAK,GAAG,MAAM,CAAC,KAAK,EACpB,GAAG,WAAW,EACf,GAAG,IAAI,CAAA;IAER,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAA;IAElE,IAAI,CAAC,OAAO;QACV,MAAM,IAAI,oBAAoB,CAAC;YAC7B,QAAQ,EAAE,sCAAsC;SACjD,CAAC,CAAA;IAEJ,mBAAmB,CAAC;QAClB,OAAO;QACP,KAAK;QACL,GAAI,IAAsC;KAC3C,CAAC,CAAA;IAEF,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,eAAe;QACjC,MAAM,IAAI,SAAS,CAAC,uCAAuC,CAAC,CAAA;IAC9D,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,WAAW;QAClC,MAAM,IAAI,SAAS,CAAC,4CAA4C,CAAC,CAAA;IAEnE,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAA;IACrE,IAAI,KAAK,KAAK,IAAI;QAChB,kBAAkB,CAAC;YACjB,cAAc,EAAE,OAAO;YACvB,KAAK,EAAE,KAAK;SACb,CAAC,CAAA;IAEJ,MAAM,YAAY,GAAG,KAAK,EAAE,MAAM,CAAC,eAAe,CAAC;QACjD,GAAG,WAAW;QACd,OAAO;QACP,IAAI,EAAE,OAAO,CAAC,OAAO;QACrB,IAAI,EAAE,QAAQ;KACf,CAAC,CAAA;IAEF,MAAM,eAAe,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE;QAClD,GAAG,YAAY;QACf,OAAO;KACR,CAAC,CAAA;IAEF,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,CACpC;QACE,OAAO;QACP,GAAG,WAAW;QACd,eAAe;QACf,IAAI,EAAE,QAAe;KACtB,EACD,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CACK,CAAA;AACtC,CAAC"}

View File

@@ -0,0 +1,49 @@
import { signTransaction as signTransaction_ } from '../../actions/wallet/signTransaction.js';
import { isEIP712Transaction } from '../utils/isEip712Transaction.js';
import { signEip712Transaction } from './signEip712Transaction.js';
/**
* Signs a transaction.
*
* - Docs: https://viem.sh/docs/zksync/actions/signTransaction
*
* @param args - {@link SignTransactionParameters}
* @returns The signed serialized transaction. {@link SignTransactionReturnType}
*
* @example
* import { createWalletClient, custom } from 'viem'
* import { zksync } from 'viem/chains'
* import { signTransaction } from 'viem/zksync'
*
* const client = createWalletClient({
* chain: zksync,
* transport: custom(window.ethereum),
* })
* const signature = await signTransaction(client, {
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
* to: '0x0000000000000000000000000000000000000000',
* value: 1n,
* })
*
* @example
* // Account Hoisting
* import { createWalletClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { zksync } from 'viem/chains'
* import { signTransaction } from 'viem/zksync'
*
* const client = createWalletClient({
* account: privateKeyToAccount('0x…'),
* chain: zksync,
* transport: custom(window.ethereum),
* })
* const signature = await signTransaction(client, {
* to: '0x0000000000000000000000000000000000000000',
* value: 1n,
* })
*/
export async function signTransaction(client, args) {
if (isEIP712Transaction(args))
return signEip712Transaction(client, args);
return await signTransaction_(client, args);
}
//# sourceMappingURL=signTransaction.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"signTransaction.js","sourceRoot":"","sources":["../../../zksync/actions/signTransaction.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,IAAI,gBAAgB,EAAE,MAAM,yCAAyC,CAAA;AAW7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AA2BlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAKnC,MAAyC,EACzC,IAA8D;IAE9D,IAAI,mBAAmB,CAAC,IAAI,CAAC;QAAE,OAAO,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACzE,OAAO,MAAM,gBAAgB,CAAC,MAAM,EAAE,IAAW,CAAC,CAAA;AACpD,CAAC"}

164
node_modules/viem/_esm/zksync/actions/withdraw.js generated vendored Normal file
View File

@@ -0,0 +1,164 @@
import { parseAbi } from 'abitype';
import { readContract } from '../../actions/public/readContract.js';
import { AccountNotFoundError } from '../../errors/account.js';
import { ClientChainNotConfiguredError } from '../../errors/chain.js';
import { encodeAbiParameters, encodeFunctionData, isAddressEqual, keccak256, parseAccount, } from '../../utils/index.js';
import { ethTokenAbi, l2SharedBridgeAbi } from '../constants/abis.js';
import { ethAddressInContracts, l2AssetRouterAddress, l2BaseTokenAddress, l2NativeTokenVaultAddress, legacyEthAddress, } from '../constants/address.js';
import { getDefaultBridgeAddresses } from './getDefaultBridgeAddresses.js';
import { getL1ChainId } from './getL1ChainId.js';
import { getL2TokenAddress } from './getL2TokenAddress.js';
import { sendTransaction, } from './sendTransaction.js';
/**
* Initiates the withdrawal process which withdraws ETH or any ERC20 token
* from the associated account on L2 network to the target account on L1 network.
*
* @param client - Client to use
* @param parameters - {@link WithdrawParameters}
* @returns hash - The [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash. {@link WithdrawReturnType}
*
*
* @example
* import { createPublicClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { zksync } from 'viem/chains'
* import { withdraw, legacyEthAddress } from 'viem/zksync'
*
* const client = createPublicClient({
* chain: zksync,
* transport: http(),
* })
*
* const hash = await withdraw(client, {
* account: privateKeyToAccount('0x…'),
* amount: 1_000_000_000_000_000_000n,
* token: legacyEthAddress,
* })
*
* @example Account Hoisting
* import { createPublicClient, createWalletClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { zksync } from 'viem/chains'
* import { withdraw, legacyEthAddress } from 'viem/zksync'
*
* const client = createWalletClient({
* account: privateKeyToAccount('0x…'),
* chain: zksync,
* transport: http(),
* })
*
* const hash = await withdraw(client, {
* amount: 1_000_000_000_000_000_000n,
* token: legacyEthAddress,
* })
*
* @example Paymaster
* import { createPublicClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { zksync } from 'viem/chains'
* import {
* withdraw,
* legacyEthAddress,
* getApprovalBasedPaymasterInput
* } from 'viem/zksync'
*
* const client = createPublicClient({
* chain: zksync,
* transport: http(),
* })
*
* const hash = await withdraw(client, {
* account: privateKeyToAccount('0x…'),
* amount: 1_000_000_000_000_000_000n,
* token: legacyEthAddress,
* paymaster: '0x0EEc6f45108B4b806e27B81d9002e162BD910670',
* paymasterInput: getApprovalBasedPaymasterInput({
* minAllowance: 1n,
* token: '0x2dc3685cA34163952CF4A5395b0039c00DFa851D',
* innerInput: new Uint8Array(),
* }),
* })
*/
export async function withdraw(client, parameters) {
let { account: account_ = client.account, chain: chain_ = client.chain, token = l2BaseTokenAddress, to, amount, bridgeAddress, ...rest } = parameters;
const account = account_ ? parseAccount(account_) : client.account;
if (!account)
throw new AccountNotFoundError({
docsPath: '/docs/actions/wallet/sendTransaction',
});
if (!to)
to = account.address;
let data;
let contract;
let value = 0n;
if (isAddressEqual(token, legacyEthAddress) ||
isAddressEqual(token, ethAddressInContracts))
token = await getL2TokenAddress(client, { token: ethAddressInContracts });
if (isAddressEqual(token, l2BaseTokenAddress)) {
data = encodeFunctionData({
abi: ethTokenAbi,
functionName: 'withdraw',
args: [to],
});
value = amount;
contract = l2BaseTokenAddress;
}
else {
const assetId = await readContract(client, {
address: l2NativeTokenVaultAddress,
abi: parseAbi(['function assetId(address token) view returns (bytes32)']),
functionName: 'assetId',
args: [token],
});
const originChainId = await readContract(client, {
address: l2NativeTokenVaultAddress,
abi: parseAbi([
'function originChainId(bytes32 assetId) view returns (uint256)',
]),
functionName: 'originChainId',
args: [assetId],
});
const l1ChainId = await getL1ChainId(client);
const isTokenL1Native = originChainId === BigInt(l1ChainId) || token === ethAddressInContracts;
if (!bridgeAddress) {
// If the legacy L2SharedBridge is deployed we use it for l1 native tokens.
bridgeAddress = isTokenL1Native
? (await getDefaultBridgeAddresses(client)).sharedL2
: l2AssetRouterAddress;
}
// For non L1 native tokens we need to use the AssetRouter.
// For L1 native tokens we can use the legacy withdraw method.
if (!isTokenL1Native) {
contract = l2AssetRouterAddress;
if (!chain_)
throw new ClientChainNotConfiguredError();
const chainId = chain_.id;
const assetId = keccak256(encodeAbiParameters([{ type: 'uint256' }, { type: 'address' }, { type: 'address' }], [BigInt(chainId), l2NativeTokenVaultAddress, token]));
const assetData = encodeAbiParameters([{ type: 'uint256' }, { type: 'address' }, { type: 'address' }], [BigInt(amount), to, token]);
data = encodeFunctionData({
abi: parseAbi([
'function withdraw(bytes32 _assetId, bytes _transferData)',
]),
functionName: 'withdraw',
args: [assetId, assetData],
});
}
else {
contract = bridgeAddress;
data = encodeFunctionData({
abi: l2SharedBridgeAbi,
functionName: 'withdraw',
args: [to, token, amount],
});
}
}
return await sendTransaction(client, {
chain: chain_,
account,
to: contract,
data,
value,
...rest,
});
}
//# sourceMappingURL=withdraw.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"withdraw.js","sourceRoot":"","sources":["../../../zksync/actions/withdraw.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AAGnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAA;AAKrE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,SAAS,EACT,YAAY,GACb,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACrE,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,EACzB,gBAAgB,GACjB,MAAM,yBAAyB,CAAA;AAGhC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AA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E,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAC/D,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,yBAAyB,EAAE,KAAK,CAAC,CACpD,CACF,CAAA;YACD,MAAM,SAAS,GAAG,mBAAmB,CACnC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAC/D,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,CAC5B,CAAA;YACD,IAAI,GAAG,kBAAkB,CAAC;gBACxB,GAAG,EAAE,QAAQ,CAAC;oBACZ,0DAA0D;iBAC3D,CAAC;gBACF,YAAY,EAAE,UAAU;gBACxB,IAAI,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC;aAC3B,CAAC,CAAA;QACJ,CAAC;aAAM,CAAC;YACN,QAAQ,GAAG,aAAa,CAAA;YACxB,IAAI,GAAG,kBAAkB,CAAC;gBACxB,GAAG,EAAE,iBAAiB;gBACtB,YAAY,EAAE,UAAU;gBACxB,IAAI,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC;aAC1B,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,OAAO,MAAM,eAAe,CAAC,MAAM,EAAE;QACnC,KAAK,EAAE,MAAM;QACb,OAAO;QACP,EAAE,EAAE,QAAQ;QACZ,IAAI;QACJ,KAAK;QACL,GAAG,IAAI;KACqB,CAAC,CAAA;AACjC,CAAC"}

12
node_modules/viem/_esm/zksync/chainConfig.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
import { formatters } from './formatters.js';
import { serializers } from './serializers.js';
import { getEip712Domain } from './utils/getEip712Domain.js';
export const chainConfig = {
blockTime: 1_000,
formatters,
serializers,
custom: {
getEip712Domain,
},
};
//# sourceMappingURL=chainConfig.js.map

1
node_modules/viem/_esm/zksync/chainConfig.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"chainConfig.js","sourceRoot":"","sources":["../../zksync/chainConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE5D,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,SAAS,EAAE,KAAK;IAChB,UAAU;IACV,WAAW;IACX,MAAM,EAAE;QACN,eAAe;KAChB;CACO,CAAA"}

9
node_modules/viem/_esm/zksync/chains.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
// biome-ignore lint/performance/noBarrelFile: entrypoint module
export { zksync } from '../chains/definitions/zksync.js';
export { zksyncInMemoryNode } from '../chains/definitions/zksyncInMemoryNode.js';
export { zksyncLocalCustomHyperchain } from '../chains/definitions/zksyncLocalCustomHyperchain.js';
export { zksyncLocalHyperchain } from '../chains/definitions/zksyncLocalHyperchain.js';
export { zksyncLocalHyperchainL1 } from '../chains/definitions/zksyncLocalHyperchainL1.js';
export { zksyncLocalNode } from '../chains/definitions/zksyncLocalNode.js';
export { zksyncSepoliaTestnet } from '../chains/definitions/zksyncSepoliaTestnet.js';
//# sourceMappingURL=chains.js.map

1
node_modules/viem/_esm/zksync/chains.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"chains.js","sourceRoot":"","sources":["../../zksync/chains.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAA;AAChF,OAAO,EAAE,2BAA2B,EAAE,MAAM,sDAAsD,CAAA;AAClG,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAA;AACtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,kDAAkD,CAAA;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAA;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAA"}

4653
node_modules/viem/_esm/zksync/constants/abis.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

1
node_modules/viem/_esm/zksync/constants/abis.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

14
node_modules/viem/_esm/zksync/constants/address.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
export const contractDeployerAddress = '0x0000000000000000000000000000000000008006';
export const contract2FactoryAddress = '0x0000000000000000000000000000000000010000';
/** The address of the L1 `ETH` token. */
export const legacyEthAddress = '0x0000000000000000000000000000000000000000';
export const ethAddressInContracts = '0x0000000000000000000000000000000000000001';
/** The address of the base token. */
export const l2BaseTokenAddress = '0x000000000000000000000000000000000000800a';
export const l1MessengerAddress = '0x0000000000000000000000000000000000008008';
export const l1ToL2AliasOffset = '0x1111000000000000000000000000000000001111';
export const l2AssetRouterAddress = '0x0000000000000000000000000000000000010003';
export const l2NativeTokenVaultAddress = '0x0000000000000000000000000000000000010004';
export const bootloaderFormalAddress = '0x0000000000000000000000000000000000008001';
export const addressModulo = 2n ** 160n;
//# sourceMappingURL=address.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../../zksync/constants/address.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAClC,4CAAqD,CAAA;AAEvD,MAAM,CAAC,MAAM,uBAAuB,GAClC,4CAAqD,CAAA;AAEvD,yCAAyC;AACzC,MAAM,CAAC,MAAM,gBAAgB,GAC3B,4CAAqD,CAAA;AAEvD,MAAM,CAAC,MAAM,qBAAqB,GAChC,4CAAqD,CAAA;AAEvD,qCAAqC;AACrC,MAAM,CAAC,MAAM,kBAAkB,GAC7B,4CAAqD,CAAA;AAEvD,MAAM,CAAC,MAAM,kBAAkB,GAC7B,4CAAqD,CAAA;AAEvD,MAAM,CAAC,MAAM,iBAAiB,GAC5B,4CAAqD,CAAA;AAEvD,MAAM,CAAC,MAAM,oBAAoB,GAC/B,4CAAqD,CAAA;AAEvD,MAAM,CAAC,MAAM,yBAAyB,GACpC,4CAAqD,CAAA;AAEvD,MAAM,CAAC,MAAM,uBAAuB,GAClC,4CAAqD,CAAA;AAEvD,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,IAAI,IAAI,CAAA"}

2
node_modules/viem/_esm/zksync/constants/contract.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export const accountAbstractionVersion1 = 1;
//# sourceMappingURL=contract.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../zksync/constants/contract.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAA"}

5
node_modules/viem/_esm/zksync/constants/number.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import { maxUint16 } from '../../constants/number.js';
export const gasPerPubdataDefault = 50000n;
export const maxBytecodeSize = maxUint16 * 32n;
export const requiredL1ToL2GasPerPubdataLimit = 800n;
//# sourceMappingURL=number.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"number.js","sourceRoot":"","sources":["../../../zksync/constants/number.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAErD,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAA;AAC1C,MAAM,CAAC,MAAM,eAAe,GAAG,SAAS,GAAG,GAAG,CAAA;AAC9C,MAAM,CAAC,MAAM,gCAAgC,GAAG,IAAI,CAAA"}

15
node_modules/viem/_esm/zksync/decorators/eip712.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import { writeContract } from '../../actions/wallet/writeContract.js';
import { deployContract, } from '../actions/deployContract.js';
import { sendTransaction, } from '../actions/sendTransaction.js';
import { signTransaction, } from '../actions/signTransaction.js';
export function eip712WalletActions() {
return (client) => ({
sendTransaction: (args) => sendTransaction(client, args),
signTransaction: (args) => signTransaction(client, args),
deployContract: (args) => deployContract(client, args),
writeContract: (args) => writeContract(Object.assign(client, {
sendTransaction: (args) => sendTransaction(client, args),
}), args),
});
}
//# sourceMappingURL=eip712.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"eip712.js","sourceRoot":"","sources":["../../../zksync/decorators/eip712.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAA;AAKrE,OAAO,EAGL,cAAc,GACf,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAGL,eAAe,GAChB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAGL,eAAe,GAChB,MAAM,+BAA+B,CAAA;AAoMtC,MAAM,UAAU,mBAAmB;IACjC,OAAO,CAKL,MAAyC,EACJ,EAAE,CAAC,CAAC;QACzC,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC;QACxD,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC;QACxD,cAAc,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC;QACtD,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE,CACtB,aAAa,CACX,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;YACpB,eAAe,EAAE,CAAC,IAAS,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC;SAC9D,CAAC,EACF,IAAI,CACL;KACJ,CAAC,CAAA;AACJ,CAAC"}

14
node_modules/viem/_esm/zksync/decorators/publicL1.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
import { getL1Allowance, } from '../actions/getL1Allowance.js';
import { getL1Balance, } from '../actions/getL1Balance.js';
import { getL1TokenBalance, } from '../actions/getL1TokenBalance.js';
import { isWithdrawalFinalized, } from '../actions/isWithdrawalFinalized.js';
export function publicActionsL1() {
return (client) => ({
getL1Allowance: (args) => getL1Allowance(client, args),
getL1TokenBalance: (args) => getL1TokenBalance(client, args),
// @ts-expect-error
getL1Balance: (args) => getL1Balance(client, args),
isWithdrawalFinalized: (args) => isWithdrawalFinalized(client, args),
});
}
//# sourceMappingURL=publicL1.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"publicL1.js","sourceRoot":"","sources":["../../../zksync/decorators/publicL1.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,cAAc,GACf,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAGL,YAAY,GACb,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAGL,iBAAiB,GAClB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAGL,qBAAqB,GACtB,MAAM,qCAAqC,CAAA;AAmL5C,MAAM,UAAU,eAAe;IAC7B,OAAO,CAIL,MAAyC,EACf,EAAE,CAAC,CAAC;QAC9B,cAAc,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC;QACtD,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC;QAC5D,mBAAmB;QACnB,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC;QAClD,qBAAqB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC;KACrE,CAAC,CAAA;AACJ,CAAC"}

45
node_modules/viem/_esm/zksync/decorators/publicL2.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
import { estimateFee } from '../actions/estimateFee.js';
import { estimateGasL1ToL2, } from '../actions/estimateGasL1ToL2.js';
import { getAllBalances, } from '../actions/getAllBalances.js';
import { getBaseTokenL1Address, } from '../actions/getBaseTokenL1Address.js';
import { getBlockDetails, } from '../actions/getBlockDetails.js';
import { getBridgehubContractAddress, } from '../actions/getBridgehubContractAddress.js';
import { getDefaultBridgeAddresses, } from '../actions/getDefaultBridgeAddresses.js';
import { getGasPerPubdata, } from '../actions/getGasPerPubdata.js';
import { getL1BatchBlockRange, } from '../actions/getL1BatchBlockRange.js';
import { getL1BatchDetails, } from '../actions/getL1BatchDetails.js';
import { getL1BatchNumber, } from '../actions/getL1BatchNumber.js';
import { getL1ChainId, } from '../actions/getL1ChainId.js';
import { getL1TokenAddress, } from '../actions/getL1TokenAddress.js';
import { getL2TokenAddress, } from '../actions/getL2TokenAddress.js';
import { getLogProof, } from '../actions/getLogProof.js';
import { getMainContractAddress, } from '../actions/getMainContractAddress.js';
import { getRawBlockTransactions, } from '../actions/getRawBlockTransactions.js';
import { getTestnetPaymasterAddress, } from '../actions/getTestnetPaymasterAddress.js';
import { getTransactionDetails, } from '../actions/getTransactionDetails.js';
export function publicActionsL2() {
return (client) => {
return {
estimateGasL1ToL2: (args) => estimateGasL1ToL2(client, args),
getDefaultBridgeAddresses: () => getDefaultBridgeAddresses(client),
getTestnetPaymasterAddress: () => getTestnetPaymasterAddress(client),
getL1ChainId: () => getL1ChainId(client),
getMainContractAddress: () => getMainContractAddress(client),
getAllBalances: (args) => getAllBalances(client, args),
getRawBlockTransaction: (args) => getRawBlockTransactions(client, args),
getBlockDetails: (args) => getBlockDetails(client, args),
getL1BatchDetails: (args) => getL1BatchDetails(client, args),
getL1BatchBlockRange: (args) => getL1BatchBlockRange(client, args),
getL1BatchNumber: () => getL1BatchNumber(client),
getLogProof: (args) => getLogProof(client, args),
getTransactionDetails: (args) => getTransactionDetails(client, args),
estimateFee: (args) => estimateFee(client, args),
getBridgehubContractAddress: () => getBridgehubContractAddress(client),
getBaseTokenL1Address: () => getBaseTokenL1Address(client),
getL2TokenAddress: (args) => getL2TokenAddress(client, args),
getL1TokenAddress: (args) => getL1TokenAddress(client, args),
getGasPerPubdata: () => getGasPerPubdata(client),
};
};
}
//# sourceMappingURL=publicL2.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"publicL2.js","sourceRoot":"","sources":["../../../zksync/decorators/publicL2.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAGL,iBAAiB,GAClB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAGL,cAAc,GACf,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAEL,qBAAqB,GACtB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAGL,eAAe,GAChB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAEL,2BAA2B,GAC5B,MAAM,2CAA2C,CAAA;AAClD,OAAO,EAEL,yBAAyB,GAC1B,MAAM,yCAAyC,CAAA;AAChD,OAAO,EAEL,gBAAgB,GACjB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAGL,oBAAoB,GACrB,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EAGL,iBAAiB,GAClB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAEL,gBAAgB,GACjB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAEL,YAAY,GACb,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAGL,iBAAiB,GAClB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAGL,iBAAiB,GAClB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAGL,WAAW,GACZ,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAEL,sBAAsB,GACvB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EAGL,uBAAuB,GACxB,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EAEL,0BAA0B,GAC3B,MAAM,0CAA0C,CAAA;AACjD,OAAO,EAGL,qBAAqB,GACtB,MAAM,qCAAqC,CAAA;AA0Z5C,MAAM,UAAU,eAAe;IAC7B,OAAO,CAKL,MAAyC,EACR,EAAE;QACnC,OAAO;YACL,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,C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iB,CAAC,MAAM,EAAE,IAAI,CAAC;YAC5D,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC;YAC5D,gBAAgB,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,MAAM,CAAC;SACjD,CAAA;IACH,CAAC,CAAA;AACH,CAAC"}

13
node_modules/viem/_esm/zksync/decorators/walletL1.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import { claimFailedDeposit, } from '../actions/claimFailedDeposit.js';
import { deposit, } from '../actions/deposit.js';
import { finalizeWithdrawal, } from '../actions/finalizeWithdrawal.js';
import { requestExecute, } from '../actions/requestExecute.js';
export function walletActionsL1() {
return (client) => ({
claimFailedDeposit: (args) => claimFailedDeposit(client, args),
deposit: (args) => deposit(client, args),
finalizeWithdrawal: (args) => finalizeWithdrawal(client, args),
requestExecute: (args) => requestExecute(client, args),
});
}
//# sourceMappingURL=walletL1.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"walletL1.js","sourceRoot":"","sources":["../../../zksync/decorators/walletL1.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,kBAAkB,GACnB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAGL,OAAO,GACR,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAGL,kBAAkB,GACnB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAGL,cAAc,GACf,MAAM,8BAA8B,CAAA;AA0LrC,MAAM,UAAU,eAAe;IAC7B,OAAO,CAKL,MAAyC,EACR,EAAE,CAAC,CAAC;QACrC,kBAAkB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC;QAC9D,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC;QACxC,kBAAkB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC;QAC9D,cAAc,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC;KACvD,CAAC,CAAA;AACJ,CAAC"}

7
node_modules/viem/_esm/zksync/decorators/walletL2.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
import { withdraw, } from '../actions/withdraw.js';
export function walletActionsL2() {
return (client) => ({
withdraw: (args) => withdraw(client, args),
});
}
//# sourceMappingURL=walletL2.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"walletL2.js","sourceRoot":"","sources":["../../../zksync/decorators/walletL2.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,QAAQ,GACT,MAAM,wBAAwB,CAAA;AA6E/B,MAAM,UAAU,eAAe;IAC7B,OAAO,CAKL,MAAyC,EACR,EAAE,CAAC,CAAC;QACrC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;KAC3C,CAAC,CAAA;AACJ,CAAC"}

47
node_modules/viem/_esm/zksync/errors/bridge.js generated vendored Normal file
View File

@@ -0,0 +1,47 @@
import { BaseError } from '../../errors/base.js';
export class BaseFeeHigherThanValueError extends BaseError {
constructor(baseCost, value) {
super([
'The base cost of performing the priority operation is higher than the provided transaction value parameter.',
'',
`Base cost: ${baseCost}.`,
`Provided value: ${value}.`,
].join('\n'), { name: 'BaseFeeHigherThanValueError' });
}
}
export class TxHashNotFoundInLogsError extends BaseError {
constructor() {
super('The transaction hash not found in event logs.', {
name: 'TxHashNotFoundInLogsError',
});
}
}
export class WithdrawalLogNotFoundError extends BaseError {
constructor({ hash }) {
super([
`Withdrawal log with hash ${hash} not found.`,
'',
'Either the withdrawal transaction is still processing or it did not finish successfully.',
].join('\n'), { name: 'WithdrawalLogNotFoundError' });
}
}
export class CannotClaimSuccessfulDepositError extends BaseError {
constructor({ hash }) {
super([`Cannot claim successful deposit: ${hash}.`].join('\n'), {
name: 'CannotClaimSuccessfulDepositError',
});
}
}
export class LogProofNotFoundError extends BaseError {
constructor({ hash, index }) {
super([`Log proof not found for hash ${hash} and index ${index}.`].join('\n'), { name: 'LogProofNotFoundError' });
}
}
export class L2BridgeNotFoundError extends BaseError {
constructor() {
super(['L2 bridge address not found.'].join('\n'), {
name: 'L2BridgeNotFoundError',
});
}
}
//# sourceMappingURL=bridge.js.map

1
node_modules/viem/_esm/zksync/errors/bridge.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../../zksync/errors/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAMhD,MAAM,OAAO,2BAA4B,SAAQ,SAAS;IACxD,YAAY,QAAgB,EAAE,KAAa;QACzC,KAAK,CACH;YACE,6GAA6G;YAC7G,EAAE;YACF,cAAc,QAAQ,GAAG;YACzB,mBAAmB,KAAK,GAAG;SAC5B,CAAC,IAAI,CAAC,IAAI,CAAC,EACZ,EAAE,IAAI,EAAE,6BAA6B,EAAE,CACxC,CAAA;IACH,CAAC;CACF;AAKD,MAAM,OAAO,yBAA0B,SAAQ,SAAS;IACtD;QACE,KAAK,CAAC,+CAA+C,EAAE;YACrD,IAAI,EAAE,2BAA2B;SAClC,CAAC,CAAA;IACJ,CAAC;CACF;AAKD,MAAM,OAAO,0BAA2B,SAAQ,SAAS;IACvD,YAAY,EAAE,IAAI,EAAkB;QAClC,KAAK,CACH;YACE,4BAA4B,IAAI,aAAa;YAC7C,EAAE;YACF,0FAA0F;SAC3F,CAAC,IAAI,CAAC,IAAI,CAAC,EACZ,EAAE,IAAI,EAAE,4BAA4B,EAAE,CACvC,CAAA;IACH,CAAC;CACF;AAMD,MAAM,OAAO,iCAAkC,SAAQ,SAAS;IAC9D,YAAY,EAAE,IAAI,EAAkB;QAClC,KAAK,CAAC,CAAC,oCAAoC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YAC9D,IAAI,EAAE,mCAAmC;SAC1C,CAAC,CAAA;IACJ,CAAC;CACF;AAKD,MAAM,OAAO,qBAAsB,SAAQ,SAAS;IAClD,YAAY,EAAE,IAAI,EAAE,KAAK,EAAiC;QACxD,KAAK,CACH,CAAC,gCAAgC,IAAI,cAAc,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EACvE,EAAE,IAAI,EAAE,uBAAuB,EAAE,CAClC,CAAA;IACH,CAAC;CACF;AAKD,MAAM,OAAO,qBAAsB,SAAQ,SAAS;IAClD;QACE,KAAK,CAAC,CAAC,8BAA8B,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACjD,IAAI,EAAE,uBAAuB;SAC9B,CAAC,CAAA;IACJ,CAAC;CACF"}

17
node_modules/viem/_esm/zksync/errors/bytecode.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
import { BaseError } from '../../errors/base.js';
export class BytecodeLengthExceedsMaxSizeError extends BaseError {
constructor({ givenLength, maxBytecodeSize, }) {
super(`Bytecode cannot be longer than ${maxBytecodeSize} bytes. Given length: ${givenLength}`, { name: 'BytecodeLengthExceedsMaxSizeError' });
}
}
export class BytecodeLengthInWordsMustBeOddError extends BaseError {
constructor({ givenLengthInWords }) {
super(`Bytecode length in 32-byte words must be odd. Given length in words: ${givenLengthInWords}`, { name: 'BytecodeLengthInWordsMustBeOddError' });
}
}
export class BytecodeLengthMustBeDivisibleBy32Error extends BaseError {
constructor({ givenLength }) {
super(`The bytecode length in bytes must be divisible by 32. Given length: ${givenLength}`, { name: 'BytecodeLengthMustBeDivisibleBy32Error' });
}
}
//# sourceMappingURL=bytecode.js.map

1
node_modules/viem/_esm/zksync/errors/bytecode.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"bytecode.js","sourceRoot":"","sources":["../../../zksync/errors/bytecode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAOhD,MAAM,OAAO,iCAAkC,SAAQ,SAAS;IAC9D,YAAY,EACV,WAAW,EACX,eAAe,GACkC;QACjD,KAAK,CACH,kCAAkC,eAAe,yBAAyB,WAAW,EAAE,EACvF,EAAE,IAAI,EAAE,mCAAmC,EAAE,CAC9C,CAAA;IACH,CAAC;CACF;AAOD,MAAM,OAAO,mCAAoC,SAAQ,SAAS;IAChE,YAAY,EAAE,kBAAkB,EAAkC;QAChE,KAAK,CACH,wEAAwE,kBAAkB,EAAE,EAC5F,EAAE,IAAI,EAAE,qCAAqC,EAAE,CAChD,CAAA;IACH,CAAC;CACF;AAOD,MAAM,OAAO,sCAAuC,SAAQ,SAAS;IACnE,YAAY,EAAE,WAAW,EAA2B;QAClD,KAAK,CACH,uEAAuE,WAAW,EAAE,EACpF,EAAE,IAAI,EAAE,wCAAwC,EAAE,CACnD,CAAA;IACH,CAAC;CACF"}

7
node_modules/viem/_esm/zksync/errors/token-is-eth.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
import { BaseError } from '../../errors/base.js';
export class TokenIsEthError extends BaseError {
constructor() {
super(['Token is an ETH token.', '', 'ETH token cannot be retrieved.'].join('\n'), { name: 'TokenIsEthError' });
}
}
//# sourceMappingURL=token-is-eth.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"token-is-eth.js","sourceRoot":"","sources":["../../../zksync/errors/token-is-eth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAKhD,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C;QACE,KAAK,CACH,CAAC,wBAAwB,EAAE,EAAE,EAAE,gCAAgC,CAAC,CAAC,IAAI,CACnE,IAAI,CACL,EACD,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAC5B,CAAA;IACH,CAAC;CACF"}

Some files were not shown because too many files have changed in this diff Show More