-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
unified syntax - egld of esdt payment refs
- Loading branch information
1 parent
0bd3e86
commit ea52e2c
Showing
18 changed files
with
281 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 0 additions & 117 deletions
117
framework/base/src/types/interaction/tx_payment/tx_payment_egld_or_esdt_ref.rs
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
framework/base/src/types/interaction/tx_payment/tx_payment_egld_or_esdt_refs.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
use alloc::borrow::ToOwned; | ||
|
||
use crate::{ | ||
api::ManagedTypeApi, | ||
contract_base::SendRawWrapper, | ||
types::{ | ||
AnnotatedValue, BigUint, EgldOrEsdtTokenIdentifier, EgldOrEsdtTokenPayment, | ||
EgldOrEsdtTokenPaymentRefs, EgldOrMultiEsdtPayment, EsdtTokenPayment, EsdtTokenPaymentRefs, | ||
ManagedAddress, ManagedType, ManagedVec, MultiEsdtPayment, TxFrom, TxToSpecified, | ||
}, | ||
}; | ||
|
||
use super::{ | ||
AnnotatedEgldPayment, Egld, FullPaymentData, FunctionCall, TxEgldValue, TxEnv, TxPayment, | ||
}; | ||
|
||
impl<'a, Env> TxPayment<Env> for EgldOrEsdtTokenPaymentRefs<'a, Env::Api> | ||
where | ||
Env: TxEnv, | ||
{ | ||
fn is_no_payment(&self, _env: &Env) -> bool { | ||
self.is_empty() | ||
} | ||
|
||
fn perform_transfer_execute( | ||
self, | ||
env: &Env, | ||
to: &ManagedAddress<Env::Api>, | ||
gas_limit: u64, | ||
fc: FunctionCall<Env::Api>, | ||
) { | ||
self.map_egld_or_esdt( | ||
fc, | ||
|fc, amount| Egld(amount).perform_transfer_execute(env, to, gas_limit, fc), | ||
|fc, esdt_payment| esdt_payment.perform_transfer_execute(env, to, gas_limit, fc), | ||
) | ||
} | ||
|
||
fn with_normalized<From, To, F, R>( | ||
self, | ||
env: &Env, | ||
from: &From, | ||
to: To, | ||
fc: FunctionCall<Env::Api>, | ||
f: F, | ||
) -> R | ||
where | ||
From: TxFrom<Env>, | ||
To: TxToSpecified<Env>, | ||
F: FnOnce(&ManagedAddress<Env::Api>, &BigUint<Env::Api>, &FunctionCall<Env::Api>) -> R, | ||
{ | ||
self.map_egld_or_esdt( | ||
(to, fc, f), | ||
|(to, fc, f), amount| Egld(amount).with_normalized(env, from, to, fc, f), | ||
|(to, fc, f), esdt_payment| esdt_payment.with_normalized(env, from, to, fc, f), | ||
) | ||
} | ||
|
||
fn into_full_payment_data(self, env: &Env) -> FullPaymentData<Env::Api> { | ||
self.map_egld_or_esdt( | ||
(), | ||
|(), amount| TxPayment::<Env>::into_full_payment_data(Egld(amount), env), | ||
|(), esdt_payment| TxPayment::<Env>::into_full_payment_data(esdt_payment, env), | ||
) | ||
} | ||
} |
Oops, something went wrong.