@coinmeca/ethers
Version:
Solidty helpers and utilities for using ethers.
107 lines • 4.04 kB
TypeScript
import { Artifact, HardhatRuntimeEnvironment, RunSuperFunction, TaskArguments } from 'hardhat/types';
import { ResolvedFile } from 'hardhat/internal/solidity/resolver';
import { CompilationJob } from 'hardhat/internal/solidity/compilation-job';
import { BaseContract } from 'ethers';
import { AddressString } from './types';
export declare const FacetCutAction: {
Add: number;
Replace: number;
Remove: number;
};
export type BytesString = `0x${string[8]}`;
export interface Cut {
key: string;
data: Data[];
}
export type Data = string | {
action?: number;
facet: string;
selectors?: BytesString[] | CutData | CutData[];
};
export type CutData = {
action?: number;
selectors: BytesString[];
};
export interface Args {
owner: any;
init?: any;
initCalldata?: any;
}
export interface FacetCut {
key?: string;
action: number;
facetAddress: AddressString;
functionSelectors: BytesString[];
}
export interface DiamondCut {
key: string;
data: FacetCut[];
}
interface DiamondDeployerConfig {
address?: BytesString;
privateKey?: BytesString;
}
interface DiamondExportConfig {
path?: string;
file?: string;
}
interface abiConfig extends DiamondExportConfig {
include?: string[];
exclude?: string[];
filter?: (abiElement: any, index: number, abi: any[], name: string) => boolean;
}
interface DiamondArtifactConfig {
diamonds?: string[];
abi?: abiConfig;
}
export type Selector = `0x${string[8]}`;
export type ContractWithSelectors = Selectors & any;
export interface Selectors {
selectors?: Selector[];
get?: (this: ContractWithSelectors, functionNames?: (string | Selector)[]) => Selector[];
remove?: (this: ContractWithSelectors, functionNames: (string | Selector)[]) => (Selector | undefined)[];
[x: string | number | symbol]: any;
}
export interface DiamondConfig {
deployer?: DiamondDeployerConfig;
cut?: string;
artifact?: DiamondArtifactConfig;
loupe?: DiamondExportConfig;
}
type ArtifactsEmittedPerFile = Array<{
file: ResolvedFile;
artifactsEmitted: string[];
}>;
type ArtifactsEmittedPerJob = Array<{
compilationJob: CompilationJob;
artifactsEmittedPerFile: ArtifactsEmittedPerFile;
}>;
export declare function createArtifact(artifact: {
name: string;
directory: string;
info: any;
}, abi: unknown[]): Artifact;
export declare function createInfo(diamond: {
name: string;
address?: string;
facets?: any[];
init?: Args;
}): Promise<string>;
export declare function abi(name: string, facets?: string[]): Promise<string>;
export declare function cut(cuts: Cut[], display?: boolean, name?: string): Promise<DiamondCut[]>;
export declare function upgrade(contract: string | BaseContract & any, cuts: Cut[], init?: Args | boolean, display?: boolean): Promise<any>;
export declare function cutMultiple(facetCuts: FacetCut[]): Promise<any>;
export declare function cutAdd(key: string, facet: string, selectors: BytesString[]): Cut[];
export declare function cutReplace(key: string, facet: string, selectors: BytesString[]): Cut[];
export declare function cutRemove(key: string, facet: string, selectors: BytesString[]): Cut[];
export declare function factory(name: string, args: any[], display?: boolean): Promise<any>;
export declare function getAllFunctionNames(contract: ContractWithSelectors): string[];
export declare function getAllFunctionSelectors(contract: ContractWithSelectors, display?: boolean): Selector[];
export declare function getSelectors(contract: ContractWithSelectors): ContractWithSelectors;
export declare function getSelector(functionName: string): string | undefined;
export declare function removeSelectors(selectors: Selector[], functionNames: (Selector | string)[]): Selector[];
export declare function compile(args: TaskArguments, hre: HardhatRuntimeEnvironment, runSuper: RunSuperFunction<TaskArguments>): Promise<{
artifactsEmittedPerJob: ArtifactsEmittedPerJob;
} | void>;
export {};
//# sourceMappingURL=diamond.d.ts.map