v0.2.13-pre.003

This commit is contained in:
2026-08-28 05:04:10 +02:00
parent 99477d0d2b
commit 900444bff5
10 changed files with 480 additions and 41 deletions

View File

@@ -0,0 +1,6 @@
// file: crates/ksp-interface-lib/src/error.rs
// version: 1
/// Error code used when a bounded passive Program instruction contract exceeds one of its Interface-owned admission limits.
pub const ERROR_CODE_PROGRAM_INSTRUCTION_LIMIT_EXCEEDED: ksp_core_lib::ErrorCode =
ksp_core_lib::ErrorCode::new("interface", "program_instruction_limit_exceeded");

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-interface-lib/src/lib.rs
// version: 1
// version: 2
#![warn(missing_docs)]
#![deny(unreachable_pub)]
@@ -7,10 +7,19 @@
//! Passive wire contracts shared by KSP Program implementations.
//!
//! The foundation deliberately starts with the canonical Solana [`Pubkey`]
//! owned by `ksp-core-lib`. Program-facing instruction contracts are added in
//! later slices without introducing runtime, transport, persistence or Program
//! behavior into Interface.
//! The foundation reuses the canonical Solana [`Pubkey`] owned by
//! `ksp-core-lib` and exposes only bounded, passive Program-facing structures.
//! Runtime, transport, persistence and Program behavior remain outside this
//! crate.
mod error;
mod program_account_meta;
/// Error code used when an Interface-owned Program instruction admission limit is exceeded.
pub use self::error::ERROR_CODE_PROGRAM_INSTRUCTION_LIMIT_EXCEEDED;
/// Maximum number of account metas admitted by one passive Program instruction contract.
pub use self::program_account_meta::MAX_PROGRAM_INSTRUCTION_ACCOUNTS;
/// Passive account metadata attached to one Program instruction.
pub use self::program_account_meta::ProgramAccountMeta;
/// Canonical Solana account address primitive owned by `ksp-core-lib`.
pub use ksp_core_lib::Pubkey;

View File

@@ -0,0 +1,52 @@
// file: crates/ksp-interface-lib/src/program_account_meta.rs
// version: 1
/// Maximum number of account metas admitted by one passive Program instruction contract.
pub const MAX_PROGRAM_INSTRUCTION_ACCOUNTS: usize = 255;
/// Passive account metadata attached to one Program instruction.
///
/// Account metas preserve the caller-provided Solana account identity and the
/// signer/writable flags without applying Program-specific semantics.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct ProgramAccountMeta {
pubkey: crate::Pubkey,
is_signer: bool,
is_writable: bool,
}
impl ProgramAccountMeta {
/// Creates one read-only account meta.
#[must_use]
pub const fn readonly(pubkey: crate::Pubkey, is_signer: bool) -> Self {
return Self { pubkey, is_signer, is_writable: false };
}
/// Creates one writable account meta.
#[must_use]
pub const fn writable(pubkey: crate::Pubkey, is_signer: bool) -> Self {
return Self { pubkey, is_signer, is_writable: true };
}
/// Returns whether this account must sign the containing instruction.
#[must_use]
pub const fn is_signer(&self) -> bool {
return self.is_signer;
}
/// Returns whether this account may be written by the containing instruction.
#[must_use]
pub const fn is_writable(&self) -> bool {
return self.is_writable;
}
/// Returns the canonical account address.
#[must_use]
pub const fn pubkey(&self) -> &crate::Pubkey {
return &self.pubkey;
}
}
#[cfg(test)]
#[path = "../unit_tests/program_account_meta.rs"]
mod tests;