Skip to content

Commit

Permalink
--wip-- [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocaillard committed Jun 24, 2024
1 parent e59b1f3 commit 2e3ca97
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 14 deletions.
File renamed without changes.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion components/clarinet-cli/src/generate/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ impl GetChangesForNewProject {
use_current_dir: bool,
telemetry_enabled: bool,
) -> Self {
println!("project_path: {project_path}, project_name: {project_name}");
let project_path = if use_current_dir {
project_path.clone()
} else {
Expand Down
53 changes: 53 additions & 0 deletions components/clarity-repl/src/analysis/ast_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,23 @@ pub trait ASTVisitor<'a> {
.unwrap_or(&DEFAULT_NAME),
args.get(1).unwrap_or(&DEFAULT_EXPR),
),
GetStacksBlockInfo => self.traverse_get_stacks_block_info(
expr,
args.get(0)
.unwrap_or(&DEFAULT_EXPR)
.match_atom()
.unwrap_or(&DEFAULT_NAME),
args.get(1).unwrap_or(&DEFAULT_EXPR),
),
GetTenureInfo => self.traverse_get_tenure_info(
expr,
args.get(0)
.unwrap_or(&DEFAULT_EXPR)
.match_atom()
.unwrap_or(&DEFAULT_NAME),
args.get(1).unwrap_or(&DEFAULT_EXPR),
),

ConsError => self.traverse_err(expr, args.get(0).unwrap_or(&DEFAULT_EXPR)),
ConsOkay => self.traverse_ok(expr, args.get(0).unwrap_or(&DEFAULT_EXPR)),
ConsSome => self.traverse_some(expr, args.get(0).unwrap_or(&DEFAULT_EXPR)),
Expand Down Expand Up @@ -1465,6 +1482,42 @@ pub trait ASTVisitor<'a> {
true
}

fn traverse_get_stacks_block_info(
&mut self,
expr: &'a SymbolicExpression,
prop_name: &'a ClarityName,
block: &'a SymbolicExpression,
) -> bool {
self.traverse_expr(block) && self.visit_get_stacks_block_info(expr, prop_name, block)
}

fn visit_get_stacks_block_info(
&mut self,
expr: &'a SymbolicExpression,
prop_name: &'a ClarityName,
block: &'a SymbolicExpression,
) -> bool {
true
}

fn traverse_get_tenure_info(
&mut self,
expr: &'a SymbolicExpression,
prop_name: &'a ClarityName,
block: &'a SymbolicExpression,
) -> bool {
self.traverse_expr(block) && self.visit_get_tenure_info(expr, prop_name, block)
}

fn visit_get_tenure_info(
&mut self,
expr: &'a SymbolicExpression,
prop_name: &'a ClarityName,
block: &'a SymbolicExpression,
) -> bool {
true
}

fn traverse_err(
&mut self,
expr: &'a SymbolicExpression,
Expand Down
46 changes: 39 additions & 7 deletions components/clarity-repl/src/repl/datastore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ impl HeadersDB for BurnDatastore {
fn get_stacks_block_header_hash_for_block(
&self,
id_bhh: &StacksBlockId,
_epoch_id: &StacksEpochId,
) -> Option<BlockHeaderHash> {
self.store.get(id_bhh).map(|id| id.block_header_hash)
}
Expand All @@ -410,32 +411,63 @@ impl HeadersDB for BurnDatastore {
self.store.get(id_bhh).map(|id| id.burn_block_header_hash)
}

fn get_consensus_hash_for_block(&self, id_bhh: &StacksBlockId) -> Option<ConsensusHash> {
fn get_consensus_hash_for_block(
&self,
id_bhh: &StacksBlockId,
_epoch_id: &StacksEpochId,
) -> Option<ConsensusHash> {
self.store.get(id_bhh).map(|id| id.consensus_hash)
}
fn get_vrf_seed_for_block(&self, id_bhh: &StacksBlockId) -> Option<VRFSeed> {
fn get_vrf_seed_for_block(
&self,
id_bhh: &StacksBlockId,
_epoch_id: &StacksEpochId,
) -> Option<VRFSeed> {
self.store.get(id_bhh).map(|id| id.vrf_seed)
}
fn get_burn_block_time_for_block(&self, id_bhh: &StacksBlockId) -> Option<u64> {
fn get_stacks_block_time_for_block(&self, id_bhh: &StacksBlockId) -> Option<u64> {
self.store.get(id_bhh).map(|id| id.burn_block_time)
}
fn get_burn_block_time_for_block(
&self,
id_bhh: &StacksBlockId,
_epoch_id: Option<&StacksEpochId>,
) -> Option<u64> {
self.store.get(id_bhh).map(|id| id.burn_block_time)
}
fn get_burn_block_height_for_block(&self, id_bhh: &StacksBlockId) -> Option<u32> {
self.store.get(id_bhh).map(|id| id.burn_block_height)
}
fn get_miner_address(&self, id_bhh: &StacksBlockId) -> Option<StacksAddress> {
fn get_miner_address(
&self,
id_bhh: &StacksBlockId,
_epoch_id: &StacksEpochId,
) -> Option<StacksAddress> {
self.store.get(id_bhh).map(|id| id.miner)
}
fn get_burnchain_tokens_spent_for_block(&self, id_bhh: &StacksBlockId) -> Option<u128> {
fn get_burnchain_tokens_spent_for_block(
&self,
id_bhh: &StacksBlockId,
_epoch_id: &StacksEpochId,
) -> Option<u128> {
self.store
.get(id_bhh)
.map(|id| id.burnchain_tokens_spent_for_block)
}
fn get_burnchain_tokens_spent_for_winning_block(&self, id_bhh: &StacksBlockId) -> Option<u128> {
fn get_burnchain_tokens_spent_for_winning_block(
&self,
id_bhh: &StacksBlockId,
_epoch_id: &StacksEpochId,
) -> Option<u128> {
self.store
.get(id_bhh)
.map(|id| id.get_burnchain_tokens_spent_for_winning_block)
}
fn get_tokens_earned_for_block(&self, id_bhh: &StacksBlockId) -> Option<u128> {
fn get_tokens_earned_for_block(
&self,
id_bhh: &StacksBlockId,
_epoch_id: &StacksEpochId,
) -> Option<u128> {
self.store.get(id_bhh).map(|id| id.tokens_earned_for_block)
}
}
Expand Down

0 comments on commit 2e3ca97

Please sign in to comment.