addEntity.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /**
  2. * This code was GENERATED using the solita package.
  3. * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality.
  4. *
  5. * See: https://github.com/metaplex-foundation/solita
  6. */
  7. import * as beet from "@metaplex-foundation/beet";
  8. import * as web3 from "@solana/web3.js";
  9. /**
  10. * @category Instructions
  11. * @category AddEntity
  12. * @category generated
  13. */
  14. export interface AddEntityInstructionArgs {
  15. seed: beet.COption<string>;
  16. }
  17. /**
  18. * @category Instructions
  19. * @category AddEntity
  20. * @category generated
  21. */
  22. export const addEntityStruct = new beet.FixableBeetArgsStruct<
  23. AddEntityInstructionArgs & {
  24. instructionDiscriminator: number[] /* size: 8 */;
  25. }
  26. >(
  27. [
  28. ["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)],
  29. ["seed", beet.coption(beet.utf8String)],
  30. ],
  31. "AddEntityInstructionArgs"
  32. );
  33. /**
  34. * Accounts required by the _addEntity_ instruction
  35. *
  36. * @property [_writable_, **signer**] payer
  37. * @property [_writable_] entity
  38. * @property [_writable_] world
  39. * @category Instructions
  40. * @category AddEntity
  41. * @category generated
  42. */
  43. export interface AddEntityInstructionAccounts {
  44. payer: web3.PublicKey;
  45. entity: web3.PublicKey;
  46. world: web3.PublicKey;
  47. systemProgram?: web3.PublicKey;
  48. anchorRemainingAccounts?: web3.AccountMeta[];
  49. }
  50. export const addEntityInstructionDiscriminator = [
  51. 163, 241, 57, 35, 244, 244, 48, 57,
  52. ];
  53. /**
  54. * Creates a _AddEntity_ instruction.
  55. *
  56. * @param accounts that will be accessed while the instruction is processed
  57. * @param args to provide as instruction data to the program
  58. *
  59. * @category Instructions
  60. * @category AddEntity
  61. * @category generated
  62. */
  63. export function createAddEntityInstruction(
  64. accounts: AddEntityInstructionAccounts,
  65. args: AddEntityInstructionArgs,
  66. programId = new web3.PublicKey("WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n")
  67. ) {
  68. const [data] = addEntityStruct.serialize({
  69. instructionDiscriminator: addEntityInstructionDiscriminator,
  70. ...args,
  71. });
  72. const keys: web3.AccountMeta[] = [
  73. {
  74. pubkey: accounts.payer,
  75. isWritable: true,
  76. isSigner: true,
  77. },
  78. {
  79. pubkey: accounts.entity,
  80. isWritable: true,
  81. isSigner: false,
  82. },
  83. {
  84. pubkey: accounts.world,
  85. isWritable: true,
  86. isSigner: false,
  87. },
  88. {
  89. pubkey: accounts.systemProgram ?? web3.SystemProgram.programId,
  90. isWritable: false,
  91. isSigner: false,
  92. },
  93. ];
  94. if (accounts.anchorRemainingAccounts != null) {
  95. for (const acc of accounts.anchorRemainingAccounts) {
  96. keys.push(acc);
  97. }
  98. }
  99. const ix = new web3.TransactionInstruction({
  100. programId,
  101. keys,
  102. data,
  103. });
  104. return ix;
  105. }