-
Notifications
You must be signed in to change notification settings - Fork 76
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
Nick Garfield
committed
Mar 2, 2022
1 parent
ced6d04
commit 2a36955
Showing
14 changed files
with
97 additions
and
122 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,35 @@ | ||
use { | ||
crate::env, | ||
solana_client_helpers::{Client, ClientResult, RpcClient}, | ||
solana_sdk::{ | ||
commitment_config::CommitmentConfig, instruction::Instruction, signature::read_keypair, | ||
signature::Signature, transaction::Transaction, | ||
}, | ||
std::fs::File, | ||
}; | ||
|
||
pub trait RPCClient { | ||
fn new() -> Client; | ||
fn sign_and_submit(&self, ixs: &[Instruction], memo: &str) -> ClientResult<Signature>; | ||
} | ||
|
||
impl RPCClient for Client { | ||
fn new() -> Client { | ||
let payer = read_keypair(&mut File::open(env::keypath().as_str()).unwrap()).unwrap(); | ||
let client = RpcClient::new_with_commitment::<String>( | ||
env::rpc_endpoint().as_str().into(), | ||
CommitmentConfig::processed(), | ||
); | ||
Client { client, payer } | ||
} | ||
|
||
fn sign_and_submit(&self, ixs: &[Instruction], memo: &str) -> ClientResult<Signature> { | ||
println!("{}", memo); | ||
let payer = self.payer_pubkey(); | ||
let mut tx = Transaction::new_with_payer(ixs, Some(&payer)); | ||
tx.sign(&vec![&self.payer], self.latest_blockhash()?); | ||
let sig = self.send_and_confirm_transaction(&tx)?; | ||
println!("✅ {:?}", sig); | ||
Ok(sig) | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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