-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from neotheprogramist/1/4-token-policies
1/4 Session Policies
- Loading branch information
Showing
12 changed files
with
322 additions
and
129 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
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 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,44 +1,39 @@ | ||
use starknet::{core::types::FieldElement, macros::felt}; | ||
|
||
use crate::abigen::account::Call; | ||
|
||
#[derive(Clone)] | ||
pub struct Session { | ||
session_expires: u64, | ||
root: FieldElement, | ||
proof_len: u32, | ||
proofs: Vec<FieldElement>, | ||
session_token: Vec<FieldElement>, | ||
permitted_calls: Vec<Call>, | ||
} | ||
|
||
impl Session { | ||
pub fn session_expires(&self) -> u64 { | ||
self.session_expires | ||
} | ||
|
||
pub fn root(&self) -> FieldElement { | ||
self.root | ||
} | ||
|
||
pub fn proof_len(&self) -> u32 { | ||
self.proof_len | ||
pub fn session_token(&self) -> Vec<FieldElement> { | ||
self.session_token.clone() | ||
} | ||
|
||
pub fn proofs(&self) -> Vec<FieldElement> { | ||
self.proofs.clone() | ||
pub fn permitted_calls(&self) -> &Vec<Call> { | ||
&self.permitted_calls | ||
} | ||
|
||
pub fn session_token(&self) -> Vec<FieldElement> { | ||
self.session_token.clone() | ||
#[cfg(test)] | ||
pub fn set_permitted_calls(&mut self, calls: Vec<Call>) { | ||
self.permitted_calls = calls; | ||
} | ||
} | ||
|
||
impl Default for Session { | ||
fn default() -> Self { | ||
Self { | ||
session_expires: u64::MAX, | ||
root: felt!("0x0"), | ||
proof_len: 1, | ||
proofs: vec![felt!("44")], | ||
session_token: vec![felt!("0x2137")], | ||
permitted_calls: vec![], | ||
} | ||
} | ||
} |
Oops, something went wrong.