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