import * as zk from 'zksync-ethers'; import { DeployOpts, ProxyKindOption, StandaloneValidationOptions, ValidationOptions, withValidationDefaults, } from '@openzeppelin/upgrades-core'; import { DeploymentType, PaymasterParams } from 'zksync-ethers/build/types'; import { LOCAL_SETUP_ZKSYNC_NETWORK } from '../constants'; export type StandaloneOptions = StandaloneValidationOptions & DeployOpts & { constructorArgs?: unknown[]; useDeployedImplementation?: boolean; provider?: any; factoryDeps?: string[]; } & CustomDataOptions & InitialOwnerType; export interface InitialOwnerType { initialOwner?: string; } export type CustomDataOptions = TRequiredSeperateForProxy extends true | undefined ? { otherCustomData?: any; deploymentTypeImpl?: DeploymentType; deploymentTypeProxy?: DeploymentType; saltImpl?: string; saltProxy?: string; paymasterImplParams?: PaymasterParams; paymasterProxyParams?: PaymasterParams; } : { otherCustomData?: any; deploymentType?: DeploymentType; salt?: string; paymasterParams?: PaymasterParams; }; export type UpgradeOptions = ValidationOptions & StandaloneOptions; export function withDefaults( opts: UpgradeOptions = {}, ): Required> { return { constructorArgs: opts.constructorArgs ?? [], timeout: opts.timeout ?? 60e3, provider: opts.provider ?? new zk.Provider(LOCAL_SETUP_ZKSYNC_NETWORK), pollingInterval: opts.pollingInterval ?? 5e3, useDeployedImplementation: opts.useDeployedImplementation ?? true, factoryDeps: opts.factoryDeps ?? [], ...withValidationDefaults(opts), } as Required>; } interface Initializer { initializer?: string | false; } export type DeployBeaconProxyOptions = ProxyKindOption & Initializer & CustomDataOptions; export type DeployBeaconOptions = StandaloneOptions; export type DeployImplementationOptions = StandaloneOptions; export type DeployProxyOptions = StandaloneOptions & Initializer; export type UpgradeBeaconOptions = UpgradeOptions; export type UpgradeProxyOptions = UpgradeOptions & { call?: { fn: string; args?: unknown[] } | string; }; export type ValidateImplementationOptions = StandaloneValidationOptions;