Skip to content

Commit

Permalink
push_effect_list (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
juchiast authored Dec 1, 2023
1 parent 55cebf3 commit c509e03
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 0 deletions.
76 changes: 76 additions & 0 deletions crates/cmds-pdg/node-definitions/push_effect_list.json
Original file line number Diff line number Diff line change
@@ -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": {}
}
1 change: 1 addition & 0 deletions crates/cmds-pdg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
39 changes: 39 additions & 0 deletions crates/cmds-pdg/src/push_effect_list.rs
Original file line number Diff line number Diff line change
@@ -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<Effect>,
element: Effect,
}

#[derive(Serialize, Debug)]
struct Output {
effects: Vec<Effect>,
}

async fn run(_: Context, input: Input) -> Result<Output, CommandError> {
let mut e = EffectsList::from(input.effects);
e.push(input.element);
Ok(Output {
effects: e.effects.into_iter().collect(),
})
}

0 comments on commit c509e03

Please sign in to comment.