From 01081d645658e0c4bfb1d7021e21748521cb476a Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Wed, 15 May 2024 13:45:00 +0400 Subject: [PATCH 1/5] feat: simplify the omnichain template --- contracts/OnlySystem.sol | 10 +- contracts/ZetaChain.sol | 24 + package.json | 5 +- .../contracts/{{contractName}}.sol.hbs | 14 +- .../templates/omnichain/tasks/deploy.ts.hbs | 4 +- .../@openzeppelin/contracts/index.ts | 2 + .../protocol-contracts/contracts/evm/index.ts | 2 + .../contracts/evm/interfaces/index.ts | 1 + .../zevm/interfaces/IWZETA.sol/IWETH9.ts | 438 ++++++++++++++++++ .../zevm/interfaces/IWZETA.sol/index.ts | 4 + .../contracts/zevm/interfaces/index.ts | 2 + typechain-types/contracts/OmnichainSwap.ts | 55 +++ typechain-types/contracts/OnlySystem.ts | 55 +++ typechain-types/contracts/ZetaChain.ts | 159 +++++++ typechain-types/contracts/index.ts | 2 + .../@openzeppelin/contracts/index.ts | 1 + .../protocol-contracts/contracts/evm/index.ts | 1 + .../contracts/evm/interfaces/index.ts | 1 + .../interfaces/IWZETA.sol/IWETH9__factory.ts | 264 +++++++++++ .../zevm/interfaces/IWZETA.sol/index.ts | 4 + .../contracts/zevm/interfaces/index.ts | 1 + .../contracts/OmnichainSwap__factory.ts | 73 +++ .../contracts/OnlySystem__factory.ts | 90 ++++ .../contracts/SwapHelperLib__factory.ts | 2 +- .../factories/contracts/ZetaChain__factory.ts | 92 ++++ typechain-types/factories/contracts/index.ts | 2 + typechain-types/hardhat.d.ts | 63 +++ typechain-types/index.ts | 14 + 28 files changed, 1367 insertions(+), 18 deletions(-) create mode 100644 contracts/ZetaChain.sol create mode 100644 typechain-types/@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol/IWETH9.ts create mode 100644 typechain-types/@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol/index.ts create mode 100644 typechain-types/contracts/OmnichainSwap.ts create mode 100644 typechain-types/contracts/OnlySystem.ts create mode 100644 typechain-types/contracts/ZetaChain.ts create mode 100644 typechain-types/factories/@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol/IWETH9__factory.ts create mode 100644 typechain-types/factories/@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol/index.ts create mode 100644 typechain-types/factories/contracts/OmnichainSwap__factory.ts create mode 100644 typechain-types/factories/contracts/OnlySystem__factory.ts create mode 100644 typechain-types/factories/contracts/ZetaChain__factory.ts diff --git a/contracts/OnlySystem.sol b/contracts/OnlySystem.sol index 3745b4a4..9298e862 100644 --- a/contracts/OnlySystem.sol +++ b/contracts/OnlySystem.sol @@ -4,10 +4,16 @@ pragma solidity ^0.8.7; import "@zetachain/protocol-contracts/contracts/zevm/SystemContract.sol"; contract OnlySystem { + address internal systemContractAddress; + error OnlySystemContract(string); - modifier onlySystem(SystemContract systemContract) { - if (msg.sender != address(systemContract)) { + constructor(address _systemContractAddress) { + systemContractAddress = _systemContractAddress; + } + + modifier onlySystem() { + if (msg.sender != systemContractAddress) { revert OnlySystemContract( "Only system contract can call this function" ); diff --git a/contracts/ZetaChain.sol b/contracts/ZetaChain.sol new file mode 100644 index 00000000..0c3ae47f --- /dev/null +++ b/contracts/ZetaChain.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.7; + +import "./OnlySystem.sol"; +import "./BytesHelperLib.sol"; +import "./SwapHelperLib.sol"; +import "@zetachain/protocol-contracts/contracts/zevm/SystemContract.sol"; +import "@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol"; + +abstract contract ZetaChain is zContract, OnlySystem { + SystemContract public systemContract; + mapping(uint256 => address) private systemContracts; + + constructor() OnlySystem(_initializeSystemContracts()) { + address systemContractAddress = systemContracts[block.chainid]; + systemContract = SystemContract(systemContractAddress); + } + + function _initializeSystemContracts() private returns (address) { + systemContracts[7000] = 0x91d18e54DAf4F677cB28167158d6dd21F6aB3921; + systemContracts[7001] = 0xEdf1c3275d13489aCdC6cD6eD246E72458B8795B; + return systemContracts[block.chainid]; + } +} diff --git a/package.json b/package.json index 88165127..1df8b7bf 100644 --- a/package.json +++ b/package.json @@ -107,5 +107,6 @@ "spinnies": "^0.5.1", "tiny-secp256k1": "^2.2.3", "ws": "^8.13.0" - } -} \ No newline at end of file + }, + "packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72" +} diff --git a/packages/tasks/templates/omnichain/contracts/{{contractName}}.sol.hbs b/packages/tasks/templates/omnichain/contracts/{{contractName}}.sol.hbs index 6aab90c0..bdbdb28c 100644 --- a/packages/tasks/templates/omnichain/contracts/{{contractName}}.sol.hbs +++ b/packages/tasks/templates/omnichain/contracts/{{contractName}}.sol.hbs @@ -1,23 +1,17 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.7; -import "@zetachain/protocol-contracts/contracts/zevm/SystemContract.sol"; -import "@zetachain/protocol-contracts/contracts/zevm/interfaces/zContract.sol"; -import "@zetachain/toolkit/contracts/OnlySystem.sol"; +import "@zetachain/toolkit/contracts/ZetaChain.sol"; -contract {{contractName}} is zContract, OnlySystem { - SystemContract public systemContract; - - constructor(address systemContractAddress) { - systemContract = SystemContract(systemContractAddress); - } +contract {{contractName}} is ZetaChain { + constructor() ZetaChain() {} function onCrossChainCall( zContext calldata context, address zrc20, uint256 amount, bytes calldata message - ) external virtual override onlySystem(systemContract) { + ) external override onlySystem { {{#if arguments.pairsWithDataLocation}} ({{#each arguments.pairsWithDataLocation}}{{#if @index}}, {{/if}}{{this.[1]}} {{this.[0]}}{{/each}}) = abi.decode( message, diff --git a/packages/tasks/templates/omnichain/tasks/deploy.ts.hbs b/packages/tasks/templates/omnichain/tasks/deploy.ts.hbs index fa1d8b0f..1870aacb 100644 --- a/packages/tasks/templates/omnichain/tasks/deploy.ts.hbs +++ b/packages/tasks/templates/omnichain/tasks/deploy.ts.hbs @@ -18,10 +18,8 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => { ); } - const systemContract = getAddress("systemContract", network); - const factory = await hre.ethers.getContractFactory(args.name); - const contract = await factory.deploy(systemContract); + const contract = await factory.deploy(); await contract.deployed(); const isTestnet = network === "zeta_testnet"; diff --git a/typechain-types/@openzeppelin/contracts/index.ts b/typechain-types/@openzeppelin/contracts/index.ts index c2d4e462..e0b6b666 100644 --- a/typechain-types/@openzeppelin/contracts/index.ts +++ b/typechain-types/@openzeppelin/contracts/index.ts @@ -1,5 +1,7 @@ /* Autogenerated file. Do not edit manually. */ /* tslint:disable */ /* eslint-disable */ +import type * as access from "./access"; +export type { access }; import type * as token from "./token"; export type { token }; diff --git a/typechain-types/@zetachain/protocol-contracts/contracts/evm/index.ts b/typechain-types/@zetachain/protocol-contracts/contracts/evm/index.ts index 92159233..d702fef9 100644 --- a/typechain-types/@zetachain/protocol-contracts/contracts/evm/index.ts +++ b/typechain-types/@zetachain/protocol-contracts/contracts/evm/index.ts @@ -3,3 +3,5 @@ /* eslint-disable */ import type * as interfaces from "./interfaces"; export type { interfaces }; +import type * as tools from "./tools"; +export type { tools }; diff --git a/typechain-types/@zetachain/protocol-contracts/contracts/evm/interfaces/index.ts b/typechain-types/@zetachain/protocol-contracts/contracts/evm/interfaces/index.ts index 935a91ac..0ae4f35b 100644 --- a/typechain-types/@zetachain/protocol-contracts/contracts/evm/interfaces/index.ts +++ b/typechain-types/@zetachain/protocol-contracts/contracts/evm/interfaces/index.ts @@ -3,3 +3,4 @@ /* eslint-disable */ import type * as zetaInterfacesSol from "./ZetaInterfaces.sol"; export type { zetaInterfacesSol }; +export type { ZetaInteractorErrors } from "./ZetaInteractorErrors"; diff --git a/typechain-types/@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol/IWETH9.ts b/typechain-types/@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol/IWETH9.ts new file mode 100644 index 00000000..36336221 --- /dev/null +++ b/typechain-types/@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol/IWETH9.ts @@ -0,0 +1,438 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PayableOverrides, + PopulatedTransaction, + Signer, + utils, +} from "ethers"; +import type { + FunctionFragment, + Result, + EventFragment, +} from "@ethersproject/abi"; +import type { Listener, Provider } from "@ethersproject/providers"; +import type { + TypedEventFilter, + TypedEvent, + TypedListener, + OnEvent, + PromiseOrValue, +} from "../../../../../../common"; + +export interface IWETH9Interface extends utils.Interface { + functions: { + "allowance(address,address)": FunctionFragment; + "approve(address,uint256)": FunctionFragment; + "balanceOf(address)": FunctionFragment; + "deposit()": FunctionFragment; + "totalSupply()": FunctionFragment; + "transfer(address,uint256)": FunctionFragment; + "transferFrom(address,address,uint256)": FunctionFragment; + "withdraw(uint256)": FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | "allowance" + | "approve" + | "balanceOf" + | "deposit" + | "totalSupply" + | "transfer" + | "transferFrom" + | "withdraw" + ): FunctionFragment; + + encodeFunctionData( + functionFragment: "allowance", + values: [PromiseOrValue, PromiseOrValue] + ): string; + encodeFunctionData( + functionFragment: "approve", + values: [PromiseOrValue, PromiseOrValue] + ): string; + encodeFunctionData( + functionFragment: "balanceOf", + values: [PromiseOrValue] + ): string; + encodeFunctionData(functionFragment: "deposit", values?: undefined): string; + encodeFunctionData( + functionFragment: "totalSupply", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "transfer", + values: [PromiseOrValue, PromiseOrValue] + ): string; + encodeFunctionData( + functionFragment: "transferFrom", + values: [ + PromiseOrValue, + PromiseOrValue, + PromiseOrValue + ] + ): string; + encodeFunctionData( + functionFragment: "withdraw", + values: [PromiseOrValue] + ): string; + + decodeFunctionResult(functionFragment: "allowance", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "approve", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "balanceOf", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "deposit", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "totalSupply", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "transfer", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "transferFrom", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "withdraw", data: BytesLike): Result; + + events: { + "Approval(address,address,uint256)": EventFragment; + "Deposit(address,uint256)": EventFragment; + "Transfer(address,address,uint256)": EventFragment; + "Withdrawal(address,uint256)": EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: "Approval"): EventFragment; + getEvent(nameOrSignatureOrTopic: "Deposit"): EventFragment; + getEvent(nameOrSignatureOrTopic: "Transfer"): EventFragment; + getEvent(nameOrSignatureOrTopic: "Withdrawal"): EventFragment; +} + +export interface ApprovalEventObject { + owner: string; + spender: string; + value: BigNumber; +} +export type ApprovalEvent = TypedEvent< + [string, string, BigNumber], + ApprovalEventObject +>; + +export type ApprovalEventFilter = TypedEventFilter; + +export interface DepositEventObject { + dst: string; + wad: BigNumber; +} +export type DepositEvent = TypedEvent<[string, BigNumber], DepositEventObject>; + +export type DepositEventFilter = TypedEventFilter; + +export interface TransferEventObject { + from: string; + to: string; + value: BigNumber; +} +export type TransferEvent = TypedEvent< + [string, string, BigNumber], + TransferEventObject +>; + +export type TransferEventFilter = TypedEventFilter; + +export interface WithdrawalEventObject { + src: string; + wad: BigNumber; +} +export type WithdrawalEvent = TypedEvent< + [string, BigNumber], + WithdrawalEventObject +>; + +export type WithdrawalEventFilter = TypedEventFilter; + +export interface IWETH9 extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: IWETH9Interface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners( + eventFilter?: TypedEventFilter + ): Array>; + listeners(eventName?: string): Array; + removeAllListeners( + eventFilter: TypedEventFilter + ): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + allowance( + owner: PromiseOrValue, + spender: PromiseOrValue, + overrides?: CallOverrides + ): Promise<[BigNumber]>; + + approve( + spender: PromiseOrValue, + wad: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + balanceOf( + owner: PromiseOrValue, + overrides?: CallOverrides + ): Promise<[BigNumber]>; + + deposit( + overrides?: PayableOverrides & { from?: PromiseOrValue } + ): Promise; + + totalSupply(overrides?: CallOverrides): Promise<[BigNumber]>; + + transfer( + to: PromiseOrValue, + wad: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + transferFrom( + from: PromiseOrValue, + to: PromiseOrValue, + wad: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + withdraw( + wad: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + }; + + allowance( + owner: PromiseOrValue, + spender: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + approve( + spender: PromiseOrValue, + wad: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + balanceOf( + owner: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + deposit( + overrides?: PayableOverrides & { from?: PromiseOrValue } + ): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer( + to: PromiseOrValue, + wad: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + transferFrom( + from: PromiseOrValue, + to: PromiseOrValue, + wad: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + withdraw( + wad: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + callStatic: { + allowance( + owner: PromiseOrValue, + spender: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + approve( + spender: PromiseOrValue, + wad: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + balanceOf( + owner: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + deposit(overrides?: CallOverrides): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer( + to: PromiseOrValue, + wad: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + transferFrom( + from: PromiseOrValue, + to: PromiseOrValue, + wad: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + withdraw( + wad: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + }; + + filters: { + "Approval(address,address,uint256)"( + owner?: PromiseOrValue | null, + spender?: PromiseOrValue | null, + value?: null + ): ApprovalEventFilter; + Approval( + owner?: PromiseOrValue | null, + spender?: PromiseOrValue | null, + value?: null + ): ApprovalEventFilter; + + "Deposit(address,uint256)"( + dst?: PromiseOrValue | null, + wad?: null + ): DepositEventFilter; + Deposit( + dst?: PromiseOrValue | null, + wad?: null + ): DepositEventFilter; + + "Transfer(address,address,uint256)"( + from?: PromiseOrValue | null, + to?: PromiseOrValue | null, + value?: null + ): TransferEventFilter; + Transfer( + from?: PromiseOrValue | null, + to?: PromiseOrValue | null, + value?: null + ): TransferEventFilter; + + "Withdrawal(address,uint256)"( + src?: PromiseOrValue | null, + wad?: null + ): WithdrawalEventFilter; + Withdrawal( + src?: PromiseOrValue | null, + wad?: null + ): WithdrawalEventFilter; + }; + + estimateGas: { + allowance( + owner: PromiseOrValue, + spender: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + approve( + spender: PromiseOrValue, + wad: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + balanceOf( + owner: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + deposit( + overrides?: PayableOverrides & { from?: PromiseOrValue } + ): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer( + to: PromiseOrValue, + wad: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + transferFrom( + from: PromiseOrValue, + to: PromiseOrValue, + wad: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + withdraw( + wad: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + }; + + populateTransaction: { + allowance( + owner: PromiseOrValue, + spender: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + approve( + spender: PromiseOrValue, + wad: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + balanceOf( + owner: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + deposit( + overrides?: PayableOverrides & { from?: PromiseOrValue } + ): Promise; + + totalSupply(overrides?: CallOverrides): Promise; + + transfer( + to: PromiseOrValue, + wad: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + transferFrom( + from: PromiseOrValue, + to: PromiseOrValue, + wad: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + withdraw( + wad: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + }; +} diff --git a/typechain-types/@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol/index.ts b/typechain-types/@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol/index.ts new file mode 100644 index 00000000..95069327 --- /dev/null +++ b/typechain-types/@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol/index.ts @@ -0,0 +1,4 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export type { IWETH9 } from "./IWETH9"; diff --git a/typechain-types/@zetachain/protocol-contracts/contracts/zevm/interfaces/index.ts b/typechain-types/@zetachain/protocol-contracts/contracts/zevm/interfaces/index.ts index 7954e646..cb205b01 100644 --- a/typechain-types/@zetachain/protocol-contracts/contracts/zevm/interfaces/index.ts +++ b/typechain-types/@zetachain/protocol-contracts/contracts/zevm/interfaces/index.ts @@ -1,5 +1,7 @@ /* Autogenerated file. Do not edit manually. */ /* tslint:disable */ /* eslint-disable */ +import type * as iwzetaSol from "./IWZETA.sol"; +export type { iwzetaSol }; export type { IZRC20 } from "./IZRC20"; export type { ZContract } from "./ZContract"; diff --git a/typechain-types/contracts/OmnichainSwap.ts b/typechain-types/contracts/OmnichainSwap.ts new file mode 100644 index 00000000..7624a042 --- /dev/null +++ b/typechain-types/contracts/OmnichainSwap.ts @@ -0,0 +1,55 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { BaseContract, Signer, utils } from "ethers"; + +import type { Listener, Provider } from "@ethersproject/providers"; +import type { + TypedEventFilter, + TypedEvent, + TypedListener, + OnEvent, +} from "../common"; + +export interface OmnichainSwapInterface extends utils.Interface { + functions: {}; + + events: {}; +} + +export interface OmnichainSwap extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: OmnichainSwapInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners( + eventFilter?: TypedEventFilter + ): Array>; + listeners(eventName?: string): Array; + removeAllListeners( + eventFilter: TypedEventFilter + ): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: {}; + + callStatic: {}; + + filters: {}; + + estimateGas: {}; + + populateTransaction: {}; +} diff --git a/typechain-types/contracts/OnlySystem.ts b/typechain-types/contracts/OnlySystem.ts new file mode 100644 index 00000000..6e06145d --- /dev/null +++ b/typechain-types/contracts/OnlySystem.ts @@ -0,0 +1,55 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { BaseContract, Signer, utils } from "ethers"; + +import type { Listener, Provider } from "@ethersproject/providers"; +import type { + TypedEventFilter, + TypedEvent, + TypedListener, + OnEvent, +} from "../common"; + +export interface OnlySystemInterface extends utils.Interface { + functions: {}; + + events: {}; +} + +export interface OnlySystem extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: OnlySystemInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners( + eventFilter?: TypedEventFilter + ): Array>; + listeners(eventName?: string): Array; + removeAllListeners( + eventFilter: TypedEventFilter + ): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: {}; + + callStatic: {}; + + filters: {}; + + estimateGas: {}; + + populateTransaction: {}; +} diff --git a/typechain-types/contracts/ZetaChain.ts b/typechain-types/contracts/ZetaChain.ts new file mode 100644 index 00000000..421298ca --- /dev/null +++ b/typechain-types/contracts/ZetaChain.ts @@ -0,0 +1,159 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from "ethers"; +import type { FunctionFragment, Result } from "@ethersproject/abi"; +import type { Listener, Provider } from "@ethersproject/providers"; +import type { + TypedEventFilter, + TypedEvent, + TypedListener, + OnEvent, + PromiseOrValue, +} from "../common"; + +export type ZContextStruct = { + origin: PromiseOrValue; + sender: PromiseOrValue; + chainID: PromiseOrValue; +}; + +export type ZContextStructOutput = [string, string, BigNumber] & { + origin: string; + sender: string; + chainID: BigNumber; +}; + +export interface ZetaChainInterface extends utils.Interface { + functions: { + "onCrossChainCall((bytes,address,uint256),address,uint256,bytes)": FunctionFragment; + "systemContract()": FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: "onCrossChainCall" | "systemContract" + ): FunctionFragment; + + encodeFunctionData( + functionFragment: "onCrossChainCall", + values: [ + ZContextStruct, + PromiseOrValue, + PromiseOrValue, + PromiseOrValue + ] + ): string; + encodeFunctionData( + functionFragment: "systemContract", + values?: undefined + ): string; + + decodeFunctionResult( + functionFragment: "onCrossChainCall", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "systemContract", + data: BytesLike + ): Result; + + events: {}; +} + +export interface ZetaChain extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: ZetaChainInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners( + eventFilter?: TypedEventFilter + ): Array>; + listeners(eventName?: string): Array; + removeAllListeners( + eventFilter: TypedEventFilter + ): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + onCrossChainCall( + context: ZContextStruct, + zrc20: PromiseOrValue, + amount: PromiseOrValue, + message: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + systemContract(overrides?: CallOverrides): Promise<[string]>; + }; + + onCrossChainCall( + context: ZContextStruct, + zrc20: PromiseOrValue, + amount: PromiseOrValue, + message: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + systemContract(overrides?: CallOverrides): Promise; + + callStatic: { + onCrossChainCall( + context: ZContextStruct, + zrc20: PromiseOrValue, + amount: PromiseOrValue, + message: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + systemContract(overrides?: CallOverrides): Promise; + }; + + filters: {}; + + estimateGas: { + onCrossChainCall( + context: ZContextStruct, + zrc20: PromiseOrValue, + amount: PromiseOrValue, + message: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + systemContract(overrides?: CallOverrides): Promise; + }; + + populateTransaction: { + onCrossChainCall( + context: ZContextStruct, + zrc20: PromiseOrValue, + amount: PromiseOrValue, + message: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise; + + systemContract(overrides?: CallOverrides): Promise; + }; +} diff --git a/typechain-types/contracts/index.ts b/typechain-types/contracts/index.ts index 4f74065a..c484129e 100644 --- a/typechain-types/contracts/index.ts +++ b/typechain-types/contracts/index.ts @@ -7,6 +7,8 @@ import type * as zetaConnectorMockSol from "./ZetaConnectorMock.sol"; export type { zetaConnectorMockSol }; import type * as shared from "./shared"; export type { shared }; +export type { OnlySystem } from "./OnlySystem"; export type { SwapHelperLib } from "./SwapHelperLib"; export type { TestSystemContract } from "./TestSystemContract"; export type { TestZRC20 } from "./TestZRC20"; +export type { ZetaChain } from "./ZetaChain"; diff --git a/typechain-types/factories/@openzeppelin/contracts/index.ts b/typechain-types/factories/@openzeppelin/contracts/index.ts index a9780efc..3063f57a 100644 --- a/typechain-types/factories/@openzeppelin/contracts/index.ts +++ b/typechain-types/factories/@openzeppelin/contracts/index.ts @@ -1,4 +1,5 @@ /* Autogenerated file. Do not edit manually. */ /* tslint:disable */ /* eslint-disable */ +export * as access from "./access"; export * as token from "./token"; diff --git a/typechain-types/factories/@zetachain/protocol-contracts/contracts/evm/index.ts b/typechain-types/factories/@zetachain/protocol-contracts/contracts/evm/index.ts index 1d3444d5..9449ab84 100644 --- a/typechain-types/factories/@zetachain/protocol-contracts/contracts/evm/index.ts +++ b/typechain-types/factories/@zetachain/protocol-contracts/contracts/evm/index.ts @@ -2,3 +2,4 @@ /* tslint:disable */ /* eslint-disable */ export * as interfaces from "./interfaces"; +export * as tools from "./tools"; diff --git a/typechain-types/factories/@zetachain/protocol-contracts/contracts/evm/interfaces/index.ts b/typechain-types/factories/@zetachain/protocol-contracts/contracts/evm/interfaces/index.ts index e9347caa..e3731657 100644 --- a/typechain-types/factories/@zetachain/protocol-contracts/contracts/evm/interfaces/index.ts +++ b/typechain-types/factories/@zetachain/protocol-contracts/contracts/evm/interfaces/index.ts @@ -2,3 +2,4 @@ /* tslint:disable */ /* eslint-disable */ export * as zetaInterfacesSol from "./ZetaInterfaces.sol"; +export { ZetaInteractorErrors__factory } from "./ZetaInteractorErrors__factory"; diff --git a/typechain-types/factories/@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol/IWETH9__factory.ts b/typechain-types/factories/@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol/IWETH9__factory.ts new file mode 100644 index 00000000..5590cf88 --- /dev/null +++ b/typechain-types/factories/@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol/IWETH9__factory.ts @@ -0,0 +1,264 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from "ethers"; +import type { Provider } from "@ethersproject/providers"; +import type { + IWETH9, + IWETH9Interface, +} from "../../../../../../../@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol/IWETH9"; + +const _abi = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "Approval", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "dst", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "wad", + type: "uint256", + }, + ], + name: "Deposit", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "Transfer", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "src", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "wad", + type: "uint256", + }, + ], + name: "Withdrawal", + type: "event", + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address", + }, + { + internalType: "address", + name: "spender", + type: "address", + }, + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address", + }, + { + internalType: "uint256", + name: "wad", + type: "uint256", + }, + ], + name: "approve", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address", + }, + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "deposit", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address", + }, + { + internalType: "uint256", + name: "wad", + type: "uint256", + }, + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address", + }, + { + internalType: "address", + name: "to", + type: "address", + }, + { + internalType: "uint256", + name: "wad", + type: "uint256", + }, + ], + name: "transferFrom", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "wad", + type: "uint256", + }, + ], + name: "withdraw", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, +] as const; + +export class IWETH9__factory { + static readonly abi = _abi; + static createInterface(): IWETH9Interface { + return new utils.Interface(_abi) as IWETH9Interface; + } + static connect(address: string, signerOrProvider: Signer | Provider): IWETH9 { + return new Contract(address, _abi, signerOrProvider) as IWETH9; + } +} diff --git a/typechain-types/factories/@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol/index.ts b/typechain-types/factories/@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol/index.ts new file mode 100644 index 00000000..d3b0ed8d --- /dev/null +++ b/typechain-types/factories/@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol/index.ts @@ -0,0 +1,4 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export { IWETH9__factory } from "./IWETH9__factory"; diff --git a/typechain-types/factories/@zetachain/protocol-contracts/contracts/zevm/interfaces/index.ts b/typechain-types/factories/@zetachain/protocol-contracts/contracts/zevm/interfaces/index.ts index a62dd52b..7ba09734 100644 --- a/typechain-types/factories/@zetachain/protocol-contracts/contracts/zevm/interfaces/index.ts +++ b/typechain-types/factories/@zetachain/protocol-contracts/contracts/zevm/interfaces/index.ts @@ -1,5 +1,6 @@ /* Autogenerated file. Do not edit manually. */ /* tslint:disable */ /* eslint-disable */ +export * as iwzetaSol from "./IWZETA.sol"; export { IZRC20__factory } from "./IZRC20__factory"; export { ZContract__factory } from "./ZContract__factory"; diff --git a/typechain-types/factories/contracts/OmnichainSwap__factory.ts b/typechain-types/factories/contracts/OmnichainSwap__factory.ts new file mode 100644 index 00000000..64484755 --- /dev/null +++ b/typechain-types/factories/contracts/OmnichainSwap__factory.ts @@ -0,0 +1,73 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import { Signer, utils, Contract, ContractFactory, Overrides } from "ethers"; +import type { Provider, TransactionRequest } from "@ethersproject/providers"; +import type { PromiseOrValue } from "../../common"; +import type { + OmnichainSwap, + OmnichainSwapInterface, +} from "../../contracts/OmnichainSwap"; + +const _abi = [ + { + inputs: [], + name: "CantBeIdenticalAddresses", + type: "error", + }, + { + inputs: [], + name: "CantBeZeroAddress", + type: "error", + }, +] as const; + +const _bytecode = + "0x611ed3610053600b82828239805160001a607314610046577f4e487b7100000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100355760003560e01c80633a9e08e51461003a575b600080fd5b81801561004657600080fd5b50610061600480360381019061005c91906115f3565b610063565b005b6000606061479c876040013514156100b55761008184846000610423565b915061008f84846014610423565b60405160200161009f9190611826565b60405160208183030381529060405290506100d4565b60008085858101906100c791906114e1565b9150915081935080925050505b60008873ffffffffffffffffffffffffffffffffffffffff1663569541b96040518163ffffffff1660e01b815260040160206040518083038186803b15801561011c57600080fd5b505afa158015610130573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061015491906114b4565b905060008173ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16149050600080600083610228578673ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b8152600401604080518083038186803b1580156101d857600080fd5b505afa1580156101ec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610210919061153d565b80925081935050506102258d8c83858e610498565b92505b600061024f8e8d8761024557868e6102409190611b00565b610247565b8d5b8b6000610a31565b905084156102f6578573ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8861027d90611bd6565b60601c836040518363ffffffff1660e01b815260040161029e9291906118ca565b602060405180830381600087803b1580156102b857600080fd5b505af11580156102cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102f091906115c6565b50610413565b8273ffffffffffffffffffffffffffffffffffffffff1663095ea7b389846040518363ffffffff1660e01b81526004016103319291906118ca565b602060405180830381600087803b15801561034b57600080fd5b505af115801561035f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061038391906115c6565b508773ffffffffffffffffffffffffffffffffffffffff1663c701262688836040518363ffffffff1660e01b81526004016103bf9291906118f3565b602060405180830381600087803b1580156103d957600080fd5b505af11580156103ed573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041191906115c6565b505b5050505050505050505050505050565b600080848484906014866104379190611aaa565b9261044493929190611a6f565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050905060148101519150509392505050565b6000806105238773ffffffffffffffffffffffffffffffffffffffff1663d936a0126040518163ffffffff1660e01b815260040160206040518083038186803b1580156104e457600080fd5b505afa1580156104f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061051c91906114b4565b8786610fd6565b90506060811561061c57600267ffffffffffffffff81111561054857610547611d3c565b5b6040519080825280602002602001820160405280156105765781602001602082028036833780820191505090505b509050868160008151811061058e5761058d611d0d565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505084816001815181106105dd576105dc611d0d565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506107d3565b600367ffffffffffffffff81111561063757610636611d3c565b5b6040519080825280602002602001820160405280156106655781602001602082028036833780820191505090505b509050868160008151811061067d5761067c611d0d565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508773ffffffffffffffffffffffffffffffffffffffff1663569541b96040518163ffffffff1660e01b815260040160206040518083038186803b1580156106fd57600080fd5b505afa158015610711573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073591906114b4565b8160018151811061074957610748611d0d565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050848160028151811061079857610797611d0d565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250505b8673ffffffffffffffffffffffffffffffffffffffff1663095ea7b38973ffffffffffffffffffffffffffffffffffffffff1663842da36d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561083557600080fd5b505afa158015610849573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086d91906114b4565b866040518363ffffffff1660e01b815260040161088b9291906118ca565b602060405180830381600087803b1580156108a557600080fd5b505af11580156108b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108dd91906115c6565b5060008873ffffffffffffffffffffffffffffffffffffffff1663842da36d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561092657600080fd5b505afa15801561093a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095e91906114b4565b73ffffffffffffffffffffffffffffffffffffffff16638803dbee8887853060c861ffff164261098e9190611aaa565b6040518663ffffffff1660e01b81526004016109ae959493929190611923565b600060405180830381600087803b1580156109c857600080fd5b505af11580156109dc573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610a05919061157d565b905080600081518110610a1b57610a1a611d0d565b5b6020026020010151935050505095945050505050565b600080610abc8773ffffffffffffffffffffffffffffffffffffffff1663d936a0126040518163ffffffff1660e01b815260040160206040518083038186803b158015610a7d57600080fd5b505afa158015610a91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ab591906114b4565b8786610fd6565b905060608115610bb557600267ffffffffffffffff811115610ae157610ae0611d3c565b5b604051908082528060200260200182016040528015610b0f5781602001602082028036833780820191505090505b5090508681600081518110610b2757610b26611d0d565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508481600181518110610b7657610b75611d0d565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050610d6c565b600367ffffffffffffffff811115610bd057610bcf611d3c565b5b604051908082528060200260200182016040528015610bfe5781602001602082028036833780820191505090505b5090508681600081518110610c1657610c15611d0d565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508773ffffffffffffffffffffffffffffffffffffffff1663569541b96040518163ffffffff1660e01b815260040160206040518083038186803b158015610c9657600080fd5b505afa158015610caa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cce91906114b4565b81600181518110610ce257610ce1611d0d565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508481600281518110610d3157610d30611d0d565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250505b8673ffffffffffffffffffffffffffffffffffffffff1663095ea7b38973ffffffffffffffffffffffffffffffffffffffff1663842da36d6040518163ffffffff1660e01b815260040160206040518083038186803b158015610dce57600080fd5b505afa158015610de2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0691906114b4565b886040518363ffffffff1660e01b8152600401610e249291906118ca565b602060405180830381600087803b158015610e3e57600080fd5b505af1158015610e52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e7691906115c6565b5060008873ffffffffffffffffffffffffffffffffffffffff1663842da36d6040518163ffffffff1660e01b815260040160206040518083038186803b158015610ebf57600080fd5b505afa158015610ed3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ef791906114b4565b73ffffffffffffffffffffffffffffffffffffffff166338ed17398887853060c861ffff1642610f279190611aaa565b6040518663ffffffff1660e01b8152600401610f47959493929190611923565b600060405180830381600087803b158015610f6157600080fd5b505af1158015610f75573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610f9e919061157d565b90508060018351610faf9190611b00565b81518110610fc057610fbf611d0d565b5b6020026020010151935050505095945050505050565b600080610fe4858585611110565b905060008473ffffffffffffffffffffffffffffffffffffffff166370a08231836040518263ffffffff1660e01b815260040161102191906118af565b60206040518083038186803b15801561103957600080fd5b505afa15801561104d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107191906116a9565b118015611106575060008373ffffffffffffffffffffffffffffffffffffffff166370a08231836040518263ffffffff1660e01b81526004016110b491906118af565b60206040518083038186803b1580156110cc57600080fd5b505afa1580156110e0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061110491906116a9565b115b9150509392505050565b600080600061111f8585611182565b91509150858282604051602001611137929190611841565b6040516020818303038152906040528051906020012060405160200161115e92919061186d565b6040516020818303038152906040528051906020012060001c925050509392505050565b6000808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614156111eb576040517fcb1e7cfe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1610611225578284611228565b83835b8092508193505050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611297576040517f78b507da00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9250929050565b60006112b16112ac846119a2565b61197d565b905080838252602082019050828560208602820111156112d4576112d3611d99565b5b60005b8581101561130457816112ea888261149f565b8452602084019350602083019250506001810190506112d7565b5050509392505050565b600061132161131c846119ce565b61197d565b90508281526020810184848401111561133d5761133c611d9e565b5b611348848285611c3d565b509392505050565b60008135905061135f81611e2a565b92915050565b60008151905061137481611e2a565b92915050565b60008135905061138981611e41565b92915050565b600082601f8301126113a4576113a3611d85565b5b81516113b484826020860161129e565b91505092915050565b6000815190506113cc81611e58565b92915050565b60008083601f8401126113e8576113e7611d85565b5b8235905067ffffffffffffffff81111561140557611404611d80565b5b60208301915083600182028301111561142157611420611d99565b5b9250929050565b600082601f83011261143d5761143c611d85565b5b813561144d84826020860161130e565b91505092915050565b60008135905061146581611e6f565b92915050565b60006060828403121561148157611480611d8a565b5b81905092915050565b60008135905061149981611e86565b92915050565b6000815190506114ae81611e86565b92915050565b6000602082840312156114ca576114c9611da8565b5b60006114d884828501611365565b91505092915050565b600080604083850312156114f8576114f7611da8565b5b60006115068582860161137a565b925050602083013567ffffffffffffffff81111561152757611526611da3565b5b61153385828601611428565b9150509250929050565b6000806040838503121561155457611553611da8565b5b600061156285828601611365565b92505060206115738582860161149f565b9150509250929050565b60006020828403121561159357611592611da8565b5b600082015167ffffffffffffffff8111156115b1576115b0611da3565b5b6115bd8482850161138f565b91505092915050565b6000602082840312156115dc576115db611da8565b5b60006115ea848285016113bd565b91505092915050565b60008060008060008060a087890312156116105761160f611da8565b5b600061161e89828a01611456565b965050602087013567ffffffffffffffff81111561163f5761163e611da3565b5b61164b89828a0161146b565b955050604061165c89828a01611350565b945050606061166d89828a0161148a565b935050608087013567ffffffffffffffff81111561168e5761168d611da3565b5b61169a89828a016113d2565b92509250509295509295509295565b6000602082840312156116bf576116be611da8565b5b60006116cd8482850161149f565b91505092915050565b60006116e283836116ee565b60208301905092915050565b6116f781611b34565b82525050565b61170681611b34565b82525050565b61171d61171882611b34565b611cb0565b82525050565b600061172e82611a1f565b6117388185611a42565b9350611743836119ff565b8060005b8381101561177457815161175b88826116d6565b975061176683611a35565b925050600181019050611747565b5085935050505092915050565b61179261178d82611b90565b611cc2565b82525050565b60006117a382611a2a565b6117ad8185611a53565b93506117bd818560208601611c4c565b6117c681611dad565b840191505092915050565b60006117de602083611a64565b91506117e982611dd8565b602082019050919050565b6000611801600183611a64565b915061180c82611e01565b600182019050919050565b61182081611bcc565b82525050565b6000611832828461170c565b60148201915081905092915050565b600061184d828561170c565b60148201915061185d828461170c565b6014820191508190509392505050565b6000611878826117f4565b9150611884828561170c565b6014820191506118948284611781565b6020820191506118a3826117d1565b91508190509392505050565b60006020820190506118c460008301846116fd565b92915050565b60006040820190506118df60008301856116fd565b6118ec6020830184611817565b9392505050565b6000604082019050818103600083015261190d8185611798565b905061191c6020830184611817565b9392505050565b600060a0820190506119386000830188611817565b6119456020830187611817565b81810360408301526119578186611723565b905061196660608301856116fd565b6119736080830184611817565b9695505050505050565b6000611987611998565b90506119938282611c7f565b919050565b6000604051905090565b600067ffffffffffffffff8211156119bd576119bc611d3c565b5b602082029050602081019050919050565b600067ffffffffffffffff8211156119e9576119e8611d3c565b5b6119f282611dad565b9050602081019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b60008085851115611a8357611a82611d94565b5b83861115611a9457611a93611d8f565b5b6001850283019150848603905094509492505050565b6000611ab582611bcc565b9150611ac083611bcc565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115611af557611af4611cde565b5b828201905092915050565b6000611b0b82611bcc565b9150611b1683611bcc565b925082821015611b2957611b28611cde565b5b828203905092915050565b6000611b3f82611bac565b9050919050565b6000611b5182611bac565b9050919050565b60008115159050919050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b6000819050919050565b6000611ba582611b34565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000611be182611a2a565b82611beb84611a0f565b9050611bf681611d6b565b92506014821015611c3657611c317fffffffffffffffffffffffffffffffffffffffff00000000000000000000000083601403600802611dcb565b831692505b5050919050565b82818337600083830152505050565b60005b83811015611c6a578082015181840152602081019050611c4f565b83811115611c79576000848401525b50505050565b611c8882611dad565b810181811067ffffffffffffffff82111715611ca757611ca6611d3c565b5b80604052505050565b6000611cbb82611ccc565b9050919050565b6000819050919050565b6000611cd782611dbe565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000611d778251611b64565b80915050919050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b600082821b905092915050565b7f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f600082015250565b7fff00000000000000000000000000000000000000000000000000000000000000600082015250565b611e3381611b34565b8114611e3e57600080fd5b50565b611e4a81611b46565b8114611e5557600080fd5b50565b611e6181611b58565b8114611e6c57600080fd5b50565b611e7881611b9a565b8114611e8357600080fd5b50565b611e8f81611bcc565b8114611e9a57600080fd5b5056fea2646970667358221220f9e1c08106ab76fbfd6113a935948bf0f403c030ce1c914b82c435b35b7eeb1964736f6c63430008070033"; + +type OmnichainSwapConstructorParams = + | [signer?: Signer] + | ConstructorParameters; + +const isSuperArgs = ( + xs: OmnichainSwapConstructorParams +): xs is ConstructorParameters => xs.length > 1; + +export class OmnichainSwap__factory extends ContractFactory { + constructor(...args: OmnichainSwapConstructorParams) { + if (isSuperArgs(args)) { + super(...args); + } else { + super(_abi, _bytecode, args[0]); + } + } + + override deploy( + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise { + return super.deploy(overrides || {}) as Promise; + } + override getDeployTransaction( + overrides?: Overrides & { from?: PromiseOrValue } + ): TransactionRequest { + return super.getDeployTransaction(overrides || {}); + } + override attach(address: string): OmnichainSwap { + return super.attach(address) as OmnichainSwap; + } + override connect(signer: Signer): OmnichainSwap__factory { + return super.connect(signer) as OmnichainSwap__factory; + } + + static readonly bytecode = _bytecode; + static readonly abi = _abi; + static createInterface(): OmnichainSwapInterface { + return new utils.Interface(_abi) as OmnichainSwapInterface; + } + static connect( + address: string, + signerOrProvider: Signer | Provider + ): OmnichainSwap { + return new Contract(address, _abi, signerOrProvider) as OmnichainSwap; + } +} diff --git a/typechain-types/factories/contracts/OnlySystem__factory.ts b/typechain-types/factories/contracts/OnlySystem__factory.ts new file mode 100644 index 00000000..e912c06d --- /dev/null +++ b/typechain-types/factories/contracts/OnlySystem__factory.ts @@ -0,0 +1,90 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import { Signer, utils, Contract, ContractFactory, Overrides } from "ethers"; +import type { Provider, TransactionRequest } from "@ethersproject/providers"; +import type { PromiseOrValue } from "../../common"; +import type { + OnlySystem, + OnlySystemInterface, +} from "../../contracts/OnlySystem"; + +const _abi = [ + { + inputs: [ + { + internalType: "address", + name: "_systemContractAddress", + type: "address", + }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + name: "OnlySystemContract", + type: "error", + }, +] as const; + +const _bytecode = + "0x608060405234801561001057600080fd5b506040516101553803806101558339818101604052810190610032919061008d565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610108565b600081519050610087816100f1565b92915050565b6000602082840312156100a3576100a26100ec565b5b60006100b184828501610078565b91505092915050565b60006100c5826100cc565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600080fd5b6100fa816100ba565b811461010557600080fd5b50565b603f806101166000396000f3fe6080604052600080fdfea26469706673582212206a96c204136062952aef1b9d799057f079bab409bc73b1c69d5bd069adaddf2264736f6c63430008070033"; + +type OnlySystemConstructorParams = + | [signer?: Signer] + | ConstructorParameters; + +const isSuperArgs = ( + xs: OnlySystemConstructorParams +): xs is ConstructorParameters => xs.length > 1; + +export class OnlySystem__factory extends ContractFactory { + constructor(...args: OnlySystemConstructorParams) { + if (isSuperArgs(args)) { + super(...args); + } else { + super(_abi, _bytecode, args[0]); + } + } + + override deploy( + _systemContractAddress: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): Promise { + return super.deploy( + _systemContractAddress, + overrides || {} + ) as Promise; + } + override getDeployTransaction( + _systemContractAddress: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue } + ): TransactionRequest { + return super.getDeployTransaction(_systemContractAddress, overrides || {}); + } + override attach(address: string): OnlySystem { + return super.attach(address) as OnlySystem; + } + override connect(signer: Signer): OnlySystem__factory { + return super.connect(signer) as OnlySystem__factory; + } + + static readonly bytecode = _bytecode; + static readonly abi = _abi; + static createInterface(): OnlySystemInterface { + return new utils.Interface(_abi) as OnlySystemInterface; + } + static connect( + address: string, + signerOrProvider: Signer | Provider + ): OnlySystem { + return new Contract(address, _abi, signerOrProvider) as OnlySystem; + } +} diff --git a/typechain-types/factories/contracts/SwapHelperLib__factory.ts b/typechain-types/factories/contracts/SwapHelperLib__factory.ts index 9b59195f..2f0f5fb1 100644 --- a/typechain-types/factories/contracts/SwapHelperLib__factory.ts +++ b/typechain-types/factories/contracts/SwapHelperLib__factory.ts @@ -62,7 +62,7 @@ const _abi = [ ] as const; const _bytecode = - "0x610492610053600b82828239805160001a607314610046577f4e487b7100000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100355760003560e01c8063c63585cc1461003a575b600080fd5b610054600480360381019061004f919061020d565b61006a565b6040516100619190610351565b60405180910390f35b600080600061007985856100dc565b915091508582826040516020016100919291906102e3565b604051602081830303815290604052805190602001206040516020016100b892919061030f565b6040516020818303038152906040528051906020012060001c925050509392505050565b6000808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415610145576040517fcb1e7cfe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161061017f578284610182565b83835b8092508193505050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156101f1576040517f78b507da00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9250929050565b60008135905061020781610445565b92915050565b600080600060608486031215610226576102256103e1565b5b6000610234868287016101f8565b9350506020610245868287016101f8565b9250506040610256868287016101f8565b9150509250925092565b61026981610377565b82525050565b61028061027b82610377565b6103b3565b82525050565b61029761029282610389565b6103c5565b82525050565b60006102aa60208361036c565b91506102b5826103f3565b602082019050919050565b60006102cd60018361036c565b91506102d88261041c565b600182019050919050565b60006102ef828561026f565b6014820191506102ff828461026f565b6014820191508190509392505050565b600061031a826102c0565b9150610326828561026f565b6014820191506103368284610286565b6020820191506103458261029d565b91508190509392505050565b60006020820190506103666000830184610260565b92915050565b600081905092915050565b600061038282610393565b9050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006103be826103cf565b9050919050565b6000819050919050565b60006103da826103e6565b9050919050565b600080fd5b60008160601b9050919050565b7f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f600082015250565b7fff00000000000000000000000000000000000000000000000000000000000000600082015250565b61044e81610377565b811461045957600080fd5b5056fea2646970667358221220b10a491e33dfa621fcb8a77d7febf000e330b5776d1d0edf68ea15b6eb7590ad64736f6c63430008070033"; + "0x610492610053600b82828239805160001a607314610046577f4e487b7100000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100355760003560e01c8063c63585cc1461003a575b600080fd5b610054600480360381019061004f919061020d565b61006a565b6040516100619190610351565b60405180910390f35b600080600061007985856100dc565b915091508582826040516020016100919291906102e3565b604051602081830303815290604052805190602001206040516020016100b892919061030f565b6040516020818303038152906040528051906020012060001c925050509392505050565b6000808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415610145576040517fcb1e7cfe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161061017f578284610182565b83835b8092508193505050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156101f1576040517f78b507da00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9250929050565b60008135905061020781610445565b92915050565b600080600060608486031215610226576102256103e1565b5b6000610234868287016101f8565b9350506020610245868287016101f8565b9250506040610256868287016101f8565b9150509250925092565b61026981610377565b82525050565b61028061027b82610377565b6103b3565b82525050565b61029761029282610389565b6103c5565b82525050565b60006102aa60208361036c565b91506102b5826103f3565b602082019050919050565b60006102cd60018361036c565b91506102d88261041c565b600182019050919050565b60006102ef828561026f565b6014820191506102ff828461026f565b6014820191508190509392505050565b600061031a826102c0565b9150610326828561026f565b6014820191506103368284610286565b6020820191506103458261029d565b91508190509392505050565b60006020820190506103666000830184610260565b92915050565b600081905092915050565b600061038282610393565b9050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006103be826103cf565b9050919050565b6000819050919050565b60006103da826103e6565b9050919050565b600080fd5b60008160601b9050919050565b7f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f600082015250565b7fff00000000000000000000000000000000000000000000000000000000000000600082015250565b61044e81610377565b811461045957600080fd5b5056fea2646970667358221220ecd86d07164105c72752ddee1f025ed5b5a1f55fabb9a16df5693cec1df5179a64736f6c63430008070033"; type SwapHelperLibConstructorParams = | [signer?: Signer] diff --git a/typechain-types/factories/contracts/ZetaChain__factory.ts b/typechain-types/factories/contracts/ZetaChain__factory.ts new file mode 100644 index 00000000..3de998d8 --- /dev/null +++ b/typechain-types/factories/contracts/ZetaChain__factory.ts @@ -0,0 +1,92 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from "ethers"; +import type { Provider } from "@ethersproject/providers"; +import type { ZetaChain, ZetaChainInterface } from "../../contracts/ZetaChain"; + +const _abi = [ + { + inputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + name: "OnlySystemContract", + type: "error", + }, + { + inputs: [ + { + components: [ + { + internalType: "bytes", + name: "origin", + type: "bytes", + }, + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "uint256", + name: "chainID", + type: "uint256", + }, + ], + internalType: "struct zContext", + name: "context", + type: "tuple", + }, + { + internalType: "address", + name: "zrc20", + type: "address", + }, + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + { + internalType: "bytes", + name: "message", + type: "bytes", + }, + ], + name: "onCrossChainCall", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "systemContract", + outputs: [ + { + internalType: "contract SystemContract", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const; + +export class ZetaChain__factory { + static readonly abi = _abi; + static createInterface(): ZetaChainInterface { + return new utils.Interface(_abi) as ZetaChainInterface; + } + static connect( + address: string, + signerOrProvider: Signer | Provider + ): ZetaChain { + return new Contract(address, _abi, signerOrProvider) as ZetaChain; + } +} diff --git a/typechain-types/factories/contracts/index.ts b/typechain-types/factories/contracts/index.ts index 57f22cd3..a34a7712 100644 --- a/typechain-types/factories/contracts/index.ts +++ b/typechain-types/factories/contracts/index.ts @@ -4,6 +4,8 @@ export * as ethZetaMockSol from "./EthZetaMock.sol"; export * as zetaConnectorMockSol from "./ZetaConnectorMock.sol"; export * as shared from "./shared"; +export { OnlySystem__factory } from "./OnlySystem__factory"; export { SwapHelperLib__factory } from "./SwapHelperLib__factory"; export { TestSystemContract__factory } from "./TestSystemContract__factory"; export { TestZRC20__factory } from "./TestZRC20__factory"; +export { ZetaChain__factory } from "./ZetaChain__factory"; diff --git a/typechain-types/hardhat.d.ts b/typechain-types/hardhat.d.ts index d97adae5..3b0ae979 100644 --- a/typechain-types/hardhat.d.ts +++ b/typechain-types/hardhat.d.ts @@ -12,6 +12,14 @@ import * as Contracts from "."; declare module "hardhat/types/runtime" { interface HardhatEthersHelpers extends HardhatEthersHelpersBase { + getContractFactory( + name: "Ownable", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "Ownable2Step", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; getContractFactory( name: "ERC20", signerOrOptions?: ethers.Signer | FactoryOptions @@ -76,6 +84,10 @@ declare module "hardhat/types/runtime" { name: "UniswapV2Router02", signerOrOptions?: ethers.Signer | FactoryOptions ): Promise; + getContractFactory( + name: "ZetaInteractorErrors", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; getContractFactory( name: "ZetaCommonErrors", signerOrOptions?: ethers.Signer | FactoryOptions @@ -92,6 +104,14 @@ declare module "hardhat/types/runtime" { name: "ZetaTokenConsumer", signerOrOptions?: ethers.Signer | FactoryOptions ): Promise; + getContractFactory( + name: "ZetaInteractor", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; + getContractFactory( + name: "IWETH9", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; getContractFactory( name: "IZRC20", signerOrOptions?: ethers.Signer | FactoryOptions @@ -112,6 +132,10 @@ declare module "hardhat/types/runtime" { name: "ZetaEthMock", signerOrOptions?: ethers.Signer | FactoryOptions ): Promise; + getContractFactory( + name: "OnlySystem", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; getContractFactory( name: "IERC20", signerOrOptions?: ethers.Signer | FactoryOptions @@ -160,11 +184,25 @@ declare module "hardhat/types/runtime" { name: "TestZRC20", signerOrOptions?: ethers.Signer | FactoryOptions ): Promise; + getContractFactory( + name: "ZetaChain", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; getContractFactory( name: "ZetaConnectorMockValue", signerOrOptions?: ethers.Signer | FactoryOptions ): Promise; + getContractAt( + name: "Ownable", + address: string, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "Ownable2Step", + address: string, + signer?: ethers.Signer + ): Promise; getContractAt( name: "ERC20", address: string, @@ -245,6 +283,11 @@ declare module "hardhat/types/runtime" { address: string, signer?: ethers.Signer ): Promise; + getContractAt( + name: "ZetaInteractorErrors", + address: string, + signer?: ethers.Signer + ): Promise; getContractAt( name: "ZetaCommonErrors", address: string, @@ -265,6 +308,16 @@ declare module "hardhat/types/runtime" { address: string, signer?: ethers.Signer ): Promise; + getContractAt( + name: "ZetaInteractor", + address: string, + signer?: ethers.Signer + ): Promise; + getContractAt( + name: "IWETH9", + address: string, + signer?: ethers.Signer + ): Promise; getContractAt( name: "IZRC20", address: string, @@ -290,6 +343,11 @@ declare module "hardhat/types/runtime" { address: string, signer?: ethers.Signer ): Promise; + getContractAt( + name: "OnlySystem", + address: string, + signer?: ethers.Signer + ): Promise; getContractAt( name: "IERC20", address: string, @@ -350,6 +408,11 @@ declare module "hardhat/types/runtime" { address: string, signer?: ethers.Signer ): Promise; + getContractAt( + name: "ZetaChain", + address: string, + signer?: ethers.Signer + ): Promise; getContractAt( name: "ZetaConnectorMockValue", address: string, diff --git a/typechain-types/index.ts b/typechain-types/index.ts index df73bd66..b5c3b369 100644 --- a/typechain-types/index.ts +++ b/typechain-types/index.ts @@ -10,6 +10,10 @@ export type { zetachain }; import type * as contracts from "./contracts"; export type { contracts }; export * as factories from "./factories"; +export type { Ownable } from "./@openzeppelin/contracts/access/Ownable"; +export { Ownable__factory } from "./factories/@openzeppelin/contracts/access/Ownable__factory"; +export type { Ownable2Step } from "./@openzeppelin/contracts/access/Ownable2Step"; +export { Ownable2Step__factory } from "./factories/@openzeppelin/contracts/access/Ownable2Step__factory"; export type { ERC20 } from "./@openzeppelin/contracts/token/ERC20/ERC20"; export { ERC20__factory } from "./factories/@openzeppelin/contracts/token/ERC20/ERC20__factory"; export type { IERC20Metadata } from "./@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata"; @@ -38,6 +42,8 @@ export type { IWETH } from "./@uniswap/v2-periphery/contracts/interfaces/IWETH"; export { IWETH__factory } from "./factories/@uniswap/v2-periphery/contracts/interfaces/IWETH__factory"; export type { UniswapV2Router02 } from "./@uniswap/v2-periphery/contracts/UniswapV2Router02"; export { UniswapV2Router02__factory } from "./factories/@uniswap/v2-periphery/contracts/UniswapV2Router02__factory"; +export type { ZetaInteractorErrors } from "./@zetachain/protocol-contracts/contracts/evm/interfaces/ZetaInteractorErrors"; +export { ZetaInteractorErrors__factory } from "./factories/@zetachain/protocol-contracts/contracts/evm/interfaces/ZetaInteractorErrors__factory"; export type { ZetaCommonErrors } from "./@zetachain/protocol-contracts/contracts/evm/interfaces/ZetaInterfaces.sol/ZetaCommonErrors"; export { ZetaCommonErrors__factory } from "./factories/@zetachain/protocol-contracts/contracts/evm/interfaces/ZetaInterfaces.sol/ZetaCommonErrors__factory"; export type { ZetaConnector } from "./@zetachain/protocol-contracts/contracts/evm/interfaces/ZetaInterfaces.sol/ZetaConnector"; @@ -46,6 +52,10 @@ export type { ZetaReceiver } from "./@zetachain/protocol-contracts/contracts/evm export { ZetaReceiver__factory } from "./factories/@zetachain/protocol-contracts/contracts/evm/interfaces/ZetaInterfaces.sol/ZetaReceiver__factory"; export type { ZetaTokenConsumer } from "./@zetachain/protocol-contracts/contracts/evm/interfaces/ZetaInterfaces.sol/ZetaTokenConsumer"; export { ZetaTokenConsumer__factory } from "./factories/@zetachain/protocol-contracts/contracts/evm/interfaces/ZetaInterfaces.sol/ZetaTokenConsumer__factory"; +export type { ZetaInteractor } from "./@zetachain/protocol-contracts/contracts/evm/tools/ZetaInteractor"; +export { ZetaInteractor__factory } from "./factories/@zetachain/protocol-contracts/contracts/evm/tools/ZetaInteractor__factory"; +export type { IWETH9 } from "./@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol/IWETH9"; +export { IWETH9__factory } from "./factories/@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol/IWETH9__factory"; export type { IZRC20 } from "./@zetachain/protocol-contracts/contracts/zevm/interfaces/IZRC20"; export { IZRC20__factory } from "./factories/@zetachain/protocol-contracts/contracts/zevm/interfaces/IZRC20__factory"; export type { ZContract } from "./@zetachain/protocol-contracts/contracts/zevm/interfaces/ZContract"; @@ -56,6 +66,8 @@ export type { SystemContractErrors } from "./@zetachain/protocol-contracts/contr export { SystemContractErrors__factory } from "./factories/@zetachain/protocol-contracts/contracts/zevm/SystemContract.sol/SystemContractErrors__factory"; export type { ZetaEthMock } from "./contracts/EthZetaMock.sol/ZetaEthMock"; export { ZetaEthMock__factory } from "./factories/contracts/EthZetaMock.sol/ZetaEthMock__factory"; +export type { OnlySystem } from "./contracts/OnlySystem"; +export { OnlySystem__factory } from "./factories/contracts/OnlySystem__factory"; export type { Math } from "./contracts/shared/libraries/SafeMath.sol/Math"; export { Math__factory } from "./factories/contracts/shared/libraries/SafeMath.sol/Math__factory"; export type { UniswapV2Library } from "./contracts/shared/libraries/UniswapV2Library"; @@ -74,5 +86,7 @@ export type { TestSystemContract } from "./contracts/TestSystemContract"; export { TestSystemContract__factory } from "./factories/contracts/TestSystemContract__factory"; export type { TestZRC20 } from "./contracts/TestZRC20"; export { TestZRC20__factory } from "./factories/contracts/TestZRC20__factory"; +export type { ZetaChain } from "./contracts/ZetaChain"; +export { ZetaChain__factory } from "./factories/contracts/ZetaChain__factory"; export type { ZetaConnectorMockValue } from "./contracts/ZetaConnectorMock.sol/ZetaConnectorMockValue"; export { ZetaConnectorMockValue__factory } from "./factories/contracts/ZetaConnectorMock.sol/ZetaConnectorMockValue__factory"; From d4ecf31247de50062826a9c9a977fd6c5eff9f1c Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Tue, 21 May 2024 12:59:36 +0300 Subject: [PATCH 2/5] moved system contract logic into onlysystem --- contracts/OnlySystem.sol | 16 ++++++++++++---- contracts/ZetaChain.sol | 12 +----------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/contracts/OnlySystem.sol b/contracts/OnlySystem.sol index 9298e862..c20bf071 100644 --- a/contracts/OnlySystem.sol +++ b/contracts/OnlySystem.sol @@ -4,16 +4,24 @@ pragma solidity ^0.8.7; import "@zetachain/protocol-contracts/contracts/zevm/SystemContract.sol"; contract OnlySystem { - address internal systemContractAddress; + SystemContract internal systemContract; + mapping(uint256 => address) private systemContracts; error OnlySystemContract(string); - constructor(address _systemContractAddress) { - systemContractAddress = _systemContractAddress; + constructor() { + address _systemContractAddress = _initializeSystemContracts(); + systemContract = SystemContract(_systemContractAddress); + } + + function _initializeSystemContracts() private returns (address) { + systemContracts[7000] = 0x91d18e54DAf4F677cB28167158d6dd21F6aB3921; + systemContracts[7001] = 0xEdf1c3275d13489aCdC6cD6eD246E72458B8795B; + return systemContracts[block.chainid]; } modifier onlySystem() { - if (msg.sender != systemContractAddress) { + if (msg.sender != address(systemContract)) { revert OnlySystemContract( "Only system contract can call this function" ); diff --git a/contracts/ZetaChain.sol b/contracts/ZetaChain.sol index 0c3ae47f..78d59abd 100644 --- a/contracts/ZetaChain.sol +++ b/contracts/ZetaChain.sol @@ -8,17 +8,7 @@ import "@zetachain/protocol-contracts/contracts/zevm/SystemContract.sol"; import "@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol"; abstract contract ZetaChain is zContract, OnlySystem { - SystemContract public systemContract; - mapping(uint256 => address) private systemContracts; - constructor() OnlySystem(_initializeSystemContracts()) { - address systemContractAddress = systemContracts[block.chainid]; - systemContract = SystemContract(systemContractAddress); - } - - function _initializeSystemContracts() private returns (address) { - systemContracts[7000] = 0x91d18e54DAf4F677cB28167158d6dd21F6aB3921; - systemContracts[7001] = 0xEdf1c3275d13489aCdC6cD6eD246E72458B8795B; - return systemContracts[block.chainid]; + constructor() OnlySystem() { } } From dc864b1552a155a634e672035b9670e6360cb482 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Thu, 23 May 2024 05:38:04 +0300 Subject: [PATCH 3/5] typechain types --- typechain-types/contracts/ZetaChain.ts | 23 +------------------ .../contracts/OnlySystem__factory.ts | 7 +++++- .../factories/contracts/ZetaChain__factory.ts | 13 ----------- 3 files changed, 7 insertions(+), 36 deletions(-) diff --git a/typechain-types/contracts/ZetaChain.ts b/typechain-types/contracts/ZetaChain.ts index 421298ca..5cc22360 100644 --- a/typechain-types/contracts/ZetaChain.ts +++ b/typechain-types/contracts/ZetaChain.ts @@ -38,12 +38,9 @@ export type ZContextStructOutput = [string, string, BigNumber] & { export interface ZetaChainInterface extends utils.Interface { functions: { "onCrossChainCall((bytes,address,uint256),address,uint256,bytes)": FunctionFragment; - "systemContract()": FunctionFragment; }; - getFunction( - nameOrSignatureOrTopic: "onCrossChainCall" | "systemContract" - ): FunctionFragment; + getFunction(nameOrSignatureOrTopic: "onCrossChainCall"): FunctionFragment; encodeFunctionData( functionFragment: "onCrossChainCall", @@ -54,19 +51,11 @@ export interface ZetaChainInterface extends utils.Interface { PromiseOrValue ] ): string; - encodeFunctionData( - functionFragment: "systemContract", - values?: undefined - ): string; decodeFunctionResult( functionFragment: "onCrossChainCall", data: BytesLike ): Result; - decodeFunctionResult( - functionFragment: "systemContract", - data: BytesLike - ): Result; events: {}; } @@ -105,8 +94,6 @@ export interface ZetaChain extends BaseContract { message: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - - systemContract(overrides?: CallOverrides): Promise<[string]>; }; onCrossChainCall( @@ -117,8 +104,6 @@ export interface ZetaChain extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - systemContract(overrides?: CallOverrides): Promise; - callStatic: { onCrossChainCall( context: ZContextStruct, @@ -127,8 +112,6 @@ export interface ZetaChain extends BaseContract { message: PromiseOrValue, overrides?: CallOverrides ): Promise; - - systemContract(overrides?: CallOverrides): Promise; }; filters: {}; @@ -141,8 +124,6 @@ export interface ZetaChain extends BaseContract { message: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - - systemContract(overrides?: CallOverrides): Promise; }; populateTransaction: { @@ -153,7 +134,5 @@ export interface ZetaChain extends BaseContract { message: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - - systemContract(overrides?: CallOverrides): Promise; }; } diff --git a/typechain-types/factories/contracts/OnlySystem__factory.ts b/typechain-types/factories/contracts/OnlySystem__factory.ts index 8d7775ba..1acbb358 100644 --- a/typechain-types/factories/contracts/OnlySystem__factory.ts +++ b/typechain-types/factories/contracts/OnlySystem__factory.ts @@ -10,6 +10,11 @@ import type { } from "../../contracts/OnlySystem"; const _abi = [ + { + inputs: [], + stateMutability: "nonpayable", + type: "constructor", + }, { inputs: [ { @@ -24,7 +29,7 @@ const _abi = [ ] as const; const _bytecode = - "0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe6080604052600080fdfea26469706673582212201ab8eb4b85cea37bdebcfd76388ba1fb426a3b2974f95edcfb6b12919a1c76d564736f6c63430008070033"; + "0x608060405234801561001057600080fd5b50600061002161006960201b60201c565b9050806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610174565b60007391d18e54daf4f677cb28167158d6dd21f6ab392160016000611b58815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555073edf1c3275d13489acdc6cd6ed246e72458b8795b60016000611b59815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600046815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b603f806101826000396000f3fe6080604052600080fdfea26469706673582212204ad7f1317d2cf0fbb89ed1137a929a638fe6fcfe267f7c5e5f2abbe5fc5d447664736f6c63430008070033"; type OnlySystemConstructorParams = | [signer?: Signer] diff --git a/typechain-types/factories/contracts/ZetaChain__factory.ts b/typechain-types/factories/contracts/ZetaChain__factory.ts index 3de998d8..1fce0c1d 100644 --- a/typechain-types/factories/contracts/ZetaChain__factory.ts +++ b/typechain-types/factories/contracts/ZetaChain__factory.ts @@ -63,19 +63,6 @@ const _abi = [ stateMutability: "nonpayable", type: "function", }, - { - inputs: [], - name: "systemContract", - outputs: [ - { - internalType: "contract SystemContract", - name: "", - type: "address", - }, - ], - stateMutability: "view", - type: "function", - }, ] as const; export class ZetaChain__factory { From 811a1ac29667bf477eda05e81fdfde207ff72541 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Fri, 31 May 2024 16:56:55 +0300 Subject: [PATCH 4/5] replace ZetaChain with ZetaChainApp --- contracts/ZetaChain.sol | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 contracts/ZetaChain.sol diff --git a/contracts/ZetaChain.sol b/contracts/ZetaChain.sol deleted file mode 100644 index 78d59abd..00000000 --- a/contracts/ZetaChain.sol +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.7; - -import "./OnlySystem.sol"; -import "./BytesHelperLib.sol"; -import "./SwapHelperLib.sol"; -import "@zetachain/protocol-contracts/contracts/zevm/SystemContract.sol"; -import "@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol"; - -abstract contract ZetaChain is zContract, OnlySystem { - - constructor() OnlySystem() { - } -} From f38edbb8aef3a57d847cacc10a84fbf584115ec1 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Fri, 31 May 2024 16:59:51 +0300 Subject: [PATCH 5/5] replace ZetaChain with ZetaChainApp --- contracts/ZetaChainApp.sol | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 contracts/ZetaChainApp.sol diff --git a/contracts/ZetaChainApp.sol b/contracts/ZetaChainApp.sol new file mode 100644 index 00000000..02129e28 --- /dev/null +++ b/contracts/ZetaChainApp.sol @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.7; + +import "./OnlySystem.sol"; +import "./BytesHelperLib.sol"; +import "./SwapHelperLib.sol"; +import "@zetachain/protocol-contracts/contracts/zevm/SystemContract.sol"; +import "@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol"; + +abstract contract ZetaChainApp is zContract, OnlySystem { + constructor() OnlySystem() {} +}