diff --git a/abi/IBridgedStandardToken.json b/abi/IBridgedStandardToken.json new file mode 100644 index 0000000..9d7ead0 --- /dev/null +++ b/abi/IBridgedStandardToken.json @@ -0,0 +1,181 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "IBridgedStandardToken", + "sourceName": "contracts/bridge/interfaces/IBridgedStandardToken.sol", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "BridgeBurn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "l1Token", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "decimals", + "type": "uint8" + } + ], + "name": "BridgeInitialize", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "BridgeMint", + "type": "event" + }, + { + "inputs": [], + "name": "assetId", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "bridgeBurn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "bridgeMint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "l1Address", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "l2Bridge", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nativeTokenVault", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "originToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x", + "deployedBytecode": "0x", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/abi/IL2AssetRouter.json b/abi/IL2AssetRouter.json new file mode 100644 index 0000000..66a59c0 --- /dev/null +++ b/abi/IL2AssetRouter.json @@ -0,0 +1,371 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "IL2AssetRouter", + "sourceName": "contracts/bridge/asset-router/IL2AssetRouter.sol", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "assetId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "_assetAddress", + "type": "address" + } + ], + "name": "AssetHandlerRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "assetId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "assetHandlerAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "additionalData", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "assetDeploymentTracker", + "type": "address" + } + ], + "name": "AssetHandlerRegisteredInitial", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "assetId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "BridgehubDepositBaseTokenInitiated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "txDataHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "assetId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "bridgeMintCalldata", + "type": "bytes" + } + ], + "name": "BridgehubDepositInitiated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "assetId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "assetDataHash", + "type": "bytes32" + } + ], + "name": "BridgehubWithdrawalInitiated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "assetId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "assetData", + "type": "bytes" + } + ], + "name": "DepositFinalizedAssetRouter", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "l2Sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "assetId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "assetData", + "type": "bytes" + } + ], + "name": "WithdrawalInitiatedAssetRouter", + "type": "event" + }, + { + "inputs": [], + "name": "BRIDGE_HUB", + "outputs": [ + { + "internalType": "contract IBridgehub", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_assetId", + "type": "bytes32" + } + ], + "name": "assetHandlerAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "_assetId", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "_transferData", + "type": "bytes" + } + ], + "name": "finalizeDeposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "l1AssetRouter", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_originChainId", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "_assetId", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "_assetAddress", + "type": "address" + } + ], + "name": "setAssetHandlerAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_assetRegistrationData", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "_assetHandlerAddress", + "type": "address" + } + ], + "name": "setAssetHandlerAddressThisChain", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_assetId", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "_transferData", + "type": "bytes" + } + ], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_l1Receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "_l2Token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_sender", + "type": "address" + } + ], + "name": "withdrawLegacyBridge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x", + "deployedBytecode": "0x", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/abi/IL2NativeTokenVault.json b/abi/IL2NativeTokenVault.json new file mode 100644 index 0000000..25a4de7 --- /dev/null +++ b/abi/IL2NativeTokenVault.json @@ -0,0 +1,298 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "IL2NativeTokenVault", + "sourceName": "contracts/bridge/ntv/IL2NativeTokenVault.sol", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "bridgedTokenBeacon", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "bridgedTokenProxyBytecodeHash", + "type": "bytes32" + } + ], + "name": "BridgedTokenBeaconUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "l1Sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "l2Receiver", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "l2Token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "FinalizeDeposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "l2TokenBeacon", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "l2TokenProxyBytecodeHash", + "type": "bytes32" + } + ], + "name": "L2TokenBeaconUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "l2Sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "l1Receiver", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "l2Token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "WithdrawalInitiated", + "type": "event" + }, + { + "inputs": [], + "name": "ASSET_ROUTER", + "outputs": [ + { + "internalType": "contract IAssetRouterBase", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WETH_TOKEN", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "assetId", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_tokenAddress", + "type": "address" + } + ], + "name": "calculateAssetId", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_originChainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_originToken", + "type": "address" + } + ], + "name": "calculateCreate2TokenAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_originChainId", + "type": "uint256" + } + ], + "name": "getERC20Getters", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_l1Token", + "type": "address" + } + ], + "name": "l2TokenAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "assetId", + "type": "bytes32" + } + ], + "name": "originChainId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_l1Token", + "type": "address" + } + ], + "name": "registerToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "assetId", + "type": "bytes32" + } + ], + "name": "tokenAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x", + "deployedBytecode": "0x", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/src/provider.ts b/src/provider.ts index 7c765fd..c912fa5 100644 --- a/src/provider.ts +++ b/src/provider.ts @@ -19,10 +19,16 @@ import { import { IERC20__factory, IEthToken__factory, + IL2AssetRouter, + IL2AssetRouter__factory, IL2Bridge, IL2Bridge__factory, + IL2NativeTokenVault, + IL2NativeTokenVault__factory, IL2SharedBridge, IL2SharedBridge__factory, + IBridgedStandardToken, + IBridgedStandardToken__factory, } from './typechain'; import { Address, @@ -65,6 +71,8 @@ import { getERC20DefaultBridgeData, getERC20BridgeCalldata, applyL1ToL2Alias, + L2_ASSET_ROUTER_ADDRESS, + L2_NATIVE_TOKEN_VAULT_ADDRESS, } from './utils'; import {Signer} from './signer'; @@ -506,6 +514,18 @@ export function JsonRpcApiProvider< return IL2SharedBridge__factory.connect(address, this); } + async connectL2NTV() : Promise { + return IL2NativeTokenVault__factory.connect(L2_NATIVE_TOKEN_VAULT_ADDRESS, this); + } + + async connectBridgedToken(token: Address): Promise { + return IBridgedStandardToken__factory.connect(token, this); + } + + async connectL2AssetRouter(): Promise { + return IL2AssetRouter__factory.connect(L2_ASSET_ROUTER_ADDRESS, this); + } + /** * Returns true if passed bridge address is legacy and false if its shared bridge. ** @@ -767,19 +787,44 @@ export function JsonRpcApiProvider< } return populatedTx; } + const ntv = await this.connectL2NTV(); + const assetId = await ntv.assetId(tx.token); + const originChainId = await ntv.originChainId(assetId); + console.log("originChainId", originChainId); + const l1ChainId = await this.getL1ChainId(); + const isTokenL1Native = originChainId == BigInt(l1ChainId) || tx.token == ETH_ADDRESS_IN_CONTRACTS; if (!tx.bridgeAddress) { const bridgeAddresses = await this.getDefaultBridgeAddresses(); - tx.bridgeAddress = bridgeAddresses.sharedL2; + console.log(bridgeAddresses) + tx.bridgeAddress = isTokenL1Native ? bridgeAddresses.sharedL2 : L2_ASSET_ROUTER_ADDRESS; + } + console.log("bridgeAddress 2", tx.bridgeAddress); + + let populatedTx; + if (!isTokenL1Native) { + let bridge = await this.connectL2AssetRouter(); + const token = await this.connectBridgedToken(tx.token); + const assetId = await token.assetId(); + const assetData = ethers.AbiCoder.defaultAbiCoder().encode( + ['uint256', 'address'], + [tx.amount, tx.to] + ) + + populatedTx = await bridge.withdraw.populateTransaction( + assetId, + assetData, + tx.overrides + ); + } else { + let bridge = await this.connectL2Bridge(tx.bridgeAddress!); + populatedTx = await bridge.withdraw.populateTransaction( + tx.to!, + tx.token, + tx.amount, + tx.overrides + ); } - - const bridge = await this.connectL2Bridge(tx.bridgeAddress!); - const populatedTx = await bridge.withdraw.populateTransaction( - tx.to!, - tx.token, - tx.amount, - tx.overrides - ); if (tx.paymasterParams) { return { ...populatedTx, diff --git a/src/typechain/IBridgedStandardToken.ts b/src/typechain/IBridgedStandardToken.ts new file mode 100644 index 0000000..d09c6f7 --- /dev/null +++ b/src/typechain/IBridgedStandardToken.ts @@ -0,0 +1,283 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumberish, + BytesLike, + FunctionFragment, + Result, + Interface, + EventFragment, + AddressLike, + ContractRunner, + ContractMethod, + Listener, +} from "ethers"; +import type { + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedLogDescription, + TypedListener, + TypedContractMethod, +} from "./common"; + +export interface IBridgedStandardTokenInterface extends Interface { + getFunction( + nameOrSignature: + | "assetId" + | "bridgeBurn" + | "bridgeMint" + | "l1Address" + | "l2Bridge" + | "nativeTokenVault" + | "originToken" + ): FunctionFragment; + + getEvent( + nameOrSignatureOrTopic: "BridgeBurn" | "BridgeInitialize" | "BridgeMint" + ): EventFragment; + + encodeFunctionData(functionFragment: "assetId", values?: undefined): string; + encodeFunctionData( + functionFragment: "bridgeBurn", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "bridgeMint", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData(functionFragment: "l1Address", values?: undefined): string; + encodeFunctionData(functionFragment: "l2Bridge", values?: undefined): string; + encodeFunctionData( + functionFragment: "nativeTokenVault", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "originToken", + values?: undefined + ): string; + + decodeFunctionResult(functionFragment: "assetId", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "bridgeBurn", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "bridgeMint", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "l1Address", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "l2Bridge", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "nativeTokenVault", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "originToken", + data: BytesLike + ): Result; +} + +export namespace BridgeBurnEvent { + export type InputTuple = [account: AddressLike, amount: BigNumberish]; + export type OutputTuple = [account: string, amount: bigint]; + export interface OutputObject { + account: string; + amount: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace BridgeInitializeEvent { + export type InputTuple = [ + l1Token: AddressLike, + name: string, + symbol: string, + decimals: BigNumberish + ]; + export type OutputTuple = [ + l1Token: string, + name: string, + symbol: string, + decimals: bigint + ]; + export interface OutputObject { + l1Token: string; + name: string; + symbol: string; + decimals: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace BridgeMintEvent { + export type InputTuple = [account: AddressLike, amount: BigNumberish]; + export type OutputTuple = [account: string, amount: bigint]; + export interface OutputObject { + account: string; + amount: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export interface IBridgedStandardToken extends BaseContract { + connect(runner?: ContractRunner | null): IBridgedStandardToken; + waitForDeployment(): Promise; + + interface: IBridgedStandardTokenInterface; + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + + on( + event: TCEvent, + listener: TypedListener + ): Promise; + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + once( + event: TCEvent, + listener: TypedListener + ): Promise; + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + listeners( + event: TCEvent + ): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners( + event?: TCEvent + ): Promise; + + assetId: TypedContractMethod<[], [string], "view">; + + bridgeBurn: TypedContractMethod< + [_account: AddressLike, _amount: BigNumberish], + [void], + "nonpayable" + >; + + bridgeMint: TypedContractMethod< + [_account: AddressLike, _amount: BigNumberish], + [void], + "nonpayable" + >; + + l1Address: TypedContractMethod<[], [string], "view">; + + l2Bridge: TypedContractMethod<[], [string], "view">; + + nativeTokenVault: TypedContractMethod<[], [string], "view">; + + originToken: TypedContractMethod<[], [string], "view">; + + getFunction( + key: string | FunctionFragment + ): T; + + getFunction( + nameOrSignature: "assetId" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "bridgeBurn" + ): TypedContractMethod< + [_account: AddressLike, _amount: BigNumberish], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "bridgeMint" + ): TypedContractMethod< + [_account: AddressLike, _amount: BigNumberish], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "l1Address" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "l2Bridge" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "nativeTokenVault" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "originToken" + ): TypedContractMethod<[], [string], "view">; + + getEvent( + key: "BridgeBurn" + ): TypedContractEvent< + BridgeBurnEvent.InputTuple, + BridgeBurnEvent.OutputTuple, + BridgeBurnEvent.OutputObject + >; + getEvent( + key: "BridgeInitialize" + ): TypedContractEvent< + BridgeInitializeEvent.InputTuple, + BridgeInitializeEvent.OutputTuple, + BridgeInitializeEvent.OutputObject + >; + getEvent( + key: "BridgeMint" + ): TypedContractEvent< + BridgeMintEvent.InputTuple, + BridgeMintEvent.OutputTuple, + BridgeMintEvent.OutputObject + >; + + filters: { + "BridgeBurn(address,uint256)": TypedContractEvent< + BridgeBurnEvent.InputTuple, + BridgeBurnEvent.OutputTuple, + BridgeBurnEvent.OutputObject + >; + BridgeBurn: TypedContractEvent< + BridgeBurnEvent.InputTuple, + BridgeBurnEvent.OutputTuple, + BridgeBurnEvent.OutputObject + >; + + "BridgeInitialize(address,string,string,uint8)": TypedContractEvent< + BridgeInitializeEvent.InputTuple, + BridgeInitializeEvent.OutputTuple, + BridgeInitializeEvent.OutputObject + >; + BridgeInitialize: TypedContractEvent< + BridgeInitializeEvent.InputTuple, + BridgeInitializeEvent.OutputTuple, + BridgeInitializeEvent.OutputObject + >; + + "BridgeMint(address,uint256)": TypedContractEvent< + BridgeMintEvent.InputTuple, + BridgeMintEvent.OutputTuple, + BridgeMintEvent.OutputObject + >; + BridgeMint: TypedContractEvent< + BridgeMintEvent.InputTuple, + BridgeMintEvent.OutputTuple, + BridgeMintEvent.OutputObject + >; + }; +} diff --git a/src/typechain/IL2AssetRouter.ts b/src/typechain/IL2AssetRouter.ts new file mode 100644 index 0000000..4e8ff54 --- /dev/null +++ b/src/typechain/IL2AssetRouter.ts @@ -0,0 +1,552 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumberish, + BytesLike, + FunctionFragment, + Result, + Interface, + EventFragment, + AddressLike, + ContractRunner, + ContractMethod, + Listener, +} from "ethers"; +import type { + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedLogDescription, + TypedListener, + TypedContractMethod, +} from "./common"; + +export interface IL2AssetRouterInterface extends Interface { + getFunction( + nameOrSignature: + | "BRIDGE_HUB" + | "assetHandlerAddress" + | "finalizeDeposit" + | "l1AssetRouter" + | "setAssetHandlerAddress" + | "setAssetHandlerAddressThisChain" + | "withdraw" + | "withdrawLegacyBridge" + ): FunctionFragment; + + getEvent( + nameOrSignatureOrTopic: + | "AssetHandlerRegistered" + | "AssetHandlerRegisteredInitial" + | "BridgehubDepositBaseTokenInitiated" + | "BridgehubDepositInitiated" + | "BridgehubWithdrawalInitiated" + | "DepositFinalizedAssetRouter" + | "WithdrawalInitiatedAssetRouter" + ): EventFragment; + + encodeFunctionData( + functionFragment: "BRIDGE_HUB", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "assetHandlerAddress", + values: [BytesLike] + ): string; + encodeFunctionData( + functionFragment: "finalizeDeposit", + values: [BigNumberish, BytesLike, BytesLike] + ): string; + encodeFunctionData( + functionFragment: "l1AssetRouter", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "setAssetHandlerAddress", + values: [BigNumberish, BytesLike, AddressLike] + ): string; + encodeFunctionData( + functionFragment: "setAssetHandlerAddressThisChain", + values: [BytesLike, AddressLike] + ): string; + encodeFunctionData( + functionFragment: "withdraw", + values: [BytesLike, BytesLike] + ): string; + encodeFunctionData( + functionFragment: "withdrawLegacyBridge", + values: [AddressLike, AddressLike, BigNumberish, AddressLike] + ): string; + + decodeFunctionResult(functionFragment: "BRIDGE_HUB", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "assetHandlerAddress", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "finalizeDeposit", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "l1AssetRouter", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setAssetHandlerAddress", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setAssetHandlerAddressThisChain", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "withdraw", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "withdrawLegacyBridge", + data: BytesLike + ): Result; +} + +export namespace AssetHandlerRegisteredEvent { + export type InputTuple = [assetId: BytesLike, _assetAddress: AddressLike]; + export type OutputTuple = [assetId: string, _assetAddress: string]; + export interface OutputObject { + assetId: string; + _assetAddress: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace AssetHandlerRegisteredInitialEvent { + export type InputTuple = [ + assetId: BytesLike, + assetHandlerAddress: AddressLike, + additionalData: BytesLike, + assetDeploymentTracker: AddressLike + ]; + export type OutputTuple = [ + assetId: string, + assetHandlerAddress: string, + additionalData: string, + assetDeploymentTracker: string + ]; + export interface OutputObject { + assetId: string; + assetHandlerAddress: string; + additionalData: string; + assetDeploymentTracker: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace BridgehubDepositBaseTokenInitiatedEvent { + export type InputTuple = [ + chainId: BigNumberish, + from: AddressLike, + assetId: BytesLike, + amount: BigNumberish + ]; + export type OutputTuple = [ + chainId: bigint, + from: string, + assetId: string, + amount: bigint + ]; + export interface OutputObject { + chainId: bigint; + from: string; + assetId: string; + amount: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace BridgehubDepositInitiatedEvent { + export type InputTuple = [ + chainId: BigNumberish, + txDataHash: BytesLike, + from: AddressLike, + assetId: BytesLike, + bridgeMintCalldata: BytesLike + ]; + export type OutputTuple = [ + chainId: bigint, + txDataHash: string, + from: string, + assetId: string, + bridgeMintCalldata: string + ]; + export interface OutputObject { + chainId: bigint; + txDataHash: string; + from: string; + assetId: string; + bridgeMintCalldata: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace BridgehubWithdrawalInitiatedEvent { + export type InputTuple = [ + chainId: BigNumberish, + sender: AddressLike, + assetId: BytesLike, + assetDataHash: BytesLike + ]; + export type OutputTuple = [ + chainId: bigint, + sender: string, + assetId: string, + assetDataHash: string + ]; + export interface OutputObject { + chainId: bigint; + sender: string; + assetId: string; + assetDataHash: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace DepositFinalizedAssetRouterEvent { + export type InputTuple = [ + chainId: BigNumberish, + assetId: BytesLike, + assetData: BytesLike + ]; + export type OutputTuple = [ + chainId: bigint, + assetId: string, + assetData: string + ]; + export interface OutputObject { + chainId: bigint; + assetId: string; + assetData: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace WithdrawalInitiatedAssetRouterEvent { + export type InputTuple = [ + chainId: BigNumberish, + l2Sender: AddressLike, + assetId: BytesLike, + assetData: BytesLike + ]; + export type OutputTuple = [ + chainId: bigint, + l2Sender: string, + assetId: string, + assetData: string + ]; + export interface OutputObject { + chainId: bigint; + l2Sender: string; + assetId: string; + assetData: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export interface IL2AssetRouter extends BaseContract { + connect(runner?: ContractRunner | null): IL2AssetRouter; + waitForDeployment(): Promise; + + interface: IL2AssetRouterInterface; + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + + on( + event: TCEvent, + listener: TypedListener + ): Promise; + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + once( + event: TCEvent, + listener: TypedListener + ): Promise; + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + listeners( + event: TCEvent + ): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners( + event?: TCEvent + ): Promise; + + BRIDGE_HUB: TypedContractMethod<[], [string], "view">; + + assetHandlerAddress: TypedContractMethod< + [_assetId: BytesLike], + [string], + "view" + >; + + finalizeDeposit: TypedContractMethod< + [_chainId: BigNumberish, _assetId: BytesLike, _transferData: BytesLike], + [void], + "nonpayable" + >; + + l1AssetRouter: TypedContractMethod<[], [string], "view">; + + setAssetHandlerAddress: TypedContractMethod< + [ + _originChainId: BigNumberish, + _assetId: BytesLike, + _assetAddress: AddressLike + ], + [void], + "nonpayable" + >; + + setAssetHandlerAddressThisChain: TypedContractMethod< + [_assetRegistrationData: BytesLike, _assetHandlerAddress: AddressLike], + [void], + "nonpayable" + >; + + withdraw: TypedContractMethod< + [_assetId: BytesLike, _transferData: BytesLike], + [void], + "nonpayable" + >; + + withdrawLegacyBridge: TypedContractMethod< + [ + _l1Receiver: AddressLike, + _l2Token: AddressLike, + _amount: BigNumberish, + _sender: AddressLike + ], + [void], + "nonpayable" + >; + + getFunction( + key: string | FunctionFragment + ): T; + + getFunction( + nameOrSignature: "BRIDGE_HUB" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "assetHandlerAddress" + ): TypedContractMethod<[_assetId: BytesLike], [string], "view">; + getFunction( + nameOrSignature: "finalizeDeposit" + ): TypedContractMethod< + [_chainId: BigNumberish, _assetId: BytesLike, _transferData: BytesLike], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "l1AssetRouter" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "setAssetHandlerAddress" + ): TypedContractMethod< + [ + _originChainId: BigNumberish, + _assetId: BytesLike, + _assetAddress: AddressLike + ], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "setAssetHandlerAddressThisChain" + ): TypedContractMethod< + [_assetRegistrationData: BytesLike, _assetHandlerAddress: AddressLike], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "withdraw" + ): TypedContractMethod< + [_assetId: BytesLike, _transferData: BytesLike], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "withdrawLegacyBridge" + ): TypedContractMethod< + [ + _l1Receiver: AddressLike, + _l2Token: AddressLike, + _amount: BigNumberish, + _sender: AddressLike + ], + [void], + "nonpayable" + >; + + getEvent( + key: "AssetHandlerRegistered" + ): TypedContractEvent< + AssetHandlerRegisteredEvent.InputTuple, + AssetHandlerRegisteredEvent.OutputTuple, + AssetHandlerRegisteredEvent.OutputObject + >; + getEvent( + key: "AssetHandlerRegisteredInitial" + ): TypedContractEvent< + AssetHandlerRegisteredInitialEvent.InputTuple, + AssetHandlerRegisteredInitialEvent.OutputTuple, + AssetHandlerRegisteredInitialEvent.OutputObject + >; + getEvent( + key: "BridgehubDepositBaseTokenInitiated" + ): TypedContractEvent< + BridgehubDepositBaseTokenInitiatedEvent.InputTuple, + BridgehubDepositBaseTokenInitiatedEvent.OutputTuple, + BridgehubDepositBaseTokenInitiatedEvent.OutputObject + >; + getEvent( + key: "BridgehubDepositInitiated" + ): TypedContractEvent< + BridgehubDepositInitiatedEvent.InputTuple, + BridgehubDepositInitiatedEvent.OutputTuple, + BridgehubDepositInitiatedEvent.OutputObject + >; + getEvent( + key: "BridgehubWithdrawalInitiated" + ): TypedContractEvent< + BridgehubWithdrawalInitiatedEvent.InputTuple, + BridgehubWithdrawalInitiatedEvent.OutputTuple, + BridgehubWithdrawalInitiatedEvent.OutputObject + >; + getEvent( + key: "DepositFinalizedAssetRouter" + ): TypedContractEvent< + DepositFinalizedAssetRouterEvent.InputTuple, + DepositFinalizedAssetRouterEvent.OutputTuple, + DepositFinalizedAssetRouterEvent.OutputObject + >; + getEvent( + key: "WithdrawalInitiatedAssetRouter" + ): TypedContractEvent< + WithdrawalInitiatedAssetRouterEvent.InputTuple, + WithdrawalInitiatedAssetRouterEvent.OutputTuple, + WithdrawalInitiatedAssetRouterEvent.OutputObject + >; + + filters: { + "AssetHandlerRegistered(bytes32,address)": TypedContractEvent< + AssetHandlerRegisteredEvent.InputTuple, + AssetHandlerRegisteredEvent.OutputTuple, + AssetHandlerRegisteredEvent.OutputObject + >; + AssetHandlerRegistered: TypedContractEvent< + AssetHandlerRegisteredEvent.InputTuple, + AssetHandlerRegisteredEvent.OutputTuple, + AssetHandlerRegisteredEvent.OutputObject + >; + + "AssetHandlerRegisteredInitial(bytes32,address,bytes32,address)": TypedContractEvent< + AssetHandlerRegisteredInitialEvent.InputTuple, + AssetHandlerRegisteredInitialEvent.OutputTuple, + AssetHandlerRegisteredInitialEvent.OutputObject + >; + AssetHandlerRegisteredInitial: TypedContractEvent< + AssetHandlerRegisteredInitialEvent.InputTuple, + AssetHandlerRegisteredInitialEvent.OutputTuple, + AssetHandlerRegisteredInitialEvent.OutputObject + >; + + "BridgehubDepositBaseTokenInitiated(uint256,address,bytes32,uint256)": TypedContractEvent< + BridgehubDepositBaseTokenInitiatedEvent.InputTuple, + BridgehubDepositBaseTokenInitiatedEvent.OutputTuple, + BridgehubDepositBaseTokenInitiatedEvent.OutputObject + >; + BridgehubDepositBaseTokenInitiated: TypedContractEvent< + BridgehubDepositBaseTokenInitiatedEvent.InputTuple, + BridgehubDepositBaseTokenInitiatedEvent.OutputTuple, + BridgehubDepositBaseTokenInitiatedEvent.OutputObject + >; + + "BridgehubDepositInitiated(uint256,bytes32,address,bytes32,bytes)": TypedContractEvent< + BridgehubDepositInitiatedEvent.InputTuple, + BridgehubDepositInitiatedEvent.OutputTuple, + BridgehubDepositInitiatedEvent.OutputObject + >; + BridgehubDepositInitiated: TypedContractEvent< + BridgehubDepositInitiatedEvent.InputTuple, + BridgehubDepositInitiatedEvent.OutputTuple, + BridgehubDepositInitiatedEvent.OutputObject + >; + + "BridgehubWithdrawalInitiated(uint256,address,bytes32,bytes32)": TypedContractEvent< + BridgehubWithdrawalInitiatedEvent.InputTuple, + BridgehubWithdrawalInitiatedEvent.OutputTuple, + BridgehubWithdrawalInitiatedEvent.OutputObject + >; + BridgehubWithdrawalInitiated: TypedContractEvent< + BridgehubWithdrawalInitiatedEvent.InputTuple, + BridgehubWithdrawalInitiatedEvent.OutputTuple, + BridgehubWithdrawalInitiatedEvent.OutputObject + >; + + "DepositFinalizedAssetRouter(uint256,bytes32,bytes)": TypedContractEvent< + DepositFinalizedAssetRouterEvent.InputTuple, + DepositFinalizedAssetRouterEvent.OutputTuple, + DepositFinalizedAssetRouterEvent.OutputObject + >; + DepositFinalizedAssetRouter: TypedContractEvent< + DepositFinalizedAssetRouterEvent.InputTuple, + DepositFinalizedAssetRouterEvent.OutputTuple, + DepositFinalizedAssetRouterEvent.OutputObject + >; + + "WithdrawalInitiatedAssetRouter(uint256,address,bytes32,bytes)": TypedContractEvent< + WithdrawalInitiatedAssetRouterEvent.InputTuple, + WithdrawalInitiatedAssetRouterEvent.OutputTuple, + WithdrawalInitiatedAssetRouterEvent.OutputObject + >; + WithdrawalInitiatedAssetRouter: TypedContractEvent< + WithdrawalInitiatedAssetRouterEvent.InputTuple, + WithdrawalInitiatedAssetRouterEvent.OutputTuple, + WithdrawalInitiatedAssetRouterEvent.OutputObject + >; + }; +} diff --git a/src/typechain/IL2NativeTokenVault.ts b/src/typechain/IL2NativeTokenVault.ts new file mode 100644 index 0000000..7e5905e --- /dev/null +++ b/src/typechain/IL2NativeTokenVault.ts @@ -0,0 +1,418 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumberish, + BytesLike, + FunctionFragment, + Result, + Interface, + EventFragment, + AddressLike, + ContractRunner, + ContractMethod, + Listener, +} from "ethers"; +import type { + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedLogDescription, + TypedListener, + TypedContractMethod, +} from "./common"; + +export interface IL2NativeTokenVaultInterface extends Interface { + getFunction( + nameOrSignature: + | "ASSET_ROUTER" + | "WETH_TOKEN" + | "assetId" + | "calculateAssetId" + | "calculateCreate2TokenAddress" + | "getERC20Getters" + | "l2TokenAddress" + | "originChainId" + | "registerToken" + | "tokenAddress" + ): FunctionFragment; + + getEvent( + nameOrSignatureOrTopic: + | "BridgedTokenBeaconUpdated" + | "FinalizeDeposit" + | "L2TokenBeaconUpdated" + | "WithdrawalInitiated" + ): EventFragment; + + encodeFunctionData( + functionFragment: "ASSET_ROUTER", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "WETH_TOKEN", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "assetId", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "calculateAssetId", + values: [BigNumberish, AddressLike] + ): string; + encodeFunctionData( + functionFragment: "calculateCreate2TokenAddress", + values: [BigNumberish, AddressLike] + ): string; + encodeFunctionData( + functionFragment: "getERC20Getters", + values: [AddressLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "l2TokenAddress", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "originChainId", + values: [BytesLike] + ): string; + encodeFunctionData( + functionFragment: "registerToken", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "tokenAddress", + values: [BytesLike] + ): string; + + decodeFunctionResult( + functionFragment: "ASSET_ROUTER", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "WETH_TOKEN", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "assetId", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "calculateAssetId", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "calculateCreate2TokenAddress", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getERC20Getters", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "l2TokenAddress", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "originChainId", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "registerToken", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "tokenAddress", + data: BytesLike + ): Result; +} + +export namespace BridgedTokenBeaconUpdatedEvent { + export type InputTuple = [ + bridgedTokenBeacon: AddressLike, + bridgedTokenProxyBytecodeHash: BytesLike + ]; + export type OutputTuple = [ + bridgedTokenBeacon: string, + bridgedTokenProxyBytecodeHash: string + ]; + export interface OutputObject { + bridgedTokenBeacon: string; + bridgedTokenProxyBytecodeHash: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace FinalizeDepositEvent { + export type InputTuple = [ + l1Sender: AddressLike, + l2Receiver: AddressLike, + l2Token: AddressLike, + amount: BigNumberish + ]; + export type OutputTuple = [ + l1Sender: string, + l2Receiver: string, + l2Token: string, + amount: bigint + ]; + export interface OutputObject { + l1Sender: string; + l2Receiver: string; + l2Token: string; + amount: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace L2TokenBeaconUpdatedEvent { + export type InputTuple = [ + l2TokenBeacon: AddressLike, + l2TokenProxyBytecodeHash: BytesLike + ]; + export type OutputTuple = [ + l2TokenBeacon: string, + l2TokenProxyBytecodeHash: string + ]; + export interface OutputObject { + l2TokenBeacon: string; + l2TokenProxyBytecodeHash: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace WithdrawalInitiatedEvent { + export type InputTuple = [ + l2Sender: AddressLike, + l1Receiver: AddressLike, + l2Token: AddressLike, + amount: BigNumberish + ]; + export type OutputTuple = [ + l2Sender: string, + l1Receiver: string, + l2Token: string, + amount: bigint + ]; + export interface OutputObject { + l2Sender: string; + l1Receiver: string; + l2Token: string; + amount: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export interface IL2NativeTokenVault extends BaseContract { + connect(runner?: ContractRunner | null): IL2NativeTokenVault; + waitForDeployment(): Promise; + + interface: IL2NativeTokenVaultInterface; + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + + on( + event: TCEvent, + listener: TypedListener + ): Promise; + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + once( + event: TCEvent, + listener: TypedListener + ): Promise; + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + listeners( + event: TCEvent + ): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners( + event?: TCEvent + ): Promise; + + ASSET_ROUTER: TypedContractMethod<[], [string], "view">; + + WETH_TOKEN: TypedContractMethod<[], [string], "view">; + + assetId: TypedContractMethod<[token: AddressLike], [string], "view">; + + calculateAssetId: TypedContractMethod< + [_chainId: BigNumberish, _tokenAddress: AddressLike], + [string], + "view" + >; + + calculateCreate2TokenAddress: TypedContractMethod< + [_originChainId: BigNumberish, _originToken: AddressLike], + [string], + "view" + >; + + getERC20Getters: TypedContractMethod< + [_token: AddressLike, _originChainId: BigNumberish], + [string], + "view" + >; + + l2TokenAddress: TypedContractMethod< + [_l1Token: AddressLike], + [string], + "view" + >; + + originChainId: TypedContractMethod<[assetId: BytesLike], [bigint], "view">; + + registerToken: TypedContractMethod< + [_l1Token: AddressLike], + [void], + "nonpayable" + >; + + tokenAddress: TypedContractMethod<[assetId: BytesLike], [string], "view">; + + getFunction( + key: string | FunctionFragment + ): T; + + getFunction( + nameOrSignature: "ASSET_ROUTER" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "WETH_TOKEN" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "assetId" + ): TypedContractMethod<[token: AddressLike], [string], "view">; + getFunction( + nameOrSignature: "calculateAssetId" + ): TypedContractMethod< + [_chainId: BigNumberish, _tokenAddress: AddressLike], + [string], + "view" + >; + getFunction( + nameOrSignature: "calculateCreate2TokenAddress" + ): TypedContractMethod< + [_originChainId: BigNumberish, _originToken: AddressLike], + [string], + "view" + >; + getFunction( + nameOrSignature: "getERC20Getters" + ): TypedContractMethod< + [_token: AddressLike, _originChainId: BigNumberish], + [string], + "view" + >; + getFunction( + nameOrSignature: "l2TokenAddress" + ): TypedContractMethod<[_l1Token: AddressLike], [string], "view">; + getFunction( + nameOrSignature: "originChainId" + ): TypedContractMethod<[assetId: BytesLike], [bigint], "view">; + getFunction( + nameOrSignature: "registerToken" + ): TypedContractMethod<[_l1Token: AddressLike], [void], "nonpayable">; + getFunction( + nameOrSignature: "tokenAddress" + ): TypedContractMethod<[assetId: BytesLike], [string], "view">; + + getEvent( + key: "BridgedTokenBeaconUpdated" + ): TypedContractEvent< + BridgedTokenBeaconUpdatedEvent.InputTuple, + BridgedTokenBeaconUpdatedEvent.OutputTuple, + BridgedTokenBeaconUpdatedEvent.OutputObject + >; + getEvent( + key: "FinalizeDeposit" + ): TypedContractEvent< + FinalizeDepositEvent.InputTuple, + FinalizeDepositEvent.OutputTuple, + FinalizeDepositEvent.OutputObject + >; + getEvent( + key: "L2TokenBeaconUpdated" + ): TypedContractEvent< + L2TokenBeaconUpdatedEvent.InputTuple, + L2TokenBeaconUpdatedEvent.OutputTuple, + L2TokenBeaconUpdatedEvent.OutputObject + >; + getEvent( + key: "WithdrawalInitiated" + ): TypedContractEvent< + WithdrawalInitiatedEvent.InputTuple, + WithdrawalInitiatedEvent.OutputTuple, + WithdrawalInitiatedEvent.OutputObject + >; + + filters: { + "BridgedTokenBeaconUpdated(address,bytes32)": TypedContractEvent< + BridgedTokenBeaconUpdatedEvent.InputTuple, + BridgedTokenBeaconUpdatedEvent.OutputTuple, + BridgedTokenBeaconUpdatedEvent.OutputObject + >; + BridgedTokenBeaconUpdated: TypedContractEvent< + BridgedTokenBeaconUpdatedEvent.InputTuple, + BridgedTokenBeaconUpdatedEvent.OutputTuple, + BridgedTokenBeaconUpdatedEvent.OutputObject + >; + + "FinalizeDeposit(address,address,address,uint256)": TypedContractEvent< + FinalizeDepositEvent.InputTuple, + FinalizeDepositEvent.OutputTuple, + FinalizeDepositEvent.OutputObject + >; + FinalizeDeposit: TypedContractEvent< + FinalizeDepositEvent.InputTuple, + FinalizeDepositEvent.OutputTuple, + FinalizeDepositEvent.OutputObject + >; + + "L2TokenBeaconUpdated(address,bytes32)": TypedContractEvent< + L2TokenBeaconUpdatedEvent.InputTuple, + L2TokenBeaconUpdatedEvent.OutputTuple, + L2TokenBeaconUpdatedEvent.OutputObject + >; + L2TokenBeaconUpdated: TypedContractEvent< + L2TokenBeaconUpdatedEvent.InputTuple, + L2TokenBeaconUpdatedEvent.OutputTuple, + L2TokenBeaconUpdatedEvent.OutputObject + >; + + "WithdrawalInitiated(address,address,address,uint256)": TypedContractEvent< + WithdrawalInitiatedEvent.InputTuple, + WithdrawalInitiatedEvent.OutputTuple, + WithdrawalInitiatedEvent.OutputObject + >; + WithdrawalInitiated: TypedContractEvent< + WithdrawalInitiatedEvent.InputTuple, + WithdrawalInitiatedEvent.OutputTuple, + WithdrawalInitiatedEvent.OutputObject + >; + }; +} diff --git a/src/typechain/factories/IBridgedStandardToken__factory.ts b/src/typechain/factories/IBridgedStandardToken__factory.ts new file mode 100644 index 0000000..494446f --- /dev/null +++ b/src/typechain/factories/IBridgedStandardToken__factory.ts @@ -0,0 +1,199 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Interface, type ContractRunner } from "ethers"; +import type { + IBridgedStandardToken, + IBridgedStandardTokenInterface, +} from "../IBridgedStandardToken"; + +const _abi = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "BridgeBurn", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "l1Token", + type: "address", + }, + { + indexed: false, + internalType: "string", + name: "name", + type: "string", + }, + { + indexed: false, + internalType: "string", + name: "symbol", + type: "string", + }, + { + indexed: false, + internalType: "uint8", + name: "decimals", + type: "uint8", + }, + ], + name: "BridgeInitialize", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "BridgeMint", + type: "event", + }, + { + inputs: [], + name: "assetId", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_account", + type: "address", + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, + ], + name: "bridgeBurn", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_account", + type: "address", + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, + ], + name: "bridgeMint", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "l1Address", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "l2Bridge", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "nativeTokenVault", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "originToken", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const; + +export class IBridgedStandardToken__factory { + static readonly abi = _abi; + static createInterface(): IBridgedStandardTokenInterface { + return new Interface(_abi) as IBridgedStandardTokenInterface; + } + static connect( + address: string, + runner?: ContractRunner | null + ): IBridgedStandardToken { + return new Contract( + address, + _abi, + runner + ) as unknown as IBridgedStandardToken; + } +} diff --git a/src/typechain/factories/IL2AssetRouter__factory.ts b/src/typechain/factories/IL2AssetRouter__factory.ts new file mode 100644 index 0000000..8294b02 --- /dev/null +++ b/src/typechain/factories/IL2AssetRouter__factory.ts @@ -0,0 +1,385 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Interface, type ContractRunner } from "ethers"; +import type { + IL2AssetRouter, + IL2AssetRouterInterface, +} from "../IL2AssetRouter"; + +const _abi = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "assetId", + type: "bytes32", + }, + { + indexed: true, + internalType: "address", + name: "_assetAddress", + type: "address", + }, + ], + name: "AssetHandlerRegistered", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "assetId", + type: "bytes32", + }, + { + indexed: true, + internalType: "address", + name: "assetHandlerAddress", + type: "address", + }, + { + indexed: true, + internalType: "bytes32", + name: "additionalData", + type: "bytes32", + }, + { + indexed: false, + internalType: "address", + name: "assetDeploymentTracker", + type: "address", + }, + ], + name: "AssetHandlerRegisteredInitial", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: true, + internalType: "address", + name: "from", + type: "address", + }, + { + indexed: false, + internalType: "bytes32", + name: "assetId", + type: "bytes32", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "BridgehubDepositBaseTokenInitiated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: true, + internalType: "bytes32", + name: "txDataHash", + type: "bytes32", + }, + { + indexed: true, + internalType: "address", + name: "from", + type: "address", + }, + { + indexed: false, + internalType: "bytes32", + name: "assetId", + type: "bytes32", + }, + { + indexed: false, + internalType: "bytes", + name: "bridgeMintCalldata", + type: "bytes", + }, + ], + name: "BridgehubDepositInitiated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: true, + internalType: "address", + name: "sender", + type: "address", + }, + { + indexed: true, + internalType: "bytes32", + name: "assetId", + type: "bytes32", + }, + { + indexed: false, + internalType: "bytes32", + name: "assetDataHash", + type: "bytes32", + }, + ], + name: "BridgehubWithdrawalInitiated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: true, + internalType: "bytes32", + name: "assetId", + type: "bytes32", + }, + { + indexed: false, + internalType: "bytes", + name: "assetData", + type: "bytes", + }, + ], + name: "DepositFinalizedAssetRouter", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: true, + internalType: "address", + name: "l2Sender", + type: "address", + }, + { + indexed: true, + internalType: "bytes32", + name: "assetId", + type: "bytes32", + }, + { + indexed: false, + internalType: "bytes", + name: "assetData", + type: "bytes", + }, + ], + name: "WithdrawalInitiatedAssetRouter", + type: "event", + }, + { + inputs: [], + name: "BRIDGE_HUB", + outputs: [ + { + internalType: "contract IBridgehub", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_assetId", + type: "bytes32", + }, + ], + name: "assetHandlerAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "bytes32", + name: "_assetId", + type: "bytes32", + }, + { + internalType: "bytes", + name: "_transferData", + type: "bytes", + }, + ], + name: "finalizeDeposit", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "l1AssetRouter", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_originChainId", + type: "uint256", + }, + { + internalType: "bytes32", + name: "_assetId", + type: "bytes32", + }, + { + internalType: "address", + name: "_assetAddress", + type: "address", + }, + ], + name: "setAssetHandlerAddress", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_assetRegistrationData", + type: "bytes32", + }, + { + internalType: "address", + name: "_assetHandlerAddress", + type: "address", + }, + ], + name: "setAssetHandlerAddressThisChain", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_assetId", + type: "bytes32", + }, + { + internalType: "bytes", + name: "_transferData", + type: "bytes", + }, + ], + name: "withdraw", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_l1Receiver", + type: "address", + }, + { + internalType: "address", + name: "_l2Token", + type: "address", + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, + { + internalType: "address", + name: "_sender", + type: "address", + }, + ], + name: "withdrawLegacyBridge", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, +] as const; + +export class IL2AssetRouter__factory { + static readonly abi = _abi; + static createInterface(): IL2AssetRouterInterface { + return new Interface(_abi) as IL2AssetRouterInterface; + } + static connect( + address: string, + runner?: ContractRunner | null + ): IL2AssetRouter { + return new Contract(address, _abi, runner) as unknown as IL2AssetRouter; + } +} diff --git a/src/typechain/factories/IL2NativeTokenVault__factory.ts b/src/typechain/factories/IL2NativeTokenVault__factory.ts new file mode 100644 index 0000000..c565bec --- /dev/null +++ b/src/typechain/factories/IL2NativeTokenVault__factory.ts @@ -0,0 +1,316 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Interface, type ContractRunner } from "ethers"; +import type { + IL2NativeTokenVault, + IL2NativeTokenVaultInterface, +} from "../IL2NativeTokenVault"; + +const _abi = [ + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "bridgedTokenBeacon", + type: "address", + }, + { + indexed: false, + internalType: "bytes32", + name: "bridgedTokenProxyBytecodeHash", + type: "bytes32", + }, + ], + name: "BridgedTokenBeaconUpdated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "l1Sender", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "l2Receiver", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "l2Token", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "FinalizeDeposit", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "l2TokenBeacon", + type: "address", + }, + { + indexed: true, + internalType: "bytes32", + name: "l2TokenProxyBytecodeHash", + type: "bytes32", + }, + ], + name: "L2TokenBeaconUpdated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "l2Sender", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "l1Receiver", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "l2Token", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "WithdrawalInitiated", + type: "event", + }, + { + inputs: [], + name: "ASSET_ROUTER", + outputs: [ + { + internalType: "contract IAssetRouterBase", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "WETH_TOKEN", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "token", + type: "address", + }, + ], + name: "assetId", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "address", + name: "_tokenAddress", + type: "address", + }, + ], + name: "calculateAssetId", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_originChainId", + type: "uint256", + }, + { + internalType: "address", + name: "_originToken", + type: "address", + }, + ], + name: "calculateCreate2TokenAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_token", + type: "address", + }, + { + internalType: "uint256", + name: "_originChainId", + type: "uint256", + }, + ], + name: "getERC20Getters", + outputs: [ + { + internalType: "bytes", + name: "", + type: "bytes", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_l1Token", + type: "address", + }, + ], + name: "l2TokenAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "assetId", + type: "bytes32", + }, + ], + name: "originChainId", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_l1Token", + type: "address", + }, + ], + name: "registerToken", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "assetId", + type: "bytes32", + }, + ], + name: "tokenAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const; + +export class IL2NativeTokenVault__factory { + static readonly abi = _abi; + static createInterface(): IL2NativeTokenVaultInterface { + return new Interface(_abi) as IL2NativeTokenVaultInterface; + } + static connect( + address: string, + runner?: ContractRunner | null + ): IL2NativeTokenVault { + return new Contract( + address, + _abi, + runner + ) as unknown as IL2NativeTokenVault; + } +} diff --git a/src/typechain/factories/index.ts b/src/typechain/factories/index.ts index 8b35eb6..be2ea51 100644 --- a/src/typechain/factories/index.ts +++ b/src/typechain/factories/index.ts @@ -1,6 +1,7 @@ /* Autogenerated file. Do not edit manually. */ /* tslint:disable */ /* eslint-disable */ +export { IBridgedStandardToken__factory } from "./IBridgedStandardToken__factory"; export { IBridgehub__factory } from "./IBridgehub__factory"; export { IContractDeployer__factory } from "./IContractDeployer__factory"; export { IERC1271__factory } from "./IERC1271__factory"; @@ -10,7 +11,9 @@ export { IL1Bridge__factory } from "./IL1Bridge__factory"; export { IL1ERC20Bridge__factory } from "./IL1ERC20Bridge__factory"; export { IL1Messenger__factory } from "./IL1Messenger__factory"; export { IL1SharedBridge__factory } from "./IL1SharedBridge__factory"; +export { IL2AssetRouter__factory } from "./IL2AssetRouter__factory"; export { IL2Bridge__factory } from "./IL2Bridge__factory"; +export { IL2NativeTokenVault__factory } from "./IL2NativeTokenVault__factory"; export { IL2SharedBridge__factory } from "./IL2SharedBridge__factory"; export { INonceHolder__factory } from "./INonceHolder__factory"; export { IPaymasterFlow__factory } from "./IPaymasterFlow__factory"; diff --git a/src/typechain/index.ts b/src/typechain/index.ts index baadae5..b35dd72 100644 --- a/src/typechain/index.ts +++ b/src/typechain/index.ts @@ -1,6 +1,7 @@ /* Autogenerated file. Do not edit manually. */ /* tslint:disable */ /* eslint-disable */ +export type { IBridgedStandardToken } from "./IBridgedStandardToken"; export type { IBridgehub } from "./IBridgehub"; export type { IContractDeployer } from "./IContractDeployer"; export type { IERC1271 } from "./IERC1271"; @@ -10,7 +11,9 @@ export type { IL1Bridge } from "./IL1Bridge"; export type { IL1ERC20Bridge } from "./IL1ERC20Bridge"; export type { IL1Messenger } from "./IL1Messenger"; export type { IL1SharedBridge } from "./IL1SharedBridge"; +export type { IL2AssetRouter } from "./IL2AssetRouter"; export type { IL2Bridge } from "./IL2Bridge"; +export type { IL2NativeTokenVault } from "./IL2NativeTokenVault"; export type { IL2SharedBridge } from "./IL2SharedBridge"; export type { INonceHolder } from "./INonceHolder"; export type { IPaymasterFlow } from "./IPaymasterFlow"; @@ -18,6 +21,7 @@ export type { ITestnetERC20Token } from "./ITestnetERC20Token"; export type { IZkSync } from "./IZkSync"; export type { IZkSyncHyperchain } from "./IZkSyncHyperchain"; export * as factories from "./factories"; +export { IBridgedStandardToken__factory } from "./factories/IBridgedStandardToken__factory"; export { IBridgehub__factory } from "./factories/IBridgehub__factory"; export { IContractDeployer__factory } from "./factories/IContractDeployer__factory"; export { IERC1271__factory } from "./factories/IERC1271__factory"; @@ -27,7 +31,9 @@ export { IL1Bridge__factory } from "./factories/IL1Bridge__factory"; export { IL1ERC20Bridge__factory } from "./factories/IL1ERC20Bridge__factory"; export { IL1Messenger__factory } from "./factories/IL1Messenger__factory"; export { IL1SharedBridge__factory } from "./factories/IL1SharedBridge__factory"; +export { IL2AssetRouter__factory } from "./factories/IL2AssetRouter__factory"; export { IL2Bridge__factory } from "./factories/IL2Bridge__factory"; +export { IL2NativeTokenVault__factory } from "./factories/IL2NativeTokenVault__factory"; export { IL2SharedBridge__factory } from "./factories/IL2SharedBridge__factory"; export { INonceHolder__factory } from "./factories/INonceHolder__factory"; export { IPaymasterFlow__factory } from "./factories/IPaymasterFlow__factory"; diff --git a/src/utils.ts b/src/utils.ts index ddd47aa..faf6736 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -154,6 +154,13 @@ export const NONCE_HOLDER_ADDRESS: Address = export const L1_TO_L2_ALIAS_OFFSET: Address = '0x1111000000000000000000000000000000001111'; + +export const L2_ASSET_ROUTER_ADDRESS: Address = + '0x0000000000000000000000000000000000010003'; + +export const L2_NATIVE_TOKEN_VAULT_ADDRESS: Address = + '0x0000000000000000000000000000000000010004'; + /** * The EIP1271 magic value used for signature validation in smart contracts. * This predefined constant serves as a standardized indicator to signal successful diff --git a/tests/integration/provider.test.ts b/tests/integration/provider.test.ts index 2ec2b63..4cb0652 100644 --- a/tests/integration/provider.test.ts +++ b/tests/integration/provider.test.ts @@ -580,6 +580,22 @@ describe('Provider', () => { expect(result).to.be.deepEqualExcluding(tx, ['data']); }); + it('should return a Crown withdraw transaction', async () => { + const tx = { + type: 113, + from: ADDRESS1, + to: (await provider.getDefaultBridgeAddresses()).sharedL2, + data: '0xd9caed1200000000000000000000000036615cf349d7f6344891b1e7ca7c72883f5dc04900000000000000000000000082b5ea13260346f4251c0940067a9117a6cf13840000000000000000000000000000000000000000000000000000000000000005', + }; + const result = await provider.getWithdrawTx({ + token: await provider.l2TokenAddress(APPROVAL_TOKEN), + amount: 5, + to: ADDRESS1, + from: ADDRESS1, + }); + expect(result).to.be.deepEqualExcluding(tx, ['data']); + }); + it('should return a withdraw transaction with `tx.from==tx.to` when `tx.to` is not provided', async () => { const tx = { type: 113, diff --git a/tests/integration/wallet.test.ts b/tests/integration/wallet.test.ts index 42a67fe..6c64c19 100644 --- a/tests/integration/wallet.test.ts +++ b/tests/integration/wallet.test.ts @@ -1601,6 +1601,36 @@ describe('Wallet', () => { amount ); }).timeout(90_000); + + // it('should withdraw Crown to the L1 network', async () => { + // const amount = 5n; + // const l2DAI = await provider.l2TokenAddress(DAI_L1); + // const l2BalanceBeforeWithdrawal = await wallet.getBalance(l2DAI); + // const l1BalanceBeforeWithdrawal = await wallet.getBalanceL1(DAI_L1); + + // const withdrawTx = await wallet.withdraw({ + // token: l2DAI, + // to: await wallet.getAddress(), + // amount: amount, + // }); + // await withdrawTx.waitFinalize(); + // expect(await wallet.isWithdrawalFinalized(withdrawTx.hash)).to.be.false; + + // const finalizeWithdrawTx = await wallet.finalizeWithdrawal( + // withdrawTx.hash + // ); + // const result = await finalizeWithdrawTx.wait(); + // const l2BalanceAfterWithdrawal = await wallet.getBalance(l2DAI); + // const l1BalanceAfterWithdrawal = await wallet.getBalanceL1(DAI_L1); + + // expect(result).not.to.be.null; + // expect(l2BalanceBeforeWithdrawal - l2BalanceAfterWithdrawal).to.be.equal( + // amount + // ); + // expect(l1BalanceAfterWithdrawal - l1BalanceBeforeWithdrawal).to.be.equal( + // amount + // ); + // }).timeout(90_000); }); describe('#getRequestExecuteTx()', () => { diff --git a/tests/utils.ts b/tests/utils.ts index 7944dfa..0f35e95 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -10,8 +10,11 @@ export const DAI_L1 = '0x70a0F165d6f8054d0d0CF8dFd4DD2005f0AF6B55'; export const APPROVAL_TOKEN = '0x841c43Fa5d8fFfdB9efE3358906f7578d8700Dd4'; // Crown token export const PAYMASTER = '0xa222f0c183AFA73a8Bc1AFb48D34C88c9Bf7A174'; // Crown token paymaster -export const IS_ETH_BASED = false; -export const L2_CHAIN_URL = IS_ETH_BASED - ? 'http://127.0.0.1:15100' - : 'http://127.0.0.1:15200'; -export const L1_CHAIN_URL = 'http://127.0.0.1:15045'; +export const IS_ETH_BASED = true; +export const L2_CHAIN_URL = 'http://127.0.0.1:3050' +export const L1_CHAIN_URL = 'http://127.0.0.1:8545' +// export const IS_ETH_BASED = false; +// export const L2_CHAIN_URL = IS_ETH_BASED +// ? 'http://127.0.0.1:15100' +// : 'http://127.0.0.1:15200'; +// export const L1_CHAIN_URL = 'http://127.0.0.1:15045';