Skip to content

Commit

Permalink
fix(sdk): added signing_withdrawal_key_to_use to withdraw sdk call (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer authored Oct 10, 2024
1 parent a646669 commit 3ca878d
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use dpp::identity::accessors::IdentityGettersV0;

use dpp::identity::core_script::CoreScript;
use dpp::identity::signer::Signer;
use dpp::identity::Identity;
use dpp::identity::{Identity, IdentityPublicKey};
use dpp::prelude::UserFeeIncrease;

use crate::platform::transition::broadcast::BroadcastStateTransition;
Expand All @@ -19,13 +19,15 @@ use dpp::withdrawal::Pooling;
#[async_trait::async_trait]
pub trait WithdrawFromIdentity {
/// Function to withdraw credits from an identity. Returns the final identity balance.
/// If signing_withdrawal_key_to_use is not set, we will try to use one in the signer that is
/// available for withdrawal
async fn withdraw<S: Signer + Send>(
&self,
sdk: &Sdk,
address: Option<Address>,
amount: u64,
core_fee_per_byte: Option<u32>,
user_fee_increase: Option<UserFeeIncrease>,
signing_withdrawal_key_to_use: Option<&IdentityPublicKey>,
signer: S,
settings: Option<PutSettings>,
) -> Result<u64, Error>;
Expand All @@ -39,12 +41,15 @@ impl WithdrawFromIdentity for Identity {
address: Option<Address>,
amount: u64,
core_fee_per_byte: Option<u32>,
user_fee_increase: Option<UserFeeIncrease>,
signing_withdrawal_key_to_use: Option<&IdentityPublicKey>,
signer: S,
settings: Option<PutSettings>,
) -> Result<u64, Error> {
let new_identity_nonce = sdk.get_identity_nonce(self.id(), true, settings).await?;
let script = address.map(|address| CoreScript::new(address.script_pubkey()));
let user_fee_increase = settings
.map(|settings| settings.user_fee_increase)
.flatten();
let state_transition = IdentityCreditWithdrawalTransition::try_from_identity(
self,
script,
Expand All @@ -53,7 +58,7 @@ impl WithdrawFromIdentity for Identity {
core_fee_per_byte.unwrap_or(1),
user_fee_increase.unwrap_or_default(),
signer,
None,
signing_withdrawal_key_to_use,
PreferredKeyPurposeForSigningWithdrawal::TransferPreferred,
new_identity_nonce,
sdk.version(),
Expand Down

0 comments on commit 3ca878d

Please sign in to comment.