Struct clarity_repl::clarity::clarity::ClarityTransactionConnection
source · [−]pub struct ClarityTransactionConnection<'a> { /* private fields */ }
Expand description
Interface for Clarity VM interactions within a given transaction.
commit the transaction to the block with .commit() rollback the transaction by dropping this struct.
Implementations
sourceimpl<'a> ClarityTransactionConnection<'a>
impl<'a> ClarityTransactionConnection<'a>
sourcepub fn with_clarity_db<F, R>(&mut self, to_do: F) -> Result<R, Error> where
F: FnOnce(&mut ClarityDatabase<'_>) -> Result<R, Error>,
pub fn with_clarity_db<F, R>(&mut self, to_do: F) -> Result<R, Error> where
F: FnOnce(&mut ClarityDatabase<'_>) -> Result<R, Error>,
Do something to the underlying DB that involves writing.
sourcepub fn cost_so_far(&self) -> ExecutionCost
pub fn cost_so_far(&self) -> ExecutionCost
What’s our total (block-wide) resource use so far?
sourcepub fn analyze_smart_contract(
&mut self,
identifier: &QualifiedContractIdentifier,
contract_content: &str
) -> Result<(ContractAST, ContractAnalysis), Error>
pub fn analyze_smart_contract(
&mut self,
identifier: &QualifiedContractIdentifier,
contract_content: &str
) -> Result<(ContractAST, ContractAnalysis), Error>
Analyze a provided smart contract, but do not write the analysis to the AnalysisDatabase
sourcepub fn save_analysis(
&mut self,
identifier: &QualifiedContractIdentifier,
contract_analysis: &ContractAnalysis
) -> Result<(), CheckError>
pub fn save_analysis(
&mut self,
identifier: &QualifiedContractIdentifier,
contract_analysis: &ContractAnalysis
) -> Result<(), CheckError>
Save a contract analysis output to the AnalysisDatabase An error here would indicate that something has gone terribly wrong in the processing of a contract insert. the caller should likely abort the whole block or panic
sourcepub fn run_stx_transfer(
&mut self,
from: &PrincipalData,
to: &PrincipalData,
amount: u128
) -> Result<(Value, AssetMap, Vec<StacksTransactionEvent>), Error>
pub fn run_stx_transfer(
&mut self,
from: &PrincipalData,
to: &PrincipalData,
amount: u128
) -> Result<(Value, AssetMap, Vec<StacksTransactionEvent>), Error>
Execute a STX transfer in the current block. Will throw an error if it tries to spend STX that the ‘from’ principal doesn’t have.
sourcepub fn run_contract_call<F>(
&mut self,
sender: &PrincipalData,
contract: &QualifiedContractIdentifier,
public_function: &str,
args: &[Value],
abort_call_back: F
) -> Result<(Value, AssetMap, Vec<StacksTransactionEvent>), Error> where
F: FnOnce(&AssetMap, &mut ClarityDatabase<'_>) -> bool,
pub fn run_contract_call<F>(
&mut self,
sender: &PrincipalData,
contract: &QualifiedContractIdentifier,
public_function: &str,
args: &[Value],
abort_call_back: F
) -> Result<(Value, AssetMap, Vec<StacksTransactionEvent>), Error> where
F: FnOnce(&AssetMap, &mut ClarityDatabase<'_>) -> bool,
Execute a contract call in the current block. If an error occurs while processing the transaction, it’s modifications will be rolled back. abort_call_back is called with an AssetMap and a ClarityDatabase reference, if abort_call_back returns true, all modifications from this transaction will be rolled back. otherwise, they will be committed (though they may later be rolled back if the block itself is rolled back).
sourcepub fn initialize_smart_contract<F>(
&mut self,
identifier: &QualifiedContractIdentifier,
contract_ast: &ContractAST,
contract_str: &str,
abort_call_back: F
) -> Result<(AssetMap, Vec<StacksTransactionEvent>), Error> where
F: FnOnce(&AssetMap, &mut ClarityDatabase<'_>) -> bool,
pub fn initialize_smart_contract<F>(
&mut self,
identifier: &QualifiedContractIdentifier,
contract_ast: &ContractAST,
contract_str: &str,
abort_call_back: F
) -> Result<(AssetMap, Vec<StacksTransactionEvent>), Error> where
F: FnOnce(&AssetMap, &mut ClarityDatabase<'_>) -> bool,
Initialize a contract in the current block. If an error occurs while processing the initialization, it’s modifications will be rolled back. abort_call_back is called with an AssetMap and a ClarityDatabase reference, if abort_call_back returns true, all modifications from this transaction will be rolled back. otherwise, they will be committed (though they may later be rolled back if the block itself is rolled back).
Trait Implementations
sourceimpl ClarityConnection for ClarityTransactionConnection<'_>
impl ClarityConnection for ClarityTransactionConnection<'_>
sourcefn with_clarity_db_readonly_owned<F, R>(&mut self, to_do: F) -> R where
F: FnOnce(ClarityDatabase<'_>) -> (R, ClarityDatabase<'_>),
fn with_clarity_db_readonly_owned<F, R>(&mut self, to_do: F) -> R where
F: FnOnce(ClarityDatabase<'_>) -> (R, ClarityDatabase<'_>),
Do something with ownership of the underlying DB that involves only reading.
fn with_analysis_db_readonly<F, R>(&mut self, to_do: F) -> R where
F: FnOnce(&mut AnalysisDatabase<'_>) -> R,
fn with_clarity_db_readonly<F, R>(&mut self, to_do: F) -> R where
F: FnOnce(&mut ClarityDatabase<'_>) -> R,
fn with_readonly_clarity_env<F, R>(
&mut self,
mainnet: bool,
sender: PrincipalData,
cost_track: LimitedCostTracker,
to_do: F
) -> Result<R, InterpreterError> where
F: FnOnce(&mut Environment<'_, '_>) -> Result<R, InterpreterError>,
Auto Trait Implementations
impl<'a> !RefUnwindSafe for ClarityTransactionConnection<'a>
impl<'a> !Send for ClarityTransactionConnection<'a>
impl<'a> !Sync for ClarityTransactionConnection<'a>
impl<'a> Unpin for ClarityTransactionConnection<'a>
impl<'a> !UnwindSafe for ClarityTransactionConnection<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more