diff --git a/src/main/java/io/zksync/methods/response/ZksGetBaseTokenContractAddress.java b/src/main/java/io/zksync/methods/response/ZksGetBaseTokenContractAddress.java new file mode 100644 index 0000000..5d61142 --- /dev/null +++ b/src/main/java/io/zksync/methods/response/ZksGetBaseTokenContractAddress.java @@ -0,0 +1,6 @@ +package io.zksync.methods.response; + +import org.web3j.protocol.core.Response; + +public class ZksGetBaseTokenContractAddress extends Response { +} diff --git a/src/main/java/io/zksync/methods/response/ZksGetBridgehubContract.java b/src/main/java/io/zksync/methods/response/ZksGetBridgehubContract.java new file mode 100644 index 0000000..c7eeb7d --- /dev/null +++ b/src/main/java/io/zksync/methods/response/ZksGetBridgehubContract.java @@ -0,0 +1,6 @@ +package io.zksync.methods.response; + +import org.web3j.protocol.core.Response; + +public class ZksGetBridgehubContract extends Response { +} diff --git a/src/main/java/io/zksync/protocol/JsonRpc2_0ZkSync.java b/src/main/java/io/zksync/protocol/JsonRpc2_0ZkSync.java index 8b2de65..8ab4eab 100755 --- a/src/main/java/io/zksync/protocol/JsonRpc2_0ZkSync.java +++ b/src/main/java/io/zksync/protocol/JsonRpc2_0ZkSync.java @@ -13,16 +13,19 @@ import io.zksync.transaction.type.TransferTransaction; import io.zksync.transaction.type.WithdrawTransaction; import io.zksync.utils.TransactionStatus; +import io.zksync.utils.WalletUtils; import io.zksync.utils.ZkSyncAddresses; import io.zksync.wrappers.ERC20; import io.zksync.wrappers.IEthToken; import io.zksync.wrappers.IL2Bridge; import org.jetbrains.annotations.Nullable; +import org.web3j.abi.FunctionEncoder; +import org.web3j.abi.TypeReference; +import org.web3j.abi.datatypes.Address; +import org.web3j.abi.datatypes.Function; +import org.web3j.abi.datatypes.Type; import org.web3j.protocol.Web3jService; -import org.web3j.protocol.core.DefaultBlockParameter; -import org.web3j.protocol.core.DefaultBlockParameterName; -import org.web3j.protocol.core.JsonRpc2_0Web3j; -import org.web3j.protocol.core.Request; +import org.web3j.protocol.core.*; import org.web3j.protocol.core.methods.request.EthFilter; import org.web3j.protocol.core.methods.response.EthEstimateGas; import org.web3j.protocol.core.methods.response.Log; @@ -31,6 +34,8 @@ import org.web3j.tx.gas.ContractGasProvider; import org.web3j.utils.Numeric; +import static io.zksync.wrappers.IL2Bridge.FUNC_WITHDRAW; + public class JsonRpc2_0ZkSync extends JsonRpc2_0Web3j implements ZkSync { public static final int DEFAULT_BLOCK_COMMIT_TIME = 800; @@ -50,6 +55,11 @@ public Request zksMainContract() { return new Request<>("zks_getMainContract", Collections.emptyList(), web3jService, ZksMainContract.class); } + @Override + public Request zksGetBridgehubContract() { + return new Request<>("zks_getBridgehubContract", Collections.emptyList(), web3jService, ZksGetBridgehubContract.class); + } + @Override public Request zksGetConfirmedTokens(Integer from, Short limit) { return new Request<>( @@ -89,6 +99,21 @@ public Request zksGetBridgeContracts() { return new Request<>("zks_getBridgeContracts", Collections.emptyList(), web3jService, ZksBridgeAddresses.class); } + @Override + public Request zksGetBaseTokenContractAddress() { + return new Request<>("zks_getBaseTokenL1Address", Collections.emptyList(), web3jService, ZksGetBaseTokenContractAddress.class); + } + @Override + public boolean isEthBasedChain() { + String baseTokenAddress = zksGetBaseTokenContractAddress().sendAsync().join().getResult(); + return ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS.equalsIgnoreCase(baseTokenAddress); + } + @Override + public boolean isBaseToken(String tokenAddress) { + String baseTokenAddress = zksGetBaseTokenContractAddress().sendAsync().join().getResult(); + return tokenAddress.equalsIgnoreCase(baseTokenAddress) || tokenAddress.equalsIgnoreCase(ZkSyncAddresses.L2_BASE_TOKEN_ADDRESS); + } + @Override public Request zksGetL2ToL1MsgProof(Integer block, String sender, String message, @Nullable Long l2LogPosition) { return new Request<>("zks_getL2ToL1MsgProof", Arrays.asList(block, sender, message), web3jService, ZksMessageProof.class); @@ -162,6 +187,23 @@ public Request estimateGasL1(Transaction transaction) { EthEstimateGas.class); } + public String l2TokenAddress(String tokenAddress){ + if (tokenAddress.equalsIgnoreCase(ZkSyncAddresses.LEGACY_ETH_ADDRESS)){ + tokenAddress = ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS; + } + + String baseToken = zksGetBaseTokenContractAddress().sendAsync().join().getResult(); + if (baseToken.equalsIgnoreCase(tokenAddress)){ + return ZkSyncAddresses.L2_BASE_TOKEN_ADDRESS; + } + + BridgeAddresses bridgeAddresses = zksGetBridgeContracts().sendAsync().join().getResult(); + BigInteger gas = ethGasPrice().sendAsync().join().getGasPrice(); + IL2Bridge shared = IL2Bridge.load(bridgeAddresses.getL2SharedDefaultBridge(), this, WalletUtils.createRandomCredentials(), gas, gas); + + return shared.l2TokenAddress(tokenAddress).sendAsync().join(); + } + public Request estimateL1ToL2Execute(String contractAddress, byte[] calldata, String caller, @Nullable BigInteger l2GasLimit, @Nullable BigInteger l2Value, @Nullable byte[][] factoryDeps, @Nullable BigInteger operatorTip, @Nullable BigInteger gasPerPubDataByte, @Nullable String refoundRecepient) { if (gasPerPubDataByte == null){ gasPerPubDataByte = BigInteger.valueOf(800); @@ -176,6 +218,22 @@ public Request estimateL1ToL2Execute(String contractAddress, } public Transaction getWithdrawTransaction(WithdrawTransaction tx, ContractGasProvider gasProvider, TransactionManager transactionManager) throws Exception { + boolean isEthBasedChain = isEthBasedChain(); + + if (tx.tokenAddress != null && + !tx.tokenAddress.isEmpty() && + tx.tokenAddress.equalsIgnoreCase(ZkSyncAddresses.LEGACY_ETH_ADDRESS) && + !isEthBasedChain){ + tx.tokenAddress = l2TokenAddress(ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS); + } else if (tx.tokenAddress == null || + tx.tokenAddress.isEmpty() || + isBaseToken(tx.tokenAddress)){ + tx.tokenAddress = ZkSyncAddresses.L2_BASE_TOKEN_ADDRESS; + } + + if (tx.tokenAddress.equalsIgnoreCase(ZkSyncAddresses.LEGACY_ETH_ADDRESS)){ + tx.tokenAddress = ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS; + } if (tx.from == null && tx.to == null){ throw new Error("Withdrawal target address is undefined!"); } @@ -183,7 +241,7 @@ public Transaction getWithdrawTransaction(WithdrawTransaction tx, ContractGasPro tx.to = tx.to == null ? tx.from : tx.to; tx.options = tx.options == null ? new TransactionOptions() : tx.options; - if (tx.tokenAddress == ZkSyncAddresses.ETH_ADDRESS){ + if (ZkSyncAddresses.isEth(tx.tokenAddress)){ if (tx.options.getValue() == null){ tx.options.setValue(tx.amount); } @@ -202,23 +260,34 @@ public Transaction getWithdrawTransaction(WithdrawTransaction tx, ContractGasPro } if (tx.bridgeAddress == null){ BridgeAddresses bridgeAddresses = zksGetBridgeContracts().sendAsync().join().getResult(); - IL2Bridge l2WethBridge = IL2Bridge.load(bridgeAddresses.getL2wETHBridge(), this, transactionManager, gasProvider); - - String l1WethToken = ZkSyncAddresses.ETH_ADDRESS; - try{ - l1WethToken = l2WethBridge.l1TokenAddress(tx.tokenAddress).sendAsync().join(); - }catch (Exception e){} - - tx.bridgeAddress = l1WethToken != ZkSyncAddresses.ETH_ADDRESS ? bridgeAddresses.getL2wETHBridge() : bridgeAddresses.getL2Erc20DefaultBridge(); + tx.bridgeAddress = bridgeAddresses.getL2SharedDefaultBridge(); } - IL2Bridge bridge = IL2Bridge.load(tx.bridgeAddress, this, transactionManager, gasProvider); - String data = bridge.encodeWithdraw(tx.to, tx.tokenAddress, tx.amount); + final Function function = new Function( + FUNC_WITHDRAW, + Arrays.asList(new Address(160, tx.to), + new Address(160, tx.tokenAddress), + new org.web3j.abi.datatypes.generated.Uint256(tx.amount)), + Collections.>emptyList()); + String data = FunctionEncoder.encode(function); Eip712Meta meta = new Eip712Meta(BigInteger.valueOf(50000), null, null, tx.paymasterParams); return new Transaction(tx.from, tx.bridgeAddress, BigInteger.ZERO, BigInteger.ZERO, BigInteger.ZERO, data, meta); } public Transaction getTransferTransaction(TransferTransaction tx, TransactionManager transactionManager, ContractGasProvider gasProvider){ + boolean isEthBasedChain = isEthBasedChain(); + + if (tx.tokenAddress != null && + !tx.tokenAddress.isEmpty() && + tx.tokenAddress.equalsIgnoreCase(ZkSyncAddresses.LEGACY_ETH_ADDRESS) && + !isEthBasedChain){ + tx.tokenAddress = l2TokenAddress(ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS); + } else if (tx.tokenAddress == null || + tx.tokenAddress.isEmpty() || + isBaseToken(tx.tokenAddress)){ + tx.tokenAddress = ZkSyncAddresses.L2_BASE_TOKEN_ADDRESS; + } + tx.to = tx.to == null ? tx.from : tx.to; tx.options = tx.options == null ? new TransactionOptions() : tx.options; BigInteger gasPrice = tx.options.getGasPrice(); @@ -230,7 +299,7 @@ public Transaction getTransferTransaction(TransferTransaction tx, TransactionMan } Eip712Meta meta = new Eip712Meta(tx.gasPerPubData, null, null, tx.paymasterParams); - if (tx.tokenAddress == null || tx.tokenAddress == ZkSyncAddresses.ETH_ADDRESS){ + if (tx.tokenAddress == null || tx.tokenAddress == ZkSyncAddresses.LEGACY_ETH_ADDRESS || isBaseToken(tx.tokenAddress)){ return new Transaction(tx.from, tx.to, BigInteger.ZERO, gasPrice, tx.amount, "0x", meta); } ERC20 token = ERC20.load(tx.tokenAddress, this, transactionManager, gasProvider); diff --git a/src/main/java/io/zksync/protocol/ZkSync.java b/src/main/java/io/zksync/protocol/ZkSync.java index 30906d9..030ccbd 100755 --- a/src/main/java/io/zksync/protocol/ZkSync.java +++ b/src/main/java/io/zksync/protocol/ZkSync.java @@ -8,6 +8,7 @@ import org.web3j.protocol.Web3j; import org.web3j.protocol.Web3jService; import org.web3j.protocol.core.DefaultBlockParameter; +import org.web3j.protocol.core.RemoteFunctionCall; import org.web3j.protocol.core.Request; import org.web3j.protocol.core.methods.request.EthFilter; import org.web3j.protocol.core.methods.response.EthEstimateGas; @@ -38,6 +39,11 @@ static ZkSync build(Web3jService web3jService) { */ Request zksMainContract(); + /** + * Returns address of the Bridgehub smart contract. + */ + Request zksGetBridgehubContract(); + /** * Get list of the tokens supported by ZkSync. * The tokens are returned in alphabetical order by their symbol, so basically, the token id is its position in an alphabetically sorted array of tokens. @@ -82,6 +88,21 @@ static ZkSync build(Web3jService web3jService) { */ Request zksGetBridgeContracts(); + /** + * Returns the L1 base token address. + */ + Request zksGetBaseTokenContractAddress(); + + /** + * Returns whether the chain is ETH-based. + */ + boolean isEthBasedChain(); + + /** + * Returns whether the `token` is the base token. + */ + boolean isBaseToken(String tokenAddress); + /** * Get the proof for the message sent via the IL1Messenger system contract. * @@ -166,6 +187,16 @@ Request zksGetBlockByHash( Request zksGetBlockByNumber( DefaultBlockParameter defaultBlockParameter, boolean returnFullTransactionObjects); + /** + * Returns the L2 token address equivalent for a L1 token address as they are not necessarily equal. + * The ETH address is set to the zero address. + * + * @remarks Only works for tokens bridged on default zkSync Era bridges. + * + * @param token The address of the token on L1. + */ + String l2TokenAddress(String tokenAddress); + Request estimateL1ToL2Execute(String contractAddress, byte[] calldata, String caller, @Nullable BigInteger l2GasLimit, @Nullable BigInteger l2Value, @Nullable byte[][] factoryDeps, @Nullable BigInteger operatorTip, @Nullable BigInteger gasPerPubDataByte, @Nullable String refoundRecepient); Transaction getWithdrawTransaction(WithdrawTransaction tx, ContractGasProvider gasProvider, TransactionManager transactionManager) throws Exception; diff --git a/src/main/java/io/zksync/protocol/account/Wallet.java b/src/main/java/io/zksync/protocol/account/Wallet.java index dbce38f..34ad0e1 100644 --- a/src/main/java/io/zksync/protocol/account/Wallet.java +++ b/src/main/java/io/zksync/protocol/account/Wallet.java @@ -51,11 +51,11 @@ @Getter public class Wallet extends WalletL1{ - private final TransactionReceiptProcessor transactionReceiptProcessor; + private final ZkSyncTransactionReceiptProcessor transactionReceiptProcessor; private final ZkTransactionFeeProvider feeProviderL2; protected final EthSigner signerL2; - public Wallet(Web3j providerL1, ZkSync providerL2, TransactionManager transactionManager, ContractGasProvider feeProviderL1, ZkTransactionFeeProvider feeProviderL2, TransactionReceiptProcessor transactionReceiptProcessor, Credentials credentials) { + public Wallet(Web3j providerL1, ZkSync providerL2, TransactionManager transactionManager, ContractGasProvider feeProviderL1, ZkTransactionFeeProvider feeProviderL2, ZkSyncTransactionReceiptProcessor transactionReceiptProcessor, Credentials credentials) { super(providerL1, providerL2, transactionManager, feeProviderL1, credentials); this.transactionReceiptProcessor = transactionReceiptProcessor; this.feeProviderL2 = feeProviderL2; @@ -97,7 +97,7 @@ public String getAddress(){ */ public L2BridgeContracts getL2BridgeContracts(){ BridgeAddresses bridgeAddresses = providerL2.zksGetBridgeContracts().sendAsync().join().getResult(); - return new L2BridgeContracts(bridgeAddresses.getL2Erc20DefaultBridge(), bridgeAddresses.getL2wETHBridge(), providerL2, transactionManager, feeProviderL2); + return new L2BridgeContracts(bridgeAddresses.getL2Erc20DefaultBridge(), bridgeAddresses.getL2WethBridge(), providerL2, transactionManager, feeProviderL2); } public CompletableFuture getDeploymentNonce(){ @@ -135,7 +135,7 @@ public RemoteCall transfer(TransferTransaction tx) { * @return Prepared remote call of transaction */ public RemoteCall withdraw(WithdrawTransaction tx) { - tx.tokenAddress = tx.tokenAddress == null ? ZkSyncAddresses.ETH_ADDRESS : tx.tokenAddress; + tx.tokenAddress = tx.tokenAddress == null ? ZkSyncAddresses.LEGACY_ETH_ADDRESS : tx.tokenAddress; tx.from = tx.from == null ? getAddress() : tx.from; tx.options = tx.options == null ? new TransactionOptions() : tx.options; BigInteger maxPriorityFeePerGas = tx.options.getMaxPriorityFeePerGas() == null ? BigInteger.ZERO : tx.options.getMaxPriorityFeePerGas(); @@ -295,7 +295,7 @@ public RemoteCall execute(String contractAddress, Function f * @return Prepared get balance call */ public RemoteCall getBalance() { - return getBalance(getAddress(), ZkSyncAddresses.ETH_ADDRESS, ZkBlockParameterName.COMMITTED); + return getBalance(getAddress(), getBaseToken().sendAsync().join(), ZkBlockParameterName.COMMITTED); } /** @@ -329,7 +329,10 @@ public RemoteCall getBalance(String address, String token) { * @return Prepared get balance call */ public RemoteCall getBalance(String address, String token, DefaultBlockParameter at) { - if (token == ZkSyncAddresses.ETH_ADDRESS) { + if (token.equalsIgnoreCase(ZkSyncAddresses.LEGACY_ETH_ADDRESS)){ + token = ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS; + } + if (providerL2.isBaseToken(token)) { return new RemoteCall<>(() -> this.providerL2.ethGetBalance(address, at).sendAsync().join().getBalance()); } else { diff --git a/src/main/java/io/zksync/protocol/account/WalletL1.java b/src/main/java/io/zksync/protocol/account/WalletL1.java index b03cb6e..3519795 100644 --- a/src/main/java/io/zksync/protocol/account/WalletL1.java +++ b/src/main/java/io/zksync/protocol/account/WalletL1.java @@ -11,11 +11,21 @@ import io.zksync.protocol.core.Token; import io.zksync.protocol.core.ZkBlockParameterName; import io.zksync.transaction.type.*; +import io.zksync.utils.WalletUtils; import io.zksync.utils.ZkSyncAddresses; -import io.zksync.wrappers.*; +import io.zksync.wrappers.ERC20; +import io.zksync.wrappers.IBridgehub; +import io.zksync.wrappers.IL1Bridge; +import io.zksync.wrappers.IZkSync; import lombok.Getter; import org.jetbrains.annotations.Nullable; import org.web3j.abi.EventValues; +import org.web3j.abi.FunctionEncoder; +import org.web3j.abi.TypeReference; +import org.web3j.abi.datatypes.Address; +import org.web3j.abi.datatypes.Function; +import org.web3j.abi.datatypes.Type; +import org.web3j.abi.datatypes.generated.Uint256; import org.web3j.crypto.Credentials; import org.web3j.crypto.Hash; import org.web3j.crypto.RawTransaction; @@ -23,7 +33,10 @@ import org.web3j.protocol.Web3j; import org.web3j.protocol.core.*; import org.web3j.protocol.core.methods.request.Transaction; -import org.web3j.protocol.core.methods.response.*; +import org.web3j.protocol.core.methods.response.EthEstimateGas; +import org.web3j.protocol.core.methods.response.EthSendTransaction; +import org.web3j.protocol.core.methods.response.Log; +import org.web3j.protocol.core.methods.response.TransactionReceipt; import org.web3j.tx.Contract; import org.web3j.tx.RawTransactionManager; import org.web3j.tx.TransactionManager; @@ -33,7 +46,6 @@ import org.web3j.tx.response.TransactionReceiptProcessor; import org.web3j.utils.Numeric; -import java.io.IOException; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; @@ -44,8 +56,8 @@ import static io.zksync.transaction.manager.ZkSyncTransactionManager.DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH; import static io.zksync.transaction.manager.ZkSyncTransactionManager.DEFAULT_POLLING_FREQUENCY; import static io.zksync.utils.WalletUtils.*; -import static io.zksync.utils.ZkSyncAddresses.L2_ETH_TOKEN_ADDRESS; import static io.zksync.utils.ZkSyncAddresses.MESSENGER_ADDRESS; +import static io.zksync.wrappers.IBridgehub.FUNC_REQUESTL2TRANSACTIONDIRECT; import static io.zksync.wrappers.IL1Messenger.L1MESSAGESENT_EVENT; @Getter @@ -95,13 +107,18 @@ public IZkSync getMainContract(){ return contract; } + public IBridgehub getBridgehubContract(){ + String address = providerL2.zksGetBridgehubContract().sendAsync().join().getResult(); + return IBridgehub.load(address, providerL1, transactionManager, gasProvider); + } + /** * Get balance of wallet in native coin (wallet address gets from {@link EthSigner}) * * @return Prepared get balance call */ public RemoteCall getBalanceL1() { - return getBalanceL1(signer.getAddress(), ZkSyncAddresses.ETH_ADDRESS, DefaultBlockParameterName.LATEST); + return getBalanceL1(signer.getAddress(), ZkSyncAddresses.LEGACY_ETH_ADDRESS, DefaultBlockParameterName.LATEST); } /** @@ -135,7 +152,7 @@ public RemoteCall getBalanceL1(String address, String token) { * @return Prepared get balance call */ public RemoteCall getBalanceL1(String address, String token, DefaultBlockParameter at) { - if (token == ZkSyncAddresses.ETH_ADDRESS) { + if (ZkSyncAddresses.isEth(token)) { return new RemoteCall<>(() -> this.providerL1.ethGetBalance(address, at).sendAsync().join().getBalance()); } else { @@ -143,76 +160,125 @@ public RemoteCall getBalanceL1(String address, String token, Default return erc20.balanceOf(address); } } - public CompletableFuture approveERC20(String token, BigInteger amount) { + public RemoteFunctionCall approveERC20(String token, BigInteger amount) { return approveERC20(token, amount, null); } - public CompletableFuture approveERC20(String token, @Nullable BigInteger amount, @Nullable String bridgeAddress) { - if (token == ZkSyncAddresses.ETH_ADDRESS){ + + public CompletableFuture getBalanceL1Async(String address, String token, DefaultBlockParameter at) { + if (ZkSyncAddresses.isEth(token)) { + return this.providerL1.ethGetBalance(address, at).sendAsync() + .thenApply(ethGetBalance -> ethGetBalance.getBalance()) + .exceptionally(ex -> { + System.err.println("Failed to get ETH balance: " + ex.getMessage()); + return BigInteger.ZERO; + }); + } else { + ERC20 erc20 = ERC20.load(token, this.providerL2, transactionManager, gasProvider); + return erc20.balanceOf(address).sendAsync() + .exceptionally(ex -> { + System.err.println("Failed to get ERC20 balance: " + ex.getMessage()); + return BigInteger.ZERO; + }); + } + } + + /** + * Bridging ERC20 tokens from L1 requires approving the tokens to the zkSync Era smart contract. + * + * @param token The L1 address of the token. + * @param amount The amount of the token to be approved. + * @param bridgeAddress Bridge address to be used. + * @throws {Error} If attempting to approve an ETH token. + * @returns A promise that resolves to the response of the approval transaction. + */ + public RemoteFunctionCall approveERC20(String token, @Nullable BigInteger amount, @Nullable String bridgeAddress) { + if (ZkSyncAddresses.isEth(token)){ throw new Error("ETH token can't be approved! The address of the token does not exist on L1."); } ERC20 tokenContract = ERC20.load(token, providerL1, transactionManager, gasProvider); if (bridgeAddress == null){ - L1BridgeContracts bridgeContracts = getL1BridgeContracts(); - String l2WethAddress = ZkSyncAddresses.ETH_ADDRESS; - try{ - l2WethAddress = bridgeContracts.wethL1Bridge.l2TokenAddress(token).sendAsync().join(); - }catch (Exception e){} - bridgeAddress = l2WethAddress != ZkSyncAddresses.ETH_ADDRESS ? bridgeContracts.wethL1Bridge.getContractAddress() : bridgeContracts.erc20L1Bridge.getContractAddress(); + bridgeAddress = providerL2.zksGetBridgeContracts().sendAsync().join().getResult().getL1SharedDefaultBridge(); } - return tokenContract.approve(bridgeAddress, amount).sendAsync(); + return tokenContract.approve(bridgeAddress, amount); } - public CompletableFuture getAllowanceL1(String token){ + public RemoteFunctionCall getAllowanceL1(String token){ return getAllowanceL1(token, null); } - public CompletableFuture getAllowanceL1(String token, @Nullable String bridgeAddress){ + /** + * Returns the amount of approved tokens for a specific L1 bridge. + * + * @param token The Ethereum address of the token. + * @param bridgeAddress The address of the bridge contract to be used. + * Defaults to the default zkSync Era bridge, either `L1EthBridge` or `L1Erc20Bridge`. + */ + public RemoteFunctionCall getAllowanceL1(String token, @Nullable String bridgeAddress){ if (bridgeAddress == null){ - L1BridgeContracts bridgeContracts = getL1BridgeContracts(); - String l2WethToken = ZkSyncAddresses.ETH_ADDRESS; - try{ - l2WethToken = bridgeContracts.wethL1Bridge.l2TokenAddress(token).sendAsync().join(); - }catch (Exception e){} - bridgeAddress = l2WethToken != ZkSyncAddresses.ETH_ADDRESS ? bridgeContracts.wethL1Bridge.getContractAddress() : bridgeContracts.erc20L1Bridge.getContractAddress(); + bridgeAddress = providerL2.zksGetBridgeContracts().sendAsync().join().getResult().getL1SharedDefaultBridge(); } ERC20 erc20 = ERC20.load(token, providerL1, transactionManager, gasProvider); - return erc20.allowance(signer.getAddress(), bridgeAddress).sendAsync(); + return erc20.allowance(signer.getAddress(), bridgeAddress); } + /** + * Returns the L2 token address equivalent for a L1 token address as they are not necessarily equal. + * The ETH address is set to the zero address. + * + * @remarks Only works for tokens bridged on default zkSync Era bridges. + * + * @param l1Address The address of the token on L1. + */ public String l2TokenAddress(String l1Address){ - if (ZkSyncAddresses.ETH_ADDRESS == l1Address){ - return ZkSyncAddresses.ETH_ADDRESS; - } - - L1BridgeContracts bridgeContracts = getL1BridgeContracts(); - IL1Bridge bridge = bridgeContracts.erc20L1Bridge; - String l2WethAddress = ZkSyncAddresses.ETH_ADDRESS; - try{ - l2WethAddress = bridgeContracts.wethL1Bridge.l2TokenAddress(l1Address).sendAsync().join(); - if (l2WethAddress == ZkSyncAddresses.ETH_ADDRESS){ - return l2WethAddress; - } - }catch (Exception e){} - return bridgeContracts.erc20L1Bridge.l2TokenAddress(l1Address).sendAsync().join(); + return providerL2.l2TokenAddress(l1Address); } private EthSigner getSigner() { return signer; } + /** + * Returns L1 bridge contracts. + * + * @remarks There is no separate Ether bridge contract, {@link } is used instead. + */ public L1BridgeContracts getL1BridgeContracts(){ BridgeAddresses bridgeAddresses = providerL2.zksGetBridgeContracts().sendAsync().join().getResult(); - return new L1BridgeContracts(bridgeAddresses.getL1Erc20DefaultBridge(), bridgeAddresses.getL1wETHBridge(), providerL1, transactionManager, gasProvider); + return new L1BridgeContracts(bridgeAddresses.getL1Erc20DefaultBridge(),bridgeAddresses.getL1SharedDefaultBridge(), bridgeAddresses.getL1SharedDefaultBridge(), providerL1, transactionManager, gasProvider); + } + + /** + * Returns the address of the base token on L1. + */ + public RemoteCall getBaseToken(){ + IBridgehub bridgehub = getBridgehubContract(); + BigInteger chainId = providerL2.ethChainId().sendAsync().join().getChainId(); + return bridgehub.baseToken(chainId); + } + + /** + * Returns whether the chain is ETH-based. + */ + public boolean isETHBasedChain(){ + return providerL2.isEthBasedChain(); } - public CompletableFuture getBaseCost(BigInteger gasLimit) { + public RemoteFunctionCall getBaseCost(BigInteger gasLimit) { return getBaseCost(gasLimit, null, null); } - public CompletableFuture getBaseCost(BigInteger gasLimit, @Nullable BigInteger gasPerPubdataByte, @Nullable BigInteger gasPrice) { + /** + * Returns the base cost for an L2 transaction. + * + * @param gasLimit The gasLimit for the L2 contract call. + * @param gasPerPubdataByte The L2 gas price for each published L1 calldata byte. + * @param gasPrice The L1 gas price of the L1 transaction that will send the request for an execute call. + */ + public RemoteFunctionCall getBaseCost(BigInteger gasLimit, @Nullable BigInteger gasPerPubdataByte, @Nullable BigInteger gasPrice) { + IBridgehub bridgehub = getBridgehubContract(); if (gasPrice == null){ gasPrice = providerL1.ethGasPrice().sendAsync().join().getGasPrice(); } @@ -220,11 +286,44 @@ public CompletableFuture getBaseCost(BigInteger gasLimit, @Nullable gasPerPubdataByte = L1_TO_L2_GAS_PER_PUBDATA; } - return contract.l2TransactionBaseCost(gasPrice, gasLimit, gasPerPubdataByte).sendAsync(); + return bridgehub.l2TransactionBaseCost(providerL2.ethChainId().sendAsync().join().getChainId() ,gasPrice, gasLimit, gasPerPubdataByte); } - public RequestExecuteTransaction getRequestExecuteTransaction(RequestExecuteTransaction transaction){ + public List getDepositAllowanceParams(String tokenAddress, BigInteger amount) throws Exception { + if (tokenAddress.equalsIgnoreCase(ZkSyncAddresses.LEGACY_ETH_ADDRESS)){ + tokenAddress = ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS; + } + + String baseTokenAddress = getBaseToken().sendAsync().join(); + boolean isEthBasedChain = isETHBasedChain(); + List result = new ArrayList<>(); + if (isEthBasedChain && tokenAddress.equalsIgnoreCase(ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS)){ + throw new Error("ETH token can't be approved! The address of the token does not exist on L1."); + }else if (baseTokenAddress.equalsIgnoreCase(ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS)){ + result.add(new AllowanceParams(tokenAddress, amount)); + return result; + } else if (tokenAddress.equalsIgnoreCase(ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS)) { + result.add(new AllowanceParams(baseTokenAddress, + _getDepositETHOnNonETHBasedChainTx( + new DepositTransaction(tokenAddress, amount)).mintValue)); + return result; + } else if (tokenAddress.equalsIgnoreCase(baseTokenAddress)) { + result.add(new AllowanceParams(baseTokenAddress, + _getDepositBaseTokenOnNonETHBasedChainTx( + new DepositTransaction(tokenAddress, amount)).mintValue)); + return result; + } + // A deposit of a non-base token to a non-ETH-based chain requires two approvals. + result.add(new AllowanceParams(baseTokenAddress, + _getDepositNonBaseTokenToNonETHBasedChain( + new DepositTransaction(tokenAddress, amount)).mintValue)); + result.add(new AllowanceParams(tokenAddress, amount)); + return result; + } + + public RawTransaction getRequestExecuteTransaction(RequestExecuteTransaction transaction){ + boolean isEthBasedChain = isETHBasedChain(); if (transaction.getOperatorTip() == null){ transaction.setOperatorTip(BigInteger.valueOf(0)); } @@ -247,172 +346,579 @@ public RequestExecuteTransaction getRequestExecuteTransaction(RequestExecuteTran BigInteger gasPriceForestimation = transaction.getOptions().getMaxFeePerGas() != null ? transaction.getOptions().getMaxFeePerGas() : transaction.getOptions().getGasPrice(); - BigInteger baseCost = getBaseCost(transaction.getL2GasLimit(), transaction.getGasPerPubDataByte(), gasPriceForestimation).join(); + BigInteger baseCost = getBaseCost(transaction.getL2GasLimit(), transaction.getGasPerPubDataByte(), gasPriceForestimation).sendAsync().join(); + BigInteger l2Cost = baseCost.add(transaction.operatorTip.add(transaction.l2Value)); + BigInteger providedValue = isEthBasedChain ? transaction.options.value : transaction.mintValue; - if (transaction.getOptions().getValue() == null){ - transaction.getOptions().setValue(baseCost.add(transaction.getL2Value().add(transaction.getOperatorTip()))); + if (transaction.options.value == null || transaction.options.value.equals(BigInteger.ZERO)){ + providedValue = l2Cost; + if (isEthBasedChain){ + transaction.options.value = providedValue; + } } - checkBaseCost(baseCost, transaction.getOptions().getValue()); + checkBaseCost(baseCost, providedValue); + + IBridgehub.L2TransactionRequestDirect request = new IBridgehub.L2TransactionRequestDirect( + providerL2.ethChainId().sendAsync().join().getChainId(), + providedValue, + transaction.getContractAddress(), + transaction.getL2Value(), + transaction.getCalldata(), + transaction.getL2GasLimit(), + transaction.getGasPerPubDataByte(), + Collections.emptyList(), + transaction.getRefoundRecepient()); + final Function function = new Function( + FUNC_REQUESTL2TRANSACTIONDIRECT, + Arrays.asList(request), + Collections.>emptyList()); + String data = FunctionEncoder.encode(function); + + return RawTransaction.createTransaction(transaction.getOptions().getChainId().longValue(), transaction.getOptions().getNonce(), transaction.getOptions().getGasLimit(), getBridgehubContract().getContractAddress(), transaction.getOptions().getValue(), data, transaction.getOptions().getMaxPriorityFeePerGas(), transaction.getOptions().getMaxFeePerGas()); + } - return transaction; + public Request deposit(DepositTransaction transaction) throws Exception { + if (transaction.tokenAddress.equalsIgnoreCase(ZkSyncAddresses.LEGACY_ETH_ADDRESS)){ + transaction.tokenAddress = ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS; + } + + String baseTokenAddress = getBaseToken().sendAsync().join(); + boolean isEthBasedChain = baseTokenAddress.equalsIgnoreCase(ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS); + + if (isEthBasedChain && transaction.tokenAddress.equalsIgnoreCase(ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS)){ + return _depositETHToETHBasedChain(transaction); + }else if (baseTokenAddress.equalsIgnoreCase(ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS)){ + return _depositTokenToETHBasedChain(transaction); + }else if (transaction.tokenAddress.equalsIgnoreCase(ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS)){ + return _depositETHToNonETHBasedChain(transaction); + } else if (transaction.tokenAddress.equalsIgnoreCase(baseTokenAddress)) { + return _depositBaseTokenToNonETHBasedChain(transaction); + } + return _depositNonBaseTokenToNonETHBasedChain(transaction); } - public Request deposit(DepositTransaction transaction) throws IOException { - transaction = getDepositTransaction(transaction); + private Request _depositNonBaseTokenToNonETHBasedChain(DepositTransaction transaction) { + String baseTokenAddress = getBaseToken().sendAsync().join(); + L1BridgeContracts bridgeContracts = getL1BridgeContracts(); + + GetDepositTransaction depositTransaction = _getDepositNonBaseTokenToNonETHBasedChain(transaction); + Transaction tx = depositTransaction.tx; + BigInteger mintValue = depositTransaction.mintValue; - if (transaction.tokenAddress == ZkSyncAddresses.ETH_ADDRESS){ - BigInteger baseGasLimit = estimateGasRequestExecute(transaction.toRequestExecute(mainContractAddress)).sendAsync().join().getAmountUsed(); - BigInteger gasLimit = scaleGasLimit(baseGasLimit); + if (transaction.approveBaseERC20){ + BigInteger allowance = getAllowanceL1(baseTokenAddress, bridgeContracts.sharedL1Bridge.getContractAddress()).sendAsync().join(); - if (transaction.options.getGasLimit() == null) - transaction.options.setGasLimit(gasLimit); - return requestExecute(transaction.toRequestExecute(mainContractAddress)); + if (allowance.compareTo(mintValue) < 0){ + approveERC20( + baseTokenAddress, mintValue, bridgeContracts.sharedL1Bridge.getContractAddress()).sendAsync().join(); + } } - L1BridgeContracts bridgeContracts = getL1BridgeContracts(); - IL1Bridge bridge = bridgeContracts.erc20L1Bridge; - if (transaction.bridgeAddress == null){ - String l2WethAddress = ZkSyncAddresses.ETH_ADDRESS; - try{ - l2WethAddress = bridgeContracts.wethL1Bridge.l2TokenAddress(transaction.tokenAddress).sendAsync().join(); - bridge = bridgeContracts.wethL1Bridge; - }catch (Exception e){} - transaction.bridgeAddress = l2WethAddress != ZkSyncAddresses.ETH_ADDRESS ? bridgeContracts.wethL1Bridge.getContractAddress() : bridgeContracts.erc20L1Bridge.getContractAddress(); - } - if (transaction.approveERC20 != null || transaction.approveERC20){ - BigInteger allowance = getAllowanceL1(transaction.tokenAddress, transaction.bridgeAddress).join(); - if (transaction.amount.compareTo(allowance) > 0){ - approveERC20(transaction.tokenAddress, transaction.amount, transaction.bridgeAddress).join(); + if (transaction.approveERC20){ + String bridgeAddress = transaction.bridgeAddress == null || transaction.bridgeAddress.isEmpty() + ? bridgeContracts.sharedL1Bridge.getContractAddress() + : transaction.bridgeAddress; + BigInteger allowance = getAllowanceL1(transaction.tokenAddress, bridgeAddress).sendAsync().join(); + + if (allowance.compareTo(mintValue) < 0){ + approveERC20( + transaction.tokenAddress, transaction.amount, bridgeAddress).sendAsync().join(); } } - String data = bridge.encodeDeposit(signer.getAddress(), transaction.tokenAddress, transaction.amount, transaction.l2GasLimit, transaction.gasPerPubdataByte, transaction.refoundRecepient, transaction.options.getValue()); - Transaction a = transaction.toTx(signer.getAddress(), data); - BigInteger baseGasLimit = providerL1.ethEstimateGas(a).sendAsync().join().getAmountUsed(); - BigInteger gasLimit = scaleGasLimit(baseGasLimit); - RawTransaction tx = RawTransaction.createTransaction(transaction.options.getChainId().longValue(), transaction.options.getNonce(), gasLimit, bridge.getContractAddress(), transaction.options.getValue(), data, transaction.options.getMaxPriorityFeePerGas(), transaction.options.getMaxFeePerGas()); - byte[] message = TransactionEncoder.signMessage(tx, credentials); + BigInteger gasLimit = tx.getGas() != null ? Numeric.toBigInt(tx.getGas()) : BigInteger.ZERO; + if (gasLimit.equals(BigInteger.ZERO)){ + BigInteger baseGasLimit = providerL1.ethEstimateGas(tx).sendAsync().join().getAmountUsed(); + gasLimit = scaleGasLimit(baseGasLimit); + } + + BigInteger nonceToUse = tx.getNonce() == null + ? providerL1.ethGetTransactionCount(credentials.getAddress(), + DefaultBlockParameterName.LATEST).sendAsync().join().getTransactionCount() + : Numeric.toBigInt(tx.getNonce()); + + RawTransaction prepared = RawTransaction.createTransaction( + Numeric.toBigInt(tx.getChainId()).longValue(), + nonceToUse, + gasLimit, + tx.getTo(), + Numeric.toBigInt(tx.getValue()), + tx.getData(), + Numeric.toBigInt(tx.getMaxPriorityFeePerGas()), + Numeric.toBigInt(tx.getMaxFeePerGas())); + byte[] message = TransactionEncoder.signMessage(prepared, credentials); return providerL1.ethSendRawTransaction(Numeric.toHexString(message)); } - public BigInteger estimateGasDeposit(DepositTransaction transaction){ - transaction = getDepositTransaction(transaction); - BigInteger baseGasLimit = BigInteger.ZERO; - if (transaction.tokenAddress == ZkSyncAddresses.ETH_ADDRESS){ - String address = providerL2.zksMainContract().sendAsync().join().getResult(); - baseGasLimit = estimateGasRequestExecute(new RequestExecuteTransaction(transaction.l2GasLimit, address, transaction.customBridgeData, transaction.amount, null, transaction.operatorTip, transaction.gasPerPubdataByte, transaction.refoundRecepient, transaction.options)).sendAsync().join().getAmountUsed(); - } else { - L1BridgeContracts l1BridgeContracts = getL1BridgeContracts(); - String l2WethToken = ZkSyncAddresses.ETH_ADDRESS; - try { - l2WethToken = l1BridgeContracts.wethL1Bridge.l2TokenAddress(transaction.tokenAddress).sendAsync().join(); - } catch (Exception e) {} + private Request _depositBaseTokenToNonETHBasedChain(DepositTransaction transaction) { + IBridgehub bridgehub = getBridgehubContract(); + BigInteger chainId = providerL2.ethChainId().sendAsync().join().getChainId(); + String baseTokenAddress = getBaseToken().sendAsync().join(); + IL1Bridge sharedL1Bridge = getL1BridgeContracts().sharedL1Bridge; + + GetDepositTransaction depositTransaction = _getDepositBaseTokenOnNonETHBasedChainTx(transaction); + RequestExecuteTransaction tx = depositTransaction.requestExecuteTransaction; + BigInteger mintValue = depositTransaction.mintValue; - IL1Bridge l1Bridge = l2WethToken != ZkSyncAddresses.ETH_ADDRESS ? l1BridgeContracts.wethL1Bridge : l1BridgeContracts.erc20L1Bridge; - baseGasLimit = providerL1.ethEstimateGas(transaction.toFunctionCallTx(signer.getAddress(), l1Bridge)).sendAsync().join().getAmountUsed(); + if (transaction.approveERC20 || transaction.approveBaseERC20){ + BigInteger allowance = getAllowanceL1(baseTokenAddress, sharedL1Bridge.getContractAddress()).sendAsync().join(); + if (allowance.compareTo(mintValue) < 0){ + approveERC20( + baseTokenAddress, mintValue, sharedL1Bridge.getContractAddress()).sendAsync().join(); + } } - return scaleGasLimit(baseGasLimit); + + if (tx.options.gasLimit == null){ + BigInteger baseGasLimit = estimateGasRequestExecute(tx).sendAsync().join().getAmountUsed(); + tx.options.gasLimit = scaleGasLimit(baseGasLimit); + } + + return requestExecute(tx); } - public FullDepositFee getFullRequiredDepositFee(DepositTransaction transaction){ - L1BridgeContracts l1BridgeContracts = getL1BridgeContracts(); - transaction.amount = BigInteger.valueOf(1); + private Request _depositETHToNonETHBasedChain(DepositTransaction transaction) throws Exception { + String baseTokenAddress = getBaseToken().sendAsync().join(); + IL1Bridge sharedL1Bridge = getL1BridgeContracts().sharedL1Bridge; - transaction.options = insertGasPriceInTransactionOptions(transaction.options, providerL1); + GetDepositTransaction depositTransaction = _getDepositETHOnNonETHBasedChainTx(transaction); + Transaction tx = depositTransaction.tx; + BigInteger mintValue = depositTransaction.mintValue; - BigInteger gasPriceForEstimation = transaction.options.getMaxFeePerGas() != null ? transaction.options.getMaxFeePerGas() : transaction.options.getGasPrice(); + if (transaction.approveBaseERC20){ + String proposedBridge = sharedL1Bridge.getContractAddress(); + String bridgeAddress = transaction.bridgeAddress == null || transaction.bridgeAddress.isEmpty() + ? proposedBridge + : transaction.bridgeAddress; - transaction.to = transaction.to == null ? signer.getAddress() : transaction.to; - transaction.gasPerPubdataByte = transaction.gasPerPubdataByte == null ? L1_TO_L2_GAS_PER_PUBDATA : transaction.gasPerPubdataByte; - if (transaction.bridgeAddress != null){ - String customBridgeData = transaction.customBridgeData == null ? - (transaction.bridgeAddress == l1BridgeContracts.wethL1Bridge.getContractAddress() ? "0x" : - getERC20DefaultBridgeData(transaction.tokenAddress, providerL1, credentials, gasProvider)) - : Numeric.toHexString(transaction.customBridgeData); + BigInteger allowance = getAllowanceL1(baseTokenAddress, bridgeAddress).sendAsync().join(); - } else { - transaction.l2GasLimit = estimateDefaultBridgeDepositL2Gas( - transaction.tokenAddress, transaction.amount, transaction.to, providerL2, getL1BridgeContracts(), providerL1, credentials,gasProvider, signer.getAddress(), transaction.gasPerPubdataByte); + if (allowance.compareTo(mintValue) < 0){ + approveERC20( + baseTokenAddress, mintValue, bridgeAddress).sendAsync().join(); + } } - BigInteger baseCost = contract.l2TransactionBaseCost(gasPriceForEstimation, transaction.l2GasLimit, transaction.gasPerPubdataByte).sendAsync().join(); + BigInteger gasLimit = tx.getGas() != null ? Numeric.toBigInt(tx.getGas()) : BigInteger.ZERO; + if (gasLimit.equals(BigInteger.ZERO)){ + BigInteger baseGasLimit = providerL1.ethEstimateGas(tx).sendAsync().join().getAmountUsed(); + gasLimit = scaleGasLimit(baseGasLimit); + } - BigInteger balance = getBalanceL1().sendAsync().join(); + BigInteger nonceToUse = tx.getNonce() == null + ? providerL1.ethGetTransactionCount(credentials.getAddress(), + DefaultBlockParameterName.LATEST).sendAsync().join().getTransactionCount() + : Numeric.toBigInt(tx.getNonce()); + + RawTransaction prepared = RawTransaction.createTransaction( + Numeric.toBigInt(tx.getChainId()).longValue(), + nonceToUse, + gasLimit, + tx.getTo(), + Numeric.toBigInt(tx.getValue()), + tx.getData(), + Numeric.toBigInt(tx.getMaxPriorityFeePerGas()), + Numeric.toBigInt(tx.getMaxFeePerGas())); + byte[] message = TransactionEncoder.signMessage(prepared, credentials); + return providerL1.ethSendRawTransaction(Numeric.toHexString(message)); + } + + private Request _depositTokenToETHBasedChain(DepositTransaction transaction) { + L1BridgeContracts bridgeContracts = getL1BridgeContracts(); + Transaction tx = _getDepositTokenOnETHBasedChainTx(transaction); + + if (transaction.approveERC20){ + String proposedBridge = bridgeContracts.sharedL1Bridge.getContractAddress(); + String bridgeAddress = transaction.bridgeAddress == null || transaction.bridgeAddress.isEmpty() + ? proposedBridge + : transaction.bridgeAddress; + + BigInteger allowance = getAllowanceL1(transaction.tokenAddress, bridgeAddress).sendAsync().join(); - if (baseCost.compareTo(balance.add(transaction.amount)) >= 0){ - BigInteger recommendedETHBalance = (transaction.tokenAddress == ZkSyncAddresses.ETH_ADDRESS ? - L1_RECOMMENDED_MIN_ETH_DEPOSIT_GAS_LIMIT : L1_RECOMMENDED_MIN_ERC20_DEPOSIT_GAS_LIMIT).multiply( - gasPriceForEstimation).multiply( - baseCost - ); - throw new Error("Not enough balance for deposit. Under the provided gas price, the recommended balance to perform a deposit is " + recommendedETHBalance + " ETH"); + if (allowance.compareTo(transaction.amount) < 0){ + approveERC20( + transaction.tokenAddress, transaction.amount, bridgeAddress).sendAsync().join(); + } + } + + BigInteger gasLimit = tx.getGas() != null ? Numeric.toBigInt(tx.getGas()) : BigInteger.ZERO; + if (gasLimit.equals(BigInteger.ZERO)){ + BigInteger baseGasLimit = providerL1.ethEstimateGas(tx).sendAsync().join().getAmountUsed(); + gasLimit = scaleGasLimit(baseGasLimit); } - if (transaction.tokenAddress != ZkSyncAddresses.ETH_ADDRESS && getAllowanceL1(transaction.tokenAddress).join().compareTo(transaction.amount) < 0){ - throw new Error("Not enough allowance to cover the deposit"); + BigInteger nonceToUse = tx.getNonce() == null + ? providerL1.ethGetTransactionCount(credentials.getAddress(), + DefaultBlockParameterName.LATEST).sendAsync().join().getTransactionCount() + : Numeric.toBigInt(tx.getNonce()); + + RawTransaction prepared = RawTransaction.createTransaction( + Numeric.toBigInt(tx.getChainId()).longValue(), + nonceToUse, + gasLimit, + tx.getTo(), + Numeric.toBigInt(tx.getValue()), + tx.getData(), + Numeric.toBigInt(tx.getMaxPriorityFeePerGas()), + Numeric.toBigInt(tx.getMaxFeePerGas())); + byte[] message = TransactionEncoder.signMessage(prepared, credentials); + return providerL1.ethSendRawTransaction(Numeric.toHexString(message)); + } + + private Request _depositETHToETHBasedChain(DepositTransaction transaction) { + RequestExecuteTransaction tx = _getDepositEthOnEthBasedChain(transaction); + + if (tx.options.gasLimit == null){ + BigInteger baseGasLimit = estimateGasRequestExecute(tx).sendAsync().join().getAmountUsed(); + tx.options.gasLimit = scaleGasLimit(baseGasLimit); } - FullDepositFee fullFee = new FullDepositFee(); - if (transaction.options.getGasPrice() != null){ - fullFee.gasPrice = transaction.options.getGasPrice(); + return requestExecute(tx); + } + + private GetDepositTransaction _getDepositNonBaseTokenToNonETHBasedChain(DepositTransaction transaction) { + IBridgehub bridgehub = getBridgehubContract(); + BigInteger chainId = providerL2.ethChainId().sendAsync().join().getChainId(); + L1BridgeContracts bridgeContracts = getL1BridgeContracts(); + + _getDepositTxWithDefaults(transaction); + + BigInteger gasPriceForestimation = transaction.options.maxFeePerGas != null ? + transaction.options.maxFeePerGas : transaction.options.getGasPrice(); + BigInteger baseCost = getBaseCost( + transaction.l2GasLimit, + transaction.gasPerPubdataByte, + gasPriceForestimation).sendAsync().join(); + + BigInteger mintValue = baseCost.add(transaction.operatorTip); + checkBaseCost(baseCost, mintValue); + transaction.options.value = BigInteger.ZERO; + + Function f = new Function(null, + Arrays.asList(new Address(transaction.tokenAddress), new Uint256(transaction.amount), new Address(transaction.to)), + Collections.emptyList()); + String secondBridgeCalldata = Numeric.prependHexPrefix(FunctionEncoder.encode(f)); + + String calldata = bridgehub.encodeRequestL2TransactionTwoBridges( + new IBridgehub.L2TransactionRequestTwoBridgesOuter( + chainId, + mintValue, + BigInteger.ZERO, + transaction.l2GasLimit, + transaction.gasPerPubdataByte, + transaction.refoundRecepient, + bridgeContracts.sharedL1Bridge.getContractAddress(), + BigInteger.ZERO, + Numeric.hexStringToByteArray(secondBridgeCalldata))); + + Transaction tx = new Transaction( + credentials.getAddress(), + transaction.options.nonce, + null, + transaction.options.gasLimit, + bridgehub.getContractAddress(), + BigInteger.ZERO, + calldata, + providerL1.ethChainId().sendAsync().join().getChainId().longValue(), + transaction.options.maxPriorityFeePerGas, + transaction.options.maxFeePerGas); + + return new GetDepositTransaction(tx, mintValue, null); + } + + private GetDepositTransaction _getDepositBaseTokenOnNonETHBasedChainTx(DepositTransaction transaction) { + IBridgehub bridgehub = getBridgehubContract(); + BigInteger chainId = providerL2.ethChainId().sendAsync().join().getChainId(); + + _getDepositTxWithDefaults(transaction); + + BigInteger gasPriceForestimation = transaction.options.maxFeePerGas != null ? + transaction.options.maxFeePerGas : transaction.options.getGasPrice(); + BigInteger baseCost = getBaseCost( + transaction.l2GasLimit, + transaction.gasPerPubdataByte, + gasPriceForestimation).sendAsync().join(); + + transaction.options.value = BigInteger.ZERO; + BigInteger mintValue = baseCost.add(transaction.operatorTip.add(transaction.amount)); + return new GetDepositTransaction(null, mintValue, transaction.toRequestExecute(transaction.to)); + } + + private GetDepositTransaction _getDepositETHOnNonETHBasedChainTx(DepositTransaction transaction) throws Exception { + IBridgehub bridgehub = getBridgehubContract(); + BigInteger chainId = providerL2.ethChainId().sendAsync().join().getChainId(); + IL1Bridge sharedBridge = getL1BridgeContracts().sharedL1Bridge; + + _getDepositTxWithDefaults(transaction); + + BigInteger gasPriceForestimation = transaction.options.maxFeePerGas != null ? + transaction.options.maxFeePerGas : transaction.options.getGasPrice(); + BigInteger baseCost = getBaseCost( + transaction.l2GasLimit, + transaction.gasPerPubdataByte, + gasPriceForestimation).sendAsync().join(); + + transaction.options.value = transaction.options.value != null ? transaction.options.value : transaction.amount; + BigInteger mintValue = baseCost.add(transaction.operatorTip); + checkBaseCost(baseCost, mintValue); + + Function f = new Function(null, + Arrays.asList(new Address(ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS), new Uint256(BigInteger.ZERO), new Address(transaction.to)), + Collections.emptyList()); + String secondBridgeCalldata = Numeric.prependHexPrefix(FunctionEncoder.encode(f)); + + String calldata = bridgehub.encodeRequestL2TransactionTwoBridges( + new IBridgehub.L2TransactionRequestTwoBridgesOuter( + chainId, + mintValue, + BigInteger.ZERO, + transaction.l2GasLimit, + transaction.gasPerPubdataByte, + transaction.refoundRecepient, + sharedBridge.getContractAddress(), + transaction.amount, + Numeric.hexStringToByteArray(secondBridgeCalldata))); + BigInteger a = getBalanceL1().send(); + String aaa = bridgehub.requestL2TransactionTwoBridges( + new IBridgehub.L2TransactionRequestTwoBridgesOuter( + chainId, + mintValue, + BigInteger.ZERO, + transaction.l2GasLimit, + transaction.gasPerPubdataByte, + transaction.refoundRecepient, + sharedBridge.getContractAddress(), + transaction.amount, + Numeric.hexStringToByteArray(secondBridgeCalldata)), BigInteger.ZERO).encodeFunctionCall(); + BigInteger b = getBalanceL1().send(); + + Transaction tx = new Transaction( + credentials.getAddress(), + transaction.options.nonce, + null, + transaction.options.gasLimit, + bridgehub.getContractAddress(), + transaction.amount, + calldata, + providerL1.ethChainId().sendAsync().join().getChainId().longValue(), + transaction.options.maxPriorityFeePerGas, + transaction.options.maxFeePerGas); + + return new GetDepositTransaction(tx, mintValue, null); + } + + private Transaction _getDepositTokenOnETHBasedChainTx(DepositTransaction transaction){ + IBridgehub bridgehub = getBridgehubContract(); + BigInteger chainId = providerL2.ethChainId().sendAsync().join().getChainId(); + + _getDepositTxWithDefaults(transaction); + + BigInteger gasPriceForestimation = transaction.options.maxFeePerGas != null ? + transaction.options.maxFeePerGas : transaction.options.getGasPrice(); + BigInteger baseCost = getBaseCost( + transaction.l2GasLimit, + transaction.gasPerPubdataByte, + gasPriceForestimation).sendAsync().join(); + + BigInteger mintValue = baseCost.add(transaction.operatorTip); + transaction.options.value = transaction.options.value != null ? transaction.options.value : mintValue; + checkBaseCost(baseCost, mintValue); + + String secondBridgeAddress; + String secondBridgeCalldata; + if (transaction.bridgeAddress != null){ + secondBridgeAddress = transaction.bridgeAddress; + secondBridgeCalldata = getERC20DefaultBridgeData(transaction.tokenAddress, providerL1, credentials, gasProvider); }else{ - fullFee.maxFeePerGas = transaction.options.getMaxFeePerGas(); - fullFee.maxPriorityFeePerGas = transaction.options.getMaxPriorityFeePerGas(); + secondBridgeAddress = getL1BridgeContracts().sharedL1Bridge.getContractAddress(); + Function f = new Function(null, + Arrays.asList(new Address(transaction.tokenAddress), new Uint256(transaction.amount), new Address(transaction.to)), + Collections.emptyList()); + secondBridgeCalldata = Numeric.prependHexPrefix(FunctionEncoder.encode(f)); } - transaction.options.setGasPrice(null); - transaction.options.setMaxPriorityFeePerGas(null); - transaction.options.setMaxFeePerGas(null); + String calldata = bridgehub.encodeRequestL2TransactionTwoBridges( + new IBridgehub.L2TransactionRequestTwoBridgesOuter( + chainId, + mintValue, + BigInteger.ZERO, + transaction.l2GasLimit, + transaction.gasPerPubdataByte, + transaction.refoundRecepient, + secondBridgeAddress, + BigInteger.ZERO, + Numeric.hexStringToByteArray(secondBridgeCalldata))); + return new Transaction( + credentials.getAddress(), + transaction.options.nonce, + null, + transaction.options.gasLimit, + bridgehub.getContractAddress(), + mintValue, + calldata, + providerL1.ethChainId().sendAsync().join().getChainId().longValue(), + transaction.options.maxPriorityFeePerGas, + transaction.options.maxFeePerGas); + } + + private RequestExecuteTransaction _getDepositEthOnEthBasedChain(DepositTransaction transaction){ + IBridgehub bridgehub = getBridgehubContract(); + BigInteger chainId = providerL2.ethChainId().sendAsync().join().getChainId(); + + _getDepositTxWithDefaults(transaction); + + BigInteger gasPriceForestimation = transaction.options.getMaxFeePerGas() != null ? + transaction.options.getMaxFeePerGas() : transaction.options.getGasPrice(); + BigInteger baseCost = getBaseCost(transaction.l2GasLimit, transaction.gasPerPubdataByte, gasPriceForestimation).sendAsync().join(); - fullFee.l1GasLimit = estimateGasDeposit(transaction); - fullFee.baseCost = baseCost; - fullFee.l2GasLimit = transaction.l2GasLimit; + transaction.options.setValue(baseCost.add(transaction.operatorTip.add(transaction.amount))); - return fullFee; + return transaction.toRequestExecute(transaction.to); } - public DepositTransaction getDepositTransaction(DepositTransaction transaction){ - L1BridgeContracts l1BridgeContracts = getL1BridgeContracts(); - l1BridgeContracts.erc20L1Bridge = transaction.bridgeAddress != null ? IL1Bridge.load(transaction.bridgeAddress, providerL1, credentials, gasProvider) : l1BridgeContracts.erc20L1Bridge; + private DepositTransaction _getDepositTxWithDefaults(DepositTransaction transaction){ transaction.to = transaction.to == null ? signer.getAddress() : transaction.to; transaction.refoundRecepient = transaction.refoundRecepient == null ? signer.getAddress() : transaction.refoundRecepient; transaction.operatorTip = transaction.operatorTip == null ? BigInteger.ZERO : transaction.operatorTip; transaction.gasPerPubdataByte = transaction.gasPerPubdataByte == null ? L1_TO_L2_GAS_PER_PUBDATA : transaction.gasPerPubdataByte; - transaction.customBridgeData = transaction.customBridgeData == null ? Numeric.hexStringToByteArray("0x") : transaction.customBridgeData; + transaction.options = transaction.options == null ? new TransactionOptions() : transaction.options; + transaction.l2GasLimit = transaction.l2GasLimit == null ? _getL2GasLimit(transaction) : transaction.l2GasLimit; + + insertGasPriceInTransactionOptions(transaction.options, providerL1); + + return transaction; + } + + private BigInteger _getL2GasLimit(DepositTransaction transaction){ if (transaction.bridgeAddress != null){ - String customBridgeData = transaction.customBridgeData == null ? - (transaction.bridgeAddress == l1BridgeContracts.wethL1Bridge.getContractAddress() ? "0x" : - getERC20DefaultBridgeData(transaction.tokenAddress, providerL1, credentials, gasProvider)) - : Numeric.toHexString(transaction.customBridgeData); - IL1Bridge bridge = IL1Bridge.load(transaction.tokenAddress, providerL1, transactionManager, gasProvider); - String l2Address = bridge.l2Bridge().sendAsync().join(); - if (transaction.l2GasLimit == null){ - transaction.l2GasLimit = estimateCustomBridgeDepositL2Gas(transaction.bridgeAddress, l2Address, transaction.tokenAddress, transaction.amount, transaction.to, customBridgeData, signer.getAddress(), transaction.gasPerPubdataByte, transaction.options.getValue(), providerL2); - } - } else { - transaction.l2GasLimit = estimateDefaultBridgeDepositL2Gas( - transaction.tokenAddress, transaction.amount, transaction.to, providerL2, getL1BridgeContracts(), providerL1, credentials, gasProvider, signer.getAddress(), transaction.gasPerPubdataByte); - } - transaction.options = insertGasPriceInTransactionOptions(transaction.options, providerL1); - transaction.options.setChainId(transaction.options.getChainId() == null ? providerL1.ethChainId().sendAsync().join().getChainId() : transaction.options.getChainId()); - transaction.options.setNonce(transaction.options.getNonce() == null ? providerL1.ethGetTransactionCount(signer.getAddress(), DefaultBlockParameterName.LATEST).sendAsync().join().getTransactionCount() : transaction.options.getNonce()); - BigInteger gasPriceForEstimation = transaction.options.getMaxFeePerGas() == null ? transaction.options.getGasPrice() : transaction.options.getMaxFeePerGas(); - BigInteger baseCost = contract.l2TransactionBaseCost(gasPriceForEstimation, transaction.l2GasLimit, transaction.gasPerPubdataByte).sendAsync().join(); - - if (transaction.tokenAddress == ZkSyncAddresses.ETH_ADDRESS){ - if (transaction.options.getValue() == null){ - transaction.options.setValue(baseCost.add(transaction.amount.add(transaction.operatorTip))); - } - return transaction; + return _getL2GasLimitFromCustomBridge(transaction); } - if (transaction.options.getValue() == null){ - transaction.options.setValue(baseCost.add(transaction.operatorTip)); + return estimateDefaultBridgeDepositL2Gas( + transaction.tokenAddress, transaction.amount, transaction.to, providerL2, providerL1, credentials,gasProvider, signer.getAddress(), transaction.gasPerPubdataByte); + } + + private BigInteger _getL2GasLimitFromCustomBridge(DepositTransaction transaction){ + String bridgeData = transaction.customBridgeData != null ? + Numeric.toHexString(transaction.customBridgeData) : + getERC20DefaultBridgeData(transaction.tokenAddress, providerL1, credentials, gasProvider); + + IL1Bridge bridge = IL1Bridge.load(transaction.tokenAddress, providerL1, credentials, gasProvider); + BigInteger chainId = providerL2.ethChainId().sendAsync().join().getChainId(); + String l2Address = bridge.l2BridgeAddress(chainId).sendAsync().join(); + + return WalletUtils.estimateCustomBridgeDepositL2Gas( + transaction.bridgeAddress, + l2Address, + transaction.tokenAddress, + transaction.amount, + transaction.to, + bridgeData, + credentials.getAddress(), + transaction.gasPerPubdataByte, + BigInteger.ZERO, + providerL2 + ); + } + + public BigInteger estimateGasDeposit(DepositTransaction transaction) throws Exception { + if (transaction.tokenAddress.equalsIgnoreCase(ZkSyncAddresses.LEGACY_ETH_ADDRESS)){ + transaction.tokenAddress = ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS; } - checkBaseCost(baseCost, transaction.options.getValue()); + String baseTokenAddress = getBaseToken().sendAsync().join(); + boolean isEthBasedChain = baseTokenAddress.equalsIgnoreCase(ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS); + + BigInteger baseGasLimit = BigInteger.ZERO; + if (isEthBasedChain && transaction.tokenAddress.equalsIgnoreCase(ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS)){ + RequestExecuteTransaction tx = _getDepositEthOnEthBasedChain(transaction); + baseGasLimit = estimateGasRequestExecute(tx).sendAsync().join().getAmountUsed(); + }else if (baseTokenAddress.equalsIgnoreCase(ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS)){ + Transaction tx = _getDepositTokenOnETHBasedChainTx(transaction); + baseGasLimit = providerL1.ethEstimateGas(tx).sendAsync().join().getAmountUsed(); + }else if (transaction.tokenAddress.equalsIgnoreCase(ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS)){ + Transaction tx = _getDepositETHOnNonETHBasedChainTx(transaction).tx; + baseGasLimit = providerL1.ethEstimateGas(tx).sendAsync().join().getAmountUsed(); + } else if (transaction.tokenAddress.equalsIgnoreCase(baseTokenAddress)) { + RequestExecuteTransaction tx = _getDepositBaseTokenOnNonETHBasedChainTx(transaction).requestExecuteTransaction; + baseGasLimit = estimateGasRequestExecute(tx).sendAsync().join().getAmountUsed(); + }else{ + Transaction tx = _getDepositNonBaseTokenToNonETHBasedChain(transaction).tx; + baseGasLimit = providerL1.ethEstimateGas(tx).sendAsync().join().getAmountUsed(); + } + return scaleGasLimit(baseGasLimit); + } + + public RemoteCall getFullRequiredDepositFee(DepositTransaction transaction){ + return new RemoteCall<>(() -> { + if (transaction.tokenAddress.equalsIgnoreCase(ZkSyncAddresses.LEGACY_ETH_ADDRESS)){ + transaction.tokenAddress = ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS; + } + transaction.amount = BigInteger.valueOf(1); + IBridgehub bridgehub = getBridgehubContract(); + String baseTokenAddress = getBaseToken().sendAsync().join(); + BigInteger chainId = providerL2.ethChainId().sendAsync().join().getChainId(); + boolean isEthBasedChain = isETHBasedChain(); + + _getDepositTxWithDefaults(transaction); + + BigInteger gasPriceForestimation = transaction.options.maxFeePerGas != null ? + transaction.options.maxFeePerGas : transaction.options.getGasPrice(); + BigInteger baseCost = getBaseCost( + transaction.l2GasLimit, + transaction.gasPerPubdataByte, + gasPriceForestimation).sendAsync().join(); + + if (isEthBasedChain){ + BigInteger selfBalanceEth = getBalanceL1().sendAsync().join(); + if (baseCost.compareTo(selfBalanceEth.add(transaction.amount)) >= 0){ + BigInteger recommendedL1GasLimit = transaction.tokenAddress.equalsIgnoreCase(ZkSyncAddresses.LEGACY_ETH_ADDRESS) + ? L1_RECOMMENDED_MIN_ETH_DEPOSIT_GAS_LIMIT + : L1_RECOMMENDED_MIN_ERC20_DEPOSIT_GAS_LIMIT; + BigInteger recommendedETHBalance = recommendedL1GasLimit.multiply(gasPriceForestimation).add(baseCost); + throw new Error("Not enough balance for deposit. Under the provided gas price, the recommended balance to perform a deposit is " + recommendedETHBalance + " ETH"); + } + if (!transaction.tokenAddress.equalsIgnoreCase(ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS) && + getAllowanceL1(transaction.tokenAddress, transaction.bridgeAddress).sendAsync().join().compareTo(transaction.amount) < 0){ + throw new Error("Not enough allowance to cover the deposit!"); + } + }else{ + BigInteger mintValue = baseCost.add(transaction.operatorTip); + + if (getAllowanceL1(baseTokenAddress).sendAsync().join().compareTo(mintValue) < 0){ + throw new Error("Not enough base token allowance to cover the deposit!"); + } + if (transaction.tokenAddress.equalsIgnoreCase(ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS) || + transaction.tokenAddress.equalsIgnoreCase(baseTokenAddress)){ + transaction.options.value = transaction.amount; + }else{ + transaction.options.value = BigInteger.ZERO; + if (getAllowanceL1(transaction.tokenAddress).sendAsync().join().compareTo(transaction.amount) < 0){ + throw new Error("Not enough token allowance to cover the deposit!"); + } + } + } + FullDepositFee fullFee = new FullDepositFee(); + if (transaction.options.getGasPrice() != null){ + fullFee.gasPrice = transaction.options.getGasPrice(); + }else{ + fullFee.maxFeePerGas = transaction.options.getMaxFeePerGas(); + fullFee.maxPriorityFeePerGas = transaction.options.getMaxPriorityFeePerGas(); + } + + transaction.options.setGasPrice(null); + transaction.options.setMaxPriorityFeePerGas(null); + transaction.options.setMaxFeePerGas(null); + + fullFee.l1GasLimit = estimateGasDeposit(transaction); + fullFee.baseCost = baseCost; + fullFee.l2GasLimit = transaction.l2GasLimit; + + return fullFee; + }); + } + + public void getPriorityOpConfirmation(String txHash, int index){ - return transaction; } public RemoteFunctionCall finalizeWithdraw(String txHash, int index) throws Exception { @@ -433,17 +939,10 @@ public RemoteFunctionCall finalizeWithdraw(String txHash, in for (int i = 0 ; i < l2ToL1MessageProof.getProof().size() ; i++){ merkle_proof.add(Numeric.hexStringToByteArray(l2ToL1MessageProof.getProof().get(i))); } - byte[] senderBytes = Numeric.hexStringToByteArray(log.getTopics().get(1)); - String sender = Numeric.toHexString(Arrays.copyOfRange(senderBytes, 12, senderBytes.length)); - if (sender.equals(L2_ETH_TOKEN_ADDRESS)){ - return contract.finalizeEthWithdrawal(l1BatchNumber, BigInteger.valueOf(l2ToL1MessageProof.getId()), receipt.getL1BatchTxIndex(), bytes_data, merkle_proof); - } - IL2Bridge il2Bridge = IL2Bridge.load(sender, providerL2, credentials, gasProvider); - String a = il2Bridge.l1Bridge().send(); - IL1Bridge il1Bridge = IL1Bridge.load(il2Bridge.l1Bridge().send(), providerL1, transactionManager, gasProvider); + IL1Bridge il1Bridge = IL1Bridge.load(getL1BridgeContracts().sharedL1Bridge.getContractAddress(), providerL1, transactionManager, gasProvider); - return il1Bridge.finalizeWithdrawal(l1BatchNumber, BigInteger.valueOf(l2ToL1MessageProof.getId()), receipt.getL1BatchTxIndex(), bytes_data, merkle_proof); + return il1Bridge.finalizeWithdrawal(providerL2.ethChainId().sendAsync().join().getChainId(), l1BatchNumber, BigInteger.valueOf(l2ToL1MessageProof.getId()), receipt.getL1BatchTxIndex(), bytes_data, merkle_proof); } public int getWithdrawalLogIndex(List logs, int index){ @@ -471,22 +970,50 @@ public int getWithdrawalL2ToL1LogIndex(List logs, int index){ return logIndex.get(index); } - public Request requestExecute(RequestExecuteTransaction transaction) throws IOException { - transaction = getRequestExecuteTransaction(transaction); - String data = contract.encodeRequestL2Transaction(transaction.getContractAddress(), transaction.getL2Value(), transaction.getCalldata(), transaction.getL2GasLimit(), transaction.getGasPerPubDataByte(), Collections.emptyList(), transaction.getRefoundRecepient(), transaction.getOptions().getValue()); - RawTransaction tx = RawTransaction.createTransaction(transaction.getOptions().getChainId().longValue(), transaction.getOptions().getNonce(), transaction.getOptions().getGasLimit(), transaction.getContractAddress(), transaction.getOptions().getValue(), data, transaction.getOptions().getMaxPriorityFeePerGas(), transaction.getOptions().getMaxFeePerGas()); + public Request requestExecute(RequestExecuteTransaction transaction) { + RawTransaction tx = getRequestExecuteTransaction(transaction); byte[] message = TransactionEncoder.signMessage(tx, credentials); return providerL1.ethSendRawTransaction(Numeric.toHexString(message)); } public Request estimateGasRequestExecute(RequestExecuteTransaction transaction){ - transaction = getRequestExecuteTransaction(transaction); - transaction.getOptions().setGasPrice(null); - transaction.getOptions().setMaxFeePerGas(null); - transaction.getOptions().setMaxPriorityFeePerGas(null); - String data = contract.encodeRequestL2Transaction(transaction.getContractAddress(), transaction.getL2Value(), transaction.getCalldata(), transaction.getL2GasLimit(), transaction.getGasPerPubDataByte(), Collections.emptyList(), transaction.getRefoundRecepient(), transaction.getOptions().getValue()); - org.web3j.protocol.core.methods.request.Transaction tr = Transaction.createEthCallTransaction(signer.getAddress(), transaction.getContractAddress(), data, transaction.getOptions().getValue()); + RawTransaction tx = getRequestExecuteTransaction(transaction); + + org.web3j.protocol.core.methods.request.Transaction tr = Transaction.createEthCallTransaction(signer.getAddress(), tx.getTo(), tx.getData(), tx.getValue()); return providerL1.ethEstimateGas(tr); } + public AllowanceParams getRequestExecuteAllowanceParams(RequestExecuteTransaction transaction){ + boolean isEthBasedChain = isETHBasedChain(); + + if (isEthBasedChain){ + throw new Error("ETH token can't be approved! The address of the token does not exist on L1."); + } + + if (transaction.getOperatorTip() == null){ + transaction.setOperatorTip(BigInteger.valueOf(0)); + } + if (transaction.getGasPerPubDataByte() == null){ + transaction.setGasPerPubDataByte(BigInteger.valueOf(800)); + } + if (transaction.getRefoundRecepient() == null){ + transaction.setRefoundRecepient(signer.getAddress()); + } + if (transaction.l2Value == null){ + transaction.l2Value = BigInteger.ZERO; + } + if (transaction.getL2GasLimit() == null){ + transaction.setL2GasLimit(providerL2.estimateL1ToL2Execute(transaction.getContractAddress(), transaction.getCalldata(), getSigner().getAddress(), null, transaction.l2Value, transaction.getFactoryDeps(), transaction.getOperatorTip(), transaction.getGasPerPubDataByte(), transaction.getRefoundRecepient()).sendAsync().join().getAmountUsed()); + } + if (transaction.getFactoryDeps() == null) + transaction.setFactoryDeps(new byte[1][]); + + insertGasPriceInTransactionOptions(transaction.options, providerL1); + + BigInteger gasPriceForestimation = transaction.getOptions().getMaxFeePerGas() != null ? transaction.getOptions().getMaxFeePerGas() : transaction.getOptions().getGasPrice(); + + BigInteger baseCost = getBaseCost(transaction.getL2GasLimit(), transaction.getGasPerPubDataByte(), gasPriceForestimation).sendAsync().join(); + + return new AllowanceParams(getBaseToken().sendAsync().join(), baseCost.add(transaction.operatorTip.add(transaction.l2Value))); + } } diff --git a/src/main/java/io/zksync/protocol/core/BridgeAddresses.java b/src/main/java/io/zksync/protocol/core/BridgeAddresses.java index b51a6a7..02ba6db 100644 --- a/src/main/java/io/zksync/protocol/core/BridgeAddresses.java +++ b/src/main/java/io/zksync/protocol/core/BridgeAddresses.java @@ -10,6 +10,8 @@ public class BridgeAddresses { private String l1Erc20DefaultBridge; private String l2Erc20DefaultBridge; - private String l1wETHBridge; - private String l2wETHBridge; + private String l1WethBridge; + private String l2WethBridge; + private String l1SharedDefaultBridge; + private String l2SharedDefaultBridge; } diff --git a/src/main/java/io/zksync/protocol/provider/DefaultEthereumProvider.java b/src/main/java/io/zksync/protocol/provider/DefaultEthereumProvider.java index 7ce0474..f97f1b5 100755 --- a/src/main/java/io/zksync/protocol/provider/DefaultEthereumProvider.java +++ b/src/main/java/io/zksync/protocol/provider/DefaultEthereumProvider.java @@ -111,7 +111,7 @@ public CompletableFuture deposit(Token token, BigInteger amo } else { BigInteger gasLimit = GAS_LIMITS.getOrDefault(token.getL1Address(), BigInteger.valueOf(300000)); BigInteger totalAmount = operatorTips.add(baseCost); - return l1ERC20Bridge.deposit(userAddress, token.getL1Address(), amount, gasLimit, L1_TO_L2_GAS_PER_PUBDATA, userAddress, totalAmount).sendAsync().join(); + return l1ERC20Bridge.deposit(web3j.ethChainId().sendAsync().join().getChainId() ,userAddress, token.getL1Address(), BigInteger.ZERO, amount, gasLimit, L1_TO_L2_GAS_PER_PUBDATA, userAddress, totalAmount).sendAsync().join(); } }); } @@ -154,7 +154,7 @@ public TransactionReceipt finalizeWithdraw(String txHash, int index) throws Exce IL2Bridge il2Bridge = IL2Bridge.load(sender, web3j, transactionManager, gasProvider); IL1Bridge il1Bridge = IL1Bridge.load(il2Bridge.l1Bridge().send(), web3j, transactionManager, gasProvider); - return il1Bridge.finalizeWithdrawal(l1BatchNumber, BigInteger.valueOf(l2ToL1MessageProof.getId()), receipt.getL1BatchTxIndex(), bytes_data, merkle_proof).sendAsync().join(); + return il1Bridge.finalizeWithdrawal(web3j.ethChainId().sendAsync().join().getChainId() ,l1BatchNumber, BigInteger.valueOf(l2ToL1MessageProof.getId()), receipt.getL1BatchTxIndex(), bytes_data, merkle_proof).sendAsync().join(); } public int getWithdrawalLogIndex(List logs, int index){ diff --git a/src/main/java/io/zksync/transaction/response/ZkSyncTransactionReceiptProcessor.java b/src/main/java/io/zksync/transaction/response/ZkSyncTransactionReceiptProcessor.java index b9a37a9..7370f50 100644 --- a/src/main/java/io/zksync/transaction/response/ZkSyncTransactionReceiptProcessor.java +++ b/src/main/java/io/zksync/transaction/response/ZkSyncTransactionReceiptProcessor.java @@ -1,12 +1,14 @@ package io.zksync.transaction.response; import io.zksync.protocol.ZkSync; +import org.web3j.protocol.core.DefaultBlockParameterName; import org.web3j.protocol.core.methods.response.EthGetTransactionReceipt; import org.web3j.protocol.core.methods.response.TransactionReceipt; import org.web3j.protocol.exceptions.TransactionException; import org.web3j.tx.response.TransactionReceiptProcessor; import java.io.IOException; +import java.math.BigInteger; import java.util.Optional; public class ZkSyncTransactionReceiptProcessor extends TransactionReceiptProcessor { @@ -58,6 +60,41 @@ private TransactionReceipt getTransactionReceipt( transactionHash); } + public TransactionReceipt waitFinalized(String transactionHash) + throws IOException, TransactionException { + return waitFinalized(transactionHash, sleepDuration, attempts); + } + + public TransactionReceipt waitFinalized( + String transactionHash, long sleepDuration, int attempts) + throws IOException, TransactionException { + + Optional receiptOptional = + sendTransactionReceiptRequest(transactionHash); + BigInteger blockNumber = zkSync.ethGetBlockByNumber(DefaultBlockParameterName.FINALIZED, false).sendAsync().join().getBlock().getNumber(); + for (int i = 0; i < attempts; i++) { + if (!receiptOptional.isPresent() || receiptOptional.get().getBlockHash() == null || receiptOptional.get().getBlockNumber().compareTo(blockNumber) > 0) { + try { + Thread.sleep(sleepDuration); + } catch (InterruptedException e) { + throw new TransactionException(e); + } + + blockNumber = zkSync.ethGetBlockByNumber(DefaultBlockParameterName.FINALIZED, false).sendAsync().join().getBlock().getNumber(); + receiptOptional = sendTransactionReceiptRequest(transactionHash); + } else { + return receiptOptional.get(); + } + } + + throw new TransactionException( + "Transaction receipt was not generated after " + + ((sleepDuration * attempts) / 1000 + + " seconds for transaction: " + + transactionHash), + transactionHash); + } + Optional sendTransactionReceiptRequest(String transactionHash) throws IOException, TransactionException { EthGetTransactionReceipt transactionReceipt = diff --git a/src/main/java/io/zksync/transaction/type/AllowanceParams.java b/src/main/java/io/zksync/transaction/type/AllowanceParams.java new file mode 100644 index 0000000..288c295 --- /dev/null +++ b/src/main/java/io/zksync/transaction/type/AllowanceParams.java @@ -0,0 +1,11 @@ +package io.zksync.transaction.type; + +import lombok.AllArgsConstructor; + +import java.math.BigInteger; + +@AllArgsConstructor +public class AllowanceParams { + public String token; + public BigInteger amount; +} diff --git a/src/main/java/io/zksync/transaction/type/DepositTransaction.java b/src/main/java/io/zksync/transaction/type/DepositTransaction.java index 7fa6b77..bf9f416 100644 --- a/src/main/java/io/zksync/transaction/type/DepositTransaction.java +++ b/src/main/java/io/zksync/transaction/type/DepositTransaction.java @@ -1,6 +1,7 @@ package io.zksync.transaction.type; import io.zksync.wrappers.IL1Bridge; +import lombok.AllArgsConstructor; import org.jetbrains.annotations.Nullable; import org.web3j.protocol.Web3j; import org.web3j.protocol.core.methods.request.Transaction; @@ -10,6 +11,7 @@ import java.util.Arrays; import java.util.Objects; +@AllArgsConstructor public class DepositTransaction { public String tokenAddress; public BigInteger amount; @@ -21,7 +23,10 @@ public class DepositTransaction { public BigInteger operatorTip; public String refoundRecepient; public Boolean approveERC20; + public Boolean approveBaseERC20; public TransactionOptions options; + public TransactionOptions approveOptions; + public TransactionOptions approveBaseOptions; public DepositTransaction(String tokenAddress, BigInteger amount, @Nullable String to, @Nullable BigInteger l2GasLimit, @Nullable String bridgeAddress, @Nullable byte[] customBridgeData, @Nullable BigInteger gasPerPubdataByte, @Nullable BigInteger operatorTip, @Nullable String refoundRecepient, @Nullable Boolean approveERC20, @Nullable TransactionOptions options) { this.tokenAddress = tokenAddress; @@ -37,6 +42,19 @@ public DepositTransaction(String tokenAddress, BigInteger amount, @Nullable Stri this.options = options; } + public DepositTransaction(String tokenAddress, BigInteger amount, Boolean approveBaseERC20) { + this.tokenAddress = tokenAddress; + this.amount = amount; + this.approveBaseERC20 = approveBaseERC20; + } + + public DepositTransaction(String tokenAddress, BigInteger amount, Boolean approveBaseERC20, Boolean approveERC20) { + this.tokenAddress = tokenAddress; + this.amount = amount; + this.approveBaseERC20 = approveBaseERC20; + this.approveERC20 = approveERC20; + } + public DepositTransaction(String tokenAddress, BigInteger amount) { this.tokenAddress = tokenAddress; this.amount = amount; @@ -55,6 +73,20 @@ public RequestExecuteTransaction toRequestExecute(String mainContractAddress){ options); } + public RequestExecuteTransaction toRequestExecute(String mainContractAddress, BigInteger mintValue){ + return new RequestExecuteTransaction( + l2GasLimit, + mainContractAddress, + Numeric.hexStringToByteArray("0x"), + amount, + mintValue, + null, + operatorTip, + gasPerPubdataByte, + refoundRecepient, + options); + } + public Transaction toTx(String from, String calldata){ return new Transaction(from, options.getNonce(), options.getGasPrice(), BigInteger.ZERO, bridgeAddress, options.getValue(), calldata, options.getChainId().longValue(), options.getMaxPriorityFeePerGas(), options.getMaxFeePerGas()); } diff --git a/src/main/java/io/zksync/transaction/type/GetDepositTransaction.java b/src/main/java/io/zksync/transaction/type/GetDepositTransaction.java new file mode 100644 index 0000000..2b9d19c --- /dev/null +++ b/src/main/java/io/zksync/transaction/type/GetDepositTransaction.java @@ -0,0 +1,13 @@ +package io.zksync.transaction.type; + +import lombok.AllArgsConstructor; +import org.web3j.protocol.core.methods.request.Transaction; + +import java.math.BigInteger; + +@AllArgsConstructor +public class GetDepositTransaction { + public Transaction tx; + public BigInteger mintValue; + public RequestExecuteTransaction requestExecuteTransaction; +} diff --git a/src/main/java/io/zksync/transaction/type/L1BridgeContracts.java b/src/main/java/io/zksync/transaction/type/L1BridgeContracts.java index ff49c49..2fe11d1 100644 --- a/src/main/java/io/zksync/transaction/type/L1BridgeContracts.java +++ b/src/main/java/io/zksync/transaction/type/L1BridgeContracts.java @@ -9,13 +9,15 @@ public class L1BridgeContracts { public IL1Bridge erc20L1Bridge; public IL1Bridge wethL1Bridge; + public IL1Bridge sharedL1Bridge; - public L1BridgeContracts(IL1Bridge erc20L1Bridge, IL1Bridge wethL1Bridge) { + public L1BridgeContracts(IL1Bridge erc20L1Bridge, IL1Bridge wethL1Bridge, IL1Bridge sharedL1Bridge) { this.erc20L1Bridge = erc20L1Bridge; this.wethL1Bridge = wethL1Bridge; + this.sharedL1Bridge = sharedL1Bridge; } - public L1BridgeContracts(String erc20L1Bridge, String wethL1Bridge, Web3j providerL1, TransactionManager manager, ContractGasProvider gasProvider) { - this(IL1Bridge.load(erc20L1Bridge, providerL1, manager, gasProvider), IL1Bridge.load(wethL1Bridge, providerL1, manager, gasProvider)); + public L1BridgeContracts(String erc20L1Bridge, String wethL1Bridge, String sharedL1Bridge, Web3j providerL1, TransactionManager manager, ContractGasProvider gasProvider) { + this(IL1Bridge.load(erc20L1Bridge, providerL1, manager, gasProvider), IL1Bridge.load(wethL1Bridge, providerL1, manager, gasProvider), IL1Bridge.load(sharedL1Bridge, providerL1, manager, gasProvider)); } } diff --git a/src/main/java/io/zksync/transaction/type/RequestExecuteTransaction.java b/src/main/java/io/zksync/transaction/type/RequestExecuteTransaction.java index f3105f4..78c7b61 100644 --- a/src/main/java/io/zksync/transaction/type/RequestExecuteTransaction.java +++ b/src/main/java/io/zksync/transaction/type/RequestExecuteTransaction.java @@ -1,21 +1,24 @@ package io.zksync.transaction.type; import io.zksync.methods.request.Eip712Meta; +import lombok.AllArgsConstructor; import org.web3j.protocol.core.methods.request.Transaction; import org.web3j.utils.Numeric; import java.math.BigInteger; +@AllArgsConstructor public class RequestExecuteTransaction{ - private BigInteger l2GasLimit; - private String contractAddress; - private byte[] calldata; - private BigInteger l2Value; - private byte[][] factoryDeps; - private BigInteger operatorTip; - private BigInteger gasPerPubDataByte; - private String refoundRecepient; - private TransactionOptions options; + public BigInteger l2GasLimit; + public String contractAddress; + public byte[] calldata; + public BigInteger l2Value; + public BigInteger mintValue; + public byte[][] factoryDeps; + public BigInteger operatorTip; + public BigInteger gasPerPubDataByte; + public String refoundRecepient; + public TransactionOptions options; public RequestExecuteTransaction(BigInteger l2GasLimit, String contractAddress, byte[] calldata, BigInteger l2Value, byte[][] factoryDeps, BigInteger operatorTip, BigInteger gasPerPubDataByte, String refoundRecepient, TransactionOptions transactionOptions) { this.l2GasLimit = l2GasLimit; diff --git a/src/main/java/io/zksync/transaction/type/TransactionOptions.java b/src/main/java/io/zksync/transaction/type/TransactionOptions.java index 15141a8..24957b9 100644 --- a/src/main/java/io/zksync/transaction/type/TransactionOptions.java +++ b/src/main/java/io/zksync/transaction/type/TransactionOptions.java @@ -3,13 +3,13 @@ import java.math.BigInteger; public class TransactionOptions { - private BigInteger nonce; - private BigInteger value; - private BigInteger gasPrice; - private BigInteger maxFeePerGas; - private BigInteger maxPriorityFeePerGas; - private BigInteger gasLimit; - private BigInteger chainId; + public BigInteger nonce; + public BigInteger value; + public BigInteger gasPrice; + public BigInteger maxFeePerGas; + public BigInteger maxPriorityFeePerGas; + public BigInteger gasLimit; + public BigInteger chainId; public TransactionOptions(BigInteger nonce, BigInteger value, BigInteger gasPrice, BigInteger maxFeePerGas, BigInteger maxPriorityFeePerGas, BigInteger gasLimit, BigInteger chainId) { this.nonce = nonce; diff --git a/src/main/java/io/zksync/utils/WalletUtils.java b/src/main/java/io/zksync/utils/WalletUtils.java index 4b028ba..16aec29 100644 --- a/src/main/java/io/zksync/utils/WalletUtils.java +++ b/src/main/java/io/zksync/utils/WalletUtils.java @@ -1,17 +1,13 @@ package io.zksync.utils; import io.zksync.abi.ZkTypeEncoder; -import io.zksync.methods.response.ZkTransactionReceipt; import io.zksync.protocol.ZkSync; -import io.zksync.protocol.core.L2ToL1MessageProof; +import io.zksync.protocol.core.BridgeAddresses; import io.zksync.transaction.type.L1BridgeContracts; import io.zksync.transaction.type.TransactionOptions; import io.zksync.wrappers.ERC20; -import io.zksync.wrappers.IL1Bridge; import io.zksync.wrappers.IL2Bridge; -import io.zksync.wrappers.IZkSync; import org.jetbrains.annotations.Nullable; -import org.web3j.abi.EventValues; import org.web3j.abi.FunctionEncoder; import org.web3j.abi.TypeReference; import org.web3j.abi.datatypes.DynamicBytes; @@ -20,25 +16,21 @@ import org.web3j.abi.datatypes.Utf8String; import org.web3j.abi.datatypes.generated.Uint256; import org.web3j.crypto.Credentials; +import org.web3j.crypto.ECKeyPair; +import org.web3j.crypto.Keys; import org.web3j.protocol.Web3j; import org.web3j.protocol.core.DefaultBlockParameterName; -import org.web3j.protocol.core.RemoteFunctionCall; import org.web3j.protocol.core.methods.response.EthBlock; -import org.web3j.protocol.core.methods.response.Log; -import org.web3j.protocol.core.methods.response.TransactionReceipt; -import org.web3j.tx.Contract; import org.web3j.tx.gas.ContractGasProvider; import org.web3j.utils.Numeric; import java.math.BigInteger; import java.nio.ByteBuffer; -import java.util.ArrayList; +import java.security.InvalidAlgorithmParameterException; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; import java.util.Arrays; import java.util.Collections; -import java.util.List; - -import static io.zksync.utils.ZkSyncAddresses.L2_ETH_TOKEN_ADDRESS; -import static io.zksync.wrappers.IL1Messenger.L1MESSAGESENT_EVENT; public class WalletUtils { private static final BigInteger L1_FEE_ESTIMATION_COEF_NUMERATOR = BigInteger.valueOf(12); @@ -87,28 +79,15 @@ public static String getERC20BridgeCalldata(String l1TokenAddress, String l1Send return FunctionEncoder.encode(function); } - public static BigInteger estimateDefaultBridgeDepositL2Gas(String tokenAddress, BigInteger amount, String to, ZkSync providerL2, L1BridgeContracts bridgeContracts, @Nullable Web3j providerl1, @Nullable Credentials credentials, @Nullable ContractGasProvider gasProvider, @Nullable String from, @Nullable BigInteger gasPerPubDataByte){ - if (tokenAddress == ZkSyncAddresses.ETH_ADDRESS){ + public static BigInteger estimateDefaultBridgeDepositL2Gas(String tokenAddress, BigInteger amount, String to, ZkSync providerL2, @Nullable Web3j providerl1, @Nullable Credentials credentials, @Nullable ContractGasProvider gasProvider, @Nullable String from, @Nullable BigInteger gasPerPubDataByte){ + if (providerL2.isBaseToken(tokenAddress)){ return providerL2.estimateL1ToL2Execute(to, Numeric.hexStringToByteArray("0x"), from, null, amount, null, null, gasPerPubDataByte, null).sendAsync().join().getAmountUsed(); } BigInteger value = BigInteger.ZERO; - String l1BridgeAddress; - String l2BridgeAddress; - String bridgeData; - String l2WethToken = ZkSyncAddresses.ETH_ADDRESS; - try { - l2WethToken = bridgeContracts.wethL1Bridge.l2TokenAddress(tokenAddress).sendAsync().join(); - } catch (Exception e) {} - if (l2WethToken != ZkSyncAddresses.ETH_ADDRESS){ - value = amount; - l1BridgeAddress = bridgeContracts.wethL1Bridge.getContractAddress(); - l2BridgeAddress = providerL2.zksGetBridgeContracts().sendAsync().join().getResult().getL2wETHBridge(); - bridgeData = "0x"; - }else{ - l1BridgeAddress = bridgeContracts.erc20L1Bridge.getContractAddress(); - l2BridgeAddress = providerL2.zksGetBridgeContracts().sendAsync().join().getResult().getL2Erc20DefaultBridge(); - bridgeData = getERC20DefaultBridgeData(tokenAddress, providerl1, credentials, gasProvider); - } + BridgeAddresses bridgeAddresses = providerL2.zksGetBridgeContracts().sendAsync().join().getResult(); + String l1BridgeAddress = bridgeAddresses.getL1SharedDefaultBridge(); + String l2BridgeAddress = bridgeAddresses.getL2SharedDefaultBridge(); + String bridgeData = getERC20DefaultBridgeData(tokenAddress, providerl1, credentials, gasProvider); return estimateCustomBridgeDepositL2Gas( l1BridgeAddress, @@ -124,7 +103,7 @@ public static BigInteger estimateDefaultBridgeDepositL2Gas(String tokenAddress, } public static BigInteger estimateCustomBridgeDepositL2Gas(String l1BridgeAddress, String l2BridgeAddress, String tokenAddress, BigInteger amount, String to, String bridgeData, String from, BigInteger gasPerBudDataByte, BigInteger value, ZkSync provider){ - String calldata = getERC20BridgeCalldata(tokenAddress, from, to,amount, Numeric.hexStringToByteArray(bridgeData)); + String calldata = getERC20BridgeCalldata(tokenAddress, from, to, amount, Numeric.hexStringToByteArray(bridgeData)); return provider.estimateL1ToL2Execute( l2BridgeAddress, Numeric.hexStringToByteArray(calldata), applyL1ToL2Alias(l1BridgeAddress), null, value, null, null, gasPerBudDataByte, null).sendAsync().join().getAmountUsed(); } @@ -142,11 +121,14 @@ public static String undoL1ToL2Alias(String address){ } public static String getERC20DefaultBridgeData(String l1TokenAddress, Web3j provider, Credentials credentials, ContractGasProvider gasProvider){ + if (l1TokenAddress.equalsIgnoreCase(ZkSyncAddresses.LEGACY_ETH_ADDRESS)){ + l1TokenAddress = ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS; + } ERC20 token = ERC20.load(l1TokenAddress, provider, credentials, gasProvider); - String name = token.name().sendAsync().join(); - String symbol = token.symbol().sendAsync().join(); - BigInteger decimals = token.decimals().sendAsync().join(); + String name = l1TokenAddress.equalsIgnoreCase(ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS) ? "Ether" : token.name().sendAsync().join(); + String symbol = l1TokenAddress.equalsIgnoreCase(ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS) ? "ETH" : token.symbol().sendAsync().join(); + BigInteger decimals = l1TokenAddress.equalsIgnoreCase(ZkSyncAddresses.ETH_ADDRESS_IN_CONTRACTS) ? BigInteger.valueOf(18) : token.decimals().sendAsync().join(); String nameEncoded = encode(name); String symbolEncoded = encode(symbol); @@ -198,4 +180,19 @@ public static boolean checkBaseCost(BigInteger baseCost, BigInteger value){ return true; } + public static Credentials createRandomCredentials(){ + ECKeyPair keyPair = null; + try { + keyPair = Keys.createEcKeyPair(); + } catch (InvalidAlgorithmParameterException e) { + throw new RuntimeException(e); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException(e); + } catch (NoSuchProviderException e) { + throw new RuntimeException(e); + } + + return Credentials.create(keyPair); + } + } diff --git a/src/main/java/io/zksync/utils/ZkSyncAddresses.java b/src/main/java/io/zksync/utils/ZkSyncAddresses.java index 9c5d4b3..7f57c40 100644 --- a/src/main/java/io/zksync/utils/ZkSyncAddresses.java +++ b/src/main/java/io/zksync/utils/ZkSyncAddresses.java @@ -2,10 +2,38 @@ public final class ZkSyncAddresses { + /** + * The address of the L1 `ETH` token. + * @constant + */ + @Deprecated public static final String ETH_ADDRESS = "0x0000000000000000000000000000000000000000"; + /** + * The address of the L1 `ETH` token. + * @constant + */ + public static final String LEGACY_ETH_ADDRESS = "0x0000000000000000000000000000000000000000"; + + /** + * In the contracts the zero address can not be used, use one instead + * @constant + */ + public static final String ETH_ADDRESS_IN_CONTRACTS = "0x0000000000000000000000000000000000000001"; public static final String CONTRACT_DEPLOYER_ADDRESS = "0x0000000000000000000000000000000000008006"; public static final String NONCE_HOLDER_ADDRESS = "0x0000000000000000000000000000000000008003"; public static final String MESSENGER_ADDRESS = "0x0000000000000000000000000000000000008008"; + @Deprecated public static final String L2_ETH_TOKEN_ADDRESS = "0x000000000000000000000000000000000000800a"; + /** + * The address of the base token. + * @constant + */ + public static final String L2_BASE_TOKEN_ADDRESS = "0x000000000000000000000000000000000000800a"; + public static final String BOOTLOADER_FORMAL_ADDRESS = "0x0000000000000000000000000000000000008001"; + public static boolean isEth(String token){ + return token.equalsIgnoreCase(ETH_ADDRESS_IN_CONTRACTS) || + token.equalsIgnoreCase(L2_BASE_TOKEN_ADDRESS) || + token.equalsIgnoreCase(LEGACY_ETH_ADDRESS); + } } diff --git a/src/main/java/io/zksync/wrappers/ERC20.java b/src/main/java/io/zksync/wrappers/ERC20.java index ec44088..01cfbf5 100644 --- a/src/main/java/io/zksync/wrappers/ERC20.java +++ b/src/main/java/io/zksync/wrappers/ERC20.java @@ -1,7 +1,7 @@ package io.zksync.wrappers; import io.reactivex.Flowable; -import io.reactivex.functions.Function; + import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; @@ -10,10 +10,7 @@ import org.web3j.abi.EventEncoder; import org.web3j.abi.FunctionEncoder; import org.web3j.abi.TypeReference; -import org.web3j.abi.datatypes.Address; -import org.web3j.abi.datatypes.Event; -import org.web3j.abi.datatypes.Type; -import org.web3j.abi.datatypes.Utf8String; +import org.web3j.abi.datatypes.*; import org.web3j.abi.datatypes.generated.Uint256; import org.web3j.abi.datatypes.generated.Uint8; import org.web3j.crypto.Credentials; @@ -59,11 +56,11 @@ public class ERC20 extends Contract { public static final String FUNC_TRANSFERFROM = "transferFrom"; - public static final Event APPROVAL_EVENT = new Event("Approval", + public static final Event APPROVAL_EVENT = new Event("Approval", Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {}, new TypeReference() {})); ; - public static final Event TRANSFER_EVENT = new Event("Transfer", + public static final Event TRANSFER_EVENT = new Event("Transfer", Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {}, new TypeReference() {})); ; @@ -85,11 +82,11 @@ protected ERC20(String contractAddress, Web3j web3j, TransactionManager transact super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); } - public static List getApprovalEvents(TransactionReceipt transactionReceipt) { + public static List getApprovalEvents(TransactionReceipt transactionReceipt) { List valueList = staticExtractEventParametersWithLog(APPROVAL_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList(valueList.size()); for (EventValuesWithLog eventValues : valueList) { - ApprovalEventResponse typedResponse = new ApprovalEventResponse(); + ERC20.ApprovalEventResponse typedResponse = new ERC20.ApprovalEventResponse(); typedResponse.log = eventValues.getLog(); typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue(); typedResponse.spender = (String) eventValues.getIndexedValues().get(1).getValue(); @@ -99,32 +96,31 @@ public static List getApprovalEvents(TransactionReceipt t return responses; } - public Flowable approvalEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public ApprovalEventResponse apply(Log log) { - EventValuesWithLog eventValues = extractEventParametersWithLog(APPROVAL_EVENT, log); - ApprovalEventResponse typedResponse = new ApprovalEventResponse(); - typedResponse.log = log; - typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.spender = (String) eventValues.getIndexedValues().get(1).getValue(); - typedResponse.value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); - return typedResponse; - } - }); + public static ERC20.ApprovalEventResponse getApprovalEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(APPROVAL_EVENT, log); + ERC20.ApprovalEventResponse typedResponse = new ERC20.ApprovalEventResponse(); + typedResponse.log = log; + typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.spender = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + + public Flowable approvalEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getApprovalEventFromLog(log)); } - public Flowable approvalEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable approvalEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(APPROVAL_EVENT)); return approvalEventFlowable(filter); } - public static List getTransferEvents(TransactionReceipt transactionReceipt) { + public static List getTransferEvents(TransactionReceipt transactionReceipt) { List valueList = staticExtractEventParametersWithLog(TRANSFER_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList(valueList.size()); for (EventValuesWithLog eventValues : valueList) { - TransferEventResponse typedResponse = new TransferEventResponse(); + ERC20.TransferEventResponse typedResponse = new ERC20.TransferEventResponse(); typedResponse.log = eventValues.getLog(); typedResponse.from = (String) eventValues.getIndexedValues().get(0).getValue(); typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue(); @@ -134,75 +130,74 @@ public static List getTransferEvents(TransactionReceipt t return responses; } - public Flowable transferEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public TransferEventResponse apply(Log log) { - EventValuesWithLog eventValues = extractEventParametersWithLog(TRANSFER_EVENT, log); - TransferEventResponse typedResponse = new TransferEventResponse(); - typedResponse.log = log; - typedResponse.from = (String) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue(); - typedResponse.value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); - return typedResponse; - } - }); + public static ERC20.TransferEventResponse getTransferEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(TRANSFER_EVENT, log); + ERC20.TransferEventResponse typedResponse = new ERC20.TransferEventResponse(); + typedResponse.log = log; + typedResponse.from = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + + public Flowable transferEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getTransferEventFromLog(log)); } - public Flowable transferEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable transferEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(TRANSFER_EVENT)); return transferEventFlowable(filter); } public RemoteFunctionCall allowance(String owner, String spender) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_ALLOWANCE, + final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_ALLOWANCE, Arrays.asList(new Address(160, owner), - new Address(160, spender)), + new Address(160, spender)), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, BigInteger.class); } public RemoteFunctionCall approve(String spender, BigInteger amount) { final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( - FUNC_APPROVE, + FUNC_APPROVE, Arrays.asList(new Address(160, spender), - new Uint256(amount)), + new Uint256(amount)), Collections.>emptyList()); return executeRemoteCallTransaction(function); } public RemoteFunctionCall balanceOf(String account) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_BALANCEOF, + final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_BALANCEOF, Arrays.asList(new Address(160, account)), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, BigInteger.class); } public RemoteFunctionCall decimals() { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_DECIMALS, - Arrays.asList(), + final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_DECIMALS, + Arrays.asList(), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, BigInteger.class); } public RemoteFunctionCall name() { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_NAME, - Arrays.asList(), + final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_NAME, + Arrays.asList(), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, String.class); } public RemoteFunctionCall symbol() { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_SYMBOL, - Arrays.asList(), + final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_SYMBOL, + Arrays.asList(), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, String.class); } public RemoteFunctionCall totalSupply() { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_TOTALSUPPLY, - Arrays.asList(), + final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_TOTALSUPPLY, + Arrays.asList(), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, BigInteger.class); } @@ -218,19 +213,19 @@ public static String encodeTransfer(String to, BigInteger amount) { public RemoteFunctionCall transfer(String to, BigInteger amount) { final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( - FUNC_TRANSFER, + FUNC_TRANSFER, Arrays.asList(new Address(160, to), - new Uint256(amount)), + new Uint256(amount)), Collections.>emptyList()); return executeRemoteCallTransaction(function); } public RemoteFunctionCall transferFrom(String from, String to, BigInteger amount) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( - FUNC_TRANSFERFROM, + final org.web3j.abi.datatypes.Function function = new Function( + FUNC_TRANSFERFROM, Arrays.asList(new Address(160, from), - new Address(160, to), - new Uint256(amount)), + new Address(160, to), + new Uint256(amount)), Collections.>emptyList()); return executeRemoteCallTransaction(function); } diff --git a/src/main/java/io/zksync/wrappers/IBridgehub.java b/src/main/java/io/zksync/wrappers/IBridgehub.java new file mode 100644 index 0000000..a9ed70e --- /dev/null +++ b/src/main/java/io/zksync/wrappers/IBridgehub.java @@ -0,0 +1,605 @@ +package io.zksync.wrappers; + +import io.reactivex.Flowable; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import org.web3j.abi.EventEncoder; +import org.web3j.abi.FunctionEncoder; +import org.web3j.abi.TypeReference; +import org.web3j.abi.datatypes.Address; +import org.web3j.abi.datatypes.Bool; +import org.web3j.abi.datatypes.DynamicArray; +import org.web3j.abi.datatypes.DynamicBytes; +import org.web3j.abi.datatypes.DynamicStruct; +import org.web3j.abi.datatypes.Event; +import org.web3j.abi.datatypes.Function; +import org.web3j.abi.datatypes.StaticStruct; +import org.web3j.abi.datatypes.Type; +import org.web3j.abi.datatypes.generated.Bytes32; +import org.web3j.abi.datatypes.generated.Uint16; +import org.web3j.abi.datatypes.generated.Uint256; +import org.web3j.abi.datatypes.generated.Uint8; +import org.web3j.crypto.Credentials; +import org.web3j.protocol.Web3j; +import org.web3j.protocol.core.DefaultBlockParameter; +import org.web3j.protocol.core.RemoteFunctionCall; +import org.web3j.protocol.core.methods.request.EthFilter; +import org.web3j.protocol.core.methods.response.BaseEventResponse; +import org.web3j.protocol.core.methods.response.Log; +import org.web3j.protocol.core.methods.response.TransactionReceipt; +import org.web3j.tx.Contract; +import org.web3j.tx.TransactionManager; +import org.web3j.tx.gas.ContractGasProvider; + +/** + *

Auto generated code. + *

Do not modify! + *

Please use the web3j command line tools, + * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the + * codegen module to update. + * + *

Generated with web3j version 1.5.0. + */ +@SuppressWarnings("rawtypes") +public class IBridgehub extends Contract { + public static final String BINARY = "Bin file was not provided"; + + public static final String FUNC_ACCEPTADMIN = "acceptAdmin"; + + public static final String FUNC_ADDSTATETRANSITIONMANAGER = "addStateTransitionManager"; + + public static final String FUNC_ADDTOKEN = "addToken"; + + public static final String FUNC_BASETOKEN = "baseToken"; + + public static final String FUNC_CREATENEWCHAIN = "createNewChain"; + + public static final String FUNC_GETSTATETRANSITION = "getStateTransition"; + + public static final String FUNC_L2TRANSACTIONBASECOST = "l2TransactionBaseCost"; + + public static final String FUNC_PROVEL1TOL2TRANSACTIONSTATUS = "proveL1ToL2TransactionStatus"; + + public static final String FUNC_PROVEL2LOGINCLUSION = "proveL2LogInclusion"; + + public static final String FUNC_PROVEL2MESSAGEINCLUSION = "proveL2MessageInclusion"; + + public static final String FUNC_REMOVESTATETRANSITIONMANAGER = "removeStateTransitionManager"; + + public static final String FUNC_REQUESTL2TRANSACTIONDIRECT = "requestL2TransactionDirect"; + + public static final String FUNC_REQUESTL2TRANSACTIONTWOBRIDGES = "requestL2TransactionTwoBridges"; + + public static final String FUNC_SETPENDINGADMIN = "setPendingAdmin"; + + public static final String FUNC_SETSHAREDBRIDGE = "setSharedBridge"; + + public static final String FUNC_SHAREDBRIDGE = "sharedBridge"; + + public static final String FUNC_STATETRANSITIONMANAGER = "stateTransitionManager"; + + public static final String FUNC_STATETRANSITIONMANAGERISREGISTERED = "stateTransitionManagerIsRegistered"; + + public static final String FUNC_TOKENISREGISTERED = "tokenIsRegistered"; + + public static final Event NEWADMIN_EVENT = new Event("NewAdmin", + Arrays.>asList(new TypeReference

(true) {}, new TypeReference
(true) {})); + ; + + public static final Event NEWCHAIN_EVENT = new Event("NewChain", + Arrays.>asList(new TypeReference(true) {}, new TypeReference
() {}, new TypeReference
(true) {})); + ; + + public static final Event NEWPENDINGADMIN_EVENT = new Event("NewPendingAdmin", + Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {})); + ; + + @Deprecated + protected IBridgehub(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + protected IBridgehub(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, credentials, contractGasProvider); + } + + @Deprecated + protected IBridgehub(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + protected IBridgehub(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); + } + + public static List getNewAdminEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(NEWADMIN_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + NewAdminEventResponse typedResponse = new NewAdminEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.oldAdmin = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.newAdmin = (String) eventValues.getIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static NewAdminEventResponse getNewAdminEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWADMIN_EVENT, log); + NewAdminEventResponse typedResponse = new NewAdminEventResponse(); + typedResponse.log = log; + typedResponse.oldAdmin = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.newAdmin = (String) eventValues.getIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable newAdminEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getNewAdminEventFromLog(log)); + } + + public Flowable newAdminEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(NEWADMIN_EVENT)); + return newAdminEventFlowable(filter); + } + + public static List getNewChainEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(NEWCHAIN_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + NewChainEventResponse typedResponse = new NewChainEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.chainGovernance = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.stateTransitionManager = (String) eventValues.getNonIndexedValues().get(0).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static NewChainEventResponse getNewChainEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWCHAIN_EVENT, log); + NewChainEventResponse typedResponse = new NewChainEventResponse(); + typedResponse.log = log; + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.chainGovernance = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.stateTransitionManager = (String) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + + public Flowable newChainEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getNewChainEventFromLog(log)); + } + + public Flowable newChainEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(NEWCHAIN_EVENT)); + return newChainEventFlowable(filter); + } + + public static List getNewPendingAdminEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(NEWPENDINGADMIN_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + NewPendingAdminEventResponse typedResponse = new NewPendingAdminEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.oldPendingAdmin = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.newPendingAdmin = (String) eventValues.getIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static NewPendingAdminEventResponse getNewPendingAdminEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWPENDINGADMIN_EVENT, log); + NewPendingAdminEventResponse typedResponse = new NewPendingAdminEventResponse(); + typedResponse.log = log; + typedResponse.oldPendingAdmin = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.newPendingAdmin = (String) eventValues.getIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable newPendingAdminEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getNewPendingAdminEventFromLog(log)); + } + + public Flowable newPendingAdminEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(NEWPENDINGADMIN_EVENT)); + return newPendingAdminEventFlowable(filter); + } + + public RemoteFunctionCall acceptAdmin() { + final Function function = new Function( + FUNC_ACCEPTADMIN, + Arrays.asList(), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall addStateTransitionManager(String _stateTransitionManager) { + final Function function = new Function( + FUNC_ADDSTATETRANSITIONMANAGER, + Arrays.asList(new Address(160, _stateTransitionManager)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall addToken(String _token) { + final Function function = new Function( + FUNC_ADDTOKEN, + Arrays.asList(new Address(160, _token)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall baseToken(BigInteger _chainId) { + final Function function = new Function(FUNC_BASETOKEN, + Arrays.asList(new Uint256(_chainId)), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall createNewChain(BigInteger _chainId, String _stateTransitionManager, String _baseToken, BigInteger _salt, String _admin, byte[] _initData) { + final Function function = new Function( + FUNC_CREATENEWCHAIN, + Arrays.asList(new Uint256(_chainId), + new Address(160, _stateTransitionManager), + new Address(160, _baseToken), + new Uint256(_salt), + new Address(160, _admin), + new DynamicBytes(_initData)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall getStateTransition(BigInteger _chainId) { + final Function function = new Function(FUNC_GETSTATETRANSITION, + Arrays.asList(new Uint256(_chainId)), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall l2TransactionBaseCost(BigInteger _chainId, BigInteger _gasPrice, BigInteger _l2GasLimit, BigInteger _l2GasPerPubdataByteLimit) { + final Function function = new Function(FUNC_L2TRANSACTIONBASECOST, + Arrays.asList(new Uint256(_chainId), + new Uint256(_gasPrice), + new Uint256(_l2GasLimit), + new Uint256(_l2GasPerPubdataByteLimit)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall proveL1ToL2TransactionStatus(BigInteger _chainId, byte[] _l2TxHash, BigInteger _l2BatchNumber, BigInteger _l2MessageIndex, BigInteger _l2TxNumberInBatch, List _merkleProof, BigInteger _status) { + final Function function = new Function(FUNC_PROVEL1TOL2TRANSACTIONSTATUS, + Arrays.asList(new Uint256(_chainId), + new Bytes32(_l2TxHash), + new Uint256(_l2BatchNumber), + new Uint256(_l2MessageIndex), + new Uint16(_l2TxNumberInBatch), + new DynamicArray( + Bytes32.class, + org.web3j.abi.Utils.typeMap(_merkleProof, Bytes32.class)), + new Uint8(_status)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall proveL2LogInclusion(BigInteger _chainId, BigInteger _batchNumber, BigInteger _index, L2Log _log, List _proof) { + final Function function = new Function(FUNC_PROVEL2LOGINCLUSION, + Arrays.asList(new Uint256(_chainId), + new Uint256(_batchNumber), + new Uint256(_index), + _log, + new DynamicArray( + Bytes32.class, + org.web3j.abi.Utils.typeMap(_proof, Bytes32.class))), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall proveL2MessageInclusion(BigInteger _chainId, BigInteger _batchNumber, BigInteger _index, L2Message _message, List _proof) { + final Function function = new Function(FUNC_PROVEL2MESSAGEINCLUSION, + Arrays.asList(new Uint256(_chainId), + new Uint256(_batchNumber), + new Uint256(_index), + _message, + new DynamicArray( + Bytes32.class, + org.web3j.abi.Utils.typeMap(_proof, Bytes32.class))), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall removeStateTransitionManager(String _stateTransitionManager) { + final Function function = new Function( + FUNC_REMOVESTATETRANSITIONMANAGER, + Arrays.asList(new Address(160, _stateTransitionManager)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall requestL2TransactionDirect(L2TransactionRequestDirect _request, BigInteger weiValue) { + final Function function = new Function( + FUNC_REQUESTL2TRANSACTIONDIRECT, + Arrays.asList(_request), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public String encodeRequestL2TransactionTwoBridges(L2TransactionRequestTwoBridgesOuter _request) { + final Function function = new Function( + FUNC_REQUESTL2TRANSACTIONTWOBRIDGES, + Arrays.asList(_request), + Collections.>emptyList()); + return FunctionEncoder.encode(function); + } + + public RemoteFunctionCall requestL2TransactionTwoBridges(L2TransactionRequestTwoBridgesOuter _request, BigInteger weiValue) { + final Function function = new Function( + FUNC_REQUESTL2TRANSACTIONTWOBRIDGES, + Arrays.asList(_request), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public RemoteFunctionCall setPendingAdmin(String _newPendingAdmin) { + final Function function = new Function( + FUNC_SETPENDINGADMIN, + Arrays.asList(new Address(160, _newPendingAdmin)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall setSharedBridge(String _sharedBridge) { + final Function function = new Function( + FUNC_SETSHAREDBRIDGE, + Arrays.asList(new Address(160, _sharedBridge)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall sharedBridge() { + final Function function = new Function(FUNC_SHAREDBRIDGE, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall stateTransitionManager(BigInteger _chainId) { + final Function function = new Function(FUNC_STATETRANSITIONMANAGER, + Arrays.asList(new Uint256(_chainId)), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall stateTransitionManagerIsRegistered(String _stateTransitionManager) { + final Function function = new Function(FUNC_STATETRANSITIONMANAGERISREGISTERED, + Arrays.asList(new Address(160, _stateTransitionManager)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall tokenIsRegistered(String _baseToken) { + final Function function = new Function(FUNC_TOKENISREGISTERED, + Arrays.asList(new Address(160, _baseToken)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + @Deprecated + public static IBridgehub load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + return new IBridgehub(contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + @Deprecated + public static IBridgehub load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + return new IBridgehub(contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + public static IBridgehub load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + return new IBridgehub(contractAddress, web3j, credentials, contractGasProvider); + } + + public static IBridgehub load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + return new IBridgehub(contractAddress, web3j, transactionManager, contractGasProvider); + } + + public static class L2Log extends StaticStruct { + public BigInteger l2ShardId; + + public Boolean isService; + + public BigInteger txNumberInBatch; + + public String sender; + + public byte[] key; + + public byte[] value; + + public L2Log(BigInteger l2ShardId, Boolean isService, BigInteger txNumberInBatch, String sender, byte[] key, byte[] value) { + super(new Uint8(l2ShardId), + new Bool(isService), + new Uint16(txNumberInBatch), + new Address(160, sender), + new Bytes32(key), + new Bytes32(value)); + this.l2ShardId = l2ShardId; + this.isService = isService; + this.txNumberInBatch = txNumberInBatch; + this.sender = sender; + this.key = key; + this.value = value; + } + + public L2Log(Uint8 l2ShardId, Bool isService, Uint16 txNumberInBatch, Address sender, Bytes32 key, Bytes32 value) { + super(l2ShardId, isService, txNumberInBatch, sender, key, value); + this.l2ShardId = l2ShardId.getValue(); + this.isService = isService.getValue(); + this.txNumberInBatch = txNumberInBatch.getValue(); + this.sender = sender.getValue(); + this.key = key.getValue(); + this.value = value.getValue(); + } + } + + public static class L2Message extends DynamicStruct { + public BigInteger txNumberInBatch; + + public String sender; + + public byte[] data; + + public L2Message(BigInteger txNumberInBatch, String sender, byte[] data) { + super(new Uint16(txNumberInBatch), + new Address(160, sender), + new DynamicBytes(data)); + this.txNumberInBatch = txNumberInBatch; + this.sender = sender; + this.data = data; + } + + public L2Message(Uint16 txNumberInBatch, Address sender, DynamicBytes data) { + super(txNumberInBatch, sender, data); + this.txNumberInBatch = txNumberInBatch.getValue(); + this.sender = sender.getValue(); + this.data = data.getValue(); + } + } + + public static class L2TransactionRequestDirect extends DynamicStruct { + public BigInteger chainId; + + public BigInteger mintValue; + + public String l2Contract; + + public BigInteger l2Value; + + public byte[] l2Calldata; + + public BigInteger l2GasLimit; + + public BigInteger l2GasPerPubdataByteLimit; + + public List factoryDeps; + + public String refundRecipient; + + public L2TransactionRequestDirect(BigInteger chainId, BigInteger mintValue, String l2Contract, BigInteger l2Value, byte[] l2Calldata, BigInteger l2GasLimit, BigInteger l2GasPerPubdataByteLimit, List factoryDeps, String refundRecipient) { + super(new Uint256(chainId), + new Uint256(mintValue), + new Address(160, l2Contract), + new Uint256(l2Value), + new DynamicBytes(l2Calldata), + new Uint256(l2GasLimit), + new Uint256(l2GasPerPubdataByteLimit), + new DynamicArray( + DynamicBytes.class, + org.web3j.abi.Utils.typeMap(factoryDeps, DynamicBytes.class)), + new Address(160, refundRecipient)); + this.chainId = chainId; + this.mintValue = mintValue; + this.l2Contract = l2Contract; + this.l2Value = l2Value; + this.l2Calldata = l2Calldata; + this.l2GasLimit = l2GasLimit; + this.l2GasPerPubdataByteLimit = l2GasPerPubdataByteLimit; + this.factoryDeps = factoryDeps; + this.refundRecipient = refundRecipient; + } + + public L2TransactionRequestDirect(Uint256 chainId, Uint256 mintValue, Address l2Contract, Uint256 l2Value, DynamicBytes l2Calldata, Uint256 l2GasLimit, Uint256 l2GasPerPubdataByteLimit, DynamicArray factoryDeps, Address refundRecipient) { + super(chainId, mintValue, l2Contract, l2Value, l2Calldata, l2GasLimit, l2GasPerPubdataByteLimit, factoryDeps, refundRecipient); + this.chainId = chainId.getValue(); + this.mintValue = mintValue.getValue(); + this.l2Contract = l2Contract.getValue(); + this.l2Value = l2Value.getValue(); + this.l2Calldata = l2Calldata.getValue(); + this.l2GasLimit = l2GasLimit.getValue(); + this.l2GasPerPubdataByteLimit = l2GasPerPubdataByteLimit.getValue(); + this.factoryDeps = factoryDeps.getValue().stream().map(v -> v.getValue()).collect(Collectors.toList()); + this.refundRecipient = refundRecipient.getValue(); + } + } + + public static class L2TransactionRequestTwoBridgesOuter extends DynamicStruct { + public BigInteger chainId; + + public BigInteger mintValue; + + public BigInteger l2Value; + + public BigInteger l2GasLimit; + + public BigInteger l2GasPerPubdataByteLimit; + + public String refundRecipient; + + public String secondBridgeAddress; + + public BigInteger secondBridgeValue; + + public byte[] secondBridgeCalldata; + + public L2TransactionRequestTwoBridgesOuter(BigInteger chainId, BigInteger mintValue, BigInteger l2Value, BigInteger l2GasLimit, BigInteger l2GasPerPubdataByteLimit, String refundRecipient, String secondBridgeAddress, BigInteger secondBridgeValue, byte[] secondBridgeCalldata) { + super(new Uint256(chainId), + new Uint256(mintValue), + new Uint256(l2Value), + new Uint256(l2GasLimit), + new Uint256(l2GasPerPubdataByteLimit), + new Address(160, refundRecipient), + new Address(160, secondBridgeAddress), + new Uint256(secondBridgeValue), + new DynamicBytes(secondBridgeCalldata)); + this.chainId = chainId; + this.mintValue = mintValue; + this.l2Value = l2Value; + this.l2GasLimit = l2GasLimit; + this.l2GasPerPubdataByteLimit = l2GasPerPubdataByteLimit; + this.refundRecipient = refundRecipient; + this.secondBridgeAddress = secondBridgeAddress; + this.secondBridgeValue = secondBridgeValue; + this.secondBridgeCalldata = secondBridgeCalldata; + } + + public L2TransactionRequestTwoBridgesOuter(Uint256 chainId, Uint256 mintValue, Uint256 l2Value, Uint256 l2GasLimit, Uint256 l2GasPerPubdataByteLimit, Address refundRecipient, Address secondBridgeAddress, Uint256 secondBridgeValue, DynamicBytes secondBridgeCalldata) { + super(chainId, mintValue, l2Value, l2GasLimit, l2GasPerPubdataByteLimit, refundRecipient, secondBridgeAddress, secondBridgeValue, secondBridgeCalldata); + this.chainId = chainId.getValue(); + this.mintValue = mintValue.getValue(); + this.l2Value = l2Value.getValue(); + this.l2GasLimit = l2GasLimit.getValue(); + this.l2GasPerPubdataByteLimit = l2GasPerPubdataByteLimit.getValue(); + this.refundRecipient = refundRecipient.getValue(); + this.secondBridgeAddress = secondBridgeAddress.getValue(); + this.secondBridgeValue = secondBridgeValue.getValue(); + this.secondBridgeCalldata = secondBridgeCalldata.getValue(); + } + } + + public static class NewAdminEventResponse extends BaseEventResponse { + public String oldAdmin; + + public String newAdmin; + } + + public static class NewChainEventResponse extends BaseEventResponse { + public BigInteger chainId; + + public String chainGovernance; + + public String stateTransitionManager; + } + + public static class NewPendingAdminEventResponse extends BaseEventResponse { + public String oldPendingAdmin; + + public String newPendingAdmin; + } +} diff --git a/src/main/java/io/zksync/wrappers/IContractDeployer.java b/src/main/java/io/zksync/wrappers/IContractDeployer.java new file mode 100644 index 0000000..3c360b6 --- /dev/null +++ b/src/main/java/io/zksync/wrappers/IContractDeployer.java @@ -0,0 +1,396 @@ +package io.zksync.wrappers; + +import io.reactivex.Flowable; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import org.web3j.abi.EventEncoder; +import org.web3j.abi.TypeReference; +import org.web3j.abi.datatypes.Address; +import org.web3j.abi.datatypes.Bool; +import org.web3j.abi.datatypes.DynamicBytes; +import org.web3j.abi.datatypes.DynamicStruct; +import org.web3j.abi.datatypes.Event; +import org.web3j.abi.datatypes.Function; +import org.web3j.abi.datatypes.StaticStruct; +import org.web3j.abi.datatypes.Type; +import org.web3j.abi.datatypes.generated.Bytes32; +import org.web3j.abi.datatypes.generated.Uint256; +import org.web3j.abi.datatypes.generated.Uint8; +import org.web3j.crypto.Credentials; +import org.web3j.protocol.Web3j; +import org.web3j.protocol.core.DefaultBlockParameter; +import org.web3j.protocol.core.RemoteFunctionCall; +import org.web3j.protocol.core.methods.request.EthFilter; +import org.web3j.protocol.core.methods.response.BaseEventResponse; +import org.web3j.protocol.core.methods.response.Log; +import org.web3j.protocol.core.methods.response.TransactionReceipt; +import org.web3j.tx.Contract; +import org.web3j.tx.TransactionManager; +import org.web3j.tx.gas.ContractGasProvider; + +/** + *

Auto generated code. + *

Do not modify! + *

Please use the web3j command line tools, + * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the + * codegen module to update. + * + *

Generated with web3j version 1.5.0. + */ +@SuppressWarnings("rawtypes") +public class IContractDeployer extends Contract { + public static final String BINARY = "Bin file was not provided"; + + public static final String FUNC_CREATE = "create"; + + public static final String FUNC_CREATE2 = "create2"; + + public static final String FUNC_CREATE2ACCOUNT = "create2Account"; + + public static final String FUNC_CREATEACCOUNT = "createAccount"; + + public static final String FUNC_EXTENDEDACCOUNTVERSION = "extendedAccountVersion"; + + public static final String FUNC_FORCEDEPLOYONADDRESS = "forceDeployOnAddress"; + + public static final String FUNC_FORCEDEPLOYONADDRESSES = "forceDeployOnAddresses"; + + public static final String FUNC_GETACCOUNTINFO = "getAccountInfo"; + + public static final String FUNC_GETNEWADDRESSCREATE = "getNewAddressCreate"; + + public static final String FUNC_GETNEWADDRESSCREATE2 = "getNewAddressCreate2"; + + public static final String FUNC_UPDATEACCOUNTVERSION = "updateAccountVersion"; + + public static final String FUNC_UPDATENONCEORDERING = "updateNonceOrdering"; + + public static final Event ACCOUNTNONCEORDERINGUPDATED_EVENT = new Event("AccountNonceOrderingUpdated", + Arrays.>asList(new TypeReference

(true) {}, new TypeReference() {})); + ; + + public static final Event ACCOUNTVERSIONUPDATED_EVENT = new Event("AccountVersionUpdated", + Arrays.>asList(new TypeReference
(true) {}, new TypeReference() {})); + ; + + public static final Event CONTRACTDEPLOYED_EVENT = new Event("ContractDeployed", + Arrays.>asList(new TypeReference
(true) {}, new TypeReference(true) {}, new TypeReference
(true) {})); + ; + + @Deprecated + protected IContractDeployer(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + protected IContractDeployer(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, credentials, contractGasProvider); + } + + @Deprecated + protected IContractDeployer(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + protected IContractDeployer(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); + } + + public static List getAccountNonceOrderingUpdatedEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(ACCOUNTNONCEORDERINGUPDATED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + AccountNonceOrderingUpdatedEventResponse typedResponse = new AccountNonceOrderingUpdatedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.accountAddress = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.nonceOrdering = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static AccountNonceOrderingUpdatedEventResponse getAccountNonceOrderingUpdatedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(ACCOUNTNONCEORDERINGUPDATED_EVENT, log); + AccountNonceOrderingUpdatedEventResponse typedResponse = new AccountNonceOrderingUpdatedEventResponse(); + typedResponse.log = log; + typedResponse.accountAddress = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.nonceOrdering = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + + public Flowable accountNonceOrderingUpdatedEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getAccountNonceOrderingUpdatedEventFromLog(log)); + } + + public Flowable accountNonceOrderingUpdatedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(ACCOUNTNONCEORDERINGUPDATED_EVENT)); + return accountNonceOrderingUpdatedEventFlowable(filter); + } + + public static List getAccountVersionUpdatedEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(ACCOUNTVERSIONUPDATED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + AccountVersionUpdatedEventResponse typedResponse = new AccountVersionUpdatedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.accountAddress = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.aaVersion = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static AccountVersionUpdatedEventResponse getAccountVersionUpdatedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(ACCOUNTVERSIONUPDATED_EVENT, log); + AccountVersionUpdatedEventResponse typedResponse = new AccountVersionUpdatedEventResponse(); + typedResponse.log = log; + typedResponse.accountAddress = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.aaVersion = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + + public Flowable accountVersionUpdatedEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getAccountVersionUpdatedEventFromLog(log)); + } + + public Flowable accountVersionUpdatedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(ACCOUNTVERSIONUPDATED_EVENT)); + return accountVersionUpdatedEventFlowable(filter); + } + + public static List getContractDeployedEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(CONTRACTDEPLOYED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + ContractDeployedEventResponse typedResponse = new ContractDeployedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.deployerAddress = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.bytecodeHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.contractAddress = (String) eventValues.getIndexedValues().get(2).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static ContractDeployedEventResponse getContractDeployedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(CONTRACTDEPLOYED_EVENT, log); + ContractDeployedEventResponse typedResponse = new ContractDeployedEventResponse(); + typedResponse.log = log; + typedResponse.deployerAddress = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.bytecodeHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.contractAddress = (String) eventValues.getIndexedValues().get(2).getValue(); + return typedResponse; + } + + public Flowable contractDeployedEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getContractDeployedEventFromLog(log)); + } + + public Flowable contractDeployedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(CONTRACTDEPLOYED_EVENT)); + return contractDeployedEventFlowable(filter); + } + + public RemoteFunctionCall create(byte[] _salt, byte[] _bytecodeHash, byte[] _input, BigInteger weiValue) { + final Function function = new Function( + FUNC_CREATE, + Arrays.asList(new Bytes32(_salt), + new Bytes32(_bytecodeHash), + new DynamicBytes(_input)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public RemoteFunctionCall create2(byte[] _salt, byte[] _bytecodeHash, byte[] _input, BigInteger weiValue) { + final Function function = new Function( + FUNC_CREATE2, + Arrays.asList(new Bytes32(_salt), + new Bytes32(_bytecodeHash), + new DynamicBytes(_input)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public RemoteFunctionCall create2Account(byte[] _salt, byte[] _bytecodeHash, byte[] _input, BigInteger _aaVersion, BigInteger weiValue) { + final Function function = new Function( + FUNC_CREATE2ACCOUNT, + Arrays.asList(new Bytes32(_salt), + new Bytes32(_bytecodeHash), + new DynamicBytes(_input), + new Uint8(_aaVersion)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public RemoteFunctionCall createAccount(byte[] param0, byte[] _bytecodeHash, byte[] _input, BigInteger _aaVersion, BigInteger weiValue) { + final Function function = new Function( + FUNC_CREATEACCOUNT, + Arrays.asList(new Bytes32(param0), + new Bytes32(_bytecodeHash), + new DynamicBytes(_input), + new Uint8(_aaVersion)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public RemoteFunctionCall extendedAccountVersion(String _address) { + final Function function = new Function(FUNC_EXTENDEDACCOUNTVERSION, + Arrays.asList(new Address(160, _address)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall forceDeployOnAddress(ForceDeployment _deployment, String _sender, BigInteger weiValue) { + final Function function = new Function( + FUNC_FORCEDEPLOYONADDRESS, + Arrays.asList(_deployment, + new Address(160, _sender)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public RemoteFunctionCall forceDeployOnAddresses(List _deployments, BigInteger weiValue) { + final Function function = new Function( + FUNC_FORCEDEPLOYONADDRESSES, + Arrays.asList(new org.web3j.abi.datatypes.DynamicArray(ForceDeployment.class, _deployments)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public RemoteFunctionCall getAccountInfo(String _address) { + final Function function = new Function(FUNC_GETACCOUNTINFO, + Arrays.asList(new Address(160, _address)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, AccountInfo.class); + } + + public RemoteFunctionCall getNewAddressCreate(String _sender, BigInteger _senderNonce) { + final Function function = new Function(FUNC_GETNEWADDRESSCREATE, + Arrays.asList(new Address(160, _sender), + new Uint256(_senderNonce)), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall getNewAddressCreate2(String _sender, byte[] _bytecodeHash, byte[] _salt, byte[] _input) { + final Function function = new Function(FUNC_GETNEWADDRESSCREATE2, + Arrays.asList(new Address(160, _sender), + new Bytes32(_bytecodeHash), + new Bytes32(_salt), + new DynamicBytes(_input)), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall updateAccountVersion(BigInteger _version) { + final Function function = new Function( + FUNC_UPDATEACCOUNTVERSION, + Arrays.asList(new Uint8(_version)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall updateNonceOrdering(BigInteger _nonceOrdering) { + final Function function = new Function( + FUNC_UPDATENONCEORDERING, + Arrays.asList(new Uint8(_nonceOrdering)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + @Deprecated + public static IContractDeployer load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + return new IContractDeployer(contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + @Deprecated + public static IContractDeployer load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + return new IContractDeployer(contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + public static IContractDeployer load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + return new IContractDeployer(contractAddress, web3j, credentials, contractGasProvider); + } + + public static IContractDeployer load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + return new IContractDeployer(contractAddress, web3j, transactionManager, contractGasProvider); + } + + public static class ForceDeployment extends DynamicStruct { + public byte[] bytecodeHash; + + public String newAddress; + + public Boolean callConstructor; + + public BigInteger value; + + public byte[] input; + + public ForceDeployment(byte[] bytecodeHash, String newAddress, Boolean callConstructor, BigInteger value, byte[] input) { + super(new Bytes32(bytecodeHash), + new Address(160, newAddress), + new Bool(callConstructor), + new Uint256(value), + new DynamicBytes(input)); + this.bytecodeHash = bytecodeHash; + this.newAddress = newAddress; + this.callConstructor = callConstructor; + this.value = value; + this.input = input; + } + + public ForceDeployment(Bytes32 bytecodeHash, Address newAddress, Bool callConstructor, Uint256 value, DynamicBytes input) { + super(bytecodeHash, newAddress, callConstructor, value, input); + this.bytecodeHash = bytecodeHash.getValue(); + this.newAddress = newAddress.getValue(); + this.callConstructor = callConstructor.getValue(); + this.value = value.getValue(); + this.input = input.getValue(); + } + } + + public static class AccountInfo extends StaticStruct { + public BigInteger supportedAAVersion; + + public BigInteger nonceOrdering; + + public AccountInfo(BigInteger supportedAAVersion, BigInteger nonceOrdering) { + super(new Uint8(supportedAAVersion), + new Uint8(nonceOrdering)); + this.supportedAAVersion = supportedAAVersion; + this.nonceOrdering = nonceOrdering; + } + + public AccountInfo(Uint8 supportedAAVersion, Uint8 nonceOrdering) { + super(supportedAAVersion, nonceOrdering); + this.supportedAAVersion = supportedAAVersion.getValue(); + this.nonceOrdering = nonceOrdering.getValue(); + } + } + + public static class AccountNonceOrderingUpdatedEventResponse extends BaseEventResponse { + public String accountAddress; + + public BigInteger nonceOrdering; + } + + public static class AccountVersionUpdatedEventResponse extends BaseEventResponse { + public String accountAddress; + + public BigInteger aaVersion; + } + + public static class ContractDeployedEventResponse extends BaseEventResponse { + public String deployerAddress; + + public byte[] bytecodeHash; + + public String contractAddress; + } +} diff --git a/src/main/java/io/zksync/wrappers/IERC1271.java b/src/main/java/io/zksync/wrappers/IERC1271.java new file mode 100644 index 0000000..35ac634 --- /dev/null +++ b/src/main/java/io/zksync/wrappers/IERC1271.java @@ -0,0 +1,74 @@ +package io.zksync.wrappers; + +import java.math.BigInteger; +import java.util.Arrays; +import org.web3j.abi.TypeReference; +import org.web3j.abi.datatypes.Function; +import org.web3j.abi.datatypes.Type; +import org.web3j.abi.datatypes.generated.Bytes4; +import org.web3j.crypto.Credentials; +import org.web3j.protocol.Web3j; +import org.web3j.protocol.core.RemoteFunctionCall; +import org.web3j.tx.Contract; +import org.web3j.tx.TransactionManager; +import org.web3j.tx.gas.ContractGasProvider; + +/** + *

Auto generated code. + *

Do not modify! + *

Please use the web3j command line tools, + * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the + * codegen module to update. + * + *

Generated with web3j version 1.5.0. + */ +@SuppressWarnings("rawtypes") +public class IERC1271 extends Contract { + public static final String BINARY = "Bin file was not provided"; + + public static final String FUNC_ISVALIDSIGNATURE = "isValidSignature"; + + @Deprecated + protected IERC1271(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + protected IERC1271(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, credentials, contractGasProvider); + } + + @Deprecated + protected IERC1271(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + protected IERC1271(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); + } + + public RemoteFunctionCall isValidSignature(byte[] hash, byte[] signature) { + final Function function = new Function(FUNC_ISVALIDSIGNATURE, + Arrays.asList(new org.web3j.abi.datatypes.generated.Bytes32(hash), + new org.web3j.abi.datatypes.DynamicBytes(signature)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, byte[].class); + } + + @Deprecated + public static IERC1271 load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + return new IERC1271(contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + @Deprecated + public static IERC1271 load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + return new IERC1271(contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + public static IERC1271 load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + return new IERC1271(contractAddress, web3j, credentials, contractGasProvider); + } + + public static IERC1271 load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + return new IERC1271(contractAddress, web3j, transactionManager, contractGasProvider); + } +} diff --git a/src/main/java/io/zksync/wrappers/IEthToken.java b/src/main/java/io/zksync/wrappers/IEthToken.java index fe77a56..f09f23a 100644 --- a/src/main/java/io/zksync/wrappers/IEthToken.java +++ b/src/main/java/io/zksync/wrappers/IEthToken.java @@ -1,7 +1,6 @@ package io.zksync.wrappers; import io.reactivex.Flowable; -import io.reactivex.functions.Function; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; @@ -13,6 +12,7 @@ import org.web3j.abi.datatypes.Address; import org.web3j.abi.datatypes.DynamicBytes; import org.web3j.abi.datatypes.Event; +import org.web3j.abi.datatypes.Function; import org.web3j.abi.datatypes.Type; import org.web3j.abi.datatypes.Utf8String; import org.web3j.abi.datatypes.generated.Uint256; @@ -36,7 +36,7 @@ * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the * codegen module to update. * - *

Generated with web3j version 1.4.2. + *

Generated with web3j version 1.5.0. */ @SuppressWarnings("rawtypes") public class IEthToken extends Contract { @@ -95,9 +95,9 @@ protected IEthToken(String contractAddress, Web3j web3j, TransactionManager tran } public static List getMintEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(MINT_EVENT, transactionReceipt); + List valueList = staticExtractEventParametersWithLog(MINT_EVENT, transactionReceipt); ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { + for (EventValuesWithLog eventValues : valueList) { MintEventResponse typedResponse = new MintEventResponse(); typedResponse.log = eventValues.getLog(); typedResponse.account = (String) eventValues.getIndexedValues().get(0).getValue(); @@ -107,18 +107,17 @@ public static List getMintEvents(TransactionReceipt transacti return responses; } + public static MintEventResponse getMintEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(MINT_EVENT, log); + MintEventResponse typedResponse = new MintEventResponse(); + typedResponse.log = log; + typedResponse.account = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + public Flowable mintEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public MintEventResponse apply(Log log) { - Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(MINT_EVENT, log); - MintEventResponse typedResponse = new MintEventResponse(); - typedResponse.log = log; - typedResponse.account = (String) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> getMintEventFromLog(log)); } public Flowable mintEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -128,9 +127,9 @@ public Flowable mintEventFlowable(DefaultBlockParameter start } public static List getTransferEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(TRANSFER_EVENT, transactionReceipt); + List valueList = staticExtractEventParametersWithLog(TRANSFER_EVENT, transactionReceipt); ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { + for (EventValuesWithLog eventValues : valueList) { TransferEventResponse typedResponse = new TransferEventResponse(); typedResponse.log = eventValues.getLog(); typedResponse.from = (String) eventValues.getIndexedValues().get(0).getValue(); @@ -141,19 +140,18 @@ public static List getTransferEvents(TransactionReceipt t return responses; } + public static TransferEventResponse getTransferEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(TRANSFER_EVENT, log); + TransferEventResponse typedResponse = new TransferEventResponse(); + typedResponse.log = log; + typedResponse.from = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + public Flowable transferEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public TransferEventResponse apply(Log log) { - Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(TRANSFER_EVENT, log); - TransferEventResponse typedResponse = new TransferEventResponse(); - typedResponse.log = log; - typedResponse.from = (String) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue(); - typedResponse.value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> getTransferEventFromLog(log)); } public Flowable transferEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -163,9 +161,9 @@ public Flowable transferEventFlowable(DefaultBlockParamet } public static List getWithdrawalEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(WITHDRAWAL_EVENT, transactionReceipt); + List valueList = staticExtractEventParametersWithLog(WITHDRAWAL_EVENT, transactionReceipt); ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { + for (EventValuesWithLog eventValues : valueList) { WithdrawalEventResponse typedResponse = new WithdrawalEventResponse(); typedResponse.log = eventValues.getLog(); typedResponse._l2Sender = (String) eventValues.getIndexedValues().get(0).getValue(); @@ -176,19 +174,18 @@ public static List getWithdrawalEvents(TransactionRecei return responses; } + public static WithdrawalEventResponse getWithdrawalEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(WITHDRAWAL_EVENT, log); + WithdrawalEventResponse typedResponse = new WithdrawalEventResponse(); + typedResponse.log = log; + typedResponse._l2Sender = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse._l1Receiver = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse._amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + public Flowable withdrawalEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public WithdrawalEventResponse apply(Log log) { - Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(WITHDRAWAL_EVENT, log); - WithdrawalEventResponse typedResponse = new WithdrawalEventResponse(); - typedResponse.log = log; - typedResponse._l2Sender = (String) eventValues.getIndexedValues().get(0).getValue(); - typedResponse._l1Receiver = (String) eventValues.getIndexedValues().get(1).getValue(); - typedResponse._amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> getWithdrawalEventFromLog(log)); } public Flowable withdrawalEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -198,9 +195,9 @@ public Flowable withdrawalEventFlowable(DefaultBlockPar } public static List getWithdrawalWithMessageEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(WITHDRAWALWITHMESSAGE_EVENT, transactionReceipt); + List valueList = staticExtractEventParametersWithLog(WITHDRAWALWITHMESSAGE_EVENT, transactionReceipt); ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { + for (EventValuesWithLog eventValues : valueList) { WithdrawalWithMessageEventResponse typedResponse = new WithdrawalWithMessageEventResponse(); typedResponse.log = eventValues.getLog(); typedResponse._l2Sender = (String) eventValues.getIndexedValues().get(0).getValue(); @@ -212,20 +209,19 @@ public static List getWithdrawalWithMessageE return responses; } + public static WithdrawalWithMessageEventResponse getWithdrawalWithMessageEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(WITHDRAWALWITHMESSAGE_EVENT, log); + WithdrawalWithMessageEventResponse typedResponse = new WithdrawalWithMessageEventResponse(); + typedResponse.log = log; + typedResponse._l2Sender = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse._l1Receiver = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse._amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse._additionalData = (byte[]) eventValues.getNonIndexedValues().get(1).getValue(); + return typedResponse; + } + public Flowable withdrawalWithMessageEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public WithdrawalWithMessageEventResponse apply(Log log) { - Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(WITHDRAWALWITHMESSAGE_EVENT, log); - WithdrawalWithMessageEventResponse typedResponse = new WithdrawalWithMessageEventResponse(); - typedResponse.log = log; - typedResponse._l2Sender = (String) eventValues.getIndexedValues().get(0).getValue(); - typedResponse._l1Receiver = (String) eventValues.getIndexedValues().get(1).getValue(); - typedResponse._amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); - typedResponse._additionalData = (byte[]) eventValues.getNonIndexedValues().get(1).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> getWithdrawalWithMessageEventFromLog(log)); } public Flowable withdrawalWithMessageEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -235,80 +231,80 @@ public Flowable withdrawalWithMessageEventFl } public RemoteFunctionCall balanceOf(BigInteger param0) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_BALANCEOF, - Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(param0)), + final Function function = new Function(FUNC_BALANCEOF, + Arrays.asList(new Uint256(param0)), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, BigInteger.class); } public RemoteFunctionCall decimals() { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_DECIMALS, + final Function function = new Function(FUNC_DECIMALS, Arrays.asList(), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, BigInteger.class); } public RemoteFunctionCall mint(String _account, BigInteger _amount) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( + final Function function = new Function( FUNC_MINT, - Arrays.asList(new org.web3j.abi.datatypes.Address(160, _account), - new org.web3j.abi.datatypes.generated.Uint256(_amount)), + Arrays.asList(new Address(160, _account), + new Uint256(_amount)), Collections.>emptyList()); return executeRemoteCallTransaction(function); } public RemoteFunctionCall name() { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_NAME, + final Function function = new Function(FUNC_NAME, Arrays.asList(), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, String.class); } public RemoteFunctionCall symbol() { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_SYMBOL, + final Function function = new Function(FUNC_SYMBOL, Arrays.asList(), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, String.class); } public RemoteFunctionCall totalSupply() { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_TOTALSUPPLY, + final Function function = new Function(FUNC_TOTALSUPPLY, Arrays.asList(), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, BigInteger.class); } public RemoteFunctionCall transferFromTo(String _from, String _to, BigInteger _amount) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( + final Function function = new Function( FUNC_TRANSFERFROMTO, - Arrays.asList(new org.web3j.abi.datatypes.Address(160, _from), - new org.web3j.abi.datatypes.Address(160, _to), - new org.web3j.abi.datatypes.generated.Uint256(_amount)), + Arrays.asList(new Address(160, _from), + new Address(160, _to), + new Uint256(_amount)), Collections.>emptyList()); return executeRemoteCallTransaction(function); } public String encodeWithdraw(String _l1Receiver, BigInteger weiValue) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( + final Function function = new Function( FUNC_WITHDRAW, - Arrays.asList(new org.web3j.abi.datatypes.Address(160, _l1Receiver)), + Arrays.asList(new Address(160, _l1Receiver)), Collections.>emptyList()); return FunctionEncoder.encode(function); } public RemoteFunctionCall withdraw(String _l1Receiver, BigInteger weiValue) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( + final Function function = new Function( FUNC_WITHDRAW, - Arrays.asList(new org.web3j.abi.datatypes.Address(160, _l1Receiver)), + Arrays.asList(new Address(160, _l1Receiver)), Collections.>emptyList()); return executeRemoteCallTransaction(function, weiValue); } public RemoteFunctionCall withdrawWithMessage(String _l1Receiver, byte[] _additionalData, BigInteger weiValue) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( + final Function function = new Function( FUNC_WITHDRAWWITHMESSAGE, - Arrays.asList(new org.web3j.abi.datatypes.Address(160, _l1Receiver), - new org.web3j.abi.datatypes.DynamicBytes(_additionalData)), + Arrays.asList(new Address(160, _l1Receiver), + new DynamicBytes(_additionalData)), Collections.>emptyList()); return executeRemoteCallTransaction(function, weiValue); } diff --git a/src/main/java/io/zksync/wrappers/IL1Bridge.java b/src/main/java/io/zksync/wrappers/IL1Bridge.java index 6d5bcd1..141eeb6 100644 --- a/src/main/java/io/zksync/wrappers/IL1Bridge.java +++ b/src/main/java/io/zksync/wrappers/IL1Bridge.java @@ -1,18 +1,26 @@ package io.zksync.wrappers; import io.reactivex.Flowable; -import io.reactivex.functions.Function; + +import java.io.IOException; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; + +import io.zksync.abi.ZkFunctionEncoder; import org.web3j.abi.EventEncoder; import org.web3j.abi.FunctionEncoder; import org.web3j.abi.TypeReference; import org.web3j.abi.datatypes.Address; import org.web3j.abi.datatypes.Bool; +import org.web3j.abi.datatypes.DynamicArray; +import org.web3j.abi.datatypes.DynamicBytes; +import org.web3j.abi.datatypes.DynamicStruct; import org.web3j.abi.datatypes.Event; +import org.web3j.abi.datatypes.Function; import org.web3j.abi.datatypes.Type; import org.web3j.abi.datatypes.generated.Bytes32; import org.web3j.abi.datatypes.generated.Uint256; @@ -24,8 +32,10 @@ import org.web3j.protocol.core.methods.response.BaseEventResponse; import org.web3j.protocol.core.methods.response.Log; import org.web3j.protocol.core.methods.response.TransactionReceipt; +import org.web3j.protocol.exceptions.TransactionException; import org.web3j.tx.Contract; import org.web3j.tx.TransactionManager; +import org.web3j.tx.gas.ContractEIP1559GasProvider; import org.web3j.tx.gas.ContractGasProvider; /** @@ -35,34 +45,50 @@ * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the * codegen module to update. * - *

Generated with web3j version 1.4.2. + *

Generated with web3j version 1.5.0. */ @SuppressWarnings("rawtypes") public class IL1Bridge extends Contract { public static final String BINARY = "Bin file was not provided"; + public static final String FUNC_BRIDGEHUB = "bridgehub"; + + public static final String FUNC_BRIDGEHUBCONFIRML2TRANSACTION = "bridgehubConfirmL2Transaction"; + + public static final String FUNC_BRIDGEHUBDEPOSIT = "bridgehubDeposit"; + + public static final String FUNC_BRIDGEHUBDEPOSITBASETOKEN = "bridgehubDepositBaseToken"; + public static final String FUNC_CLAIMFAILEDDEPOSIT = "claimFailedDeposit"; public static final String FUNC_DEPOSIT = "deposit"; + public static final String FUNC_DEPOSITHAPPENED = "depositHappened"; + public static final String FUNC_FINALIZEWITHDRAWAL = "finalizeWithdrawal"; - public static final String FUNC_ISWITHDRAWALFINALIZED = "isWithdrawalFinalized"; + public static final String FUNC_ISWITHDRAWALFINALIZEDSHARED = "isWithdrawalFinalizedShared"; - public static final String FUNC_L2BRIDGE = "l2Bridge"; + public static final String FUNC_L2BRIDGEADDRESS = "l2BridgeAddress"; - public static final String FUNC_L2TOKENADDRESS = "l2TokenAddress"; + public static final Event BRIDGEHUBDEPOSITFINALIZED_EVENT = new Event("BridgehubDepositFinalized", + Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {}, new TypeReference(true) {})); + ; + + public static final Event BRIDGEHUBDEPOSITINITIATEDSHAREDBRIDGE_EVENT = new Event("BridgehubDepositInitiatedSharedBridge", + Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {}, new TypeReference

(true) {}, new TypeReference
() {}, new TypeReference
() {}, new TypeReference() {})); + ; - public static final Event CLAIMEDFAILEDDEPOSIT_EVENT = new Event("ClaimedFailedDeposit", - Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {}, new TypeReference() {})); + public static final Event CLAIMEDFAILEDDEPOSITSHAREDBRIDGE_EVENT = new Event("ClaimedFailedDepositSharedBridge", + Arrays.>asList(new TypeReference(true) {}, new TypeReference
(true) {}, new TypeReference
(true) {}, new TypeReference() {})); ; - public static final Event DEPOSITINITIATED_EVENT = new Event("DepositInitiated", - Arrays.>asList(new TypeReference(true) {}, new TypeReference
(true) {}, new TypeReference
(true) {}, new TypeReference
() {}, new TypeReference() {})); + public static final Event DEPOSITINITIATEDSHAREDBRIDGE_EVENT = new Event("DepositInitiatedSharedBridge", + Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {}, new TypeReference
(true) {}, new TypeReference
() {}, new TypeReference
() {}, new TypeReference() {})); ; - public static final Event WITHDRAWALFINALIZED_EVENT = new Event("WithdrawalFinalized", - Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {}, new TypeReference() {})); + public static final Event WITHDRAWALFINALIZEDSHAREDBRIDGE_EVENT = new Event("WithdrawalFinalizedSharedBridge", + Arrays.>asList(new TypeReference(true) {}, new TypeReference
(true) {}, new TypeReference
(true) {}, new TypeReference() {})); ; @Deprecated @@ -83,125 +109,242 @@ protected IL1Bridge(String contractAddress, Web3j web3j, TransactionManager tran super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); } - public static List getClaimedFailedDepositEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(CLAIMEDFAILEDDEPOSIT_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + public static List getBridgehubDepositFinalizedEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(BRIDGEHUBDEPOSITFINALIZED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + BridgehubDepositFinalizedEventResponse typedResponse = new BridgehubDepositFinalizedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.txDataHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.l2DepositTxHash = (byte[]) eventValues.getIndexedValues().get(2).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static BridgehubDepositFinalizedEventResponse getBridgehubDepositFinalizedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(BRIDGEHUBDEPOSITFINALIZED_EVENT, log); + BridgehubDepositFinalizedEventResponse typedResponse = new BridgehubDepositFinalizedEventResponse(); + typedResponse.log = log; + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.txDataHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.l2DepositTxHash = (byte[]) eventValues.getIndexedValues().get(2).getValue(); + return typedResponse; + } + + public Flowable bridgehubDepositFinalizedEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getBridgehubDepositFinalizedEventFromLog(log)); + } + + public Flowable bridgehubDepositFinalizedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(BRIDGEHUBDEPOSITFINALIZED_EVENT)); + return bridgehubDepositFinalizedEventFlowable(filter); + } + + public static List getBridgehubDepositInitiatedSharedBridgeEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(BRIDGEHUBDEPOSITINITIATEDSHAREDBRIDGE_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + BridgehubDepositInitiatedSharedBridgeEventResponse typedResponse = new BridgehubDepositInitiatedSharedBridgeEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.txDataHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.from = (String) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.to = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.l1Token = (String) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static BridgehubDepositInitiatedSharedBridgeEventResponse getBridgehubDepositInitiatedSharedBridgeEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(BRIDGEHUBDEPOSITINITIATEDSHAREDBRIDGE_EVENT, log); + BridgehubDepositInitiatedSharedBridgeEventResponse typedResponse = new BridgehubDepositInitiatedSharedBridgeEventResponse(); + typedResponse.log = log; + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.txDataHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.from = (String) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.to = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.l1Token = (String) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + return typedResponse; + } + + public Flowable bridgehubDepositInitiatedSharedBridgeEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getBridgehubDepositInitiatedSharedBridgeEventFromLog(log)); + } + + public Flowable bridgehubDepositInitiatedSharedBridgeEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(BRIDGEHUBDEPOSITINITIATEDSHAREDBRIDGE_EVENT)); + return bridgehubDepositInitiatedSharedBridgeEventFlowable(filter); + } + + public static List getClaimedFailedDepositSharedBridgeEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(CLAIMEDFAILEDDEPOSITSHAREDBRIDGE_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); for (EventValuesWithLog eventValues : valueList) { - ClaimedFailedDepositEventResponse typedResponse = new ClaimedFailedDepositEventResponse(); + ClaimedFailedDepositSharedBridgeEventResponse typedResponse = new ClaimedFailedDepositSharedBridgeEventResponse(); typedResponse.log = eventValues.getLog(); - typedResponse.to = (String) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.l1Token = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.l1Token = (String) eventValues.getIndexedValues().get(2).getValue(); typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); responses.add(typedResponse); } return responses; } - public Flowable claimedFailedDepositEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public ClaimedFailedDepositEventResponse apply(Log log) { - EventValuesWithLog eventValues = extractEventParametersWithLog(CLAIMEDFAILEDDEPOSIT_EVENT, log); - ClaimedFailedDepositEventResponse typedResponse = new ClaimedFailedDepositEventResponse(); - typedResponse.log = log; - typedResponse.to = (String) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.l1Token = (String) eventValues.getIndexedValues().get(1).getValue(); - typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); - return typedResponse; - } - }); + public static ClaimedFailedDepositSharedBridgeEventResponse getClaimedFailedDepositSharedBridgeEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(CLAIMEDFAILEDDEPOSITSHAREDBRIDGE_EVENT, log); + ClaimedFailedDepositSharedBridgeEventResponse typedResponse = new ClaimedFailedDepositSharedBridgeEventResponse(); + typedResponse.log = log; + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.l1Token = (String) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; } - public Flowable claimedFailedDepositEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable claimedFailedDepositSharedBridgeEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getClaimedFailedDepositSharedBridgeEventFromLog(log)); + } + + public Flowable claimedFailedDepositSharedBridgeEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); - filter.addSingleTopic(EventEncoder.encode(CLAIMEDFAILEDDEPOSIT_EVENT)); - return claimedFailedDepositEventFlowable(filter); + filter.addSingleTopic(EventEncoder.encode(CLAIMEDFAILEDDEPOSITSHAREDBRIDGE_EVENT)); + return claimedFailedDepositSharedBridgeEventFlowable(filter); } - public static List getDepositInitiatedEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(DEPOSITINITIATED_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + public static List getDepositInitiatedSharedBridgeEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(DEPOSITINITIATEDSHAREDBRIDGE_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); for (EventValuesWithLog eventValues : valueList) { - DepositInitiatedEventResponse typedResponse = new DepositInitiatedEventResponse(); + DepositInitiatedSharedBridgeEventResponse typedResponse = new DepositInitiatedSharedBridgeEventResponse(); typedResponse.log = eventValues.getLog(); - typedResponse.l2DepositTxHash = (byte[]) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.from = (String) eventValues.getIndexedValues().get(1).getValue(); - typedResponse.to = (String) eventValues.getIndexedValues().get(2).getValue(); - typedResponse.l1Token = (String) eventValues.getNonIndexedValues().get(0).getValue(); - typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.l2DepositTxHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.from = (String) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.to = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.l1Token = (String) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); responses.add(typedResponse); } return responses; } - public Flowable depositInitiatedEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public DepositInitiatedEventResponse apply(Log log) { - EventValuesWithLog eventValues = extractEventParametersWithLog(DEPOSITINITIATED_EVENT, log); - DepositInitiatedEventResponse typedResponse = new DepositInitiatedEventResponse(); - typedResponse.log = log; - typedResponse.l2DepositTxHash = (byte[]) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.from = (String) eventValues.getIndexedValues().get(1).getValue(); - typedResponse.to = (String) eventValues.getIndexedValues().get(2).getValue(); - typedResponse.l1Token = (String) eventValues.getNonIndexedValues().get(0).getValue(); - typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); - return typedResponse; - } - }); - } - - public Flowable depositInitiatedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public static DepositInitiatedSharedBridgeEventResponse getDepositInitiatedSharedBridgeEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(DEPOSITINITIATEDSHAREDBRIDGE_EVENT, log); + DepositInitiatedSharedBridgeEventResponse typedResponse = new DepositInitiatedSharedBridgeEventResponse(); + typedResponse.log = log; + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.l2DepositTxHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.from = (String) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.to = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.l1Token = (String) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + return typedResponse; + } + + public Flowable depositInitiatedSharedBridgeEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getDepositInitiatedSharedBridgeEventFromLog(log)); + } + + public Flowable depositInitiatedSharedBridgeEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); - filter.addSingleTopic(EventEncoder.encode(DEPOSITINITIATED_EVENT)); - return depositInitiatedEventFlowable(filter); + filter.addSingleTopic(EventEncoder.encode(DEPOSITINITIATEDSHAREDBRIDGE_EVENT)); + return depositInitiatedSharedBridgeEventFlowable(filter); } - public static List getWithdrawalFinalizedEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(WITHDRAWALFINALIZED_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + public static List getWithdrawalFinalizedSharedBridgeEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(WITHDRAWALFINALIZEDSHAREDBRIDGE_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); for (EventValuesWithLog eventValues : valueList) { - WithdrawalFinalizedEventResponse typedResponse = new WithdrawalFinalizedEventResponse(); + WithdrawalFinalizedSharedBridgeEventResponse typedResponse = new WithdrawalFinalizedSharedBridgeEventResponse(); typedResponse.log = eventValues.getLog(); - typedResponse.to = (String) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.l1Token = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.l1Token = (String) eventValues.getIndexedValues().get(2).getValue(); typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); responses.add(typedResponse); } return responses; } - public Flowable withdrawalFinalizedEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public WithdrawalFinalizedEventResponse apply(Log log) { - EventValuesWithLog eventValues = extractEventParametersWithLog(WITHDRAWALFINALIZED_EVENT, log); - WithdrawalFinalizedEventResponse typedResponse = new WithdrawalFinalizedEventResponse(); - typedResponse.log = log; - typedResponse.to = (String) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.l1Token = (String) eventValues.getIndexedValues().get(1).getValue(); - typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); - return typedResponse; - } - }); + public static WithdrawalFinalizedSharedBridgeEventResponse getWithdrawalFinalizedSharedBridgeEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(WITHDRAWALFINALIZEDSHAREDBRIDGE_EVENT, log); + WithdrawalFinalizedSharedBridgeEventResponse typedResponse = new WithdrawalFinalizedSharedBridgeEventResponse(); + typedResponse.log = log; + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.l1Token = (String) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + + public Flowable withdrawalFinalizedSharedBridgeEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getWithdrawalFinalizedSharedBridgeEventFromLog(log)); } - public Flowable withdrawalFinalizedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable withdrawalFinalizedSharedBridgeEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); - filter.addSingleTopic(EventEncoder.encode(WITHDRAWALFINALIZED_EVENT)); - return withdrawalFinalizedEventFlowable(filter); + filter.addSingleTopic(EventEncoder.encode(WITHDRAWALFINALIZEDSHAREDBRIDGE_EVENT)); + return withdrawalFinalizedSharedBridgeEventFlowable(filter); } - public RemoteFunctionCall claimFailedDeposit(String _depositSender, String _l1Token, byte[] _l2TxHash, BigInteger _l2BatchNumber, BigInteger _l2MessageIndex, BigInteger _l2TxNumberInBatch, List _merkleProof) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( + public RemoteFunctionCall bridgehub() { + final Function function = new Function(FUNC_BRIDGEHUB, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall bridgehubConfirmL2Transaction(BigInteger _chainId, byte[] _txDataHash, byte[] _txHash) { + final Function function = new Function( + FUNC_BRIDGEHUBCONFIRML2TRANSACTION, + Arrays.asList(new Uint256(_chainId), + new Bytes32(_txDataHash), + new Bytes32(_txHash)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall bridgehubDeposit(BigInteger _chainId, String _prevMsgSender, byte[] _data, BigInteger weiValue) { + final Function function = new Function( + FUNC_BRIDGEHUBDEPOSIT, + Arrays.asList(new Uint256(_chainId), + new Address(160, _prevMsgSender), + new DynamicBytes(_data)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public RemoteFunctionCall bridgehubDepositBaseToken(BigInteger _chainId, String _prevMsgSender, String _l1Token, BigInteger _amount, BigInteger weiValue) { + final Function function = new Function( + FUNC_BRIDGEHUBDEPOSITBASETOKEN, + Arrays.asList(new Uint256(_chainId), + new Address(160, _prevMsgSender), + new Address(160, _l1Token), + new Uint256(_amount)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public RemoteFunctionCall claimFailedDeposit(BigInteger _chainId, String _depositSender, String _l1Token, BigInteger _amount, byte[] _l2TxHash, BigInteger _l2BatchNumber, BigInteger _l2MessageIndex, BigInteger _l2TxNumberInBatch, List _merkleProof) { + final Function function = new Function( FUNC_CLAIMFAILEDDEPOSIT, - Arrays.asList(new Address(160, _depositSender), + Arrays.asList(new Uint256(_chainId), + new Address(160, _depositSender), new Address(160, _l1Token), + new Uint256(_amount), new Bytes32(_l2TxHash), new Uint256(_l2BatchNumber), new Uint256(_l2MessageIndex), new org.web3j.abi.datatypes.generated.Uint16(_l2TxNumberInBatch), - new org.web3j.abi.datatypes.DynamicArray( + new DynamicArray( Bytes32.class, org.web3j.abi.Utils.typeMap(_merkleProof, Bytes32.class))), Collections.>emptyList()); @@ -221,11 +364,13 @@ public String encodeDeposit(String _l2Receiver, String _l1Token, BigInteger _amo return FunctionEncoder.encode(function); } - public RemoteFunctionCall deposit(String _l2Receiver, String _l1Token, BigInteger _amount, BigInteger _l2TxGasLimit, BigInteger _l2TxGasPerPubdataByte, String _refundRecipient, BigInteger weiValue) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( + public RemoteFunctionCall deposit(BigInteger _chainId, String _l2Receiver, String _l1Token, BigInteger _mintValue, BigInteger _amount, BigInteger _l2TxGasLimit, BigInteger _l2TxGasPerPubdataByte, String _refundRecipient, BigInteger weiValue) { + final Function function = new Function( FUNC_DEPOSIT, - Arrays.asList(new Address(160, _l2Receiver), + Arrays.asList(new Uint256(_chainId), + new Address(160, _l2Receiver), new Address(160, _l1Token), + new Uint256(_mintValue), new Uint256(_amount), new Uint256(_l2TxGasLimit), new Uint256(_l2TxGasPerPubdataByte), @@ -234,38 +379,42 @@ public RemoteFunctionCall deposit(String _l2Receiver, String return executeRemoteCallTransaction(function, weiValue); } - public RemoteFunctionCall finalizeWithdrawal(BigInteger _l2BatchNumber, BigInteger _l2MessageIndex, BigInteger _l2TxNumberInBatch, byte[] _message, List _merkleProof) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( - FUNC_FINALIZEWITHDRAWAL, - Arrays.asList(new Uint256(_l2BatchNumber), - new Uint256(_l2MessageIndex), - new org.web3j.abi.datatypes.generated.Uint16(_l2TxNumberInBatch), - new org.web3j.abi.datatypes.DynamicBytes(_message), - new org.web3j.abi.datatypes.DynamicArray( - Bytes32.class, - org.web3j.abi.Utils.typeMap(_merkleProof, Bytes32.class))), + public RemoteFunctionCall depositHappened(BigInteger _chainId, byte[] _l2TxHash) { + final Function function = new Function(FUNC_DEPOSITHAPPENED, + Arrays.asList(new Uint256(_chainId), + new Bytes32(_l2TxHash)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, byte[].class); + } + + public RemoteFunctionCall finalizeWithdrawal(BigInteger _chainId, BigInteger _l2BatchNumber, BigInteger _l2MessageIndex, BigInteger _l2TxNumberInBatch, byte[] _message, List _merkleProof) throws TransactionException, IOException { + final Function function = new Function( + FUNC_FINALIZEWITHDRAWAL, + Arrays.asList(new Uint256(_chainId), + new Uint256(_l2BatchNumber), + new Uint256(_l2MessageIndex), + new org.web3j.abi.datatypes.generated.Uint16(_l2TxNumberInBatch), + new DynamicBytes(_message), + new DynamicArray( + Bytes32.class, + org.web3j.abi.Utils.typeMap(_merkleProof, Bytes32.class))), Collections.>emptyList()); - return executeRemoteCallTransaction(function); + + return new RemoteFunctionCall(function, () -> this.send(this.contractAddress, ZkFunctionEncoder.encode(function), BigInteger.ZERO, this.gasProvider.getGasPrice(FUNC_FINALIZEWITHDRAWAL), this.gasProvider.getGasLimit(FUNC_FINALIZEWITHDRAWAL), false)); } - public RemoteFunctionCall isWithdrawalFinalized(BigInteger _l2BatchNumber, BigInteger _l2MessageIndex) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_ISWITHDRAWALFINALIZED, - Arrays.asList(new Uint256(_l2BatchNumber), + public RemoteFunctionCall isWithdrawalFinalizedShared(BigInteger _chainId, BigInteger _l2BatchNumber, BigInteger _l2MessageIndex) { + final Function function = new Function(FUNC_ISWITHDRAWALFINALIZEDSHARED, + Arrays.asList(new Uint256(_chainId), + new Uint256(_l2BatchNumber), new Uint256(_l2MessageIndex)), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, Boolean.class); } - public RemoteFunctionCall l2Bridge() { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_L2BRIDGE, - Arrays.asList(), - Arrays.>asList(new TypeReference
() {})); - return executeRemoteCallSingleValueReturn(function, String.class); - } - - public RemoteFunctionCall l2TokenAddress(String _l1Token) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_L2TOKENADDRESS, - Arrays.asList(new Address(160, _l1Token)), + public RemoteFunctionCall l2BridgeAddress(BigInteger _chainId) { + final Function function = new Function(FUNC_L2BRIDGEADDRESS, + Arrays.asList(new Uint256(_chainId)), Arrays.>asList(new TypeReference
() {})); return executeRemoteCallSingleValueReturn(function, String.class); } @@ -288,7 +437,67 @@ public static IL1Bridge load(String contractAddress, Web3j web3j, TransactionMan return new IL1Bridge(contractAddress, web3j, transactionManager, contractGasProvider); } - public static class ClaimedFailedDepositEventResponse extends BaseEventResponse { + public static class L2TransactionRequestTwoBridgesInner extends DynamicStruct { + public byte[] magicValue; + + public String l2Contract; + + public byte[] l2Calldata; + + public List factoryDeps; + + public byte[] txDataHash; + + public L2TransactionRequestTwoBridgesInner(byte[] magicValue, String l2Contract, byte[] l2Calldata, List factoryDeps, byte[] txDataHash) { + super(new Bytes32(magicValue), + new Address(160, l2Contract), + new DynamicBytes(l2Calldata), + new DynamicArray( + DynamicBytes.class, + org.web3j.abi.Utils.typeMap(factoryDeps, DynamicBytes.class)), + new Bytes32(txDataHash)); + this.magicValue = magicValue; + this.l2Contract = l2Contract; + this.l2Calldata = l2Calldata; + this.factoryDeps = factoryDeps; + this.txDataHash = txDataHash; + } + + public L2TransactionRequestTwoBridgesInner(Bytes32 magicValue, Address l2Contract, DynamicBytes l2Calldata, DynamicArray factoryDeps, Bytes32 txDataHash) { + super(magicValue, l2Contract, l2Calldata, factoryDeps, txDataHash); + this.magicValue = magicValue.getValue(); + this.l2Contract = l2Contract.getValue(); + this.l2Calldata = l2Calldata.getValue(); + this.factoryDeps = factoryDeps.getValue().stream().map(v -> v.getValue()).collect(Collectors.toList()); + this.txDataHash = txDataHash.getValue(); + } + } + + public static class BridgehubDepositFinalizedEventResponse extends BaseEventResponse { + public BigInteger chainId; + + public byte[] txDataHash; + + public byte[] l2DepositTxHash; + } + + public static class BridgehubDepositInitiatedSharedBridgeEventResponse extends BaseEventResponse { + public BigInteger chainId; + + public byte[] txDataHash; + + public String from; + + public String to; + + public String l1Token; + + public BigInteger amount; + } + + public static class ClaimedFailedDepositSharedBridgeEventResponse extends BaseEventResponse { + public BigInteger chainId; + public String to; public String l1Token; @@ -296,7 +505,9 @@ public static class ClaimedFailedDepositEventResponse extends BaseEventResponse public BigInteger amount; } - public static class DepositInitiatedEventResponse extends BaseEventResponse { + public static class DepositInitiatedSharedBridgeEventResponse extends BaseEventResponse { + public BigInteger chainId; + public byte[] l2DepositTxHash; public String from; @@ -308,7 +519,9 @@ public static class DepositInitiatedEventResponse extends BaseEventResponse { public BigInteger amount; } - public static class WithdrawalFinalizedEventResponse extends BaseEventResponse { + public static class WithdrawalFinalizedSharedBridgeEventResponse extends BaseEventResponse { + public BigInteger chainId; + public String to; public String l1Token; diff --git a/src/main/java/io/zksync/wrappers/IL1ERC20Bridge.java b/src/main/java/io/zksync/wrappers/IL1ERC20Bridge.java new file mode 100644 index 0000000..1234cc9 --- /dev/null +++ b/src/main/java/io/zksync/wrappers/IL1ERC20Bridge.java @@ -0,0 +1,354 @@ +package io.zksync.wrappers; + +import io.reactivex.Flowable; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import org.web3j.abi.EventEncoder; +import org.web3j.abi.TypeReference; +import org.web3j.abi.datatypes.Address; +import org.web3j.abi.datatypes.Bool; +import org.web3j.abi.datatypes.Event; +import org.web3j.abi.datatypes.Function; +import org.web3j.abi.datatypes.Type; +import org.web3j.abi.datatypes.generated.Bytes32; +import org.web3j.abi.datatypes.generated.Uint256; +import org.web3j.crypto.Credentials; +import org.web3j.protocol.Web3j; +import org.web3j.protocol.core.DefaultBlockParameter; +import org.web3j.protocol.core.RemoteFunctionCall; +import org.web3j.protocol.core.methods.request.EthFilter; +import org.web3j.protocol.core.methods.response.BaseEventResponse; +import org.web3j.protocol.core.methods.response.Log; +import org.web3j.protocol.core.methods.response.TransactionReceipt; +import org.web3j.tx.Contract; +import org.web3j.tx.TransactionManager; +import org.web3j.tx.gas.ContractGasProvider; + +/** + *

Auto generated code. + *

Do not modify! + *

Please use the web3j command line tools, + * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the + * codegen module to update. + * + *

Generated with web3j version 1.5.0. + */ +@SuppressWarnings("rawtypes") +public class IL1ERC20Bridge extends Contract { + public static final String BINARY = "Bin file was not provided"; + + public static final String FUNC_CLAIMFAILEDDEPOSIT = "claimFailedDeposit"; + + public static final String FUNC_deposit = "deposit"; + + public static final String FUNC_DEPOSITAMOUNT = "depositAmount"; + + public static final String FUNC_FINALIZEWITHDRAWAL = "finalizeWithdrawal"; + + public static final String FUNC_ISWITHDRAWALFINALIZED = "isWithdrawalFinalized"; + + public static final String FUNC_L2BRIDGE = "l2Bridge"; + + public static final String FUNC_L2TOKENADDRESS = "l2TokenAddress"; + + public static final String FUNC_L2TOKENBEACON = "l2TokenBeacon"; + + public static final String FUNC_SHAREDBRIDGE = "sharedBridge"; + + public static final String FUNC_TRANSFERTOKENTOSHAREDBRIDGE = "transferTokenToSharedBridge"; + + public static final Event CLAIMEDFAILEDDEPOSIT_EVENT = new Event("ClaimedFailedDeposit", + Arrays.>asList(new TypeReference

(true) {}, new TypeReference
(true) {}, new TypeReference() {})); + ; + + public static final Event DEPOSITINITIATED_EVENT = new Event("DepositInitiated", + Arrays.>asList(new TypeReference(true) {}, new TypeReference
(true) {}, new TypeReference
(true) {}, new TypeReference
() {}, new TypeReference() {})); + ; + + public static final Event WITHDRAWALFINALIZED_EVENT = new Event("WithdrawalFinalized", + Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {}, new TypeReference() {})); + ; + + @Deprecated + protected IL1ERC20Bridge(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + protected IL1ERC20Bridge(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, credentials, contractGasProvider); + } + + @Deprecated + protected IL1ERC20Bridge(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + protected IL1ERC20Bridge(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); + } + + public static List getClaimedFailedDepositEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(CLAIMEDFAILEDDEPOSIT_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + ClaimedFailedDepositEventResponse typedResponse = new ClaimedFailedDepositEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.to = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.l1Token = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static ClaimedFailedDepositEventResponse getClaimedFailedDepositEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(CLAIMEDFAILEDDEPOSIT_EVENT, log); + ClaimedFailedDepositEventResponse typedResponse = new ClaimedFailedDepositEventResponse(); + typedResponse.log = log; + typedResponse.to = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.l1Token = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + + public Flowable claimedFailedDepositEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getClaimedFailedDepositEventFromLog(log)); + } + + public Flowable claimedFailedDepositEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(CLAIMEDFAILEDDEPOSIT_EVENT)); + return claimedFailedDepositEventFlowable(filter); + } + + public static List getDepositInitiatedEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(DEPOSITINITIATED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + DepositInitiatedEventResponse typedResponse = new DepositInitiatedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.l2DepositTxHash = (byte[]) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.from = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.to = (String) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.l1Token = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static DepositInitiatedEventResponse getDepositInitiatedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(DEPOSITINITIATED_EVENT, log); + DepositInitiatedEventResponse typedResponse = new DepositInitiatedEventResponse(); + typedResponse.log = log; + typedResponse.l2DepositTxHash = (byte[]) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.from = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.to = (String) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.l1Token = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable depositInitiatedEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getDepositInitiatedEventFromLog(log)); + } + + public Flowable depositInitiatedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(DEPOSITINITIATED_EVENT)); + return depositInitiatedEventFlowable(filter); + } + + public static List getWithdrawalFinalizedEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(WITHDRAWALFINALIZED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + WithdrawalFinalizedEventResponse typedResponse = new WithdrawalFinalizedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.to = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.l1Token = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static WithdrawalFinalizedEventResponse getWithdrawalFinalizedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(WITHDRAWALFINALIZED_EVENT, log); + WithdrawalFinalizedEventResponse typedResponse = new WithdrawalFinalizedEventResponse(); + typedResponse.log = log; + typedResponse.to = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.l1Token = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + + public Flowable withdrawalFinalizedEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getWithdrawalFinalizedEventFromLog(log)); + } + + public Flowable withdrawalFinalizedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(WITHDRAWALFINALIZED_EVENT)); + return withdrawalFinalizedEventFlowable(filter); + } + + public RemoteFunctionCall claimFailedDeposit(String _depositSender, String _l1Token, byte[] _l2TxHash, BigInteger _l2BatchNumber, BigInteger _l2MessageIndex, BigInteger _l2TxNumberInBatch, List _merkleProof) { + final Function function = new Function( + FUNC_CLAIMFAILEDDEPOSIT, + Arrays.asList(new Address(160, _depositSender), + new Address(160, _l1Token), + new Bytes32(_l2TxHash), + new Uint256(_l2BatchNumber), + new Uint256(_l2MessageIndex), + new org.web3j.abi.datatypes.generated.Uint16(_l2TxNumberInBatch), + new org.web3j.abi.datatypes.DynamicArray( + Bytes32.class, + org.web3j.abi.Utils.typeMap(_merkleProof, Bytes32.class))), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall deposit(String _l2Receiver, String _l1Token, BigInteger _amount, BigInteger _l2TxGasLimit, BigInteger _l2TxGasPerPubdataByte, BigInteger weiValue) { + final Function function = new Function( + FUNC_deposit, + Arrays.asList(new Address(160, _l2Receiver), + new Address(160, _l1Token), + new Uint256(_amount), + new Uint256(_l2TxGasLimit), + new Uint256(_l2TxGasPerPubdataByte)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public RemoteFunctionCall deposit(String _l2Receiver, String _l1Token, BigInteger _amount, BigInteger _l2TxGasLimit, BigInteger _l2TxGasPerPubdataByte, String _refundRecipient, BigInteger weiValue) { + final Function function = new Function( + FUNC_deposit, + Arrays.asList(new Address(160, _l2Receiver), + new Address(160, _l1Token), + new Uint256(_amount), + new Uint256(_l2TxGasLimit), + new Uint256(_l2TxGasPerPubdataByte), + new Address(160, _refundRecipient)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public RemoteFunctionCall depositAmount(String _account, String _l1Token, byte[] _depositL2TxHash) { + final Function function = new Function( + FUNC_DEPOSITAMOUNT, + Arrays.asList(new Address(160, _account), + new Address(160, _l1Token), + new Bytes32(_depositL2TxHash)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall finalizeWithdrawal(BigInteger _l2BatchNumber, BigInteger _l2MessageIndex, BigInteger _l2TxNumberInBatch, byte[] _message, List _merkleProof) { + final Function function = new Function( + FUNC_FINALIZEWITHDRAWAL, + Arrays.asList(new Uint256(_l2BatchNumber), + new Uint256(_l2MessageIndex), + new org.web3j.abi.datatypes.generated.Uint16(_l2TxNumberInBatch), + new org.web3j.abi.datatypes.DynamicBytes(_message), + new org.web3j.abi.datatypes.DynamicArray( + Bytes32.class, + org.web3j.abi.Utils.typeMap(_merkleProof, Bytes32.class))), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall isWithdrawalFinalized(BigInteger _l2BatchNumber, BigInteger _l2MessageIndex) { + final Function function = new Function(FUNC_ISWITHDRAWALFINALIZED, + Arrays.asList(new Uint256(_l2BatchNumber), + new Uint256(_l2MessageIndex)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall l2Bridge() { + final Function function = new Function(FUNC_L2BRIDGE, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall l2TokenAddress(String _l1Token) { + final Function function = new Function(FUNC_L2TOKENADDRESS, + Arrays.asList(new Address(160, _l1Token)), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall l2TokenBeacon() { + final Function function = new Function(FUNC_L2TOKENBEACON, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall sharedBridge() { + final Function function = new Function(FUNC_SHAREDBRIDGE, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall transferTokenToSharedBridge(String _token, BigInteger _amount) { + final Function function = new Function( + FUNC_TRANSFERTOKENTOSHAREDBRIDGE, + Arrays.asList(new Address(160, _token), + new Uint256(_amount)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + @Deprecated + public static IL1ERC20Bridge load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + return new IL1ERC20Bridge(contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + @Deprecated + public static IL1ERC20Bridge load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + return new IL1ERC20Bridge(contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + public static IL1ERC20Bridge load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + return new IL1ERC20Bridge(contractAddress, web3j, credentials, contractGasProvider); + } + + public static IL1ERC20Bridge load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + return new IL1ERC20Bridge(contractAddress, web3j, transactionManager, contractGasProvider); + } + + public static class ClaimedFailedDepositEventResponse extends BaseEventResponse { + public String to; + + public String l1Token; + + public BigInteger amount; + } + + public static class DepositInitiatedEventResponse extends BaseEventResponse { + public byte[] l2DepositTxHash; + + public String from; + + public String to; + + public String l1Token; + + public BigInteger amount; + } + + public static class WithdrawalFinalizedEventResponse extends BaseEventResponse { + public String to; + + public String l1Token; + + public BigInteger amount; + } +} diff --git a/src/main/java/io/zksync/wrappers/IL1Messenger.java b/src/main/java/io/zksync/wrappers/IL1Messenger.java index ccdf0cc..4bfebe0 100644 --- a/src/main/java/io/zksync/wrappers/IL1Messenger.java +++ b/src/main/java/io/zksync/wrappers/IL1Messenger.java @@ -1,7 +1,6 @@ package io.zksync.wrappers; import io.reactivex.Flowable; -import io.reactivex.functions.Function; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; @@ -14,6 +13,7 @@ import org.web3j.abi.datatypes.Bool; import org.web3j.abi.datatypes.DynamicBytes; import org.web3j.abi.datatypes.Event; +import org.web3j.abi.datatypes.Function; import org.web3j.abi.datatypes.StaticStruct; import org.web3j.abi.datatypes.Type; import org.web3j.abi.datatypes.generated.Bytes32; @@ -38,7 +38,7 @@ * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the * codegen module to update. * - *

Generated with web3j version 1.4.2. + *

Generated with web3j version 1.5.0. */ @SuppressWarnings("rawtypes") public class IL1Messenger extends Contract { @@ -92,17 +92,16 @@ public static List getBytecodeL1Pub return responses; } + public static BytecodeL1PublicationRequestedEventResponse getBytecodeL1PublicationRequestedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(BYTECODEL1PUBLICATIONREQUESTED_EVENT, log); + BytecodeL1PublicationRequestedEventResponse typedResponse = new BytecodeL1PublicationRequestedEventResponse(); + typedResponse.log = log; + typedResponse._bytecodeHash = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + public Flowable bytecodeL1PublicationRequestedEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public BytecodeL1PublicationRequestedEventResponse apply(Log log) { - EventValuesWithLog eventValues = extractEventParametersWithLog(BYTECODEL1PUBLICATIONREQUESTED_EVENT, log); - BytecodeL1PublicationRequestedEventResponse typedResponse = new BytecodeL1PublicationRequestedEventResponse(); - typedResponse.log = log; - typedResponse._bytecodeHash = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> getBytecodeL1PublicationRequestedEventFromLog(log)); } public Flowable bytecodeL1PublicationRequestedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -125,19 +124,18 @@ public static List getL1MessageSentEvents(Transactio return responses; } + public static L1MessageSentEventResponse getL1MessageSentEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(L1MESSAGESENT_EVENT, log); + L1MessageSentEventResponse typedResponse = new L1MessageSentEventResponse(); + typedResponse.log = log; + typedResponse._sender = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse._hash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse._message = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + public Flowable l1MessageSentEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public L1MessageSentEventResponse apply(Log log) { - EventValuesWithLog eventValues = extractEventParametersWithLog(L1MESSAGESENT_EVENT, log); - L1MessageSentEventResponse typedResponse = new L1MessageSentEventResponse(); - typedResponse.log = log; - typedResponse._sender = (String) eventValues.getIndexedValues().get(0).getValue(); - typedResponse._hash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); - typedResponse._message = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> getL1MessageSentEventFromLog(log)); } public Flowable l1MessageSentEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -158,17 +156,16 @@ public static List getL2ToL1LogSentEvents(Transactio return responses; } + public static L2ToL1LogSentEventResponse getL2ToL1LogSentEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(L2TOL1LOGSENT_EVENT, log); + L2ToL1LogSentEventResponse typedResponse = new L2ToL1LogSentEventResponse(); + typedResponse.log = log; + typedResponse._l2log = (L2ToL1Log) eventValues.getNonIndexedValues().get(0); + return typedResponse; + } + public Flowable l2ToL1LogSentEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public L2ToL1LogSentEventResponse apply(Log log) { - EventValuesWithLog eventValues = extractEventParametersWithLog(L2TOL1LOGSENT_EVENT, log); - L2ToL1LogSentEventResponse typedResponse = new L2ToL1LogSentEventResponse(); - typedResponse.log = log; - typedResponse._l2log = (L2ToL1Log) eventValues.getNonIndexedValues().get(0); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> getL2ToL1LogSentEventFromLog(log)); } public Flowable l2ToL1LogSentEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -178,7 +175,7 @@ public Flowable l2ToL1LogSentEventFlowable(DefaultBl } public RemoteFunctionCall requestBytecodeL1Publication(byte[] _bytecodeHash) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( + final Function function = new Function( FUNC_REQUESTBYTECODEL1PUBLICATION, Arrays.asList(new Bytes32(_bytecodeHash)), Collections.>emptyList()); @@ -186,7 +183,7 @@ public RemoteFunctionCall requestBytecodeL1Publication(byte[ } public RemoteFunctionCall sendL2ToL1Log(Boolean _isService, byte[] _key, byte[] _value) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( + final Function function = new Function( FUNC_SENDL2TOL1LOG, Arrays.asList(new Bool(_isService), new Bytes32(_key), @@ -196,7 +193,7 @@ public RemoteFunctionCall sendL2ToL1Log(Boolean _isService, } public static String encodeSendToL1(byte[] _message) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( + final Function function = new Function( FUNC_SENDTOL1, Arrays.asList(new DynamicBytes(_message)), Collections.>emptyList()); @@ -204,7 +201,7 @@ public static String encodeSendToL1(byte[] _message) { } public RemoteFunctionCall sendToL1(byte[] _message) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( + final Function function = new Function( FUNC_SENDTOL1, Arrays.asList(new DynamicBytes(_message)), Collections.>emptyList()); diff --git a/src/main/java/io/zksync/wrappers/IL1SharedBridge.java b/src/main/java/io/zksync/wrappers/IL1SharedBridge.java new file mode 100644 index 0000000..d8e835d --- /dev/null +++ b/src/main/java/io/zksync/wrappers/IL1SharedBridge.java @@ -0,0 +1,633 @@ +package io.zksync.wrappers; + +import io.reactivex.Flowable; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import org.web3j.abi.EventEncoder; +import org.web3j.abi.TypeReference; +import org.web3j.abi.datatypes.Address; +import org.web3j.abi.datatypes.Bool; +import org.web3j.abi.datatypes.DynamicArray; +import org.web3j.abi.datatypes.DynamicBytes; +import org.web3j.abi.datatypes.DynamicStruct; +import org.web3j.abi.datatypes.Event; +import org.web3j.abi.datatypes.Function; +import org.web3j.abi.datatypes.Type; +import org.web3j.abi.datatypes.generated.Bytes32; +import org.web3j.abi.datatypes.generated.Uint256; +import org.web3j.crypto.Credentials; +import org.web3j.protocol.Web3j; +import org.web3j.protocol.core.DefaultBlockParameter; +import org.web3j.protocol.core.RemoteFunctionCall; +import org.web3j.protocol.core.methods.request.EthFilter; +import org.web3j.protocol.core.methods.response.BaseEventResponse; +import org.web3j.protocol.core.methods.response.Log; +import org.web3j.protocol.core.methods.response.TransactionReceipt; +import org.web3j.tx.Contract; +import org.web3j.tx.TransactionManager; +import org.web3j.tx.gas.ContractGasProvider; + +/** + *

Auto generated code. + *

Do not modify! + *

Please use the web3j command line tools, + * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the + * codegen module to update. + * + *

Generated with web3j version 1.5.0. + */ +@SuppressWarnings("rawtypes") +public class IL1SharedBridge extends Contract { + public static final String BINARY = "Bin file was not provided"; + + public static final String FUNC_BRIDGEHUB = "bridgehub"; + + public static final String FUNC_BRIDGEHUBCONFIRML2TRANSACTION = "bridgehubConfirmL2Transaction"; + + public static final String FUNC_BRIDGEHUBDEPOSIT = "bridgehubDeposit"; + + public static final String FUNC_BRIDGEHUBDEPOSITBASETOKEN = "bridgehubDepositBaseToken"; + + public static final String FUNC_CLAIMFAILEDDEPOSIT = "claimFailedDeposit"; + + public static final String FUNC_CLAIMFAILEDDEPOSITLEGACYERC20BRIDGE = "claimFailedDepositLegacyErc20Bridge"; + + public static final String FUNC_DEPOSITHAPPENED = "depositHappened"; + + public static final String FUNC_DEPOSITLEGACYERC20BRIDGE = "depositLegacyErc20Bridge"; + + public static final String FUNC_FINALIZEWITHDRAWAL = "finalizeWithdrawal"; + + public static final String FUNC_FINALIZEWITHDRAWALLEGACYERC20BRIDGE = "finalizeWithdrawalLegacyErc20Bridge"; + + public static final String FUNC_ISWITHDRAWALFINALIZED = "isWithdrawalFinalized"; + + public static final String FUNC_L1WETHADDRESS = "l1WethAddress"; + + public static final String FUNC_L2BRIDGEADDRESS = "l2BridgeAddress"; + + public static final String FUNC_LEGACYBRIDGE = "legacyBridge"; + + public static final String FUNC_RECEIVEETH = "receiveEth"; + + public static final String FUNC_SETERAFIRSTPOSTUPGRADEBATCH = "setEraFirstPostUpgradeBatch"; + + public static final Event BRIDGEHUBDEPOSITBASETOKENINITIATED_EVENT = new Event("BridgehubDepositBaseTokenInitiated", + Arrays.>asList(new TypeReference(true) {}, new TypeReference

(true) {}, new TypeReference
() {}, new TypeReference() {})); + ; + + public static final Event BRIDGEHUBDEPOSITFINALIZED_EVENT = new Event("BridgehubDepositFinalized", + Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {}, new TypeReference(true) {})); + ; + + public static final Event BRIDGEHUBDEPOSITINITIATED_EVENT = new Event("BridgehubDepositInitiated", + Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {}, new TypeReference
(true) {}, new TypeReference
() {}, new TypeReference
() {}, new TypeReference() {})); + ; + + public static final Event CLAIMEDFAILEDDEPOSITSHAREDBRIDGE_EVENT = new Event("ClaimedFailedDepositSharedBridge", + Arrays.>asList(new TypeReference(true) {}, new TypeReference
(true) {}, new TypeReference
(true) {}, new TypeReference() {})); + ; + + public static final Event LEGACYDEPOSITINITIATED_EVENT = new Event("LegacyDepositInitiated", + Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {}, new TypeReference
(true) {}, new TypeReference
() {}, new TypeReference
() {}, new TypeReference() {})); + ; + + public static final Event WITHDRAWALFINALIZEDSHAREDBRIDGE_EVENT = new Event("WithdrawalFinalizedSharedBridge", + Arrays.>asList(new TypeReference(true) {}, new TypeReference
(true) {}, new TypeReference
(true) {}, new TypeReference() {})); + ; + + @Deprecated + protected IL1SharedBridge(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + protected IL1SharedBridge(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, credentials, contractGasProvider); + } + + @Deprecated + protected IL1SharedBridge(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + protected IL1SharedBridge(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); + } + + public static List getBridgehubDepositBaseTokenInitiatedEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(BRIDGEHUBDEPOSITBASETOKENINITIATED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + BridgehubDepositBaseTokenInitiatedEventResponse typedResponse = new BridgehubDepositBaseTokenInitiatedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.from = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.l1Token = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static BridgehubDepositBaseTokenInitiatedEventResponse getBridgehubDepositBaseTokenInitiatedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(BRIDGEHUBDEPOSITBASETOKENINITIATED_EVENT, log); + BridgehubDepositBaseTokenInitiatedEventResponse typedResponse = new BridgehubDepositBaseTokenInitiatedEventResponse(); + typedResponse.log = log; + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.from = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.l1Token = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable bridgehubDepositBaseTokenInitiatedEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getBridgehubDepositBaseTokenInitiatedEventFromLog(log)); + } + + public Flowable bridgehubDepositBaseTokenInitiatedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(BRIDGEHUBDEPOSITBASETOKENINITIATED_EVENT)); + return bridgehubDepositBaseTokenInitiatedEventFlowable(filter); + } + + public static List getBridgehubDepositFinalizedEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(BRIDGEHUBDEPOSITFINALIZED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + BridgehubDepositFinalizedEventResponse typedResponse = new BridgehubDepositFinalizedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.txDataHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.l2DepositTxHash = (byte[]) eventValues.getIndexedValues().get(2).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static BridgehubDepositFinalizedEventResponse getBridgehubDepositFinalizedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(BRIDGEHUBDEPOSITFINALIZED_EVENT, log); + BridgehubDepositFinalizedEventResponse typedResponse = new BridgehubDepositFinalizedEventResponse(); + typedResponse.log = log; + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.txDataHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.l2DepositTxHash = (byte[]) eventValues.getIndexedValues().get(2).getValue(); + return typedResponse; + } + + public Flowable bridgehubDepositFinalizedEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getBridgehubDepositFinalizedEventFromLog(log)); + } + + public Flowable bridgehubDepositFinalizedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(BRIDGEHUBDEPOSITFINALIZED_EVENT)); + return bridgehubDepositFinalizedEventFlowable(filter); + } + + public static List getBridgehubDepositInitiatedEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(BRIDGEHUBDEPOSITINITIATED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + BridgehubDepositInitiatedEventResponse typedResponse = new BridgehubDepositInitiatedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.txDataHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.from = (String) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.to = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.l1Token = (String) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static BridgehubDepositInitiatedEventResponse getBridgehubDepositInitiatedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(BRIDGEHUBDEPOSITINITIATED_EVENT, log); + BridgehubDepositInitiatedEventResponse typedResponse = new BridgehubDepositInitiatedEventResponse(); + typedResponse.log = log; + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.txDataHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.from = (String) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.to = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.l1Token = (String) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + return typedResponse; + } + + public Flowable bridgehubDepositInitiatedEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getBridgehubDepositInitiatedEventFromLog(log)); + } + + public Flowable bridgehubDepositInitiatedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(BRIDGEHUBDEPOSITINITIATED_EVENT)); + return bridgehubDepositInitiatedEventFlowable(filter); + } + + public static List getClaimedFailedDepositSharedBridgeEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(CLAIMEDFAILEDDEPOSITSHAREDBRIDGE_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + ClaimedFailedDepositSharedBridgeEventResponse typedResponse = new ClaimedFailedDepositSharedBridgeEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.l1Token = (String) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static ClaimedFailedDepositSharedBridgeEventResponse getClaimedFailedDepositSharedBridgeEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(CLAIMEDFAILEDDEPOSITSHAREDBRIDGE_EVENT, log); + ClaimedFailedDepositSharedBridgeEventResponse typedResponse = new ClaimedFailedDepositSharedBridgeEventResponse(); + typedResponse.log = log; + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.l1Token = (String) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + + public Flowable claimedFailedDepositSharedBridgeEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getClaimedFailedDepositSharedBridgeEventFromLog(log)); + } + + public Flowable claimedFailedDepositSharedBridgeEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(CLAIMEDFAILEDDEPOSITSHAREDBRIDGE_EVENT)); + return claimedFailedDepositSharedBridgeEventFlowable(filter); + } + + public static List getLegacyDepositInitiatedEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(LEGACYDEPOSITINITIATED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + LegacyDepositInitiatedEventResponse typedResponse = new LegacyDepositInitiatedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.l2DepositTxHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.from = (String) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.to = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.l1Token = (String) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static LegacyDepositInitiatedEventResponse getLegacyDepositInitiatedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(LEGACYDEPOSITINITIATED_EVENT, log); + LegacyDepositInitiatedEventResponse typedResponse = new LegacyDepositInitiatedEventResponse(); + typedResponse.log = log; + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.l2DepositTxHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.from = (String) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.to = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.l1Token = (String) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + return typedResponse; + } + + public Flowable legacyDepositInitiatedEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getLegacyDepositInitiatedEventFromLog(log)); + } + + public Flowable legacyDepositInitiatedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(LEGACYDEPOSITINITIATED_EVENT)); + return legacyDepositInitiatedEventFlowable(filter); + } + + public static List getWithdrawalFinalizedSharedBridgeEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(WITHDRAWALFINALIZEDSHAREDBRIDGE_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + WithdrawalFinalizedSharedBridgeEventResponse typedResponse = new WithdrawalFinalizedSharedBridgeEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.l1Token = (String) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static WithdrawalFinalizedSharedBridgeEventResponse getWithdrawalFinalizedSharedBridgeEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(WITHDRAWALFINALIZEDSHAREDBRIDGE_EVENT, log); + WithdrawalFinalizedSharedBridgeEventResponse typedResponse = new WithdrawalFinalizedSharedBridgeEventResponse(); + typedResponse.log = log; + typedResponse.chainId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.l1Token = (String) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + + public Flowable withdrawalFinalizedSharedBridgeEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getWithdrawalFinalizedSharedBridgeEventFromLog(log)); + } + + public Flowable withdrawalFinalizedSharedBridgeEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(WITHDRAWALFINALIZEDSHAREDBRIDGE_EVENT)); + return withdrawalFinalizedSharedBridgeEventFlowable(filter); + } + + public RemoteFunctionCall bridgehub() { + final Function function = new Function(FUNC_BRIDGEHUB, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall bridgehubConfirmL2Transaction(BigInteger _chainId, byte[] _txDataHash, byte[] _txHash) { + final Function function = new Function( + FUNC_BRIDGEHUBCONFIRML2TRANSACTION, + Arrays.asList(new Uint256(_chainId), + new Bytes32(_txDataHash), + new Bytes32(_txHash)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall bridgehubDeposit(BigInteger _chainId, String _prevMsgSender, BigInteger _l2Value, byte[] _data, BigInteger weiValue) { + final Function function = new Function( + FUNC_BRIDGEHUBDEPOSIT, + Arrays.asList(new Uint256(_chainId), + new Address(160, _prevMsgSender), + new Uint256(_l2Value), + new DynamicBytes(_data)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public RemoteFunctionCall bridgehubDepositBaseToken(BigInteger _chainId, String _prevMsgSender, String _l1Token, BigInteger _amount, BigInteger weiValue) { + final Function function = new Function( + FUNC_BRIDGEHUBDEPOSITBASETOKEN, + Arrays.asList(new Uint256(_chainId), + new Address(160, _prevMsgSender), + new Address(160, _l1Token), + new Uint256(_amount)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public RemoteFunctionCall claimFailedDeposit(BigInteger _chainId, String _depositSender, String _l1Token, BigInteger _amount, byte[] _l2TxHash, BigInteger _l2BatchNumber, BigInteger _l2MessageIndex, BigInteger _l2TxNumberInBatch, List _merkleProof) { + final Function function = new Function( + FUNC_CLAIMFAILEDDEPOSIT, + Arrays.asList(new Uint256(_chainId), + new Address(160, _depositSender), + new Address(160, _l1Token), + new Uint256(_amount), + new Bytes32(_l2TxHash), + new Uint256(_l2BatchNumber), + new Uint256(_l2MessageIndex), + new org.web3j.abi.datatypes.generated.Uint16(_l2TxNumberInBatch), + new DynamicArray( + Bytes32.class, + org.web3j.abi.Utils.typeMap(_merkleProof, Bytes32.class))), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall claimFailedDepositLegacyErc20Bridge(String _depositSender, String _l1Token, BigInteger _amount, byte[] _l2TxHash, BigInteger _l2BatchNumber, BigInteger _l2MessageIndex, BigInteger _l2TxNumberInBatch, List _merkleProof) { + final Function function = new Function( + FUNC_CLAIMFAILEDDEPOSITLEGACYERC20BRIDGE, + Arrays.asList(new Address(160, _depositSender), + new Address(160, _l1Token), + new Uint256(_amount), + new Bytes32(_l2TxHash), + new Uint256(_l2BatchNumber), + new Uint256(_l2MessageIndex), + new org.web3j.abi.datatypes.generated.Uint16(_l2TxNumberInBatch), + new DynamicArray( + Bytes32.class, + org.web3j.abi.Utils.typeMap(_merkleProof, Bytes32.class))), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall depositHappened(BigInteger _chainId, byte[] _l2TxHash) { + final Function function = new Function(FUNC_DEPOSITHAPPENED, + Arrays.asList(new Uint256(_chainId), + new Bytes32(_l2TxHash)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, byte[].class); + } + + public RemoteFunctionCall depositLegacyErc20Bridge(String _msgSender, String _l2Receiver, String _l1Token, BigInteger _amount, BigInteger _l2TxGasLimit, BigInteger _l2TxGasPerPubdataByte, String _refundRecipient, BigInteger weiValue) { + final Function function = new Function( + FUNC_DEPOSITLEGACYERC20BRIDGE, + Arrays.asList(new Address(160, _msgSender), + new Address(160, _l2Receiver), + new Address(160, _l1Token), + new Uint256(_amount), + new Uint256(_l2TxGasLimit), + new Uint256(_l2TxGasPerPubdataByte), + new Address(160, _refundRecipient)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public RemoteFunctionCall finalizeWithdrawal(BigInteger _chainId, BigInteger _l2BatchNumber, BigInteger _l2MessageIndex, BigInteger _l2TxNumberInBatch, byte[] _message, List _merkleProof) { + final Function function = new Function( + FUNC_FINALIZEWITHDRAWAL, + Arrays.asList(new Uint256(_chainId), + new Uint256(_l2BatchNumber), + new Uint256(_l2MessageIndex), + new org.web3j.abi.datatypes.generated.Uint16(_l2TxNumberInBatch), + new DynamicBytes(_message), + new DynamicArray( + Bytes32.class, + org.web3j.abi.Utils.typeMap(_merkleProof, Bytes32.class))), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall finalizeWithdrawalLegacyErc20Bridge(BigInteger _l2BatchNumber, BigInteger _l2MessageIndex, BigInteger _l2TxNumberInBatch, byte[] _message, List _merkleProof) { + final Function function = new Function( + FUNC_FINALIZEWITHDRAWALLEGACYERC20BRIDGE, + Arrays.asList(new Uint256(_l2BatchNumber), + new Uint256(_l2MessageIndex), + new org.web3j.abi.datatypes.generated.Uint16(_l2TxNumberInBatch), + new DynamicBytes(_message), + new DynamicArray( + Bytes32.class, + org.web3j.abi.Utils.typeMap(_merkleProof, Bytes32.class))), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall isWithdrawalFinalized(BigInteger _chainId, BigInteger _l2BatchNumber, BigInteger _l2MessageIndex) { + final Function function = new Function(FUNC_ISWITHDRAWALFINALIZED, + Arrays.asList(new Uint256(_chainId), + new Uint256(_l2BatchNumber), + new Uint256(_l2MessageIndex)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall l1WethAddress() { + final Function function = new Function(FUNC_L1WETHADDRESS, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall l2BridgeAddress(BigInteger _chainId) { + final Function function = new Function(FUNC_L2BRIDGEADDRESS, + Arrays.asList(new Uint256(_chainId)), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall legacyBridge() { + final Function function = new Function(FUNC_LEGACYBRIDGE, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall receiveEth(BigInteger _chainId, BigInteger weiValue) { + final Function function = new Function( + FUNC_RECEIVEETH, + Arrays.asList(new Uint256(_chainId)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public RemoteFunctionCall setEraFirstPostUpgradeBatch(BigInteger _eraFirstPostUpgradeBatch) { + final Function function = new Function( + FUNC_SETERAFIRSTPOSTUPGRADEBATCH, + Arrays.asList(new Uint256(_eraFirstPostUpgradeBatch)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + @Deprecated + public static IL1SharedBridge load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + return new IL1SharedBridge(contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + @Deprecated + public static IL1SharedBridge load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + return new IL1SharedBridge(contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + public static IL1SharedBridge load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + return new IL1SharedBridge(contractAddress, web3j, credentials, contractGasProvider); + } + + public static IL1SharedBridge load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + return new IL1SharedBridge(contractAddress, web3j, transactionManager, contractGasProvider); + } + + public static class L2TransactionRequestTwoBridgesInner extends DynamicStruct { + public byte[] magicValue; + + public String l2Contract; + + public byte[] l2Calldata; + + public List factoryDeps; + + public byte[] txDataHash; + + public L2TransactionRequestTwoBridgesInner(byte[] magicValue, String l2Contract, byte[] l2Calldata, List factoryDeps, byte[] txDataHash) { + super(new Bytes32(magicValue), + new Address(160, l2Contract), + new DynamicBytes(l2Calldata), + new DynamicArray( + DynamicBytes.class, + org.web3j.abi.Utils.typeMap(factoryDeps, DynamicBytes.class)), + new Bytes32(txDataHash)); + this.magicValue = magicValue; + this.l2Contract = l2Contract; + this.l2Calldata = l2Calldata; + this.factoryDeps = factoryDeps; + this.txDataHash = txDataHash; + } + + public L2TransactionRequestTwoBridgesInner(Bytes32 magicValue, Address l2Contract, DynamicBytes l2Calldata, DynamicArray factoryDeps, Bytes32 txDataHash) { + super(magicValue, l2Contract, l2Calldata, factoryDeps, txDataHash); + this.magicValue = magicValue.getValue(); + this.l2Contract = l2Contract.getValue(); + this.l2Calldata = l2Calldata.getValue(); + this.factoryDeps = factoryDeps.getValue().stream().map(v -> v.getValue()).collect(Collectors.toList()); + this.txDataHash = txDataHash.getValue(); + } + } + + public static class BridgehubDepositBaseTokenInitiatedEventResponse extends BaseEventResponse { + public BigInteger chainId; + + public String from; + + public String l1Token; + + public BigInteger amount; + } + + public static class BridgehubDepositFinalizedEventResponse extends BaseEventResponse { + public BigInteger chainId; + + public byte[] txDataHash; + + public byte[] l2DepositTxHash; + } + + public static class BridgehubDepositInitiatedEventResponse extends BaseEventResponse { + public BigInteger chainId; + + public byte[] txDataHash; + + public String from; + + public String to; + + public String l1Token; + + public BigInteger amount; + } + + public static class ClaimedFailedDepositSharedBridgeEventResponse extends BaseEventResponse { + public BigInteger chainId; + + public String to; + + public String l1Token; + + public BigInteger amount; + } + + public static class LegacyDepositInitiatedEventResponse extends BaseEventResponse { + public BigInteger chainId; + + public byte[] l2DepositTxHash; + + public String from; + + public String to; + + public String l1Token; + + public BigInteger amount; + } + + public static class WithdrawalFinalizedSharedBridgeEventResponse extends BaseEventResponse { + public BigInteger chainId; + + public String to; + + public String l1Token; + + public BigInteger amount; + } +} diff --git a/src/main/java/io/zksync/wrappers/IL2Bridge.java b/src/main/java/io/zksync/wrappers/IL2Bridge.java index afefcf4..8055cd4 100644 --- a/src/main/java/io/zksync/wrappers/IL2Bridge.java +++ b/src/main/java/io/zksync/wrappers/IL2Bridge.java @@ -3,8 +3,6 @@ import java.math.BigInteger; import java.util.Arrays; import java.util.Collections; - -import org.web3j.abi.FunctionEncoder; import org.web3j.abi.TypeReference; import org.web3j.abi.datatypes.Address; import org.web3j.abi.datatypes.Function; @@ -24,7 +22,7 @@ * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the * codegen module to update. * - *

Generated with web3j version 1.4.2. + *

Generated with web3j version 1.5.0. */ @SuppressWarnings("rawtypes") public class IL2Bridge extends Contract { @@ -91,16 +89,6 @@ public RemoteFunctionCall l2TokenAddress(String _l1Token) { return executeRemoteCallSingleValueReturn(function, String.class); } - public String encodeWithdraw(String _l1Receiver, String _l2Token, BigInteger _amount) { - final Function function = new Function( - FUNC_WITHDRAW, - Arrays.asList(new Address(160, _l1Receiver), - new Address(160, _l2Token), - new org.web3j.abi.datatypes.generated.Uint256(_amount)), - Collections.>emptyList()); - return FunctionEncoder.encode(function); - } - public RemoteFunctionCall withdraw(String _l1Receiver, String _l2Token, BigInteger _amount) { final Function function = new Function( FUNC_WITHDRAW, diff --git a/src/main/java/io/zksync/wrappers/INonceHolder.java b/src/main/java/io/zksync/wrappers/INonceHolder.java index 26ea6c0..79fac73 100644 --- a/src/main/java/io/zksync/wrappers/INonceHolder.java +++ b/src/main/java/io/zksync/wrappers/INonceHolder.java @@ -1,7 +1,6 @@ package io.zksync.wrappers; import io.reactivex.Flowable; -import io.reactivex.functions.Function; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; @@ -12,6 +11,7 @@ import org.web3j.abi.datatypes.Address; import org.web3j.abi.datatypes.Bool; import org.web3j.abi.datatypes.Event; +import org.web3j.abi.datatypes.Function; import org.web3j.abi.datatypes.Type; import org.web3j.abi.datatypes.generated.Uint256; import org.web3j.crypto.Credentials; @@ -33,7 +33,7 @@ * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the * codegen module to update. * - *

Generated with web3j version 1.4.2. + *

Generated with web3j version 1.5.0. */ @SuppressWarnings("rawtypes") public class INonceHolder extends Contract { @@ -95,19 +95,18 @@ public static List getValueSetUnderNonceEvents( return responses; } + public static ValueSetUnderNonceEventResponse getValueSetUnderNonceEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(VALUESETUNDERNONCE_EVENT, log); + ValueSetUnderNonceEventResponse typedResponse = new ValueSetUnderNonceEventResponse(); + typedResponse.log = log; + typedResponse.accountAddress = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.key = (BigInteger) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + public Flowable valueSetUnderNonceEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public ValueSetUnderNonceEventResponse apply(Log log) { - EventValuesWithLog eventValues = extractEventParametersWithLog(VALUESETUNDERNONCE_EVENT, log); - ValueSetUnderNonceEventResponse typedResponse = new ValueSetUnderNonceEventResponse(); - typedResponse.log = log; - typedResponse.accountAddress = (String) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.key = (BigInteger) eventValues.getIndexedValues().get(1).getValue(); - typedResponse.value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> getValueSetUnderNonceEventFromLog(log)); } public Flowable valueSetUnderNonceEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -117,35 +116,35 @@ public Flowable valueSetUnderNonceEventFlowable } public RemoteFunctionCall getDeploymentNonce(String _address) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_GETDEPLOYMENTNONCE, + final Function function = new Function(FUNC_GETDEPLOYMENTNONCE, Arrays.asList(new Address(160, _address)), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, BigInteger.class); } public RemoteFunctionCall getMinNonce(String _address) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_GETMINNONCE, + final Function function = new Function(FUNC_GETMINNONCE, Arrays.asList(new Address(160, _address)), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, BigInteger.class); } public RemoteFunctionCall getRawNonce(String _address) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_GETRAWNONCE, + final Function function = new Function(FUNC_GETRAWNONCE, Arrays.asList(new Address(160, _address)), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, BigInteger.class); } public RemoteFunctionCall getValueUnderNonce(BigInteger _key) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_GETVALUEUNDERNONCE, + final Function function = new Function(FUNC_GETVALUEUNDERNONCE, Arrays.asList(new Uint256(_key)), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, BigInteger.class); } public RemoteFunctionCall increaseMinNonce(BigInteger _value) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( + final Function function = new Function( FUNC_INCREASEMINNONCE, Arrays.asList(new Uint256(_value)), Collections.>emptyList()); @@ -153,7 +152,7 @@ public RemoteFunctionCall increaseMinNonce(BigInteger _value } public RemoteFunctionCall incrementDeploymentNonce(String _address) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( + final Function function = new Function( FUNC_INCREMENTDEPLOYMENTNONCE, Arrays.asList(new Address(160, _address)), Collections.>emptyList()); @@ -161,7 +160,7 @@ public RemoteFunctionCall incrementDeploymentNonce(String _a } public RemoteFunctionCall incrementMinNonceIfEquals(BigInteger _expectedNonce) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( + final Function function = new Function( FUNC_INCREMENTMINNONCEIFEQUALS, Arrays.asList(new Uint256(_expectedNonce)), Collections.>emptyList()); @@ -169,7 +168,7 @@ public RemoteFunctionCall incrementMinNonceIfEquals(BigInteg } public RemoteFunctionCall isNonceUsed(String _address, BigInteger _nonce) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_ISNONCEUSED, + final Function function = new Function(FUNC_ISNONCEUSED, Arrays.asList(new Address(160, _address), new Uint256(_nonce)), Arrays.>asList(new TypeReference() {})); @@ -177,7 +176,7 @@ public RemoteFunctionCall isNonceUsed(String _address, BigInteger _nonc } public RemoteFunctionCall setValueUnderNonce(BigInteger _key, BigInteger _value) { - final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( + final Function function = new Function( FUNC_SETVALUEUNDERNONCE, Arrays.asList(new Uint256(_key), new Uint256(_value)), diff --git a/src/main/java/io/zksync/wrappers/IPaymasterFlow.java b/src/main/java/io/zksync/wrappers/IPaymasterFlow.java new file mode 100644 index 0000000..b83f378 --- /dev/null +++ b/src/main/java/io/zksync/wrappers/IPaymasterFlow.java @@ -0,0 +1,87 @@ +package io.zksync.wrappers; + +import java.math.BigInteger; +import java.util.Arrays; +import java.util.Collections; +import org.web3j.abi.TypeReference; +import org.web3j.abi.datatypes.Function; +import org.web3j.abi.datatypes.Type; +import org.web3j.crypto.Credentials; +import org.web3j.protocol.Web3j; +import org.web3j.protocol.core.RemoteFunctionCall; +import org.web3j.protocol.core.methods.response.TransactionReceipt; +import org.web3j.tx.Contract; +import org.web3j.tx.TransactionManager; +import org.web3j.tx.gas.ContractGasProvider; + +/** + *

Auto generated code. + *

Do not modify! + *

Please use the web3j command line tools, + * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the + * codegen module to update. + * + *

Generated with web3j version 1.5.0. + */ +@SuppressWarnings("rawtypes") +public class IPaymasterFlow extends Contract { + public static final String BINARY = "Bin file was not provided"; + + public static final String FUNC_APPROVALBASED = "approvalBased"; + + public static final String FUNC_GENERAL = "general"; + + @Deprecated + protected IPaymasterFlow(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + protected IPaymasterFlow(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, credentials, contractGasProvider); + } + + @Deprecated + protected IPaymasterFlow(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + protected IPaymasterFlow(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); + } + + public RemoteFunctionCall approvalBased(String _token, BigInteger _minAllowance, byte[] _innerInput) { + final Function function = new Function( + FUNC_APPROVALBASED, + Arrays.asList(new org.web3j.abi.datatypes.Address(160, _token), + new org.web3j.abi.datatypes.generated.Uint256(_minAllowance), + new org.web3j.abi.datatypes.DynamicBytes(_innerInput)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall general(byte[] input) { + final Function function = new Function( + FUNC_GENERAL, + Arrays.asList(new org.web3j.abi.datatypes.DynamicBytes(input)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + @Deprecated + public static IPaymasterFlow load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + return new IPaymasterFlow(contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + @Deprecated + public static IPaymasterFlow load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + return new IPaymasterFlow(contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + public static IPaymasterFlow load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + return new IPaymasterFlow(contractAddress, web3j, credentials, contractGasProvider); + } + + public static IPaymasterFlow load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + return new IPaymasterFlow(contractAddress, web3j, transactionManager, contractGasProvider); + } +} diff --git a/src/main/java/io/zksync/wrappers/ITestnetERC20Token.java b/src/main/java/io/zksync/wrappers/ITestnetERC20Token.java new file mode 100644 index 0000000..580ca5a --- /dev/null +++ b/src/main/java/io/zksync/wrappers/ITestnetERC20Token.java @@ -0,0 +1,86 @@ +package io.zksync.wrappers; + +import java.math.BigInteger; +import java.util.Arrays; +import java.util.Collections; +import org.web3j.abi.TypeReference; +import org.web3j.abi.datatypes.Function; +import org.web3j.abi.datatypes.Type; +import org.web3j.crypto.Credentials; +import org.web3j.protocol.Web3j; +import org.web3j.protocol.core.RemoteFunctionCall; +import org.web3j.protocol.core.methods.response.TransactionReceipt; +import org.web3j.tx.Contract; +import org.web3j.tx.TransactionManager; +import org.web3j.tx.gas.ContractGasProvider; + +/** + *

Auto generated code. + *

Do not modify! + *

Please use the web3j command line tools, + * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the + * codegen module to update. + * + *

Generated with web3j version 1.5.0. + */ +@SuppressWarnings("rawtypes") +public class ITestnetERC20Token extends Contract { + public static final String BINARY = "Bin file was not provided"; + + public static final String FUNC_DECIMALS = "decimals"; + + public static final String FUNC_MINT = "mint"; + + @Deprecated + protected ITestnetERC20Token(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + protected ITestnetERC20Token(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, credentials, contractGasProvider); + } + + @Deprecated + protected ITestnetERC20Token(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + protected ITestnetERC20Token(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); + } + + public RemoteFunctionCall decimals() { + final Function function = new Function( + FUNC_DECIMALS, + Arrays.asList(), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall mint(String _to, BigInteger _amount) { + final Function function = new Function( + FUNC_MINT, + Arrays.asList(new org.web3j.abi.datatypes.Address(160, _to), + new org.web3j.abi.datatypes.generated.Uint256(_amount)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + @Deprecated + public static ITestnetERC20Token load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + return new ITestnetERC20Token(contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + @Deprecated + public static ITestnetERC20Token load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + return new ITestnetERC20Token(contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + public static ITestnetERC20Token load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + return new ITestnetERC20Token(contractAddress, web3j, credentials, contractGasProvider); + } + + public static ITestnetERC20Token load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + return new ITestnetERC20Token(contractAddress, web3j, transactionManager, contractGasProvider); + } +} diff --git a/src/main/java/io/zksync/wrappers/IZkSync.java b/src/main/java/io/zksync/wrappers/IZkSync.java index e6df065..4c8fcd8 100644 --- a/src/main/java/io/zksync/wrappers/IZkSync.java +++ b/src/main/java/io/zksync/wrappers/IZkSync.java @@ -9,7 +9,6 @@ import java.util.concurrent.Callable; import java.util.stream.Collectors; import org.web3j.abi.EventEncoder; -import org.web3j.abi.FunctionEncoder; import org.web3j.abi.TypeReference; import org.web3j.abi.datatypes.Address; import org.web3j.abi.datatypes.Array; @@ -637,8 +636,8 @@ public static List getNewPriorityRequestEvents( public static NewPriorityRequestEventResponse getNewPriorityRequestEventFromLog(Log log) { EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWPRIORITYREQUEST_EVENT, log); NewPriorityRequestEventResponse typedResponse = new NewPriorityRequestEventResponse(); -// typedResponse.log = log; -// typedResponse.txId = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.log = log; + typedResponse.txId = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); typedResponse.txHash = (byte[]) eventValues.getNonIndexedValues().get(1).getValue(); typedResponse.expirationTimestamp = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); typedResponse.transaction = (L2CanonicalTransaction) eventValues.getNonIndexedValues().get(3); @@ -1089,22 +1088,6 @@ public RemoteFunctionCall proveL2MessageInclusion(BigInteger _l2BatchNu return executeRemoteCallSingleValueReturn(function, Boolean.class); } - public String encodeRequestL2Transaction(String _contractL2, BigInteger _l2Value, byte[] _calldata, BigInteger _l2GasLimit, BigInteger _l2GasPerPubdataByteLimit, List _factoryDeps, String _refundRecipient, BigInteger weiValue) { - final Function function = new Function( - FUNC_REQUESTL2TRANSACTION, - Arrays.asList(new Address(160, _contractL2), - new Uint256(_l2Value), - new DynamicBytes(_calldata), - new Uint256(_l2GasLimit), - new Uint256(_l2GasPerPubdataByteLimit), - new DynamicArray( - DynamicBytes.class, - org.web3j.abi.Utils.typeMap(_factoryDeps, DynamicBytes.class)), - new Address(160, _refundRecipient)), - Collections.>emptyList()); - - return FunctionEncoder.encode(function); - } public RemoteFunctionCall requestL2Transaction(String _contractL2, BigInteger _l2Value, byte[] _calldata, BigInteger _l2GasLimit, BigInteger _l2GasPerPubdataByteLimit, List _factoryDeps, String _refundRecipient, BigInteger weiValue) { final Function function = new Function( FUNC_REQUESTL2TRANSACTION, diff --git a/src/main/java/io/zksync/wrappers/IZkSyncStateTransition.java b/src/main/java/io/zksync/wrappers/IZkSyncStateTransition.java new file mode 100644 index 0000000..2ea270c --- /dev/null +++ b/src/main/java/io/zksync/wrappers/IZkSyncStateTransition.java @@ -0,0 +1,2090 @@ +package io.zksync.wrappers; + +import io.reactivex.Flowable; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.stream.Collectors; +import org.web3j.abi.EventEncoder; +import org.web3j.abi.TypeReference; +import org.web3j.abi.datatypes.Address; +import org.web3j.abi.datatypes.Array; +import org.web3j.abi.datatypes.Bool; +import org.web3j.abi.datatypes.DynamicArray; +import org.web3j.abi.datatypes.DynamicBytes; +import org.web3j.abi.datatypes.DynamicStruct; +import org.web3j.abi.datatypes.Event; +import org.web3j.abi.datatypes.Function; +import org.web3j.abi.datatypes.StaticStruct; +import org.web3j.abi.datatypes.Type; +import org.web3j.abi.datatypes.Utf8String; +import org.web3j.abi.datatypes.generated.Bytes32; +import org.web3j.abi.datatypes.generated.Bytes4; +import org.web3j.abi.datatypes.generated.StaticArray4; +import org.web3j.abi.datatypes.generated.Uint128; +import org.web3j.abi.datatypes.generated.Uint16; +import org.web3j.abi.datatypes.generated.Uint192; +import org.web3j.abi.datatypes.generated.Uint256; +import org.web3j.abi.datatypes.generated.Uint32; +import org.web3j.abi.datatypes.generated.Uint64; +import org.web3j.abi.datatypes.generated.Uint8; +import org.web3j.abi.datatypes.reflection.Parameterized; +import org.web3j.crypto.Credentials; +import org.web3j.protocol.Web3j; +import org.web3j.protocol.core.DefaultBlockParameter; +import org.web3j.protocol.core.RemoteFunctionCall; +import org.web3j.protocol.core.methods.request.EthFilter; +import org.web3j.protocol.core.methods.response.BaseEventResponse; +import org.web3j.protocol.core.methods.response.Log; +import org.web3j.protocol.core.methods.response.TransactionReceipt; +import org.web3j.tx.Contract; +import org.web3j.tx.TransactionManager; +import org.web3j.tx.gas.ContractGasProvider; + +/** + *

Auto generated code. + *

Do not modify! + *

Please use the web3j command line tools, + * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the + * codegen module to update. + * + *

Generated with web3j version 1.5.0. + */ +@SuppressWarnings("rawtypes") +public class IZkSyncStateTransition extends Contract { + public static final String BINARY = "Bin file was not provided"; + + public static final String FUNC_ACCEPTADMIN = "acceptAdmin"; + + public static final String FUNC_BASETOKENGASPRICEMULTIPLIERDENOMINATOR = "baseTokenGasPriceMultiplierDenominator"; + + public static final String FUNC_BASETOKENGASPRICEMULTIPLIERNOMINATOR = "baseTokenGasPriceMultiplierNominator"; + + public static final String FUNC_BRIDGEHUBREQUESTL2TRANSACTION = "bridgehubRequestL2Transaction"; + + public static final String FUNC_CHANGEFEEPARAMS = "changeFeeParams"; + + public static final String FUNC_COMMITBATCHES = "commitBatches"; + + public static final String FUNC_COMMITBATCHESSHAREDBRIDGE = "commitBatchesSharedBridge"; + + public static final String FUNC_EXECUTEBATCHES = "executeBatches"; + + public static final String FUNC_EXECUTEBATCHESSHAREDBRIDGE = "executeBatchesSharedBridge"; + + public static final String FUNC_EXECUTEUPGRADE = "executeUpgrade"; + + public static final String FUNC_FACETADDRESS = "facetAddress"; + + public static final String FUNC_FACETADDRESSES = "facetAddresses"; + + public static final String FUNC_FACETFUNCTIONSELECTORS = "facetFunctionSelectors"; + + public static final String FUNC_FACETS = "facets"; + + public static final String FUNC_FINALIZEETHWITHDRAWAL = "finalizeEthWithdrawal"; + + public static final String FUNC_FREEZEDIAMOND = "freezeDiamond"; + + public static final String FUNC_GETADMIN = "getAdmin"; + + public static final String FUNC_GETBASETOKEN = "getBaseToken"; + + public static final String FUNC_GETBASETOKENBRIDGE = "getBaseTokenBridge"; + + public static final String FUNC_GETBRIDGEHUB = "getBridgehub"; + + public static final String FUNC_GETFIRSTUNPROCESSEDPRIORITYTX = "getFirstUnprocessedPriorityTx"; + + public static final String FUNC_GETL2BOOTLOADERBYTECODEHASH = "getL2BootloaderBytecodeHash"; + + public static final String FUNC_GETL2DEFAULTACCOUNTBYTECODEHASH = "getL2DefaultAccountBytecodeHash"; + + public static final String FUNC_GETL2SYSTEMCONTRACTSUPGRADEBATCHNUMBER = "getL2SystemContractsUpgradeBatchNumber"; + + public static final String FUNC_GETL2SYSTEMCONTRACTSUPGRADETXHASH = "getL2SystemContractsUpgradeTxHash"; + + public static final String FUNC_GETNAME = "getName"; + + public static final String FUNC_GETPENDINGADMIN = "getPendingAdmin"; + + public static final String FUNC_GETPRIORITYQUEUESIZE = "getPriorityQueueSize"; + + public static final String FUNC_GETPRIORITYTXMAXGASLIMIT = "getPriorityTxMaxGasLimit"; + + public static final String FUNC_GETPROTOCOLVERSION = "getProtocolVersion"; + + public static final String FUNC_GETPUBDATAPRICINGMODE = "getPubdataPricingMode"; + + public static final String FUNC_GETSTATETRANSITIONMANAGER = "getStateTransitionManager"; + + public static final String FUNC_GETTOTALBATCHESCOMMITTED = "getTotalBatchesCommitted"; + + public static final String FUNC_GETTOTALBATCHESEXECUTED = "getTotalBatchesExecuted"; + + public static final String FUNC_GETTOTALBATCHESVERIFIED = "getTotalBatchesVerified"; + + public static final String FUNC_GETTOTALPRIORITYTXS = "getTotalPriorityTxs"; + + public static final String FUNC_GETVERIFIER = "getVerifier"; + + public static final String FUNC_GETVERIFIERPARAMS = "getVerifierParams"; + + public static final String FUNC_ISDIAMONDSTORAGEFROZEN = "isDiamondStorageFrozen"; + + public static final String FUNC_ISETHWITHDRAWALFINALIZED = "isEthWithdrawalFinalized"; + + public static final String FUNC_ISFACETFREEZABLE = "isFacetFreezable"; + + public static final String FUNC_ISFUNCTIONFREEZABLE = "isFunctionFreezable"; + + public static final String FUNC_ISVALIDATOR = "isValidator"; + + public static final String FUNC_L2LOGSROOTHASH = "l2LogsRootHash"; + + public static final String FUNC_L2TRANSACTIONBASECOST = "l2TransactionBaseCost"; + + public static final String FUNC_PRIORITYQUEUEFRONTOPERATION = "priorityQueueFrontOperation"; + + public static final String FUNC_PROVEBATCHES = "proveBatches"; + + public static final String FUNC_PROVEBATCHESSHAREDBRIDGE = "proveBatchesSharedBridge"; + + public static final String FUNC_PROVEL1TOL2TRANSACTIONSTATUS = "proveL1ToL2TransactionStatus"; + + public static final String FUNC_PROVEL2LOGINCLUSION = "proveL2LogInclusion"; + + public static final String FUNC_PROVEL2MESSAGEINCLUSION = "proveL2MessageInclusion"; + + public static final String FUNC_REQUESTL2TRANSACTION = "requestL2Transaction"; + + public static final String FUNC_REVERTBATCHES = "revertBatches"; + + public static final String FUNC_REVERTBATCHESSHAREDBRIDGE = "revertBatchesSharedBridge"; + + public static final String FUNC_SETPENDINGADMIN = "setPendingAdmin"; + + public static final String FUNC_SETPORTERAVAILABILITY = "setPorterAvailability"; + + public static final String FUNC_SETPRIORITYTXMAXGASLIMIT = "setPriorityTxMaxGasLimit"; + + public static final String FUNC_SETTOKENMULTIPLIER = "setTokenMultiplier"; + + public static final String FUNC_SETTRANSACTIONFILTERER = "setTransactionFilterer"; + + public static final String FUNC_SETVALIDATOR = "setValidator"; + + public static final String FUNC_SETVALIDIUMMODE = "setValidiumMode"; + + public static final String FUNC_STOREDBATCHHASH = "storedBatchHash"; + + public static final String FUNC_TRANSFERETHTOSHAREDBRIDGE = "transferEthToSharedBridge"; + + public static final String FUNC_UNFREEZEDIAMOND = "unfreezeDiamond"; + + public static final String FUNC_UPGRADECHAINFROMVERSION = "upgradeChainFromVersion"; + + public static final Event BLOCKCOMMIT_EVENT = new Event("BlockCommit", + Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {}, new TypeReference(true) {})); + ; + + public static final Event BLOCKEXECUTION_EVENT = new Event("BlockExecution", + Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {}, new TypeReference(true) {})); + ; + + public static final Event BLOCKSREVERT_EVENT = new Event("BlocksRevert", + Arrays.>asList(new TypeReference() {}, new TypeReference() {}, new TypeReference() {})); + ; + + public static final Event BLOCKSVERIFICATION_EVENT = new Event("BlocksVerification", + Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {})); + ; + + public static final Event ETHWITHDRAWALFINALIZED_EVENT = new Event("EthWithdrawalFinalized", + Arrays.>asList(new TypeReference

(true) {}, new TypeReference() {})); + ; + + public static final Event EXECUTEUPGRADE_EVENT = new Event("ExecuteUpgrade", + Arrays.>asList(new TypeReference() {})); + ; + + public static final Event FREEZE_EVENT = new Event("Freeze", + Arrays.>asList()); + ; + + public static final Event ISPORTERAVAILABLESTATUSUPDATE_EVENT = new Event("IsPorterAvailableStatusUpdate", + Arrays.>asList(new TypeReference() {})); + ; + + public static final Event NEWADMIN_EVENT = new Event("NewAdmin", + Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {})); + ; + + public static final Event NEWBASETOKENMULTIPLIER_EVENT = new Event("NewBaseTokenMultiplier", + Arrays.>asList(new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {})); + ; + + public static final Event NEWFEEPARAMS_EVENT = new Event("NewFeeParams", + Arrays.>asList(new TypeReference() {}, new TypeReference() {})); + ; + + public static final Event NEWPENDINGADMIN_EVENT = new Event("NewPendingAdmin", + Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {})); + ; + + public static final Event NEWPRIORITYREQUEST_EVENT = new Event("NewPriorityRequest", + Arrays.>asList(new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference>() {})); + ; + + public static final Event NEWPRIORITYTXMAXGASLIMIT_EVENT = new Event("NewPriorityTxMaxGasLimit", + Arrays.>asList(new TypeReference() {}, new TypeReference() {})); + ; + + public static final Event NEWTRANSACTIONFILTERER_EVENT = new Event("NewTransactionFilterer", + Arrays.>asList(new TypeReference
() {}, new TypeReference
() {})); + ; + + public static final Event PROPOSETRANSPARENTUPGRADE_EVENT = new Event("ProposeTransparentUpgrade", + Arrays.>asList(new TypeReference() {}, new TypeReference(true) {}, new TypeReference() {})); + ; + + public static final Event UNFREEZE_EVENT = new Event("Unfreeze", + Arrays.>asList()); + ; + + public static final Event VALIDATORSTATUSUPDATE_EVENT = new Event("ValidatorStatusUpdate", + Arrays.>asList(new TypeReference
(true) {}, new TypeReference() {})); + ; + + public static final Event VALIDIUMMODESTATUSUPDATE_EVENT = new Event("ValidiumModeStatusUpdate", + Arrays.>asList(new TypeReference() {})); + ; + + @Deprecated + protected IZkSyncStateTransition(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + protected IZkSyncStateTransition(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, credentials, contractGasProvider); + } + + @Deprecated + protected IZkSyncStateTransition(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + protected IZkSyncStateTransition(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); + } + + public static List getBlockCommitEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(BLOCKCOMMIT_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + BlockCommitEventResponse typedResponse = new BlockCommitEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.batchNumber = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.batchHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.commitment = (byte[]) eventValues.getIndexedValues().get(2).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static BlockCommitEventResponse getBlockCommitEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(BLOCKCOMMIT_EVENT, log); + BlockCommitEventResponse typedResponse = new BlockCommitEventResponse(); + typedResponse.log = log; + typedResponse.batchNumber = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.batchHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.commitment = (byte[]) eventValues.getIndexedValues().get(2).getValue(); + return typedResponse; + } + + public Flowable blockCommitEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getBlockCommitEventFromLog(log)); + } + + public Flowable blockCommitEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(BLOCKCOMMIT_EVENT)); + return blockCommitEventFlowable(filter); + } + + public static List getBlockExecutionEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(BLOCKEXECUTION_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + BlockExecutionEventResponse typedResponse = new BlockExecutionEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.batchNumber = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.batchHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.commitment = (byte[]) eventValues.getIndexedValues().get(2).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static BlockExecutionEventResponse getBlockExecutionEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(BLOCKEXECUTION_EVENT, log); + BlockExecutionEventResponse typedResponse = new BlockExecutionEventResponse(); + typedResponse.log = log; + typedResponse.batchNumber = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.batchHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.commitment = (byte[]) eventValues.getIndexedValues().get(2).getValue(); + return typedResponse; + } + + public Flowable blockExecutionEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getBlockExecutionEventFromLog(log)); + } + + public Flowable blockExecutionEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(BLOCKEXECUTION_EVENT)); + return blockExecutionEventFlowable(filter); + } + + public static List getBlocksRevertEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(BLOCKSREVERT_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + BlocksRevertEventResponse typedResponse = new BlocksRevertEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.totalBatchesCommitted = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.totalBatchesVerified = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.totalBatchesExecuted = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static BlocksRevertEventResponse getBlocksRevertEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(BLOCKSREVERT_EVENT, log); + BlocksRevertEventResponse typedResponse = new BlocksRevertEventResponse(); + typedResponse.log = log; + typedResponse.totalBatchesCommitted = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.totalBatchesVerified = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.totalBatchesExecuted = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + return typedResponse; + } + + public Flowable blocksRevertEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getBlocksRevertEventFromLog(log)); + } + + public Flowable blocksRevertEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(BLOCKSREVERT_EVENT)); + return blocksRevertEventFlowable(filter); + } + + public static List getBlocksVerificationEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(BLOCKSVERIFICATION_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + BlocksVerificationEventResponse typedResponse = new BlocksVerificationEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.previousLastVerifiedBatch = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.currentLastVerifiedBatch = (BigInteger) eventValues.getIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static BlocksVerificationEventResponse getBlocksVerificationEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(BLOCKSVERIFICATION_EVENT, log); + BlocksVerificationEventResponse typedResponse = new BlocksVerificationEventResponse(); + typedResponse.log = log; + typedResponse.previousLastVerifiedBatch = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.currentLastVerifiedBatch = (BigInteger) eventValues.getIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable blocksVerificationEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getBlocksVerificationEventFromLog(log)); + } + + public Flowable blocksVerificationEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(BLOCKSVERIFICATION_EVENT)); + return blocksVerificationEventFlowable(filter); + } + + public static List getEthWithdrawalFinalizedEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(ETHWITHDRAWALFINALIZED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + EthWithdrawalFinalizedEventResponse typedResponse = new EthWithdrawalFinalizedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.to = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static EthWithdrawalFinalizedEventResponse getEthWithdrawalFinalizedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(ETHWITHDRAWALFINALIZED_EVENT, log); + EthWithdrawalFinalizedEventResponse typedResponse = new EthWithdrawalFinalizedEventResponse(); + typedResponse.log = log; + typedResponse.to = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + + public Flowable ethWithdrawalFinalizedEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getEthWithdrawalFinalizedEventFromLog(log)); + } + + public Flowable ethWithdrawalFinalizedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(ETHWITHDRAWALFINALIZED_EVENT)); + return ethWithdrawalFinalizedEventFlowable(filter); + } + + public static List getExecuteUpgradeEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(EXECUTEUPGRADE_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + ExecuteUpgradeEventResponse typedResponse = new ExecuteUpgradeEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.diamondCut = (DiamondCutData) eventValues.getNonIndexedValues().get(0); + responses.add(typedResponse); + } + return responses; + } + + public static ExecuteUpgradeEventResponse getExecuteUpgradeEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(EXECUTEUPGRADE_EVENT, log); + ExecuteUpgradeEventResponse typedResponse = new ExecuteUpgradeEventResponse(); + typedResponse.log = log; + typedResponse.diamondCut = (DiamondCutData) eventValues.getNonIndexedValues().get(0); + return typedResponse; + } + + public Flowable executeUpgradeEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getExecuteUpgradeEventFromLog(log)); + } + + public Flowable executeUpgradeEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(EXECUTEUPGRADE_EVENT)); + return executeUpgradeEventFlowable(filter); + } + + public static List getFreezeEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(FREEZE_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + FreezeEventResponse typedResponse = new FreezeEventResponse(); + typedResponse.log = eventValues.getLog(); + responses.add(typedResponse); + } + return responses; + } + + public static FreezeEventResponse getFreezeEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(FREEZE_EVENT, log); + FreezeEventResponse typedResponse = new FreezeEventResponse(); + typedResponse.log = log; + return typedResponse; + } + + public Flowable freezeEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getFreezeEventFromLog(log)); + } + + public Flowable freezeEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(FREEZE_EVENT)); + return freezeEventFlowable(filter); + } + + public static List getIsPorterAvailableStatusUpdateEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(ISPORTERAVAILABLESTATUSUPDATE_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + IsPorterAvailableStatusUpdateEventResponse typedResponse = new IsPorterAvailableStatusUpdateEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.isPorterAvailable = (Boolean) eventValues.getNonIndexedValues().get(0).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static IsPorterAvailableStatusUpdateEventResponse getIsPorterAvailableStatusUpdateEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(ISPORTERAVAILABLESTATUSUPDATE_EVENT, log); + IsPorterAvailableStatusUpdateEventResponse typedResponse = new IsPorterAvailableStatusUpdateEventResponse(); + typedResponse.log = log; + typedResponse.isPorterAvailable = (Boolean) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + + public Flowable isPorterAvailableStatusUpdateEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getIsPorterAvailableStatusUpdateEventFromLog(log)); + } + + public Flowable isPorterAvailableStatusUpdateEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(ISPORTERAVAILABLESTATUSUPDATE_EVENT)); + return isPorterAvailableStatusUpdateEventFlowable(filter); + } + + public static List getNewAdminEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(NEWADMIN_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + NewAdminEventResponse typedResponse = new NewAdminEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.oldAdmin = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.newAdmin = (String) eventValues.getIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static NewAdminEventResponse getNewAdminEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWADMIN_EVENT, log); + NewAdminEventResponse typedResponse = new NewAdminEventResponse(); + typedResponse.log = log; + typedResponse.oldAdmin = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.newAdmin = (String) eventValues.getIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable newAdminEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getNewAdminEventFromLog(log)); + } + + public Flowable newAdminEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(NEWADMIN_EVENT)); + return newAdminEventFlowable(filter); + } + + public static List getNewBaseTokenMultiplierEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(NEWBASETOKENMULTIPLIER_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + NewBaseTokenMultiplierEventResponse typedResponse = new NewBaseTokenMultiplierEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.oldNominator = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.oldDenominator = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.newNominator = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + typedResponse.newDenominator = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static NewBaseTokenMultiplierEventResponse getNewBaseTokenMultiplierEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWBASETOKENMULTIPLIER_EVENT, log); + NewBaseTokenMultiplierEventResponse typedResponse = new NewBaseTokenMultiplierEventResponse(); + typedResponse.log = log; + typedResponse.oldNominator = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.oldDenominator = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.newNominator = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + typedResponse.newDenominator = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue(); + return typedResponse; + } + + public Flowable newBaseTokenMultiplierEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getNewBaseTokenMultiplierEventFromLog(log)); + } + + public Flowable newBaseTokenMultiplierEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(NEWBASETOKENMULTIPLIER_EVENT)); + return newBaseTokenMultiplierEventFlowable(filter); + } + + public static List getNewFeeParamsEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(NEWFEEPARAMS_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + NewFeeParamsEventResponse typedResponse = new NewFeeParamsEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.oldFeeParams = (FeeParams) eventValues.getNonIndexedValues().get(0); + typedResponse.newFeeParams = (FeeParams) eventValues.getNonIndexedValues().get(1); + responses.add(typedResponse); + } + return responses; + } + + public static NewFeeParamsEventResponse getNewFeeParamsEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWFEEPARAMS_EVENT, log); + NewFeeParamsEventResponse typedResponse = new NewFeeParamsEventResponse(); + typedResponse.log = log; + typedResponse.oldFeeParams = (FeeParams) eventValues.getNonIndexedValues().get(0); + typedResponse.newFeeParams = (FeeParams) eventValues.getNonIndexedValues().get(1); + return typedResponse; + } + + public Flowable newFeeParamsEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getNewFeeParamsEventFromLog(log)); + } + + public Flowable newFeeParamsEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(NEWFEEPARAMS_EVENT)); + return newFeeParamsEventFlowable(filter); + } + + public static List getNewPendingAdminEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(NEWPENDINGADMIN_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + NewPendingAdminEventResponse typedResponse = new NewPendingAdminEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.oldPendingAdmin = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.newPendingAdmin = (String) eventValues.getIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static NewPendingAdminEventResponse getNewPendingAdminEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWPENDINGADMIN_EVENT, log); + NewPendingAdminEventResponse typedResponse = new NewPendingAdminEventResponse(); + typedResponse.log = log; + typedResponse.oldPendingAdmin = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.newPendingAdmin = (String) eventValues.getIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable newPendingAdminEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getNewPendingAdminEventFromLog(log)); + } + + public Flowable newPendingAdminEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(NEWPENDINGADMIN_EVENT)); + return newPendingAdminEventFlowable(filter); + } + + public static List getNewPriorityRequestEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(NEWPRIORITYREQUEST_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + NewPriorityRequestEventResponse typedResponse = new NewPriorityRequestEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.txId = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.txHash = (byte[]) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.expirationTimestamp = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + typedResponse.transaction = (L2CanonicalTransaction) eventValues.getNonIndexedValues().get(3); + typedResponse.factoryDeps = (List) ((Array) eventValues.getNonIndexedValues().get(4)).getNativeValueCopy(); + responses.add(typedResponse); + } + return responses; + } + + public static NewPriorityRequestEventResponse getNewPriorityRequestEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWPRIORITYREQUEST_EVENT, log); + NewPriorityRequestEventResponse typedResponse = new NewPriorityRequestEventResponse(); + typedResponse.log = log; + typedResponse.txId = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.txHash = (byte[]) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.expirationTimestamp = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + typedResponse.transaction = (L2CanonicalTransaction) eventValues.getNonIndexedValues().get(3); + typedResponse.factoryDeps = (List) ((Array) eventValues.getNonIndexedValues().get(4)).getNativeValueCopy(); + return typedResponse; + } + + public Flowable newPriorityRequestEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getNewPriorityRequestEventFromLog(log)); + } + + public Flowable newPriorityRequestEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(NEWPRIORITYREQUEST_EVENT)); + return newPriorityRequestEventFlowable(filter); + } + + public static List getNewPriorityTxMaxGasLimitEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(NEWPRIORITYTXMAXGASLIMIT_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + NewPriorityTxMaxGasLimitEventResponse typedResponse = new NewPriorityTxMaxGasLimitEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.oldPriorityTxMaxGasLimit = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.newPriorityTxMaxGasLimit = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static NewPriorityTxMaxGasLimitEventResponse getNewPriorityTxMaxGasLimitEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWPRIORITYTXMAXGASLIMIT_EVENT, log); + NewPriorityTxMaxGasLimitEventResponse typedResponse = new NewPriorityTxMaxGasLimitEventResponse(); + typedResponse.log = log; + typedResponse.oldPriorityTxMaxGasLimit = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.newPriorityTxMaxGasLimit = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable newPriorityTxMaxGasLimitEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getNewPriorityTxMaxGasLimitEventFromLog(log)); + } + + public Flowable newPriorityTxMaxGasLimitEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(NEWPRIORITYTXMAXGASLIMIT_EVENT)); + return newPriorityTxMaxGasLimitEventFlowable(filter); + } + + public static List getNewTransactionFiltererEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(NEWTRANSACTIONFILTERER_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + NewTransactionFiltererEventResponse typedResponse = new NewTransactionFiltererEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.oldTransactionFilterer = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.newTransactionFilterer = (String) eventValues.getNonIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static NewTransactionFiltererEventResponse getNewTransactionFiltererEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWTRANSACTIONFILTERER_EVENT, log); + NewTransactionFiltererEventResponse typedResponse = new NewTransactionFiltererEventResponse(); + typedResponse.log = log; + typedResponse.oldTransactionFilterer = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.newTransactionFilterer = (String) eventValues.getNonIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable newTransactionFiltererEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getNewTransactionFiltererEventFromLog(log)); + } + + public Flowable newTransactionFiltererEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(NEWTRANSACTIONFILTERER_EVENT)); + return newTransactionFiltererEventFlowable(filter); + } + + public static List getProposeTransparentUpgradeEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(PROPOSETRANSPARENTUPGRADE_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + ProposeTransparentUpgradeEventResponse typedResponse = new ProposeTransparentUpgradeEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.proposalId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.diamondCut = (DiamondCutData) eventValues.getNonIndexedValues().get(0); + typedResponse.proposalSalt = (byte[]) eventValues.getNonIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static ProposeTransparentUpgradeEventResponse getProposeTransparentUpgradeEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(PROPOSETRANSPARENTUPGRADE_EVENT, log); + ProposeTransparentUpgradeEventResponse typedResponse = new ProposeTransparentUpgradeEventResponse(); + typedResponse.log = log; + typedResponse.proposalId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.diamondCut = (DiamondCutData) eventValues.getNonIndexedValues().get(0); + typedResponse.proposalSalt = (byte[]) eventValues.getNonIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable proposeTransparentUpgradeEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getProposeTransparentUpgradeEventFromLog(log)); + } + + public Flowable proposeTransparentUpgradeEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(PROPOSETRANSPARENTUPGRADE_EVENT)); + return proposeTransparentUpgradeEventFlowable(filter); + } + + public static List getUnfreezeEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(UNFREEZE_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + UnfreezeEventResponse typedResponse = new UnfreezeEventResponse(); + typedResponse.log = eventValues.getLog(); + responses.add(typedResponse); + } + return responses; + } + + public static UnfreezeEventResponse getUnfreezeEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(UNFREEZE_EVENT, log); + UnfreezeEventResponse typedResponse = new UnfreezeEventResponse(); + typedResponse.log = log; + return typedResponse; + } + + public Flowable unfreezeEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getUnfreezeEventFromLog(log)); + } + + public Flowable unfreezeEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(UNFREEZE_EVENT)); + return unfreezeEventFlowable(filter); + } + + public static List getValidatorStatusUpdateEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(VALIDATORSTATUSUPDATE_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + ValidatorStatusUpdateEventResponse typedResponse = new ValidatorStatusUpdateEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.validatorAddress = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.isActive = (Boolean) eventValues.getNonIndexedValues().get(0).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static ValidatorStatusUpdateEventResponse getValidatorStatusUpdateEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(VALIDATORSTATUSUPDATE_EVENT, log); + ValidatorStatusUpdateEventResponse typedResponse = new ValidatorStatusUpdateEventResponse(); + typedResponse.log = log; + typedResponse.validatorAddress = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.isActive = (Boolean) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + + public Flowable validatorStatusUpdateEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getValidatorStatusUpdateEventFromLog(log)); + } + + public Flowable validatorStatusUpdateEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(VALIDATORSTATUSUPDATE_EVENT)); + return validatorStatusUpdateEventFlowable(filter); + } + + public static List getValidiumModeStatusUpdateEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(VALIDIUMMODESTATUSUPDATE_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + ValidiumModeStatusUpdateEventResponse typedResponse = new ValidiumModeStatusUpdateEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.validiumMode = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static ValidiumModeStatusUpdateEventResponse getValidiumModeStatusUpdateEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(VALIDIUMMODESTATUSUPDATE_EVENT, log); + ValidiumModeStatusUpdateEventResponse typedResponse = new ValidiumModeStatusUpdateEventResponse(); + typedResponse.log = log; + typedResponse.validiumMode = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + + public Flowable validiumModeStatusUpdateEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getValidiumModeStatusUpdateEventFromLog(log)); + } + + public Flowable validiumModeStatusUpdateEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(VALIDIUMMODESTATUSUPDATE_EVENT)); + return validiumModeStatusUpdateEventFlowable(filter); + } + + public RemoteFunctionCall acceptAdmin() { + final Function function = new Function( + FUNC_ACCEPTADMIN, + Arrays.asList(), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall baseTokenGasPriceMultiplierDenominator() { + final Function function = new Function(FUNC_BASETOKENGASPRICEMULTIPLIERDENOMINATOR, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall baseTokenGasPriceMultiplierNominator() { + final Function function = new Function(FUNC_BASETOKENGASPRICEMULTIPLIERNOMINATOR, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall bridgehubRequestL2Transaction(BridgehubL2TransactionRequest _request, BigInteger weiValue) { + final Function function = new Function( + FUNC_BRIDGEHUBREQUESTL2TRANSACTION, + Arrays.asList(_request), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public RemoteFunctionCall changeFeeParams(FeeParams _newFeeParams) { + final Function function = new Function( + FUNC_CHANGEFEEPARAMS, + Arrays.asList(_newFeeParams), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall commitBatches(StoredBatchInfo _lastCommittedBatchData, List _newBatchesData) { + final Function function = new Function( + FUNC_COMMITBATCHES, + Arrays.asList(_lastCommittedBatchData, + new DynamicArray(CommitBatchInfo.class, _newBatchesData)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall commitBatchesSharedBridge(BigInteger _chainId, StoredBatchInfo _lastCommittedBatchData, List _newBatchesData) { + final Function function = new Function( + FUNC_COMMITBATCHESSHAREDBRIDGE, + Arrays.asList(new Uint256(_chainId), + _lastCommittedBatchData, + new DynamicArray(CommitBatchInfo.class, _newBatchesData)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall executeBatches(List _batchesData) { + final Function function = new Function( + FUNC_EXECUTEBATCHES, + Arrays.asList(new DynamicArray(StoredBatchInfo.class, _batchesData)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall executeBatchesSharedBridge(BigInteger _chainId, List _batchesData) { + final Function function = new Function( + FUNC_EXECUTEBATCHESSHAREDBRIDGE, + Arrays.asList(new Uint256(_chainId), + new DynamicArray(StoredBatchInfo.class, _batchesData)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall executeUpgrade(DiamondCutData _diamondCut) { + final Function function = new Function( + FUNC_EXECUTEUPGRADE, + Arrays.asList(_diamondCut), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall facetAddress(byte[] _selector) { + final Function function = new Function(FUNC_FACETADDRESS, + Arrays.asList(new Bytes4(_selector)), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall facetAddresses() { + final Function function = new Function(FUNC_FACETADDRESSES, + Arrays.asList(), + Arrays.>asList(new TypeReference>() {})); + return new RemoteFunctionCall(function, + new Callable() { + @Override + @SuppressWarnings("unchecked") + public List call() throws Exception { + List result = (List) executeCallSingleValueReturn(function, List.class); + return convertToNative(result); + } + }); + } + + public RemoteFunctionCall facetFunctionSelectors(String _facet) { + final Function function = new Function(FUNC_FACETFUNCTIONSELECTORS, + Arrays.asList(new Address(160, _facet)), + Arrays.>asList(new TypeReference>() {})); + return new RemoteFunctionCall(function, + new Callable() { + @Override + @SuppressWarnings("unchecked") + public List call() throws Exception { + List result = (List) executeCallSingleValueReturn(function, List.class); + return convertToNative(result); + } + }); + } + + public RemoteFunctionCall facets() { + final Function function = new Function(FUNC_FACETS, + Arrays.asList(), + Arrays.>asList(new TypeReference>() {})); + return new RemoteFunctionCall(function, + new Callable() { + @Override + @SuppressWarnings("unchecked") + public List call() throws Exception { + List result = (List) executeCallSingleValueReturn(function, List.class); + return convertToNative(result); + } + }); + } + + public RemoteFunctionCall finalizeEthWithdrawal(BigInteger _l2BatchNumber, BigInteger _l2MessageIndex, BigInteger _l2TxNumberInBatch, byte[] _message, List _merkleProof) { + final Function function = new Function( + FUNC_FINALIZEETHWITHDRAWAL, + Arrays.asList(new Uint256(_l2BatchNumber), + new Uint256(_l2MessageIndex), + new Uint16(_l2TxNumberInBatch), + new DynamicBytes(_message), + new DynamicArray( + Bytes32.class, + org.web3j.abi.Utils.typeMap(_merkleProof, Bytes32.class))), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall freezeDiamond() { + final Function function = new Function( + FUNC_FREEZEDIAMOND, + Arrays.asList(), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall getAdmin() { + final Function function = new Function(FUNC_GETADMIN, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall getBaseToken() { + final Function function = new Function(FUNC_GETBASETOKEN, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall getBaseTokenBridge() { + final Function function = new Function(FUNC_GETBASETOKENBRIDGE, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall getBridgehub() { + final Function function = new Function(FUNC_GETBRIDGEHUB, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall getFirstUnprocessedPriorityTx() { + final Function function = new Function(FUNC_GETFIRSTUNPROCESSEDPRIORITYTX, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall getL2BootloaderBytecodeHash() { + final Function function = new Function(FUNC_GETL2BOOTLOADERBYTECODEHASH, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, byte[].class); + } + + public RemoteFunctionCall getL2DefaultAccountBytecodeHash() { + final Function function = new Function(FUNC_GETL2DEFAULTACCOUNTBYTECODEHASH, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, byte[].class); + } + + public RemoteFunctionCall getL2SystemContractsUpgradeBatchNumber() { + final Function function = new Function(FUNC_GETL2SYSTEMCONTRACTSUPGRADEBATCHNUMBER, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall getL2SystemContractsUpgradeTxHash() { + final Function function = new Function(FUNC_GETL2SYSTEMCONTRACTSUPGRADETXHASH, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, byte[].class); + } + + public RemoteFunctionCall getName() { + final Function function = new Function(FUNC_GETNAME, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall getPendingAdmin() { + final Function function = new Function(FUNC_GETPENDINGADMIN, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall getPriorityQueueSize() { + final Function function = new Function(FUNC_GETPRIORITYQUEUESIZE, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall getPriorityTxMaxGasLimit() { + final Function function = new Function(FUNC_GETPRIORITYTXMAXGASLIMIT, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall getProtocolVersion() { + final Function function = new Function(FUNC_GETPROTOCOLVERSION, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall getPubdataPricingMode() { + final Function function = new Function(FUNC_GETPUBDATAPRICINGMODE, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall getStateTransitionManager() { + final Function function = new Function(FUNC_GETSTATETRANSITIONMANAGER, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall getTotalBatchesCommitted() { + final Function function = new Function(FUNC_GETTOTALBATCHESCOMMITTED, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall getTotalBatchesExecuted() { + final Function function = new Function(FUNC_GETTOTALBATCHESEXECUTED, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall getTotalBatchesVerified() { + final Function function = new Function(FUNC_GETTOTALBATCHESVERIFIED, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall getTotalPriorityTxs() { + final Function function = new Function(FUNC_GETTOTALPRIORITYTXS, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall getVerifier() { + final Function function = new Function(FUNC_GETVERIFIER, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall getVerifierParams() { + final Function function = new Function(FUNC_GETVERIFIERPARAMS, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, VerifierParams.class); + } + + public RemoteFunctionCall isDiamondStorageFrozen() { + final Function function = new Function(FUNC_ISDIAMONDSTORAGEFROZEN, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall isEthWithdrawalFinalized(BigInteger _l2BatchNumber, BigInteger _l2MessageIndex) { + final Function function = new Function(FUNC_ISETHWITHDRAWALFINALIZED, + Arrays.asList(new Uint256(_l2BatchNumber), + new Uint256(_l2MessageIndex)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall isFacetFreezable(String _facet) { + final Function function = new Function(FUNC_ISFACETFREEZABLE, + Arrays.asList(new Address(160, _facet)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall isFunctionFreezable(byte[] _selector) { + final Function function = new Function(FUNC_ISFUNCTIONFREEZABLE, + Arrays.asList(new Bytes4(_selector)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall isValidator(String _address) { + final Function function = new Function(FUNC_ISVALIDATOR, + Arrays.asList(new Address(160, _address)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall l2LogsRootHash(BigInteger _batchNumber) { + final Function function = new Function(FUNC_L2LOGSROOTHASH, + Arrays.asList(new Uint256(_batchNumber)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, byte[].class); + } + + public RemoteFunctionCall l2TransactionBaseCost(BigInteger _gasPrice, BigInteger _l2GasLimit, BigInteger _l2GasPerPubdataByteLimit) { + final Function function = new Function(FUNC_L2TRANSACTIONBASECOST, + Arrays.asList(new Uint256(_gasPrice), + new Uint256(_l2GasLimit), + new Uint256(_l2GasPerPubdataByteLimit)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall priorityQueueFrontOperation() { + final Function function = new Function(FUNC_PRIORITYQUEUEFRONTOPERATION, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, PriorityOperation.class); + } + + public RemoteFunctionCall proveBatches(StoredBatchInfo _prevBatch, List _committedBatches, ProofInput _proof) { + final Function function = new Function( + FUNC_PROVEBATCHES, + Arrays.asList(_prevBatch, + new DynamicArray(StoredBatchInfo.class, _committedBatches), + _proof), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall proveBatchesSharedBridge(BigInteger _chainId, StoredBatchInfo _prevBatch, List _committedBatches, ProofInput _proof) { + final Function function = new Function( + FUNC_PROVEBATCHESSHAREDBRIDGE, + Arrays.asList(new Uint256(_chainId), + _prevBatch, + new DynamicArray(StoredBatchInfo.class, _committedBatches), + _proof), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall proveL1ToL2TransactionStatus(byte[] _l2TxHash, BigInteger _l2BatchNumber, BigInteger _l2MessageIndex, BigInteger _l2TxNumberInBatch, List _merkleProof, BigInteger _status) { + final Function function = new Function(FUNC_PROVEL1TOL2TRANSACTIONSTATUS, + Arrays.asList(new Bytes32(_l2TxHash), + new Uint256(_l2BatchNumber), + new Uint256(_l2MessageIndex), + new Uint16(_l2TxNumberInBatch), + new DynamicArray( + Bytes32.class, + org.web3j.abi.Utils.typeMap(_merkleProof, Bytes32.class)), + new Uint8(_status)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall proveL2LogInclusion(BigInteger _batchNumber, BigInteger _index, L2Log _log, List _proof) { + final Function function = new Function(FUNC_PROVEL2LOGINCLUSION, + Arrays.asList(new Uint256(_batchNumber), + new Uint256(_index), + _log, + new DynamicArray( + Bytes32.class, + org.web3j.abi.Utils.typeMap(_proof, Bytes32.class))), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall proveL2MessageInclusion(BigInteger _batchNumber, BigInteger _index, L2Message _message, List _proof) { + final Function function = new Function(FUNC_PROVEL2MESSAGEINCLUSION, + Arrays.asList(new Uint256(_batchNumber), + new Uint256(_index), + _message, + new DynamicArray( + Bytes32.class, + org.web3j.abi.Utils.typeMap(_proof, Bytes32.class))), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall requestL2Transaction(String _contractL2, BigInteger _l2Value, byte[] _calldata, BigInteger _l2GasLimit, BigInteger _l2GasPerPubdataByteLimit, List _factoryDeps, String _refundRecipient, BigInteger weiValue) { + final Function function = new Function( + FUNC_REQUESTL2TRANSACTION, + Arrays.asList(new Address(160, _contractL2), + new Uint256(_l2Value), + new DynamicBytes(_calldata), + new Uint256(_l2GasLimit), + new Uint256(_l2GasPerPubdataByteLimit), + new DynamicArray( + DynamicBytes.class, + org.web3j.abi.Utils.typeMap(_factoryDeps, DynamicBytes.class)), + new Address(160, _refundRecipient)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public RemoteFunctionCall revertBatches(BigInteger _newLastBatch) { + final Function function = new Function( + FUNC_REVERTBATCHES, + Arrays.asList(new Uint256(_newLastBatch)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall revertBatchesSharedBridge(BigInteger _chainId, BigInteger _newLastBatch) { + final Function function = new Function( + FUNC_REVERTBATCHESSHAREDBRIDGE, + Arrays.asList(new Uint256(_chainId), + new Uint256(_newLastBatch)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall setPendingAdmin(String _newPendingAdmin) { + final Function function = new Function( + FUNC_SETPENDINGADMIN, + Arrays.asList(new Address(160, _newPendingAdmin)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall setPorterAvailability(Boolean _zkPorterIsAvailable) { + final Function function = new Function( + FUNC_SETPORTERAVAILABILITY, + Arrays.asList(new Bool(_zkPorterIsAvailable)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall setPriorityTxMaxGasLimit(BigInteger _newPriorityTxMaxGasLimit) { + final Function function = new Function( + FUNC_SETPRIORITYTXMAXGASLIMIT, + Arrays.asList(new Uint256(_newPriorityTxMaxGasLimit)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall setTokenMultiplier(BigInteger _nominator, BigInteger _denominator) { + final Function function = new Function( + FUNC_SETTOKENMULTIPLIER, + Arrays.asList(new Uint128(_nominator), + new Uint128(_denominator)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall setTransactionFilterer(String _transactionFilterer) { + final Function function = new Function( + FUNC_SETTRANSACTIONFILTERER, + Arrays.asList(new Address(160, _transactionFilterer)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall setValidator(String _validator, Boolean _active) { + final Function function = new Function( + FUNC_SETVALIDATOR, + Arrays.asList(new Address(160, _validator), + new Bool(_active)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall setValidiumMode(BigInteger _validiumMode) { + final Function function = new Function( + FUNC_SETVALIDIUMMODE, + Arrays.asList(new Uint8(_validiumMode)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall storedBatchHash(BigInteger _batchNumber) { + final Function function = new Function(FUNC_STOREDBATCHHASH, + Arrays.asList(new Uint256(_batchNumber)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, byte[].class); + } + + public RemoteFunctionCall transferEthToSharedBridge() { + final Function function = new Function( + FUNC_TRANSFERETHTOSHAREDBRIDGE, + Arrays.asList(), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall unfreezeDiamond() { + final Function function = new Function( + FUNC_UNFREEZEDIAMOND, + Arrays.asList(), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall upgradeChainFromVersion(BigInteger _protocolVersion, DiamondCutData _cutData) { + final Function function = new Function( + FUNC_UPGRADECHAINFROMVERSION, + Arrays.asList(new Uint256(_protocolVersion), + _cutData), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + @Deprecated + public static IZkSyncStateTransition load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + return new IZkSyncStateTransition(contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + @Deprecated + public static IZkSyncStateTransition load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + return new IZkSyncStateTransition(contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + public static IZkSyncStateTransition load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + return new IZkSyncStateTransition(contractAddress, web3j, credentials, contractGasProvider); + } + + public static IZkSyncStateTransition load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + return new IZkSyncStateTransition(contractAddress, web3j, transactionManager, contractGasProvider); + } + + public static class FacetCut extends DynamicStruct { + public String facet; + + public BigInteger action; + + public Boolean isFreezable; + + public List selectors; + + public FacetCut(String facet, BigInteger action, Boolean isFreezable, List selectors) { + super(new Address(160, facet), + new Uint8(action), + new Bool(isFreezable), + new DynamicArray( + Bytes4.class, + org.web3j.abi.Utils.typeMap(selectors, Bytes4.class))); + this.facet = facet; + this.action = action; + this.isFreezable = isFreezable; + this.selectors = selectors; + } + + public FacetCut(Address facet, Uint8 action, Bool isFreezable, DynamicArray selectors) { + super(facet, action, isFreezable, selectors); + this.facet = facet.getValue(); + this.action = action.getValue(); + this.isFreezable = isFreezable.getValue(); + this.selectors = selectors.getValue().stream().map(v -> v.getValue()).collect(Collectors.toList()); + } + } + + public static class FeeParams extends StaticStruct { + public BigInteger pubdataPricingMode; + + public BigInteger batchOverheadL1Gas; + + public BigInteger maxPubdataPerBatch; + + public BigInteger maxL2GasPerBatch; + + public BigInteger priorityTxMaxPubdata; + + public BigInteger minimalL2GasPrice; + + public FeeParams(BigInteger pubdataPricingMode, BigInteger batchOverheadL1Gas, BigInteger maxPubdataPerBatch, BigInteger maxL2GasPerBatch, BigInteger priorityTxMaxPubdata, BigInteger minimalL2GasPrice) { + super(new Uint8(pubdataPricingMode), + new Uint32(batchOverheadL1Gas), + new Uint32(maxPubdataPerBatch), + new Uint32(maxL2GasPerBatch), + new Uint32(priorityTxMaxPubdata), + new Uint64(minimalL2GasPrice)); + this.pubdataPricingMode = pubdataPricingMode; + this.batchOverheadL1Gas = batchOverheadL1Gas; + this.maxPubdataPerBatch = maxPubdataPerBatch; + this.maxL2GasPerBatch = maxL2GasPerBatch; + this.priorityTxMaxPubdata = priorityTxMaxPubdata; + this.minimalL2GasPrice = minimalL2GasPrice; + } + + public FeeParams(Uint8 pubdataPricingMode, Uint32 batchOverheadL1Gas, Uint32 maxPubdataPerBatch, Uint32 maxL2GasPerBatch, Uint32 priorityTxMaxPubdata, Uint64 minimalL2GasPrice) { + super(pubdataPricingMode, batchOverheadL1Gas, maxPubdataPerBatch, maxL2GasPerBatch, priorityTxMaxPubdata, minimalL2GasPrice); + this.pubdataPricingMode = pubdataPricingMode.getValue(); + this.batchOverheadL1Gas = batchOverheadL1Gas.getValue(); + this.maxPubdataPerBatch = maxPubdataPerBatch.getValue(); + this.maxL2GasPerBatch = maxL2GasPerBatch.getValue(); + this.priorityTxMaxPubdata = priorityTxMaxPubdata.getValue(); + this.minimalL2GasPrice = minimalL2GasPrice.getValue(); + } + } + + public static class L2CanonicalTransaction extends DynamicStruct { + public BigInteger txType; + + public BigInteger from; + + public BigInteger to; + + public BigInteger gasLimit; + + public BigInteger gasPerPubdataByteLimit; + + public BigInteger maxFeePerGas; + + public BigInteger maxPriorityFeePerGas; + + public BigInteger paymaster; + + public BigInteger nonce; + + public BigInteger value; + + public List reserved; + + public byte[] data; + + public byte[] signature; + + public List factoryDeps; + + public byte[] paymasterInput; + + public byte[] reservedDynamic; + + public L2CanonicalTransaction(BigInteger txType, BigInteger from, BigInteger to, BigInteger gasLimit, BigInteger gasPerPubdataByteLimit, BigInteger maxFeePerGas, BigInteger maxPriorityFeePerGas, BigInteger paymaster, BigInteger nonce, BigInteger value, List reserved, byte[] data, byte[] signature, List factoryDeps, byte[] paymasterInput, byte[] reservedDynamic) { + super(new Uint256(txType), + new Uint256(from), + new Uint256(to), + new Uint256(gasLimit), + new Uint256(gasPerPubdataByteLimit), + new Uint256(maxFeePerGas), + new Uint256(maxPriorityFeePerGas), + new Uint256(paymaster), + new Uint256(nonce), + new Uint256(value), + new StaticArray4( + Uint256.class, + org.web3j.abi.Utils.typeMap(reserved, Uint256.class)), + new DynamicBytes(data), + new DynamicBytes(signature), + new DynamicArray( + Uint256.class, + org.web3j.abi.Utils.typeMap(factoryDeps, Uint256.class)), + new DynamicBytes(paymasterInput), + new DynamicBytes(reservedDynamic)); + this.txType = txType; + this.from = from; + this.to = to; + this.gasLimit = gasLimit; + this.gasPerPubdataByteLimit = gasPerPubdataByteLimit; + this.maxFeePerGas = maxFeePerGas; + this.maxPriorityFeePerGas = maxPriorityFeePerGas; + this.paymaster = paymaster; + this.nonce = nonce; + this.value = value; + this.reserved = reserved; + this.data = data; + this.signature = signature; + this.factoryDeps = factoryDeps; + this.paymasterInput = paymasterInput; + this.reservedDynamic = reservedDynamic; + } + + public L2CanonicalTransaction(Uint256 txType, Uint256 from, Uint256 to, Uint256 gasLimit, Uint256 gasPerPubdataByteLimit, Uint256 maxFeePerGas, Uint256 maxPriorityFeePerGas, Uint256 paymaster, Uint256 nonce, Uint256 value, StaticArray4 reserved, DynamicBytes data, DynamicBytes signature, DynamicArray factoryDeps, DynamicBytes paymasterInput, DynamicBytes reservedDynamic) { + super(txType, from, to, gasLimit, gasPerPubdataByteLimit, maxFeePerGas, maxPriorityFeePerGas, paymaster, nonce, value, reserved, data, signature, factoryDeps, paymasterInput, reservedDynamic); + this.txType = txType.getValue(); + this.from = from.getValue(); + this.to = to.getValue(); + this.gasLimit = gasLimit.getValue(); + this.gasPerPubdataByteLimit = gasPerPubdataByteLimit.getValue(); + this.maxFeePerGas = maxFeePerGas.getValue(); + this.maxPriorityFeePerGas = maxPriorityFeePerGas.getValue(); + this.paymaster = paymaster.getValue(); + this.nonce = nonce.getValue(); + this.value = value.getValue(); + this.reserved = reserved.getValue().stream().map(v -> v.getValue()).collect(Collectors.toList()); + this.data = data.getValue(); + this.signature = signature.getValue(); + this.factoryDeps = factoryDeps.getValue().stream().map(v -> v.getValue()).collect(Collectors.toList()); + this.paymasterInput = paymasterInput.getValue(); + this.reservedDynamic = reservedDynamic.getValue(); + } + } + + public static class BridgehubL2TransactionRequest extends DynamicStruct { + public String sender; + + public String contractL2; + + public BigInteger mintValue; + + public BigInteger l2Value; + + public byte[] l2Calldata; + + public BigInteger l2GasLimit; + + public BigInteger l2GasPerPubdataByteLimit; + + public List factoryDeps; + + public String refundRecipient; + + public BridgehubL2TransactionRequest(String sender, String contractL2, BigInteger mintValue, BigInteger l2Value, byte[] l2Calldata, BigInteger l2GasLimit, BigInteger l2GasPerPubdataByteLimit, List factoryDeps, String refundRecipient) { + super(new Address(160, sender), + new Address(160, contractL2), + new Uint256(mintValue), + new Uint256(l2Value), + new DynamicBytes(l2Calldata), + new Uint256(l2GasLimit), + new Uint256(l2GasPerPubdataByteLimit), + new DynamicArray( + DynamicBytes.class, + org.web3j.abi.Utils.typeMap(factoryDeps, DynamicBytes.class)), + new Address(160, refundRecipient)); + this.sender = sender; + this.contractL2 = contractL2; + this.mintValue = mintValue; + this.l2Value = l2Value; + this.l2Calldata = l2Calldata; + this.l2GasLimit = l2GasLimit; + this.l2GasPerPubdataByteLimit = l2GasPerPubdataByteLimit; + this.factoryDeps = factoryDeps; + this.refundRecipient = refundRecipient; + } + + public BridgehubL2TransactionRequest(Address sender, Address contractL2, Uint256 mintValue, Uint256 l2Value, DynamicBytes l2Calldata, Uint256 l2GasLimit, Uint256 l2GasPerPubdataByteLimit, DynamicArray factoryDeps, Address refundRecipient) { + super(sender, contractL2, mintValue, l2Value, l2Calldata, l2GasLimit, l2GasPerPubdataByteLimit, factoryDeps, refundRecipient); + this.sender = sender.getValue(); + this.contractL2 = contractL2.getValue(); + this.mintValue = mintValue.getValue(); + this.l2Value = l2Value.getValue(); + this.l2Calldata = l2Calldata.getValue(); + this.l2GasLimit = l2GasLimit.getValue(); + this.l2GasPerPubdataByteLimit = l2GasPerPubdataByteLimit.getValue(); + this.factoryDeps = factoryDeps.getValue().stream().map(v -> v.getValue()).collect(Collectors.toList()); + this.refundRecipient = refundRecipient.getValue(); + } + } + + public static class StoredBatchInfo extends StaticStruct { + public BigInteger batchNumber; + + public byte[] batchHash; + + public BigInteger indexRepeatedStorageChanges; + + public BigInteger numberOfLayer1Txs; + + public byte[] priorityOperationsHash; + + public byte[] l2LogsTreeRoot; + + public BigInteger timestamp; + + public byte[] commitment; + + public StoredBatchInfo(BigInteger batchNumber, byte[] batchHash, BigInteger indexRepeatedStorageChanges, BigInteger numberOfLayer1Txs, byte[] priorityOperationsHash, byte[] l2LogsTreeRoot, BigInteger timestamp, byte[] commitment) { + super(new Uint64(batchNumber), + new Bytes32(batchHash), + new Uint64(indexRepeatedStorageChanges), + new Uint256(numberOfLayer1Txs), + new Bytes32(priorityOperationsHash), + new Bytes32(l2LogsTreeRoot), + new Uint256(timestamp), + new Bytes32(commitment)); + this.batchNumber = batchNumber; + this.batchHash = batchHash; + this.indexRepeatedStorageChanges = indexRepeatedStorageChanges; + this.numberOfLayer1Txs = numberOfLayer1Txs; + this.priorityOperationsHash = priorityOperationsHash; + this.l2LogsTreeRoot = l2LogsTreeRoot; + this.timestamp = timestamp; + this.commitment = commitment; + } + + public StoredBatchInfo(Uint64 batchNumber, Bytes32 batchHash, Uint64 indexRepeatedStorageChanges, Uint256 numberOfLayer1Txs, Bytes32 priorityOperationsHash, Bytes32 l2LogsTreeRoot, Uint256 timestamp, Bytes32 commitment) { + super(batchNumber, batchHash, indexRepeatedStorageChanges, numberOfLayer1Txs, priorityOperationsHash, l2LogsTreeRoot, timestamp, commitment); + this.batchNumber = batchNumber.getValue(); + this.batchHash = batchHash.getValue(); + this.indexRepeatedStorageChanges = indexRepeatedStorageChanges.getValue(); + this.numberOfLayer1Txs = numberOfLayer1Txs.getValue(); + this.priorityOperationsHash = priorityOperationsHash.getValue(); + this.l2LogsTreeRoot = l2LogsTreeRoot.getValue(); + this.timestamp = timestamp.getValue(); + this.commitment = commitment.getValue(); + } + } + + public static class CommitBatchInfo extends DynamicStruct { + public BigInteger batchNumber; + + public BigInteger timestamp; + + public BigInteger indexRepeatedStorageChanges; + + public byte[] newStateRoot; + + public BigInteger numberOfLayer1Txs; + + public byte[] priorityOperationsHash; + + public byte[] bootloaderHeapInitialContentsHash; + + public byte[] eventsQueueStateHash; + + public byte[] systemLogs; + + public byte[] pubdataCommitments; + + public CommitBatchInfo(BigInteger batchNumber, BigInteger timestamp, BigInteger indexRepeatedStorageChanges, byte[] newStateRoot, BigInteger numberOfLayer1Txs, byte[] priorityOperationsHash, byte[] bootloaderHeapInitialContentsHash, byte[] eventsQueueStateHash, byte[] systemLogs, byte[] pubdataCommitments) { + super(new Uint64(batchNumber), + new Uint64(timestamp), + new Uint64(indexRepeatedStorageChanges), + new Bytes32(newStateRoot), + new Uint256(numberOfLayer1Txs), + new Bytes32(priorityOperationsHash), + new Bytes32(bootloaderHeapInitialContentsHash), + new Bytes32(eventsQueueStateHash), + new DynamicBytes(systemLogs), + new DynamicBytes(pubdataCommitments)); + this.batchNumber = batchNumber; + this.timestamp = timestamp; + this.indexRepeatedStorageChanges = indexRepeatedStorageChanges; + this.newStateRoot = newStateRoot; + this.numberOfLayer1Txs = numberOfLayer1Txs; + this.priorityOperationsHash = priorityOperationsHash; + this.bootloaderHeapInitialContentsHash = bootloaderHeapInitialContentsHash; + this.eventsQueueStateHash = eventsQueueStateHash; + this.systemLogs = systemLogs; + this.pubdataCommitments = pubdataCommitments; + } + + public CommitBatchInfo(Uint64 batchNumber, Uint64 timestamp, Uint64 indexRepeatedStorageChanges, Bytes32 newStateRoot, Uint256 numberOfLayer1Txs, Bytes32 priorityOperationsHash, Bytes32 bootloaderHeapInitialContentsHash, Bytes32 eventsQueueStateHash, DynamicBytes systemLogs, DynamicBytes pubdataCommitments) { + super(batchNumber, timestamp, indexRepeatedStorageChanges, newStateRoot, numberOfLayer1Txs, priorityOperationsHash, bootloaderHeapInitialContentsHash, eventsQueueStateHash, systemLogs, pubdataCommitments); + this.batchNumber = batchNumber.getValue(); + this.timestamp = timestamp.getValue(); + this.indexRepeatedStorageChanges = indexRepeatedStorageChanges.getValue(); + this.newStateRoot = newStateRoot.getValue(); + this.numberOfLayer1Txs = numberOfLayer1Txs.getValue(); + this.priorityOperationsHash = priorityOperationsHash.getValue(); + this.bootloaderHeapInitialContentsHash = bootloaderHeapInitialContentsHash.getValue(); + this.eventsQueueStateHash = eventsQueueStateHash.getValue(); + this.systemLogs = systemLogs.getValue(); + this.pubdataCommitments = pubdataCommitments.getValue(); + } + } + + public static class Facet extends DynamicStruct { + public String addr; + + public List selectors; + + public Facet(String addr, List selectors) { + super(new Address(160, addr), + new DynamicArray( + Bytes4.class, + org.web3j.abi.Utils.typeMap(selectors, Bytes4.class))); + this.addr = addr; + this.selectors = selectors; + } + + public Facet(Address addr, DynamicArray selectors) { + super(addr, selectors); + this.addr = addr.getValue(); + this.selectors = selectors.getValue().stream().map(v -> v.getValue()).collect(Collectors.toList()); + } + } + + public static class VerifierParams extends StaticStruct { + public byte[] recursionNodeLevelVkHash; + + public byte[] recursionLeafLevelVkHash; + + public byte[] recursionCircuitsSetVksHash; + + public VerifierParams(byte[] recursionNodeLevelVkHash, byte[] recursionLeafLevelVkHash, byte[] recursionCircuitsSetVksHash) { + super(new Bytes32(recursionNodeLevelVkHash), + new Bytes32(recursionLeafLevelVkHash), + new Bytes32(recursionCircuitsSetVksHash)); + this.recursionNodeLevelVkHash = recursionNodeLevelVkHash; + this.recursionLeafLevelVkHash = recursionLeafLevelVkHash; + this.recursionCircuitsSetVksHash = recursionCircuitsSetVksHash; + } + + public VerifierParams(Bytes32 recursionNodeLevelVkHash, Bytes32 recursionLeafLevelVkHash, Bytes32 recursionCircuitsSetVksHash) { + super(recursionNodeLevelVkHash, recursionLeafLevelVkHash, recursionCircuitsSetVksHash); + this.recursionNodeLevelVkHash = recursionNodeLevelVkHash.getValue(); + this.recursionLeafLevelVkHash = recursionLeafLevelVkHash.getValue(); + this.recursionCircuitsSetVksHash = recursionCircuitsSetVksHash.getValue(); + } + } + + public static class PriorityOperation extends StaticStruct { + public byte[] canonicalTxHash; + + public BigInteger expirationTimestamp; + + public BigInteger layer2Tip; + + public PriorityOperation(byte[] canonicalTxHash, BigInteger expirationTimestamp, BigInteger layer2Tip) { + super(new Bytes32(canonicalTxHash), + new Uint64(expirationTimestamp), + new Uint192(layer2Tip)); + this.canonicalTxHash = canonicalTxHash; + this.expirationTimestamp = expirationTimestamp; + this.layer2Tip = layer2Tip; + } + + public PriorityOperation(Bytes32 canonicalTxHash, Uint64 expirationTimestamp, Uint192 layer2Tip) { + super(canonicalTxHash, expirationTimestamp, layer2Tip); + this.canonicalTxHash = canonicalTxHash.getValue(); + this.expirationTimestamp = expirationTimestamp.getValue(); + this.layer2Tip = layer2Tip.getValue(); + } + } + + public static class ProofInput extends DynamicStruct { + public List recursiveAggregationInput; + + public List serializedProof; + + public ProofInput(List recursiveAggregationInput, List serializedProof) { + super(new DynamicArray( + Uint256.class, + org.web3j.abi.Utils.typeMap(recursiveAggregationInput, Uint256.class)), + new DynamicArray( + Uint256.class, + org.web3j.abi.Utils.typeMap(serializedProof, Uint256.class))); + this.recursiveAggregationInput = recursiveAggregationInput; + this.serializedProof = serializedProof; + } + + public ProofInput(DynamicArray recursiveAggregationInput, DynamicArray serializedProof) { + super(recursiveAggregationInput, serializedProof); + this.recursiveAggregationInput = recursiveAggregationInput.getValue().stream().map(v -> v.getValue()).collect(Collectors.toList()); + this.serializedProof = serializedProof.getValue().stream().map(v -> v.getValue()).collect(Collectors.toList()); + } + } + + public static class L2Log extends StaticStruct { + public BigInteger l2ShardId; + + public Boolean isService; + + public BigInteger txNumberInBatch; + + public String sender; + + public byte[] key; + + public byte[] value; + + public L2Log(BigInteger l2ShardId, Boolean isService, BigInteger txNumberInBatch, String sender, byte[] key, byte[] value) { + super(new Uint8(l2ShardId), + new Bool(isService), + new Uint16(txNumberInBatch), + new Address(160, sender), + new Bytes32(key), + new Bytes32(value)); + this.l2ShardId = l2ShardId; + this.isService = isService; + this.txNumberInBatch = txNumberInBatch; + this.sender = sender; + this.key = key; + this.value = value; + } + + public L2Log(Uint8 l2ShardId, Bool isService, Uint16 txNumberInBatch, Address sender, Bytes32 key, Bytes32 value) { + super(l2ShardId, isService, txNumberInBatch, sender, key, value); + this.l2ShardId = l2ShardId.getValue(); + this.isService = isService.getValue(); + this.txNumberInBatch = txNumberInBatch.getValue(); + this.sender = sender.getValue(); + this.key = key.getValue(); + this.value = value.getValue(); + } + } + + public static class L2Message extends DynamicStruct { + public BigInteger txNumberInBatch; + + public String sender; + + public byte[] data; + + public L2Message(BigInteger txNumberInBatch, String sender, byte[] data) { + super(new Uint16(txNumberInBatch), + new Address(160, sender), + new DynamicBytes(data)); + this.txNumberInBatch = txNumberInBatch; + this.sender = sender; + this.data = data; + } + + public L2Message(Uint16 txNumberInBatch, Address sender, DynamicBytes data) { + super(txNumberInBatch, sender, data); + this.txNumberInBatch = txNumberInBatch.getValue(); + this.sender = sender.getValue(); + this.data = data.getValue(); + } + } + + public static class DiamondCutData extends DynamicStruct { + public List facetCuts; + + public String initAddress; + + public byte[] initCalldata; + + public DiamondCutData(List facetCuts, String initAddress, byte[] initCalldata) { + super(new DynamicArray(FacetCut.class, facetCuts), + new Address(160, initAddress), + new DynamicBytes(initCalldata)); + this.facetCuts = facetCuts; + this.initAddress = initAddress; + this.initCalldata = initCalldata; + } + + public DiamondCutData(@Parameterized(type = FacetCut.class) DynamicArray facetCuts, Address initAddress, DynamicBytes initCalldata) { + super(facetCuts, initAddress, initCalldata); + this.facetCuts = facetCuts.getValue(); + this.initAddress = initAddress.getValue(); + this.initCalldata = initCalldata.getValue(); + } + } + + public static class BlockCommitEventResponse extends BaseEventResponse { + public BigInteger batchNumber; + + public byte[] batchHash; + + public byte[] commitment; + } + + public static class BlockExecutionEventResponse extends BaseEventResponse { + public BigInteger batchNumber; + + public byte[] batchHash; + + public byte[] commitment; + } + + public static class BlocksRevertEventResponse extends BaseEventResponse { + public BigInteger totalBatchesCommitted; + + public BigInteger totalBatchesVerified; + + public BigInteger totalBatchesExecuted; + } + + public static class BlocksVerificationEventResponse extends BaseEventResponse { + public BigInteger previousLastVerifiedBatch; + + public BigInteger currentLastVerifiedBatch; + } + + public static class EthWithdrawalFinalizedEventResponse extends BaseEventResponse { + public String to; + + public BigInteger amount; + } + + public static class ExecuteUpgradeEventResponse extends BaseEventResponse { + public DiamondCutData diamondCut; + } + + public static class FreezeEventResponse extends BaseEventResponse { + } + + public static class IsPorterAvailableStatusUpdateEventResponse extends BaseEventResponse { + public Boolean isPorterAvailable; + } + + public static class NewAdminEventResponse extends BaseEventResponse { + public String oldAdmin; + + public String newAdmin; + } + + public static class NewBaseTokenMultiplierEventResponse extends BaseEventResponse { + public BigInteger oldNominator; + + public BigInteger oldDenominator; + + public BigInteger newNominator; + + public BigInteger newDenominator; + } + + public static class NewFeeParamsEventResponse extends BaseEventResponse { + public FeeParams oldFeeParams; + + public FeeParams newFeeParams; + } + + public static class NewPendingAdminEventResponse extends BaseEventResponse { + public String oldPendingAdmin; + + public String newPendingAdmin; + } + + public static class NewPriorityRequestEventResponse extends BaseEventResponse { + public BigInteger txId; + + public byte[] txHash; + + public BigInteger expirationTimestamp; + + public L2CanonicalTransaction transaction; + + public List factoryDeps; + } + + public static class NewPriorityTxMaxGasLimitEventResponse extends BaseEventResponse { + public BigInteger oldPriorityTxMaxGasLimit; + + public BigInteger newPriorityTxMaxGasLimit; + } + + public static class NewTransactionFiltererEventResponse extends BaseEventResponse { + public String oldTransactionFilterer; + + public String newTransactionFilterer; + } + + public static class ProposeTransparentUpgradeEventResponse extends BaseEventResponse { + public BigInteger proposalId; + + public DiamondCutData diamondCut; + + public byte[] proposalSalt; + } + + public static class UnfreezeEventResponse extends BaseEventResponse { + } + + public static class ValidatorStatusUpdateEventResponse extends BaseEventResponse { + public String validatorAddress; + + public Boolean isActive; + } + + public static class ValidiumModeStatusUpdateEventResponse extends BaseEventResponse { + public BigInteger validiumMode; + } +} diff --git a/src/main/java/io/zksync/wrappers/ZkSyncContract.java b/src/main/java/io/zksync/wrappers/ZkSyncContract.java index 40293b7..8311676 100644 --- a/src/main/java/io/zksync/wrappers/ZkSyncContract.java +++ b/src/main/java/io/zksync/wrappers/ZkSyncContract.java @@ -11,16 +11,7 @@ import java.util.stream.Collectors; import org.web3j.abi.EventEncoder; import org.web3j.abi.TypeReference; -import org.web3j.abi.datatypes.Address; -import org.web3j.abi.datatypes.Array; -import org.web3j.abi.datatypes.Bool; -import org.web3j.abi.datatypes.DynamicArray; -import org.web3j.abi.datatypes.DynamicBytes; -import org.web3j.abi.datatypes.DynamicStruct; -import org.web3j.abi.datatypes.Event; -import org.web3j.abi.datatypes.Function; -import org.web3j.abi.datatypes.StaticStruct; -import org.web3j.abi.datatypes.Type; +import org.web3j.abi.datatypes.*; import org.web3j.abi.datatypes.generated.Bytes32; import org.web3j.abi.datatypes.generated.Bytes4; import org.web3j.abi.datatypes.generated.StaticArray4; @@ -54,15 +45,15 @@ */ @SuppressWarnings("rawtypes") public class ZkSyncContract extends Contract { - public static final String BINARY = "0x"; + public static final String BINARY = "Bin file was not provided"; - public static final String FUNC_ACCEPTGOVERNOR = "acceptGovernor"; + public static final String FUNC_ACCEPTADMIN = "acceptAdmin"; - public static final String FUNC_CANCELUPGRADEPROPOSAL = "cancelUpgradeProposal"; + public static final String FUNC_ACCEPTGOVERNOR = "acceptGovernor"; - public static final String FUNC_COMMITBLOCKS = "commitBlocks"; + public static final String FUNC_COMMITBATCHES = "commitBatches"; - public static final String FUNC_EXECUTEBLOCKS = "executeBlocks"; + public static final String FUNC_EXECUTEBATCHES = "executeBatches"; public static final String FUNC_EXECUTEUPGRADE = "executeUpgrade"; @@ -78,8 +69,6 @@ public class ZkSyncContract extends Contract { public static final String FUNC_FREEZEDIAMOND = "freezeDiamond"; - public static final String FUNC_GETCURRENTPROPOSALID = "getCurrentProposalId"; - public static final String FUNC_GETFIRSTUNPROCESSEDPRIORITYTX = "getFirstUnprocessedPriorityTx"; public static final String FUNC_GETGOVERNOR = "getGovernor"; @@ -88,34 +77,32 @@ public class ZkSyncContract extends Contract { public static final String FUNC_GETL2DEFAULTACCOUNTBYTECODEHASH = "getL2DefaultAccountBytecodeHash"; + public static final String FUNC_GETL2SYSTEMCONTRACTSUPGRADEBATCHNUMBER = "getL2SystemContractsUpgradeBatchNumber"; + + public static final String FUNC_GETL2SYSTEMCONTRACTSUPGRADETXHASH = "getL2SystemContractsUpgradeTxHash"; + + public static final String FUNC_GETNAME = "getName"; + public static final String FUNC_GETPENDINGGOVERNOR = "getPendingGovernor"; public static final String FUNC_GETPRIORITYQUEUESIZE = "getPriorityQueueSize"; - public static final String FUNC_GETPROPOSEDUPGRADEHASH = "getProposedUpgradeHash"; + public static final String FUNC_GETPRIORITYTXMAXGASLIMIT = "getPriorityTxMaxGasLimit"; - public static final String FUNC_GETPROPOSEDUPGRADETIMESTAMP = "getProposedUpgradeTimestamp"; + public static final String FUNC_GETPROTOCOLVERSION = "getProtocolVersion"; - public static final String FUNC_GETSECURITYCOUNCIL = "getSecurityCouncil"; + public static final String FUNC_GETTOTALBATCHESCOMMITTED = "getTotalBatchesCommitted"; - public static final String FUNC_GETTOTALBLOCKSCOMMITTED = "getTotalBlocksCommitted"; + public static final String FUNC_GETTOTALBATCHESEXECUTED = "getTotalBatchesExecuted"; - public static final String FUNC_GETTOTALBLOCKSEXECUTED = "getTotalBlocksExecuted"; - - public static final String FUNC_GETTOTALBLOCKSVERIFIED = "getTotalBlocksVerified"; + public static final String FUNC_GETTOTALBATCHESVERIFIED = "getTotalBatchesVerified"; public static final String FUNC_GETTOTALPRIORITYTXS = "getTotalPriorityTxs"; - public static final String FUNC_GETUPGRADEPROPOSALSTATE = "getUpgradeProposalState"; - public static final String FUNC_GETVERIFIER = "getVerifier"; public static final String FUNC_GETVERIFIERPARAMS = "getVerifierParams"; - public static final String FUNC_GETPRIORITYTXMAXGASLIMIT = "getpriorityTxMaxGasLimit"; - - public static final String FUNC_ISAPPROVEDBYSECURITYCOUNCIL = "isApprovedBySecurityCouncil"; - public static final String FUNC_ISDIAMONDSTORAGEFROZEN = "isDiamondStorageFrozen"; public static final String FUNC_ISETHWITHDRAWALFINALIZED = "isEthWithdrawalFinalized"; @@ -132,11 +119,7 @@ public class ZkSyncContract extends Contract { public static final String FUNC_PRIORITYQUEUEFRONTOPERATION = "priorityQueueFrontOperation"; - public static final String FUNC_PROPOSESHADOWUPGRADE = "proposeShadowUpgrade"; - - public static final String FUNC_PROPOSETRANSPARENTUPGRADE = "proposeTransparentUpgrade"; - - public static final String FUNC_PROVEBLOCKS = "proveBlocks"; + public static final String FUNC_PROVEBATCHES = "proveBatches"; public static final String FUNC_PROVEL1TOL2TRANSACTIONSTATUS = "proveL1ToL2TransactionStatus"; @@ -146,15 +129,9 @@ public class ZkSyncContract extends Contract { public static final String FUNC_REQUESTL2TRANSACTION = "requestL2Transaction"; - public static final String FUNC_REVERTBLOCKS = "revertBlocks"; - - public static final String FUNC_SECURITYCOUNCILUPGRADEAPPROVE = "securityCouncilUpgradeApprove"; - - public static final String FUNC_SERIALIZEL2TRANSACTION = "serializeL2Transaction"; + public static final String FUNC_REVERTBATCHES = "revertBatches"; - public static final String FUNC_SETL2BOOTLOADERBYTECODEHASH = "setL2BootloaderBytecodeHash"; - - public static final String FUNC_SETL2DEFAULTACCOUNTBYTECODEHASH = "setL2DefaultAccountBytecodeHash"; + public static final String FUNC_SETPENDINGADMIN = "setPendingAdmin"; public static final String FUNC_SETPENDINGGOVERNOR = "setPendingGovernor"; @@ -164,16 +141,10 @@ public class ZkSyncContract extends Contract { public static final String FUNC_SETVALIDATOR = "setValidator"; - public static final String FUNC_SETVERIFIER = "setVerifier"; - - public static final String FUNC_SETVERIFIERPARAMS = "setVerifierParams"; - - public static final String FUNC_STOREDBLOCKHASH = "storedBlockHash"; + public static final String FUNC_STOREDBATCHHASH = "storedBatchHash"; public static final String FUNC_UNFREEZEDIAMOND = "unfreezeDiamond"; - public static final String FUNC_UPGRADEPROPOSALHASH = "upgradeProposalHash"; - public static final Event BLOCKCOMMIT_EVENT = new Event("BlockCommit", Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {}, new TypeReference(true) {})); ; @@ -190,16 +161,12 @@ public class ZkSyncContract extends Contract { Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {})); ; - public static final Event CANCELUPGRADEPROPOSAL_EVENT = new Event("CancelUpgradeProposal", - Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {})); - ; - public static final Event ETHWITHDRAWALFINALIZED_EVENT = new Event("EthWithdrawalFinalized", Arrays.>asList(new TypeReference
(true) {}, new TypeReference() {})); ; public static final Event EXECUTEUPGRADE_EVENT = new Event("ExecuteUpgrade", - Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {}, new TypeReference() {})); + Arrays.>asList(new TypeReference() {})); ; public static final Event FREEZE_EVENT = new Event("Freeze", @@ -210,16 +177,16 @@ public class ZkSyncContract extends Contract { Arrays.>asList(new TypeReference() {})); ; - public static final Event NEWGOVERNOR_EVENT = new Event("NewGovernor", + public static final Event NEWADMIN_EVENT = new Event("NewAdmin", Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {})); ; - public static final Event NEWL2BOOTLOADERBYTECODEHASH_EVENT = new Event("NewL2BootloaderBytecodeHash", - Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {})); + public static final Event NEWGOVERNOR_EVENT = new Event("NewGovernor", + Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {})); ; - public static final Event NEWL2DEFAULTACCOUNTBYTECODEHASH_EVENT = new Event("NewL2DefaultAccountBytecodeHash", - Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {})); + public static final Event NEWPENDINGADMIN_EVENT = new Event("NewPendingAdmin", + Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {})); ; public static final Event NEWPENDINGGOVERNOR_EVENT = new Event("NewPendingGovernor", @@ -227,33 +194,13 @@ public class ZkSyncContract extends Contract { ; public static final Event NEWPRIORITYREQUEST_EVENT = new Event("NewPriorityRequest", - Arrays.>asList(new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference>() {})); + Arrays.>asList(new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference>() {})); ; public static final Event NEWPRIORITYTXMAXGASLIMIT_EVENT = new Event("NewPriorityTxMaxGasLimit", Arrays.>asList(new TypeReference() {}, new TypeReference() {})); ; - public static final Event NEWVERIFIER_EVENT = new Event("NewVerifier", - Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {})); - ; - - public static final Event NEWVERIFIERPARAMS_EVENT = new Event("NewVerifierParams", - Arrays.>asList(new TypeReference() {}, new TypeReference() {})); - ; - - public static final Event PROPOSESHADOWUPGRADE_EVENT = new Event("ProposeShadowUpgrade", - Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {})); - ; - - public static final Event PROPOSETRANSPARENTUPGRADE_EVENT = new Event("ProposeTransparentUpgrade", - Arrays.>asList(new TypeReference() {}, new TypeReference(true) {}, new TypeReference() {})); - ; - - public static final Event SECURITYCOUNCILUPGRADEAPPROVE_EVENT = new Event("SecurityCouncilUpgradeApprove", - Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {})); - ; - public static final Event UNFREEZE_EVENT = new Event("Unfreeze", Arrays.>asList()); ; @@ -262,12 +209,6 @@ public class ZkSyncContract extends Contract { Arrays.>asList(new TypeReference
(true) {}, new TypeReference() {})); ; - protected static final HashMap _addresses; - - static { - _addresses = new HashMap(); - } - @Deprecated protected ZkSyncContract(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); @@ -286,177 +227,145 @@ protected ZkSyncContract(String contractAddress, Web3j web3j, TransactionManager super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); } - public static List getBlockCommitEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(BLOCKCOMMIT_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - BlockCommitEventResponse typedResponse = new BlockCommitEventResponse(); + public static List getBlockCommitEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(BLOCKCOMMIT_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + IZkSync.BlockCommitEventResponse typedResponse = new IZkSync.BlockCommitEventResponse(); typedResponse.log = eventValues.getLog(); - typedResponse.blockNumber = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.blockHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.batchNumber = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.batchHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); typedResponse.commitment = (byte[]) eventValues.getIndexedValues().get(2).getValue(); responses.add(typedResponse); } return responses; } - public static BlockCommitEventResponse getBlockCommitEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(BLOCKCOMMIT_EVENT, log); - BlockCommitEventResponse typedResponse = new BlockCommitEventResponse(); + public static IZkSync.BlockCommitEventResponse getBlockCommitEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(BLOCKCOMMIT_EVENT, log); + IZkSync.BlockCommitEventResponse typedResponse = new IZkSync.BlockCommitEventResponse(); typedResponse.log = log; - typedResponse.blockNumber = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.blockHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.batchNumber = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.batchHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); typedResponse.commitment = (byte[]) eventValues.getIndexedValues().get(2).getValue(); return typedResponse; } - public Flowable blockCommitEventFlowable(EthFilter filter) { + public Flowable blockCommitEventFlowable(EthFilter filter) { return web3j.ethLogFlowable(filter).map(log -> getBlockCommitEventFromLog(log)); } - public Flowable blockCommitEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable blockCommitEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(BLOCKCOMMIT_EVENT)); return blockCommitEventFlowable(filter); } - public static List getBlockExecutionEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(BLOCKEXECUTION_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - BlockExecutionEventResponse typedResponse = new BlockExecutionEventResponse(); + public static List getBlockExecutionEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(BLOCKEXECUTION_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + IZkSync.BlockExecutionEventResponse typedResponse = new IZkSync.BlockExecutionEventResponse(); typedResponse.log = eventValues.getLog(); - typedResponse.blockNumber = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.blockHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.batchNumber = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.batchHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); typedResponse.commitment = (byte[]) eventValues.getIndexedValues().get(2).getValue(); responses.add(typedResponse); } return responses; } - public static BlockExecutionEventResponse getBlockExecutionEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(BLOCKEXECUTION_EVENT, log); - BlockExecutionEventResponse typedResponse = new BlockExecutionEventResponse(); + public static IZkSync.BlockExecutionEventResponse getBlockExecutionEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(BLOCKEXECUTION_EVENT, log); + IZkSync.BlockExecutionEventResponse typedResponse = new IZkSync.BlockExecutionEventResponse(); typedResponse.log = log; - typedResponse.blockNumber = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.blockHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.batchNumber = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.batchHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); typedResponse.commitment = (byte[]) eventValues.getIndexedValues().get(2).getValue(); return typedResponse; } - public Flowable blockExecutionEventFlowable(EthFilter filter) { + public Flowable blockExecutionEventFlowable(EthFilter filter) { return web3j.ethLogFlowable(filter).map(log -> getBlockExecutionEventFromLog(log)); } - public Flowable blockExecutionEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable blockExecutionEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(BLOCKEXECUTION_EVENT)); return blockExecutionEventFlowable(filter); } - public static List getBlocksRevertEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(BLOCKSREVERT_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - BlocksRevertEventResponse typedResponse = new BlocksRevertEventResponse(); + public static List getBlocksRevertEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(BLOCKSREVERT_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + IZkSync.BlocksRevertEventResponse typedResponse = new IZkSync.BlocksRevertEventResponse(); typedResponse.log = eventValues.getLog(); - typedResponse.totalBlocksCommitted = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); - typedResponse.totalBlocksVerified = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); - typedResponse.totalBlocksExecuted = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + typedResponse.totalBatchesCommitted = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.totalBatchesVerified = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.totalBatchesExecuted = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); responses.add(typedResponse); } return responses; } - public static BlocksRevertEventResponse getBlocksRevertEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(BLOCKSREVERT_EVENT, log); - BlocksRevertEventResponse typedResponse = new BlocksRevertEventResponse(); + public static IZkSync.BlocksRevertEventResponse getBlocksRevertEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(BLOCKSREVERT_EVENT, log); + IZkSync.BlocksRevertEventResponse typedResponse = new IZkSync.BlocksRevertEventResponse(); typedResponse.log = log; - typedResponse.totalBlocksCommitted = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); - typedResponse.totalBlocksVerified = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); - typedResponse.totalBlocksExecuted = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + typedResponse.totalBatchesCommitted = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.totalBatchesVerified = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.totalBatchesExecuted = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); return typedResponse; } - public Flowable blocksRevertEventFlowable(EthFilter filter) { + public Flowable blocksRevertEventFlowable(EthFilter filter) { return web3j.ethLogFlowable(filter).map(log -> getBlocksRevertEventFromLog(log)); } - public Flowable blocksRevertEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable blocksRevertEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(BLOCKSREVERT_EVENT)); return blocksRevertEventFlowable(filter); } - public static List getBlocksVerificationEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(BLOCKSVERIFICATION_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - BlocksVerificationEventResponse typedResponse = new BlocksVerificationEventResponse(); + public static List getBlocksVerificationEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(BLOCKSVERIFICATION_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + IZkSync.BlocksVerificationEventResponse typedResponse = new IZkSync.BlocksVerificationEventResponse(); typedResponse.log = eventValues.getLog(); - typedResponse.previousLastVerifiedBlock = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.currentLastVerifiedBlock = (BigInteger) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.previousLastVerifiedBatch = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.currentLastVerifiedBatch = (BigInteger) eventValues.getIndexedValues().get(1).getValue(); responses.add(typedResponse); } return responses; } - public static BlocksVerificationEventResponse getBlocksVerificationEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(BLOCKSVERIFICATION_EVENT, log); - BlocksVerificationEventResponse typedResponse = new BlocksVerificationEventResponse(); + public static IZkSync.BlocksVerificationEventResponse getBlocksVerificationEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(BLOCKSVERIFICATION_EVENT, log); + IZkSync.BlocksVerificationEventResponse typedResponse = new IZkSync.BlocksVerificationEventResponse(); typedResponse.log = log; - typedResponse.previousLastVerifiedBlock = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.currentLastVerifiedBlock = (BigInteger) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.previousLastVerifiedBatch = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.currentLastVerifiedBatch = (BigInteger) eventValues.getIndexedValues().get(1).getValue(); return typedResponse; } - public Flowable blocksVerificationEventFlowable(EthFilter filter) { + public Flowable blocksVerificationEventFlowable(EthFilter filter) { return web3j.ethLogFlowable(filter).map(log -> getBlocksVerificationEventFromLog(log)); } - public Flowable blocksVerificationEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable blocksVerificationEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(BLOCKSVERIFICATION_EVENT)); return blocksVerificationEventFlowable(filter); } - public static List getCancelUpgradeProposalEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(CANCELUPGRADEPROPOSAL_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - CancelUpgradeProposalEventResponse typedResponse = new CancelUpgradeProposalEventResponse(); - typedResponse.log = eventValues.getLog(); - typedResponse.proposalId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.proposalHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); - responses.add(typedResponse); - } - return responses; - } - - public static CancelUpgradeProposalEventResponse getCancelUpgradeProposalEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(CANCELUPGRADEPROPOSAL_EVENT, log); - CancelUpgradeProposalEventResponse typedResponse = new CancelUpgradeProposalEventResponse(); - typedResponse.log = log; - typedResponse.proposalId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.proposalHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); - return typedResponse; - } - - public Flowable cancelUpgradeProposalEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(log -> getCancelUpgradeProposalEventFromLog(log)); - } - - public Flowable cancelUpgradeProposalEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { - EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); - filter.addSingleTopic(EventEncoder.encode(CANCELUPGRADEPROPOSAL_EVENT)); - return cancelUpgradeProposalEventFlowable(filter); - } - - public static List getEthWithdrawalFinalizedEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(ETHWITHDRAWALFINALIZED_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - EthWithdrawalFinalizedEventResponse typedResponse = new EthWithdrawalFinalizedEventResponse(); + public static List getEthWithdrawalFinalizedEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(ETHWITHDRAWALFINALIZED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + IZkSync.EthWithdrawalFinalizedEventResponse typedResponse = new IZkSync.EthWithdrawalFinalizedEventResponse(); typedResponse.log = eventValues.getLog(); typedResponse.to = (String) eventValues.getIndexedValues().get(0).getValue(); typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); @@ -465,92 +374,88 @@ public static List getEthWithdrawalFinalize return responses; } - public static EthWithdrawalFinalizedEventResponse getEthWithdrawalFinalizedEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(ETHWITHDRAWALFINALIZED_EVENT, log); - EthWithdrawalFinalizedEventResponse typedResponse = new EthWithdrawalFinalizedEventResponse(); + public static IZkSync.EthWithdrawalFinalizedEventResponse getEthWithdrawalFinalizedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(ETHWITHDRAWALFINALIZED_EVENT, log); + IZkSync.EthWithdrawalFinalizedEventResponse typedResponse = new IZkSync.EthWithdrawalFinalizedEventResponse(); typedResponse.log = log; typedResponse.to = (String) eventValues.getIndexedValues().get(0).getValue(); typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); return typedResponse; } - public Flowable ethWithdrawalFinalizedEventFlowable(EthFilter filter) { + public Flowable ethWithdrawalFinalizedEventFlowable(EthFilter filter) { return web3j.ethLogFlowable(filter).map(log -> getEthWithdrawalFinalizedEventFromLog(log)); } - public Flowable ethWithdrawalFinalizedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable ethWithdrawalFinalizedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(ETHWITHDRAWALFINALIZED_EVENT)); return ethWithdrawalFinalizedEventFlowable(filter); } - public static List getExecuteUpgradeEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(EXECUTEUPGRADE_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - ExecuteUpgradeEventResponse typedResponse = new ExecuteUpgradeEventResponse(); + public static List getExecuteUpgradeEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(EXECUTEUPGRADE_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + IZkSync.ExecuteUpgradeEventResponse typedResponse = new IZkSync.ExecuteUpgradeEventResponse(); typedResponse.log = eventValues.getLog(); - typedResponse.proposalId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.proposalHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); - typedResponse.proposalSalt = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.diamondCut = (IZkSync.DiamondCutData) eventValues.getNonIndexedValues().get(0); responses.add(typedResponse); } return responses; } - public static ExecuteUpgradeEventResponse getExecuteUpgradeEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(EXECUTEUPGRADE_EVENT, log); - ExecuteUpgradeEventResponse typedResponse = new ExecuteUpgradeEventResponse(); + public static IZkSync.ExecuteUpgradeEventResponse getExecuteUpgradeEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(EXECUTEUPGRADE_EVENT, log); + IZkSync.ExecuteUpgradeEventResponse typedResponse = new IZkSync.ExecuteUpgradeEventResponse(); typedResponse.log = log; - typedResponse.proposalId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.proposalHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); - typedResponse.proposalSalt = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.diamondCut = (IZkSync.DiamondCutData) eventValues.getNonIndexedValues().get(0); return typedResponse; } - public Flowable executeUpgradeEventFlowable(EthFilter filter) { + public Flowable executeUpgradeEventFlowable(EthFilter filter) { return web3j.ethLogFlowable(filter).map(log -> getExecuteUpgradeEventFromLog(log)); } - public Flowable executeUpgradeEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable executeUpgradeEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(EXECUTEUPGRADE_EVENT)); return executeUpgradeEventFlowable(filter); } - public static List getFreezeEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(FREEZE_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - FreezeEventResponse typedResponse = new FreezeEventResponse(); + public static List getFreezeEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(FREEZE_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + IZkSync.FreezeEventResponse typedResponse = new IZkSync.FreezeEventResponse(); typedResponse.log = eventValues.getLog(); responses.add(typedResponse); } return responses; } - public static FreezeEventResponse getFreezeEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(FREEZE_EVENT, log); - FreezeEventResponse typedResponse = new FreezeEventResponse(); + public static IZkSync.FreezeEventResponse getFreezeEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(FREEZE_EVENT, log); + IZkSync.FreezeEventResponse typedResponse = new IZkSync.FreezeEventResponse(); typedResponse.log = log; return typedResponse; } - public Flowable freezeEventFlowable(EthFilter filter) { + public Flowable freezeEventFlowable(EthFilter filter) { return web3j.ethLogFlowable(filter).map(log -> getFreezeEventFromLog(log)); } - public Flowable freezeEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable freezeEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(FREEZE_EVENT)); return freezeEventFlowable(filter); } - public static List getIsPorterAvailableStatusUpdateEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(ISPORTERAVAILABLESTATUSUPDATE_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - IsPorterAvailableStatusUpdateEventResponse typedResponse = new IsPorterAvailableStatusUpdateEventResponse(); + public static List getIsPorterAvailableStatusUpdateEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(ISPORTERAVAILABLESTATUSUPDATE_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + IZkSync.IsPorterAvailableStatusUpdateEventResponse typedResponse = new IZkSync.IsPorterAvailableStatusUpdateEventResponse(); typedResponse.log = eventValues.getLog(); typedResponse.isPorterAvailable = (Boolean) eventValues.getNonIndexedValues().get(0).getValue(); responses.add(typedResponse); @@ -558,125 +463,125 @@ public static List getIsPorterAvaila return responses; } - public static IsPorterAvailableStatusUpdateEventResponse getIsPorterAvailableStatusUpdateEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(ISPORTERAVAILABLESTATUSUPDATE_EVENT, log); - IsPorterAvailableStatusUpdateEventResponse typedResponse = new IsPorterAvailableStatusUpdateEventResponse(); + public static IZkSync.IsPorterAvailableStatusUpdateEventResponse getIsPorterAvailableStatusUpdateEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(ISPORTERAVAILABLESTATUSUPDATE_EVENT, log); + IZkSync.IsPorterAvailableStatusUpdateEventResponse typedResponse = new IZkSync.IsPorterAvailableStatusUpdateEventResponse(); typedResponse.log = log; typedResponse.isPorterAvailable = (Boolean) eventValues.getNonIndexedValues().get(0).getValue(); return typedResponse; } - public Flowable isPorterAvailableStatusUpdateEventFlowable(EthFilter filter) { + public Flowable isPorterAvailableStatusUpdateEventFlowable(EthFilter filter) { return web3j.ethLogFlowable(filter).map(log -> getIsPorterAvailableStatusUpdateEventFromLog(log)); } - public Flowable isPorterAvailableStatusUpdateEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable isPorterAvailableStatusUpdateEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(ISPORTERAVAILABLESTATUSUPDATE_EVENT)); return isPorterAvailableStatusUpdateEventFlowable(filter); } - public static List getNewGovernorEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(NEWGOVERNOR_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - NewGovernorEventResponse typedResponse = new NewGovernorEventResponse(); + public static List getNewAdminEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(NEWADMIN_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + IZkSync.NewAdminEventResponse typedResponse = new IZkSync.NewAdminEventResponse(); typedResponse.log = eventValues.getLog(); - typedResponse.oldGovernor = (String) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.newGovernor = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.oldAdmin = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.newAdmin = (String) eventValues.getIndexedValues().get(1).getValue(); responses.add(typedResponse); } return responses; } - public static NewGovernorEventResponse getNewGovernorEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWGOVERNOR_EVENT, log); - NewGovernorEventResponse typedResponse = new NewGovernorEventResponse(); + public static IZkSync.NewAdminEventResponse getNewAdminEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWADMIN_EVENT, log); + IZkSync.NewAdminEventResponse typedResponse = new IZkSync.NewAdminEventResponse(); typedResponse.log = log; - typedResponse.oldGovernor = (String) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.newGovernor = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.oldAdmin = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.newAdmin = (String) eventValues.getIndexedValues().get(1).getValue(); return typedResponse; } - public Flowable newGovernorEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(log -> getNewGovernorEventFromLog(log)); + public Flowable newAdminEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getNewAdminEventFromLog(log)); } - public Flowable newGovernorEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable newAdminEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); - filter.addSingleTopic(EventEncoder.encode(NEWGOVERNOR_EVENT)); - return newGovernorEventFlowable(filter); + filter.addSingleTopic(EventEncoder.encode(NEWADMIN_EVENT)); + return newAdminEventFlowable(filter); } - public static List getNewL2BootloaderBytecodeHashEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(NEWL2BOOTLOADERBYTECODEHASH_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - NewL2BootloaderBytecodeHashEventResponse typedResponse = new NewL2BootloaderBytecodeHashEventResponse(); + public static List getNewGovernorEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(NEWGOVERNOR_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + IZkSync.NewGovernorEventResponse typedResponse = new IZkSync.NewGovernorEventResponse(); typedResponse.log = eventValues.getLog(); - typedResponse.previousBytecodeHash = (byte[]) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.newBytecodeHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.oldGovernor = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.newGovernor = (String) eventValues.getIndexedValues().get(1).getValue(); responses.add(typedResponse); } return responses; } - public static NewL2BootloaderBytecodeHashEventResponse getNewL2BootloaderBytecodeHashEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWL2BOOTLOADERBYTECODEHASH_EVENT, log); - NewL2BootloaderBytecodeHashEventResponse typedResponse = new NewL2BootloaderBytecodeHashEventResponse(); + public static IZkSync.NewGovernorEventResponse getNewGovernorEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWGOVERNOR_EVENT, log); + IZkSync.NewGovernorEventResponse typedResponse = new IZkSync.NewGovernorEventResponse(); typedResponse.log = log; - typedResponse.previousBytecodeHash = (byte[]) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.newBytecodeHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.oldGovernor = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.newGovernor = (String) eventValues.getIndexedValues().get(1).getValue(); return typedResponse; } - public Flowable newL2BootloaderBytecodeHashEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(log -> getNewL2BootloaderBytecodeHashEventFromLog(log)); + public Flowable newGovernorEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getNewGovernorEventFromLog(log)); } - public Flowable newL2BootloaderBytecodeHashEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable newGovernorEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); - filter.addSingleTopic(EventEncoder.encode(NEWL2BOOTLOADERBYTECODEHASH_EVENT)); - return newL2BootloaderBytecodeHashEventFlowable(filter); + filter.addSingleTopic(EventEncoder.encode(NEWGOVERNOR_EVENT)); + return newGovernorEventFlowable(filter); } - public static List getNewL2DefaultAccountBytecodeHashEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(NEWL2DEFAULTACCOUNTBYTECODEHASH_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - NewL2DefaultAccountBytecodeHashEventResponse typedResponse = new NewL2DefaultAccountBytecodeHashEventResponse(); + public static List getNewPendingAdminEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(NEWPENDINGADMIN_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + IZkSync.NewPendingAdminEventResponse typedResponse = new IZkSync.NewPendingAdminEventResponse(); typedResponse.log = eventValues.getLog(); - typedResponse.previousBytecodeHash = (byte[]) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.newBytecodeHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.oldPendingAdmin = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.newPendingAdmin = (String) eventValues.getIndexedValues().get(1).getValue(); responses.add(typedResponse); } return responses; } - public static NewL2DefaultAccountBytecodeHashEventResponse getNewL2DefaultAccountBytecodeHashEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWL2DEFAULTACCOUNTBYTECODEHASH_EVENT, log); - NewL2DefaultAccountBytecodeHashEventResponse typedResponse = new NewL2DefaultAccountBytecodeHashEventResponse(); + public static IZkSync.NewPendingAdminEventResponse getNewPendingAdminEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWPENDINGADMIN_EVENT, log); + IZkSync.NewPendingAdminEventResponse typedResponse = new IZkSync.NewPendingAdminEventResponse(); typedResponse.log = log; - typedResponse.previousBytecodeHash = (byte[]) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.newBytecodeHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.oldPendingAdmin = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.newPendingAdmin = (String) eventValues.getIndexedValues().get(1).getValue(); return typedResponse; } - public Flowable newL2DefaultAccountBytecodeHashEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(log -> getNewL2DefaultAccountBytecodeHashEventFromLog(log)); + public Flowable newPendingAdminEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getNewPendingAdminEventFromLog(log)); } - public Flowable newL2DefaultAccountBytecodeHashEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable newPendingAdminEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); - filter.addSingleTopic(EventEncoder.encode(NEWL2DEFAULTACCOUNTBYTECODEHASH_EVENT)); - return newL2DefaultAccountBytecodeHashEventFlowable(filter); + filter.addSingleTopic(EventEncoder.encode(NEWPENDINGADMIN_EVENT)); + return newPendingAdminEventFlowable(filter); } - public static List getNewPendingGovernorEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(NEWPENDINGGOVERNOR_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - NewPendingGovernorEventResponse typedResponse = new NewPendingGovernorEventResponse(); + public static List getNewPendingGovernorEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(NEWPENDINGGOVERNOR_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + IZkSync.NewPendingGovernorEventResponse typedResponse = new IZkSync.NewPendingGovernorEventResponse(); typedResponse.log = eventValues.getLog(); typedResponse.oldPendingGovernor = (String) eventValues.getIndexedValues().get(0).getValue(); typedResponse.newPendingGovernor = (String) eventValues.getIndexedValues().get(1).getValue(); @@ -685,68 +590,68 @@ public static List getNewPendingGovernorEvents( return responses; } - public static NewPendingGovernorEventResponse getNewPendingGovernorEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWPENDINGGOVERNOR_EVENT, log); - NewPendingGovernorEventResponse typedResponse = new NewPendingGovernorEventResponse(); + public static IZkSync.NewPendingGovernorEventResponse getNewPendingGovernorEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWPENDINGGOVERNOR_EVENT, log); + IZkSync.NewPendingGovernorEventResponse typedResponse = new IZkSync.NewPendingGovernorEventResponse(); typedResponse.log = log; typedResponse.oldPendingGovernor = (String) eventValues.getIndexedValues().get(0).getValue(); typedResponse.newPendingGovernor = (String) eventValues.getIndexedValues().get(1).getValue(); return typedResponse; } - public Flowable newPendingGovernorEventFlowable(EthFilter filter) { + public Flowable newPendingGovernorEventFlowable(EthFilter filter) { return web3j.ethLogFlowable(filter).map(log -> getNewPendingGovernorEventFromLog(log)); } - public Flowable newPendingGovernorEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable newPendingGovernorEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(NEWPENDINGGOVERNOR_EVENT)); return newPendingGovernorEventFlowable(filter); } - public static List getNewPriorityRequestEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(NEWPRIORITYREQUEST_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - NewPriorityRequestEventResponse typedResponse = new NewPriorityRequestEventResponse(); + public static List getNewPriorityRequestEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(NEWPRIORITYREQUEST_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + IZkSync.NewPriorityRequestEventResponse typedResponse = new IZkSync.NewPriorityRequestEventResponse(); typedResponse.log = eventValues.getLog(); typedResponse.txId = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); typedResponse.txHash = (byte[]) eventValues.getNonIndexedValues().get(1).getValue(); typedResponse.expirationTimestamp = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); - typedResponse.transaction = (L2CanonicalTransaction) eventValues.getNonIndexedValues().get(3); + typedResponse.transaction = (IZkSync.L2CanonicalTransaction) eventValues.getNonIndexedValues().get(3); typedResponse.factoryDeps = (List) ((Array) eventValues.getNonIndexedValues().get(4)).getNativeValueCopy(); responses.add(typedResponse); } return responses; } - public static NewPriorityRequestEventResponse getNewPriorityRequestEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWPRIORITYREQUEST_EVENT, log); - NewPriorityRequestEventResponse typedResponse = new NewPriorityRequestEventResponse(); + public static IZkSync.NewPriorityRequestEventResponse getNewPriorityRequestEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWPRIORITYREQUEST_EVENT, log); + IZkSync.NewPriorityRequestEventResponse typedResponse = new IZkSync.NewPriorityRequestEventResponse(); typedResponse.log = log; typedResponse.txId = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); typedResponse.txHash = (byte[]) eventValues.getNonIndexedValues().get(1).getValue(); typedResponse.expirationTimestamp = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); - typedResponse.transaction = (L2CanonicalTransaction) eventValues.getNonIndexedValues().get(3); + typedResponse.transaction = (IZkSync.L2CanonicalTransaction) eventValues.getNonIndexedValues().get(3); typedResponse.factoryDeps = (List) ((Array) eventValues.getNonIndexedValues().get(4)).getNativeValueCopy(); return typedResponse; } - public Flowable newPriorityRequestEventFlowable(EthFilter filter) { + public Flowable newPriorityRequestEventFlowable(EthFilter filter) { return web3j.ethLogFlowable(filter).map(log -> getNewPriorityRequestEventFromLog(log)); } - public Flowable newPriorityRequestEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable newPriorityRequestEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(NEWPRIORITYREQUEST_EVENT)); return newPriorityRequestEventFlowable(filter); } - public static List getNewPriorityTxMaxGasLimitEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(NEWPRIORITYTXMAXGASLIMIT_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - NewPriorityTxMaxGasLimitEventResponse typedResponse = new NewPriorityTxMaxGasLimitEventResponse(); + public static List getNewPriorityTxMaxGasLimitEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(NEWPRIORITYTXMAXGASLIMIT_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + IZkSync.NewPriorityTxMaxGasLimitEventResponse typedResponse = new IZkSync.NewPriorityTxMaxGasLimitEventResponse(); typedResponse.log = eventValues.getLog(); typedResponse.oldPriorityTxMaxGasLimit = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); typedResponse.newPriorityTxMaxGasLimit = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); @@ -755,220 +660,58 @@ public static List getNewPriorityTxMaxGas return responses; } - public static NewPriorityTxMaxGasLimitEventResponse getNewPriorityTxMaxGasLimitEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWPRIORITYTXMAXGASLIMIT_EVENT, log); - NewPriorityTxMaxGasLimitEventResponse typedResponse = new NewPriorityTxMaxGasLimitEventResponse(); + public static IZkSync.NewPriorityTxMaxGasLimitEventResponse getNewPriorityTxMaxGasLimitEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWPRIORITYTXMAXGASLIMIT_EVENT, log); + IZkSync.NewPriorityTxMaxGasLimitEventResponse typedResponse = new IZkSync.NewPriorityTxMaxGasLimitEventResponse(); typedResponse.log = log; typedResponse.oldPriorityTxMaxGasLimit = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); typedResponse.newPriorityTxMaxGasLimit = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); return typedResponse; } - public Flowable newPriorityTxMaxGasLimitEventFlowable(EthFilter filter) { + public Flowable newPriorityTxMaxGasLimitEventFlowable(EthFilter filter) { return web3j.ethLogFlowable(filter).map(log -> getNewPriorityTxMaxGasLimitEventFromLog(log)); } - public Flowable newPriorityTxMaxGasLimitEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable newPriorityTxMaxGasLimitEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(NEWPRIORITYTXMAXGASLIMIT_EVENT)); return newPriorityTxMaxGasLimitEventFlowable(filter); } - public static List getNewVerifierEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(NEWVERIFIER_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - NewVerifierEventResponse typedResponse = new NewVerifierEventResponse(); - typedResponse.log = eventValues.getLog(); - typedResponse.oldVerifier = (String) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.newVerifier = (String) eventValues.getIndexedValues().get(1).getValue(); - responses.add(typedResponse); - } - return responses; - } - - public static NewVerifierEventResponse getNewVerifierEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWVERIFIER_EVENT, log); - NewVerifierEventResponse typedResponse = new NewVerifierEventResponse(); - typedResponse.log = log; - typedResponse.oldVerifier = (String) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.newVerifier = (String) eventValues.getIndexedValues().get(1).getValue(); - return typedResponse; - } - - public Flowable newVerifierEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(log -> getNewVerifierEventFromLog(log)); - } - - public Flowable newVerifierEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { - EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); - filter.addSingleTopic(EventEncoder.encode(NEWVERIFIER_EVENT)); - return newVerifierEventFlowable(filter); - } - - public static List getNewVerifierParamsEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(NEWVERIFIERPARAMS_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - NewVerifierParamsEventResponse typedResponse = new NewVerifierParamsEventResponse(); - typedResponse.log = eventValues.getLog(); - typedResponse.oldVerifierParams = (VerifierParams) eventValues.getNonIndexedValues().get(0); - typedResponse.newVerifierParams = (VerifierParams) eventValues.getNonIndexedValues().get(1); - responses.add(typedResponse); - } - return responses; - } - - public static NewVerifierParamsEventResponse getNewVerifierParamsEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(NEWVERIFIERPARAMS_EVENT, log); - NewVerifierParamsEventResponse typedResponse = new NewVerifierParamsEventResponse(); - typedResponse.log = log; - typedResponse.oldVerifierParams = (VerifierParams) eventValues.getNonIndexedValues().get(0); - typedResponse.newVerifierParams = (VerifierParams) eventValues.getNonIndexedValues().get(1); - return typedResponse; - } - - public Flowable newVerifierParamsEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(log -> getNewVerifierParamsEventFromLog(log)); - } - - public Flowable newVerifierParamsEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { - EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); - filter.addSingleTopic(EventEncoder.encode(NEWVERIFIERPARAMS_EVENT)); - return newVerifierParamsEventFlowable(filter); - } - - public static List getProposeShadowUpgradeEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(PROPOSESHADOWUPGRADE_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - ProposeShadowUpgradeEventResponse typedResponse = new ProposeShadowUpgradeEventResponse(); - typedResponse.log = eventValues.getLog(); - typedResponse.proposalId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.proposalHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); - responses.add(typedResponse); - } - return responses; - } - - public static ProposeShadowUpgradeEventResponse getProposeShadowUpgradeEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(PROPOSESHADOWUPGRADE_EVENT, log); - ProposeShadowUpgradeEventResponse typedResponse = new ProposeShadowUpgradeEventResponse(); - typedResponse.log = log; - typedResponse.proposalId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.proposalHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); - return typedResponse; - } - - public Flowable proposeShadowUpgradeEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(log -> getProposeShadowUpgradeEventFromLog(log)); - } - - public Flowable proposeShadowUpgradeEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { - EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); - filter.addSingleTopic(EventEncoder.encode(PROPOSESHADOWUPGRADE_EVENT)); - return proposeShadowUpgradeEventFlowable(filter); - } - - public static List getProposeTransparentUpgradeEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(PROPOSETRANSPARENTUPGRADE_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - ProposeTransparentUpgradeEventResponse typedResponse = new ProposeTransparentUpgradeEventResponse(); - typedResponse.log = eventValues.getLog(); - typedResponse.proposalId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.diamondCut = (DiamondCutData) eventValues.getNonIndexedValues().get(0); - typedResponse.proposalSalt = (byte[]) eventValues.getNonIndexedValues().get(1).getValue(); - responses.add(typedResponse); - } - return responses; - } - - public static ProposeTransparentUpgradeEventResponse getProposeTransparentUpgradeEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(PROPOSETRANSPARENTUPGRADE_EVENT, log); - ProposeTransparentUpgradeEventResponse typedResponse = new ProposeTransparentUpgradeEventResponse(); - typedResponse.log = log; - typedResponse.proposalId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.diamondCut = (DiamondCutData) eventValues.getNonIndexedValues().get(0); - typedResponse.proposalSalt = (byte[]) eventValues.getNonIndexedValues().get(1).getValue(); - return typedResponse; - } - - public Flowable proposeTransparentUpgradeEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(log -> getProposeTransparentUpgradeEventFromLog(log)); - } - - public Flowable proposeTransparentUpgradeEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { - EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); - filter.addSingleTopic(EventEncoder.encode(PROPOSETRANSPARENTUPGRADE_EVENT)); - return proposeTransparentUpgradeEventFlowable(filter); - } - - public static List getSecurityCouncilUpgradeApproveEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(SECURITYCOUNCILUPGRADEAPPROVE_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - SecurityCouncilUpgradeApproveEventResponse typedResponse = new SecurityCouncilUpgradeApproveEventResponse(); - typedResponse.log = eventValues.getLog(); - typedResponse.proposalId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.proposalHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); - responses.add(typedResponse); - } - return responses; - } - - public static SecurityCouncilUpgradeApproveEventResponse getSecurityCouncilUpgradeApproveEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(SECURITYCOUNCILUPGRADEAPPROVE_EVENT, log); - SecurityCouncilUpgradeApproveEventResponse typedResponse = new SecurityCouncilUpgradeApproveEventResponse(); - typedResponse.log = log; - typedResponse.proposalId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.proposalHash = (byte[]) eventValues.getIndexedValues().get(1).getValue(); - return typedResponse; - } - - public Flowable securityCouncilUpgradeApproveEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(log -> getSecurityCouncilUpgradeApproveEventFromLog(log)); - } - - public Flowable securityCouncilUpgradeApproveEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { - EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); - filter.addSingleTopic(EventEncoder.encode(SECURITYCOUNCILUPGRADEAPPROVE_EVENT)); - return securityCouncilUpgradeApproveEventFlowable(filter); - } - - public static List getUnfreezeEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(UNFREEZE_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - UnfreezeEventResponse typedResponse = new UnfreezeEventResponse(); + public static List getUnfreezeEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(UNFREEZE_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + IZkSync.UnfreezeEventResponse typedResponse = new IZkSync.UnfreezeEventResponse(); typedResponse.log = eventValues.getLog(); responses.add(typedResponse); } return responses; } - public static UnfreezeEventResponse getUnfreezeEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(UNFREEZE_EVENT, log); - UnfreezeEventResponse typedResponse = new UnfreezeEventResponse(); + public static IZkSync.UnfreezeEventResponse getUnfreezeEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(UNFREEZE_EVENT, log); + IZkSync.UnfreezeEventResponse typedResponse = new IZkSync.UnfreezeEventResponse(); typedResponse.log = log; return typedResponse; } - public Flowable unfreezeEventFlowable(EthFilter filter) { + public Flowable unfreezeEventFlowable(EthFilter filter) { return web3j.ethLogFlowable(filter).map(log -> getUnfreezeEventFromLog(log)); } - public Flowable unfreezeEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable unfreezeEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(UNFREEZE_EVENT)); return unfreezeEventFlowable(filter); } - public static List getValidatorStatusUpdateEvents(TransactionReceipt transactionReceipt) { - List valueList = staticExtractEventParametersWithLog(VALIDATORSTATUSUPDATE_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); - for (Contract.EventValuesWithLog eventValues : valueList) { - ValidatorStatusUpdateEventResponse typedResponse = new ValidatorStatusUpdateEventResponse(); + public static List getValidatorStatusUpdateEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(VALIDATORSTATUSUPDATE_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + IZkSync.ValidatorStatusUpdateEventResponse typedResponse = new IZkSync.ValidatorStatusUpdateEventResponse(); typedResponse.log = eventValues.getLog(); typedResponse.validatorAddress = (String) eventValues.getIndexedValues().get(0).getValue(); typedResponse.isActive = (Boolean) eventValues.getNonIndexedValues().get(0).getValue(); @@ -977,70 +720,69 @@ public static List getValidatorStatusUpdateE return responses; } - public static ValidatorStatusUpdateEventResponse getValidatorStatusUpdateEventFromLog(Log log) { - Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(VALIDATORSTATUSUPDATE_EVENT, log); - ValidatorStatusUpdateEventResponse typedResponse = new ValidatorStatusUpdateEventResponse(); + public static IZkSync.ValidatorStatusUpdateEventResponse getValidatorStatusUpdateEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(VALIDATORSTATUSUPDATE_EVENT, log); + IZkSync.ValidatorStatusUpdateEventResponse typedResponse = new IZkSync.ValidatorStatusUpdateEventResponse(); typedResponse.log = log; typedResponse.validatorAddress = (String) eventValues.getIndexedValues().get(0).getValue(); typedResponse.isActive = (Boolean) eventValues.getNonIndexedValues().get(0).getValue(); return typedResponse; } - public Flowable validatorStatusUpdateEventFlowable(EthFilter filter) { + public Flowable validatorStatusUpdateEventFlowable(EthFilter filter) { return web3j.ethLogFlowable(filter).map(log -> getValidatorStatusUpdateEventFromLog(log)); } - public Flowable validatorStatusUpdateEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable validatorStatusUpdateEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(VALIDATORSTATUSUPDATE_EVENT)); return validatorStatusUpdateEventFlowable(filter); } - public RemoteFunctionCall acceptGovernor() { + public RemoteFunctionCall acceptAdmin() { final Function function = new Function( - FUNC_ACCEPTGOVERNOR, + FUNC_ACCEPTADMIN, Arrays.asList(), Collections.>emptyList()); return executeRemoteCallTransaction(function); } - public RemoteFunctionCall cancelUpgradeProposal(byte[] _proposedUpgradeHash) { + public RemoteFunctionCall acceptGovernor() { final Function function = new Function( - FUNC_CANCELUPGRADEPROPOSAL, - Arrays.asList(new org.web3j.abi.datatypes.generated.Bytes32(_proposedUpgradeHash)), + FUNC_ACCEPTGOVERNOR, + Arrays.asList(), Collections.>emptyList()); return executeRemoteCallTransaction(function); } - public RemoteFunctionCall commitBlocks(StoredBlockInfo _lastCommittedBlockData, List _newBlocksData) { + public RemoteFunctionCall commitBatches(IZkSync.StoredBatchInfo _lastCommittedBatchData, List _newBatchesData) { final Function function = new Function( - FUNC_COMMITBLOCKS, - Arrays.asList(_lastCommittedBlockData, - new org.web3j.abi.datatypes.DynamicArray(CommitBlockInfo.class, _newBlocksData)), + FUNC_COMMITBATCHES, + Arrays.asList(_lastCommittedBatchData, + new DynamicArray(IZkSync.CommitBatchInfo.class, _newBatchesData)), Collections.>emptyList()); return executeRemoteCallTransaction(function); } - public RemoteFunctionCall executeBlocks(List _blocksData) { + public RemoteFunctionCall executeBatches(List _batchesData) { final Function function = new Function( - FUNC_EXECUTEBLOCKS, - Arrays.asList(new org.web3j.abi.datatypes.DynamicArray(StoredBlockInfo.class, _blocksData)), + FUNC_EXECUTEBATCHES, + Arrays.asList(new DynamicArray(IZkSync.StoredBatchInfo.class, _batchesData)), Collections.>emptyList()); return executeRemoteCallTransaction(function); } - public RemoteFunctionCall executeUpgrade(DiamondCutData _diamondCut, byte[] _proposalSalt) { + public RemoteFunctionCall executeUpgrade(IZkSync.DiamondCutData _diamondCut) { final Function function = new Function( FUNC_EXECUTEUPGRADE, - Arrays.asList(_diamondCut, - new org.web3j.abi.datatypes.generated.Bytes32(_proposalSalt)), + Arrays.asList(_diamondCut), Collections.>emptyList()); return executeRemoteCallTransaction(function); } public RemoteFunctionCall facetAddress(byte[] _selector) { final Function function = new Function(FUNC_FACETADDRESS, - Arrays.asList(new org.web3j.abi.datatypes.generated.Bytes4(_selector)), + Arrays.asList(new Bytes4(_selector)), Arrays.>asList(new TypeReference
() {})); return executeRemoteCallSingleValueReturn(function, String.class); } @@ -1062,7 +804,7 @@ public List call() throws Exception { public RemoteFunctionCall facetFunctionSelectors(String _facet) { final Function function = new Function(FUNC_FACETFUNCTIONSELECTORS, - Arrays.asList(new org.web3j.abi.datatypes.Address(_facet)), + Arrays.asList(new Address(160, _facet)), Arrays.>asList(new TypeReference>() {})); return new RemoteFunctionCall(function, new Callable() { @@ -1078,7 +820,7 @@ public List call() throws Exception { public RemoteFunctionCall facets() { final Function function = new Function(FUNC_FACETS, Arrays.asList(), - Arrays.>asList(new TypeReference>() {})); + Arrays.>asList(new TypeReference>() {})); return new RemoteFunctionCall(function, new Callable() { @Override @@ -1090,16 +832,16 @@ public List call() throws Exception { }); } - public RemoteFunctionCall finalizeEthWithdrawal(BigInteger _l2BlockNumber, BigInteger _l2MessageIndex, BigInteger _l2TxNumberInBlock, byte[] _message, List _merkleProof) { + public RemoteFunctionCall finalizeEthWithdrawal(BigInteger _l2BatchNumber, BigInteger _l2MessageIndex, BigInteger _l2TxNumberInBatch, byte[] _message, List _merkleProof) { final Function function = new Function( FUNC_FINALIZEETHWITHDRAWAL, - Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(_l2BlockNumber), - new org.web3j.abi.datatypes.generated.Uint256(_l2MessageIndex), - new org.web3j.abi.datatypes.generated.Uint16(_l2TxNumberInBlock), - new org.web3j.abi.datatypes.DynamicBytes(_message), - new org.web3j.abi.datatypes.DynamicArray( - org.web3j.abi.datatypes.generated.Bytes32.class, - org.web3j.abi.Utils.typeMap(_merkleProof, org.web3j.abi.datatypes.generated.Bytes32.class))), + Arrays.asList(new Uint256(_l2BatchNumber), + new Uint256(_l2MessageIndex), + new Uint16(_l2TxNumberInBatch), + new DynamicBytes(_message), + new DynamicArray( + Bytes32.class, + org.web3j.abi.Utils.typeMap(_merkleProof, Bytes32.class))), Collections.>emptyList()); return executeRemoteCallTransaction(function); } @@ -1112,13 +854,6 @@ public RemoteFunctionCall freezeDiamond() { return executeRemoteCallTransaction(function); } - public RemoteFunctionCall getCurrentProposalId() { - final Function function = new Function(FUNC_GETCURRENTPROPOSALID, - Arrays.asList(), - Arrays.>asList(new TypeReference() {})); - return executeRemoteCallSingleValueReturn(function, BigInteger.class); - } - public RemoteFunctionCall getFirstUnprocessedPriorityTx() { final Function function = new Function(FUNC_GETFIRSTUNPROCESSEDPRIORITYTX, Arrays.asList(), @@ -1147,6 +882,27 @@ public RemoteFunctionCall getL2DefaultAccountBytecodeHash() { return executeRemoteCallSingleValueReturn(function, byte[].class); } + public RemoteFunctionCall getL2SystemContractsUpgradeBatchNumber() { + final Function function = new Function(FUNC_GETL2SYSTEMCONTRACTSUPGRADEBATCHNUMBER, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall getL2SystemContractsUpgradeTxHash() { + final Function function = new Function(FUNC_GETL2SYSTEMCONTRACTSUPGRADETXHASH, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, byte[].class); + } + + public RemoteFunctionCall getName() { + final Function function = new Function(FUNC_GETNAME, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + public RemoteFunctionCall getPendingGovernor() { final Function function = new Function(FUNC_GETPENDINGGOVERNOR, Arrays.asList(), @@ -1161,43 +917,36 @@ public RemoteFunctionCall getPriorityQueueSize() { return executeRemoteCallSingleValueReturn(function, BigInteger.class); } - public RemoteFunctionCall getProposedUpgradeHash() { - final Function function = new Function(FUNC_GETPROPOSEDUPGRADEHASH, - Arrays.asList(), - Arrays.>asList(new TypeReference() {})); - return executeRemoteCallSingleValueReturn(function, byte[].class); - } - - public RemoteFunctionCall getProposedUpgradeTimestamp() { - final Function function = new Function(FUNC_GETPROPOSEDUPGRADETIMESTAMP, + public RemoteFunctionCall getPriorityTxMaxGasLimit() { + final Function function = new Function(FUNC_GETPRIORITYTXMAXGASLIMIT, Arrays.asList(), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, BigInteger.class); } - public RemoteFunctionCall getSecurityCouncil() { - final Function function = new Function(FUNC_GETSECURITYCOUNCIL, + public RemoteFunctionCall getProtocolVersion() { + final Function function = new Function(FUNC_GETPROTOCOLVERSION, Arrays.asList(), - Arrays.>asList(new TypeReference
() {})); - return executeRemoteCallSingleValueReturn(function, String.class); + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); } - public RemoteFunctionCall getTotalBlocksCommitted() { - final Function function = new Function(FUNC_GETTOTALBLOCKSCOMMITTED, + public RemoteFunctionCall getTotalBatchesCommitted() { + final Function function = new Function(FUNC_GETTOTALBATCHESCOMMITTED, Arrays.asList(), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, BigInteger.class); } - public RemoteFunctionCall getTotalBlocksExecuted() { - final Function function = new Function(FUNC_GETTOTALBLOCKSEXECUTED, + public RemoteFunctionCall getTotalBatchesExecuted() { + final Function function = new Function(FUNC_GETTOTALBATCHESEXECUTED, Arrays.asList(), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, BigInteger.class); } - public RemoteFunctionCall getTotalBlocksVerified() { - final Function function = new Function(FUNC_GETTOTALBLOCKSVERIFIED, + public RemoteFunctionCall getTotalBatchesVerified() { + final Function function = new Function(FUNC_GETTOTALBATCHESVERIFIED, Arrays.asList(), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, BigInteger.class); @@ -1210,13 +959,6 @@ public RemoteFunctionCall getTotalPriorityTxs() { return executeRemoteCallSingleValueReturn(function, BigInteger.class); } - public RemoteFunctionCall getUpgradeProposalState() { - final Function function = new Function(FUNC_GETUPGRADEPROPOSALSTATE, - Arrays.asList(), - Arrays.>asList(new TypeReference() {})); - return executeRemoteCallSingleValueReturn(function, BigInteger.class); - } - public RemoteFunctionCall getVerifier() { final Function function = new Function(FUNC_GETVERIFIER, Arrays.asList(), @@ -1224,25 +966,11 @@ public RemoteFunctionCall getVerifier() { return executeRemoteCallSingleValueReturn(function, String.class); } - public RemoteFunctionCall getVerifierParams() { + public RemoteFunctionCall getVerifierParams() { final Function function = new Function(FUNC_GETVERIFIERPARAMS, Arrays.asList(), - Arrays.>asList(new TypeReference() {})); - return executeRemoteCallSingleValueReturn(function, VerifierParams.class); - } - - public RemoteFunctionCall getpriorityTxMaxGasLimit() { - final Function function = new Function(FUNC_GETPRIORITYTXMAXGASLIMIT, - Arrays.asList(), - Arrays.>asList(new TypeReference() {})); - return executeRemoteCallSingleValueReturn(function, BigInteger.class); - } - - public RemoteFunctionCall isApprovedBySecurityCouncil() { - final Function function = new Function(FUNC_ISAPPROVEDBYSECURITYCOUNCIL, - Arrays.asList(), - Arrays.>asList(new TypeReference() {})); - return executeRemoteCallSingleValueReturn(function, Boolean.class); + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, IZkSync.VerifierParams.class); } public RemoteFunctionCall isDiamondStorageFrozen() { @@ -1252,120 +980,102 @@ public RemoteFunctionCall isDiamondStorageFrozen() { return executeRemoteCallSingleValueReturn(function, Boolean.class); } - public RemoteFunctionCall isEthWithdrawalFinalized(BigInteger _l2BlockNumber, BigInteger _l2MessageIndex) { + public RemoteFunctionCall isEthWithdrawalFinalized(BigInteger _l2BatchNumber, BigInteger _l2MessageIndex) { final Function function = new Function(FUNC_ISETHWITHDRAWALFINALIZED, - Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(_l2BlockNumber), - new org.web3j.abi.datatypes.generated.Uint256(_l2MessageIndex)), + Arrays.asList(new Uint256(_l2BatchNumber), + new Uint256(_l2MessageIndex)), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, Boolean.class); } public RemoteFunctionCall isFacetFreezable(String _facet) { final Function function = new Function(FUNC_ISFACETFREEZABLE, - Arrays.asList(new org.web3j.abi.datatypes.Address(_facet)), + Arrays.asList(new Address(160, _facet)), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, Boolean.class); } public RemoteFunctionCall isFunctionFreezable(byte[] _selector) { final Function function = new Function(FUNC_ISFUNCTIONFREEZABLE, - Arrays.asList(new org.web3j.abi.datatypes.generated.Bytes4(_selector)), + Arrays.asList(new Bytes4(_selector)), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, Boolean.class); } public RemoteFunctionCall isValidator(String _address) { final Function function = new Function(FUNC_ISVALIDATOR, - Arrays.asList(new org.web3j.abi.datatypes.Address(_address)), + Arrays.asList(new Address(160, _address)), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, Boolean.class); } - public RemoteFunctionCall l2LogsRootHash(BigInteger _blockNumber) { + public RemoteFunctionCall l2LogsRootHash(BigInteger _batchNumber) { final Function function = new Function(FUNC_L2LOGSROOTHASH, - Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(_blockNumber)), + Arrays.asList(new Uint256(_batchNumber)), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, byte[].class); } public RemoteFunctionCall l2TransactionBaseCost(BigInteger _gasPrice, BigInteger _l2GasLimit, BigInteger _l2GasPerPubdataByteLimit) { final Function function = new Function(FUNC_L2TRANSACTIONBASECOST, - Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(_gasPrice), - new org.web3j.abi.datatypes.generated.Uint256(_l2GasLimit), - new org.web3j.abi.datatypes.generated.Uint256(_l2GasPerPubdataByteLimit)), + Arrays.asList(new Uint256(_gasPrice), + new Uint256(_l2GasLimit), + new Uint256(_l2GasPerPubdataByteLimit)), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, BigInteger.class); } - public RemoteFunctionCall priorityQueueFrontOperation() { + public RemoteFunctionCall priorityQueueFrontOperation() { final Function function = new Function(FUNC_PRIORITYQUEUEFRONTOPERATION, Arrays.asList(), - Arrays.>asList(new TypeReference() {})); - return executeRemoteCallSingleValueReturn(function, PriorityOperation.class); - } - - public RemoteFunctionCall proposeShadowUpgrade(byte[] _proposalHash, BigInteger _proposalId) { - final Function function = new Function( - FUNC_PROPOSESHADOWUPGRADE, - Arrays.asList(new org.web3j.abi.datatypes.generated.Bytes32(_proposalHash), - new org.web3j.abi.datatypes.generated.Uint40(_proposalId)), - Collections.>emptyList()); - return executeRemoteCallTransaction(function); - } - - public RemoteFunctionCall proposeTransparentUpgrade(DiamondCutData _diamondCut, BigInteger _proposalId) { - final Function function = new Function( - FUNC_PROPOSETRANSPARENTUPGRADE, - Arrays.asList(_diamondCut, - new org.web3j.abi.datatypes.generated.Uint40(_proposalId)), - Collections.>emptyList()); - return executeRemoteCallTransaction(function); + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, IZkSync.PriorityOperation.class); } - public RemoteFunctionCall proveBlocks(StoredBlockInfo _prevBlock, List _committedBlocks, ProofInput _proof) { + public RemoteFunctionCall proveBatches(IZkSync.StoredBatchInfo _prevBatch, List _committedBatches, IZkSync.ProofInput _proof) { final Function function = new Function( - FUNC_PROVEBLOCKS, - Arrays.asList(_prevBlock, - new org.web3j.abi.datatypes.DynamicArray(StoredBlockInfo.class, _committedBlocks), + FUNC_PROVEBATCHES, + Arrays.asList(_prevBatch, + new DynamicArray(IZkSync.StoredBatchInfo.class, _committedBatches), _proof), Collections.>emptyList()); return executeRemoteCallTransaction(function); } - public RemoteFunctionCall proveL1ToL2TransactionStatus(byte[] _l2TxHash, BigInteger _l2BlockNumber, BigInteger _l2MessageIndex, BigInteger _l2TxNumberInBlock, List _merkleProof, BigInteger _status) { + public RemoteFunctionCall proveL1ToL2TransactionStatus(byte[] _l2TxHash, BigInteger _l2BatchNumber, BigInteger _l2MessageIndex, BigInteger _l2TxNumberInBatch, List _merkleProof, BigInteger _status) { final Function function = new Function(FUNC_PROVEL1TOL2TRANSACTIONSTATUS, - Arrays.asList(new org.web3j.abi.datatypes.generated.Bytes32(_l2TxHash), - new org.web3j.abi.datatypes.generated.Uint256(_l2BlockNumber), - new org.web3j.abi.datatypes.generated.Uint256(_l2MessageIndex), - new org.web3j.abi.datatypes.generated.Uint16(_l2TxNumberInBlock), - new org.web3j.abi.datatypes.DynamicArray( - org.web3j.abi.datatypes.generated.Bytes32.class, - org.web3j.abi.Utils.typeMap(_merkleProof, org.web3j.abi.datatypes.generated.Bytes32.class)), - new org.web3j.abi.datatypes.generated.Uint8(_status)), + Arrays.asList(new Bytes32(_l2TxHash), + new Uint256(_l2BatchNumber), + new Uint256(_l2MessageIndex), + new Uint16(_l2TxNumberInBatch), + new DynamicArray( + Bytes32.class, + org.web3j.abi.Utils.typeMap(_merkleProof, Bytes32.class)), + new Uint8(_status)), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, Boolean.class); } - public RemoteFunctionCall proveL2LogInclusion(BigInteger _blockNumber, BigInteger _index, L2Log _log, List _proof) { + public RemoteFunctionCall proveL2LogInclusion(BigInteger _l2BatchNumber, BigInteger _index, IZkSync.L2Log _log, List _proof) { final Function function = new Function(FUNC_PROVEL2LOGINCLUSION, - Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(_blockNumber), - new org.web3j.abi.datatypes.generated.Uint256(_index), + Arrays.asList(new Uint256(_l2BatchNumber), + new Uint256(_index), _log, - new org.web3j.abi.datatypes.DynamicArray( - org.web3j.abi.datatypes.generated.Bytes32.class, - org.web3j.abi.Utils.typeMap(_proof, org.web3j.abi.datatypes.generated.Bytes32.class))), + new DynamicArray( + Bytes32.class, + org.web3j.abi.Utils.typeMap(_proof, Bytes32.class))), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, Boolean.class); } - public RemoteFunctionCall proveL2MessageInclusion(BigInteger _blockNumber, BigInteger _index, L2Message _message, List _proof) { + public RemoteFunctionCall proveL2MessageInclusion(BigInteger _l2BatchNumber, BigInteger _index, IZkSync.L2Message _message, List _proof) { final Function function = new Function(FUNC_PROVEL2MESSAGEINCLUSION, - Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(_blockNumber), - new org.web3j.abi.datatypes.generated.Uint256(_index), + Arrays.asList(new Uint256(_l2BatchNumber), + new Uint256(_index), _message, - new org.web3j.abi.datatypes.DynamicArray( - org.web3j.abi.datatypes.generated.Bytes32.class, - org.web3j.abi.Utils.typeMap(_proof, org.web3j.abi.datatypes.generated.Bytes32.class))), + new DynamicArray( + Bytes32.class, + org.web3j.abi.Utils.typeMap(_proof, Bytes32.class))), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, Boolean.class); } @@ -1373,65 +1083,31 @@ public RemoteFunctionCall proveL2MessageInclusion(BigInteger _blockNumb public RemoteFunctionCall requestL2Transaction(String _contractL2, BigInteger _l2Value, byte[] _calldata, BigInteger _l2GasLimit, BigInteger _l2GasPerPubdataByteLimit, List _factoryDeps, String _refundRecipient, BigInteger weiValue) { final Function function = new Function( FUNC_REQUESTL2TRANSACTION, - Arrays.asList(new org.web3j.abi.datatypes.Address(_contractL2), - new org.web3j.abi.datatypes.generated.Uint256(_l2Value), - new org.web3j.abi.datatypes.DynamicBytes(_calldata), - new org.web3j.abi.datatypes.generated.Uint256(_l2GasLimit), - new org.web3j.abi.datatypes.generated.Uint256(_l2GasPerPubdataByteLimit), - new org.web3j.abi.datatypes.DynamicArray( - org.web3j.abi.datatypes.DynamicBytes.class, - org.web3j.abi.Utils.typeMap(_factoryDeps, org.web3j.abi.datatypes.DynamicBytes.class)), - new org.web3j.abi.datatypes.Address(_refundRecipient)), + Arrays.asList(new Address(160, _contractL2), + new Uint256(_l2Value), + new DynamicBytes(_calldata), + new Uint256(_l2GasLimit), + new Uint256(_l2GasPerPubdataByteLimit), + new DynamicArray( + DynamicBytes.class, + org.web3j.abi.Utils.typeMap(_factoryDeps, DynamicBytes.class)), + new Address(160, _refundRecipient)), Collections.>emptyList()); return executeRemoteCallTransaction(function, weiValue); } - public RemoteFunctionCall revertBlocks(BigInteger _newLastBlock) { - final Function function = new Function( - FUNC_REVERTBLOCKS, - Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(_newLastBlock)), - Collections.>emptyList()); - return executeRemoteCallTransaction(function); - } - - public RemoteFunctionCall securityCouncilUpgradeApprove(byte[] _upgradeProposalHash) { - final Function function = new Function( - FUNC_SECURITYCOUNCILUPGRADEAPPROVE, - Arrays.asList(new org.web3j.abi.datatypes.generated.Bytes32(_upgradeProposalHash)), - Collections.>emptyList()); - return executeRemoteCallTransaction(function); - } - - public RemoteFunctionCall serializeL2Transaction(BigInteger _txId, BigInteger _l2Value, String _sender, String _contractAddressL2, byte[] _calldata, BigInteger _l2GasLimit, BigInteger _l2GasPerPubdataByteLimit, List _factoryDeps, BigInteger _toMint, String _refundRecipient) { - final Function function = new Function(FUNC_SERIALIZEL2TRANSACTION, - Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(_txId), - new org.web3j.abi.datatypes.generated.Uint256(_l2Value), - new org.web3j.abi.datatypes.Address(_sender), - new org.web3j.abi.datatypes.Address(_contractAddressL2), - new org.web3j.abi.datatypes.DynamicBytes(_calldata), - new org.web3j.abi.datatypes.generated.Uint256(_l2GasLimit), - new org.web3j.abi.datatypes.generated.Uint256(_l2GasPerPubdataByteLimit), - new org.web3j.abi.datatypes.DynamicArray( - org.web3j.abi.datatypes.DynamicBytes.class, - org.web3j.abi.Utils.typeMap(_factoryDeps, org.web3j.abi.datatypes.DynamicBytes.class)), - new org.web3j.abi.datatypes.generated.Uint256(_toMint), - new org.web3j.abi.datatypes.Address(_refundRecipient)), - Arrays.>asList(new TypeReference() {})); - return executeRemoteCallSingleValueReturn(function, L2CanonicalTransaction.class); - } - - public RemoteFunctionCall setL2BootloaderBytecodeHash(byte[] _l2BootloaderBytecodeHash) { + public RemoteFunctionCall revertBatches(BigInteger _newLastBatch) { final Function function = new Function( - FUNC_SETL2BOOTLOADERBYTECODEHASH, - Arrays.asList(new org.web3j.abi.datatypes.generated.Bytes32(_l2BootloaderBytecodeHash)), + FUNC_REVERTBATCHES, + Arrays.asList(new Uint256(_newLastBatch)), Collections.>emptyList()); return executeRemoteCallTransaction(function); } - public RemoteFunctionCall setL2DefaultAccountBytecodeHash(byte[] _l2DefaultAccountBytecodeHash) { + public RemoteFunctionCall setPendingAdmin(String _newPendingAdmin) { final Function function = new Function( - FUNC_SETL2DEFAULTACCOUNTBYTECODEHASH, - Arrays.asList(new org.web3j.abi.datatypes.generated.Bytes32(_l2DefaultAccountBytecodeHash)), + FUNC_SETPENDINGADMIN, + Arrays.asList(new Address(160, _newPendingAdmin)), Collections.>emptyList()); return executeRemoteCallTransaction(function); } @@ -1439,7 +1115,7 @@ public RemoteFunctionCall setL2DefaultAccountBytecodeHash(by public RemoteFunctionCall setPendingGovernor(String _newPendingGovernor) { final Function function = new Function( FUNC_SETPENDINGGOVERNOR, - Arrays.asList(new org.web3j.abi.datatypes.Address(_newPendingGovernor)), + Arrays.asList(new Address(160, _newPendingGovernor)), Collections.>emptyList()); return executeRemoteCallTransaction(function); } @@ -1447,7 +1123,7 @@ public RemoteFunctionCall setPendingGovernor(String _newPend public RemoteFunctionCall setPorterAvailability(Boolean _zkPorterIsAvailable) { final Function function = new Function( FUNC_SETPORTERAVAILABILITY, - Arrays.asList(new org.web3j.abi.datatypes.Bool(_zkPorterIsAvailable)), + Arrays.asList(new Bool(_zkPorterIsAvailable)), Collections.>emptyList()); return executeRemoteCallTransaction(function); } @@ -1455,7 +1131,7 @@ public RemoteFunctionCall setPorterAvailability(Boolean _zkP public RemoteFunctionCall setPriorityTxMaxGasLimit(BigInteger _newPriorityTxMaxGasLimit) { final Function function = new Function( FUNC_SETPRIORITYTXMAXGASLIMIT, - Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(_newPriorityTxMaxGasLimit)), + Arrays.asList(new Uint256(_newPriorityTxMaxGasLimit)), Collections.>emptyList()); return executeRemoteCallTransaction(function); } @@ -1463,31 +1139,15 @@ public RemoteFunctionCall setPriorityTxMaxGasLimit(BigIntege public RemoteFunctionCall setValidator(String _validator, Boolean _active) { final Function function = new Function( FUNC_SETVALIDATOR, - Arrays.asList(new org.web3j.abi.datatypes.Address(_validator), - new org.web3j.abi.datatypes.Bool(_active)), - Collections.>emptyList()); - return executeRemoteCallTransaction(function); - } - - public RemoteFunctionCall setVerifier(String _newVerifier) { - final Function function = new Function( - FUNC_SETVERIFIER, - Arrays.asList(new org.web3j.abi.datatypes.Address(_newVerifier)), - Collections.>emptyList()); - return executeRemoteCallTransaction(function); - } - - public RemoteFunctionCall setVerifierParams(VerifierParams _newVerifierParams) { - final Function function = new Function( - FUNC_SETVERIFIERPARAMS, - Arrays.asList(_newVerifierParams), + Arrays.asList(new Address(160, _validator), + new Bool(_active)), Collections.>emptyList()); return executeRemoteCallTransaction(function); } - public RemoteFunctionCall storedBlockHash(BigInteger _blockNumber) { - final Function function = new Function(FUNC_STOREDBLOCKHASH, - Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(_blockNumber)), + public RemoteFunctionCall storedBatchHash(BigInteger _batchNumber) { + final Function function = new Function(FUNC_STOREDBATCHHASH, + Arrays.asList(new Uint256(_batchNumber)), Arrays.>asList(new TypeReference() {})); return executeRemoteCallSingleValueReturn(function, byte[].class); } @@ -1500,15 +1160,6 @@ public RemoteFunctionCall unfreezeDiamond() { return executeRemoteCallTransaction(function); } - public RemoteFunctionCall upgradeProposalHash(DiamondCutData _diamondCut, BigInteger _proposalId, byte[] _salt) { - final Function function = new Function(FUNC_UPGRADEPROPOSALHASH, - Arrays.asList(_diamondCut, - new org.web3j.abi.datatypes.generated.Uint256(_proposalId), - new org.web3j.abi.datatypes.generated.Bytes32(_salt)), - Arrays.>asList(new TypeReference() {})); - return executeRemoteCallSingleValueReturn(function, byte[].class); - } - @Deprecated public static ZkSyncContract load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { return new ZkSyncContract(contractAddress, web3j, credentials, gasPrice, gasLimit); @@ -1527,30 +1178,35 @@ public static ZkSyncContract load(String contractAddress, Web3j web3j, Transacti return new ZkSyncContract(contractAddress, web3j, transactionManager, contractGasProvider); } - public static RemoteCall deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { - return deployRemoteCall(ZkSyncContract.class, web3j, credentials, contractGasProvider, BINARY, ""); - } + public static class FacetCut extends DynamicStruct { + public String facet; - @Deprecated - public static RemoteCall deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { - return deployRemoteCall(ZkSyncContract.class, web3j, credentials, gasPrice, gasLimit, BINARY, ""); - } + public BigInteger action; - public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { - return deployRemoteCall(ZkSyncContract.class, web3j, transactionManager, contractGasProvider, BINARY, ""); - } + public Boolean isFreezable; - @Deprecated - public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { - return deployRemoteCall(ZkSyncContract.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, ""); - } + public List selectors; - protected String getStaticDeployedAddress(String networkId) { - return _addresses.get(networkId); - } + public FacetCut(String facet, BigInteger action, Boolean isFreezable, List selectors) { + super(new Address(160, facet), + new Uint8(action), + new Bool(isFreezable), + new DynamicArray( + Bytes4.class, + org.web3j.abi.Utils.typeMap(selectors, Bytes4.class))); + this.facet = facet; + this.action = action; + this.isFreezable = isFreezable; + this.selectors = selectors; + } - public static String getPreviouslyDeployedAddress(String networkId) { - return _addresses.get(networkId); + public FacetCut(Address facet, Uint8 action, Bool isFreezable, DynamicArray selectors) { + super(facet, action, isFreezable, selectors); + this.facet = facet.getValue(); + this.action = action.getValue(); + this.isFreezable = isFreezable.getValue(); + this.selectors = selectors.getValue().stream().map(v -> v.getValue()).collect(Collectors.toList()); + } } public static class L2CanonicalTransaction extends DynamicStruct { @@ -1587,26 +1243,26 @@ public static class L2CanonicalTransaction extends DynamicStruct { public byte[] reservedDynamic; public L2CanonicalTransaction(BigInteger txType, BigInteger from, BigInteger to, BigInteger gasLimit, BigInteger gasPerPubdataByteLimit, BigInteger maxFeePerGas, BigInteger maxPriorityFeePerGas, BigInteger paymaster, BigInteger nonce, BigInteger value, List reserved, byte[] data, byte[] signature, List factoryDeps, byte[] paymasterInput, byte[] reservedDynamic) { - super(new org.web3j.abi.datatypes.generated.Uint256(txType), - new org.web3j.abi.datatypes.generated.Uint256(from), - new org.web3j.abi.datatypes.generated.Uint256(to), - new org.web3j.abi.datatypes.generated.Uint256(gasLimit), - new org.web3j.abi.datatypes.generated.Uint256(gasPerPubdataByteLimit), - new org.web3j.abi.datatypes.generated.Uint256(maxFeePerGas), - new org.web3j.abi.datatypes.generated.Uint256(maxPriorityFeePerGas), - new org.web3j.abi.datatypes.generated.Uint256(paymaster), - new org.web3j.abi.datatypes.generated.Uint256(nonce), - new org.web3j.abi.datatypes.generated.Uint256(value), - new org.web3j.abi.datatypes.generated.StaticArray4( - org.web3j.abi.datatypes.generated.Uint256.class, - org.web3j.abi.Utils.typeMap(reserved, org.web3j.abi.datatypes.generated.Uint256.class)), - new org.web3j.abi.datatypes.DynamicBytes(data), - new org.web3j.abi.datatypes.DynamicBytes(signature), - new org.web3j.abi.datatypes.DynamicArray( - org.web3j.abi.datatypes.generated.Uint256.class, - org.web3j.abi.Utils.typeMap(factoryDeps, org.web3j.abi.datatypes.generated.Uint256.class)), - new org.web3j.abi.datatypes.DynamicBytes(paymasterInput), - new org.web3j.abi.datatypes.DynamicBytes(reservedDynamic)); + super(new Uint256(txType), + new Uint256(from), + new Uint256(to), + new Uint256(gasLimit), + new Uint256(gasPerPubdataByteLimit), + new Uint256(maxFeePerGas), + new Uint256(maxPriorityFeePerGas), + new Uint256(paymaster), + new Uint256(nonce), + new Uint256(value), + new StaticArray4( + Uint256.class, + org.web3j.abi.Utils.typeMap(reserved, Uint256.class)), + new DynamicBytes(data), + new DynamicBytes(signature), + new DynamicArray( + Uint256.class, + org.web3j.abi.Utils.typeMap(factoryDeps, Uint256.class)), + new DynamicBytes(paymasterInput), + new DynamicBytes(reservedDynamic)); this.txType = txType; this.from = from; this.to = to; @@ -1646,65 +1302,10 @@ public L2CanonicalTransaction(Uint256 txType, Uint256 from, Uint256 to, Uint256 } } - public static class VerifierParams extends StaticStruct { - public byte[] recursionNodeLevelVkHash; - - public byte[] recursionLeafLevelVkHash; - - public byte[] recursionCircuitsSetVksHash; - - public VerifierParams(byte[] recursionNodeLevelVkHash, byte[] recursionLeafLevelVkHash, byte[] recursionCircuitsSetVksHash) { - super(new org.web3j.abi.datatypes.generated.Bytes32(recursionNodeLevelVkHash), - new org.web3j.abi.datatypes.generated.Bytes32(recursionLeafLevelVkHash), - new org.web3j.abi.datatypes.generated.Bytes32(recursionCircuitsSetVksHash)); - this.recursionNodeLevelVkHash = recursionNodeLevelVkHash; - this.recursionLeafLevelVkHash = recursionLeafLevelVkHash; - this.recursionCircuitsSetVksHash = recursionCircuitsSetVksHash; - } - - public VerifierParams(Bytes32 recursionNodeLevelVkHash, Bytes32 recursionLeafLevelVkHash, Bytes32 recursionCircuitsSetVksHash) { - super(recursionNodeLevelVkHash, recursionLeafLevelVkHash, recursionCircuitsSetVksHash); - this.recursionNodeLevelVkHash = recursionNodeLevelVkHash.getValue(); - this.recursionLeafLevelVkHash = recursionLeafLevelVkHash.getValue(); - this.recursionCircuitsSetVksHash = recursionCircuitsSetVksHash.getValue(); - } - } - - public static class FacetCut extends DynamicStruct { - public String facet; - - public BigInteger action; - - public Boolean isFreezable; - - public List selectors; - - public FacetCut(String facet, BigInteger action, Boolean isFreezable, List selectors) { - super(new org.web3j.abi.datatypes.Address(facet), - new org.web3j.abi.datatypes.generated.Uint8(action), - new org.web3j.abi.datatypes.Bool(isFreezable), - new org.web3j.abi.datatypes.DynamicArray( - org.web3j.abi.datatypes.generated.Bytes4.class, - org.web3j.abi.Utils.typeMap(selectors, org.web3j.abi.datatypes.generated.Bytes4.class))); - this.facet = facet; - this.action = action; - this.isFreezable = isFreezable; - this.selectors = selectors; - } - - public FacetCut(Address facet, Uint8 action, Bool isFreezable, DynamicArray selectors) { - super(facet, action, isFreezable, selectors); - this.facet = facet.getValue(); - this.action = action.getValue(); - this.isFreezable = isFreezable.getValue(); - this.selectors = selectors.getValue().stream().map(v -> v.getValue()).collect(Collectors.toList()); - } - } - - public static class StoredBlockInfo extends StaticStruct { - public BigInteger blockNumber; + public static class StoredBatchInfo extends StaticStruct { + public BigInteger batchNumber; - public byte[] blockHash; + public byte[] batchHash; public BigInteger indexRepeatedStorageChanges; @@ -1718,17 +1319,17 @@ public static class StoredBlockInfo extends StaticStruct { public byte[] commitment; - public StoredBlockInfo(BigInteger blockNumber, byte[] blockHash, BigInteger indexRepeatedStorageChanges, BigInteger numberOfLayer1Txs, byte[] priorityOperationsHash, byte[] l2LogsTreeRoot, BigInteger timestamp, byte[] commitment) { - super(new org.web3j.abi.datatypes.generated.Uint64(blockNumber), - new org.web3j.abi.datatypes.generated.Bytes32(blockHash), - new org.web3j.abi.datatypes.generated.Uint64(indexRepeatedStorageChanges), - new org.web3j.abi.datatypes.generated.Uint256(numberOfLayer1Txs), - new org.web3j.abi.datatypes.generated.Bytes32(priorityOperationsHash), - new org.web3j.abi.datatypes.generated.Bytes32(l2LogsTreeRoot), - new org.web3j.abi.datatypes.generated.Uint256(timestamp), - new org.web3j.abi.datatypes.generated.Bytes32(commitment)); - this.blockNumber = blockNumber; - this.blockHash = blockHash; + public StoredBatchInfo(BigInteger batchNumber, byte[] batchHash, BigInteger indexRepeatedStorageChanges, BigInteger numberOfLayer1Txs, byte[] priorityOperationsHash, byte[] l2LogsTreeRoot, BigInteger timestamp, byte[] commitment) { + super(new Uint64(batchNumber), + new Bytes32(batchHash), + new Uint64(indexRepeatedStorageChanges), + new Uint256(numberOfLayer1Txs), + new Bytes32(priorityOperationsHash), + new Bytes32(l2LogsTreeRoot), + new Uint256(timestamp), + new Bytes32(commitment)); + this.batchNumber = batchNumber; + this.batchHash = batchHash; this.indexRepeatedStorageChanges = indexRepeatedStorageChanges; this.numberOfLayer1Txs = numberOfLayer1Txs; this.priorityOperationsHash = priorityOperationsHash; @@ -1737,10 +1338,10 @@ public StoredBlockInfo(BigInteger blockNumber, byte[] blockHash, BigInteger inde this.commitment = commitment; } - public StoredBlockInfo(Uint64 blockNumber, Bytes32 blockHash, Uint64 indexRepeatedStorageChanges, Uint256 numberOfLayer1Txs, Bytes32 priorityOperationsHash, Bytes32 l2LogsTreeRoot, Uint256 timestamp, Bytes32 commitment) { - super(blockNumber, blockHash, indexRepeatedStorageChanges, numberOfLayer1Txs, priorityOperationsHash, l2LogsTreeRoot, timestamp, commitment); - this.blockNumber = blockNumber.getValue(); - this.blockHash = blockHash.getValue(); + public StoredBatchInfo(Uint64 batchNumber, Bytes32 batchHash, Uint64 indexRepeatedStorageChanges, Uint256 numberOfLayer1Txs, Bytes32 priorityOperationsHash, Bytes32 l2LogsTreeRoot, Uint256 timestamp, Bytes32 commitment) { + super(batchNumber, batchHash, indexRepeatedStorageChanges, numberOfLayer1Txs, priorityOperationsHash, l2LogsTreeRoot, timestamp, commitment); + this.batchNumber = batchNumber.getValue(); + this.batchHash = batchHash.getValue(); this.indexRepeatedStorageChanges = indexRepeatedStorageChanges.getValue(); this.numberOfLayer1Txs = numberOfLayer1Txs.getValue(); this.priorityOperationsHash = priorityOperationsHash.getValue(); @@ -1750,8 +1351,8 @@ public StoredBlockInfo(Uint64 blockNumber, Bytes32 blockHash, Uint64 indexRepeat } } - public static class CommitBlockInfo extends DynamicStruct { - public BigInteger blockNumber; + public static class CommitBatchInfo extends DynamicStruct { + public BigInteger batchNumber; public BigInteger timestamp; @@ -1761,65 +1362,51 @@ public static class CommitBlockInfo extends DynamicStruct { public BigInteger numberOfLayer1Txs; - public byte[] l2LogsTreeRoot; - public byte[] priorityOperationsHash; - public byte[] initialStorageChanges; - - public byte[] repeatedStorageChanges; + public byte[] bootloaderHeapInitialContentsHash; - public byte[] l2Logs; + public byte[] eventsQueueStateHash; - public List l2ArbitraryLengthMessages; + public byte[] systemLogs; - public List factoryDeps; + public byte[] totalL2ToL1Pubdata; - public CommitBlockInfo(BigInteger blockNumber, BigInteger timestamp, BigInteger indexRepeatedStorageChanges, byte[] newStateRoot, BigInteger numberOfLayer1Txs, byte[] l2LogsTreeRoot, byte[] priorityOperationsHash, byte[] initialStorageChanges, byte[] repeatedStorageChanges, byte[] l2Logs, List l2ArbitraryLengthMessages, List factoryDeps) { - super(new org.web3j.abi.datatypes.generated.Uint64(blockNumber), - new org.web3j.abi.datatypes.generated.Uint64(timestamp), - new org.web3j.abi.datatypes.generated.Uint64(indexRepeatedStorageChanges), - new org.web3j.abi.datatypes.generated.Bytes32(newStateRoot), - new org.web3j.abi.datatypes.generated.Uint256(numberOfLayer1Txs), - new org.web3j.abi.datatypes.generated.Bytes32(l2LogsTreeRoot), - new org.web3j.abi.datatypes.generated.Bytes32(priorityOperationsHash), - new org.web3j.abi.datatypes.DynamicBytes(initialStorageChanges), - new org.web3j.abi.datatypes.DynamicBytes(repeatedStorageChanges), - new org.web3j.abi.datatypes.DynamicBytes(l2Logs), - new org.web3j.abi.datatypes.DynamicArray( - org.web3j.abi.datatypes.DynamicBytes.class, - org.web3j.abi.Utils.typeMap(l2ArbitraryLengthMessages, org.web3j.abi.datatypes.DynamicBytes.class)), - new org.web3j.abi.datatypes.DynamicArray( - org.web3j.abi.datatypes.DynamicBytes.class, - org.web3j.abi.Utils.typeMap(factoryDeps, org.web3j.abi.datatypes.DynamicBytes.class))); - this.blockNumber = blockNumber; + public CommitBatchInfo(BigInteger batchNumber, BigInteger timestamp, BigInteger indexRepeatedStorageChanges, byte[] newStateRoot, BigInteger numberOfLayer1Txs, byte[] priorityOperationsHash, byte[] bootloaderHeapInitialContentsHash, byte[] eventsQueueStateHash, byte[] systemLogs, byte[] totalL2ToL1Pubdata) { + super(new Uint64(batchNumber), + new Uint64(timestamp), + new Uint64(indexRepeatedStorageChanges), + new Bytes32(newStateRoot), + new Uint256(numberOfLayer1Txs), + new Bytes32(priorityOperationsHash), + new Bytes32(bootloaderHeapInitialContentsHash), + new Bytes32(eventsQueueStateHash), + new DynamicBytes(systemLogs), + new DynamicBytes(totalL2ToL1Pubdata)); + this.batchNumber = batchNumber; this.timestamp = timestamp; this.indexRepeatedStorageChanges = indexRepeatedStorageChanges; this.newStateRoot = newStateRoot; this.numberOfLayer1Txs = numberOfLayer1Txs; - this.l2LogsTreeRoot = l2LogsTreeRoot; this.priorityOperationsHash = priorityOperationsHash; - this.initialStorageChanges = initialStorageChanges; - this.repeatedStorageChanges = repeatedStorageChanges; - this.l2Logs = l2Logs; - this.l2ArbitraryLengthMessages = l2ArbitraryLengthMessages; - this.factoryDeps = factoryDeps; + this.bootloaderHeapInitialContentsHash = bootloaderHeapInitialContentsHash; + this.eventsQueueStateHash = eventsQueueStateHash; + this.systemLogs = systemLogs; + this.totalL2ToL1Pubdata = totalL2ToL1Pubdata; } - public CommitBlockInfo(Uint64 blockNumber, Uint64 timestamp, Uint64 indexRepeatedStorageChanges, Bytes32 newStateRoot, Uint256 numberOfLayer1Txs, Bytes32 l2LogsTreeRoot, Bytes32 priorityOperationsHash, DynamicBytes initialStorageChanges, DynamicBytes repeatedStorageChanges, DynamicBytes l2Logs, DynamicArray l2ArbitraryLengthMessages, DynamicArray factoryDeps) { - super(blockNumber, timestamp, indexRepeatedStorageChanges, newStateRoot, numberOfLayer1Txs, l2LogsTreeRoot, priorityOperationsHash, initialStorageChanges, repeatedStorageChanges, l2Logs, l2ArbitraryLengthMessages, factoryDeps); - this.blockNumber = blockNumber.getValue(); + public CommitBatchInfo(Uint64 batchNumber, Uint64 timestamp, Uint64 indexRepeatedStorageChanges, Bytes32 newStateRoot, Uint256 numberOfLayer1Txs, Bytes32 priorityOperationsHash, Bytes32 bootloaderHeapInitialContentsHash, Bytes32 eventsQueueStateHash, DynamicBytes systemLogs, DynamicBytes totalL2ToL1Pubdata) { + super(batchNumber, timestamp, indexRepeatedStorageChanges, newStateRoot, numberOfLayer1Txs, priorityOperationsHash, bootloaderHeapInitialContentsHash, eventsQueueStateHash, systemLogs, totalL2ToL1Pubdata); + this.batchNumber = batchNumber.getValue(); this.timestamp = timestamp.getValue(); this.indexRepeatedStorageChanges = indexRepeatedStorageChanges.getValue(); this.newStateRoot = newStateRoot.getValue(); this.numberOfLayer1Txs = numberOfLayer1Txs.getValue(); - this.l2LogsTreeRoot = l2LogsTreeRoot.getValue(); this.priorityOperationsHash = priorityOperationsHash.getValue(); - this.initialStorageChanges = initialStorageChanges.getValue(); - this.repeatedStorageChanges = repeatedStorageChanges.getValue(); - this.l2Logs = l2Logs.getValue(); - this.l2ArbitraryLengthMessages = l2ArbitraryLengthMessages.getValue().stream().map(v -> v.getValue()).collect(Collectors.toList()); - this.factoryDeps = factoryDeps.getValue().stream().map(v -> v.getValue()).collect(Collectors.toList()); + this.bootloaderHeapInitialContentsHash = bootloaderHeapInitialContentsHash.getValue(); + this.eventsQueueStateHash = eventsQueueStateHash.getValue(); + this.systemLogs = systemLogs.getValue(); + this.totalL2ToL1Pubdata = totalL2ToL1Pubdata.getValue(); } } @@ -1829,10 +1416,10 @@ public static class Facet extends DynamicStruct { public List selectors; public Facet(String addr, List selectors) { - super(new org.web3j.abi.datatypes.Address(addr), - new org.web3j.abi.datatypes.DynamicArray( - org.web3j.abi.datatypes.generated.Bytes4.class, - org.web3j.abi.Utils.typeMap(selectors, org.web3j.abi.datatypes.generated.Bytes4.class))); + super(new Address(160, addr), + new DynamicArray( + Bytes4.class, + org.web3j.abi.Utils.typeMap(selectors, Bytes4.class))); this.addr = addr; this.selectors = selectors; } @@ -1844,6 +1431,30 @@ public Facet(Address addr, DynamicArray selectors) { } } + public static class VerifierParams extends StaticStruct { + public byte[] recursionNodeLevelVkHash; + + public byte[] recursionLeafLevelVkHash; + + public byte[] recursionCircuitsSetVksHash; + + public VerifierParams(byte[] recursionNodeLevelVkHash, byte[] recursionLeafLevelVkHash, byte[] recursionCircuitsSetVksHash) { + super(new Bytes32(recursionNodeLevelVkHash), + new Bytes32(recursionLeafLevelVkHash), + new Bytes32(recursionCircuitsSetVksHash)); + this.recursionNodeLevelVkHash = recursionNodeLevelVkHash; + this.recursionLeafLevelVkHash = recursionLeafLevelVkHash; + this.recursionCircuitsSetVksHash = recursionCircuitsSetVksHash; + } + + public VerifierParams(Bytes32 recursionNodeLevelVkHash, Bytes32 recursionLeafLevelVkHash, Bytes32 recursionCircuitsSetVksHash) { + super(recursionNodeLevelVkHash, recursionLeafLevelVkHash, recursionCircuitsSetVksHash); + this.recursionNodeLevelVkHash = recursionNodeLevelVkHash.getValue(); + this.recursionLeafLevelVkHash = recursionLeafLevelVkHash.getValue(); + this.recursionCircuitsSetVksHash = recursionCircuitsSetVksHash.getValue(); + } + } + public static class PriorityOperation extends StaticStruct { public byte[] canonicalTxHash; @@ -1852,9 +1463,9 @@ public static class PriorityOperation extends StaticStruct { public BigInteger layer2Tip; public PriorityOperation(byte[] canonicalTxHash, BigInteger expirationTimestamp, BigInteger layer2Tip) { - super(new org.web3j.abi.datatypes.generated.Bytes32(canonicalTxHash), - new org.web3j.abi.datatypes.generated.Uint64(expirationTimestamp), - new org.web3j.abi.datatypes.generated.Uint192(layer2Tip)); + super(new Bytes32(canonicalTxHash), + new Uint64(expirationTimestamp), + new Uint192(layer2Tip)); this.canonicalTxHash = canonicalTxHash; this.expirationTimestamp = expirationTimestamp; this.layer2Tip = layer2Tip; @@ -1874,12 +1485,12 @@ public static class ProofInput extends DynamicStruct { public List serializedProof; public ProofInput(List recursiveAggregationInput, List serializedProof) { - super(new org.web3j.abi.datatypes.DynamicArray( - org.web3j.abi.datatypes.generated.Uint256.class, - org.web3j.abi.Utils.typeMap(recursiveAggregationInput, org.web3j.abi.datatypes.generated.Uint256.class)), - new org.web3j.abi.datatypes.DynamicArray( - org.web3j.abi.datatypes.generated.Uint256.class, - org.web3j.abi.Utils.typeMap(serializedProof, org.web3j.abi.datatypes.generated.Uint256.class))); + super(new DynamicArray( + Uint256.class, + org.web3j.abi.Utils.typeMap(recursiveAggregationInput, Uint256.class)), + new DynamicArray( + Uint256.class, + org.web3j.abi.Utils.typeMap(serializedProof, Uint256.class))); this.recursiveAggregationInput = recursiveAggregationInput; this.serializedProof = serializedProof; } @@ -1896,7 +1507,7 @@ public static class L2Log extends StaticStruct { public Boolean isService; - public BigInteger txNumberInBlock; + public BigInteger txNumberInBatch; public String sender; @@ -1904,26 +1515,26 @@ public static class L2Log extends StaticStruct { public byte[] value; - public L2Log(BigInteger l2ShardId, Boolean isService, BigInteger txNumberInBlock, String sender, byte[] key, byte[] value) { - super(new org.web3j.abi.datatypes.generated.Uint8(l2ShardId), - new org.web3j.abi.datatypes.Bool(isService), - new org.web3j.abi.datatypes.generated.Uint16(txNumberInBlock), - new org.web3j.abi.datatypes.Address(sender), - new org.web3j.abi.datatypes.generated.Bytes32(key), - new org.web3j.abi.datatypes.generated.Bytes32(value)); + public L2Log(BigInteger l2ShardId, Boolean isService, BigInteger txNumberInBatch, String sender, byte[] key, byte[] value) { + super(new Uint8(l2ShardId), + new Bool(isService), + new Uint16(txNumberInBatch), + new Address(160, sender), + new Bytes32(key), + new Bytes32(value)); this.l2ShardId = l2ShardId; this.isService = isService; - this.txNumberInBlock = txNumberInBlock; + this.txNumberInBatch = txNumberInBatch; this.sender = sender; this.key = key; this.value = value; } - public L2Log(Uint8 l2ShardId, Bool isService, Uint16 txNumberInBlock, Address sender, Bytes32 key, Bytes32 value) { - super(l2ShardId, isService, txNumberInBlock, sender, key, value); + public L2Log(Uint8 l2ShardId, Bool isService, Uint16 txNumberInBatch, Address sender, Bytes32 key, Bytes32 value) { + super(l2ShardId, isService, txNumberInBatch, sender, key, value); this.l2ShardId = l2ShardId.getValue(); this.isService = isService.getValue(); - this.txNumberInBlock = txNumberInBlock.getValue(); + this.txNumberInBatch = txNumberInBatch.getValue(); this.sender = sender.getValue(); this.key = key.getValue(); this.value = value.getValue(); @@ -1931,46 +1542,46 @@ public L2Log(Uint8 l2ShardId, Bool isService, Uint16 txNumberInBlock, Address se } public static class L2Message extends DynamicStruct { - public BigInteger txNumberInBlock; + public BigInteger txNumberInBatch; public String sender; public byte[] data; - public L2Message(BigInteger txNumberInBlock, String sender, byte[] data) { - super(new org.web3j.abi.datatypes.generated.Uint16(txNumberInBlock), - new org.web3j.abi.datatypes.Address(sender), - new org.web3j.abi.datatypes.DynamicBytes(data)); - this.txNumberInBlock = txNumberInBlock; + public L2Message(BigInteger txNumberInBatch, String sender, byte[] data) { + super(new Uint16(txNumberInBatch), + new Address(160, sender), + new DynamicBytes(data)); + this.txNumberInBatch = txNumberInBatch; this.sender = sender; this.data = data; } - public L2Message(Uint16 txNumberInBlock, Address sender, DynamicBytes data) { - super(txNumberInBlock, sender, data); - this.txNumberInBlock = txNumberInBlock.getValue(); + public L2Message(Uint16 txNumberInBatch, Address sender, DynamicBytes data) { + super(txNumberInBatch, sender, data); + this.txNumberInBatch = txNumberInBatch.getValue(); this.sender = sender.getValue(); this.data = data.getValue(); } } public static class DiamondCutData extends DynamicStruct { - public List facetCuts; + public List facetCuts; public String initAddress; public byte[] initCalldata; - public DiamondCutData(List facetCuts, String initAddress, byte[] initCalldata) { - super(new org.web3j.abi.datatypes.DynamicArray(FacetCut.class, facetCuts), - new org.web3j.abi.datatypes.Address(initAddress), - new org.web3j.abi.datatypes.DynamicBytes(initCalldata)); + public DiamondCutData(List facetCuts, String initAddress, byte[] initCalldata) { + super(new DynamicArray(IZkSync.FacetCut.class, facetCuts), + new Address(160, initAddress), + new DynamicBytes(initCalldata)); this.facetCuts = facetCuts; this.initAddress = initAddress; this.initCalldata = initCalldata; } - public DiamondCutData(@Parameterized(type = FacetCut.class) DynamicArray facetCuts, Address initAddress, DynamicBytes initCalldata) { + public DiamondCutData(@Parameterized(type = IZkSync.FacetCut.class) DynamicArray facetCuts, Address initAddress, DynamicBytes initCalldata) { super(facetCuts, initAddress, initCalldata); this.facetCuts = facetCuts.getValue(); this.initAddress = initAddress.getValue(); @@ -1979,39 +1590,33 @@ public DiamondCutData(@Parameterized(type = FacetCut.class) DynamicArray factoryDeps; } @@ -2077,38 +1678,6 @@ public static class NewPriorityTxMaxGasLimitEventResponse extends BaseEventRespo public BigInteger newPriorityTxMaxGasLimit; } - public static class NewVerifierEventResponse extends BaseEventResponse { - public String oldVerifier; - - public String newVerifier; - } - - public static class NewVerifierParamsEventResponse extends BaseEventResponse { - public VerifierParams oldVerifierParams; - - public VerifierParams newVerifierParams; - } - - public static class ProposeShadowUpgradeEventResponse extends BaseEventResponse { - public BigInteger proposalId; - - public byte[] proposalHash; - } - - public static class ProposeTransparentUpgradeEventResponse extends BaseEventResponse { - public BigInteger proposalId; - - public DiamondCutData diamondCut; - - public byte[] proposalSalt; - } - - public static class SecurityCouncilUpgradeApproveEventResponse extends BaseEventResponse { - public BigInteger proposalId; - - public byte[] proposalHash; - } - public static class UnfreezeEventResponse extends BaseEventResponse { } diff --git a/src/test/java/io/zksync/integration/BaseIntegrationEnv.java b/src/test/java/io/zksync/integration/BaseIntegrationEnv.java index 05d785b..d0ba736 100644 --- a/src/test/java/io/zksync/integration/BaseIntegrationEnv.java +++ b/src/test/java/io/zksync/integration/BaseIntegrationEnv.java @@ -8,7 +8,6 @@ import io.zksync.methods.response.ZksEstimateFee; import io.zksync.protocol.ZkSync; import io.zksync.protocol.account.Wallet; -import io.zksync.protocol.account.WalletL1; import io.zksync.protocol.core.Token; import io.zksync.protocol.provider.EthereumProvider; import io.zksync.transaction.fee.DefaultTransactionFeeProvider; @@ -18,9 +17,8 @@ import io.zksync.transaction.type.DepositTransaction; import io.zksync.transaction.type.Transaction712; import io.zksync.utils.ContractDeployer; +import io.zksync.wrappers.ITestnetERC20Token; import io.zksync.wrappers.IZkSync; -import io.zksync.wrappers.ZkSyncContract; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.web3j.crypto.Credentials; import org.web3j.crypto.ECKeyPair; @@ -110,8 +108,10 @@ protected BaseIntegrationEnv() { } @Test - public void testPrepare() throws IOException, InterruptedException { - testWallet.approveERC20(L1_DAI, BigInteger.valueOf(100)).join(); + public void testPrepare() throws Exception { + ITestnetERC20Token tokenContract = ITestnetERC20Token.load(L1_DAI, l1Web3, credentials, new StaticGasProvider(l1Web3.ethGasPrice().sendAsync().join().getGasPrice(), BigInteger.valueOf(300_000L))); + TransactionReceipt receipt = tokenContract.mint(credentials.getAddress(), BigInteger.valueOf(1000)).send(); + testWallet.approveERC20(L1_DAI, BigInteger.valueOf(100)).sendAsync().join(); DepositTransaction transaction = new DepositTransaction(L1_DAI, BigInteger.valueOf(50), null,null, null, null, null, null, null, true, null); String hash = testWallet.deposit(transaction).sendAsync().join().getResult(); Thread.sleep(5000); diff --git a/src/test/java/io/zksync/integration/account/WalletTest.java b/src/test/java/io/zksync/integration/account/WalletTest.java index e6323d9..895f326 100644 --- a/src/test/java/io/zksync/integration/account/WalletTest.java +++ b/src/test/java/io/zksync/integration/account/WalletTest.java @@ -8,10 +8,10 @@ import io.zksync.utils.Paymaster; import io.zksync.utils.ZkSyncAddresses; import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.web3j.abi.FunctionEncoder; -import org.web3j.protocol.core.methods.response.EthGetTransactionReceipt; +import org.web3j.crypto.RawTransaction; +import org.web3j.protocol.core.DefaultBlockParameterName; import org.web3j.protocol.core.methods.response.EthSendTransaction; import org.web3j.protocol.core.methods.response.TransactionReceipt; import org.web3j.protocol.exceptions.TransactionException; @@ -19,6 +19,7 @@ import java.io.IOException; import java.math.BigInteger; +import java.util.List; import java.util.Map; import static org.junit.jupiter.api.Assertions.*; @@ -42,12 +43,25 @@ public void testGetBalanceL1_ShouldReturnL1Balance(){ @Test public void testGetAllowanceL1(){ - assertTrue(testWallet.getAllowanceL1(L1_DAI).join().compareTo(BigInteger.ZERO) >= 0); + assertTrue(testWallet.getAllowanceL1(L1_DAI).sendAsync().join().compareTo(BigInteger.ZERO) >= 0); } @Test - public void testL2TokenAddressETH(){ - assertEquals(ZkSyncAddresses.ETH_ADDRESS.toLowerCase(), testWallet.l2TokenAddress(ZkSyncAddresses.ETH_ADDRESS).toLowerCase()); + public void testBaseL2TokenAddress(){ + String baseTokenAddress = testWallet.getBaseToken().sendAsync().join(); + assertEquals(ZkSyncAddresses.L2_BASE_TOKEN_ADDRESS, testWallet.l2TokenAddress(baseTokenAddress).toLowerCase()); + } + + @Test + public void testL2TokenAddress(){ + if (!testWallet.isETHBasedChain()){ + assertNotNull(testWallet.l2TokenAddress(ZkSyncAddresses.LEGACY_ETH_ADDRESS).toLowerCase()); + } + } + + @Test + public void testL2DaiTokenAddress(){ + assertNotNull(testWallet.l2TokenAddress(L1_DAI).toLowerCase()); } @Test @@ -57,7 +71,7 @@ public void testL2TokenAddressERC20(){ @Test public void testApproveERC20(){ - TransactionReceipt tx = testWallet.approveERC20(L1_DAI, BigInteger.valueOf(5)).join(); + TransactionReceipt tx = testWallet.approveERC20(L1_DAI, BigInteger.valueOf(5)).sendAsync().join(); assertNotNull(tx); } @@ -67,14 +81,16 @@ public void testGetBaseCost(){ } @Test - public void testGetBalance(){ - assertTrue(wallet.getBalance().sendAsync().join().compareTo(BigInteger.ZERO) > 0); + public void testGetBalance() throws Exception { + System.out.println(testWallet.getBalanceL1Async(credentials.getAddress() , L1_DAI, DefaultBlockParameterName.LATEST).join()); + assertTrue(testWallet.getBalanceL1Async(credentials.getAddress() , L1_DAI, DefaultBlockParameterName.LATEST).join().compareTo(BigInteger.ZERO) > 0); } @Test public void testGetAllBalances(){ + int expected = testWallet.isETHBasedChain() ? 2 : 3; Map result = testWallet.getAllBalances().join().getBalances(); - assertEquals(2, result.size()); + assertEquals(expected, result.size()); } @Test @@ -90,8 +106,8 @@ public void getAddress_ShouldReturnWalletAddress(){ @Test public void testGetRequestExecuteTransaction() throws IOException { RequestExecuteTransaction transaction = new RequestExecuteTransaction(null, zksync.zksMainContract().send().getResult(), Numeric.hexStringToByteArray("0x"), BigInteger.valueOf(7000000), null, null, null, null, null); - RequestExecuteTransaction x = testWallet.getRequestExecuteTransaction(transaction); - System.out.println(x); + RawTransaction result = testWallet.getRequestExecuteTransaction(transaction); + assertNotNull(result); } @Test @@ -100,37 +116,163 @@ public void testGetDeploymentNonce(){ } @Test - @Disabled - public void testGetDepositTransaction(){ - TransactionOptions options = new TransactionOptions(null, new BigInteger("286654500007000"), null, BigInteger.valueOf(1500000007), BigInteger.valueOf(1500000000), null, null); - DepositTransaction transaction = new DepositTransaction(ZkSyncAddresses.ETH_ADDRESS, BigInteger.valueOf(7_000), ADDRESS, BigInteger.valueOf(573_309), null, Numeric.hexStringToByteArray("0x"), BigInteger.valueOf(800), BigInteger.ZERO, ADDRESS, null, options); - DepositTransaction result = testWallet.getDepositTransaction(new DepositTransaction(ZkSyncAddresses.ETH_ADDRESS, BigInteger.valueOf(7_000))); - System.out.println(result.hashCode()); - System.out.println(transaction.hashCode()); + public void testEstimateGasDepositETH() throws Exception { + if (testWallet.isETHBasedChain()){ + DepositTransaction transaction = new DepositTransaction(ZkSyncAddresses.LEGACY_ETH_ADDRESS, BigInteger.valueOf(5), null,null, null, null, null, null, null, null, null); + BigInteger result = testWallet.estimateGasDeposit(transaction); + assertTrue(result.compareTo(BigInteger.valueOf(0)) > 0); + }else{ + List allowanceParams = testWallet.getDepositAllowanceParams(ZkSyncAddresses.LEGACY_ETH_ADDRESS, BigInteger.valueOf(5)); + testWallet.approveERC20(allowanceParams.get(0).token, allowanceParams.get(0).amount).sendAsync().join(); + + DepositTransaction transaction = new DepositTransaction(ZkSyncAddresses.LEGACY_ETH_ADDRESS, BigInteger.valueOf(5), null,null, null, null, null, null, null, null, null); + BigInteger result = testWallet.estimateGasDeposit(transaction); + assertTrue(result.compareTo(BigInteger.valueOf(0)) > 0); + } + } + + @Test + public void testEstimateGasDepositBaseToken() throws Exception { + if (!testWallet.isETHBasedChain()){ + String token = testWallet.getBaseToken().sendAsync().join(); + List allowanceParams = testWallet.getDepositAllowanceParams(token, BigInteger.valueOf(5)); + testWallet.approveERC20(allowanceParams.get(0).token, allowanceParams.get(0).amount).sendAsync().join(); + + DepositTransaction transaction = new DepositTransaction(token, BigInteger.valueOf(5), null,null, null, null, null, null, null, null, null); + BigInteger result = testWallet.estimateGasDeposit(transaction); + assertTrue(result.compareTo(BigInteger.valueOf(0)) > 0); + } + } + + @Test + public void testEstimateGasDepositERC20() throws Exception { + if (testWallet.isETHBasedChain()){ + DepositTransaction transaction = new DepositTransaction(L1_DAI, BigInteger.valueOf(5), null,null, null, null, null, null, null, null, null); + BigInteger result = testWallet.estimateGasDeposit(transaction); + assertTrue(result.compareTo(BigInteger.valueOf(0)) > 0); + }else{ + List allowanceParams = testWallet.getDepositAllowanceParams(L1_DAI, BigInteger.valueOf(5)); + testWallet.approveERC20(allowanceParams.get(0).token, allowanceParams.get(0).amount).sendAsync().join(); + testWallet.approveERC20(allowanceParams.get(1).token, allowanceParams.get(1).amount).sendAsync().join(); + + DepositTransaction transaction = new DepositTransaction(L1_DAI, BigInteger.valueOf(5), null,null, null, null, null, null, null, null, null); + BigInteger result = testWallet.estimateGasDeposit(transaction); + assertTrue(result.compareTo(BigInteger.valueOf(0)) > 0); + } + } + + @Test + public void testGetFullRequiredDepositFeeEth() throws Exception { + if (testWallet.isETHBasedChain()){ + DepositTransaction transaction = new DepositTransaction(ZkSyncAddresses.LEGACY_ETH_ADDRESS, BigInteger.valueOf(5), null,null, null, null, null, null, null, null, null); + FullDepositFee fee = testWallet.getFullRequiredDepositFee(transaction).sendAsync().join(); + assertTrue(fee.baseCost.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.l1GasLimit.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.l2GasLimit.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.maxPriorityFeePerGas.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.maxFeePerGas.compareTo(BigInteger.valueOf(0)) > 0); + }else{ + List allowanceParams = testWallet.getDepositAllowanceParams(ZkSyncAddresses.LEGACY_ETH_ADDRESS, BigInteger.valueOf(1)); + testWallet.approveERC20(allowanceParams.get(0).token, allowanceParams.get(0).amount).sendAsync().join(); + + DepositTransaction transaction = new DepositTransaction(ZkSyncAddresses.LEGACY_ETH_ADDRESS, BigInteger.valueOf(1), null,null, null, null, null, null, null, null, null); + FullDepositFee fee = testWallet.getFullRequiredDepositFee(transaction).sendAsync().join(); + assertTrue(fee.baseCost.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.l1GasLimit.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.l2GasLimit.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.maxPriorityFeePerGas.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.maxFeePerGas.compareTo(BigInteger.valueOf(0)) > 0); + } + } - assertEquals(transaction, result); + @Test + public void testGetFullRequiredDepositFeeErc20Token() throws Exception { + if (testWallet.isETHBasedChain()){ + + DepositTransaction transaction = new DepositTransaction(L1_DAI, BigInteger.valueOf(5), null,null, null, null, null, null, null, null, null); + FullDepositFee fee = testWallet.getFullRequiredDepositFee(transaction).sendAsync().join(); + assertTrue(fee.baseCost.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.l1GasLimit.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.l2GasLimit.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.maxPriorityFeePerGas.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.maxFeePerGas.compareTo(BigInteger.valueOf(0)) > 0); + }else{ + List allowanceParams = testWallet.getDepositAllowanceParams(L1_DAI, BigInteger.valueOf(1)); + testWallet.approveERC20(allowanceParams.get(0).token, allowanceParams.get(0).amount).sendAsync().join(); + testWallet.approveERC20(allowanceParams.get(1).token, allowanceParams.get(1).amount).sendAsync().join(); + + DepositTransaction transaction = new DepositTransaction(L1_DAI, BigInteger.valueOf(1), null,null, null, null, null, null, null, null, null); + FullDepositFee fee = testWallet.getFullRequiredDepositFee(transaction).sendAsync().join(); + assertTrue(fee.baseCost.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.l1GasLimit.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.l2GasLimit.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.maxPriorityFeePerGas.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.maxFeePerGas.compareTo(BigInteger.valueOf(0)) > 0); + } } @Test - public void testEstimateGasDepositETH() throws IOException { - DepositTransaction transaction = new DepositTransaction(ZkSyncAddresses.ETH_ADDRESS, BigInteger.valueOf(5), null,null, null, null, null, null, null, null, null); - BigInteger result = testWallet.estimateGasDeposit(transaction); - assertEquals(0, result.compareTo(BigInteger.valueOf(132_711))); + public void testGetFullRequiredDepositFeeBaseToken() throws Exception { + if (!testWallet.isETHBasedChain()){ + String token = testWallet.getBaseToken().sendAsync().join(); + List allowanceParams = testWallet.getDepositAllowanceParams(token, BigInteger.valueOf(1)); + testWallet.approveERC20(allowanceParams.get(0).token, allowanceParams.get(0).amount).sendAsync().join(); + + DepositTransaction transaction = new DepositTransaction(token, BigInteger.valueOf(1), null,null, null, null, null, null, null, null, null); + FullDepositFee fee = testWallet.getFullRequiredDepositFee(transaction).sendAsync().join(); + assertTrue(fee.baseCost.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.l1GasLimit.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.l2GasLimit.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.maxPriorityFeePerGas.compareTo(BigInteger.valueOf(0)) > 0); + assertTrue(fee.maxFeePerGas.compareTo(BigInteger.valueOf(0)) > 0); + } } @Test - public void testEstimateGasDepositERC20() throws IOException { - DepositTransaction transaction = new DepositTransaction(L1_DAI, BigInteger.valueOf(5), null,null, null, null, null, null, null, null, null); - BigInteger result = testWallet.estimateGasDeposit(transaction); - assertEquals(0, result.compareTo(BigInteger.valueOf(253_418))); + public void testDepositETH() throws Exception { + if (testWallet.isETHBasedChain()){ + BigInteger amount = new BigInteger("7000000000"); + BigInteger l2BalanceBeforeDeposit = testWallet.getBalance().sendAsync().join(); + BigInteger l1BalanceBeforeDeposit = testWallet.getBalanceL1().sendAsync().join(); + + DepositTransaction transaction = new DepositTransaction(ZkSyncAddresses.LEGACY_ETH_ADDRESS, amount); + EthSendTransaction hash = testWallet.deposit(transaction).send(); + + TransactionReceipt l1Receipt = processorL1.waitForTransactionReceipt(hash.getTransactionHash()); + String l2Hash = zksync.getL2HashFromPriorityOp(l1Receipt, zksync.zksMainContract().sendAsync().join().getResult()); + testWallet.getTransactionReceiptProcessor().waitForTransactionReceipt(l2Hash); + BigInteger l2BalanceAfterDeposit = testWallet.getBalance().sendAsync().join(); + BigInteger l1BalanceAfterDeposit = testWallet.getBalanceL1().sendAsync().join(); + + assertNotNull(hash); + assertTrue(l2BalanceAfterDeposit.subtract(l2BalanceBeforeDeposit).compareTo(amount) >= 0); + assertTrue(l1BalanceBeforeDeposit.subtract(l1BalanceAfterDeposit).compareTo(amount) >= 0); + }else{ + BigInteger amount = new BigInteger("7000000000"); + BigInteger l2BalanceBeforeDeposit = testWallet.getBalance().sendAsync().join(); + BigInteger l1BalanceBeforeDeposit = testWallet.getBalanceL1().sendAsync().join(); + + DepositTransaction transaction = new DepositTransaction(ZkSyncAddresses.LEGACY_ETH_ADDRESS, amount, true); + EthSendTransaction hash = testWallet.deposit(transaction).send(); + + TransactionReceipt l1Receipt = processorL1.waitForTransactionReceipt(hash.getTransactionHash()); + String l2Hash = zksync.getL2HashFromPriorityOp(l1Receipt, zksync.zksMainContract().sendAsync().join().getResult()); + testWallet.getTransactionReceiptProcessor().waitForTransactionReceipt(l2Hash); + BigInteger l2BalanceAfterDeposit = testWallet.getBalance().sendAsync().join(); + BigInteger l1BalanceAfterDeposit = testWallet.getBalanceL1().sendAsync().join(); + + assertNotNull(hash); + assertTrue(l2BalanceAfterDeposit.subtract(l2BalanceBeforeDeposit).compareTo(amount) >= 0); + assertTrue(l1BalanceBeforeDeposit.subtract(l1BalanceAfterDeposit).compareTo(amount) >= 0); + } } @Test - public void testDepositETH() throws IOException, InterruptedException, TransactionException { - BigInteger amount = new BigInteger("7000000000"); + public void testDepositBaseToken() throws Exception { + BigInteger amount = new BigInteger("5"); BigInteger l2BalanceBeforeDeposit = testWallet.getBalance().sendAsync().join(); BigInteger l1BalanceBeforeDeposit = testWallet.getBalanceL1().sendAsync().join(); - DepositTransaction transaction = new DepositTransaction(ZkSyncAddresses.ETH_ADDRESS, amount); + DepositTransaction transaction = new DepositTransaction(ZkSyncAddresses.LEGACY_ETH_ADDRESS, amount, true); EthSendTransaction hash = testWallet.deposit(transaction).send(); TransactionReceipt l1Receipt = processorL1.waitForTransactionReceipt(hash.getTransactionHash()); @@ -144,36 +286,49 @@ public void testDepositETH() throws IOException, InterruptedException, Transacti assertTrue(l1BalanceBeforeDeposit.subtract(l1BalanceAfterDeposit).compareTo(amount) >= 0); } @Test - public void testDepositERC20() throws IOException, TransactionException, InterruptedException { - String l2DAI = testWallet.l2TokenAddress(L1_DAI); - - BigInteger balanceBefore = BigInteger.ZERO; - try { - balanceBefore = testWallet.getBalance(l2DAI).sendAsync().join(); - }catch (Exception e){} - - DepositTransaction transaction = new DepositTransaction(L1_DAI, BigInteger.valueOf(5), null,null, null, null, null, null, null, true, null); - EthSendTransaction hash = testWallet.deposit(transaction).sendAsync().join(); - TransactionReceipt receipt = processorL1.waitForTransactionReceipt(hash.getTransactionHash()); - String l2Hash = zksync.getL2HashFromPriorityOp(receipt, zksync.zksMainContract().sendAsync().join().getResult()); - TransactionReceipt receiptL2 = testWallet.getTransactionReceiptProcessor().waitForTransactionReceipt(l2Hash); - BigInteger balanceAfter = testWallet.getBalance(l2DAI).sendAsync().join(); - - assertNotNull(receipt); - assertTrue(balanceAfter.subtract(balanceBefore).compareTo(BigInteger.valueOf(5)) == 0); + public void testDepositERC20() throws Exception { + if (testWallet.isETHBasedChain()){ + String l2DAI = testWallet.l2TokenAddress(L1_DAI); + + BigInteger balanceBefore = testWallet.getBalance(l2DAI).sendAsync().join(); + + DepositTransaction transaction = new DepositTransaction(L1_DAI, BigInteger.valueOf(5), null,null, null, null, null, null, null, true, null); + EthSendTransaction hash = testWallet.deposit(transaction).sendAsync().join(); + TransactionReceipt receipt = processorL1.waitForTransactionReceipt(hash.getTransactionHash()); + String l2Hash = zksync.getL2HashFromPriorityOp(receipt, zksync.zksMainContract().sendAsync().join().getResult()); + testWallet.getTransactionReceiptProcessor().waitForTransactionReceipt(l2Hash); + BigInteger balanceAfter = testWallet.getBalance(l2DAI).sendAsync().join(); + + assertNotNull(receipt); + assertEquals(0, balanceAfter.subtract(balanceBefore).compareTo(BigInteger.valueOf(5))); + }else{ + String l2DAI = testWallet.l2TokenAddress(L1_DAI); + + BigInteger balanceBefore = testWallet.getBalance(l2DAI).sendAsync().join(); + + DepositTransaction transaction = new DepositTransaction(L1_DAI, BigInteger.valueOf(5), true, true); + EthSendTransaction hash = testWallet.deposit(transaction).sendAsync().join(); + TransactionReceipt receipt = processorL1.waitForTransactionReceipt(hash.getTransactionHash()); + String l2Hash = zksync.getL2HashFromPriorityOp(receipt, zksync.zksMainContract().sendAsync().join().getResult()); + testWallet.getTransactionReceiptProcessor().waitForTransactionReceipt(l2Hash); + BigInteger balanceAfter = testWallet.getBalance(l2DAI).sendAsync().join(); + + assertNotNull(receipt); + assertEquals(0, balanceAfter.subtract(balanceBefore).compareTo(BigInteger.valueOf(5))); + } } @Test public void testTransferEth() throws TransactionException, IOException { BigInteger amount = BigInteger.valueOf(7_000_000_000L); - BigInteger balanceBeforeTransfer = testWallet.getBalance(RECEIVER, ZkSyncAddresses.ETH_ADDRESS, ZkBlockParameterName.COMMITTED).sendAsync().join(); + BigInteger balanceBeforeTransfer = testWallet.getBalance(RECEIVER, ZkSyncAddresses.LEGACY_ETH_ADDRESS, ZkBlockParameterName.COMMITTED).sendAsync().join(); TransferTransaction transaction = new TransferTransaction(RECEIVER, amount, signer.getAddress()); TransactionReceipt receipt = testWallet.transfer(transaction).sendAsync().join(); testWallet.getTransactionReceiptProcessor().waitForTransactionReceipt(receipt.getTransactionHash()); - BigInteger balanceAfterTransfer = testWallet.getBalance(RECEIVER, ZkSyncAddresses.ETH_ADDRESS, ZkBlockParameterName.COMMITTED).sendAsync().join(); + BigInteger balanceAfterTransfer = testWallet.getBalance(RECEIVER, ZkSyncAddresses.LEGACY_ETH_ADDRESS, ZkBlockParameterName.COMMITTED).sendAsync().join(); assertNotNull(receipt); assertEquals(balanceAfterTransfer.subtract(balanceBeforeTransfer), amount); @@ -198,26 +353,42 @@ public void testTransferErc20() throws TransactionException, IOException { assertEquals(balanceAfterTransfer.subtract(balanceBeforeTransfer), amount); } @Test + public void testTransferBaseToken() throws TransactionException, IOException { + BigInteger amount = BigInteger.valueOf(7_000_000_000L); + String baseToken = testWallet.getBaseToken().sendAsync().join(); + + BigInteger balanceBeforeTransfer = testWallet.getBalance(RECEIVER, baseToken, ZkBlockParameterName.COMMITTED).sendAsync().join(); + + TransferTransaction transaction = new TransferTransaction(RECEIVER, amount, signer.getAddress()); + TransactionReceipt receipt = testWallet.transfer(transaction).sendAsync().join(); + testWallet.getTransactionReceiptProcessor().waitForTransactionReceipt(receipt.getTransactionHash()); + + BigInteger balanceAfterTransfer = testWallet.getBalance(RECEIVER, baseToken, ZkBlockParameterName.COMMITTED).sendAsync().join(); + + assertNotNull(receipt); + assertEquals(balanceAfterTransfer.subtract(balanceBeforeTransfer), amount); + } + @Test @Disabled public void testTransferEthWithPaymaster() throws TransactionException, IOException { BigInteger amount = BigInteger.valueOf(7_000_000_000L); PaymasterParams paymasterParams = new PaymasterParams(PAYMASTER, Numeric.hexStringToByteArray(FunctionEncoder.encode(Paymaster.encodeApprovalBased(TOKEN, BigInteger.ONE, new byte[] {})))); - BigInteger paymasterBeforeTransfer = testWallet.getBalance(PAYMASTER, ZkSyncAddresses.ETH_ADDRESS).sendAsync().join(); + BigInteger paymasterBeforeTransfer = testWallet.getBalance(PAYMASTER, ZkSyncAddresses.LEGACY_ETH_ADDRESS).sendAsync().join(); BigInteger paymasterTokenBeforeTransfer = testWallet.getBalance(PAYMASTER, TOKEN).sendAsync().join(); BigInteger senderBalanceBeforeTransfer = testWallet.getBalance().sendAsync().join(); BigInteger senderApprovalBeforeTransfer = testWallet.getBalance(TOKEN).sendAsync().join(); - BigInteger receiverBefore = testWallet.getBalance(RECEIVER, ZkSyncAddresses.ETH_ADDRESS).sendAsync().join(); + BigInteger receiverBefore = testWallet.getBalance(RECEIVER, ZkSyncAddresses.LEGACY_ETH_ADDRESS).sendAsync().join(); TransferTransaction transaction = new TransferTransaction(RECEIVER, amount, signer.getAddress(), paymasterParams); TransactionReceipt receipt = testWallet.transfer(transaction).sendAsync().join(); testWallet.getTransactionReceiptProcessor().waitForTransactionReceipt(receipt.getTransactionHash()); - BigInteger paymasterAfterTransfer = testWallet.getBalance(PAYMASTER, ZkSyncAddresses.ETH_ADDRESS).sendAsync().join(); + BigInteger paymasterAfterTransfer = testWallet.getBalance(PAYMASTER, ZkSyncAddresses.LEGACY_ETH_ADDRESS).sendAsync().join(); BigInteger paymasterTokenAfterTransfer = testWallet.getBalance(PAYMASTER, TOKEN).sendAsync().join(); BigInteger senderBalanceAfterTransfer = testWallet.getBalance().sendAsync().join(); BigInteger senderApprovalAfterTransfer = testWallet.getBalance(TOKEN).sendAsync().join(); - BigInteger receiverAfter = testWallet.getBalance(RECEIVER, ZkSyncAddresses.ETH_ADDRESS).sendAsync().join(); + BigInteger receiverAfter = testWallet.getBalance(RECEIVER, ZkSyncAddresses.LEGACY_ETH_ADDRESS).sendAsync().join(); assertNotNull(receipt); assertTrue(paymasterBeforeTransfer.subtract(paymasterAfterTransfer).compareTo(BigInteger.ZERO) >= 0); @@ -259,13 +430,16 @@ public void testWithdrawEth() throws Exception { BigInteger senderBefore = testWallet.getBalance().sendAsync().join(); - WithdrawTransaction transaction = new WithdrawTransaction(ZkSyncAddresses.ETH_ADDRESS, amount, testWallet.getAddress()); + WithdrawTransaction transaction = new WithdrawTransaction(ZkSyncAddresses.LEGACY_ETH_ADDRESS, amount, testWallet.getAddress()); TransactionReceipt result = testWallet.withdraw(transaction).sendAsync().join(); - TransactionReceipt receipt = testWallet.getTransactionReceiptProcessor().waitForTransactionReceipt(result.getTransactionHash()); + TransactionReceipt receipt = testWallet.getTransactionReceiptProcessor().waitFinalized(result.getTransactionHash()); + + TransactionReceipt finalizeWithdraw = testWallet.finalizeWithdraw(receipt.getTransactionHash(), 0).sendAsync().join(); BigInteger senderAfter = testWallet.getBalance().sendAsync().join(); assertNotNull(receipt); + assertNotNull(finalizeWithdraw); assertTrue(senderBefore.subtract(senderAfter).compareTo(amount) >= 0); } @Test @@ -278,7 +452,7 @@ public void testWithdrawEthWithPaymaster() throws Exception { BigInteger senderBefore = testWallet.getBalance().sendAsync().join(); BigInteger senderApprovalBefore = testWallet.getBalance(TOKEN).sendAsync().join(); - WithdrawTransaction transaction = new WithdrawTransaction(ZkSyncAddresses.ETH_ADDRESS, amount, paymasterParams); + WithdrawTransaction transaction = new WithdrawTransaction(ZkSyncAddresses.LEGACY_ETH_ADDRESS, amount, paymasterParams); TransactionReceipt result = testWallet.withdraw(transaction).sendAsync().join(); TransactionReceipt receipt = testWallet.getTransactionReceiptProcessor().waitForTransactionReceipt(result.getTransactionHash()); @@ -300,11 +474,13 @@ public void testWithdrawErc20() throws Exception { WithdrawTransaction transaction = new WithdrawTransaction(l2DAI, amount, testWallet.getAddress()); TransactionReceipt result = testWallet.withdraw(transaction).sendAsync().join(); - TransactionReceipt receipt = testWallet.getTransactionReceiptProcessor().waitForTransactionReceipt(result.getTransactionHash()); + TransactionReceipt receipt = testWallet.getTransactionReceiptProcessor().waitFinalized(result.getTransactionHash()); + TransactionReceipt finalizeWithdraw = testWallet.finalizeWithdraw(receipt.getTransactionHash(), 0).sendAsync().join(); BigInteger senderAfter = testWallet.getBalance(l2DAI).sendAsync().join(); assertNotNull(receipt); + assertNotNull(finalizeWithdraw); assertEquals(senderBefore.subtract(senderAfter), amount); } @Test @@ -331,14 +507,4 @@ public void testWithdrawErc20WithPaymaster() throws Exception { assertTrue(senderApprovalBefore.subtract(senderApprovalAfter).compareTo(BigInteger.ONE) == 0); assertEquals(senderBefore.subtract(senderAfter), amount); } - @Test - public void testGetFullRequiredDepositFee() throws IOException { - DepositTransaction transaction = new DepositTransaction(ZkSyncAddresses.ETH_ADDRESS, BigInteger.valueOf(5), null,null, null, null, null, null, null, null, null); - FullDepositFee fee = testWallet.getFullRequiredDepositFee(transaction); - assertTrue(fee.baseCost.compareTo(BigInteger.valueOf(285096500000000L)) == 0); - assertTrue(fee.l1GasLimit.compareTo(BigInteger.valueOf(132711)) == 0); - assertTrue(fee.l2GasLimit.compareTo(BigInteger.valueOf(570193)) == 0); - assertTrue(fee.maxPriorityFeePerGas.compareTo(BigInteger.valueOf(1500000000)) == 0); - assertTrue(fee.maxFeePerGas.compareTo(BigInteger.valueOf(1500000007)) == 0); - } }