0.1.0
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
# file: kb_executor_metadata_metaplex_token_metadata/Cargo.toml
|
||||
# version: 2
|
||||
|
||||
[package]
|
||||
name = "kb_executor_metadata_metaplex_token_metadata"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish.workspace = true
|
||||
|
||||
[dependencies]
|
||||
kb_core = { path = "../kb_core" }
|
||||
kb_execution_api = { path = "../kb_execution_api" }
|
||||
kb_model = { path = "../kb_model" }
|
||||
kb_program_ids = { path = "../kb_program_ids" }
|
||||
mpl-token-metadata.workspace = true
|
||||
serde_json.workspace = true
|
||||
tracing.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
@@ -0,0 +1,15 @@
|
||||
<!-- file: kb_executor_metadata_metaplex_token_metadata/README.md -->
|
||||
<!-- version: 2 -->
|
||||
|
||||
# `kb_executor_metadata_metaplex_token_metadata`
|
||||
|
||||
Exécuteur dédié au programme Metaplex Token Metadata.
|
||||
|
||||
La crate suit la frontière commune des exécuteurs du workspace :
|
||||
|
||||
- `constants.rs` contient les constantes locales et la cible de tracing ;
|
||||
- `executor.rs` expose `MetadataMetaplexTokenMetadataExecutor` et implémente `kb_execution_api::InstructionExecutor` ;
|
||||
- `lib.rs` réexporte uniquement le type public ;
|
||||
- le Program ID provient exclusivement de `kb_program_ids`.
|
||||
|
||||
Dans `0.4.7-pre.001`, le support exact du Program ID retourne encore `Maybe`. `build_plan` produit uniquement un plan réservé sans instruction afin qu'aucune opération Metaplex ne puisse être exécutée avant validation complète des builders officiels, comptes ordonnés, autorités, signataires, préconditions, coûts, confirmations et postconditions stateful.
|
||||
@@ -0,0 +1,9 @@
|
||||
// file: kb_executor_metadata_metaplex_token_metadata/src/constants.rs
|
||||
// version: 4
|
||||
|
||||
//! Local constants for the Metaplex Token Metadata executor.
|
||||
|
||||
/// Status emitted by the reserved execution plan until exact builders are validated.
|
||||
pub(crate) const RESERVED_EXECUTION_STATUS: &str = "reserved_executor";
|
||||
/// Canonical tracing target for this crate.
|
||||
pub(crate) const TRACING_TARGET: &str = "kb_executor_metadata_metaplex_token_metadata";
|
||||
@@ -0,0 +1,72 @@
|
||||
// file: kb_executor_metadata_metaplex_token_metadata/src/executor.rs
|
||||
// version: 5
|
||||
|
||||
//! Executor scaffold for Metaplex Token Metadata.
|
||||
|
||||
/// Initial Metaplex Token Metadata executor implementation.
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct MetadataMetaplexTokenMetadataExecutor;
|
||||
|
||||
impl kb_execution_api::InstructionExecutor for crate::MetadataMetaplexTokenMetadataExecutor {
|
||||
fn executor_name(&self) -> &'static str {
|
||||
return "kb_executor_metadata_metaplex_token_metadata";
|
||||
}
|
||||
|
||||
fn executor_version(&self) -> &'static str {
|
||||
return env!("CARGO_PKG_VERSION");
|
||||
}
|
||||
|
||||
fn program_ids(&self) -> &'static [&'static str] {
|
||||
return &[kb_program_ids::METADATA_METAPLEX_TOKEN_METADATA_PROGRAM_ID];
|
||||
}
|
||||
|
||||
fn supports_request(
|
||||
&self,
|
||||
request: &kb_execution_api::ExecutionRequest,
|
||||
) -> kb_execution_api::ExecutionSupport {
|
||||
if kb_execution_api::InstructionExecutor::handles_program_id(self, &request.program_id) {
|
||||
return kb_execution_api::ExecutionSupport::Maybe;
|
||||
}
|
||||
return kb_execution_api::ExecutionSupport::No;
|
||||
}
|
||||
|
||||
fn build_plan(
|
||||
&self,
|
||||
_request: &kb_execution_api::ExecutionRequest,
|
||||
) -> kb_core::Result<kb_execution_api::ExecutionPlan> {
|
||||
tracing::debug!(
|
||||
target: crate::TRACING_TARGET,
|
||||
"Metaplex Token Metadata execution remains reserved pending builder validation"
|
||||
);
|
||||
return std::result::Result::Ok(kb_execution_api::ExecutionPlan {
|
||||
executor_name: std::string::String::from(
|
||||
"kb_executor_metadata_metaplex_token_metadata",
|
||||
),
|
||||
instruction_count: 0,
|
||||
payload_json: match kb_execution_api::serialize_payload_json(&serde_json::json!({
|
||||
"status": crate::RESERVED_EXECUTION_STATUS,
|
||||
})) {
|
||||
std::result::Result::Ok(serialized) => serialized,
|
||||
std::result::Result::Err(error) => return std::result::Result::Err(error),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn executor_identity_and_program_boundary_are_exact() {
|
||||
let executor = crate::MetadataMetaplexTokenMetadataExecutor;
|
||||
assert_eq!(
|
||||
kb_execution_api::InstructionExecutor::executor_name(&executor),
|
||||
"kb_executor_metadata_metaplex_token_metadata"
|
||||
);
|
||||
assert_eq!(
|
||||
kb_execution_api::InstructionExecutor::program_ids(&executor),
|
||||
&["metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"]
|
||||
);
|
||||
assert_eq!(crate::TRACING_TARGET, "kb_executor_metadata_metaplex_token_metadata");
|
||||
assert_eq!(crate::RESERVED_EXECUTION_STATUS, "reserved_executor");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// file: kb_executor_metadata_metaplex_token_metadata/src/lib.rs
|
||||
// version: 4
|
||||
|
||||
//! Executor crate for Metaplex Token Metadata.
|
||||
#![warn(missing_docs)]
|
||||
#![deny(unreachable_pub)]
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
mod constants;
|
||||
mod executor;
|
||||
|
||||
/// Status emitted by the reserved execution plan until exact builders are validated.
|
||||
pub(crate) use crate::constants::RESERVED_EXECUTION_STATUS;
|
||||
/// Canonical tracing target for this crate.
|
||||
pub(crate) use crate::constants::TRACING_TARGET;
|
||||
|
||||
/// Exposes the Metaplex Token Metadata executor implemented by this crate.
|
||||
pub use crate::executor::MetadataMetaplexTokenMetadataExecutor;
|
||||
Reference in New Issue
Block a user