dop-stick
Version:
Source control tooling for versionable-upgradeable smart contracts
164 lines • 6.86 kB
TypeScript
import { BatchedModuleFunctions, ModuleBatchValidationResult, UpgradeModule, ExtendedFacetCut } from '../types/upgrade';
import { DopStickConfig } from '../types/config';
import { UpgradeMode } from '../types/config';
import { UpgradeEntry } from '../types/upgrade';
import { TypechainFactoryManager } from './factory-management/typechain/factory';
/**
* BatchProcessor class handles the processing and validation of diamond contract upgrades
* including function batching, validation, and parallel deployment operations.
*/
export declare class BatchProcessor {
private readonly config;
private readonly mode;
private readonly logger;
private readonly typechainPath;
/**
* Creates a new BatchProcessor instance
* @param config - The DopStickConfig configuration object
*/
constructor(config: DopStickConfig);
/**
* Converts module upgrade configuration into batched format for efficient processing
* @param moduleConfig - The upgrade module configuration
* @returns BatchedModuleFunctions containing organized function signatures and actions
*/
batchModuleFunctions(moduleConfig: UpgradeModule): BatchedModuleFunctions;
/**
* Validates a batch of functions for a module
* @param batch - The batched module functions to validate
* @param mode - The upgrade mode being used
* @param isAutoDiscovered - Whether functions were auto-discovered
* @returns Promise<ModuleBatchValidationResult>
*/
validateBatch(batch: BatchedModuleFunctions, mode: UpgradeMode, isAutoDiscovered?: boolean): Promise<ModuleBatchValidationResult>;
/**
* Validates that functions exist in the contract
* @param batch - The batched module functions
* @param mode - The upgrade mode
* @returns Promise<ModuleBatchValidationResult>
*/
private validateFunctionsInContract;
/**
* Normalizes function signatures for consistent comparison
* @param signature - The function signature to normalize
* @returns Normalized signature string
*/
private normalizeSignature;
/**
* Checks for selector collisions across all functions
* @param batch - The batched module functions
* @returns Promise with collision map
*/
private checkAllCollisions;
/**
* Processes functions based on collision status and mode
* @param batch - The batched module functions
* @param collisionMap - Map of function collisions
* @param mode - The upgrade mode
* @param isAutoDiscovered - Whether functions were auto-discovered
* @returns Promise<ModuleBatchValidationResult>
*/
private processFunctions;
/**
* Handles functions in strict/basic mode
* @param functionsToProcess - Map of functions and their states
* @param result - Current validation result
* @returns ModuleBatchValidationResult
*/
private handleStrictMode;
/**
* Handles functions in auto-pilot mode
* @param functionsToProcess - Map of functions and their states
* @param result - Current validation result
* @returns ModuleBatchValidationResult
*/
private handleAutoPilotMode;
/**
* Handles functions in copilot mode
* @param functionsToProcess - Map of functions and their states
* @param result - Current validation result
* @returns Promise<ModuleBatchValidationResult>
*/
private handleCopilotMode;
/**
* Handles missing functions based on mode
* @param batch - The batched module functions
* @param missingFunctions - Array of missing function signatures
* @param mode - The upgrade mode
* @param result - Current validation result
* @returns Promise<ModuleBatchValidationResult>
*/
private handleMissingFunctions;
/**
* Process module deployments in parallel
* @param modules - Array of module names to deploy
* @param config - DopStick configuration
* @returns Promise<Map<string, string>> Map of module names to deployed addresses
*/
processParallelDeploymentsNew(modules: string[], factoryManager: TypechainFactoryManager): Promise<Map<string, string>>;
/**
* Gets the string representation of a DiamondCutAction
* @param action - The action to convert to string
* @returns String representation of the action
*/
private getActionName;
/**
* Determines the suggested action based on existence and original action
* @param exists - Whether the function exists
* @param originalAction - The original action specified
* @returns Suggested DiamondCutActionType or undefined
*/
private determineSuggestedAction;
/**
* Gets the reason for a suggested action change
* @param originalAction - The original action specified
* @param suggestedAction - The suggested action after validation
* @returns string explaining the reason for the change
*/
private getChangeReason;
/**
* Initializes a new validation result object
* @param batch - The batch to initialize the result for
* @returns Initialized ModuleBatchValidationResult
*/
private initializeValidationResult;
/**
* Handles validation errors and creates appropriate error result
* @param error - The error that occurred
* @param result - Current validation result
* @returns Updated ModuleBatchValidationResult with error information
*/
private handleValidationError;
/**
* Processes an upgrade entry and converts it to BatchedModuleFunctions
* @param entry - The upgrade entry to process
* @param mode - The upgrade mode
* @returns Promise<BatchedModuleFunctions>
*/
processUpgradeEntry(entry: UpgradeEntry, mode: UpgradeMode): Promise<BatchedModuleFunctions>;
/**
* Creates a batch from just a module name by reading the contract using TypechainFactoryManager
* @param moduleName - Name of the module to create batch for
* @returns Promise<BatchedModuleFunctions>
*/
private createBatchFromModuleName;
private parseType;
/**
* Converts validated results into final cuts for diamond upgrade
* @param validatedModules - Array of validated module results
* @returns Array of ExtendedFacetCut ready for upgrade
*/
prepareFinalCuts(validatedModules: ModuleBatchValidationResult[]): ExtendedFacetCut[];
/**
* Handles auto-discovered functions
* @param functionsToProcess - Map of functions and their states
* @param result - Current validation result
* @returns ModuleBatchValidationResult
*/
private handleAutoDiscoveredFunctions;
/**
* Handles parallel library deployments before module deployments
*/
private deployLibrariesInParallel;
}
//# sourceMappingURL=batchProcessor.d.ts.map