gpl_compression/
lib.rs

1use anchor_lang::prelude::*;
2use solana_security_txt::security_txt;
3
4mod errors;
5mod events;
6pub mod instructions;
7pub mod state;
8mod utils;
9
10use crate::errors::GplCompressionError;
11use crate::instructions::*;
12
13declare_id!("41kNwkQ9jESNYZJyAA1ENscQfx7vfkEf6uetVSFmfyaW");
14
15#[cfg(not(feature = "no-entrypoint"))]
16security_txt! {
17    name: "gpl_compression",
18    project_url: "https://gum.fun",
19    contacts: "email:hello@gum.fun,twitter:@gumisfunn",
20    policy: "",
21    preferred_languages: "en",
22    source_code: "https://github.com/gumhq/gpl"
23}
24
25#[program]
26pub mod gpl_compression {
27    use super::*;
28
29    // initialize tree
30    pub fn initialize_tree(
31        ctx: Context<InitializeTreeConfig>,
32        max_depth: u32,
33        max_buffer_size: u32,
34    ) -> Result<()> {
35        initialize_tree_handler(ctx, max_depth, max_buffer_size)
36    }
37
38    // create a compressed post
39    pub fn create_compressed_post(
40        ctx: Context<CreateCompressedPost>,
41        metadata_uri: String,
42        random_hash: [u8; 32],
43    ) -> Result<()> {
44        create_compressed_post_handler(ctx, metadata_uri, random_hash)
45    }
46
47    // update a compressed post
48    pub fn update_compressed_post<'info>(
49        ctx: Context<'_, '_, '_, 'info, UpdateCompressedPost<'info>>,
50        metadata_uri: String,
51        new_metadata_uri: String,
52        random_hash: [u8; 32],
53        root: [u8; 32],
54        index: u32,
55    ) -> Result<()> {
56        update_compressed_post_handler(
57            ctx,
58            metadata_uri,
59            new_metadata_uri,
60            random_hash,
61            root,
62            index,
63        )
64    }
65
66    // delete a compressed post
67    pub fn delete_compressed_post<'info>(
68        ctx: Context<'_, '_, '_, 'info, DeleteCompressedPost<'info>>,
69        metadata_uri: String,
70        random_hash: [u8; 32],
71        root: [u8; 32],
72        index: u32,
73    ) -> Result<()> {
74        delete_compressed_post_handler(ctx, metadata_uri, random_hash, root, index)
75    }
76
77    // create a compressed connection
78    pub fn create_compressed_connection(ctx: Context<CreateCompressedConnection>) -> Result<()> {
79        create_compressed_connection_handler(ctx)
80    }
81
82    // delete a compressed connection
83    pub fn delete_compressed_connection<'info>(
84        ctx: Context<'_, '_, '_, 'info, DeleteCompressedConnection<'info>>,
85        root: [u8; 32],
86        index: u32,
87    ) -> Result<()> {
88        delete_compressed_connection_handler(ctx, root, index)
89    }
90
91    // create a compressed reaction
92    pub fn create_compressed_reaction<'info>(
93        ctx: Context<'_, '_, '_, 'info, CreateCompressedReaction<'info>>,
94        to_post: Pubkey,
95        reaction_type: String,
96        post_root: [u8; 32],
97        post_leaf: [u8; 32],
98        post_index: u32,
99    ) -> Result<()> {
100        create_compressed_reaction_handler(
101            ctx,
102            to_post,
103            reaction_type,
104            post_root,
105            post_leaf,
106            post_index,
107        )
108    }
109
110    // delete a compressed reaction
111    pub fn delete_compressed_reaction<'info>(
112        ctx: Context<'_, '_, '_, 'info, DeleteCompressedReaction<'info>>,
113        to_post: Pubkey,
114        reaction_type: String,
115        root: [u8; 32],
116        index: u32,
117    ) -> Result<()> {
118        delete_compressed_reaction_handler(ctx, to_post, reaction_type, root, index)
119    }
120
121    // create a compressed comment
122    pub fn create_compressed_comment<'info>(
123        ctx: Context<'_, '_, '_, 'info, CreateCompressedComment<'info>>,
124        reply_to: Pubkey,
125        metadata_uri: String,
126        random_hash: [u8; 32],
127        post_root: [u8; 32],
128        post_leaf: [u8; 32],
129        post_index: u32,
130    ) -> Result<()> {
131        create_compressed_comment_handler(
132            ctx,
133            reply_to,
134            metadata_uri,
135            random_hash,
136            post_root,
137            post_leaf,
138            post_index,
139        )
140    }
141}