rush_ecs_svm/instruction/
store.rs

1use std::collections::BTreeMap;
2
3use borsh::{BorshDeserialize, BorshSerialize};
4use rush_ecs_core::blueprint::{Component, ComponentValue, Entity, Region};
5use shank::{ShankContext, ShankInstruction};
6
7/// RushStore Instruction List
8///
9/// For World Authority:
10/// - CreateWorld, UpdateWorld, DeleteWorld
11///
12/// For Region Authority:
13/// - UpdateEntity, DespawnEntity
14///
15/// For Entity Authority:
16/// - SpawnEntity, UpdateEntity, DespawnEntity
17///
18#[derive(
19    BorshDeserialize, BorshSerialize, Clone, Debug, Eq, PartialEq, ShankContext, ShankInstruction,
20)]
21pub enum RushStoreInstruction {
22    #[account(
23        0,
24        name = "world_authority",
25        desc = "World authority who has access to World state changing operations"
26    )]
27    #[account(
28        1,
29        signer,
30        name = "payer",
31        desc = "Payer who funds the state account creation"
32    )]
33    #[account(2, writable, name = "world", desc = "World State PDA")]
34    #[account(3, name = "system_program", desc = "System Program")]
35    CreateWorld {
36        name: String,
37        description: String,
38        regions: Vec<Region>,
39        entities: Vec<Entity>,
40        bump: u8,
41    },
42
43    #[account(
44        0,
45        signer,
46        name = "world_authority",
47        desc = "World authority who has access to World state changing operations"
48    )]
49    #[account(1, writable, name = "world", desc = "World State PDA")]
50    #[account(2, name = "system_program", desc = "System Program")]
51    UpdateWorld {
52        regions: Vec<Region>,
53        entities: Vec<Entity>,
54    },
55
56    #[account(
57        0,
58        signer,
59        name = "world_authority",
60        desc = "World authority who has access to World state changing operations"
61    )]
62    #[account(1, writable, name = "world", desc = "World State PDA")]
63    DeleteWorld,
64
65    #[account(
66        0,
67        signer,
68        name = "instance_authority",
69        desc = "Instance authority who has access to Instance state changing operations"
70    )]
71    #[account(1, writable, name = "instance", desc = "Instance State PDA")]
72    #[account(2, writable, name = "world", desc = "World State PDA")]
73    #[account(3, name = "system_program", desc = "System Program")]
74    SpawnEntity {
75        region: Region,
76        entity: Entity,
77        components: BTreeMap<Component, ComponentValue>,
78        nonce: u64,
79        bump: u8,
80    },
81
82    #[account(
83        0,
84        signer,
85        name = "instance_authority",
86        desc = "Instance authority who has access to Instance state changing operations"
87    )]
88    #[account(1, writable, name = "instance", desc = "Instance State PDA")]
89    UpdateEntity {
90        component: Component,
91        value: ComponentValue,
92    },
93
94    #[account(
95        0,
96        signer,
97        name = "instance_authority",
98        desc = "Instance authority who has access to Instance state changing operations"
99    )]
100    #[account(1, writable, name = "instance", desc = "Instance State PDA")]
101    DespawnEntity,
102}