Socket
Socket
Sign inDemoInstall

zksync-web3

Package Overview
Dependencies
Maintainers
5
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zksync-web3 - npm Package Compare versions

Comparing version 0.11.0-alpha.1 to 0.11.0

3

build/src/adapters.d.ts

@@ -40,4 +40,3 @@ import { BigNumber, BigNumberish, ethers, BytesLike } from 'ethers';

_getWithdrawalLog(withdrawalHash: BytesLike, index?: number): Promise<{
log: ethers.providers.Log;
l1BatchNumber: number;
log: import("./types").Log;
l1BatchTxId: number;

@@ -44,0 +43,0 @@ }>;

@@ -135,4 +135,2 @@ "use strict";

log,
// TODO: remove `l1BatchNumber` from `return` if it will be included in the log (SMA-1205).
l1BatchNumber: receipt.l1BatchNumber,
l1BatchTxId: receipt.l1BatchTxIndex

@@ -142,3 +140,3 @@ };

async finalizeWithdrawal(withdrawalHash, index = 0) {
const { log, l1BatchNumber, l1BatchTxId } = await this._getWithdrawalLog(withdrawalHash, index);
const { log, l1BatchTxId } = await this._getWithdrawalLog(withdrawalHash, index);
const sender = ethers_1.ethers.utils.hexDataSlice(log.topics[1], 12);

@@ -149,6 +147,6 @@ const proof = await this._providerL2().getMessageProof(log.blockNumber, sender, log.topics[2], log.logIndex);

const l1Bridge = typechain_1.IL1BridgeFactory.connect(await l2Bridge.l1Bridge(), this._signerL1());
return await l1Bridge.finalizeWithdrawal(l1BatchNumber, proof.id, l1BatchTxId, message, proof.proof);
return await l1Bridge.finalizeWithdrawal(log.l1BatchNumber, proof.id, l1BatchTxId, message, proof.proof);
}
async isWithdrawalFinalized(withdrawalHash, index = 0) {
const { log, l1BatchNumber } = await this._getWithdrawalLog(withdrawalHash, index);
const { log } = await this._getWithdrawalLog(withdrawalHash, index);
const sender = ethers_1.ethers.utils.hexDataSlice(log.topics[1], 12);

@@ -161,3 +159,3 @@ // `getMessageProof` is called not to get proof but

const l1Bridge = typechain_1.IL1BridgeFactory.connect(await l2Bridge.l1Bridge(), this._providerL1());
return await l1Bridge.isWithdrawalFinalized(l1BatchNumber, proof.id);
return await l1Bridge.isWithdrawalFinalized(log.l1BatchNumber, proof.id);
}

@@ -164,0 +162,0 @@ async requestExecute(transaction) {

@@ -1,6 +0,6 @@

import { ethers, BigNumber, BigNumberish, utils, BytesLike } from 'ethers';
import { Log } from '@ethersproject/abstract-provider';
import { ethers, BigNumber, BigNumberish, utils, providers, BytesLike } from 'ethers';
import Formatter = providers.Formatter;
import { ExternalProvider } from '@ethersproject/providers';
import { ConnectionInfo } from '@ethersproject/web';
import { Address, EventFilter, BlockTag, TransactionResponse, TransactionRequest, TransactionStatus, Token, PriorityOpResponse, BalancesMap, MessageProof, TransactionReceipt } from './types';
import { Address, EventFilter, BlockTag, TransactionResponse, TransactionRequest, TransactionStatus, Token, PriorityOpResponse, BalancesMap, MessageProof, TransactionReceipt, Block, BlockWithTransactions, Log } from './types';
import { Signer } from './signer';

@@ -16,2 +16,5 @@ export declare class Provider extends ethers.providers.JsonRpcProvider {

getTransactionReceipt(transactionHash: string | Promise<string>): Promise<TransactionReceipt>;
getBlock(blockHashOrBlockTag: BlockTag | string | Promise<BlockTag | string>): Promise<Block>;
getBlockWithTransactions(blockHashOrBlockTag: BlockTag | string | Promise<BlockTag | string>): Promise<BlockWithTransactions>;
static getFormatter(): Formatter;
getBalance(address: Address, blockTag?: BlockTag, tokenAddress?: Address): Promise<ethers.BigNumber>;

@@ -27,2 +30,3 @@ l2TokenAddress(token: Address): Promise<string>;

getMessageProof(blockNumber: ethers.BigNumberish, sender: Address, messageHash: BytesLike, logIndex?: number): Promise<MessageProof | null>;
getL1BatchBlockRange(l1BatchNumber: number): Promise<[number, number] | null>;
getMainContractAddress(): Promise<Address>;

@@ -29,0 +33,0 @@ getTestnetPaymasterAddress(): Promise<Address | null>;

@@ -11,2 +11,3 @@ "use strict";

const signer_1 = require("./signer");
let defaultFormatter = null;
class Provider extends ethers_1.ethers.providers.JsonRpcProvider {

@@ -71,10 +72,2 @@ constructor(url, network) {

}
if (result.l1BatchNumber != null && result.l1BatchTxIndex != null) {
receipt.l1BatchNumber = ethers_1.BigNumber.from(result.l1BatchNumber).toNumber();
receipt.l1BatchTxIndex = ethers_1.BigNumber.from(result.l1BatchTxIndex).toNumber();
}
else {
receipt.l1BatchNumber = null;
receipt.l1BatchTxIndex = null;
}
return receipt;

@@ -84,2 +77,21 @@ }

}
async getBlock(blockHashOrBlockTag) {
return this._getBlock(blockHashOrBlockTag, false);
}
async getBlockWithTransactions(blockHashOrBlockTag) {
return this._getBlock(blockHashOrBlockTag, true);
}
static getFormatter() {
if (defaultFormatter == null) {
defaultFormatter = new Formatter();
const number = defaultFormatter.number.bind(this);
defaultFormatter.formats.receiptLog.l1BatchNumber = Formatter.allowNull(number);
defaultFormatter.formats.receipt.l1BatchNumber = Formatter.allowNull(number);
defaultFormatter.formats.receipt.l1BatchTxIndex = Formatter.allowNull(number);
defaultFormatter.formats.block.l1BatchNumber = Formatter.allowNull(number);
defaultFormatter.formats.blockWithTransactions.l1BatchNumber = Formatter.allowNull(number);
defaultFormatter.formats.filterLog.l1BatchNumber = Formatter.allowNull(number);
}
return defaultFormatter;
}
async getBalance(address, blockTag, tokenAddress) {

@@ -178,2 +190,9 @@ const tag = this.formatter.blockTag(blockTag);

}
async getL1BatchBlockRange(l1BatchNumber) {
const range = await this.send('zks_getL1BatchBlockRange', [l1BatchNumber]);
if (range == null) {
return null;
}
return [parseInt(range[0], 16), parseInt(range[1], 16)];
}
async getMainContractAddress() {

@@ -180,0 +199,0 @@ if (!this.contractAddresses.mainContract) {

@@ -103,4 +103,3 @@ import { ethers } from 'ethers';

_getWithdrawalLog(withdrawalHash: ethers.utils.BytesLike, index?: number): Promise<{
log: ethers.providers.Log;
l1BatchNumber: number;
log: import("./types").Log;
l1BatchTxId: number;

@@ -107,0 +106,0 @@ }>;

import { BytesLike, BigNumberish, providers, BigNumber } from 'ethers';
import { BlockWithTransactions as EthersBlockWithTransactions } from '@ethersproject/abstract-provider';
export declare type Address = string;

@@ -66,3 +67,13 @@ export declare type Signature = string;

l1BatchTxIndex: number;
logs: Array<Log>;
}
export interface Block extends providers.Block {
l1BatchNumber: number;
}
export interface BlockWithTransactions extends EthersBlockWithTransactions {
l1BatchNumber: number;
}
export interface Log extends providers.Log {
l1BatchNumber: number;
}
export declare type TransactionRequest = providers.TransactionRequest & {

@@ -69,0 +80,0 @@ customData?: Eip712Meta;

@@ -64,4 +64,3 @@ import { EIP712Signer } from './signer';

_getWithdrawalLog(withdrawalHash: ethers.utils.BytesLike, index?: number): Promise<{
log: ethers.providers.Log;
l1BatchNumber: number;
log: import("./types").Log;
l1BatchTxId: number;

@@ -68,0 +67,0 @@ }>;

{
"name": "zksync-web3",
"version": "0.11.0-alpha.1",
"version": "0.11.0",
"main": "build/src/index.js",

@@ -5,0 +5,0 @@ "types": "build/src/index.d.ts",

@@ -193,4 +193,2 @@ import { BigNumber, BigNumberish, ethers, BytesLike } from 'ethers';

log,
// TODO: remove `l1BatchNumber` from `return` if it will be included in the log (SMA-1205).
l1BatchNumber: receipt.l1BatchNumber,
l1BatchTxId: receipt.l1BatchTxIndex

@@ -201,3 +199,3 @@ };

async finalizeWithdrawal(withdrawalHash: BytesLike, index: number = 0) {
const { log, l1BatchNumber, l1BatchTxId } = await this._getWithdrawalLog(withdrawalHash, index);
const { log, l1BatchTxId } = await this._getWithdrawalLog(withdrawalHash, index);
const sender = ethers.utils.hexDataSlice(log.topics[1], 12);

@@ -214,7 +212,7 @@ const proof = await this._providerL2().getMessageProof(

const l1Bridge = IL1BridgeFactory.connect(await l2Bridge.l1Bridge(), this._signerL1());
return await l1Bridge.finalizeWithdrawal(l1BatchNumber, proof.id, l1BatchTxId, message, proof.proof);
return await l1Bridge.finalizeWithdrawal(log.l1BatchNumber, proof.id, l1BatchTxId, message, proof.proof);
}
async isWithdrawalFinalized(withdrawalHash: BytesLike, index: number = 0) {
const { log, l1BatchNumber } = await this._getWithdrawalLog(withdrawalHash, index);
const { log } = await this._getWithdrawalLog(withdrawalHash, index);
const sender = ethers.utils.hexDataSlice(log.topics[1], 12);

@@ -233,3 +231,3 @@ // `getMessageProof` is called not to get proof but

return await l1Bridge.isWithdrawalFinalized(l1BatchNumber, proof.id);
return await l1Bridge.isWithdrawalFinalized(log.l1BatchNumber, proof.id);
}

@@ -236,0 +234,0 @@

import { ethers, BigNumber, BigNumberish, utils, providers, BytesLike } from 'ethers';
import Formatter = providers.Formatter;
import { Log } from '@ethersproject/abstract-provider';
import { ExternalProvider } from '@ethersproject/providers';

@@ -18,3 +17,6 @@ import { ConnectionInfo, poll } from '@ethersproject/web';

MessageProof,
TransactionReceipt
TransactionReceipt,
Block,
BlockWithTransactions,
Log
} from './types';

@@ -24,2 +26,4 @@ import { sleep, parseTransaction, ETH_ADDRESS, isETH, getL2HashFromPriorityOp, EIP712_TX_TYPE } from './utils';

let defaultFormatter: Formatter = null;
export class Provider extends ethers.providers.JsonRpcProvider {

@@ -85,9 +89,2 @@ protected contractAddresses: {

}
if (result.l1BatchNumber != null && result.l1BatchTxIndex != null) {
receipt.l1BatchNumber = BigNumber.from(result.l1BatchNumber).toNumber();
receipt.l1BatchTxIndex = BigNumber.from(result.l1BatchTxIndex).toNumber();
} else {
receipt.l1BatchNumber = null;
receipt.l1BatchTxIndex = null;
}
return receipt;

@@ -100,2 +97,30 @@ }

override async getBlock(blockHashOrBlockTag: BlockTag | string | Promise<BlockTag | string>): Promise<Block> {
return <Promise<Block>>this._getBlock(blockHashOrBlockTag, false);
}
override async getBlockWithTransactions(
blockHashOrBlockTag: BlockTag | string | Promise<BlockTag | string>
): Promise<BlockWithTransactions> {
return <Promise<BlockWithTransactions>>this._getBlock(blockHashOrBlockTag, true);
}
static override getFormatter(): Formatter {
if (defaultFormatter == null) {
defaultFormatter = new Formatter();
const number = defaultFormatter.number.bind(this);
defaultFormatter.formats.receiptLog.l1BatchNumber = Formatter.allowNull(number);
defaultFormatter.formats.receipt.l1BatchNumber = Formatter.allowNull(number);
defaultFormatter.formats.receipt.l1BatchTxIndex = Formatter.allowNull(number);
defaultFormatter.formats.block.l1BatchNumber = Formatter.allowNull(number);
defaultFormatter.formats.blockWithTransactions.l1BatchNumber = Formatter.allowNull(number);
defaultFormatter.formats.filterLog.l1BatchNumber = Formatter.allowNull(number);
}
return defaultFormatter;
}
override async getBalance(address: Address, blockTag?: BlockTag, tokenAddress?: Address) {

@@ -219,2 +244,10 @@ const tag = this.formatter.blockTag(blockTag);

async getL1BatchBlockRange(l1BatchNumber: number): Promise<[number, number] | null> {
const range = await this.send('zks_getL1BatchBlockRange', [l1BatchNumber]);
if (range == null) {
return null;
}
return [parseInt(range[0], 16), parseInt(range[1], 16)];
}
async getMainContractAddress(): Promise<Address> {

@@ -221,0 +254,0 @@ if (!this.contractAddresses.mainContract) {

import { BytesLike, BigNumberish, providers, BigNumber } from 'ethers';
import { BlockWithTransactions as EthersBlockWithTransactions } from '@ethersproject/abstract-provider';

@@ -92,4 +93,17 @@ // 0x-prefixed, hex encoded, ethereum account address

l1BatchTxIndex: number;
logs: Array<Log>;
}
export interface Block extends providers.Block {
l1BatchNumber: number;
}
export interface BlockWithTransactions extends EthersBlockWithTransactions {
l1BatchNumber: number;
}
export interface Log extends providers.Log {
l1BatchNumber: number;
}
export type TransactionRequest = providers.TransactionRequest & { customData?: Eip712Meta };

@@ -96,0 +110,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc