Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use sbt_classes rather than sbts #66

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions contracts/community-sbt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl Contract {
let caller = env::predecessor_account_id();
let ctr = env::current_account_id();
ext_registry::ext(self.registry.clone())
.sbts(ctr.clone(), tokens.clone())
.sbt_classes(ctr.clone(), tokens.clone())
.then(Self::ext(ctr).on_sbt_renew_callback(&caller, tokens, ttl, memo))
}

Expand All @@ -123,13 +123,13 @@ impl Contract {
tokens: Vec<TokenId>,
ttl: u64,
memo: Option<String>,
#[callback_result] token_data: Result<Vec<Option<Token>>, near_sdk::PromiseError>,
#[callback_result] token_classes: Result<Vec<Option<ClassId>>, near_sdk::PromiseError>,
) -> Promise {
let ts = token_data.expect("error while retrieving tokens data from registry");
let ts = token_classes.expect("error while retrieving tokens data from registry");
let mut cached_class_info: HashMap<u64, (Vec<AccountId>, u64)> = HashMap::new();
for token in ts {
for token_class in ts {
let max_ttl: u64;
let class_id: u64 = token.expect("token not found").metadata.class;
let class_id: u64 = token_class.expect("token not found");
if let Some((cached_minters, cached_ttl)) = cached_class_info.get(&class_id) {
max_ttl = *cached_ttl;
self.assert_minter(caller, &cached_minters);
Expand Down Expand Up @@ -166,7 +166,7 @@ impl Contract {
let caller = env::predecessor_account_id();
let ctr = env::current_account_id();
ext_registry::ext(self.registry.clone())
.sbts(ctr.clone(), tokens.clone())
.sbt_classes(ctr.clone(), tokens.clone())
.then(Self::ext(ctr).on_sbt_revoke_callback(&caller, tokens, burn, memo))
}

Expand All @@ -179,12 +179,12 @@ impl Contract {
tokens: Vec<TokenId>,
burn: bool,
memo: Option<String>,
#[callback_result] token_data: Result<Vec<Option<Token>>, near_sdk::PromiseError>,
#[callback_result] token_classes: Result<Vec<Option<ClassId>>, near_sdk::PromiseError>,
) -> Promise {
let ts = token_data.expect("error while retrieving tokens data from registry");
let ts = token_classes.expect("error while retrieving tokens data from registry");
let mut cached_class_minters: HashMap<u64, Vec<AccountId>> = HashMap::new();
for token in ts {
let class_id: u64 = token.expect("token not found").metadata.class;
for token_class in ts {
let class_id: u64 = token_class.expect("token not found");
if let Some(cached_minter) = cached_class_minters.get(&class_id) {
self.assert_minter(caller, &cached_minter);
} else {
Expand Down
1 change: 1 addition & 0 deletions contracts/sbt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,5 @@ trait ExtRegistry {
fn is_human(&self, account: AccountId) -> Vec<(AccountId, Vec<TokenId>)>;
fn sbt(&self, issuer: AccountId, token: TokenId) -> Option<Token>;
fn sbts(&self, issuer: AccountId, tokens: Vec<TokenId>) -> Vec<Option<Token>>;
fn sbt_classes(&self, issuer: AccountId, tokens: Vec<TokenId>) -> Vec<Option<ClassId>>;
}