Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Daksh14 committed Sep 10, 2024
1 parent 2b176ec commit 636a821
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 35 deletions.
5 changes: 2 additions & 3 deletions rusk-wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
4 changes: 2 additions & 2 deletions rusk-wallet/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -539,7 +539,7 @@ impl<F: SecureWalletFile + Debug> Wallet<F> {
gas.limit,
gas.price,
chain_id,
data,
Some(data),
&Prover,
)?;

Expand Down
52 changes: 22 additions & 30 deletions wallet-core/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,36 +523,6 @@ fn withdraw_to_phoenix<R: RngCore + CryptoRng>(
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<BlsPublicKey>,
value: u64,
deposit: u64,
gas_limit: u64,
gas_price: u64,
nonce: u64,
chain_id: u8,
data: Option<impl Into<TransactionData>>,
) -> Result<Transaction, Error> {
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
///
Expand Down Expand Up @@ -640,3 +610,25 @@ pub fn moonlight_unstake<R: RngCore + CryptoRng>(
)?
.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<R: RngCore + CryptoRng>(
rng: &mut R,
receiver_sk: &BlsSecretKey,
contract: impl Into<ContractId>,
gas_payment_token: WithdrawReplayToken,
value: u64,
) -> Withdraw {
Withdraw::new(
rng,
receiver_sk,
contract.into(),
value,
WithdrawReceiver::Moonlight(BlsPublicKey::from(receiver_sk)),
gas_payment_token,
)
}

0 comments on commit 636a821

Please sign in to comment.