initializeComponent.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 __setModuleDefault =
  26. (this && this.__setModuleDefault) ||
  27. (Object.create
  28. ? function (o, v) {
  29. Object.defineProperty(o, "default", { enumerable: true, value: v });
  30. }
  31. : function (o, v) {
  32. o["default"] = v;
  33. });
  34. var __importStar =
  35. (this && this.__importStar) ||
  36. function (mod) {
  37. if (mod && mod.__esModule) return mod;
  38. var result = {};
  39. if (mod != null)
  40. for (var k in mod)
  41. if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
  42. __createBinding(result, mod, k);
  43. __setModuleDefault(result, mod);
  44. return result;
  45. };
  46. Object.defineProperty(exports, "__esModule", { value: true });
  47. exports.createInitializeComponentInstruction =
  48. exports.initializeComponentInstructionDiscriminator =
  49. exports.initializeComponentStruct =
  50. void 0;
  51. var beet = __importStar(require("@metaplex-foundation/beet"));
  52. var web3 = __importStar(require("@solana/web3.js"));
  53. var index_1 = require("../index");
  54. exports.initializeComponentStruct = new beet.BeetArgsStruct(
  55. [["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)]],
  56. "InitializeComponentInstructionArgs"
  57. );
  58. exports.initializeComponentInstructionDiscriminator = [
  59. 36, 143, 233, 113, 12, 234, 61, 30,
  60. ];
  61. function createInitializeComponentInstruction(accounts, programId) {
  62. var _a, _b, _c, _d;
  63. if (programId === void 0) {
  64. programId = new web3.PublicKey(
  65. "WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n"
  66. );
  67. }
  68. var data = exports.initializeComponentStruct.serialize({
  69. instructionDiscriminator:
  70. exports.initializeComponentInstructionDiscriminator,
  71. })[0];
  72. var keys = [
  73. {
  74. pubkey: accounts.payer,
  75. isWritable: true,
  76. isSigner: true,
  77. },
  78. {
  79. pubkey:
  80. (_a = accounts.data) !== null && _a !== void 0
  81. ? _a
  82. : (0, index_1.FindComponentPda)(
  83. accounts.componentProgram,
  84. accounts.entity
  85. ),
  86. isWritable: true,
  87. isSigner: false,
  88. },
  89. {
  90. pubkey: accounts.entity,
  91. isWritable: false,
  92. isSigner: false,
  93. },
  94. {
  95. pubkey: accounts.componentProgram,
  96. isWritable: false,
  97. isSigner: false,
  98. },
  99. {
  100. pubkey:
  101. (_b = accounts.authority) !== null && _b !== void 0 ? _b : programId,
  102. isWritable: false,
  103. isSigner: false,
  104. },
  105. {
  106. pubkey:
  107. (_c = accounts.instructionSysvarAccount) !== null && _c !== void 0
  108. ? _c
  109. : index_1.SYSVAR_INSTRUCTIONS_PUBKEY,
  110. isWritable: false,
  111. isSigner: false,
  112. },
  113. {
  114. pubkey:
  115. (_d = accounts.systemProgram) !== null && _d !== void 0
  116. ? _d
  117. : web3.SystemProgram.programId,
  118. isWritable: false,
  119. isSigner: false,
  120. },
  121. ];
  122. if (accounts.anchorRemainingAccounts != null) {
  123. for (
  124. var _i = 0, _e = accounts.anchorRemainingAccounts;
  125. _i < _e.length;
  126. _i++
  127. ) {
  128. var acc = _e[_i];
  129. keys.push(acc);
  130. }
  131. }
  132. var ix = new web3.TransactionInstruction({
  133. programId: programId,
  134. keys: keys,
  135. data: data,
  136. });
  137. return ix;
  138. }
  139. exports.createInitializeComponentInstruction =
  140. createInitializeComponentInstruction;
  141. //# sourceMappingURL=initializeComponent.js.map