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