Skip to content

Commit d9181d8

Browse files
committed
refactor: address some PR comments
1 parent 42bcaed commit d9181d8

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

src/rpc/relay.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616
Health, IERC20, IEscrow, IntentKind, Intents, Key, KeyHash, KeyType,
1717
MULTICHAIN_NONCE_PREFIX, MerkleLeafInfo,
1818
OrchestratorContract::IntentExecuted,
19-
Quotes, SignedCall, SignedCalls, Transfer, VersionedContracts,
19+
Quotes, SignedCall, SignedCalls, SimulateExecuteResult, Transfer, VersionedContracts,
2020
rpc::{
2121
AddFaucetFundsParameters, AddFaucetFundsResponse, AddressOrNative, Asset7811,
2222
AssetFilterItem, CallKey, CallReceipt, CallStatusCode, ChainCapabilities,
@@ -528,7 +528,7 @@ impl Relay {
528528
let calculate_asset_deficits = false;
529529

530530
// Simulate the intent
531-
let (_asset_deficits, asset_diffs, sim_result) = orchestrator
531+
let SimulateExecuteResult { asset_deficits: _, asset_diffs, gas_results } = orchestrator
532532
.simulate_execute(
533533
mock_from,
534534
self.simulator(),
@@ -546,7 +546,7 @@ impl Relay {
546546
);
547547

548548
let gas_estimate = GasEstimate::from_combined_gas(
549-
sim_result.gCombined.to(),
549+
gas_results.gCombined.to(),
550550
intrinsic_gas,
551551
&self.inner.quote_config,
552552
);

src/types/orchestrator.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl<P: Provider> Orchestrator<P> {
195195
gas_validation_offset: U256,
196196
sim_mode: SimMode,
197197
calculate_asset_deficits: bool,
198-
) -> Result<(AssetDeficits, AssetDiffs, GasResults), RelayError> {
198+
) -> Result<SimulateExecuteResult, RelayError> {
199199
let result = SimulatorContract::new(
200200
simulator,
201201
self.orchestrator.provider(),
@@ -245,7 +245,7 @@ impl<P: Provider> Orchestrator<P> {
245245
asset_diffs.remove_payer_fee(payer, intent.payment_token().into(), U256::from(1));
246246
}
247247

248-
Ok((asset_deficits, asset_diffs, result.gas))
248+
Ok(SimulateExecuteResult { asset_deficits, asset_diffs, gas_results: result.gas })
249249
}
250250

251251
/// Call `Orchestrator.execute` with the provided [`Intent`].
@@ -310,3 +310,14 @@ impl IntentExecuted {
310310
self.err != ORCHESTRATOR_NO_ERROR
311311
}
312312
}
313+
314+
/// Result of [`Orchestrator::simulate_execute`] based on simulated execution.
315+
#[derive(Debug)]
316+
pub struct SimulateExecuteResult {
317+
/// Asset deficits per account and asset.
318+
pub asset_deficits: AssetDeficits,
319+
/// Asset differences per account and asset.
320+
pub asset_diffs: AssetDiffs,
321+
/// Gas usage.
322+
pub gas_results: GasResults,
323+
}

src/types/simulation_assets.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ pub struct FiatValue {
9898
pub value: f64,
9999
}
100100

101-
/// Asset deficits per account based on simulated execution logs.
101+
/// Asset deficits per account based on simulated execution traces.
102102
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
103-
pub struct AssetDeficits(pub Vec<(Address, Vec<AssetDeficit>)>);
103+
pub struct AssetDeficits(pub HashMap<Address, Vec<AssetDeficit>>);
104104

105105
impl AssetDeficits {
106106
/// Creates a new builder for asset deficits.

tests/account

Submodule account updated 69 files

0 commit comments

Comments
 (0)