Skip to main content

txtx_addon_network_svm/
lib.rs

1#[macro_use]
2extern crate lazy_static;
3
4#[macro_use]
5extern crate txtx_addon_kit;
6
7pub mod codec;
8mod commands;
9mod constants;
10pub mod functions;
11pub mod rpc;
12mod signers;
13pub mod templates;
14pub mod utils;
15pub use solana_pubkey::Pubkey;
16
17pub mod typing {
18    pub use txtx_addon_network_svm_types::*;
19}
20
21use constants::NAMESPACE;
22use txtx_addon_kit::{
23    types::{
24        commands::PreCommandSpecification, functions::FunctionSpecification,
25        signers::SignerSpecification,
26    },
27    Addon,
28};
29use txtx_addon_network_svm_types::SvmValue;
30
31#[derive(Debug)]
32pub struct SvmNetworkAddon;
33
34impl SvmNetworkAddon {
35    pub fn new() -> Self {
36        Self {}
37    }
38}
39
40impl Addon for SvmNetworkAddon {
41    fn get_name(&self) -> &str {
42        "Solana and SVM Compatible Blockchains (beta)"
43    }
44
45    fn get_description(&self) -> &str {
46        txtx_addon_kit::indoc! {r#"
47            The SVM `txtx` plugin enables building Runbooks that interact with Solana and SVM compatible blockchains. 
48            The plugin provides utility functions that allow you to deploy anchor programs and encode instruction calls according to program IDLs.
49            The actions can be used to create valid transfer, program call, and program deployment transactions that can be signed via a mnemonic phrase, secret key, or via your browser signer.
50            "#}
51    }
52
53    fn get_namespace(&self) -> &str {
54        NAMESPACE
55    }
56
57    fn get_functions(&self) -> Vec<FunctionSpecification> {
58        functions::FUNCTIONS.clone()
59    }
60
61    fn get_actions(&self) -> Vec<PreCommandSpecification> {
62        commands::ACTIONS.clone()
63    }
64
65    fn get_signers(&self) -> Vec<SignerSpecification> {
66        signers::SIGNERS.clone()
67    }
68
69    fn to_json(
70        &self,
71        value: &txtx_addon_kit::types::types::Value,
72    ) -> Result<Option<serde_json::Value>, txtx_addon_kit::types::diagnostics::Diagnostic> {
73        SvmValue::to_json(value)
74    }
75}