Struct RemoteEnvironment

Source
pub struct RemoteEnvironment { /* private fields */ }
Expand description

A remote environment on a cluster. Interacts with the cluster using RPC.

Implementations§

Source§

impl RemoteEnvironment

Source

pub fn new(client: RpcClient, payer: Keypair) -> Self

Contruct a new remote environment. The payer keypair is expected to have enough funds to fund all transactions.

Source

pub fn new_with_airdrop( client: RpcClient, payer: Keypair, lamports: u64, ) -> Self

Construct a new remote environment, airdropping lamports from the given airdrop endpoint up to the given account. Use this on devnet and testnet.

Source

pub fn airdrop(&self, account: Pubkey, lamports: u64)

Airdrop lamports up to the given balance to the account.

Trait Implementations§

Source§

impl Environment for RemoteEnvironment

Source§

fn payer(&self) -> Keypair

Returns the keypair used to pay for all transactions. All transaction fees and rent costs are payed for by this keypair.
Source§

fn execute_transaction( &mut self, tx: Transaction, ) -> EncodedConfirmedTransactionWithStatusMeta

Executes the batch of transactions in the right order and waits for them to be confirmed. The execution results are returned.
Source§

fn get_latest_blockhash(&self) -> Hash

Fetch the latest blockhash, for construction of transactions.
Source§

fn get_rent_excemption(&self, data: usize) -> u64

Fetch the amount of lamports needed for an account of the given size to be rent excempt.
Source§

fn get_account(&self, pubkey: Pubkey) -> Option<Account>

Fetch an account. None if the account does not exist.
Source§

fn get_recent_blockhash(&self) -> Hash

👎Deprecated since 0.2.0: Please use get_latest_blockhash() instead
Fetch a recent blockhash, for construction of transactions.
Source§

fn tx_with_instructions( &self, instructions: &[Instruction], signers: &[&Keypair], ) -> Transaction

Assemble the given instructions into a transaction and sign it. All transactions constructed by this method are signed and payed for by the payer.
Source§

fn execute_as_transaction( &mut self, instructions: &[Instruction], signers: &[&Keypair], ) -> EncodedConfirmedTransactionWithStatusMeta

Assemble the given instructions into a transaction and sign it. All transactions executed by this method are signed and payed for by the payer.
Source§

fn execute_as_transaction_debug( &mut self, instructions: &[Instruction], signers: &[&Keypair], ) -> EncodedConfirmedTransactionWithStatusMeta

Assemble the given instructions into a transaction and sign it. All transactions executed by this method are signed and payed for by the payer. Prints the transaction before sending it.
Source§

fn create_account( &mut self, keypair: &Keypair, lamports: u64, space: usize, owner: Pubkey, )

Executes a transaction constructing an empty account with the specified amount of space and lamports, owned by the provided program.
Source§

fn create_account_rent_excempt( &mut self, keypair: &Keypair, space: usize, owner: Pubkey, )

Executes a transaction constructing an empty rent-excempt account with the specified amount of space, owned by the provided program.
Source§

fn create_token_mint( &mut self, mint: &Keypair, authority: Pubkey, freeze_authority: Option<Pubkey>, decimals: u8, )

Executes a transaction constructing a token mint. The account needs to be empty and belong to system for this to work.
Source§

fn mint_tokens( &mut self, mint: Pubkey, authority: &Keypair, account: Pubkey, amount: u64, )

Executes a transaction that mints tokens from a mint to an account belonging to that mint.
Source§

fn create_token_account(&mut self, account: &Keypair, mint: Pubkey)

Executes a transaction constructing a token account of the specified mint. The account needs to be empty and belong to system for this to work. Prefer to use [create_associated_token_account] if you don’t need the provided account to contain the token account.
Source§

fn create_associated_token_account( &mut self, owner: &Keypair, mint: Pubkey, ) -> Pubkey

Executes a transaction constructing the associated token account of the specified mint belonging to the owner. This will fail if the account already exists.
Source§

fn get_or_create_associated_token_account( &mut self, owner: &Keypair, mint: Pubkey, ) -> Pubkey

Executes a transaction constructing the associated token account of the specified mint belonging to the owner.
Source§

fn create_account_with_data(&mut self, account: &Keypair, data: Vec<u8>)

Executes a transaction creating and filling the given account with the given data. The account is required to be empty and will be owned by bpf_loader afterwards.
Source§

fn deploy_program<P: AsRef<Path>>(&mut self, program_path: P) -> Pubkey

Executes a transaction deploying a program from a file if it does not already exist. The keypair is derived from the file contents.
Source§

fn get_unpacked_account<T: Pack>(&self, pubkey: Pubkey) -> Option<T>

Gets and unpacks an account. None if the account does not exist.
Source§

fn get_deserialized_account<T: BorshDeserialize>( &self, pubkey: Pubkey, ) -> Option<T>

Gets and deserializes an account. None if the account does not exist.
Source§

fn get_serde_deserialized_account<'a, T: DeserializeOwned>( &self, pubkey: Pubkey, ) -> Option<T>

Gets and deserializes an account. None if the account does not exist.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AbiExample for T

Source§

default fn example() -> T

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,