solana_write_account/
lib.rs

1// solana-write-account — helper program and library for handling Solana
2//                        transaction size limit
3// © 2024 by Composable Foundation
4// © 2025 by Michał Nazarewicz <mina86@mina86.com>
5//
6// This program is free software; you can redistribute it and/or modify it under
7// the terms of the GNU General Public License as published by the Free Software
8// Foundation; either version 2 of the License, or (at your option) any later
9// version.
10//
11// This program is distributed in the hope that it will be useful, but WITHOUT
12// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13// FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
14// details.
15//
16// You should have received a copy of the GNU General Public License along with
17// this program; if not, see <https://www.gnu.org/licenses/>.
18
19//! Helper smart contract and library functions to support calling Solana
20//! programs with instruction data read from an account.
21//!
22//! Solana limits transaction size to at most 1232 bytes.  This includes all
23//! accounts participating in the transaction as well as all the instruction
24//! data.  Unfortunately, some programs may need to encode instructions which
25//! don’t fit in that limit.
26//!
27//! To address this, Solana program may support reading instruction data from an
28//! account.  This library provides a helper Solana program which allows
29//! populating the account with overlong instruction data, client helper
30//! functions for invoking program with instruction stored in an account (when
31//! built with `client` feature) and helper [`entrypoint`] module for Solana
32//! programs which want to support reading instruction data from an account
33//! (when built with `lib` feature).
34//!
35//! The account data must be a length-prefixed slice of bytes.  In other words,
36//! borsh-serialised `Vec<u8>`.  The account may contain trailing bytes which
37//! are ignored.
38//!
39//! This module provides types to help use this feature of the Solana IBC
40//! contract.  [`Accounts`] is used to add the account with instruction data to
41//! an instruction and [`Instruction`] constructs an empty instruction data to
42//! call the contract with.
43
44#[cfg(feature = "client")]
45pub mod instruction;
46
47#[cfg(feature = "lib")]
48pub mod entrypoint;
49
50#[cfg(not(any(feature = "client", feature = "lib")))]
51mod program;