index.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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.SYSVAR_INSTRUCTIONS_PUBKEY =
  39. exports.PROGRAM_ADDRESS =
  40. void 0;
  41. var web3_js_1 = require("@solana/web3.js");
  42. __exportStar(require("./accounts"), exports);
  43. __exportStar(require("./instructions"), exports);
  44. exports.PROGRAM_ADDRESS = "WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n";
  45. exports.SYSVAR_INSTRUCTIONS_PUBKEY = new web3_js_1.PublicKey(
  46. "Sysvar1nstructions1111111111111111111111111"
  47. );
  48. exports.PROGRAM_ID = new web3_js_1.PublicKey(exports.PROGRAM_ADDRESS);
  49. function FindWorldRegistryPda(programId) {
  50. if (programId === void 0) {
  51. programId = new web3_js_1.PublicKey(exports.PROGRAM_ID);
  52. }
  53. return web3_js_1.PublicKey.findProgramAddressSync(
  54. [Buffer.from("registry")],
  55. programId
  56. )[0];
  57. }
  58. exports.FindWorldRegistryPda = FindWorldRegistryPda;
  59. function FindWorldPda(id, programId) {
  60. if (programId === void 0) {
  61. programId = new web3_js_1.PublicKey(exports.PROGRAM_ID);
  62. }
  63. return web3_js_1.PublicKey.findProgramAddressSync(
  64. [Buffer.from("world"), id.toBuffer("be", 8)],
  65. programId
  66. )[0];
  67. }
  68. exports.FindWorldPda = FindWorldPda;
  69. function FindEntityPda(worldId, entityId, extraSeed, programId) {
  70. if (programId === void 0) {
  71. programId = new web3_js_1.PublicKey(exports.PROGRAM_ID);
  72. }
  73. var seeds = [Buffer.from("entity"), worldId.toBuffer("be", 8)];
  74. if (extraSeed != null) {
  75. seeds.push(Buffer.from(new Uint8Array(8)));
  76. seeds.push(Buffer.from(extraSeed));
  77. } else {
  78. seeds.push(entityId.toBuffer("be", 8));
  79. }
  80. return web3_js_1.PublicKey.findProgramAddressSync(seeds, programId)[0];
  81. }
  82. exports.FindEntityPda = FindEntityPda;
  83. function FindComponentPda(componentProgramId, entity, componentId) {
  84. if (componentId === void 0) {
  85. componentId = "";
  86. }
  87. return web3_js_1.PublicKey.findProgramAddressSync(
  88. [Buffer.from(componentId), entity.toBytes()],
  89. componentProgramId
  90. )[0];
  91. }
  92. exports.FindComponentPda = FindComponentPda;
  93. //# sourceMappingURL=index.js.map