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    SeatShogunFillAll = 41,
16    ReplaceShogun = 34,
17    Dine = 5,
18    UpgradeBarracksShards = 7,
19    UpgradeBarracksSol = 26,
20    UpgradeForge = 8,
21    MergeShogun = 9,
22    PrestigeUpgrade = 10,
23    PrestigeFodderShogun = 42,
24    ClaimShards = 11,
25    ClaimReferralReward = 12,
26    ClaimRecruitReward = 36,
27    ClaimForgeReward = 37,
28    ClaimDineReward = 38,
29    ClaimDailyReward = 39,
30    ClaimCollectionReward = 40,
31    ClaimOffChainTaskReward = 43,
32    ClaimSeekerTaskReward = 44,
33    BuyBundle = 13,
34    BuyTicketsWithShards = 22,
35    BuyFlashSale = 24,
36    ClearForgeCooldown = 15,
37    Log = 20,
38    LevelUpShogun = 25,
39    RollSceneSectionAmethyst = 27,
40    RollSceneSectionShards = 31,
41    SalvageSceneSection = 28,
42    BuyChest = 29,
43    BuyScene = 33,
44    UpdateActiveScene = 30,
45    BuySceneDojo = 35,
46
47    // Admin
48    Initialize = 0,
49    SetGenesisSlot = 19,
50}
51
52#[repr(C)]
53#[derive(Clone, Copy, Debug, Pod, Zeroable)]
54pub struct Initialize {}
55
56#[repr(C)]
57#[derive(Clone, Copy, Debug, Pod, Zeroable)]
58pub struct BuyStarterPack {
59    pub referrer: [u8; 32], // Option<Pubkey> as bytes; [0u8;32] = None
60}
61
62#[repr(C)]
63#[derive(Clone, Copy, Debug, Pod, Zeroable)]
64pub struct RecruitShogunTickets {
65    pub count: [u8; 8],   // 1 or 10
66    pub seed: [u8; 32],   // From BSM /recruit/seed (Option 7 centralized oracle)
67}
68
69#[repr(C)]
70#[derive(Clone, Copy, Debug, Pod, Zeroable)]
71pub struct RecruitShogunSol {
72    pub count: [u8; 8],   // 1 or 10
73    pub seed: [u8; 32],   // From BSM /recruit/seed (Option 7 centralized oracle)
74}
75
76/// Seat: promote one from fodder to barracks slot. rarity 0-4, element 0-4.
77#[repr(C)]
78#[derive(Clone, Copy, Debug, Pod, Zeroable)]
79pub struct SeatShogun {
80    pub slot: [u8; 8],
81    pub rarity: [u8; 8],
82    pub element: [u8; 8],
83}
84
85/// Per-seat entry for fill-all. Promotes from fodder to first empty slot.
86#[repr(C)]
87#[derive(Clone, Copy, Debug, Pod, Zeroable)]
88pub struct SeatShogunFillAllEntry {
89    pub rarity: [u8; 8],
90    pub element: [u8; 8],
91}
92
93/// Batch seat: up to 12 shoguns into empty slots. Slots inferred: first empty, second empty, ...
94#[repr(C)]
95#[derive(Clone, Copy, Debug, Pod, Zeroable)]
96pub struct SeatShogunFillAll {
97    pub count: u8,
98    pub _pad: [u8; 7],
99    pub entries: [SeatShogunFillAllEntry; 12],
100}
101
102/// Replace: return old to fodder, promote new from fodder. Same slot.
103#[repr(C)]
104#[derive(Clone, Copy, Debug, Pod, Zeroable)]
105pub struct ReplaceShogun {
106    pub slot: [u8; 8],
107    pub new_rarity: [u8; 8],
108    pub new_element: [u8; 8],
109}
110
111/// Dine: restore chakra for seated shogun. tier 0=24h, 1=48h, 2=72h.
112#[repr(C)]
113#[derive(Clone, Copy, Debug, Pod, Zeroable)]
114pub struct Dine {
115    pub tier: [u8; 8],
116    pub slot: [u8; 8],
117}
118
119#[repr(C)]
120#[derive(Clone, Copy, Debug, Pod, Zeroable)]
121pub struct UpgradeBarracksShards {}
122
123#[repr(C)]
124#[derive(Clone, Copy, Debug, Pod, Zeroable)]
125pub struct UpgradeBarracksSol {}
126
127#[repr(C)]
128#[derive(Clone, Copy, Debug, Pod, Zeroable)]
129pub struct UpgradeForge {}
130
131/// Merge: consume from fodder_counts, add new. seed from BSM /merge.
132#[repr(C)]
133#[derive(Clone, Copy, Debug, Pod, Zeroable)]
134pub struct MergeShogun {
135    pub merge_type: [u8; 8], // 0=10×N, 1=5×R, 2=3×SR
136    pub seed: [u8; 32],
137}
138
139/// Prestige: consume 2 from fodder_counts[rarity], upgrade seated shogun in slot.
140#[repr(C)]
141#[derive(Clone, Copy, Debug, Pod, Zeroable)]
142pub struct PrestigeUpgrade {
143    pub slot: [u8; 8],
144}
145
146/// Prestige fodder: upgrade SSR/UR in fodder (not seated). Lazy init: creates Prestige if missing.
147#[repr(C)]
148#[derive(Clone, Copy, Debug, Pod, Zeroable)]
149pub struct PrestigeFodderShogun {
150    /// element×5 + rarity (0–24). SSR/UR only (rarity 3 or 4).
151    pub collection_index: u8,
152    pub _pad: [u8; 7],
153    /// Prestige level to upgrade from (1–6). Upgrades to prestige+1.
154    pub from_prestige: [u8; 8],
155}
156
157/// Level up: increase level of seated shogun. Burns shards.
158#[repr(C)]
159#[derive(Clone, Copy, Debug, Pod, Zeroable)]
160pub struct LevelUpShogun {
161    pub slot: [u8; 8],
162}
163
164#[repr(C)]
165#[derive(Clone, Copy, Debug, Pod, Zeroable)]
166pub struct ClaimShards {} // Amount computed on-chain from ore; no client input (security).
167
168#[repr(C)]
169#[derive(Clone, Copy, Debug, Pod, Zeroable)]
170pub struct ClaimReferralReward {}
171
172#[repr(C)]
173#[derive(Clone, Copy, Debug, Pod, Zeroable)]
174pub struct ClaimRecruitReward {}
175
176#[repr(C)]
177#[derive(Clone, Copy, Debug, Pod, Zeroable)]
178pub struct ClaimForgeReward {}
179
180#[repr(C)]
181#[derive(Clone, Copy, Debug, Pod, Zeroable)]
182pub struct ClaimDineReward {}
183
184#[repr(C)]
185#[derive(Clone, Copy, Debug, Pod, Zeroable)]
186pub struct ClaimDailyReward {
187    pub signature: [u8; 64],
188}
189
190#[repr(C)]
191#[derive(Clone, Copy, Debug, Pod, Zeroable)]
192pub struct ClaimCollectionReward {
193    /// element×5 + rarity (0–24). Program finds 3 matching shoguns in pool.
194    pub collection_index: u8,
195}
196
197/// Off-chain task (9–16): BSM signs; one-time claim per task.
198#[repr(C)]
199#[derive(Clone, Copy, Debug, Pod, Zeroable)]
200pub struct ClaimOffChainTaskReward {
201    pub task_id: [u8; 8],
202    pub signature: [u8; 64],
203}
204
205/// Seeker task: verify user owns SGT (Seeker Genesis Token) on-chain; one-time claim.
206#[repr(C)]
207#[derive(Clone, Copy, Debug, Pod, Zeroable)]
208pub struct ClaimSeekerTaskReward {}
209
210#[repr(C)]
211#[derive(Clone, Copy, Debug, Pod, Zeroable)]
212pub struct BuyBundle {} // Fixed bundle: TICKET_BUNDLE_SOL for TICKET_BUNDLE_TICKETS
213
214#[repr(C)]
215#[derive(Clone, Copy, Debug, Pod, Zeroable)]
216pub struct BuyTicketsWithShards {} // Fixed: 5 tickets for 300 shards (daily deal)
217
218#[repr(C)]
219#[derive(Clone, Copy, Debug, Pod, Zeroable)]
220pub struct BuyFlashSale {} // Flash sale: 50 tickets for 5000 shards, max 5/day
221
222#[repr(C)]
223#[derive(Clone, Copy, Debug, Pod, Zeroable)]
224pub struct ClearForgeCooldown {}
225
226#[repr(C)]
227#[derive(Clone, Copy, Debug, Pod, Zeroable)]
228pub struct SetGenesisSlot {
229    pub genesis_slot: [u8; 8],
230    /// Slots per halving period. 0 = use HALVING_PERIOD_SLOTS_DEFAULT (~58 days, matches Hyper Ninja).
231    pub halving_period_slots: [u8; 8],
232}
233
234#[repr(C)]
235#[derive(Clone, Copy, Debug, Pod, Zeroable)]
236pub struct Log {
237    pub _reserved: [u8; 8], // Variable-length log; remaining bytes are message
238}
239
240#[repr(C)]
241#[derive(Clone, Copy, Debug, Pod, Zeroable)]
242pub struct RollSceneSectionAmethyst {
243    pub count: [u8; 8],   // 1 or 10
244    pub seed: [u8; 32],   // From BSM /roll/instruction (Option 7 centralized oracle)
245}
246
247#[repr(C)]
248#[derive(Clone, Copy, Debug, Pod, Zeroable)]
249pub struct RollSceneSectionShards {
250    pub count: [u8; 8],   // 1 or 10
251    pub seed: [u8; 32],   // From BSM /roll/instruction (Option 7 centralized oracle)
252}
253
254/// Salvage all duplicate scene sections for Amethyst refund. Program derives from on-chain state.
255#[repr(C)]
256#[derive(Clone, Copy, Debug, Pod, Zeroable)]
257pub struct SalvageSceneSection {}
258
259#[repr(C)]
260#[derive(Clone, Copy, Debug, Pod, Zeroable)]
261pub struct BuyChest {}
262
263#[repr(C)]
264#[derive(Clone, Copy, Debug, Pod, Zeroable)]
265pub struct BuyScene {
266    pub scene_id: [u8; 8], // 6, 7, or 8
267}
268
269#[repr(C)]
270#[derive(Clone, Copy, Debug, Pod, Zeroable)]
271pub struct UpdateActiveScene {
272    pub scene_id: [u8; 8],
273}
274
275/// Buy scene (6/7/8) with mixed payment: spend all amethyst, cover shortfall with DOJO.
276#[repr(C)]
277#[derive(Clone, Copy, Debug, Pod, Zeroable)]
278pub struct BuySceneDojo {
279    pub scene_id: [u8; 8],
280}
281
282instruction!(DojosInstruction, Initialize);
283instruction!(DojosInstruction, BuyStarterPack);
284instruction!(DojosInstruction, RecruitShogunTickets);
285instruction!(DojosInstruction, RecruitShogunSol);
286instruction!(DojosInstruction, SeatShogun);
287instruction!(DojosInstruction, SeatShogunFillAll);
288instruction!(DojosInstruction, ReplaceShogun);
289instruction!(DojosInstruction, Dine);
290instruction!(DojosInstruction, UpgradeBarracksShards);
291instruction!(DojosInstruction, UpgradeBarracksSol);
292instruction!(DojosInstruction, UpgradeForge);
293instruction!(DojosInstruction, MergeShogun);
294instruction!(DojosInstruction, PrestigeUpgrade);
295instruction!(DojosInstruction, PrestigeFodderShogun);
296instruction!(DojosInstruction, ClaimShards);
297instruction!(DojosInstruction, ClaimReferralReward);
298instruction!(DojosInstruction, ClaimRecruitReward);
299instruction!(DojosInstruction, ClaimForgeReward);
300instruction!(DojosInstruction, ClaimDineReward);
301instruction!(DojosInstruction, ClaimDailyReward);
302instruction!(DojosInstruction, ClaimCollectionReward);
303instruction!(DojosInstruction, ClaimOffChainTaskReward);
304instruction!(DojosInstruction, ClaimSeekerTaskReward);
305instruction!(DojosInstruction, BuyBundle);
306instruction!(DojosInstruction, BuyTicketsWithShards);
307instruction!(DojosInstruction, BuyFlashSale);
308instruction!(DojosInstruction, ClearForgeCooldown);
309instruction!(DojosInstruction, SetGenesisSlot);
310instruction!(DojosInstruction, Log);
311instruction!(DojosInstruction, LevelUpShogun);
312instruction!(DojosInstruction, RollSceneSectionAmethyst);
313instruction!(DojosInstruction, RollSceneSectionShards);
314instruction!(DojosInstruction, SalvageSceneSection);
315instruction!(DojosInstruction, BuyChest);
316instruction!(DojosInstruction, BuyScene);
317instruction!(DojosInstruction, UpdateActiveScene);
318instruction!(DojosInstruction, BuySceneDojo);