pub struct Coin<Specification>where
Specification: CoinSpecification,{
pub utxo_id: UtxoId,
pub owner: Address,
pub amount: Word,
pub asset_id: AssetId,
pub tx_pointer: TxPointer,
pub witness_index: Specification::Witness,
pub predicate_gas_used: Specification::PredicateGasUsed,
pub predicate: Specification::Predicate,
pub predicate_data: Specification::PredicateData,
}
Expand description
It is a full representation of the coin from the specification: https://github.com/FuelLabs/fuel-specs/blob/master/src/tx-format/input.md#inputcoin.
The specification defines the layout of the Coin
in the serialized form for the
fuel-vm
. But on the business logic level, we don’t use all fields at the same time.
It is why in the super::Input
the coin is represented by several forms based on
the usage context. Leaving some fields empty reduces the memory consumption by the
structure and erases the empty useless fields.
The CoinSpecification
trait specifies the sub-coin for the corresponding usage
context. It allows us to write the common logic of all sub-coins without the overhead
and duplication.
Sub-coin:
Signed
- means that the coin should be signed by theowner
, and the signature(witness) should be stored under thewitness_index
index in thewitnesses
vector of thecrate::Transaction
.Predicate
- means that the coin is not signed, and theowner
is apredicate
bytecode. The merkle root from thepredicate
should be equal to theowner
.Full
- is used during the deserialization of the coin. It should be transformed intoSigned
orPredicate
sub-coin. If thepredicate
is empty, it isSigned
, elsePredicate
.
Fields§
§utxo_id: UtxoId
§owner: Address
§amount: Word
§asset_id: AssetId
§tx_pointer: TxPointer
§witness_index: Specification::Witness
§predicate_gas_used: Specification::PredicateGasUsed
§predicate: Specification::Predicate
§predicate_data: Specification::PredicateData
Implementations§
source§impl<Specification> Coin<Specification>where
Specification: CoinSpecification,
impl<Specification> Coin<Specification>where
Specification: CoinSpecification,
sourcepub fn prepare_sign(&mut self)
pub fn prepare_sign(&mut self)
The “Note” section from the specification: https://github.com/FuelLabs/fuel-specs/blob/master/src/tx-format/input.md#inputcoin.
Trait Implementations§
source§impl<Specification> Clone for Coin<Specification>where
Specification: CoinSpecification + Clone,
Specification::Witness: Clone,
Specification::PredicateGasUsed: Clone,
Specification::Predicate: Clone,
Specification::PredicateData: Clone,
impl<Specification> Clone for Coin<Specification>where
Specification: CoinSpecification + Clone,
Specification::Witness: Clone,
Specification::PredicateGasUsed: Clone,
Specification::Predicate: Clone,
Specification::PredicateData: Clone,
source§impl<Specification> Debug for Coin<Specification>where
Specification: CoinSpecification,
impl<Specification> Debug for Coin<Specification>where
Specification: CoinSpecification,
source§impl<Specification> Default for Coin<Specification>where
Specification: CoinSpecification + Default,
Specification::Witness: Default,
Specification::PredicateGasUsed: Default,
Specification::Predicate: Default,
Specification::PredicateData: Default,
impl<Specification> Default for Coin<Specification>where
Specification: CoinSpecification + Default,
Specification::Witness: Default,
Specification::PredicateGasUsed: Default,
Specification::Predicate: Default,
Specification::PredicateData: Default,
source§impl<Specification> Deserialize for Coin<Specification>where
Specification: CoinSpecification,
Specification::Witness: Deserialize,
Specification::PredicateGasUsed: Deserialize,
Specification::Predicate: Deserialize,
Specification::PredicateData: Deserialize,
impl<Specification> Deserialize for Coin<Specification>where
Specification: CoinSpecification,
Specification::Witness: Deserialize,
Specification::PredicateGasUsed: Deserialize,
Specification::Predicate: Deserialize,
Specification::PredicateData: Deserialize,
source§fn decode_static<I: Input + ?Sized>(buffer: &mut I) -> Result<Self, Error>
fn decode_static<I: Input + ?Sized>(buffer: &mut I) -> Result<Self, Error>
Self
from the buffer
.source§fn decode_dynamic<I: Input + ?Sized>(
&mut self,
buffer: &mut I,
) -> Result<(), Error>
fn decode_dynamic<I: Input + ?Sized>( &mut self, buffer: &mut I, ) -> Result<(), Error>
buffer
to fill Self
.
The default implementation does nothing. Dynamically-sized contains should
override this.source§impl<Specification> Hash for Coin<Specification>where
Specification: CoinSpecification + Hash,
Specification::Witness: Hash,
Specification::PredicateGasUsed: Hash,
Specification::Predicate: Hash,
Specification::PredicateData: Hash,
impl<Specification> Hash for Coin<Specification>where
Specification: CoinSpecification + Hash,
Specification::Witness: Hash,
Specification::PredicateGasUsed: Hash,
Specification::Predicate: Hash,
Specification::PredicateData: Hash,
source§impl<Specification> PartialEq for Coin<Specification>where
Specification: CoinSpecification + PartialEq,
Specification::Witness: PartialEq,
Specification::PredicateGasUsed: PartialEq,
Specification::Predicate: PartialEq,
Specification::PredicateData: PartialEq,
impl<Specification> PartialEq for Coin<Specification>where
Specification: CoinSpecification + PartialEq,
Specification::Witness: PartialEq,
Specification::PredicateGasUsed: PartialEq,
Specification::Predicate: PartialEq,
Specification::PredicateData: PartialEq,
source§impl<Specification> Serialize for Coin<Specification>where
Specification: CoinSpecification,
Specification::Witness: Serialize,
Specification::PredicateGasUsed: Serialize,
Specification::Predicate: Serialize,
Specification::PredicateData: Serialize,
impl<Specification> Serialize for Coin<Specification>where
Specification: CoinSpecification,
Specification::Witness: Serialize,
Specification::PredicateGasUsed: Serialize,
Specification::Predicate: Serialize,
Specification::PredicateData: Serialize,
source§fn size_static(&self) -> usize
fn size_static(&self) -> usize
source§fn size_dynamic(&self) -> usize
fn size_dynamic(&self) -> usize
source§fn encode_static<O: Output + ?Sized>(&self, buffer: &mut O) -> Result<(), Error>
fn encode_static<O: Output + ?Sized>(&self, buffer: &mut O) -> Result<(), Error>
Self
.source§fn encode_dynamic<O: Output + ?Sized>(
&self,
buffer: &mut O,
) -> Result<(), Error>
fn encode_dynamic<O: Output + ?Sized>( &self, buffer: &mut O, ) -> Result<(), Error>
Self
.
The default implementation does nothing. Dynamically-sized contains should
override this.source§fn size(&self) -> usize
fn size(&self) -> usize
impl<Specification> Eq for Coin<Specification>where
Specification: CoinSpecification + Eq,
Specification::Witness: Eq,
Specification::PredicateGasUsed: Eq,
Specification::Predicate: Eq,
Specification::PredicateData: Eq,
impl<Specification> StructuralPartialEq for Coin<Specification>where
Specification: CoinSpecification,
Auto Trait Implementations§
impl<Specification> Freeze for Coin<Specification>where
<Specification as CoinSpecification>::Witness: Freeze,
<Specification as CoinSpecification>::PredicateGasUsed: Freeze,
<Specification as CoinSpecification>::Predicate: Freeze,
<Specification as CoinSpecification>::PredicateData: Freeze,
impl<Specification> RefUnwindSafe for Coin<Specification>where
<Specification as CoinSpecification>::Witness: RefUnwindSafe,
<Specification as CoinSpecification>::PredicateGasUsed: RefUnwindSafe,
<Specification as CoinSpecification>::Predicate: RefUnwindSafe,
<Specification as CoinSpecification>::PredicateData: RefUnwindSafe,
impl<Specification> Send for Coin<Specification>where
<Specification as CoinSpecification>::Witness: Send,
<Specification as CoinSpecification>::PredicateGasUsed: Send,
<Specification as CoinSpecification>::Predicate: Send,
<Specification as CoinSpecification>::PredicateData: Send,
impl<Specification> Sync for Coin<Specification>where
<Specification as CoinSpecification>::Witness: Sync,
<Specification as CoinSpecification>::PredicateGasUsed: Sync,
<Specification as CoinSpecification>::Predicate: Sync,
<Specification as CoinSpecification>::PredicateData: Sync,
impl<Specification> Unpin for Coin<Specification>where
<Specification as CoinSpecification>::Witness: Unpin,
<Specification as CoinSpecification>::PredicateGasUsed: Unpin,
<Specification as CoinSpecification>::Predicate: Unpin,
<Specification as CoinSpecification>::PredicateData: Unpin,
impl<Specification> UnwindSafe for Coin<Specification>where
<Specification as CoinSpecification>::Witness: UnwindSafe,
<Specification as CoinSpecification>::PredicateGasUsed: UnwindSafe,
<Specification as CoinSpecification>::Predicate: UnwindSafe,
<Specification as CoinSpecification>::PredicateData: UnwindSafe,
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
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> 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 moresource§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> StorageAsMut for T
impl<T> StorageAsMut for T
fn storage<Type>(&mut self) -> StorageMut<'_, Self, Type>where
Type: Mappable,
fn storage_as_mut<Type>(&mut self) -> StorageMut<'_, Self, Type>where
Type: Mappable,
source§impl<T> StorageAsRef for T
impl<T> StorageAsRef for T
fn storage<Type>(&self) -> StorageRef<'_, Self, Type>where
Type: Mappable,
fn storage_as_ref<Type>(&self) -> StorageRef<'_, Self, Type>where
Type: Mappable,
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.