mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-07-14 01:39:58 +00:00
fix(wallet): errors fixed, metric updates are now interiorly mutable
This commit is contained in:
parent
675e845237
commit
daabe7f29e
@ -23,7 +23,7 @@ use wallet::{AccountIdentity, WalletCore};
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// Initialize wallet
|
||||
let mut wallet_core = WalletCore::from_env().await.unwrap();
|
||||
let wallet_core = WalletCore::from_env().await.unwrap();
|
||||
|
||||
// Parse arguments
|
||||
// First argument is the path to the program binary
|
||||
|
||||
@ -26,7 +26,7 @@ use wallet::{AccountIdentity, WalletCore};
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// Initialize wallet
|
||||
let mut wallet_core = WalletCore::from_env().await.unwrap();
|
||||
let wallet_core = WalletCore::from_env().await.unwrap();
|
||||
|
||||
// Parse arguments
|
||||
// First argument is the path to the simple_tail_call program binary
|
||||
|
||||
@ -29,7 +29,7 @@ use wallet::WalletCore;
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// Initialize wallet
|
||||
let mut wallet_core = WalletCore::from_env().await.unwrap();
|
||||
let wallet_core = WalletCore::from_env().await.unwrap();
|
||||
|
||||
// Parse arguments
|
||||
// First argument is the path to the program binary
|
||||
|
||||
@ -66,7 +66,7 @@ async fn main() {
|
||||
let program = Program::new(bytecode.into()).unwrap();
|
||||
|
||||
// Initialize wallet
|
||||
let mut wallet_core = WalletCore::from_env().await.unwrap();
|
||||
let wallet_core = WalletCore::from_env().await.unwrap();
|
||||
|
||||
match cli.command {
|
||||
Command::WritePublic {
|
||||
|
||||
@ -1794,7 +1794,7 @@ fn test_wallet_ffi_transfer_generic_private() -> Result<()> {
|
||||
|
||||
#[test]
|
||||
fn test_wallet_ffi_vault_balance_and_claim_public() -> Result<()> {
|
||||
let mut ctx = BlockingTestContext::new()?;
|
||||
let ctx = BlockingTestContext::new()?;
|
||||
let home = tempfile::tempdir()?;
|
||||
let FfiCreateWalletOutput {
|
||||
wallet: wallet_ffi_handle,
|
||||
@ -1808,7 +1808,7 @@ fn test_wallet_ffi_vault_balance_and_claim_public() -> Result<()> {
|
||||
|
||||
// Fund the owner's vault, simulating an L1 bridge deposit.
|
||||
ctx.block_on(|ctx| async move {
|
||||
Vault(ctx.wallet_mut())
|
||||
Vault(ctx.wallet())
|
||||
.send_transfer(sender, owner, amount)
|
||||
.await
|
||||
})
|
||||
@ -1894,7 +1894,7 @@ fn test_wallet_ffi_vault_balance_and_claim_private() -> Result<()> {
|
||||
// Fund the owner's vault. Real deposits always land via a public transfer (the bridge
|
||||
// program crediting the vault PDA), regardless of whether the owner is private.
|
||||
ctx.block_on(|ctx| async move {
|
||||
Vault(ctx.wallet_mut())
|
||||
Vault(ctx.wallet())
|
||||
.send_transfer(sender, owner, amount)
|
||||
.await
|
||||
})
|
||||
|
||||
@ -323,7 +323,7 @@ pub unsafe extern "C" fn wallet_ffi_get_balance(
|
||||
return WalletFfiError::NullPointer;
|
||||
}
|
||||
|
||||
let mut wallet = match wrapper.core.lock() {
|
||||
let wallet = match wrapper.core.lock() {
|
||||
Ok(w) => w,
|
||||
Err(e) => {
|
||||
print_error(format!("Failed to lock wallet: {e}"));
|
||||
@ -389,7 +389,7 @@ pub unsafe extern "C" fn wallet_ffi_get_account_public(
|
||||
return WalletFfiError::NullPointer;
|
||||
}
|
||||
|
||||
let mut wallet = match wrapper.core.lock() {
|
||||
let wallet = match wrapper.core.lock() {
|
||||
Ok(w) => w,
|
||||
Err(e) => {
|
||||
print_error(format!("Failed to lock wallet: {e}"));
|
||||
|
||||
@ -55,7 +55,7 @@ pub unsafe extern "C" fn wallet_ffi_bridge_withdraw(
|
||||
return WalletFfiError::NullPointer;
|
||||
}
|
||||
|
||||
let mut wallet = match wrapper.core.lock() {
|
||||
let wallet = match wrapper.core.lock() {
|
||||
Ok(w) => w,
|
||||
Err(e) => {
|
||||
print_error(format!("Failed to lock wallet: {e}"));
|
||||
@ -66,7 +66,7 @@ pub unsafe extern "C" fn wallet_ffi_bridge_withdraw(
|
||||
let from_id = AccountId::new(unsafe { (*from).data });
|
||||
let bedrock_account_pk = unsafe { (*bedrock_account_pk).data };
|
||||
|
||||
let mut bridge = Bridge(&mut wallet);
|
||||
let bridge = Bridge(&wallet);
|
||||
|
||||
match block_on(bridge.send_withdraw(from_id, amount, bedrock_account_pk)) {
|
||||
Ok(tx_hash) => {
|
||||
|
||||
@ -237,7 +237,7 @@ pub unsafe extern "C" fn wallet_ffi_send_generic_public_transaction(
|
||||
return WalletFfiError::NullPointer;
|
||||
}
|
||||
|
||||
let mut wallet = match wrapper.core.lock() {
|
||||
let wallet = match wrapper.core.lock() {
|
||||
Ok(w) => w,
|
||||
Err(e) => {
|
||||
print_error(format!("Failed to lock wallet: {e}"));
|
||||
@ -329,7 +329,7 @@ pub unsafe extern "C" fn wallet_ffi_send_generic_private_transaction(
|
||||
return WalletFfiError::NullPointer;
|
||||
}
|
||||
|
||||
let mut wallet = match wrapper.core.lock() {
|
||||
let wallet = match wrapper.core.lock() {
|
||||
Ok(w) => w,
|
||||
Err(e) => {
|
||||
print_error(format!("Failed to lock wallet: {e}"));
|
||||
|
||||
@ -60,7 +60,7 @@ pub unsafe extern "C" fn wallet_ffi_claim_pinata(
|
||||
return WalletFfiError::NullPointer;
|
||||
}
|
||||
|
||||
let mut wallet = match wrapper.core.lock() {
|
||||
let wallet = match wrapper.core.lock() {
|
||||
Ok(w) => w,
|
||||
Err(e) => {
|
||||
print_error(format!("Failed to lock wallet: {e}"));
|
||||
@ -72,7 +72,7 @@ pub unsafe extern "C" fn wallet_ffi_claim_pinata(
|
||||
let winner_id = AccountId::new(unsafe { (*winner_account_id).data });
|
||||
let solution = u128::from_le_bytes(unsafe { *solution });
|
||||
|
||||
let mut pinata = Pinata(&mut wallet);
|
||||
let pinata = Pinata(&wallet);
|
||||
|
||||
match block_on(pinata.claim(pinata_id, winner_id, solution)) {
|
||||
Ok(tx_hash) => {
|
||||
@ -155,7 +155,7 @@ pub unsafe extern "C" fn wallet_ffi_claim_pinata_private_owned_already_initializ
|
||||
return WalletFfiError::NullPointer;
|
||||
}
|
||||
|
||||
let mut wallet = match wrapper.core.lock() {
|
||||
let wallet = match wrapper.core.lock() {
|
||||
Ok(w) => w,
|
||||
Err(e) => {
|
||||
print_error(format!("Failed to lock wallet: {e}"));
|
||||
@ -174,7 +174,7 @@ pub unsafe extern "C" fn wallet_ffi_claim_pinata_private_owned_already_initializ
|
||||
};
|
||||
let proof: MembershipProof = (winner_proof_index, siblings);
|
||||
|
||||
let mut pinata = Pinata(&mut wallet);
|
||||
let pinata = Pinata(&wallet);
|
||||
|
||||
match block_on(
|
||||
pinata
|
||||
@ -250,7 +250,7 @@ pub unsafe extern "C" fn wallet_ffi_claim_pinata_private_owned_not_initialized(
|
||||
return WalletFfiError::NullPointer;
|
||||
}
|
||||
|
||||
let mut wallet = match wrapper.core.lock() {
|
||||
let wallet = match wrapper.core.lock() {
|
||||
Ok(w) => w,
|
||||
Err(e) => {
|
||||
print_error(format!("Failed to lock wallet: {e}"));
|
||||
@ -262,7 +262,7 @@ pub unsafe extern "C" fn wallet_ffi_claim_pinata_private_owned_not_initialized(
|
||||
let winner_id = AccountId::new(unsafe { (*winner_account_id).data });
|
||||
let solution = u128::from_le_bytes(unsafe { *solution });
|
||||
|
||||
let mut pinata = Pinata(&mut wallet);
|
||||
let pinata = Pinata(&wallet);
|
||||
|
||||
match block_on(pinata.claim_private_owned_account(pinata_id, winner_id, solution)) {
|
||||
Ok((tx_hash, _shared_key)) => {
|
||||
|
||||
@ -46,7 +46,7 @@ pub unsafe extern "C" fn wallet_ffi_program_deployment(
|
||||
return WalletFfiError::NullPointer;
|
||||
}
|
||||
|
||||
let mut wallet = match wrapper.core.lock() {
|
||||
let wallet = match wrapper.core.lock() {
|
||||
Ok(w) => w,
|
||||
Err(e) => {
|
||||
print_error(format!("Failed to lock wallet: {e}"));
|
||||
|
||||
@ -126,7 +126,7 @@ pub unsafe extern "C" fn wallet_ffi_get_current_block_height(
|
||||
return WalletFfiError::NullPointer;
|
||||
}
|
||||
|
||||
let mut wallet = match wrapper.core.lock() {
|
||||
let wallet = match wrapper.core.lock() {
|
||||
Ok(w) => w,
|
||||
Err(e) => {
|
||||
print_error(format!("Failed to lock wallet: {e}"));
|
||||
|
||||
@ -72,7 +72,7 @@ pub unsafe extern "C" fn wallet_ffi_transfer_public(
|
||||
return WalletFfiError::NullPointer;
|
||||
}
|
||||
|
||||
let mut wallet = match wrapper.core.lock() {
|
||||
let wallet = match wrapper.core.lock() {
|
||||
Ok(w) => w,
|
||||
Err(e) => {
|
||||
print_error(format!("Failed to lock wallet: {e}"));
|
||||
@ -84,7 +84,7 @@ pub unsafe extern "C" fn wallet_ffi_transfer_public(
|
||||
let to_id = AccountId::new(unsafe { (*to).data });
|
||||
let amount = u128::from_le_bytes(unsafe { *amount });
|
||||
|
||||
let mut transfer = NativeTokenTransfer(&mut wallet);
|
||||
let transfer = NativeTokenTransfer(&wallet);
|
||||
|
||||
match block_on(transfer.send_public_transfer(
|
||||
AccountIdentity::Public(from_id),
|
||||
@ -164,7 +164,7 @@ pub unsafe extern "C" fn wallet_ffi_transfer_shielded(
|
||||
return WalletFfiError::NullPointer;
|
||||
}
|
||||
|
||||
let mut wallet = match wrapper.core.lock() {
|
||||
let wallet = match wrapper.core.lock() {
|
||||
Ok(w) => w,
|
||||
Err(e) => {
|
||||
print_error(format!("Failed to lock wallet: {e}"));
|
||||
@ -188,7 +188,7 @@ pub unsafe extern "C" fn wallet_ffi_transfer_shielded(
|
||||
CliAccountMention::KeyPath,
|
||||
);
|
||||
|
||||
let mut transfer = NativeTokenTransfer(&mut wallet);
|
||||
let transfer = NativeTokenTransfer(&wallet);
|
||||
|
||||
match block_on(transfer.send_shielded_transfer_to_outer_account(
|
||||
from_mention.into_public_identity(from_id),
|
||||
@ -262,7 +262,7 @@ pub unsafe extern "C" fn wallet_ffi_transfer_deshielded(
|
||||
return WalletFfiError::NullPointer;
|
||||
}
|
||||
|
||||
let mut wallet = match wrapper.core.lock() {
|
||||
let wallet = match wrapper.core.lock() {
|
||||
Ok(w) => w,
|
||||
Err(e) => {
|
||||
print_error(format!("Failed to lock wallet: {e}"));
|
||||
@ -273,7 +273,7 @@ pub unsafe extern "C" fn wallet_ffi_transfer_deshielded(
|
||||
let from_id = AccountId::new(unsafe { (*from).data });
|
||||
let to_id = AccountId::new(unsafe { (*to).data });
|
||||
let amount = u128::from_le_bytes(unsafe { *amount });
|
||||
let mut transfer = NativeTokenTransfer(&mut wallet);
|
||||
let transfer = NativeTokenTransfer(&wallet);
|
||||
|
||||
match block_on(transfer.send_deshielded_transfer(from_id, to_id, amount)) {
|
||||
Ok((tx_hash, _shared_key)) => {
|
||||
@ -348,7 +348,7 @@ pub unsafe extern "C" fn wallet_ffi_transfer_private(
|
||||
return WalletFfiError::NullPointer;
|
||||
}
|
||||
|
||||
let mut wallet = match wrapper.core.lock() {
|
||||
let wallet = match wrapper.core.lock() {
|
||||
Ok(w) => w,
|
||||
Err(e) => {
|
||||
print_error(format!("Failed to lock wallet: {e}"));
|
||||
@ -367,7 +367,7 @@ pub unsafe extern "C" fn wallet_ffi_transfer_private(
|
||||
};
|
||||
let to_identifier = u128::from_le_bytes(unsafe { (*to_identifier).data });
|
||||
let amount = u128::from_le_bytes(unsafe { *amount });
|
||||
let mut transfer = NativeTokenTransfer(&mut wallet);
|
||||
let transfer = NativeTokenTransfer(&wallet);
|
||||
|
||||
match block_on(transfer.send_private_transfer_to_outer_account(
|
||||
from_id,
|
||||
@ -445,7 +445,7 @@ pub unsafe extern "C" fn wallet_ffi_transfer_shielded_owned(
|
||||
return WalletFfiError::NullPointer;
|
||||
}
|
||||
|
||||
let mut wallet = match wrapper.core.lock() {
|
||||
let wallet = match wrapper.core.lock() {
|
||||
Ok(w) => w,
|
||||
Err(e) => {
|
||||
print_error(format!("Failed to lock wallet: {e}"));
|
||||
@ -461,7 +461,7 @@ pub unsafe extern "C" fn wallet_ffi_transfer_shielded_owned(
|
||||
CliAccountMention::KeyPath,
|
||||
);
|
||||
|
||||
let mut transfer = NativeTokenTransfer(&mut wallet);
|
||||
let transfer = NativeTokenTransfer(&wallet);
|
||||
|
||||
match block_on(transfer.send_shielded_transfer(
|
||||
from_mention.into_public_identity(from_id),
|
||||
@ -536,7 +536,7 @@ pub unsafe extern "C" fn wallet_ffi_transfer_private_owned(
|
||||
return WalletFfiError::NullPointer;
|
||||
}
|
||||
|
||||
let mut wallet = match wrapper.core.lock() {
|
||||
let wallet = match wrapper.core.lock() {
|
||||
Ok(w) => w,
|
||||
Err(e) => {
|
||||
print_error(format!("Failed to lock wallet: {e}"));
|
||||
@ -547,7 +547,7 @@ pub unsafe extern "C" fn wallet_ffi_transfer_private_owned(
|
||||
let from_id = AccountId::new(unsafe { (*from).data });
|
||||
let to_id = AccountId::new(unsafe { (*to).data });
|
||||
let amount = u128::from_le_bytes(unsafe { *amount });
|
||||
let mut transfer = NativeTokenTransfer(&mut wallet);
|
||||
let transfer = NativeTokenTransfer(&wallet);
|
||||
|
||||
match block_on(transfer.send_private_transfer_to_owned_account(from_id, to_id, amount)) {
|
||||
Ok((tx_hash, _shared_keys)) => {
|
||||
@ -608,7 +608,7 @@ pub unsafe extern "C" fn wallet_ffi_register_public_account(
|
||||
return WalletFfiError::NullPointer;
|
||||
}
|
||||
|
||||
let mut wallet = match wrapper.core.lock() {
|
||||
let wallet = match wrapper.core.lock() {
|
||||
Ok(w) => w,
|
||||
Err(e) => {
|
||||
print_error(format!("Failed to lock wallet: {e}"));
|
||||
@ -618,7 +618,7 @@ pub unsafe extern "C" fn wallet_ffi_register_public_account(
|
||||
|
||||
let account_id = AccountId::new(unsafe { (*account_id).data });
|
||||
|
||||
let mut transfer = NativeTokenTransfer(&mut wallet);
|
||||
let transfer = NativeTokenTransfer(&wallet);
|
||||
|
||||
match block_on(transfer.register_account(AccountIdentity::Public(account_id))) {
|
||||
Ok(tx_hash) => {
|
||||
@ -679,7 +679,7 @@ pub unsafe extern "C" fn wallet_ffi_register_private_account(
|
||||
return WalletFfiError::NullPointer;
|
||||
}
|
||||
|
||||
let mut wallet = match wrapper.core.lock() {
|
||||
let wallet = match wrapper.core.lock() {
|
||||
Ok(w) => w,
|
||||
Err(e) => {
|
||||
print_error(format!("Failed to lock wallet: {e}"));
|
||||
@ -688,7 +688,7 @@ pub unsafe extern "C" fn wallet_ffi_register_private_account(
|
||||
};
|
||||
|
||||
let account_id = AccountId::new(unsafe { (*account_id).data });
|
||||
let mut transfer = NativeTokenTransfer(&mut wallet);
|
||||
let transfer = NativeTokenTransfer(&wallet);
|
||||
|
||||
match block_on(transfer.register_account_private(account_id)) {
|
||||
Ok((tx_hash, _secret)) => {
|
||||
|
||||
@ -48,7 +48,7 @@ pub unsafe extern "C" fn wallet_ffi_get_vault_balance(
|
||||
return WalletFfiError::NullPointer;
|
||||
}
|
||||
|
||||
let mut wallet = match wrapper.core.lock() {
|
||||
let wallet = match wrapper.core.lock() {
|
||||
Ok(w) => w,
|
||||
Err(e) => {
|
||||
print_error(format!("Failed to lock wallet: {e}"));
|
||||
|
||||
@ -192,7 +192,7 @@ pub struct AccountManager {
|
||||
|
||||
impl AccountManager {
|
||||
pub async fn new(
|
||||
wallet: &mut WalletCore,
|
||||
wallet: &WalletCore,
|
||||
accounts: Vec<AccountIdentity>,
|
||||
) -> Result<Self, ExecutionFailureKind> {
|
||||
let mut states = Vec::with_capacity(accounts.len());
|
||||
@ -541,7 +541,7 @@ struct AccountPreparedData {
|
||||
}
|
||||
|
||||
async fn private_key_tree_acc_preparation(
|
||||
wallet: &mut WalletCore,
|
||||
wallet: &WalletCore,
|
||||
account_id: AccountId,
|
||||
is_pda: bool,
|
||||
) -> Result<AccountPreparedData, ExecutionFailureKind> {
|
||||
@ -581,7 +581,7 @@ async fn private_key_tree_acc_preparation(
|
||||
}
|
||||
|
||||
async fn private_shared_acc_preparation(
|
||||
wallet: &mut WalletCore,
|
||||
wallet: &WalletCore,
|
||||
account_id: AccountId,
|
||||
nsk: NullifierSecretKey,
|
||||
npk: NullifierPublicKey,
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
use std::{
|
||||
collections::{BTreeMap, HashMap},
|
||||
path::PathBuf,
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
pub use account_manager::AccountIdentity;
|
||||
@ -31,7 +32,7 @@ use lee_core::{
|
||||
use log::info;
|
||||
use sequencer_service_rpc::{RpcClient as _, SequencerClient};
|
||||
use storage::Storage;
|
||||
use tokio::io::AsyncWriteExt as _;
|
||||
use tokio::{io::AsyncWriteExt as _, sync::RwLock};
|
||||
use url::Url;
|
||||
|
||||
use crate::{
|
||||
@ -103,7 +104,10 @@ pub struct WalletCore {
|
||||
|
||||
metrics_path: PathBuf,
|
||||
metrics: HashMap<Url, Metrics>,
|
||||
metric_updates: Vec<MetricsUpdate>,
|
||||
/// Wrapping metric updates in Arc<RwLock> to not break intefaces too much.
|
||||
///
|
||||
/// It is assumed, that wallet methods can be accesed via immutable reference
|
||||
metric_updates: Arc<RwLock<Vec<MetricsUpdate>>>,
|
||||
|
||||
multi_sequencer_client: MultiSequencerClient,
|
||||
}
|
||||
@ -188,7 +192,7 @@ impl WalletCore {
|
||||
storage,
|
||||
metrics_path,
|
||||
metrics,
|
||||
metric_updates: vec![],
|
||||
metric_updates: Arc::new(RwLock::new(vec![])),
|
||||
multi_sequencer_client,
|
||||
})
|
||||
}
|
||||
@ -251,14 +255,20 @@ impl WalletCore {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn store_metrics(&self) -> Result<()> {
|
||||
save_metrics_at_path_with_updates(
|
||||
self.metrics.clone(),
|
||||
&self.multi_sequencer_client.leader_url,
|
||||
&self.metric_updates,
|
||||
&self.storage_path,
|
||||
)
|
||||
.with_context(|| format!("Failed to store metrics at {}", self.storage_path.display()))?;
|
||||
pub async fn store_metrics(&self) -> Result<()> {
|
||||
{
|
||||
let metric_updates = self.metric_updates.read().await;
|
||||
save_metrics_at_path_with_updates(
|
||||
self.metrics.clone(),
|
||||
&self.multi_sequencer_client.leader_url,
|
||||
&metric_updates,
|
||||
&self.storage_path,
|
||||
)
|
||||
.await
|
||||
.with_context(|| {
|
||||
format!("Failed to store metrics at {}", self.storage_path.display())
|
||||
})?;
|
||||
}
|
||||
|
||||
println!("Stored metrics at {}", self.metrics_path.display());
|
||||
|
||||
@ -478,28 +488,34 @@ impl WalletCore {
|
||||
}
|
||||
|
||||
/// Get account balance.
|
||||
pub async fn get_account_balance(&mut self, acc: AccountId) -> Result<u128> {
|
||||
pub async fn get_account_balance(&self, acc: AccountId) -> Result<u128> {
|
||||
let call_f = async |client: &SequencerClient| client.get_account_balance(acc).await;
|
||||
|
||||
let (call_res, metrics_update) = self.multi_sequencer_client.metered_call(call_f).await;
|
||||
|
||||
self.metric_updates.push(metrics_update);
|
||||
{
|
||||
let mut metric_updates_guard = self.metric_updates.write().await;
|
||||
metric_updates_guard.push(metrics_update);
|
||||
}
|
||||
|
||||
Ok(call_res?)
|
||||
}
|
||||
|
||||
/// Get accounts nonces.
|
||||
pub async fn get_accounts_nonces(&mut self, accs: Vec<AccountId>) -> Result<Vec<Nonce>> {
|
||||
pub async fn get_accounts_nonces(&self, accs: Vec<AccountId>) -> Result<Vec<Nonce>> {
|
||||
let call_f = async |client: &SequencerClient| client.get_accounts_nonces(accs).await;
|
||||
|
||||
let (call_res, metrics_update) = self.multi_sequencer_client.metered_call(call_f).await;
|
||||
|
||||
self.metric_updates.push(metrics_update);
|
||||
{
|
||||
let mut metric_updates_guard = self.metric_updates.write().await;
|
||||
metric_updates_guard.push(metrics_update);
|
||||
}
|
||||
|
||||
Ok(call_res?)
|
||||
}
|
||||
|
||||
pub async fn get_account(&mut self, account_id: AccountIdWithPrivacy) -> Result<Account> {
|
||||
pub async fn get_account(&self, account_id: AccountIdWithPrivacy) -> Result<Account> {
|
||||
match account_id {
|
||||
AccountIdWithPrivacy::Public(acc_id) => self.get_account_public(acc_id).await,
|
||||
AccountIdWithPrivacy::Private(acc_id) => {
|
||||
@ -512,46 +528,58 @@ impl WalletCore {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_last_block_id(&mut self) -> Result<u64> {
|
||||
pub async fn get_last_block_id(&self) -> Result<u64> {
|
||||
let call_f = async |client: &SequencerClient| client.get_last_block_id().await;
|
||||
|
||||
let (call_res, metrics_update) = self.multi_sequencer_client.metered_call(call_f).await;
|
||||
|
||||
self.metric_updates.push(metrics_update);
|
||||
{
|
||||
let mut metric_updates_guard = self.metric_updates.write().await;
|
||||
metric_updates_guard.push(metrics_update);
|
||||
}
|
||||
|
||||
Ok(call_res?)
|
||||
}
|
||||
|
||||
pub async fn get_block(&mut self, block_id: u64) -> Result<Option<Block>> {
|
||||
pub async fn get_block(&self, block_id: u64) -> Result<Option<Block>> {
|
||||
let call_f = async |client: &SequencerClient| client.get_block(block_id).await;
|
||||
|
||||
let (call_res, metrics_update) = self.multi_sequencer_client.metered_call(call_f).await;
|
||||
|
||||
self.metric_updates.push(metrics_update);
|
||||
{
|
||||
let mut metric_updates_guard = self.metric_updates.write().await;
|
||||
metric_updates_guard.push(metrics_update);
|
||||
}
|
||||
|
||||
Ok(call_res?)
|
||||
}
|
||||
|
||||
pub async fn get_transaction(
|
||||
&mut self,
|
||||
&self,
|
||||
hash: HashType,
|
||||
) -> Result<Option<(LeeTransaction, BlockId)>> {
|
||||
let call_f = async |client: &SequencerClient| client.get_transaction(hash).await;
|
||||
|
||||
let (call_res, metrics_update) = self.multi_sequencer_client.metered_call(call_f).await;
|
||||
|
||||
self.metric_updates.push(metrics_update);
|
||||
{
|
||||
let mut metric_updates_guard = self.metric_updates.write().await;
|
||||
metric_updates_guard.push(metrics_update);
|
||||
}
|
||||
|
||||
Ok(call_res?)
|
||||
}
|
||||
|
||||
/// Get public account.
|
||||
pub async fn get_account_public(&mut self, account_id: AccountId) -> Result<Account> {
|
||||
pub async fn get_account_public(&self, account_id: AccountId) -> Result<Account> {
|
||||
let call_f = async |client: &SequencerClient| client.get_account(account_id).await;
|
||||
|
||||
let (call_res, metrics_update) = self.multi_sequencer_client.metered_call(call_f).await;
|
||||
|
||||
self.metric_updates.push(metrics_update);
|
||||
{
|
||||
let mut metric_updates_guard = self.metric_updates.write().await;
|
||||
metric_updates_guard.push(metrics_update);
|
||||
}
|
||||
|
||||
Ok(call_res?)
|
||||
}
|
||||
@ -588,12 +616,15 @@ impl WalletCore {
|
||||
Some(Commitment::new(&account_id, account))
|
||||
}
|
||||
|
||||
pub async fn get_program_ids(&mut self) -> Result<BTreeMap<String, ProgramId>> {
|
||||
pub async fn get_program_ids(&self) -> Result<BTreeMap<String, ProgramId>> {
|
||||
let call_f = async |client: &SequencerClient| client.get_program_ids().await;
|
||||
|
||||
let (call_res, metrics_update) = self.multi_sequencer_client.metered_call(call_f).await;
|
||||
|
||||
self.metric_updates.push(metrics_update);
|
||||
{
|
||||
let mut metric_updates_guard = self.metric_updates.write().await;
|
||||
metric_updates_guard.push(metrics_update);
|
||||
}
|
||||
|
||||
Ok(call_res?)
|
||||
}
|
||||
@ -607,7 +638,7 @@ impl WalletCore {
|
||||
}
|
||||
|
||||
pub async fn check_private_account_initialized(
|
||||
&mut self,
|
||||
&self,
|
||||
account_id: AccountId,
|
||||
) -> Result<Option<MembershipProof>> {
|
||||
if let Some(acc_comm) = self.get_private_account_commitment(account_id) {
|
||||
@ -616,7 +647,10 @@ impl WalletCore {
|
||||
|
||||
let (call_res, metrics_update) = self.multi_sequencer_client.metered_call(call_f).await;
|
||||
|
||||
self.metric_updates.push(metrics_update);
|
||||
{
|
||||
let mut metric_updates_guard = self.metric_updates.write().await;
|
||||
metric_updates_guard.push(metrics_update);
|
||||
}
|
||||
|
||||
call_res.map_err(Into::into)
|
||||
} else {
|
||||
@ -624,14 +658,17 @@ impl WalletCore {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_commitment_root(&mut self) -> Result<Option<CommitmentSetDigest>> {
|
||||
pub async fn get_commitment_root(&self) -> Result<Option<CommitmentSetDigest>> {
|
||||
let call_f = async |client: &SequencerClient| {
|
||||
client.get_proof_for_commitment(DUMMY_COMMITMENT).await
|
||||
};
|
||||
|
||||
let (proof, metrics_update) = self.multi_sequencer_client.metered_call(call_f).await;
|
||||
|
||||
self.metric_updates.push(metrics_update);
|
||||
{
|
||||
let mut metric_updates_guard = self.metric_updates.write().await;
|
||||
metric_updates_guard.push(metrics_update);
|
||||
}
|
||||
Ok(proof?.map(|p| compute_digest_for_path(&DUMMY_COMMITMENT, &p)))
|
||||
}
|
||||
|
||||
@ -703,7 +740,7 @@ impl WalletCore {
|
||||
}
|
||||
|
||||
pub async fn send_privacy_preserving_tx(
|
||||
&mut self,
|
||||
&self,
|
||||
accounts: Vec<AccountIdentity>,
|
||||
instruction_data: InstructionData,
|
||||
program: &ProgramWithDependencies,
|
||||
@ -715,7 +752,7 @@ impl WalletCore {
|
||||
}
|
||||
|
||||
pub async fn send_privacy_preserving_tx_with_pre_check(
|
||||
&mut self,
|
||||
&self,
|
||||
accounts: Vec<AccountIdentity>,
|
||||
instruction_data: InstructionData,
|
||||
program: &ProgramWithDependencies,
|
||||
@ -773,13 +810,16 @@ impl WalletCore {
|
||||
|
||||
let (call_res, metrics_update) = self.multi_sequencer_client.metered_call(call_f).await;
|
||||
|
||||
self.metric_updates.push(metrics_update);
|
||||
{
|
||||
let mut metric_updates_guard = self.metric_updates.write().await;
|
||||
metric_updates_guard.push(metrics_update);
|
||||
}
|
||||
|
||||
Ok((call_res?, shared_secrets))
|
||||
}
|
||||
|
||||
pub async fn send_pub_tx(
|
||||
&mut self,
|
||||
&self,
|
||||
accounts: Vec<AccountIdentity>,
|
||||
instruction_data: InstructionData,
|
||||
program_id: ProgramId,
|
||||
@ -789,7 +829,7 @@ impl WalletCore {
|
||||
}
|
||||
|
||||
pub async fn send_pub_tx_with_pre_check(
|
||||
&mut self,
|
||||
&self,
|
||||
accounts: Vec<AccountIdentity>,
|
||||
instruction_data: InstructionData,
|
||||
program_id: ProgramId,
|
||||
@ -840,15 +880,15 @@ impl WalletCore {
|
||||
|
||||
let (call_res, metrics_update) = self.multi_sequencer_client.metered_call(call_f).await;
|
||||
|
||||
self.metric_updates.push(metrics_update);
|
||||
{
|
||||
let mut metric_updates_guard = self.metric_updates.write().await;
|
||||
metric_updates_guard.push(metrics_update);
|
||||
}
|
||||
|
||||
Ok(call_res?)
|
||||
}
|
||||
|
||||
pub async fn send_program_deployment_transaction(
|
||||
&mut self,
|
||||
bytecode: Vec<u8>,
|
||||
) -> Result<HashType> {
|
||||
pub async fn send_program_deployment_transaction(&self, bytecode: Vec<u8>) -> Result<HashType> {
|
||||
let message = lee::program_deployment_transaction::Message::new(bytecode);
|
||||
let transaction = ProgramDeploymentTransaction::new(message);
|
||||
|
||||
@ -860,7 +900,10 @@ impl WalletCore {
|
||||
|
||||
let (call_res, metrics_update) = self.multi_sequencer_client.metered_call(call_f).await;
|
||||
|
||||
self.metric_updates.push(metrics_update);
|
||||
{
|
||||
let mut metric_updates_guard = self.metric_updates.write().await;
|
||||
metric_updates_guard.push(metrics_update);
|
||||
}
|
||||
|
||||
Ok(call_res?)
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use std::{collections::HashMap, io::Write, path::Path};
|
||||
use std::{collections::HashMap, path::Path};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use sequencer_service_rpc::{RpcClient, SequencerClient, SequencerClientBuilder};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::io::AsyncWriteExt;
|
||||
use url::Url;
|
||||
|
||||
use crate::config::SequencerConnectionData;
|
||||
@ -250,15 +251,18 @@ pub fn choose_leader(
|
||||
))
|
||||
}
|
||||
|
||||
pub fn save_metrics_at_path(
|
||||
pub async fn save_metrics_at_path(
|
||||
metrics: &HashMap<Url, Metrics>,
|
||||
path: &Path,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
let metrics_serialized = serde_json::to_vec_pretty(metrics)?;
|
||||
let mut file = std::fs::File::create(path).context("Failed to create file")?;
|
||||
let mut file = tokio::fs::File::create(path)
|
||||
.await
|
||||
.context("Failed to create file")?;
|
||||
file.write_all(&metrics_serialized)
|
||||
.await
|
||||
.context("Failed to write to file")?;
|
||||
file.sync_all().context("Failed to sync file")?;
|
||||
file.sync_all().await.context("Failed to sync file")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -378,7 +382,7 @@ pub fn update_metrics(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn save_metrics_at_path_with_updates(
|
||||
pub async fn save_metrics_at_path_with_updates(
|
||||
mut metrics: HashMap<Url, Metrics>,
|
||||
leader_url: &Url,
|
||||
metric_updates: &[MetricsUpdate],
|
||||
@ -386,7 +390,7 @@ pub fn save_metrics_at_path_with_updates(
|
||||
) -> Result<(), anyhow::Error> {
|
||||
update_metrics(&mut metrics, leader_url, metric_updates)?;
|
||||
|
||||
save_metrics_at_path(&metrics, path)
|
||||
save_metrics_at_path(&metrics, path).await
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@ -4,11 +4,11 @@ use lee::{AccountId, program::Program};
|
||||
use token_core::TokenHolding;
|
||||
|
||||
use crate::{AccountIdentity, ExecutionFailureKind, WalletCore};
|
||||
pub struct Amm<'wallet>(pub &'wallet mut WalletCore);
|
||||
pub struct Amm<'wallet>(pub &'wallet WalletCore);
|
||||
|
||||
impl Amm<'_> {
|
||||
pub async fn send_new_definition(
|
||||
&mut self,
|
||||
&self,
|
||||
user_holding_a: AccountIdentity,
|
||||
user_holding_b: AccountIdentity,
|
||||
user_holding_lp: AccountIdentity,
|
||||
@ -72,7 +72,7 @@ impl Amm<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_swap_exact_input(
|
||||
&mut self,
|
||||
&self,
|
||||
user_holding_a: AccountIdentity,
|
||||
user_holding_b: AccountIdentity,
|
||||
swap_amount_in: u128,
|
||||
@ -153,7 +153,7 @@ impl Amm<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_swap_exact_output(
|
||||
&mut self,
|
||||
&self,
|
||||
user_holding_a: AccountIdentity,
|
||||
user_holding_b: AccountIdentity,
|
||||
exact_amount_out: u128,
|
||||
@ -234,7 +234,7 @@ impl Amm<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_add_liquidity(
|
||||
&mut self,
|
||||
&self,
|
||||
user_holding_a: AccountIdentity,
|
||||
user_holding_b: AccountIdentity,
|
||||
user_holding_lp: AccountIdentity,
|
||||
@ -299,7 +299,7 @@ impl Amm<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_remove_liquidity(
|
||||
&mut self,
|
||||
&self,
|
||||
user_holding_a: AccountId,
|
||||
user_holding_b: AccountId,
|
||||
user_holding_lp: AccountIdentity,
|
||||
|
||||
@ -9,11 +9,11 @@ use lee_core::SharedSecretKey;
|
||||
|
||||
use crate::{AccountIdentity, ExecutionFailureKind, WalletCore};
|
||||
|
||||
pub struct Ata<'wallet>(pub &'wallet mut WalletCore);
|
||||
pub struct Ata<'wallet>(pub &'wallet WalletCore);
|
||||
|
||||
impl Ata<'_> {
|
||||
pub async fn send_create(
|
||||
&mut self,
|
||||
&self,
|
||||
owner: AccountIdentity,
|
||||
definition_id: AccountId,
|
||||
) -> Result<HashType, ExecutionFailureKind> {
|
||||
@ -44,7 +44,7 @@ impl Ata<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_transfer(
|
||||
&mut self,
|
||||
&self,
|
||||
owner: AccountIdentity,
|
||||
definition_id: AccountId,
|
||||
recipient_id: AccountId,
|
||||
@ -80,7 +80,7 @@ impl Ata<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_burn(
|
||||
&mut self,
|
||||
&self,
|
||||
owner: AccountIdentity,
|
||||
definition_id: AccountId,
|
||||
amount: u128,
|
||||
@ -115,7 +115,7 @@ impl Ata<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_create_private_owner(
|
||||
&mut self,
|
||||
&self,
|
||||
owner_id: AccountId,
|
||||
definition_id: AccountId,
|
||||
) -> Result<(HashType, SharedSecretKey), ExecutionFailureKind> {
|
||||
@ -147,7 +147,7 @@ impl Ata<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_transfer_private_owner(
|
||||
&mut self,
|
||||
&self,
|
||||
owner_id: AccountId,
|
||||
definition_id: AccountId,
|
||||
recipient_id: AccountId,
|
||||
@ -184,7 +184,7 @@ impl Ata<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_burn_private_owner(
|
||||
&mut self,
|
||||
&self,
|
||||
owner_id: AccountId,
|
||||
definition_id: AccountId,
|
||||
amount: u128,
|
||||
|
||||
@ -3,11 +3,11 @@ use lee::{AccountId, program::Program};
|
||||
|
||||
use crate::{AccountIdentity, ExecutionFailureKind, WalletCore};
|
||||
|
||||
pub struct Bridge<'wallet>(pub &'wallet mut WalletCore);
|
||||
pub struct Bridge<'wallet>(pub &'wallet WalletCore);
|
||||
|
||||
impl Bridge<'_> {
|
||||
pub async fn send_withdraw(
|
||||
&mut self,
|
||||
&self,
|
||||
sender_account_id: AccountId,
|
||||
amount: u64,
|
||||
bedrock_account_pk: [u8; 32],
|
||||
|
||||
@ -6,7 +6,7 @@ use crate::{AccountIdentity, ExecutionFailureKind};
|
||||
|
||||
impl NativeTokenTransfer<'_> {
|
||||
pub async fn send_deshielded_transfer(
|
||||
&mut self,
|
||||
&self,
|
||||
from: AccountId,
|
||||
to: AccountId,
|
||||
balance_to_move: u128,
|
||||
|
||||
@ -12,7 +12,7 @@ pub mod shielded;
|
||||
clippy::multiple_inherent_impl,
|
||||
reason = "impl blocks split across multiple files for organization"
|
||||
)]
|
||||
pub struct NativeTokenTransfer<'wallet>(pub &'wallet mut WalletCore);
|
||||
pub struct NativeTokenTransfer<'wallet>(pub &'wallet WalletCore);
|
||||
|
||||
fn auth_transfer_preparation(
|
||||
balance_to_move: u128,
|
||||
|
||||
@ -9,7 +9,7 @@ use crate::{AccountIdentity, ExecutionFailureKind};
|
||||
|
||||
impl NativeTokenTransfer<'_> {
|
||||
pub async fn register_account_private(
|
||||
&mut self,
|
||||
&self,
|
||||
from: AccountId,
|
||||
) -> Result<(HashType, SharedSecretKey), ExecutionFailureKind> {
|
||||
let instruction = authenticated_transfer_core::Instruction::Initialize;
|
||||
@ -34,7 +34,7 @@ impl NativeTokenTransfer<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_private_transfer_to_outer_account(
|
||||
&mut self,
|
||||
&self,
|
||||
from: AccountId,
|
||||
to_npk: NullifierPublicKey,
|
||||
to_vpk: ViewingPublicKey,
|
||||
@ -69,7 +69,7 @@ impl NativeTokenTransfer<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_private_transfer_to_owned_account(
|
||||
&mut self,
|
||||
&self,
|
||||
from: AccountId,
|
||||
to: AccountId,
|
||||
balance_to_move: u128,
|
||||
|
||||
@ -10,7 +10,7 @@ use crate::{
|
||||
|
||||
impl NativeTokenTransfer<'_> {
|
||||
pub async fn send_public_transfer(
|
||||
&mut self,
|
||||
&self,
|
||||
from: AccountIdentity,
|
||||
to: AccountIdentity,
|
||||
balance_to_move: u128,
|
||||
@ -28,7 +28,7 @@ impl NativeTokenTransfer<'_> {
|
||||
}
|
||||
|
||||
pub async fn register_account(
|
||||
&mut self,
|
||||
&self,
|
||||
account: AccountIdentity,
|
||||
) -> Result<HashType, ExecutionFailureKind> {
|
||||
let instruction_data = Program::serialize_instruction(AuthTransferInstruction::Initialize)?;
|
||||
|
||||
@ -7,7 +7,7 @@ use crate::{AccountIdentity, ExecutionFailureKind};
|
||||
|
||||
impl NativeTokenTransfer<'_> {
|
||||
pub async fn send_shielded_transfer(
|
||||
&mut self,
|
||||
&self,
|
||||
from: AccountIdentity,
|
||||
to: AccountId,
|
||||
balance_to_move: u128,
|
||||
@ -36,7 +36,7 @@ impl NativeTokenTransfer<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_shielded_transfer_to_outer_account(
|
||||
&mut self,
|
||||
&self,
|
||||
from: AccountIdentity,
|
||||
to_npk: NullifierPublicKey,
|
||||
to_vpk: ViewingPublicKey,
|
||||
|
||||
@ -4,11 +4,11 @@ use lee_core::{MembershipProof, SharedSecretKey};
|
||||
|
||||
use crate::{AccountIdentity, ExecutionFailureKind, WalletCore};
|
||||
|
||||
pub struct Pinata<'wallet>(pub &'wallet mut WalletCore);
|
||||
pub struct Pinata<'wallet>(pub &'wallet WalletCore);
|
||||
|
||||
impl Pinata<'_> {
|
||||
pub async fn claim(
|
||||
&mut self,
|
||||
&self,
|
||||
pinata_account_id: AccountId,
|
||||
winner_account_id: AccountId,
|
||||
solution: u128,
|
||||
@ -35,7 +35,7 @@ impl Pinata<'_> {
|
||||
/// The `winner_proof` parameter is accepted for API completeness; the wallet currently fetches
|
||||
/// the membership proof automatically from the chain.
|
||||
pub async fn claim_private_owned_account_already_initialized(
|
||||
&mut self,
|
||||
&self,
|
||||
pinata_account_id: AccountId,
|
||||
winner_account_id: AccountId,
|
||||
solution: u128,
|
||||
@ -46,7 +46,7 @@ impl Pinata<'_> {
|
||||
}
|
||||
|
||||
pub async fn claim_private_owned_account(
|
||||
&mut self,
|
||||
&self,
|
||||
pinata_account_id: AccountId,
|
||||
winner_account_id: AccountId,
|
||||
solution: u128,
|
||||
|
||||
@ -5,11 +5,11 @@ use token_core::Instruction;
|
||||
|
||||
use crate::{AccountIdentity, ExecutionFailureKind, WalletCore};
|
||||
|
||||
pub struct Token<'wallet>(pub &'wallet mut WalletCore);
|
||||
pub struct Token<'wallet>(pub &'wallet WalletCore);
|
||||
|
||||
impl Token<'_> {
|
||||
pub async fn send_new_definition(
|
||||
&mut self,
|
||||
&self,
|
||||
definition: AccountIdentity,
|
||||
supply: AccountIdentity,
|
||||
name: String,
|
||||
@ -29,7 +29,7 @@ impl Token<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_new_definition_private_owned_supply(
|
||||
&mut self,
|
||||
&self,
|
||||
definition_account_id: AccountId,
|
||||
supply_account_id: AccountId,
|
||||
name: String,
|
||||
@ -61,7 +61,7 @@ impl Token<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_new_definition_private_owned_definiton(
|
||||
&mut self,
|
||||
&self,
|
||||
definition_account_id: AccountId,
|
||||
supply_account_id: AccountId,
|
||||
name: String,
|
||||
@ -93,7 +93,7 @@ impl Token<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_new_definition_private_owned_definiton_and_supply(
|
||||
&mut self,
|
||||
&self,
|
||||
definition_account_id: AccountId,
|
||||
supply_account_id: AccountId,
|
||||
name: String,
|
||||
@ -126,7 +126,7 @@ impl Token<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_transfer_transaction(
|
||||
&mut self,
|
||||
&self,
|
||||
sender: AccountIdentity,
|
||||
recipient: AccountIdentity,
|
||||
amount: u128,
|
||||
@ -147,7 +147,7 @@ impl Token<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_transfer_transaction_private_owned_account(
|
||||
&mut self,
|
||||
&self,
|
||||
sender_account_id: AccountId,
|
||||
recipient_account_id: AccountId,
|
||||
amount: u128,
|
||||
@ -181,7 +181,7 @@ impl Token<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_transfer_transaction_private_foreign_account(
|
||||
&mut self,
|
||||
&self,
|
||||
sender_account_id: AccountId,
|
||||
recipient_npk: NullifierPublicKey,
|
||||
recipient_vpk: ViewingPublicKey,
|
||||
@ -219,7 +219,7 @@ impl Token<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_transfer_transaction_deshielded(
|
||||
&mut self,
|
||||
&self,
|
||||
sender_account_id: AccountId,
|
||||
recipient_account_id: AccountId,
|
||||
amount: u128,
|
||||
@ -252,7 +252,7 @@ impl Token<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_transfer_transaction_shielded_owned_account(
|
||||
&mut self,
|
||||
&self,
|
||||
sender: AccountIdentity,
|
||||
recipient_account_id: AccountId,
|
||||
amount: u128,
|
||||
@ -284,7 +284,7 @@ impl Token<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_transfer_transaction_shielded_foreign_account(
|
||||
&mut self,
|
||||
&self,
|
||||
sender: AccountIdentity,
|
||||
recipient_npk: NullifierPublicKey,
|
||||
recipient_vpk: ViewingPublicKey,
|
||||
@ -320,7 +320,7 @@ impl Token<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_burn_transaction(
|
||||
&mut self,
|
||||
&self,
|
||||
definition_account_id: AccountId,
|
||||
holder: AccountIdentity,
|
||||
amount: u128,
|
||||
@ -341,7 +341,7 @@ impl Token<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_burn_transaction_private_owned_account(
|
||||
&mut self,
|
||||
&self,
|
||||
definition_account_id: AccountId,
|
||||
holder_account_id: AccountId,
|
||||
amount: u128,
|
||||
@ -375,7 +375,7 @@ impl Token<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_burn_transaction_deshielded_owned_account(
|
||||
&mut self,
|
||||
&self,
|
||||
definition_account_id: AccountId,
|
||||
holder_account_id: AccountId,
|
||||
amount: u128,
|
||||
@ -408,7 +408,7 @@ impl Token<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_burn_transaction_shielded(
|
||||
&mut self,
|
||||
&self,
|
||||
definition_account_id: AccountId,
|
||||
holder_account_id: AccountId,
|
||||
amount: u128,
|
||||
@ -441,7 +441,7 @@ impl Token<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_mint_transaction(
|
||||
&mut self,
|
||||
&self,
|
||||
definition: AccountIdentity,
|
||||
holder: AccountIdentity,
|
||||
amount: u128,
|
||||
@ -462,7 +462,7 @@ impl Token<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_mint_transaction_private_owned_account(
|
||||
&mut self,
|
||||
&self,
|
||||
definition_account_id: AccountId,
|
||||
holder_account_id: AccountId,
|
||||
amount: u128,
|
||||
@ -496,7 +496,7 @@ impl Token<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_mint_transaction_private_foreign_account(
|
||||
&mut self,
|
||||
&self,
|
||||
definition_account_id: AccountId,
|
||||
holder_npk: NullifierPublicKey,
|
||||
holder_vpk: ViewingPublicKey,
|
||||
@ -534,7 +534,7 @@ impl Token<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_mint_transaction_deshielded(
|
||||
&mut self,
|
||||
&self,
|
||||
definition_account_id: AccountId,
|
||||
holder_account_id: AccountId,
|
||||
amount: u128,
|
||||
@ -567,7 +567,7 @@ impl Token<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_mint_transaction_shielded_owned_account(
|
||||
&mut self,
|
||||
&self,
|
||||
definition_account_id: AccountId,
|
||||
holder_account_id: AccountId,
|
||||
amount: u128,
|
||||
@ -600,7 +600,7 @@ impl Token<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_mint_transaction_shielded_foreign_account(
|
||||
&mut self,
|
||||
&self,
|
||||
definition_account_id: AccountId,
|
||||
holder_npk: NullifierPublicKey,
|
||||
holder_vpk: ViewingPublicKey,
|
||||
|
||||
@ -8,11 +8,11 @@ use lee_core::SharedSecretKey;
|
||||
|
||||
use crate::{AccountIdentity, ExecutionFailureKind, WalletCore};
|
||||
|
||||
pub struct Vault<'wallet>(pub &'wallet mut WalletCore);
|
||||
pub struct Vault<'wallet>(pub &'wallet WalletCore);
|
||||
|
||||
impl Vault<'_> {
|
||||
pub async fn send_transfer(
|
||||
&mut self,
|
||||
&self,
|
||||
sender_id: AccountId,
|
||||
recipient_id: AccountId,
|
||||
amount: u128,
|
||||
@ -41,7 +41,7 @@ impl Vault<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_transfer_private_sender(
|
||||
&mut self,
|
||||
&self,
|
||||
sender_id: AccountId,
|
||||
recipient_id: AccountId,
|
||||
amount: u128,
|
||||
@ -75,7 +75,7 @@ impl Vault<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_claim(
|
||||
&mut self,
|
||||
&self,
|
||||
owner_id: AccountId,
|
||||
amount: u128,
|
||||
) -> Result<HashType, ExecutionFailureKind> {
|
||||
@ -99,7 +99,7 @@ impl Vault<'_> {
|
||||
}
|
||||
|
||||
pub async fn send_claim_private_owner(
|
||||
&mut self,
|
||||
&self,
|
||||
owner_id: AccountId,
|
||||
amount: u128,
|
||||
) -> Result<(HashType, SharedSecretKey), ExecutionFailureKind> {
|
||||
|
||||
@ -429,11 +429,11 @@ impl BlockingTestContext {
|
||||
&self.runtime
|
||||
}
|
||||
|
||||
pub fn block_on<'ctx, F>(&'ctx mut self, f: impl FnOnce(&'ctx TestContext) -> F) -> F::Output
|
||||
pub fn block_on<'ctx, F>(&'ctx self, f: impl FnOnce(&'ctx TestContext) -> F) -> F::Output
|
||||
where
|
||||
F: std::future::Future + 'ctx,
|
||||
{
|
||||
let future = f(self.ctx_mut());
|
||||
let future = f(self.ctx());
|
||||
self.runtime.block_on(future)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user