-
Notifications
You must be signed in to change notification settings - Fork 79
feat(core): contract root anchoring #134
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
Changes from 9 commits
33143be
790a222
675bb76
1583021
682aae2
0522913
c76b44e
462b347
ecff67d
3193db2
f60b6fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,39 @@ | ||
| #![allow(dead_code)] | ||
| use soroban_sdk::{contractevent, BytesN}; | ||
|
|
||
| #[contractevent] | ||
| pub struct UsernameRegistered { | ||
| pub commitment: BytesN<32>, | ||
| } | ||
|
|
||
| #[contractevent] | ||
| pub struct MerkleRootUpdated { | ||
| pub old_root: BytesN<32>, | ||
| pub new_root: BytesN<32>, | ||
| } | ||
|
|
||
| use soroban_sdk::{symbol_short, Symbol}; | ||
|
|
||
| #[allow(dead_code)] | ||
| pub const INIT_EVENT: Symbol = symbol_short!("INIT"); | ||
| #[allow(dead_code)] | ||
| pub const TRANSFER_EVENT: Symbol = symbol_short!("TRANSFER"); | ||
| #[allow(dead_code)] | ||
| pub const REGISTER_EVENT: Symbol = symbol_short!("REGISTER"); | ||
| #[allow(dead_code)] | ||
| pub const ROOT_UPDATED: Symbol = symbol_short!("ROOT_UPD"); | ||
| #[allow(dead_code)] | ||
| pub const MASTER_SET: Symbol = symbol_short!("MSTR_SET"); | ||
| #[allow(dead_code)] | ||
| pub const ADDR_ADDED: Symbol = symbol_short!("ADDR_ADD"); | ||
| #[allow(dead_code)] | ||
| pub const CHAIN_ADD: Symbol = symbol_short!("CHAIN_ADD"); | ||
| #[allow(dead_code)] | ||
| pub const CHAIN_REM: Symbol = symbol_short!("CHAIN_REM"); | ||
| #[allow(dead_code)] | ||
| pub const VAULT_CREATE: Symbol = symbol_short!("VAULT_CRT"); | ||
| #[allow(dead_code)] | ||
| pub const DEPOSIT: Symbol = symbol_short!("DEPOSIT"); | ||
| #[allow(dead_code)] | ||
| pub const WITHDRAW: Symbol = symbol_short!("WITHDRAW"); | ||
| #[allow(dead_code)] | ||
| pub const SCHED_PAY: Symbol = symbol_short!("SCHED_PAY"); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,46 @@ | ||
| use soroban_sdk::{contracttype, Address, BytesN, Env}; | ||
|
|
||
| #[contracttype] | ||
| #[derive(Clone)] | ||
| pub enum DataKey { | ||
| CurrentMerkleRoot, | ||
| Verifier, | ||
| Commitment(BytesN<32>), | ||
| } | ||
|
|
||
| pub fn is_initialized(env: &Env) -> bool { | ||
| env.storage().persistent().has(&DataKey::CurrentMerkleRoot) | ||
| && env.storage().instance().has(&DataKey::Verifier) | ||
|
||
| } | ||
|
|
||
| pub fn get_merkle_root(env: &Env) -> Option<BytesN<32>> { | ||
| env.storage().persistent().get(&DataKey::CurrentMerkleRoot) | ||
| } | ||
|
|
||
| pub fn set_merkle_root(env: &Env, root: &BytesN<32>) { | ||
| env.storage() | ||
| .persistent() | ||
| .set(&DataKey::CurrentMerkleRoot, root); | ||
| } | ||
|
|
||
| pub fn get_verifier(env: &Env) -> Option<Address> { | ||
| env.storage().instance().get(&DataKey::Verifier) | ||
| } | ||
|
|
||
| pub fn set_verifier(env: &Env, verifier: &Address) { | ||
| env.storage().instance().set(&DataKey::Verifier, verifier); | ||
| } | ||
|
|
||
| pub fn has_commitment(env: &Env, commitment: &BytesN<32>) -> bool { | ||
| env.storage() | ||
| .persistent() | ||
| .has(&DataKey::Commitment(commitment.clone())) | ||
| } | ||
|
|
||
| pub fn store_commitment(env: &Env, commitment: &BytesN<32>) { | ||
| env.storage() | ||
| .persistent() | ||
| .set(&DataKey::Commitment(commitment.clone()), &true); | ||
| use soroban_sdk::{contracttype, BytesN}; | ||
|
||
|
|
||
| /// Storage keys for the Core contract's persistent and instance storage. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.