Skip to content

Commit

Permalink
Add revert for getServiceAgreement if service agreement doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihajlo-Pavlovic committed Mar 4, 2024
1 parent 7d0db0b commit 0468e1e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions contracts/v1/errors/ServiceAgreementErrors.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;

library ServiceAgreementErrors {
error ServiceAgreementDoesntExist(bytes32 agreementId);
}
5 changes: 4 additions & 1 deletion contracts/v1/storage/ServiceAgreementStorageProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {Initializable} from "../interface/Initializable.sol";
import {Named} from "../interface/Named.sol";
import {Versioned} from "../interface/Versioned.sol";
import {GeneralErrors} from "../errors/GeneralErrors.sol";
import {ServiceAgreementErrors} from "../errors/ServiceAgreementErrors.sol";

contract ServiceAgreementStorageProxy is Named, Versioned, HubDependent, Initializable {
string private constant _NAME = "ServiceAgreementStorageProxy";
Expand Down Expand Up @@ -124,8 +125,10 @@ contract ServiceAgreementStorageProxy is Named, Versioned, HubDependent, Initial
[tokenAmount, storageV1U1.getAgreementUpdateTokenAmount(agreementId)],
scoreFunctionIdAndProofWindowOffsetPerc
);
} else {
} else if (this.agreementV1U1Exists(agreementId)) {
return storageV1U1.getAgreementData(agreementId);
} else {
revert ServiceAgreementErrors.ServiceAgreementDoesntExist(agreementId);
}
}

Expand Down

0 comments on commit 0468e1e

Please sign in to comment.