|
| 1 | +import type { SchemaType as ISchemaType } from "@dojoengine/sdk"; |
| 2 | + |
| 3 | +import { |
| 4 | + CairoCustomEnum, |
| 5 | + CairoOption, |
| 6 | + CairoOptionVariant, |
| 7 | + BigNumberish, |
| 8 | +} from "starknet"; |
| 9 | + |
| 10 | +type WithFieldOrder<T> = T & { fieldOrder: string[] }; |
| 11 | + |
| 12 | +// Type definition for `dojo_starter::models::DirectionsAvailable` struct |
| 13 | +export interface DirectionsAvailable { |
| 14 | + player: string; |
| 15 | + directions: Array<DirectionEnum>; |
| 16 | +} |
| 17 | + |
| 18 | +// Type definition for `dojo_starter::models::DirectionsAvailableValue` struct |
| 19 | +export interface DirectionsAvailableValue { |
| 20 | + directions: Array<DirectionEnum>; |
| 21 | +} |
| 22 | + |
| 23 | +// Type definition for `dojo_starter::models::Moves` struct |
| 24 | +export interface Moves { |
| 25 | + player: string; |
| 26 | + remaining: BigNumberish; |
| 27 | + last_direction: CairoOption<DirectionEnum>; |
| 28 | + can_move: boolean; |
| 29 | +} |
| 30 | + |
| 31 | +// Type definition for `dojo_starter::models::MovesValue` struct |
| 32 | +export interface MovesValue { |
| 33 | + remaining: BigNumberish; |
| 34 | + last_direction: CairoOption<DirectionEnum>; |
| 35 | + can_move: boolean; |
| 36 | +} |
| 37 | + |
| 38 | +// Type definition for `dojo_starter::models::Position` struct |
| 39 | +export interface Position { |
| 40 | + player: string; |
| 41 | + vec: Vec2; |
| 42 | +} |
| 43 | + |
| 44 | +// Type definition for `dojo_starter::models::PositionValue` struct |
| 45 | +export interface PositionValue { |
| 46 | + vec: Vec2; |
| 47 | +} |
| 48 | + |
| 49 | +// Type definition for `dojo_starter::models::Vec2` struct |
| 50 | +export interface Vec2 { |
| 51 | + x: BigNumberish; |
| 52 | + y: BigNumberish; |
| 53 | +} |
| 54 | + |
| 55 | +// Type definition for `dojo_starter::systems::actions::actions::Moved` struct |
| 56 | +export interface Moved { |
| 57 | + player: string; |
| 58 | + direction: DirectionEnum; |
| 59 | +} |
| 60 | + |
| 61 | +// Type definition for `dojo_starter::systems::actions::actions::MovedValue` struct |
| 62 | +export interface MovedValue { |
| 63 | + direction: DirectionEnum; |
| 64 | +} |
| 65 | + |
| 66 | +// Type definition for `dojo_starter::models::Direction` enum |
| 67 | +export type Direction = { |
| 68 | + Left: string; |
| 69 | + Right: string; |
| 70 | + Up: string; |
| 71 | + Down: string; |
| 72 | +}; |
| 73 | +export type DirectionEnum = CairoCustomEnum; |
| 74 | + |
| 75 | +export interface SchemaType extends ISchemaType { |
| 76 | + dojo_starter: { |
| 77 | + DirectionsAvailable: WithFieldOrder<DirectionsAvailable>; |
| 78 | + DirectionsAvailableValue: WithFieldOrder<DirectionsAvailableValue>; |
| 79 | + Moves: WithFieldOrder<Moves>; |
| 80 | + MovesValue: WithFieldOrder<MovesValue>; |
| 81 | + Position: WithFieldOrder<Position>; |
| 82 | + PositionValue: WithFieldOrder<PositionValue>; |
| 83 | + Vec2: WithFieldOrder<Vec2>; |
| 84 | + Moved: WithFieldOrder<Moved>; |
| 85 | + MovedValue: WithFieldOrder<MovedValue>; |
| 86 | + }; |
| 87 | +} |
| 88 | +export const schema: SchemaType = { |
| 89 | + dojo_starter: { |
| 90 | + DirectionsAvailable: { |
| 91 | + fieldOrder: ["player", "directions"], |
| 92 | + player: "", |
| 93 | + directions: [ |
| 94 | + new CairoCustomEnum({ |
| 95 | + Left: "", |
| 96 | + Right: undefined, |
| 97 | + Up: undefined, |
| 98 | + Down: undefined, |
| 99 | + }), |
| 100 | + ], |
| 101 | + }, |
| 102 | + DirectionsAvailableValue: { |
| 103 | + fieldOrder: ["directions"], |
| 104 | + directions: [ |
| 105 | + new CairoCustomEnum({ |
| 106 | + Left: "", |
| 107 | + Right: undefined, |
| 108 | + Up: undefined, |
| 109 | + Down: undefined, |
| 110 | + }), |
| 111 | + ], |
| 112 | + }, |
| 113 | + Moves: { |
| 114 | + fieldOrder: ["player", "remaining", "last_direction", "can_move"], |
| 115 | + player: "", |
| 116 | + remaining: 0, |
| 117 | + last_direction: new CairoOption(CairoOptionVariant.None), |
| 118 | + can_move: false, |
| 119 | + }, |
| 120 | + MovesValue: { |
| 121 | + fieldOrder: ["remaining", "last_direction", "can_move"], |
| 122 | + remaining: 0, |
| 123 | + last_direction: new CairoOption(CairoOptionVariant.None), |
| 124 | + can_move: false, |
| 125 | + }, |
| 126 | + Position: { |
| 127 | + fieldOrder: ["player", "vec"], |
| 128 | + player: "", |
| 129 | + vec: { x: 0, y: 0 }, |
| 130 | + }, |
| 131 | + PositionValue: { |
| 132 | + fieldOrder: ["vec"], |
| 133 | + vec: { x: 0, y: 0 }, |
| 134 | + }, |
| 135 | + Vec2: { |
| 136 | + fieldOrder: ["x", "y"], |
| 137 | + x: 0, |
| 138 | + y: 0, |
| 139 | + }, |
| 140 | + Moved: { |
| 141 | + fieldOrder: ["player", "direction"], |
| 142 | + player: "", |
| 143 | + direction: new CairoCustomEnum({ |
| 144 | + Left: "", |
| 145 | + Right: undefined, |
| 146 | + Up: undefined, |
| 147 | + Down: undefined, |
| 148 | + }), |
| 149 | + }, |
| 150 | + MovedValue: { |
| 151 | + fieldOrder: ["direction"], |
| 152 | + direction: new CairoCustomEnum({ |
| 153 | + Left: "", |
| 154 | + Right: undefined, |
| 155 | + Up: undefined, |
| 156 | + Down: undefined, |
| 157 | + }), |
| 158 | + }, |
| 159 | + }, |
| 160 | +}; |
| 161 | +export enum ModelsMapping { |
| 162 | + Direction = "dojo_starter-Direction", |
| 163 | + DirectionsAvailable = "dojo_starter-DirectionsAvailable", |
| 164 | + DirectionsAvailableValue = "dojo_starter-DirectionsAvailableValue", |
| 165 | + Moves = "dojo_starter-Moves", |
| 166 | + MovesValue = "dojo_starter-MovesValue", |
| 167 | + Position = "dojo_starter-Position", |
| 168 | + PositionValue = "dojo_starter-PositionValue", |
| 169 | + Vec2 = "dojo_starter-Vec2", |
| 170 | + Moved = "dojo_starter-Moved", |
| 171 | + MovedValue = "dojo_starter-MovedValue", |
| 172 | +} |
0 commit comments