pub struct Arweave {
pub name: String,
pub units: String,
pub base_url: Url,
pub crypto: Provider,
}
Expand description
Struct with methods for interacting with the Arweave network.
Fields§
§name: String
§units: String
§base_url: Url
§crypto: Provider
Implementations§
Source§impl Arweave
impl Arweave
pub async fn from_keypair_path( keypair_path: PathBuf, base_url: Url, ) -> Result<Arweave, Error>
pub fn from_keypair_path_sync( keypair_path: PathBuf, base_url: Url, ) -> Result<Arweave, Error>
Sourcepub async fn get_pending_count(&self) -> Result<usize, Error>
pub async fn get_pending_count(&self) -> Result<usize, Error>
Get pending network transaction count.
Sourcepub async fn get_price(
&self,
bytes: &u64,
) -> Result<(BigUint, BigUint, BigUint), Error>
pub async fn get_price( &self, bytes: &u64, ) -> Result<(BigUint, BigUint, BigUint), Error>
Returns price of uploading data to the network in winstons and USD per AR and USD per SOL as a BigUint with two decimals.
Sourcepub async fn get_price_terms(
&self,
reward_mult: f32,
) -> Result<(u64, u64), Error>
pub async fn get_price_terms( &self, reward_mult: f32, ) -> Result<(u64, u64), Error>
Gets base and incremental prices for a 256 KB block of data.
Sourcepub async fn get_transaction(&self, id: &Base64) -> Result<Transaction, Error>
pub async fn get_transaction(&self, id: &Base64) -> Result<Transaction, Error>
Gets transaction from the network.
Sourcepub async fn get_wallet_balance(
&self,
wallet_address: Option<String>,
) -> Result<BigUint, Error>
pub async fn get_wallet_balance( &self, wallet_address: Option<String>, ) -> Result<BigUint, Error>
Returns the balance of the wallet.
pub fn chunk_file_paths<IP>( &self, paths_iter: IP, data_size: u64, ) -> Result<Vec<PathsChunk>, Error>
pub fn create_bundle_from_data_items( &self, data_items: Vec<(DataItem, Status)>, ) -> Result<(Vec<u8>, Value), Error>
pub async fn create_bundle_transaction_from_file_paths( &self, paths_iter: Vec<PathBuf>, tags: Vec<Tag<String>>, price_terms: (u64, u64), ) -> Result<(Transaction, Value), Error>
pub fn create_data_item( &self, data: Vec<u8>, tags: Vec<Tag<String>>, auto_content_tag: bool, ) -> Result<DataItem, Error>
pub async fn create_data_item_from_file_path( &self, file_path: PathBuf, tags: Vec<Tag<String>>, ) -> Result<(DataItem, Status), Error>
pub async fn create_data_items_from_file_paths( &self, paths: Vec<PathBuf>, tags: Vec<Tag<String>>, ) -> Result<Vec<(DataItem, Status)>, Error>
pub fn deserialize_bundle( &self, bundle: Vec<u8>, ) -> Result<Vec<DataItem>, Error>
pub async fn post_bundle_transaction_from_file_paths( &self, paths_chunk: PathsChunk, tags: Vec<Tag<String>>, price_terms: (u64, u64), buffer: usize, ) -> Result<BundleStatus, Error>
pub async fn post_bundle_transaction_from_file_paths_with_sol( &self, paths_chunk: PathsChunk, tags: Vec<Tag<String>>, price_terms: (u64, u64), chunks_buffer: usize, solana_url: Url, sol_ar_url: Url, from_keypair: &Keypair, ) -> Result<BundleStatus, Error>
pub fn sign_data_item(&self, data_item: DataItem) -> Result<DataItem, Error>
pub async fn create_transaction( &self, data: Vec<u8>, other_tags: Option<Vec<Tag<Base64>>>, last_tx: Option<Base64>, price_terms: (u64, u64), auto_content_tag: bool, ) -> Result<Transaction, Error>
pub async fn create_transaction_from_file_path( &self, file_path: PathBuf, other_tags: Option<Vec<Tag<Base64>>>, last_tx: Option<Base64>, price_terms: (u64, u64), auto_content_tag: bool, ) -> Result<Transaction, Error>
pub fn merklize(&self, data: Vec<u8>) -> Result<Transaction, Error>
pub async fn post_chunk( &self, chunk: &Chunk, client: &Client, ) -> Result<usize, Error>
pub async fn post_chunk_with_retries( &self, chunk: Chunk, client: Client, ) -> Result<usize, Error>
pub async fn post_transaction( &self, signed_transaction: &Transaction, ) -> Result<(Base64, u64), Error>
pub async fn post_transaction_chunks( &self, signed_transaction: Transaction, chunks_buffer: usize, ) -> Result<(Base64, u64), Error>
Sourcepub fn sign_transaction(
&self,
transaction: Transaction,
) -> Result<Transaction, Error>
pub fn sign_transaction( &self, transaction: Transaction, ) -> Result<Transaction, Error>
Gets deep hash, signs and sets signature and id.
Sourcepub async fn sign_transaction_with_sol(
&self,
transaction: Transaction,
solana_url: Url,
sol_ar_url: Url,
from_keypair: &Keypair,
) -> Result<(Transaction, SigResponse), Error>
pub async fn sign_transaction_with_sol( &self, transaction: Transaction, solana_url: Url, sol_ar_url: Url, from_keypair: &Keypair, ) -> Result<(Transaction, SigResponse), Error>
Signs transaction with sol_ar service.
pub async fn upload_file_from_path( &self, file_path: PathBuf, log_dir: Option<PathBuf>, additional_tags: Option<Vec<Tag<Base64>>>, last_tx: Option<Base64>, price_terms: (u64, u64), ) -> Result<Status, Error>
pub async fn upload_file_from_path_with_sol( &self, file_path: PathBuf, log_dir: Option<PathBuf>, additional_tags: Option<Vec<Tag<Base64>>>, last_tx: Option<Base64>, price_terms: (u64, u64), solana_url: Url, sol_ar_url: Url, from_keypair: &Keypair, ) -> Result<Status, Error>
Sourcepub async fn upload_files_from_paths<IP, IT>(
&self,
paths_iter: IP,
log_dir: Option<PathBuf>,
tags_iter: Option<IT>,
last_tx: Option<Base64>,
price_terms: (u64, u64),
) -> Result<Vec<Status>, Error>
pub async fn upload_files_from_paths<IP, IT>( &self, paths_iter: IP, log_dir: Option<PathBuf>, tags_iter: Option<IT>, last_tx: Option<Base64>, price_terms: (u64, u64), ) -> Result<Vec<Status>, Error>
Uploads files from an iterator of paths.
Optionally logs Status objects to log_dir
, if provided and optionally adds tags to each
transaction from an iterator of tags that must be the same size as the paths iterator.
pub async fn create_log_dir(&self, parent_dir: &Path) -> Result<PathBuf, Error>
Sourcepub fn filter_statuses<S>(
&self,
all_statuses: Vec<S>,
statuses: Option<Vec<StatusCode>>,
max_confirms: Option<u64>,
) -> Result<Vec<S>, Error>where
S: Filterable,
pub fn filter_statuses<S>(
&self,
all_statuses: Vec<S>,
statuses: Option<Vec<StatusCode>>,
max_confirms: Option<u64>,
) -> Result<Vec<S>, Error>where
S: Filterable,
Filters saved Status objects by status and/or number of confirmations. Return all statuses if no status codes or maximum confirmations are provided.
If there is no raw status object and max_confirms is passed, it assumes there are zero confirms. This is designed to be used to determine whether all files have a confirmed status and to collect the paths of the files that need to be re-uploaded.
pub async fn read_bundle_status( &self, file_path: PathBuf, ) -> Result<BundleStatus, Error>
pub async fn read_bundle_statuses( &self, log_dir: &str, ) -> Result<Vec<BundleStatus>, Error>
pub async fn status_summary<IP>( &self, paths_iter: IP, log_dir: PathBuf, ) -> Result<String, Error>
pub async fn read_status( &self, file_path: PathBuf, log_dir: PathBuf, ) -> Result<Status, Error>
pub async fn read_statuses<IP>( &self, paths_iter: IP, log_dir: PathBuf, ) -> Result<Vec<Status>, Error>
pub async fn update_bundle_status( &self, file_path: PathBuf, ) -> Result<BundleStatus, Error>
pub async fn update_status( &self, file_path: PathBuf, log_dir: PathBuf, ) -> Result<Status, Error>
pub async fn update_statuses<IP>( &self, paths_iter: IP, log_dir: PathBuf, ) -> Result<Vec<Status>, Error>
Sourcepub async fn write_status(
&self,
status: Status,
log_dir: PathBuf,
file_stem: Option<String>,
) -> Result<(), Error>
pub async fn write_status( &self, status: Status, log_dir: PathBuf, file_stem: Option<String>, ) -> Result<(), Error>
Writes Status Json to log_dir
with file name based on BLAKE3 hash of status.file_path
.
This is done to facilitate checking the status of uploaded file and also means that only
one status object can exist for a given file_path
. If for some reason you wanted to record
statuses for multiple uploads of the same file you can provide a different log_dir
(or copy the
file to a different directory and upload from there).
pub fn create_data_item_from_manifest( &self, manifest: Value, ) -> Result<DataItem, Error>
pub fn create_manifest(&self, statuses: Vec<Status>) -> Result<Value, Error>
pub fn create_manifest_from_bundle_statuses( &self, statuses: Vec<BundleStatus>, ) -> Result<Value, Error>
pub async fn create_transaction_from_manifest( &self, manifest: Value, price_terms: (u64, u64), ) -> Result<Transaction, Error>
pub async fn upload_manifest_from_bundle_log_dir( &self, log_dir: &str, price_terms: (u64, u64), solana_url: Url, sol_ar_url: Url, from_keypair: Option<Keypair>, ) -> Result<String, Error>
pub async fn write_manifest( &self, manifest: Value, transaction_id: String, log_dir: PathBuf, ) -> Result<(), Error>
pub async fn read_metadata_file( &self, file_path: PathBuf, ) -> Result<Value, Error>
pub async fn update_metadata_file( &self, file_path: PathBuf, files_array: Vec<Value>, image_link: Option<String>, animation_url_link: Option<String>, ) -> Result<(), Error>
pub async fn update_metadata<IP>( &self, paths_iter: IP, manifest_path: PathBuf, image_link_file: bool, update_image_link: bool, update_animation_url_link: bool, ) -> Result<(), Error>
pub async fn write_metaplex_items<IP>( &self, paths_iter: IP, manifest_path: PathBuf, link_file: bool, ) -> Result<PathBuf, Error>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Arweave
impl RefUnwindSafe for Arweave
impl Send for Arweave
impl Sync for Arweave
impl Unpin for Arweave
impl UnwindSafe for Arweave
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> 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 more