Skip to content

Commit

Permalink
move the query to the else statement
Browse files Browse the repository at this point in the history
  • Loading branch information
sczembor committed Oct 2, 2023
1 parent 2c668c8 commit 82a6014
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion contracts/registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2430,7 +2430,7 @@ mod tests {

// revoke (burn) tokens minted for alice from issuer2
ctx.predecessor_account_id = issuer2();
ctx.prepaid_gas = Gas::ONE_TERA.mul(125);
ctx.prepaid_gas = Gas::ONE_TERA.mul(110);
testing_env!(ctx);
let res = ctr.sbt_revoke_by_owner(alice(), true);
assert!(res);
Expand Down
16 changes: 10 additions & 6 deletions contracts/registry/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,6 @@ impl SBTRegistry for Contract {
return true;
}

let non_expired_count =
self.sbt_tokens_by_owner(owner.clone(), Some(issuer.clone()), None, None, Some(false))
[0]
.1
.len();

let is_finished: bool;

if burn {
Expand Down Expand Up @@ -435,6 +429,16 @@ impl SBTRegistry for Contract {

is_finished = self.sbt_supply_by_owner(owner.clone(), issuer.clone(), None) == 0;
} else {
let non_expired_count = self.sbt_tokens_by_owner(
owner.clone(),
Some(issuer.clone()),
None,
None,
Some(false),
)[0]
.1
.len();

// Revoke: Update expire date for all tokens to current_timestamp
let now = env::block_timestamp_ms();
for (token_id, _) in &tokens_by_owner {
Expand Down

0 comments on commit 82a6014

Please sign in to comment.