@@ -143,8 +143,6 @@ pub enum DipsError {
143143 SubgraphManifestUnavailable ( String ) ,
144144 #[ error( "invalid subgraph id {0}" ) ]
145145 InvalidSubgraphManifest ( String ) ,
146- #[ error( "voucher for chain id {0}, subgraph manifest has network {1}" ) ]
147- SubgraphChainIdMistmatch ( String , String ) ,
148146 #[ error( "chainId {0} is not supported" ) ]
149147 UnsupportedChainId ( String ) ,
150148 #[ error( "price per block is below configured price for chain {0}, minimum: {1}, offered: {2}" ) ]
@@ -319,31 +317,30 @@ pub async fn validate_and_create_agreement(
319317
320318 let manifest = ipfs_fetcher. fetch ( & metadata. subgraphDeploymentId ) . await ?;
321319 match manifest. network ( ) {
322- Some ( chain_id) if chain_id == metadata. chainId => { }
323- Some ( chain_id) => {
324- return Err ( DipsError :: SubgraphChainIdMistmatch (
325- metadata. chainId ,
326- chain_id,
320+ Some ( network_name) => {
321+ tracing:: debug!( "Subgraph manifest network: {}" , network_name) ;
322+ // TODO: Check if the network is supported
323+ // This will require a mapping of network names to chain IDs
324+ // by querying the supported networks from the EBO subgraph
325+ }
326+ None => {
327+ return Err ( DipsError :: InvalidSubgraphManifest (
328+ metadata. subgraphDeploymentId ,
327329 ) )
328330 }
329- None => return Err ( DipsError :: UnsupportedChainId ( "" . to_string ( ) ) ) ,
330331 }
331332
332- let chain_id = manifest
333- . network ( )
334- . ok_or_else ( || DipsError :: UnsupportedChainId ( "" . to_string ( ) ) ) ?;
335-
336333 let offered_price = metadata. pricePerEntity ;
337- match price_calculator. get_minimum_price ( & chain_id ) {
334+ match price_calculator. get_minimum_price ( & metadata . chainId ) {
338335 Some ( price) if offered_price. lt ( & Uint :: from ( price) ) => {
339336 return Err ( DipsError :: PricePerBlockTooLow (
340- chain_id ,
337+ metadata . chainId ,
341338 price,
342339 offered_price. to_string ( ) ,
343340 ) )
344341 }
345342 Some ( _) => { }
346- None => return Err ( DipsError :: UnsupportedChainId ( chain_id ) ) ,
343+ None => return Err ( DipsError :: UnsupportedChainId ( metadata . chainId ) ) ,
347344 }
348345
349346 store
@@ -729,16 +726,25 @@ mod test {
729726 ) ] ) ,
730727 ) )
731728 . await ;
729+ let no_network_ctx =
730+ DipsServerContext :: for_testing_mocked_accounts_no_network ( EscrowAccounts :: new (
731+ HashMap :: default ( ) ,
732+ HashMap :: from_iter ( vec ! [ (
733+ voucher_ctx. payer. address( ) ,
734+ vec![ voucher_ctx. payer. address( ) ] ,
735+ ) ] ) ,
736+ ) )
737+ . await ;
732738
733739 let metadata = SubgraphIndexingVoucherMetadata {
734740 basePricePerEpoch : U256 :: from ( 10000_u64 ) ,
735741 pricePerEntity : U256 :: from ( 100_u64 ) ,
736742 protocolNetwork : "eip155:42161" . to_string ( ) ,
737- chainId : "mainnet2 " . to_string ( ) ,
743+ chainId : "mainnet " . to_string ( ) ,
738744 subgraphDeploymentId : voucher_ctx. deployment_id . clone ( ) ,
739745 } ;
740-
741- let wrong_network_voucher = voucher_ctx. test_voucher ( metadata) ;
746+ // The voucher says mainnet, but the manifest has no network
747+ let no_network_voucher = voucher_ctx. test_voucher ( metadata) ;
742748
743749 let metadata = SubgraphIndexingVoucherMetadata {
744750 basePricePerEpoch : U256 :: from ( 10000_u64 ) ,
@@ -763,10 +769,11 @@ mod test {
763769 voucher_ctx. test_voucher_with_signer ( metadata. clone ( ) , signer. clone ( ) ) ;
764770 let valid_voucher = voucher_ctx. test_voucher ( metadata) ;
765771
772+ let contexts = vec ! [ no_network_ctx, ctx. clone( ) , ctx. clone( ) , ctx. clone( ) ] ;
773+
766774 let expected_result: Vec < Result < [ u8 ; 16 ] , DipsError > > = vec ! [
767- Err ( DipsError :: SubgraphChainIdMistmatch (
768- "mainnet2" . to_string( ) ,
769- "mainnet" . to_string( ) ,
775+ Err ( DipsError :: InvalidSubgraphManifest (
776+ voucher_ctx. deployment_id. clone( ) ,
770777 ) ) ,
771778 Err ( DipsError :: PricePerBlockTooLow (
772779 "mainnet" . to_string( ) ,
@@ -782,14 +789,18 @@ mod test {
782789 . unwrap( ) ) ,
783790 ] ;
784791 let cases = vec ! [
785- wrong_network_voucher ,
792+ no_network_voucher ,
786793 low_price_voucher,
787794 valid_voucher_invalid_signer,
788795 valid_voucher,
789796 ] ;
790- for ( voucher, result) in cases. into_iter ( ) . zip ( expected_result. into_iter ( ) ) {
797+ for ( ( voucher, result) , dips_ctx) in cases
798+ . into_iter ( )
799+ . zip ( expected_result. into_iter ( ) )
800+ . zip ( contexts. into_iter ( ) )
801+ {
791802 let out = super :: validate_and_create_agreement (
792- ctx . clone ( ) ,
803+ dips_ctx . clone ( ) ,
793804 & voucher_ctx. domain ( ) ,
794805 & voucher_ctx. payee . address ( ) ,
795806 vec ! [ voucher_ctx. payer. address( ) ] ,
0 commit comments