-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
90 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,39 @@ | ||
// TODO: Add Navori as a dependency | ||
module starknet_addr::fact_registry { | ||
use std::signer::address_of; | ||
use aptos_std::smart_table; | ||
use aptos_std::smart_table::{ SmartTable, borrow, upsert, new }; | ||
use aptos_std::smart_table::SmartTable; | ||
use aptos_framework::event; | ||
|
||
#[event] | ||
struct FactRegistered has store, drop { | ||
fact_hash: u256 | ||
} | ||
|
||
struct VerifierFact has key, store { | ||
verified_fact: SmartTable<vector<u8>, bool>, | ||
verified_fact: SmartTable<u256, bool>, | ||
any_fact_registered: bool | ||
} | ||
|
||
public entry fun init_fact_registry(s: &signer) { | ||
public fun init_fact_registry(s: &signer) { | ||
move_to(s, VerifierFact { | ||
verified_fact: new<vector<u8>, bool>(), | ||
verified_fact: smart_table::new<u256, bool>(), | ||
any_fact_registered: false | ||
}); | ||
} | ||
|
||
#[view] | ||
public fun is_valid(fact: vector<u8>): bool acquires VerifierFact { | ||
let verifier_fact = borrow_global<VerifierFact>(@starknet_addr); | ||
public fun is_valid(address: address, fact: u256): bool acquires VerifierFact { | ||
let verifier_fact = borrow_global<VerifierFact>(address); | ||
*smart_table::borrow_with_default(&verifier_fact.verified_fact, fact, &false) | ||
} | ||
|
||
#[view] | ||
public fun fact_check(fact: vector<u8>): bool acquires VerifierFact { | ||
*borrow(&borrow_global<VerifierFact>(@starknet_addr).verified_fact, fact) | ||
} | ||
public fun register_fact(s: &signer, fact_hash: u256) acquires VerifierFact { | ||
let verifier_fact = borrow_global_mut<VerifierFact>(address_of(s)); | ||
smart_table::upsert(&mut verifier_fact.verified_fact, fact_hash, true); | ||
event::emit<FactRegistered>(FactRegistered { fact_hash }); | ||
|
||
public entry fun register_fact(fact_hash: vector<u8>) acquires VerifierFact { | ||
let verifier_fact = borrow_global_mut<VerifierFact>(@starknet_addr); | ||
upsert(&mut verifier_fact.verified_fact, fact_hash, true); | ||
if (verifier_fact.any_fact_registered == false) { | ||
verifier_fact.any_fact_registered = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.