-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from primitivefinance/colin/cleanup
Colin/cleanup
- Loading branch information
Showing
6 changed files
with
107 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,36 @@ | ||
#![warn(missing_docs)] | ||
//! The data that describes agents that live in a `SimulationEnvironment`. | ||
//! All agents must implement the `Agent` trait. | ||
|
||
use bytes::Bytes; | ||
use revm::primitives::{ExecutionResult, Log, TxEnv, B160, U256}; | ||
|
||
use crate::environment::{IsDeployed, SimulationContract}; | ||
|
||
// use crate::environment::SimulationEnvironment; | ||
|
||
/// Describes the gas settings for a transaction. | ||
pub struct TransactSettings { | ||
/// Gas limit for the transaction for a simulation. | ||
pub gas_limit: u64, | ||
/// Gas limit for the transaction for a simulation. | ||
pub gas_price: U256, | ||
pub value: U256, | ||
} | ||
|
||
/// Basic traits that every `Agent` must implement in order to properly interact with an EVM. | ||
pub trait Agent { | ||
/// Used to allow agentws to make a generic call a specific smart contract. | ||
fn call_contract( | ||
&mut self, | ||
contract: &SimulationContract<IsDeployed>, | ||
call_data: Bytes, | ||
value: U256, | ||
) -> ExecutionResult; | ||
/// A constructor to build a `TxEnv` for an agent (uses agent data like `address` and `TransactSettings`). | ||
fn build_call_transaction( | ||
&self, | ||
receiver_address: B160, | ||
call_data: Bytes, | ||
value: U256, | ||
) -> TxEnv; | ||
fn read_logs(&mut self) -> Vec<Log>; // TODO: Not sure this needs to be mutable self | ||
|
||
// TODO: Should agents be labeled as `active` or `inactive` similarly to `IsDeployed` and `NotDeployed`? | ||
// TODO: Not sure `read_logs` needs to be mutable self. | ||
/// Provides the ability to read event logs from the simulation's EVM. | ||
fn read_logs(&mut self) -> Vec<Log>; | ||
} |
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
Oops, something went wrong.