-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add cmd line for looking up escrow accounts, remove debug logs * Use disable preflight for debugging, burn after one minute * Add bin
- Loading branch information
Matthew Plant
authored
Apr 19, 2023
1 parent
b3c6023
commit 6af342a
Showing
5 changed files
with
58 additions
and
17 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
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,34 @@ | ||
use clap::Parser; | ||
use helium_crypto::{PublicKey, PublicKeyBinary}; | ||
use sha2::{Digest, Sha256}; | ||
use solana_sdk::pubkey::Pubkey; | ||
|
||
#[derive(Parser)] | ||
#[clap(about = "Look up the DC escrow account for a Payer account")] | ||
struct Cli { | ||
payer: PublicKey, | ||
} | ||
|
||
fn main() { | ||
let Cli { payer } = Cli::parse(); | ||
let sub_dao: Pubkey = "39Lw1RH6zt8AJvKn3BTxmUDofzduCM2J3kSaGDZ8L7Sk" | ||
.parse() | ||
.unwrap(); | ||
let payer = PublicKeyBinary::from(payer); | ||
let mut hasher = Sha256::new(); | ||
hasher.update(payer.to_string()); | ||
let sha_digest = hasher.finalize(); | ||
let (ddc_key, _) = Pubkey::find_program_address( | ||
&[ | ||
"delegated_data_credits".as_bytes(), | ||
sub_dao.as_ref(), | ||
&sha_digest, | ||
], | ||
&data_credits::ID, | ||
); | ||
let (escrow_account, _) = Pubkey::find_program_address( | ||
&["escrow_dc_account".as_bytes(), &ddc_key.to_bytes()], | ||
&data_credits::ID, | ||
); | ||
println!("https://explorer.solana.com/address/{escrow_account}"); | ||
} |