pub struct Helper(_);
Expand description
A lightweight API to suibase. Multiple instance can be created within the same app.
You interact with Suibase in 3 steps:
- Check if suibase is_installed()
- Call select_workdir() to pick among “localnet”, “devnet”, “testnet”, “mainnet” or the one currently set “active” by the user.
- You can now call any other API functions (in any order). Most calls will relate to the selected workdir.
You can call again select_workdir() to switch to another workdir.
Implementations§
source§impl Helper
impl Helper
sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a new Helper
.
Example
use suibase::Helper;
fn main() {
let sbh = Helper::new();
if sbh.is_installed()? {
sbh.select_workdir("localnet")?;
println!("active address is {}", sbh.client_address("active"));
}
}
sourcepub fn is_installed(&self) -> Result<bool, Error>
pub fn is_installed(&self) -> Result<bool, Error>
Check first if suibase is installed, otherwise most of the other calls will fail in some ways.
sourcepub fn select_workdir(&self, workdir_name: &str) -> Result<(), Error>
pub fn select_workdir(&self, workdir_name: &str) -> Result<(), Error>
Select an existing workdir by name.
Possible values are: “active”, “cargobin”, “localnet”, “devnet”, “testnet”, “mainnet” and other custom names might be supported in future.
Note: “active” is special. It will resolve the active workdir at the moment of the call. Example: if “localnet” is the active, then this call is equivalent to to be done for “localnet”. The selection does not change even if the user externally change the active after this call.
sourcepub fn keystore_pathname(&self) -> Result<String, Error>
pub fn keystore_pathname(&self) -> Result<String, Error>
Get the pathname of the file keystore (when available).
Context: Selected Workdir by this API.
sourcepub fn package_object_id(&self, package_name: &str) -> Result<ObjectID, Error>
pub fn package_object_id(&self, package_name: &str) -> Result<ObjectID, Error>
Get the ObjectID of the last successfully published “package_name”.
package_name is the “name” field specified in the “Move.toml”.
Related path: ~/suibase/workdirs/<workdir_name>/published-data/<package_name>/
sourcepub fn package_id(&self, package_name: &str) -> Result<String, Error>
pub fn package_id(&self, package_name: &str) -> Result<String, Error>
Alternative for string-based API.
sourcepub fn published_new_object_ids(
&self,
object_type: &str
) -> Result<Vec<ObjectID>, Error>
pub fn published_new_object_ids( &self, object_type: &str ) -> Result<Vec<ObjectID>, Error>
Get the ObjectID of the objects that were created when the package was published.
object_type format is the Sui Move “package::module::type”.
Example:
module acme::Tools { struct Anvil has key, drop { … } … fun init(ctx: &mut TxContext) { Anvil::new(ctx); … } }
The object_type is “acme::Tools::Anvil”
Related path: ~/suibase/workdirs/<workdir_name>/published-data/<package_name>/
sourcepub fn published_new_objects(
&self,
object_type: &str
) -> Result<Vec<String>, Error>
pub fn published_new_objects( &self, object_type: &str ) -> Result<Vec<String>, Error>
Alternative to published_new_object_ids() for string-based API.
sourcepub fn client_sui_address(
&self,
address_name: &str
) -> Result<SuiAddress, Error>
pub fn client_sui_address( &self, address_name: &str ) -> Result<SuiAddress, Error>
Get an address by name.
Suibase localnet/devnet/testnet/mainnet workdir are created with a set of pre-defined client addresses.
These addresses are useful for testing. In particular, with localnet they are prefunded.
Names can be: active | sb-[1-5]-[ed25519|scp256k1|scp256r1]
Examples: “active”, “sb-1-ed25519”, “sb-3-scp256r1”, “sb-5-scp256k1” …
“active” is same as doing “sui client active-address” for the selected workdir.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Helper
impl Send for Helper
impl Sync for Helper
impl Unpin for Helper
impl UnwindSafe for Helper
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere T: 'a,
§impl<T> Conv for T
impl<T> Conv for T
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a Request
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere Self: Sized,
§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 more§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 more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere Self: Borrow<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> Rwhere Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere Self: AsRef<U>, U: 'a + ?Sized, R: 'a,
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere Self: AsMut<U>, U: 'a + ?Sized, R: 'a,
self
, then passes self.as_mut()
into the pipe
function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,
Deref::Target
of a value. Read more§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.§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.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds.