Skip to content

Commit

Permalink
Derive serde traits for the SerializableInstruction (clockwork-xyz#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgarfield authored Mar 31, 2023
1 parent 3fb5c9d commit 390c41b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ docker-target
*.diff
**/keypair.json
**/*.log
**/.coderrect
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ name = "clockwork_utils"
[dependencies]
anchor-lang = "0.27.0"
base64 = "~0.13"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
static-pubkey = "1.0.3"

25 changes: 23 additions & 2 deletions utils/src/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use anchor_lang::{
solana_program::{self, instruction::Instruction},
AnchorDeserialize,
};
use serde::{Deserialize, Serialize};
use static_pubkey::static_pubkey;

/// The stand-in pubkey for delegating a payer address to a worker. All workers are re-imbursed by the user for lamports spent during this delegation.
Expand Down Expand Up @@ -108,7 +109,17 @@ impl Default for ThreadResponse {
}

/// The data needed execute an instruction on Solana.
#[derive(AnchorDeserialize, AnchorSerialize, BorshSchema, Clone, Debug, Hash, PartialEq)]
#[derive(
AnchorDeserialize,
AnchorSerialize,
Serialize,
Deserialize,
BorshSchema,
Clone,
Debug,
Hash,
PartialEq,
)]
pub struct SerializableInstruction {
/// Pubkey of the instruction processor that executes this instruction
pub program_id: Pubkey,
Expand Down Expand Up @@ -165,7 +176,17 @@ impl TryFrom<Vec<u8>> for SerializableInstruction {
}

/// Account metadata needed to execute an instruction on Solana.
#[derive(AnchorDeserialize, AnchorSerialize, BorshSchema, Clone, Debug, Hash, PartialEq)]
#[derive(
AnchorDeserialize,
AnchorSerialize,
Serialize,
Deserialize,
BorshSchema,
Clone,
Debug,
Hash,
PartialEq,
)]
pub struct SerializableAccount {
/// An account's public key
pub pubkey: Pubkey,
Expand Down

0 comments on commit 390c41b

Please sign in to comment.