@@ -45,6 +45,13 @@ func BuildSignupTx(
4545 duration int ,
4646 region string ,
4747) ([]byte , []byte , error ) {
48+ // Validate inputs
49+ if region == "" {
50+ return nil , nil , NewInputValidationError ("empty region provided" )
51+ }
52+ if paymentAddress == "" {
53+ return nil , nil , NewInputValidationError ("empty payment address provided" )
54+ }
4855 cfg := config .GetConfig ()
4956 cc , err := apolloBackend ()
5057 if err != nil {
@@ -53,14 +60,14 @@ func BuildSignupTx(
5360 // Decode payment address
5461 paymentAddr , err := serAddress .DecodeAddress (paymentAddress )
5562 if err != nil {
56- return nil , nil , fmt . Errorf ( " payment address: %w" , err )
63+ return nil , nil , NewInputValidationError ( "failed to decode payment address" )
5764 }
5865 // Determine owner credential
5966 ownerCredential := paymentAddr .PaymentPart
6067 if ownerAddress != "" && ownerAddress != paymentAddress {
6168 ownerAddr , err := serAddress .DecodeAddress (ownerAddress )
6269 if err != nil {
63- return nil , nil , fmt . Errorf ( " owner address: %w" , err )
70+ return nil , nil , NewInputValidationError ( "failed to decode owner address" )
6471 }
6572 ownerCredential = ownerAddr .PaymentPart
6673 }
@@ -87,6 +94,16 @@ func BuildSignupTx(
8794 default :
8895 return nil , nil , errors .New ("reference data not provided (missing deps.Ref and deps.DB)" )
8996 }
97+ // Validate region
98+ foundRegion := false
99+ for _ , refDataRegion := range refData .Regions {
100+ if region == refDataRegion .Name {
101+ foundRegion = true
102+ }
103+ }
104+ if ! foundRegion {
105+ return nil , nil , NewInputValidationError ("provided region not valid" )
106+ }
90107 // Parse script ref
91108 scriptRef , err := inputRefFromString (cfg .TxBuilder .ScriptRefInput )
92109 if err != nil {
@@ -107,14 +124,14 @@ func BuildSignupTx(
107124 return nil , nil , fmt .Errorf ("choose input UTxOs: %w" , err )
108125 }
109126 if len (inputUtxos ) == 0 {
110- return nil , nil , errors . New ("no input UTxOs found" )
127+ return nil , nil , NewInputValidationError ("no input UTxOs found" )
111128 }
112129 // Determine client ID from first selected input UTxO
113130 clientId := clientIdFromInput (inputUtxos [0 ].Input )
114131 // Determine plan selection ID from price/duration
115132 selectionId , err := determinePlanSelection (refData , price , duration )
116133 if err != nil {
117- return nil , nil , fmt . Errorf ( " determine plan selection: %w" , err )
134+ return nil , nil , NewInputValidationError ( "could not determine plan selection from provided price/duration" )
118135 }
119136 // Get last known slot
120137 curSlot , err := cc .LastBlockSlot ()
0 commit comments