-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy paththaw.rs
More file actions
34 lines (29 loc) · 1014 Bytes
/
thaw.rs
File metadata and controls
34 lines (29 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use borsh::BorshDeserialize;
use light_client::rpc::Rpc;
use light_token::instruction::Thaw;
use rust_client::{setup_frozen, SetupContext};
use solana_sdk::signer::Signer;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Setup creates mint, associated token account with tokens, and freezes account
let SetupContext {
mut rpc,
payer,
mint,
associated_token_account,
..
} = setup_frozen().await;
let thaw_instruction = Thaw {
token_account: associated_token_account,
mint,
freeze_authority: payer.pubkey(),
}
.instruction()?;
let sig = rpc
.create_and_send_transaction(&[thaw_instruction], &payer.pubkey(), &[&payer])
.await?;
let data = rpc.get_account(associated_token_account).await?.ok_or("Account not found")?;
let token = light_token_interface::state::Token::deserialize(&mut &data.data[..])?;
println!("State: {:?} Tx: {sig}", token.state);
Ok(())
}