From 0468e1e11bafd0cf641b22efc9908957f89e516c Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Mon, 4 Mar 2024 16:24:36 +0100 Subject: [PATCH] Add revert for getServiceAgreement if service agreement doesn't exist --- contracts/v1/errors/ServiceAgreementErrors.sol | 7 +++++++ contracts/v1/storage/ServiceAgreementStorageProxy.sol | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 contracts/v1/errors/ServiceAgreementErrors.sol diff --git a/contracts/v1/errors/ServiceAgreementErrors.sol b/contracts/v1/errors/ServiceAgreementErrors.sol new file mode 100644 index 00000000..59c47f09 --- /dev/null +++ b/contracts/v1/errors/ServiceAgreementErrors.sol @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.16; + +library ServiceAgreementErrors { + error ServiceAgreementDoesntExist(bytes32 agreementId); +} diff --git a/contracts/v1/storage/ServiceAgreementStorageProxy.sol b/contracts/v1/storage/ServiceAgreementStorageProxy.sol index cc216ea1..dec1ab23 100644 --- a/contracts/v1/storage/ServiceAgreementStorageProxy.sol +++ b/contracts/v1/storage/ServiceAgreementStorageProxy.sol @@ -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"; @@ -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); } }