pub struct ContractCalls<W: Witnesses + 'static> { /* private fields */ }Expand description
A contract-specific wrapper around the call-tx pipeline.
Port of TS ContractCallsInterface<C>. Each instance is bound to
one deployed contract (contract address + optional private state
id) and a providers bundle; calling
ContractCalls::call routes through the submit
pipeline and returns the finalized tx data.
Concrete typed call-tx wrappers live at the caller’s boundary — we
don’t know circuit signatures at this layer, so the Rust API is
dynamically typed at the edge (via AlignedValue). Typed wrappers
are trivial to write on top (e.g. counter.increment() →
call_tx.call(&CircuitId::new("increment"), vec![], ...)).
Implementations§
Source§impl<W: Witnesses + 'static> ContractCalls<W>
impl<W: Witnesses + 'static> ContractCalls<W>
Sourcepub fn new(
providers: Arc<ErasedProviders>,
executable: Arc<IrExecutable<W>>,
contract_address: ContractAddress,
private_state_id: Option<PrivateStateId>,
) -> Self
pub fn new( providers: Arc<ErasedProviders>, executable: Arc<IrExecutable<W>>, contract_address: ContractAddress, private_state_id: Option<PrivateStateId>, ) -> Self
Construct a new call-tx interface for contract_address.
Port of TS createContractCallsInterface.
Sourcepub fn contract_address(&self) -> &ContractAddress
pub fn contract_address(&self) -> &ContractAddress
The contract address this interface is bound to.
Sourcepub fn private_state_id(&self) -> Option<&PrivateStateId>
pub fn private_state_id(&self) -> Option<&PrivateStateId>
The private state id this interface is bound to (if any).
Sourcepub async fn build_unproven<R>(
&self,
rng: &mut R,
circuit_id: impl Into<CircuitId>,
args: RuntimeValue,
options: CallOptions,
) -> Result<UnsubmittedCallTxData>
pub async fn build_unproven<R>( &self, rng: &mut R, circuit_id: impl Into<CircuitId>, args: RuntimeValue, options: CallOptions, ) -> Result<UnsubmittedCallTxData>
Invoke circuit_id with args. Routes through
submit_call_tx and returns the finalized call-tx data.
Wire-level Rust equivalent of the TS variadic
contract.circuits.increment(...args). The Rust port is
explicit about the per-call options — chain time, network id,
fee balancing, optional private-state overrides — because the
Rust RNG isn’t implicit and we don’t have a global “chain
context” to thread from.
Stage 1: build an unproven call tx. Runs the circuit
off-chain via the bound executable, assembles the unproven
Transaction, and returns the unsubmitted bundle. No proof is
computed; no network calls are made.
Pair with Self::prove / Self::balance /
Self::submit / Self::submit_and_wait to drive the
submission pipeline stage by stage. The one-shot Self::call
chains all of these for callers that want a single entry
point.
Sourcepub async fn prove(&self, unproven: UnprovenTx) -> Result<ProvenTx>
pub async fn prove(&self, unproven: UnprovenTx) -> Result<ProvenTx>
Stage 2: hand the unproven tx to the proof provider. Returns
the proven tx phase. Apply any pre-prove balancing (e.g. the
wallet-side shielded balancer
moonproof_wallet::shielded::balance_contract_call_tx) to the
UnprovenTx before passing it in here.
Sourcepub async fn balance(
&self,
proven: ProvenTx,
ttl_ms: Option<i64>,
) -> Result<FinalizedTx>
pub async fn balance( &self, proven: ProvenTx, ttl_ms: Option<i64>, ) -> Result<FinalizedTx>
Stage 3: hand the proven tx to the wallet provider for fee
balancing + sealing. Returns the wire-format finalized tx ready
for submission. ttl_ms = None uses the wallet provider’s
default TTL (typically chain-now + 1h).
Sourcepub async fn submit(&self, tx: FinalizedTx) -> Result<TransactionId>
pub async fn submit(&self, tx: FinalizedTx) -> Result<TransactionId>
Stage 4 (fire-and-forget): submit the finalized tx to the
node, return the chain-assigned TransactionId without
waiting for finalization. Pair with
Self::wait_for_finalization when the caller needs the
finalized tx data.
Sourcepub async fn wait_for_finalization(
&self,
tx_id: &TransactionId,
) -> Result<FinalizedTxData>
pub async fn wait_for_finalization( &self, tx_id: &TransactionId, ) -> Result<FinalizedTxData>
Block until the indexer reports the tx as finalized. Pair
with Self::submit when the caller wants to drive the wait
separately.
Sourcepub async fn submit_and_wait(&self, tx: FinalizedTx) -> Result<FinalizedTxData>
pub async fn submit_and_wait(&self, tx: FinalizedTx) -> Result<FinalizedTxData>
Stage 4 (one-shot): submit the finalized tx and wait for the
indexer to report finalization. Equivalent to
Self::submit followed by Self::wait_for_finalization.
Sourcepub async fn call<R>(
&self,
rng: &mut R,
circuit_id: impl Into<CircuitId>,
args: RuntimeValue,
options: CallOptions,
) -> Result<FinalizedCallTxData>
pub async fn call<R>( &self, rng: &mut R, circuit_id: impl Into<CircuitId>, args: RuntimeValue, options: CallOptions, ) -> Result<FinalizedCallTxData>
One-shot: build → optionally pre-submit hook → prove → balance → submit → wait. The common case for “invoke a circuit and return the finalized tx data”.
circuit_id: impl Into<CircuitId> — accepts &str, String,
or an owned CircuitId. options.pre_submit is applied
between Self::build_unproven and Self::prove;
options.serialize_next_private_state is invoked on success
to persist the next private state (when
private_state_id is bound on this dispatcher).
Sourcepub async fn call_with_optional_scope<R>(
&self,
rng: &mut R,
circuit_id: impl Into<CircuitId>,
args: RuntimeValue,
options: CallOptions,
tx_ctx: Option<&Arc<TransactionContextImpl>>,
) -> Result<CallTxOutcome>
pub async fn call_with_optional_scope<R>( &self, rng: &mut R, circuit_id: impl Into<CircuitId>, args: RuntimeValue, options: CallOptions, tx_ctx: Option<&Arc<TransactionContextImpl>>, ) -> Result<CallTxOutcome>
Like Self::call but accepts an optional scoped-tx context.
When tx_ctx = Some(ctx), the call is merged into the scope’s
queue and submission is deferred to the surrounding
crate::with_contract_scoped_transaction closure exit. When
tx_ctx = None, behaviour matches Self::call.
Trait Implementations§
Source§impl<W: Witnesses + 'static> Clone for ContractCalls<W>
impl<W: Witnesses + 'static> Clone for ContractCalls<W>
Auto Trait Implementations§
impl<W> !RefUnwindSafe for ContractCalls<W>
impl<W> !UnwindSafe for ContractCalls<W>
impl<W> Forget for ContractCalls<W>
impl<W> Freeze for ContractCalls<W>where
*const ArcInner<ErasedProviders> is !null: Freeze,
PhantomData<ArcInner<ErasedProviders>>: Freeze,
*const ArcInner<IrExecutable<W>> is !null: Freeze,
PhantomData<ArcInner<IrExecutable<W>>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
impl<W> Move for ContractCalls<W>
impl<W> Send for ContractCalls<W>
impl<W> Sync for ContractCalls<W>
impl<W> Unpin for ContractCalls<W>
impl<W> UnsafeUnpin for ContractCalls<W>where
*const ArcInner<ErasedProviders> is !null: UnsafeUnpin,
PhantomData<ArcInner<ErasedProviders>>: UnsafeUnpin,
*const ArcInner<IrExecutable<W>> is !null: UnsafeUnpin,
PhantomData<ArcInner<IrExecutable<W>>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Envelope<PhantomData<T>> for T
impl<T> Envelope<PhantomData<T>> for T
Source§fn into_envelope(&self) -> PhantomData<T>
fn into_envelope(&self) -> PhantomData<T>
Source§fn envelope_data(&self) -> Vec<u8> ⓘwhere
T: Serializable + Tagged,
fn envelope_data(&self) -> Vec<u8> ⓘwhere
T: Serializable + Tagged,
Source§fn envelope_write(&self, writer: impl Write) -> Result<(), Error>where
T: Serializable + Tagged,
fn envelope_write(&self, writer: impl Write) -> Result<(), Error>where
T: Serializable + Tagged,
Source§impl<T> Envelope<T> for Twhere
T: Clone,
impl<T> Envelope<T> for Twhere
T: Clone,
Source§fn into_envelope(&self) -> T
fn into_envelope(&self) -> T
Source§fn envelope_data(&self) -> Vec<u8> ⓘwhere
T: Serializable + Tagged,
fn envelope_data(&self) -> Vec<u8> ⓘwhere
T: Serializable + Tagged,
Source§fn envelope_write(&self, writer: impl Write) -> Result<(), Error>where
T: Serializable + Tagged,
fn envelope_write(&self, writer: impl Write) -> Result<(), Error>where
T: Serializable + Tagged,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> JsonSchemaMaybe for T
impl<T> MaybeSend for Twhere
T: Send,
impl<T> MaybeSend for T
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> SyncDeps for T
impl<T> SyncDeps for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.