(_network: Network, chainId: number)
| 55 | |
| 56 | export class ContractLoader { |
| 57 | static load(_network: Network, chainId: number) { |
| 58 | // call forge script to get the contract code |
| 59 | fs.mkdirSync(cacheDir, { recursive: true }) |
| 60 | const outputPath = path.join(cacheDir, `storage-code.${chainId}.json`) |
| 61 | console.log(`Write storage code to ${outputPath}...`) |
| 62 | const result = spawnSync( |
| 63 | 'forge', |
| 64 | [ |
| 65 | 'script', |
| 66 | './contracts/scripts/ArtifactHelper.s.sol', |
| 67 | '--sig', |
| 68 | 'run(uint256,string,address)', |
| 69 | `${chainId}`, |
| 70 | outputPath, |
| 71 | validatorRegistryAddress, |
| 72 | ], |
| 73 | { cwd: projectRoot, stdio: 'inherit' }, |
| 74 | ) |
| 75 | if (result.status !== 0) { |
| 76 | throw new Error(`Failed to generate storage code`) |
| 77 | } |
| 78 | const data = schemaContractRepo.parse(JSON.parse(fs.readFileSync(outputPath, 'utf-8'))) |
| 79 | const manifest = schemaManifest.parse( |
| 80 | JSON.parse(fs.readFileSync(path.join(projectRoot, 'assets/artifacts/manifest.json'), 'utf-8')), |
| 81 | ) |
| 82 | return new ContractLoader(data, manifest) |
| 83 | } |
| 84 | |
| 85 | constructor( |
| 86 | public repo: ContractRepo, |
no test coverage detected