pub struct MockChainBuilder { /* private fields */ }Expand description
A builder for a MockChain.
Implementations§
Source§impl MockChainBuilder
impl MockChainBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Initializes a new mock chain builder with an empty state.
By default, the native_asset_id is set to ACCOUNT_ID_NATIVE_ASSET_FAUCET and can be
overwritten using Self::native_asset_id.
The verification_base_fee is initialized to 0 which means no fees are required by default.
Sourcepub fn with_accounts(
accounts: impl IntoIterator<Item = Account>,
) -> Result<Self>
pub fn with_accounts( accounts: impl IntoIterator<Item = Account>, ) -> Result<Self>
Initializes a new mock chain builder with the provided accounts.
This method only adds the accounts and cannot not register any seed or authenticator for it.
Calling MockChain::build_tx_context on accounts added in this way will not work if the
account is new or if they need an authenticator.
Due to these limitations, prefer using other methods to add accounts to the chain, e.g.
MockChainBuilder::add_account_from_builder.
Sourcepub fn native_asset_id(self, native_asset_id: AccountId) -> Self
pub fn native_asset_id(self, native_asset_id: AccountId) -> Self
Sets the native asset ID of the chain.
This must be a fungible faucet AccountId and is the asset in which fees will be accepted
by the transaction kernel.
Sourcepub fn verification_base_fee(self, verification_base_fee: u32) -> Self
pub fn verification_base_fee(self, verification_base_fee: u32) -> Self
Sets the verification_base_fee of the chain.
See FeeParameters for more details.
Sourcepub fn build(self) -> Result<MockChain>
pub fn build(self) -> Result<MockChain>
Consumes the builder, creates the genesis block of the chain and returns the MockChain.
Sourcepub fn create_new_wallet(&mut self, auth_method: Auth) -> Result<Account>
pub fn create_new_wallet(&mut self, auth_method: Auth) -> Result<Account>
Creates a new public BasicWallet account and registers the authenticator (if any) and
seed.
This does not add the account to the chain state, but it can still be used to call
MockChain::build_tx_context to automatically handle the authenticator and seed.
Sourcepub fn add_existing_wallet(&mut self, auth_method: Auth) -> Result<Account>
pub fn add_existing_wallet(&mut self, auth_method: Auth) -> Result<Account>
Adds an existing public BasicWallet account to the initial chain state and registers the
authenticator (if any).
Sourcepub fn add_existing_wallet_with_assets(
&mut self,
auth_method: Auth,
assets: impl IntoIterator<Item = Asset>,
) -> Result<Account>
pub fn add_existing_wallet_with_assets( &mut self, auth_method: Auth, assets: impl IntoIterator<Item = Asset>, ) -> Result<Account>
Adds an existing public BasicWallet account to the initial chain state and registers the
authenticator (if any).
Sourcepub fn create_new_faucet(
&mut self,
auth_method: Auth,
token_symbol: &str,
max_supply: u64,
) -> Result<Account>
pub fn create_new_faucet( &mut self, auth_method: Auth, token_symbol: &str, max_supply: u64, ) -> Result<Account>
Creates a new public BasicFungibleFaucet account and registers the authenticator (if
any) and seed.
This does not add the account to the chain state, but it can still be used to call
MockChain::build_tx_context to automatically handle the authenticator and seed.
Sourcepub fn add_existing_faucet(
&mut self,
auth_method: Auth,
token_symbol: &str,
max_supply: u64,
total_issuance: Option<u64>,
) -> Result<Account>
pub fn add_existing_faucet( &mut self, auth_method: Auth, token_symbol: &str, max_supply: u64, total_issuance: Option<u64>, ) -> Result<Account>
Adds an existing public BasicFungibleFaucet account to the initial chain state and
registers the authenticator (if the given Auth results in the creation of one).
Sourcepub fn create_new_mock_account(&mut self, auth_method: Auth) -> Result<Account>
pub fn create_new_mock_account(&mut self, auth_method: Auth) -> Result<Account>
Creates a new public account with an MockAccountComponent and registers the
authenticator (if any).
Sourcepub fn add_existing_mock_account(
&mut self,
auth_method: Auth,
) -> Result<Account>
pub fn add_existing_mock_account( &mut self, auth_method: Auth, ) -> Result<Account>
Adds an existing public account with an MockAccountComponent to the initial chain state
and registers the authenticator (if any).
Sourcepub fn add_existing_mock_account_with_storage(
&mut self,
auth_method: Auth,
slots: impl IntoIterator<Item = StorageSlot>,
) -> Result<Account>
pub fn add_existing_mock_account_with_storage( &mut self, auth_method: Auth, slots: impl IntoIterator<Item = StorageSlot>, ) -> Result<Account>
Adds an existing public account with an MockAccountComponent to the initial chain state
and registers the authenticator (if any).
Sourcepub fn add_existing_mock_account_with_assets(
&mut self,
auth_method: Auth,
assets: impl IntoIterator<Item = Asset>,
) -> Result<Account>
pub fn add_existing_mock_account_with_assets( &mut self, auth_method: Auth, assets: impl IntoIterator<Item = Asset>, ) -> Result<Account>
Adds an existing public account with an MockAccountComponent to the initial chain state
and registers the authenticator (if any).
Sourcepub fn add_existing_mock_account_with_storage_and_assets(
&mut self,
auth_method: Auth,
slots: impl IntoIterator<Item = StorageSlot>,
assets: impl IntoIterator<Item = Asset>,
) -> Result<Account>
pub fn add_existing_mock_account_with_storage_and_assets( &mut self, auth_method: Auth, slots: impl IntoIterator<Item = StorageSlot>, assets: impl IntoIterator<Item = Asset>, ) -> Result<Account>
Adds an existing public account with an MockAccountComponent to the initial chain state
and registers the authenticator (if any).
Sourcepub fn add_account_from_builder(
&mut self,
auth_method: Auth,
account_builder: AccountBuilder,
account_state: AccountState,
) -> Result<Account>
pub fn add_account_from_builder( &mut self, auth_method: Auth, account_builder: AccountBuilder, account_state: AccountState, ) -> Result<Account>
Builds the provided AccountBuilder with the provided auth method and registers the
authenticator (if any).
- If
AccountState::Existsis given the account is built as an existing account and added to the initial chain state. It can then be used in a transaction without having to validate its seed. - If
AccountState::Newis given the account is built as a new account and is not added to the chain. Its seed and authenticator are registered (if any). Its first transaction will be its creation transaction.MockChain::build_tx_contextcan be called with the account to automatically handle the authenticator and seed.
Sourcepub fn add_account(&mut self, account: Account) -> Result<()>
pub fn add_account(&mut self, account: Account) -> Result<()>
Adds the provided account to the list of genesis accounts.
This method only adds the account and does not store its account credentials (seed and
authenticator) for it. Calling MockChain::build_tx_context on accounts added in this
way will not work if the account is new or if they need an authenticator.
Due to these limitations, prefer using other methods to add accounts to the chain, e.g.
MockChainBuilder::add_account_from_builder.
Sourcepub fn add_note(&mut self, note: impl Into<OutputNote>)
pub fn add_note(&mut self, note: impl Into<OutputNote>)
Adds the provided note to the initial chain state.
Sourcepub fn add_p2any_note(
&mut self,
sender_account_id: AccountId,
asset: &[Asset],
) -> Result<Note>
pub fn add_p2any_note( &mut self, sender_account_id: AccountId, asset: &[Asset], ) -> Result<Note>
Creates a new P2ANY note from the provided parameters and adds it to the list of genesis notes. This note is similar to a P2ID note but can be consumed by any account.
In the created MockChain, the note will be immediately spendable by target_account_id
and carries no additional reclaim or timelock conditions.
Sourcepub fn add_p2id_note(
&mut self,
sender_account_id: AccountId,
target_account_id: AccountId,
asset: &[Asset],
note_type: NoteType,
) -> Result<Note, NoteError>
pub fn add_p2id_note( &mut self, sender_account_id: AccountId, target_account_id: AccountId, asset: &[Asset], note_type: NoteType, ) -> Result<Note, NoteError>
Creates a new P2ID note from the provided parameters and adds it to the list of genesis notes.
In the created MockChain, the note will be immediately spendable by target_account_id
and carries no additional reclaim or timelock conditions.
Sourcepub fn add_p2ide_note(
&mut self,
sender_account_id: AccountId,
target_account_id: AccountId,
asset: &[Asset],
note_type: NoteType,
reclaim_height: Option<BlockNumber>,
timelock_height: Option<BlockNumber>,
) -> Result<Note, NoteError>
pub fn add_p2ide_note( &mut self, sender_account_id: AccountId, target_account_id: AccountId, asset: &[Asset], note_type: NoteType, reclaim_height: Option<BlockNumber>, timelock_height: Option<BlockNumber>, ) -> Result<Note, NoteError>
Adds a P2IDE OutputNote (pay‑to‑ID‑extended) to the list of genesis notes.
A P2IDE note can include an optional timelock_height and/or an optional
reclaim_height after which the sender_account_id may reclaim the
funds.
Sourcepub fn add_swap_note(
&mut self,
sender: AccountId,
offered_asset: Asset,
requested_asset: Asset,
payback_note_type: NoteType,
) -> Result<(Note, NoteDetails)>
pub fn add_swap_note( &mut self, sender: AccountId, offered_asset: Asset, requested_asset: Asset, payback_note_type: NoteType, ) -> Result<(Note, NoteDetails)>
Adds a public SWAP OutputNote to the list of genesis notes.
Sourcepub fn add_spawn_note<'note>(
&mut self,
sender_id: AccountId,
output_notes: impl IntoIterator<Item = &'note Note>,
) -> Result<Note>
pub fn add_spawn_note<'note>( &mut self, sender_id: AccountId, output_notes: impl IntoIterator<Item = &'note Note>, ) -> Result<Note>
Adds a public SPAWN note to the list of genesis notes.
A SPAWN note contains a note script that creates all output_notes that get passed as a
parameter.
Sourcepub fn add_p2id_note_with_fee(
&mut self,
target_account_id: AccountId,
amount: u64,
) -> Result<Note>
pub fn add_p2id_note_with_fee( &mut self, target_account_id: AccountId, amount: u64, ) -> Result<Note>
Creates a new P2ID note with the provided amount of the native fee asset of the chain.
The native asset ID of the asset can be set using Self::native_asset_id. By default it
is ACCOUNT_ID_NATIVE_ASSET_FAUCET.
In the created MockChain, the note will be immediately spendable by target_account_id.
Trait Implementations§
Source§impl Clone for MockChainBuilder
impl Clone for MockChainBuilder
Source§fn clone(&self) -> MockChainBuilder
fn clone(&self) -> MockChainBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MockChainBuilder
impl Debug for MockChainBuilder
Auto Trait Implementations§
impl Freeze for MockChainBuilder
impl !RefUnwindSafe for MockChainBuilder
impl Send for MockChainBuilder
impl Sync for MockChainBuilder
impl Unpin for MockChainBuilder
impl !UnwindSafe for MockChainBuilder
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more