undelegate.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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.createUndelegateInstruction =
  48. exports.undelegateInstructionDiscriminator =
  49. exports.undelegateStruct =
  50. void 0;
  51. var beet = __importStar(require("@metaplex-foundation/beet"));
  52. var web3 = __importStar(require("@solana/web3.js"));
  53. var accounts_1 = require("./accounts");
  54. var web3_js_1 = require("@solana/web3.js");
  55. exports.undelegateStruct = new beet.FixableBeetArgsStruct(
  56. [["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)]],
  57. "UndelegateInstructionArgs"
  58. );
  59. exports.undelegateInstructionDiscriminator = [3, 0, 0, 0, 0, 0, 0, 0];
  60. function createUndelegateInstruction(accounts, programId) {
  61. var _a, _b, _c, _d, _e, _f;
  62. if (programId === void 0) {
  63. programId = new web3_js_1.PublicKey(accounts_1.DELEGATION_PROGRAM_ID);
  64. }
  65. var data = exports.undelegateStruct.serialize({
  66. instructionDiscriminator: exports.undelegateInstructionDiscriminator,
  67. })[0];
  68. var _g = (0, accounts_1.getDelegationAccounts)(
  69. accounts.delegatedAccount,
  70. accounts.ownerProgram,
  71. false
  72. ),
  73. delegationPda = _g.delegationPda,
  74. delegatedAccountSeedsPda = _g.delegatedAccountSeedsPda,
  75. bufferPda = _g.bufferPda,
  76. commitStateRecordPda = _g.commitStateRecordPda,
  77. commitStatePda = _g.commitStatePda;
  78. var keys = [
  79. {
  80. pubkey: accounts.payer,
  81. isWritable: false,
  82. isSigner: true,
  83. },
  84. {
  85. pubkey: accounts.delegatedAccount,
  86. isWritable: true,
  87. isSigner: false,
  88. },
  89. {
  90. pubkey: accounts.ownerProgram,
  91. isWritable: false,
  92. isSigner: false,
  93. },
  94. {
  95. pubkey: (_a = accounts.buffer) !== null && _a !== void 0 ? _a : bufferPda,
  96. isWritable: true,
  97. isSigner: false,
  98. },
  99. {
  100. pubkey:
  101. (_b = accounts.commitStatePda) !== null && _b !== void 0
  102. ? _b
  103. : commitStatePda,
  104. isWritable: true,
  105. isSigner: false,
  106. },
  107. {
  108. pubkey:
  109. (_c = accounts.commitStateRecordPda) !== null && _c !== void 0
  110. ? _c
  111. : commitStateRecordPda,
  112. isWritable: true,
  113. isSigner: false,
  114. },
  115. {
  116. pubkey:
  117. (_d = accounts.delegationRecord) !== null && _d !== void 0
  118. ? _d
  119. : delegationPda,
  120. isWritable: true,
  121. isSigner: false,
  122. },
  123. {
  124. pubkey:
  125. (_e = accounts.delegateAccountSeeds) !== null && _e !== void 0
  126. ? _e
  127. : delegatedAccountSeedsPda,
  128. isWritable: true,
  129. isSigner: false,
  130. },
  131. {
  132. pubkey: accounts.reimbursement,
  133. isWritable: false,
  134. isSigner: false,
  135. },
  136. {
  137. pubkey:
  138. (_f = accounts.systemProgram) !== null && _f !== void 0
  139. ? _f
  140. : web3.SystemProgram.programId,
  141. isWritable: false,
  142. isSigner: false,
  143. },
  144. ];
  145. return new web3.TransactionInstruction({
  146. programId: programId,
  147. keys: keys,
  148. data: data,
  149. });
  150. }
  151. exports.createUndelegateInstruction = createUndelegateInstruction;
  152. //# sourceMappingURL=undelegate.js.map