From ce2a43ddd48ef38926f28cbedccb9e4c7549bca3 Mon Sep 17 00:00:00 2001 From: Daksh <41485688+Daksh14@users.noreply.github.com> Date: Tue, 10 Sep 2024 12:53:00 -0400 Subject: [PATCH] test-wallet: Adapt to new wallet-core Co-authored-by: Daksh Fix merge conflicts --- rusk-wallet/src/lib.rs | 5 ++--- rusk-wallet/src/wallet.rs | 4 ++-- wallet-core/src/transaction.rs | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/rusk-wallet/src/lib.rs b/rusk-wallet/src/lib.rs index d89b1902c1..62e43610ef 100644 --- a/rusk-wallet/src/lib.rs +++ b/rusk-wallet/src/lib.rs @@ -40,9 +40,8 @@ use execution_core::{ signatures::bls::PublicKey as AccountPublicKey, stake::StakeData, transfer::phoenix::{ - ArchivedNoteLeaf, Note, NoteLeaf, NoteOpening, - PublicKey as PhoenixPublicKey, SecretKey as PhoenixSecretKey, - ViewKey as PhoenixViewKey, + ArchivedNoteLeaf, Note, NoteOpening, PublicKey as PhoenixPublicKey, + SecretKey as PhoenixSecretKey, ViewKey as PhoenixViewKey, }, BlsScalar, }; diff --git a/rusk-wallet/src/wallet.rs b/rusk-wallet/src/wallet.rs index 775866851a..471aff2a60 100644 --- a/rusk-wallet/src/wallet.rs +++ b/rusk-wallet/src/wallet.rs @@ -36,7 +36,7 @@ use wallet_core::{ use execution_core::{ signatures::bls::{PublicKey as BlsPublicKey, SecretKey as BlsSecretKey}, - transfer::{data::TransactionData, Transaction}, + transfer::{data::ContractCall, data::TransactionData, Transaction}, }; use zeroize::Zeroize; @@ -539,7 +539,7 @@ impl Wallet { gas.limit, gas.price, chain_id, - data, + Some(data), &Prover, )?; diff --git a/wallet-core/src/transaction.rs b/wallet-core/src/transaction.rs index 6f6794e1e5..bd9001628e 100644 --- a/wallet-core/src/transaction.rs +++ b/wallet-core/src/transaction.rs @@ -544,3 +544,25 @@ fn withdraw_to_moonlight( gas_payment_token, ) } + +/// Create a [`Withdraw`] struct to be used to withdraw funds from a contract +/// into a Moonlight account. +/// +/// The gas payment can be done by either Phoenix or Moonlight by setting the +/// `gas_payment_token` accordingly. +fn withdraw_to_moonlight( + rng: &mut R, + receiver_sk: &BlsSecretKey, + contract: impl Into, + gas_payment_token: WithdrawReplayToken, + value: u64, +) -> Withdraw { + Withdraw::new( + rng, + receiver_sk, + contract.into(), + value, + WithdrawReceiver::Moonlight(BlsPublicKey::from(receiver_sk)), + gas_payment_token, + ) +}