1- import { $ , semver } from "bun" ;
1+ import { semver } from "bun" ;
22import { existsSync , readdirSync } from "fs-extra" ;
33import { Listr , type ListrTask } from "listr2" ;
44import * as path from "node:path" ;
@@ -16,9 +16,8 @@ import * as anvil from "./anvil";
1616import { downloadAndExtract } from "./download" ;
1717
1818const ANVIL_VERSION = "1.4.3" ;
19- const ROLLUPS_VERSION = "2.2.0" ;
20- const PRT_VERSION = "2.1.1" ;
21- const CANNON_VERSION = "2.1.1" ;
19+ const ROLLUPS_VERSION = "3.0.0-alpha.5" ;
20+ const PRT_VERSION = "3.0.0-alpha.2" ;
2221
2322const supportedChains = {
2423 arbitrum,
@@ -39,6 +38,10 @@ const dependencies: ListrTask[] = [
3938 url : `https://github.com/cartesi/dave/releases/download/v${ PRT_VERSION } /cartesi-rollups-prt-${ PRT_VERSION } -anvil-v${ ANVIL_VERSION } .tar.gz` ,
4039 destination : "build" ,
4140 } ,
41+ {
42+ url : `https://github.com/cartesi/dave/releases/download/v${ PRT_VERSION } /cartesi-rollups-prt-${ PRT_VERSION } -deployment-addresses.tar.gz` ,
43+ destination : "build" ,
44+ } ,
4245 {
4346 url : `https://github.com/cartesi/dave/releases/download/v${ PRT_VERSION } /cartesi-rollups-prt-${ PRT_VERSION } -contract-artifacts.tar.gz` ,
4447 destination : "out" ,
@@ -91,38 +94,41 @@ const collectContracts = async (dir: string): Promise<ContractDeployments> => {
9194 } ) ,
9295 ) ;
9396
94- return deployments . reduce ( ( contracts , deployment ) => {
95- const { abi, address, contractName } = deployment ;
96- contracts [ contractName ] = { abi, address } ;
97- return contracts ;
98- } , { } ) ;
97+ return deployments . reduce (
98+ ( contracts , deployment ) => {
99+ const { abi, address, contractName } = deployment ;
100+ contracts [ contractName ] = { abi, address } ;
101+ return contracts ;
102+ } ,
103+ { } as Record < string , { abi : any ; address : string } > ,
104+ ) ;
99105} ;
100106
101107/**
102- * Inspect cannon package and export to a directory
108+ * Prepare deployment information per chain
109+ * by collection contract information based on GitHub release from cartesi-rollups-prt
103110 * @param options.chainId - chainId to export
104111 */
105- const cannonTasks : ListrTask [ ] = Object . entries ( supportedChains ) . map (
106- ( [ name , chain ] ) => ( {
107- title : `Export chain ${ chain . id } of cannon package cartesi-dave-app-factory: ${ CANNON_VERSION } ` ,
108- task : async ( ) => {
109- const chainId = chain . id . toString ( ) ;
110- const exportDir = path . join ( "build" , "deployments" , chainId ) ;
111- await $ `cannon inspect cartesi-dave-app-factory: ${ CANNON_VERSION } --chain-id ${ chainId } --write- deployments ${ exportDir } --quiet` ;
112- const contracts = await collectContracts ( exportDir ) ;
112+ const perChainDeploymentTasks : ListrTask [ ] = Object . entries (
113+ supportedChains ,
114+ ) . map ( ( [ name , chain ] ) => ( {
115+ title : `Prepare deployment for chain ${ chain . id } for cartesi-rollups-prt ${ PRT_VERSION } ` ,
116+ task : async ( ) => {
117+ const chainId = chain . id . toString ( ) ;
118+ const exportDir = path . join ( "build" , " deployments" , chainId ) ;
119+ const contracts = await collectContracts ( exportDir ) ;
113120
114- const filename = path . join ( "deployments" , `${ name } .json` ) ;
115- await Bun . write (
116- filename ,
117- JSON . stringify ( {
118- name,
119- chainId,
120- contracts,
121- } ) ,
122- ) ;
123- } ,
124- } ) ,
125- ) ;
121+ const filename = path . join ( "deployments" , `${ name } .json` ) ;
122+ await Bun . write (
123+ filename ,
124+ JSON . stringify ( {
125+ name,
126+ chainId,
127+ contracts,
128+ } ) ,
129+ ) ;
130+ } ,
131+ } ) ) ;
126132
127133/**
128134 * Deploy contracts using forge script
@@ -198,7 +204,9 @@ const build = async () => {
198204
199205 // setup graceful anvil shutdown, just in case process is terminated prematurely
200206 const shutdown = async ( ) => {
201- await anvil . stop ( ctx . anvilProc ) ;
207+ if ( ctx . anvilProc ) {
208+ await anvil . stop ( ctx . anvilProc ) ;
209+ }
202210 } ;
203211 process . on ( "SIGINT" , shutdown ) ;
204212 process . on ( "SIGTERM" , shutdown ) ;
@@ -236,9 +244,11 @@ const build = async () => {
236244 } ,
237245 } ,
238246 {
239- title : "Export cannon packages " ,
247+ title : "Generate deployment per supported chain " ,
240248 task : async ( _ , task ) =>
241- task . newListr ( cannonTasks , { concurrent : true } ) ,
249+ task . newListr ( perChainDeploymentTasks , {
250+ concurrent : true ,
251+ } ) ,
242252 } ,
243253 {
244254 title : "Stopping anvil..." ,
0 commit comments