diff --git a/crates/cmds-pdg/node-definitions/push_effect_list.json b/crates/cmds-pdg/node-definitions/push_effect_list.json new file mode 100644 index 00000000..ca2f58e1 --- /dev/null +++ b/crates/cmds-pdg/node-definitions/push_effect_list.json @@ -0,0 +1,76 @@ +{ + "type": "native", + "data": { + "node_definition_version": "0.1", + "unique_id": "", + "node_id": "push_effect_list", + "version": "0.1", + "display_name": "Push Effects List", + "description": "", + "tags": [], + "related_to": [ + { + "id": "", + "type": "", + "relationship": "" + } + ], + "resources": { + "source_code_url": "", + "documentation_url": "" + }, + "usage": { + "license": "Apache-2.0", + "license_url": "", + "pricing": { + "currency": "USDC", + "purchase_price": 0, + "price_per_run": 0, + "custom": { + "unit": "monthly", + "value": "0" + } + } + }, + "authors": [ + { + "name": "Space Operator", + "contact": "" + } + ], + "design": { + "width": 0, + "height": 0, + "icon_url": "", + "backgroundColorDark": "#000000", + "backgroundColor": "#fff" + }, + "options": {} + }, + "sources": [ + { + "name": "effects", + "type": "array", + "defaultValue": "", + "tooltip": "" + }, + { + "name": "element", + "type": "object", + "defaultValue": "", + "tooltip": "" + } + ], + "targets": [ + { + "name": "effects", + "type_bounds": ["array"], + "required": true, + "passthrough": false, + "defaultValue": null, + "tooltip": "" + } + ], + "targets_form.json_schema": {}, + "targets_form.ui_schema": {} +} diff --git a/crates/cmds-pdg/src/lib.rs b/crates/cmds-pdg/src/lib.rs index 3680ebf2..06d6cd1c 100644 --- a/crates/cmds-pdg/src/lib.rs +++ b/crates/cmds-pdg/src/lib.rs @@ -3,4 +3,5 @@ pub mod gen_pdg_attrs; pub mod get_effect_list; pub mod parse_pdg_attrs; pub mod pdg_render; +pub mod push_effect_list; pub mod update_render_params; diff --git a/crates/cmds-pdg/src/push_effect_list.rs b/crates/cmds-pdg/src/push_effect_list.rs new file mode 100644 index 00000000..20aae882 --- /dev/null +++ b/crates/cmds-pdg/src/push_effect_list.rs @@ -0,0 +1,39 @@ +use flow_lib::{ + command::{ + builder::{BuildResult, BuilderCache, CmdBuilder}, + CommandDescription, CommandError, + }, + Context, +}; +use pdg_common::nft_metadata::generate::{Effect, EffectsList}; +use serde::{Deserialize, Serialize}; + +const NAME: &str = "push_effect_list"; + +fn build() -> BuildResult { + static CACHE: BuilderCache = BuilderCache::new(|| { + CmdBuilder::new(flow_lib::node_definition!("push_effect_list.json"))?.check_name(NAME) + }); + Ok(CACHE.clone()?.build(run)) +} + +flow_lib::submit!(CommandDescription::new(NAME, |_| build())); + +#[derive(Deserialize, Debug)] +struct Input { + effects: Vec, + element: Effect, +} + +#[derive(Serialize, Debug)] +struct Output { + effects: Vec, +} + +async fn run(_: Context, input: Input) -> Result { + let mut e = EffectsList::from(input.effects); + e.push(input.element); + Ok(Output { + effects: e.effects.into_iter().collect(), + }) +}