index.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. "use strict";
  2. var __createBinding =
  3. (this && this.__createBinding) ||
  4. (Object.create
  5. ? function (o, m, k, k2) {
  6. if (k2 === undefined) k2 = k;
  7. var desc = Object.getOwnPropertyDescriptor(m, k);
  8. if (
  9. !desc ||
  10. ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
  11. ) {
  12. desc = {
  13. enumerable: true,
  14. get: function () {
  15. return m[k];
  16. },
  17. };
  18. }
  19. Object.defineProperty(o, k2, desc);
  20. }
  21. : function (o, m, k, k2) {
  22. if (k2 === undefined) k2 = k;
  23. o[k2] = m[k];
  24. });
  25. var __exportStar =
  26. (this && this.__exportStar) ||
  27. function (m, exports) {
  28. for (var p in m)
  29. if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
  30. __createBinding(exports, m, p);
  31. };
  32. Object.defineProperty(exports, "__esModule", { value: true });
  33. exports.FindComponentPda =
  34. exports.FindEntityPda =
  35. exports.FindWorldPda =
  36. exports.FindWorldRegistryPda =
  37. exports.PROGRAM_ID =
  38. exports.PROGRAM_ADDRESS =
  39. void 0;
  40. var web3_js_1 = require("@solana/web3.js");
  41. __exportStar(require("./accounts"), exports);
  42. __exportStar(require("./instructions"), exports);
  43. exports.PROGRAM_ADDRESS = "WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n";
  44. exports.PROGRAM_ID = new web3_js_1.PublicKey(exports.PROGRAM_ADDRESS);
  45. function FindWorldRegistryPda(programId) {
  46. if (programId === void 0) {
  47. programId = new web3_js_1.PublicKey(exports.PROGRAM_ID);
  48. }
  49. return web3_js_1.PublicKey.findProgramAddressSync(
  50. [Buffer.from("registry")],
  51. programId
  52. )[0];
  53. }
  54. exports.FindWorldRegistryPda = FindWorldRegistryPda;
  55. function FindWorldPda(id, programId) {
  56. if (programId === void 0) {
  57. programId = new web3_js_1.PublicKey(exports.PROGRAM_ID);
  58. }
  59. return web3_js_1.PublicKey.findProgramAddressSync(
  60. [Buffer.from("world"), id.toBuffer("be", 8)],
  61. programId
  62. )[0];
  63. }
  64. exports.FindWorldPda = FindWorldPda;
  65. function FindEntityPda(worldId, entityId, extraSeed, programId) {
  66. if (programId === void 0) {
  67. programId = new web3_js_1.PublicKey(exports.PROGRAM_ID);
  68. }
  69. var seeds = [Buffer.from("entity"), worldId.toBuffer("be", 8)];
  70. if (extraSeed != null) {
  71. seeds.push(Buffer.from(new Uint8Array(8)));
  72. seeds.push(Buffer.from(extraSeed));
  73. } else {
  74. seeds.push(entityId.toBuffer("be", 8));
  75. }
  76. return web3_js_1.PublicKey.findProgramAddressSync(seeds, programId)[0];
  77. }
  78. exports.FindEntityPda = FindEntityPda;
  79. function FindComponentPda(componentProgramId, entity, componentId) {
  80. if (componentId === void 0) {
  81. componentId = "";
  82. }
  83. return web3_js_1.PublicKey.findProgramAddressSync(
  84. [Buffer.from(componentId), entity.toBytes()],
  85. componentProgramId
  86. )[0];
  87. }
  88. exports.FindComponentPda = FindComponentPda;
  89. //# sourceMappingURL=index.js.map