From 390c41b43ed98bdb94a1bd68c71aa58b055917f7 Mon Sep 17 00:00:00 2001 From: Nick Garfield Date: Fri, 31 Mar 2023 09:33:16 -0500 Subject: [PATCH] Derive serde traits for the SerializableInstruction (#215) --- .gitignore | 1 + Cargo.lock | 2 ++ utils/Cargo.toml | 2 ++ utils/src/thread.rs | 25 +++++++++++++++++++++++-- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index baa6f8342..e0d8a177d 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ docker-target *.diff **/keypair.json **/*.log +**/.coderrect diff --git a/Cargo.lock b/Cargo.lock index 812404119..85a615642 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1319,6 +1319,8 @@ version = "2.0.2" dependencies = [ "anchor-lang", "base64 0.13.1", + "serde", + "serde_json", "static-pubkey", ] diff --git a/utils/Cargo.toml b/utils/Cargo.toml index d9abd3540..b34a461af 100644 --- a/utils/Cargo.toml +++ b/utils/Cargo.toml @@ -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" diff --git a/utils/src/thread.rs b/utils/src/thread.rs index c1bff875c..1732d0cb4 100644 --- a/utils/src/thread.rs +++ b/utils/src/thread.rs @@ -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. @@ -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, @@ -165,7 +176,17 @@ impl TryFrom> 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,