@vechain/vebetterdao-contracts
Version:
Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.
111 lines (110 loc) • 4.91 kB
TypeScript
import { AppConfig } from "@repo/config";
export type ContractName = "VOT3" | "B3TRGovernor" | "GalaxyMember" | "X2EarnApps" | "VeBetterPassport" | "Emissions" | "TimeLock" | "XAllocationPool" | "XAllocationVoting" | "VoterRewards" | "Treasury" | "X2EarnRewardsPool" | "X2EarnCreator" | "GrantsManager" | "DBAPool" | "RelayerRewardsPool" | "NavigatorRegistry";
export declare const PROXY_ABI: string[];
/**
* Get the standardized list of all contracts with their proxy addresses
* @param config - The environment configuration containing contract addresses
* @returns Array of contract proxy addresses and names
*/
export declare function getAllContracts(config: AppConfig): Array<{
proxy: string;
name: ContractName;
}>;
export interface ContractInfo {
Contract: ContractName;
Proxy: string;
Implementation: string;
Libraries: string;
Status: string;
}
export interface LibraryInfo {
name: string;
address: string;
}
export declare function getImplementationAddress(proxyAddress: string): Promise<string | null>;
export declare function getVerificationMatch(address: string, chainId: string): Promise<string | null>;
/**
* Recursively search for a contract artifact file
* @param dir - Directory to search in
* @param contractName - The name of the contract
* @returns The path to the artifact file or null if not found
*/
export declare function findArtifactFile(dir: string, contractName: string): string | null;
/**
* Get project paths dynamically
*/
export declare function getProjectPaths(): {
contractsDir: string;
artifactsDir: string;
packageDir: string;
};
/**
* Get the artifact path for a contract dynamically
* @param contractName - The name of the contract
* @returns The path to the artifact file
*/
export declare function getArtifactPath(contractName: ContractName | string): string;
/**
* Extract library names from contract artifacts by reading linkReferences
* @param contractName - The name of the contract
* @returns Array of library names used by the contract
*/
export declare function discoverLibrariesFromArtifact(contractName: ContractName): string[];
/**
* Extract library addresses using artifact's deployedLinkReferences.
* @param implementationAddress - The deployed implementation contract address
* @param contractName - The contract name
* @returns Map of library names to their deployed addresses
*/
export declare function extractLibraryAddresses(implementationAddress: string, contractName: ContractName): Promise<Map<string, string>>;
/**
* Get detailed library information (name and address) for contracts that use libraries
* @param contractName - The name of the contract to check
* @param implementationAddress - The deployed implementation contract address
* @returns Array of LibraryInfo objects containing library names and addresses
*/
export declare function getContractLibraries(contractName: ContractName, implementationAddress: string | null): Promise<LibraryInfo[]>;
export declare function getLibraryAddresses(contractName: ContractName, implementationAddress: string | null): Promise<string[]>;
export declare function getVerificationStatus(proxyAddress: string, implementationAddress: string | null, libraryAddresses: string[], chainId: bigint): Promise<string>;
export declare function hasLibraries(contractName: ContractName): string;
/**
* Display detailed library information for a specific contract
* @param contractName - The name of the contract
* @param implementationAddress - The deployed implementation contract address
*/
export declare function displayLibraryInfo(contractName: ContractName, implementationAddress: string | null): Promise<void>;
/**
* Dynamically get contract file name from contract name by searching build-info files
*/
export declare function getContractFileName(contractName: ContractName | string): string;
/**
* Find contract metadata from build-info files
*/
export declare function findContractMetadata(contractFileName: string, contractName: string): any | null;
/**
* Copy source files based on metadata
*/
export declare function copySourceFiles(metadata: any, tempDir: string, contractsBaseDir: string): string[];
/**
* Submit verification to Sourcify v2 API
*/
export declare function submitVerification(chainId: string, contractAddress: string, metadata: any, copiedFiles: string[], tempDir: string): Promise<{
success: boolean;
verificationId?: string;
error?: string;
}>;
/**
* Poll verification job status
*/
export declare function pollVerificationJob(verificationId: string, maxWaitTime?: number, pollInterval?: number): Promise<{
success: boolean;
data?: any;
error?: string;
}>;
/**
* Dynamically find library contract file path by searching build-info files
*/
export declare function getLibraryContractInfo(libraryName: string): {
fileName: string;
contractName: string;
} | null;