2929 applicationRegisterParam bool
3030 applicationTemplateHashParam string
3131 factoryAddressParam string
32+ prtFactoryAddressParam string
33+ deploymentTypePRT bool
3234)
3335
3436var applicationCmd = & cobra.Command {
@@ -59,6 +61,9 @@ const applicationExamples = `
5961# deploy an application contract using an existing consensus, then register the application
6062 - cli deploy application echo-dapp applications/echo-dapp/ --consensus=0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
6163
64+ # deploy an application contract with a PRT consensus, then register the application
65+ - cli deploy application echo-dapp applications/echo-dapp/ --prt
66+
6267# deploy but don't register into the database
6368 - cli deploy application echo-dapp applications/echo-dapp/ --register=false
6469
@@ -73,6 +78,8 @@ func init() {
7378 "Consensus address. A new authority consensus will be created if this field is left empty." )
7479 applicationCmd .Flags ().StringVarP (& factoryAddressParam , "factory" , "f" , "" ,
7580 "Application factory address. Default value is retrieved from configuration." )
81+ applicationCmd .Flags ().StringVarP (& prtFactoryAddressParam , "prt-factory" , "" , "" ,
82+ "PRT Application factory address. Default value is retrieved from configuration." )
7683 applicationCmd .Flags ().StringVarP (& applicationOwnerAddressParam , "application-owner" , "o" , "" ,
7784 "Application owner address. If not defined, it will be derived from the auth method." )
7885 applicationCmd .Flags ().StringVarP (& applicationDataAvailabilityParam , "data-availability" , "d" , "" ,
@@ -85,6 +92,8 @@ func init() {
8592 "Start processing the application, requires 'register=true'." )
8693 applicationCmd .Flags ().StringVarP (& authorityOwnerAddressParam , "authority-owner" , "O" , "" ,
8794 "Authority Owner address. If not defined, it will be derived from the auth method." )
95+ applicationCmd .Flags ().BoolVarP (& deploymentTypePRT , "prt" , "" , false ,
96+ "Deploy a PRT application." )
8897
8998 origHelpFunc := applicationCmd .HelpFunc ()
9099 applicationCmd .SetHelpFunc (func (command * cobra.Command , strings []string ) {
@@ -141,7 +150,9 @@ func runDeployApplication(cmd *cobra.Command, args []string) {
141150 }
142151
143152 var deployment ethutil.IApplicationDeployment
144- if deploySelfhosted := ! cmd .Flags ().Changed ("consensus" ); deploySelfhosted {
153+ if deploymentTypePRT {
154+ deployment , err = buildPrtApplicationDeployment (cmd , args , client , txOpts )
155+ } else if deploySelfhosted := ! cmd .Flags ().Changed ("consensus" ); deploySelfhosted {
145156 deployment , err = buildSelfhostedApplicationDeployment (cmd , args , client , txOpts )
146157 } else {
147158 deployment , err = buildApplicationOnlyDeployment (cmd , args , client , txOpts )
@@ -339,7 +350,7 @@ func buildSelfhostedApplicationDeployment(
339350 return request , nil
340351}
341352
342- func buildApplicationOnlyDeployment (
353+ func buildApplicationOnlyDeploymentWithoutConsensus (
343354 cmd * cobra.Command ,
344355 args []string ,
345356 client * ethclient.Client ,
@@ -360,11 +371,6 @@ func buildApplicationOnlyDeployment(
360371 return nil , fmt .Errorf ("error on parameter factory: %w" , err )
361372 }
362373
363- request .Consensus , err = parseHexAddress (applicationConsensusAddressParam )
364- if err != nil {
365- return nil , fmt .Errorf ("error on parameter consensus: %w" , err )
366- }
367-
368374 if ! cmd .Flags ().Changed ("template-hash" ) {
369375 if len (args ) >= 2 { // args[1] is mandatory if `template-hash` was absent
370376 request .TemplateHash , err = readHash (args [1 ])
@@ -402,17 +408,64 @@ func buildApplicationOnlyDeployment(
402408 return nil , fmt .Errorf ("error on parameter data-availability: %w" , err )
403409 }
404410
411+ request .Salt , err = ethutil .ParseSalt (saltParam )
412+ if err != nil {
413+ return nil , fmt .Errorf ("error on parameter salt: %w" , err )
414+ }
415+
416+ request .Verbose = verboseParam
417+ return request , nil
418+ }
419+
420+ func buildApplicationOnlyDeployment (
421+ cmd * cobra.Command ,
422+ args []string ,
423+ client * ethclient.Client ,
424+ txOpts * bind.TransactOpts ,
425+ ) (
426+ * ethutil.ApplicationDeployment ,
427+ error ,
428+ ) {
429+ request , err := buildApplicationOnlyDeploymentWithoutConsensus (cmd , args , client , txOpts )
430+
431+ request .Consensus , err = parseHexAddress (applicationConsensusAddressParam )
432+ if err != nil {
433+ return nil , fmt .Errorf ("error on parameter consensus: %w" , err )
434+ }
435+
405436 request .Consensus , request .EpochLength , err = customConsensus (client , applicationConsensusAddressParam )
406437 if err != nil {
407438 return nil , fmt .Errorf ("error on parameter consensus: %w" , err )
408439 }
409440
410- request .Salt , err = ethutil .ParseSalt (saltParam )
441+ return request , nil
442+ }
443+
444+ func buildPrtApplicationDeployment (
445+ cmd * cobra.Command ,
446+ args []string ,
447+ client * ethclient.Client ,
448+ txOpts * bind.TransactOpts ,
449+ ) (
450+ * ethutil.PRTDeployment ,
451+ error ,
452+ ) {
453+ var err error
454+ request := & ethutil.PRTDeployment {}
455+ if ! cmd .Flags ().Changed ("prt-factory" ) {
456+ request .FactoryAddress , err = config .GetContractsPrtFactoryAddress ()
457+ } else {
458+ request .FactoryAddress , err = parseHexAddress (factoryAddressParam )
459+ }
411460 if err != nil {
412- return nil , fmt .Errorf ("error on parameter salt: %w" , err )
461+ return nil , fmt .Errorf ("error on parameter factory: %w" , err )
462+ }
463+
464+ request .App , err = buildApplicationOnlyDeploymentWithoutConsensus (cmd , args , client , txOpts )
465+ if err != nil {
466+ return nil , fmt .Errorf ("error on application: %w" , err )
413467 }
414468
415- request .Verbose = verboseParam
416469 return request , nil
417470}
418471
0 commit comments