-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrevoke.rs
More file actions
33 lines (28 loc) · 1012 Bytes
/
revoke.rs
File metadata and controls
33 lines (28 loc) · 1012 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
use borsh::BorshDeserialize;
use light_client::rpc::Rpc;
use light_token::instruction::Revoke;
use rust_client::{setup, 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 approves delegate
let SetupContext {
mut rpc,
payer,
associated_token_account,
..
} = setup().await;
let revoke_instruction = Revoke {
token_account: associated_token_account,
owner: payer.pubkey(),
fee_payer: payer.pubkey(),
}
.instruction()?;
let sig = rpc
.create_and_send_transaction(&[revoke_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!("Delegate: {:?} Tx: {sig}", token.delegate);
Ok(())
}