solana: add URL to view transaction
This commit is contained in:
parent
b6e798a9ad
commit
c77f460176
|
@ -72,7 +72,7 @@ const LAMPORTS_PER_SOL: u64 = 1_000_000_000;
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
pub enum Error {}
|
pub enum Error {}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub enum Cluster {
|
pub enum Cluster {
|
||||||
Devnet,
|
Devnet,
|
||||||
|
@ -623,7 +623,10 @@ impl Module for Solana {
|
||||||
"derivation_accounts": [0u32 | 1 << 31],
|
"derivation_accounts": [0u32 | 1 << 31],
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
Operation::Sign(Sign { blockhash, mut transaction }) => {
|
Operation::Sign(Sign {
|
||||||
|
blockhash,
|
||||||
|
mut transaction,
|
||||||
|
}) => {
|
||||||
let keys = request
|
let keys = request
|
||||||
.derived_keys
|
.derived_keys
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
|
@ -641,7 +644,10 @@ impl Module for Solana {
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
Operation::Broadcast(Broadcast { cluster, transaction }) => {
|
Operation::Broadcast(Broadcast {
|
||||||
|
cluster,
|
||||||
|
transaction,
|
||||||
|
}) => {
|
||||||
let cluster = cluster.unwrap_or(Cluster::MainnetBeta);
|
let cluster = cluster.unwrap_or(Cluster::MainnetBeta);
|
||||||
let cluster_url = format!("https://api.{cluster}.solana.com");
|
let cluster_url = format!("https://api.{cluster}.solana.com");
|
||||||
|
|
||||||
|
@ -649,12 +655,20 @@ impl Module for Solana {
|
||||||
let client = solana_rpc_client::rpc_client::RpcClient::new(cluster_url);
|
let client = solana_rpc_client::rpc_client::RpcClient::new(cluster_url);
|
||||||
let _simulated_response = client.simulate_transaction(&transaction).unwrap();
|
let _simulated_response = client.simulate_transaction(&transaction).unwrap();
|
||||||
let response = client.send_and_confirm_transaction(&transaction);
|
let response = client.send_and_confirm_transaction(&transaction);
|
||||||
|
let cluster_suffix = {
|
||||||
|
if cluster != Cluster::MainnetBeta {
|
||||||
|
String::new()
|
||||||
|
} else {
|
||||||
|
format!("?cluster={cluster}")
|
||||||
|
}
|
||||||
|
};
|
||||||
Ok(match response {
|
Ok(match response {
|
||||||
Ok(s) => {
|
Ok(s) => {
|
||||||
serde_json::json!({
|
serde_json::json!({
|
||||||
"blob": {
|
"blob": {
|
||||||
"status": "send_and_confirm",
|
"status": "send_and_confirm",
|
||||||
"succcess": s.to_string(),
|
"succcess": s.to_string(),
|
||||||
|
"url": format!("https://explorer.solana.com/tx/{s}{cluster_suffix}"),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue