Skip to content

Commit 3f93ed2

Browse files
committed
chore: Don't use SimpleTransport as default in BlockchainContext. Minor updates
1 parent aed1b89 commit 3f93ed2

File tree

5 files changed

+22
-12
lines changed

5 files changed

+22
-12
lines changed

core/src/contracts/blockchain_context.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::sync::Arc;
22

33
use crate::error::ExecutionError;
44
use crate::models::{ContractState, GenTimings};
5-
use crate::transport::{SimpleTransport, Transport};
5+
use crate::transport::Transport;
66
use everscale_types::abi::{Function, NamedAbiValue};
77
use everscale_types::crc::crc_16;
88
use everscale_types::models::{
@@ -56,8 +56,8 @@ impl BlockchainContext {
5656
self.clock.as_ref()
5757
}
5858

59-
pub fn config(&self) -> BlockchainConfig {
60-
self.desc.config.clone()
59+
pub fn config(&self) -> &BlockchainConfig {
60+
&self.desc.config
6161
}
6262

6363
pub fn executor_params(&self) -> &ExecutorParams {
@@ -186,17 +186,19 @@ impl BlockchainContextBuilder {
186186

187187
pub fn build(self) -> anyhow::Result<BlockchainContext> {
188188
let Some(config) = self.config else {
189-
anyhow::bail!("Blockchain config is missing");
189+
anyhow::bail!("Failed to build BlockchainContext. Config is missing");
190+
};
191+
192+
let Some(transport) = self.transport else {
193+
anyhow::bail!("Failed to build BlockchainContext. Transport is missing");
190194
};
191195

192196
Ok(BlockchainContext {
193197
desc: BlockchainDesc {
194198
config: config.clone(),
195199
executor_params: self.executor_params,
196200
},
197-
transport: self
198-
.transport
199-
.unwrap_or(Arc::new(SimpleTransport::new([], config)?)),
201+
transport,
200202
clock: self.clock,
201203
})
202204
}
@@ -274,6 +276,12 @@ impl IntoMessageBody for Cell {
274276
}
275277
}
276278

279+
impl IntoMessageBody for OwnedCellSlice {
280+
fn into_message_body(self) -> anyhow::Result<OwnedCellSlice> {
281+
Ok(self)
282+
}
283+
}
284+
277285
pub trait AsGetterMethodId {
278286
fn as_getter_method_id(&self) -> u32;
279287
}

core/src/contracts/function_ext.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl FunctionExt for Function {
6666
let GenTimings { gen_utime, gen_lt } =
6767
get_gen_timings(context.clock(), account.last_trans_lt);
6868

69-
let parsed_config = ParsedConfig::parse(context.config(), gen_utime)?;
69+
let parsed_config = ParsedConfig::parse(context.config().clone(), gen_utime)?;
7070

7171
let params = context.executor_params_mut();
7272
params.block_unixtime = gen_utime;

core/src/transport.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ impl Transport for SimpleTransport {
127127
}
128128

129129
async fn get_config(&self) -> anyhow::Result<LatestBlockchainConfig> {
130-
todo!()
130+
Ok(LatestBlockchainConfig {
131+
global_id: 0,
132+
seqno: 0,
133+
config: self.config.clone(),
134+
})
131135
}
132136

133137
async fn get_transaction(&self, _: &HashBytes) -> anyhow::Result<Option<Transaction>> {

transport/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
pub mod options;
22
pub mod rpc;
33
//pub mod ton_lite;
4-
mod tracing;
5-
mod utils;
4+
pub mod tracing;

transport/src/utils.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)