@@ -18,7 +18,7 @@ async function setupPXE() {
1818
1919 const pxeDataDirectory = path . join ( import . meta. dirname , '.store' ) ;
2020 fs . rmSync ( pxeDataDirectory , { recursive : true , force : true } ) ;
21-
21+
2222 const store = await createStore ( 'pxe' , {
2323 dataDirectory : pxeDataDirectory ,
2424 dataStoreMapSizeKB : 1e6 ,
@@ -70,12 +70,7 @@ async function createAccount(pxe: PXE) {
7070
7171 return {
7272 wallet,
73- credentials : {
74- salt : salt . toString ( ) ,
75- secretKey : secretKey . toString ( ) ,
76- signingKey : Buffer . from ( signingKey ) . toString ( 'hex' ) ,
77- address : wallet . getAddress ( ) . toString ( )
78- }
73+ signingKey,
7974 } ;
8075}
8176
@@ -123,20 +118,24 @@ async function createAccountAndDeployContract() {
123118 await pxe . registerContract ( { instance : await getSponsoredPFCContract ( ) , artifact : SponsoredFPCContractArtifact } ) ;
124119
125120 // Create a new account
126- const { wallet, credentials } = await createAccount ( pxe ) ;
121+ const { wallet, signingKey } = await createAccount ( pxe ) ;
122+
123+ // Save the wallet info
124+ const walletInfo = {
125+ address : wallet . getAddress ( ) . toString ( ) ,
126+ salt : wallet . salt . toString ( ) ,
127+ secretKey : wallet . getSecretKey ( ) . toString ( ) ,
128+ signingKey : Buffer . from ( signingKey ) . toString ( 'hex' ) ,
129+ }
130+ fs . writeFileSync ( path . join ( import . meta. dirname , '../wallet-info.json' ) , JSON . stringify ( walletInfo , null , 2 ) ) ;
131+ console . log ( '\n\n\nWallet info saved to wallet-info.json\n\n\n' ) ;
127132
128133 // Deploy the contract
129134 const deploymentInfo = await deployContract ( pxe , wallet ) ;
130135
131- // Combine all information
132- const fullInfo = {
133- walletInfo : credentials ,
134- deploymentInfo
135- } ;
136-
136+ // Save the deployment info
137137 const outputPath = path . join ( import . meta. dirname , '../deployed-contract.json' ) ;
138- fs . writeFileSync ( outputPath , JSON . stringify ( fullInfo , null , 2 ) ) ;
139-
138+ fs . writeFileSync ( outputPath , JSON . stringify ( deploymentInfo , null , 2 ) ) ;
140139 console . log ( '\n\n\nContract deployed successfully. All info saved to deployed-contract.json\n\n\nIMPORTANT: Do not lose this file as you will not be able to recover the contract address if you lose it.\n\n\n' ) ;
141140}
142141
0 commit comments