Skip to content

Commit

Permalink
Merge pull request #11 from nymlab/issue_24
Browse files Browse the repository at this point in the history
Issue 24
  • Loading branch information
iorveth authored Aug 7, 2024
2 parents fbe45e7 + 4b984bb commit d8bfaaf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
24 changes: 16 additions & 8 deletions contracts/sdjwt-verifier/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ impl AvidaVerifierTrait for SdjwtVerifier<'_> {
.map(|_| Response::default())
.map_err(SdjwtVerifierError::SdjwtVerifierResultError)?)
}
AvidaVerifierSudoMsg::Update {
app_addr,
route_id,
route_criteria,
} => self._update(deps.storage, &env, &app_addr, route_id, route_criteria),
}
}

Expand Down Expand Up @@ -155,16 +160,12 @@ impl AvidaVerifierTrait for SdjwtVerifier<'_> {
) -> Result<Response, Self::Error> {
let ExecCtx { deps, env, info } = ctx;

// Ensure the app with this address is registered
if !self.app_trust_data_source.has(deps.storage, &app_addr)
|| !self.app_routes_requirements.has(deps.storage, &app_addr)
{
return Err(SdjwtVerifierError::AppIsNotRegistered);
}

let app_addr = deps.api.addr_validate(&app_addr)?;

let app_admin = self.app_admins.load(deps.storage, app_addr.as_str())?;
let app_admin = self
.app_admins
.load(deps.storage, app_addr.as_str())
.map_err(|_| SdjwtVerifierError::AppIsNotRegistered)?;

// Ensure the caller is the admin of the dApp
if app_admin != info.sender {
Expand Down Expand Up @@ -370,6 +371,13 @@ impl SdjwtVerifier<'_> {
route_id: RouteId,
route_criteria: Option<RouteVerificationRequirements>,
) -> Result<Response, SdjwtVerifierError> {
// Ensure the app with this address is registered
if !self.app_trust_data_source.has(storage, app_addr)
|| !self.app_routes_requirements.has(storage, app_addr)
{
return Err(SdjwtVerifierError::AppIsNotRegistered);
}

let mut req_map = self.app_routes_requirements.load(storage, app_addr)?;
let mut data_sources = self.app_trust_data_source.load(storage, app_addr)?;

Expand Down
5 changes: 5 additions & 0 deletions packages/common/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,9 @@ pub enum AvidaVerifierSudoMsg {
app_addr: String,
additional_requirements: Option<Binary>,
},
Update {
app_addr: String,
route_id: RouteId,
route_criteria: Option<RouteVerificationRequirements>,
},
}

0 comments on commit d8bfaaf

Please sign in to comment.