Skip to main content

tengu_api/
instruction.rs

1//! Instruction enum and data structs.
2
3use steel::*;
4
5#[repr(u8)]
6#[derive(Clone, Copy, Debug, Eq, PartialEq, num_enum::TryFromPrimitive)]
7pub enum DojosInstruction {
8    // Init
9    BuyStarterPack = 1,
10
11    // Player
12    RecruitShogunTickets = 2,
13    RecruitShogunSol = 32,
14    SeatShogun = 3,
15    ReplaceShogun = 34,
16    Dine = 5,
17    UpgradeBarracksShards = 7,
18    UpgradeBarracksSol = 26,
19    UpgradeForge = 8,
20    MergeShogun = 9,
21    PrestigeUpgrade = 10,
22    ClaimShards = 11,
23    ClaimReferralReward = 12,
24    ClaimRecruitReward = 36,
25    ClaimForgeReward = 37,
26    ClaimDineReward = 38,
27    ClaimDailyReward = 39,
28    ClaimCollectionReward = 40,
29    BuyBundle = 13,
30    BuyTicketsWithShards = 22,
31    BuyFlashSale = 24,
32    ClearForgeCooldown = 15,
33    Log = 20,
34    LevelUpShogun = 25,
35    RollSceneSectionAmethyst = 27,
36    RollSceneSectionShards = 31,
37    SalvageSceneSection = 28,
38    BuyChest = 29,
39    BuyScene = 33,
40    UpdateActiveScene = 30,
41    BuySceneDojo = 35,
42
43    // Admin
44    Initialize = 0,
45    NewVar = 16,
46    SetGenesisSlot = 19,
47    SetVarAddress = 21,
48}
49
50#[repr(C)]
51#[derive(Clone, Copy, Debug, Pod, Zeroable)]
52pub struct Initialize {}
53
54#[repr(C)]
55#[derive(Clone, Copy, Debug, Pod, Zeroable)]
56pub struct BuyStarterPack {
57    pub referrer: [u8; 32], // Option<Pubkey> as bytes; [0u8;32] = None
58}
59
60#[repr(C)]
61#[derive(Clone, Copy, Debug, Pod, Zeroable)]
62pub struct RecruitShogunTickets {
63    pub count: [u8; 8],   // 1 or 10
64    pub seed: [u8; 32],   // From BSM /recruit/seed (Option 7 centralized oracle)
65}
66
67#[repr(C)]
68#[derive(Clone, Copy, Debug, Pod, Zeroable)]
69pub struct RecruitShogunSol {
70    pub count: [u8; 8],   // 1 or 10
71    pub seed: [u8; 32],   // From BSM /recruit/seed (Option 7 centralized oracle)
72}
73
74#[repr(C)]
75#[derive(Clone, Copy, Debug, Pod, Zeroable)]
76pub struct SeatShogun {
77    pub slot: [u8; 8],
78    pub pool_index: [u8; 8],
79}
80
81#[repr(C)]
82#[derive(Clone, Copy, Debug, Pod, Zeroable)]
83pub struct ReplaceShogun {
84    pub slot: [u8; 8],
85    pub new_pool_index: [u8; 8],
86}
87
88#[repr(C)]
89#[derive(Clone, Copy, Debug, Pod, Zeroable)]
90pub struct Dine {
91    pub tier: [u8; 8],       // 0=24h/15, 1=48h/30, 2=72h/45
92    pub pool_index: [u8; 8],
93}
94
95#[repr(C)]
96#[derive(Clone, Copy, Debug, Pod, Zeroable)]
97pub struct UpgradeBarracksShards {}
98
99#[repr(C)]
100#[derive(Clone, Copy, Debug, Pod, Zeroable)]
101pub struct UpgradeBarracksSol {}
102
103#[repr(C)]
104#[derive(Clone, Copy, Debug, Pod, Zeroable)]
105pub struct UpgradeForge {}
106
107#[repr(C)]
108#[derive(Clone, Copy, Debug, Pod, Zeroable)]
109pub struct MergeShogun {
110    pub merge_type: [u8; 8], // 0=10×N, 1=5×R, 2=3×SR
111    /// Pool indices of shoguns to consume. 10×N=10, 5×R=5, 3×SR=3.
112    pub pool_indices: [u64; 10],
113    /// From BSM /merge/instruction (Option 7 centralized oracle).
114    pub seed: [u8; 32],
115}
116
117#[repr(C)]
118#[derive(Clone, Copy, Debug, Pod, Zeroable)]
119pub struct PrestigeUpgrade {
120    /// Pool index of the shogun to upgrade (SSR/UR).
121    pub target_pool_index: [u8; 8],
122    /// Pool index of first duplicate fodder.
123    pub fodder_1_pool_index: [u8; 8],
124    /// Pool index of second duplicate fodder.
125    pub fodder_2_pool_index: [u8; 8],
126}
127
128#[repr(C)]
129#[derive(Clone, Copy, Debug, Pod, Zeroable)]
130pub struct LevelUpShogun {
131    pub pool_index: [u8; 8],
132}
133
134#[repr(C)]
135#[derive(Clone, Copy, Debug, Pod, Zeroable)]
136pub struct ClaimShards {} // Amount computed on-chain from ore; no client input (security).
137
138#[repr(C)]
139#[derive(Clone, Copy, Debug, Pod, Zeroable)]
140pub struct ClaimReferralReward {}
141
142#[repr(C)]
143#[derive(Clone, Copy, Debug, Pod, Zeroable)]
144pub struct ClaimRecruitReward {}
145
146#[repr(C)]
147#[derive(Clone, Copy, Debug, Pod, Zeroable)]
148pub struct ClaimForgeReward {}
149
150#[repr(C)]
151#[derive(Clone, Copy, Debug, Pod, Zeroable)]
152pub struct ClaimDineReward {}
153
154#[repr(C)]
155#[derive(Clone, Copy, Debug, Pod, Zeroable)]
156pub struct ClaimDailyReward {
157    pub signature: [u8; 64],
158}
159
160#[repr(C)]
161#[derive(Clone, Copy, Debug, Pod, Zeroable)]
162pub struct ClaimCollectionReward {
163    pub pool_indices: [u64; 3],
164}
165
166#[repr(C)]
167#[derive(Clone, Copy, Debug, Pod, Zeroable)]
168pub struct BuyBundle {} // Fixed bundle: TICKET_BUNDLE_SOL for TICKET_BUNDLE_TICKETS
169
170#[repr(C)]
171#[derive(Clone, Copy, Debug, Pod, Zeroable)]
172pub struct BuyTicketsWithShards {} // Fixed: 5 tickets for 300 shards (daily deal)
173
174#[repr(C)]
175#[derive(Clone, Copy, Debug, Pod, Zeroable)]
176pub struct BuyFlashSale {} // Flash sale: 50 tickets for 5000 shards, max 5/day
177
178#[repr(C)]
179#[derive(Clone, Copy, Debug, Pod, Zeroable)]
180pub struct ClearForgeCooldown {}
181
182#[repr(C)]
183#[derive(Clone, Copy, Debug, Pod, Zeroable)]
184pub struct NewVar {
185    pub id: [u8; 8],
186    pub commit: [u8; 32],
187    pub provider: [u8; 32],
188    pub end_at: [u8; 8],
189    pub samples: [u8; 8],
190    pub is_auto: [u8; 8],
191}
192
193#[repr(C)]
194#[derive(Clone, Copy, Debug, Pod, Zeroable)]
195pub struct SetGenesisSlot {
196    pub genesis_slot: [u8; 8],
197    /// Slots per halving period. 0 = use HALVING_PERIOD_SLOTS_DEFAULT (~58 days, matches Hyper Ninja).
198    pub halving_period_slots: [u8; 8],
199}
200
201#[repr(C)]
202#[derive(Clone, Copy, Debug, Pod, Zeroable)]
203pub struct Log {
204    pub _reserved: [u8; 8], // Variable-length log; remaining bytes are message
205}
206
207#[repr(C)]
208#[derive(Clone, Copy, Debug, Pod, Zeroable)]
209pub struct SetVarAddress {
210    pub entropy_var: [u8; 32],
211}
212
213#[repr(C)]
214#[derive(Clone, Copy, Debug, Pod, Zeroable)]
215pub struct RollSceneSectionAmethyst {
216    pub count: [u8; 8],   // 1 or 10
217    pub seed: [u8; 32],   // From BSM /roll/instruction (Option 7 centralized oracle)
218}
219
220#[repr(C)]
221#[derive(Clone, Copy, Debug, Pod, Zeroable)]
222pub struct RollSceneSectionShards {
223    pub count: [u8; 8],   // 1 or 10
224    pub seed: [u8; 32],   // From BSM /roll/instruction (Option 7 centralized oracle)
225}
226
227/// Single salvage entry: (scene_id, section_id) + count to salvage.
228/// scene_id: 0–8, section_id: 0–11, count: 1–65535.
229#[repr(C)]
230#[derive(Clone, Copy, Debug, Pod, Zeroable)]
231pub struct SalvageItem {
232    pub scene_id: u8,
233    pub section_id: u8,
234    pub count: u16,
235}
236
237/// Salvage duplicate scene sections for Amethyst refund. Single ix handles any amount.
238/// item_count: number of valid entries in items (1–64).
239#[repr(C)]
240#[derive(Clone, Copy, Debug, Pod, Zeroable)]
241pub struct SalvageSceneSection {
242    pub item_count: u8,
243    pub _pad: [u8; 3],
244    pub items: [SalvageItem; 64],
245}
246
247#[repr(C)]
248#[derive(Clone, Copy, Debug, Pod, Zeroable)]
249pub struct BuyChest {}
250
251#[repr(C)]
252#[derive(Clone, Copy, Debug, Pod, Zeroable)]
253pub struct BuyScene {
254    pub scene_id: [u8; 8], // 6, 7, or 8
255}
256
257#[repr(C)]
258#[derive(Clone, Copy, Debug, Pod, Zeroable)]
259pub struct UpdateActiveScene {
260    pub scene_id: [u8; 8],
261}
262
263/// Buy scene (6/7/8) with mixed payment: spend all amethyst, cover shortfall with DOJO.
264#[repr(C)]
265#[derive(Clone, Copy, Debug, Pod, Zeroable)]
266pub struct BuySceneDojo {
267    pub scene_id: [u8; 8],
268}
269
270instruction!(DojosInstruction, Initialize);
271instruction!(DojosInstruction, BuyStarterPack);
272instruction!(DojosInstruction, RecruitShogunTickets);
273instruction!(DojosInstruction, RecruitShogunSol);
274instruction!(DojosInstruction, SeatShogun);
275instruction!(DojosInstruction, ReplaceShogun);
276instruction!(DojosInstruction, Dine);
277instruction!(DojosInstruction, UpgradeBarracksShards);
278instruction!(DojosInstruction, UpgradeBarracksSol);
279instruction!(DojosInstruction, UpgradeForge);
280instruction!(DojosInstruction, MergeShogun);
281instruction!(DojosInstruction, PrestigeUpgrade);
282instruction!(DojosInstruction, ClaimShards);
283instruction!(DojosInstruction, ClaimReferralReward);
284instruction!(DojosInstruction, ClaimRecruitReward);
285instruction!(DojosInstruction, ClaimForgeReward);
286instruction!(DojosInstruction, ClaimDineReward);
287instruction!(DojosInstruction, ClaimDailyReward);
288instruction!(DojosInstruction, ClaimCollectionReward);
289instruction!(DojosInstruction, BuyBundle);
290instruction!(DojosInstruction, BuyTicketsWithShards);
291instruction!(DojosInstruction, BuyFlashSale);
292instruction!(DojosInstruction, ClearForgeCooldown);
293instruction!(DojosInstruction, NewVar);
294instruction!(DojosInstruction, SetGenesisSlot);
295instruction!(DojosInstruction, Log);
296instruction!(DojosInstruction, SetVarAddress);
297instruction!(DojosInstruction, LevelUpShogun);
298instruction!(DojosInstruction, RollSceneSectionAmethyst);
299instruction!(DojosInstruction, RollSceneSectionShards);
300instruction!(DojosInstruction, SalvageSceneSection);
301instruction!(DojosInstruction, BuyChest);
302instruction!(DojosInstruction, BuyScene);
303instruction!(DojosInstruction, UpdateActiveScene);
304instruction!(DojosInstruction, BuySceneDojo);