-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d398c07
commit 1859078
Showing
8 changed files
with
166 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#![allow(unused_variables)] | ||
|
||
use clap::Parser; | ||
|
||
use mango_feeds_connector::snapshot::get_snapshot_gma; | ||
use solana_sdk::pubkey::Pubkey; | ||
|
||
#[derive(Parser, Debug, Clone)] | ||
#[clap()] | ||
struct Cli { | ||
// e.g. https://mango.devnet.rpcpool.com | ||
#[clap(short, long, env)] | ||
rpc_url: String, | ||
|
||
// e.g. 4MangoMjqJ2firMokCjjGgoK8d4MXcrgL7XJaL3w6fVg | ||
#[clap(short, long, env)] | ||
program_account: Pubkey, | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> anyhow::Result<()> { | ||
solana_logger::setup_with_default("info"); | ||
|
||
let cli = Cli::parse_from(std::env::args_os()); | ||
|
||
let rpc_http_url = cli.rpc_url; | ||
let program_id = cli.program_account; | ||
|
||
get_snapshot_gma(&rpc_http_url, vec![program_id.to_string()]).await?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
pub mod rpc_accounts_scan { | ||
use jsonrpc_core::Result; | ||
use jsonrpc_derive::rpc; | ||
use solana_account_decoder::UiAccount; | ||
use solana_rpc_client_api::config::{RpcAccountInfoConfig, RpcProgramAccountsConfig}; | ||
use solana_rpc_client_api::response::{ | ||
OptionalContext, Response as RpcResponse, RpcKeyedAccount, | ||
}; | ||
|
||
/// this definition is derived from solana-rpc/rpc.rs | ||
/// we want to avoid the heavy dependency to solana-rpc | ||
/// the crate solana-rpc-client provides some client methods but do not expose the ```Context```we need | ||
/// | ||
#[rpc] | ||
pub trait RpcAccountsScan { | ||
type Metadata; | ||
|
||
#[rpc(meta, name = "getProgramAccounts")] | ||
fn get_program_accounts( | ||
&self, | ||
meta: Self::Metadata, | ||
program_id_str: String, | ||
config: Option<RpcProgramAccountsConfig>, | ||
) -> Result<OptionalContext<Vec<RpcKeyedAccount>>>; | ||
|
||
#[rpc(meta, name = "getMultipleAccounts")] | ||
fn get_multiple_accounts( | ||
&self, | ||
meta: Self::Metadata, | ||
pubkey_strs: Vec<String>, | ||
config: Option<RpcAccountInfoConfig>, | ||
) -> Result<RpcResponse<Vec<Option<UiAccount>>>>; | ||
} | ||
} | ||
|
||
pub mod rpc_pubsub { | ||
use jsonrpc_core::Result; | ||
use jsonrpc_derive::rpc; | ||
use jsonrpc_pubsub::typed::Subscriber; | ||
use jsonrpc_pubsub::SubscriptionId as PubSubSubscriptionId; | ||
use solana_account_decoder::UiAccount; | ||
use solana_rpc_client_api::config::{RpcAccountInfoConfig, RpcProgramAccountsConfig}; | ||
use solana_rpc_client_api::response::{Response as RpcResponse, RpcKeyedAccount, SlotUpdate}; | ||
use std::sync::Arc; | ||
|
||
#[rpc] | ||
pub trait RpcSolPubSub { | ||
type Metadata; | ||
|
||
#[pubsub( | ||
subscription = "accountNotification", | ||
subscribe, | ||
name = "accountSubscribe" | ||
)] | ||
fn account_subscribe( | ||
&self, | ||
meta: Self::Metadata, | ||
subscriber: Subscriber<RpcResponse<UiAccount>>, | ||
pubkey_str: String, | ||
config: Option<RpcAccountInfoConfig>, | ||
); | ||
|
||
#[pubsub( | ||
subscription = "accountNotification", | ||
unsubscribe, | ||
name = "accountUnsubscribe" | ||
)] | ||
fn account_unsubscribe( | ||
&self, | ||
meta: Option<Self::Metadata>, | ||
id: PubSubSubscriptionId, | ||
) -> Result<bool>; | ||
|
||
#[pubsub( | ||
subscription = "programNotification", | ||
subscribe, | ||
name = "programSubscribe" | ||
)] | ||
fn program_subscribe( | ||
&self, | ||
meta: Self::Metadata, | ||
subscriber: Subscriber<RpcResponse<RpcKeyedAccount>>, | ||
pubkey_str: String, | ||
config: Option<RpcProgramAccountsConfig>, | ||
); | ||
|
||
#[pubsub( | ||
subscription = "programNotification", | ||
unsubscribe, | ||
name = "programUnsubscribe" | ||
)] | ||
fn program_unsubscribe( | ||
&self, | ||
meta: Option<Self::Metadata>, | ||
id: PubSubSubscriptionId, | ||
) -> Result<bool>; | ||
|
||
#[pubsub( | ||
subscription = "slotsUpdatesNotification", | ||
subscribe, | ||
name = "slotsUpdatesSubscribe" | ||
)] | ||
fn slots_updates_subscribe( | ||
&self, | ||
meta: Self::Metadata, | ||
subscriber: Subscriber<Arc<SlotUpdate>>, | ||
); | ||
|
||
#[pubsub( | ||
subscription = "slotsUpdatesNotification", | ||
unsubscribe, | ||
name = "slotsUpdatesUnsubscribe" | ||
)] | ||
fn slots_updates_unsubscribe( | ||
&self, | ||
meta: Option<Self::Metadata>, | ||
id: PubSubSubscriptionId, | ||
) -> Result<bool>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters