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