From 636a8215cb76f20d5c2af5bd82286e88b8d1b382 Mon Sep 17 00:00:00 2001 From: Daksh <41485688+Daksh14@users.noreply.github.com> Date: Tue, 10 Sep 2024 12:05:49 -0400 Subject: [PATCH] Fix merge conflicts --- rusk-wallet/src/lib.rs | 5 ++-- rusk-wallet/src/wallet.rs | 4 +-- wallet-core/src/transaction.rs | 52 ++++++++++++++-------------------- 3 files changed, 26 insertions(+), 35 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 0ae24e2521..f5d7782b74 100644 --- a/wallet-core/src/transaction.rs +++ b/wallet-core/src/transaction.rs @@ -523,36 +523,6 @@ fn withdraw_to_phoenix( withdraw } -/// Generate a moonlight transaction -/// -/// # Errors -/// - the transaction-data is incorrect -#[allow(clippy::too_many_arguments)] -pub fn moonlight( - from_sk: &BlsSecretKey, - to_account: Option, - value: u64, - deposit: u64, - gas_limit: u64, - gas_price: u64, - nonce: u64, - chain_id: u8, - data: Option>, -) -> Result { - Ok(MoonlightTransaction::new( - from_sk, - to_account, - value, - deposit, - gas_limit, - gas_price, - nonce + 1, - chain_id, - data, - )? - .into()) -} - /// Stake through moonlight, the `stake_nonce` is the nonce of the stake /// which is obtained via stake info query on the chain /// @@ -640,3 +610,25 @@ pub fn moonlight_unstake( )? .into()) } + +/// 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, + ) +}