@@ -21,7 +21,7 @@ use crate::{
2121 } ,
2222 signers:: SignerValidator ,
2323 store:: AgreementStore ,
24- validate_and_cancel_agreement, validate_and_create_agreement, PROTOCOL_VERSION ,
24+ validate_and_cancel_agreement, validate_and_create_agreement, DipsError , PROTOCOL_VERSION ,
2525} ;
2626
2727#[ derive( Debug ) ]
@@ -112,18 +112,59 @@ impl IndexerDipsService for DipsServer {
112112 // - The price is over the configured minimum price
113113 // - The subgraph deployment is for a chain we support
114114 // - The subgraph deployment is available on IPFS
115- validate_and_create_agreement (
115+ let response = validate_and_create_agreement (
116116 self . ctx . clone ( ) ,
117117 & dips_agreement_eip712_domain ( self . chain_id ) ,
118118 & self . expected_payee ,
119119 & self . allowed_payers ,
120120 signed_voucher,
121121 )
122- . await ?;
123-
124- Ok ( Response :: new ( SubmitAgreementProposalResponse {
125- response : ProposalResponse :: Accept . into ( ) ,
126- } ) )
122+ . await ;
123+
124+ match response {
125+ Ok ( _) => Ok ( Response :: new ( SubmitAgreementProposalResponse {
126+ response : ProposalResponse :: Accept . into ( ) ,
127+ } ) ) ,
128+ Err ( e) => match e {
129+ // Invalid signature/authorization errors
130+ DipsError :: InvalidSignature ( msg) => Err ( Status :: invalid_argument ( format ! (
131+ "invalid signature: {}" ,
132+ msg
133+ ) ) ) ,
134+ DipsError :: PayerNotAuthorised ( addr) => Err ( Status :: invalid_argument ( format ! (
135+ "payer {} not authorized" ,
136+ addr
137+ ) ) ) ,
138+ DipsError :: UnexpectedPayee { expected, actual } => {
139+ Err ( Status :: invalid_argument ( format ! (
140+ "voucher payee {} does not match expected address {}" ,
141+ actual, expected
142+ ) ) )
143+ }
144+ DipsError :: SignerNotAuthorised ( addr) => Err ( Status :: invalid_argument ( format ! (
145+ "signer {} not authorized" ,
146+ addr
147+ ) ) ) ,
148+
149+ // Deployment/manifest related errors - these should return Reject
150+ DipsError :: SubgraphManifestUnavailable ( _)
151+ | DipsError :: InvalidSubgraphManifest ( _)
152+ | DipsError :: UnsupportedChainId ( _)
153+ | DipsError :: PricePerEpochTooLow ( _, _, _)
154+ | DipsError :: PricePerEntityTooLow ( _, _, _) => {
155+ Ok ( Response :: new ( SubmitAgreementProposalResponse {
156+ response : ProposalResponse :: Reject . into ( ) ,
157+ } ) )
158+ }
159+
160+ // Other errors
161+ DipsError :: AbiDecoding ( msg) => Err ( Status :: invalid_argument ( format ! (
162+ "invalid request voucher: {}" ,
163+ msg
164+ ) ) ) ,
165+ _ => Err ( Status :: internal ( e. to_string ( ) ) ) ,
166+ } ,
167+ }
127168 }
128169 /// *
129170 /// Request to cancel an existing _indexing agreement_.
0 commit comments