-
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.
- Loading branch information
1 parent
45c431a
commit 928ca50
Showing
15 changed files
with
133 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
mod gas_left; | ||
mod to_caller; | ||
mod to_self; | ||
|
||
pub use gas_left::GasLeft; | ||
pub use to_caller::ToCaller; | ||
pub use to_self::ToSelf; |
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,29 @@ | ||
use crate::{ | ||
api::{BlockchainApi, BlockchainApiImpl, ManagedTypeApi}, | ||
formatter::FormatBuffer, | ||
types::{ | ||
interaction::display_u64, AnnotatedValue, BigUint, ManagedAddress, ManagedBuffer, | ||
ManagedBufferCachedBuilder, TxCodeValue, TxEgldValue, TxEnv, TxFrom, TxFromSpecified, | ||
TxGasValue, TxTo, TxToSpecified, | ||
}, | ||
}; | ||
|
||
/// Indicates that all remaining gas should be sent to a transaction. | ||
/// | ||
/// Usually unwise, other than for synchronous calls, you always want to have some gas left in the contract after the call. | ||
pub struct GasLeft; | ||
|
||
impl<Env> AnnotatedValue<Env, u64> for GasLeft | ||
where | ||
Env: TxEnv, | ||
{ | ||
fn annotation(&self, env: &Env) -> ManagedBuffer<Env::Api> { | ||
display_u64(self.to_value(env)) | ||
} | ||
|
||
fn to_value(&self, env: &Env) -> u64 { | ||
Env::Api::blockchain_api_impl().get_gas_left() | ||
} | ||
} | ||
|
||
impl<Env> TxGasValue<Env> for GasLeft where Env: TxEnv {} |
6 changes: 3 additions & 3 deletions
6
...c/types/interaction/tx_to/tx_to_caller.rs → ...rc/types/interaction/markers/to_caller.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
6 changes: 3 additions & 3 deletions
6
...src/types/interaction/tx_to/tx_to_self.rs → .../src/types/interaction/markers/to_self.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
mod file_expr; | ||
mod mxsc_expr; | ||
mod num_expr; | ||
|
||
pub use file_expr::FileExpr; | ||
pub use mxsc_expr::MxscExpr; | ||
pub use num_expr::NumExpr; |
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,53 @@ | ||
use crate::{api::StaticApi, ScenarioEnvExec, ScenarioTxEnv, ScenarioTxEnvData}; | ||
use core::ptr; | ||
use multiversx_chain_scenario_format::{ | ||
interpret_trait::InterpreterContext, value_interpreter::interpret_string, | ||
}; | ||
use multiversx_sc::{ | ||
api::ManagedTypeApi, | ||
types::{ | ||
AnnotatedValue, BigUint, ManagedAddress, ManagedBuffer, TxCodeValue, TxEgldValue, TxEnv, | ||
TxFrom, TxFromSpecified, TxGasValue, TxTo, TxToSpecified, | ||
}, | ||
}; | ||
use std::path::PathBuf; | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||
pub struct NumExpr<'a>(pub &'a str); | ||
|
||
fn interpret_big_uint<Api>(s: &str) -> BigUint<Api> | ||
where | ||
Api: ManagedTypeApi, | ||
{ | ||
let bytes = interpret_string(s, &InterpreterContext::new()); | ||
BigUint::from_bytes_be(&bytes) | ||
} | ||
|
||
impl<'a, Env> AnnotatedValue<Env, BigUint<Env::Api>> for NumExpr<'a> | ||
where | ||
Env: ScenarioTxEnv, | ||
{ | ||
fn annotation(&self, _env: &Env) -> ManagedBuffer<Env::Api> { | ||
self.0.into() | ||
} | ||
|
||
fn to_value(&self, env: &Env) -> BigUint<Env::Api> { | ||
interpret_big_uint(self.0) | ||
} | ||
} | ||
|
||
impl<'a, Env> AnnotatedValue<Env, u64> for NumExpr<'a> | ||
where | ||
Env: ScenarioTxEnv, | ||
{ | ||
fn annotation(&self, _env: &Env) -> ManagedBuffer<Env::Api> { | ||
self.0.into() | ||
} | ||
|
||
fn to_value(&self, env: &Env) -> u64 { | ||
interpret_big_uint::<Env::Api>(self.0).to_u64().unwrap() | ||
} | ||
} | ||
|
||
impl<'a, Env> TxEgldValue<Env> for NumExpr<'a> where Env: ScenarioTxEnv {} | ||
impl<'a, Env> TxGasValue<Env> for NumExpr<'a> where Env: ScenarioTxEnv {} |