Skip to content

Commit

Permalink
Merge pull request #296 from primitivefinance/settings_rpc
Browse files Browse the repository at this point in the history
added default rpc
  • Loading branch information
0xJepsen authored Feb 7, 2024
2 parents eaf4557 + 3180a59 commit 79564f2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
14 changes: 12 additions & 2 deletions crates/app/src/controller/settings/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ pub struct RpcManagement {
}

impl RpcManagement {
pub fn new(storage: RPCList) -> Self {
pub fn new(mut storage: RPCList) -> Self {
if storage.chains.get("flashbot").is_none() {
storage
.chains
.insert("flashbot".to_owned(), RPCValue::default());
}
Self {
storage,
chain_packet: None,
Expand Down Expand Up @@ -118,7 +123,7 @@ impl RpcManagement {
#[allow(dead_code)]
pub fn view_rpcs(&self) -> Element<'_, Message> {
let mut content = Column::new();

tracing::debug!("Chain packet: {:?}", self.storage.list());
// List all the rpcs from the RPC storage
for chain_packet in self.storage.list() {
let mut row = Row::new().spacing(Sizes::Md);
Expand Down Expand Up @@ -273,6 +278,11 @@ impl State for RpcManagement {
}
Message::Submit => {
tracing::debug!("Submitting RPC");
let mut storage = self.storage.clone();
if let Ok(chain_packet) = self.get_chain_packet() {
let chain_packet_name = chain_packet.name.clone();
storage.chains.insert(chain_packet_name, chain_packet);
}
self.reset();
}
Message::Delete => {
Expand Down
10 changes: 10 additions & 0 deletions crates/app/src/model/rpcs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ pub struct RPCValue {
pub url: String,
}

impl Default for RPCValue {
fn default() -> Self {
Self {
chain_id: 1,
name: "Flashbots".to_string(),
url: "rpc.flashbots.net".to_string(),
}
}
}

#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct RPCList {
pub chains: HashMap<String, RPCValue>,
Expand Down

0 comments on commit 79564f2

Please sign in to comment.