framework.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. export enum Direction {
  2. Left = "Left",
  3. Right = "Right",
  4. Up = "Up",
  5. Down = "Down",
  6. }
  7. import { anchor, BN } from "../clients/bolt-sdk/lib";
  8. import { type World } from "../target/types/world";
  9. import { type Position } from "../target/types/position";
  10. import { type Velocity } from "../target/types/velocity";
  11. import { type SystemSimpleMovement } from "../target/types/system_simple_movement";
  12. import { type SystemFly } from "../target/types/system_fly";
  13. import { type SystemApplyVelocity } from "../target/types/system_apply_velocity";
  14. import { Keypair, PublicKey } from "@solana/web3.js";
  15. export class Framework {
  16. provider: anchor.AnchorProvider;
  17. worldProgram: anchor.Program<World>;
  18. exampleComponentPosition: anchor.Program<Position>;
  19. exampleComponentVelocity: anchor.Program<Velocity>;
  20. systemSimpleMovement: anchor.Program<SystemSimpleMovement>;
  21. systemFly: anchor.Program<SystemFly>;
  22. systemApplyVelocity: anchor.Program<SystemApplyVelocity>;
  23. worldPda: PublicKey;
  24. worldId: BN;
  25. secondAuthority: PublicKey;
  26. entity1Pda: PublicKey;
  27. entity2Pda: PublicKey;
  28. entity4Pda: PublicKey;
  29. componentPositionEntity1Pda: PublicKey;
  30. componentVelocityEntity1Pda: PublicKey;
  31. componentPositionEntity4Pda: PublicKey;
  32. constructor() {
  33. this.secondAuthority = Keypair.generate().publicKey;
  34. this.worldProgram = anchor.workspace.World;
  35. this.exampleComponentPosition = anchor.workspace.Position;
  36. this.exampleComponentVelocity = anchor.workspace.Velocity;
  37. this.systemSimpleMovement = anchor.workspace.SystemSimpleMovement;
  38. this.systemFly = anchor.workspace.SystemFly;
  39. this.systemApplyVelocity = anchor.workspace.SystemApplyVelocity;
  40. this.provider = anchor.AnchorProvider.env();
  41. anchor.setProvider(this.provider);
  42. }
  43. }