BookRental.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. import { BookRentalArgs, bookRentalArgsBeet } from '../types/BookRentalArgs'
  10. /**
  11. * @category Instructions
  12. * @category BookRental
  13. * @category generated
  14. */
  15. export type BookRentalInstructionArgs = {
  16. bookRentalArgs: BookRentalArgs
  17. }
  18. /**
  19. * @category Instructions
  20. * @category BookRental
  21. * @category generated
  22. */
  23. export const BookRentalStruct = new beet.FixableBeetArgsStruct<
  24. BookRentalInstructionArgs & {
  25. instructionDiscriminator: number
  26. }
  27. >(
  28. [
  29. ['instructionDiscriminator', beet.u8],
  30. ['bookRentalArgs', bookRentalArgsBeet],
  31. ],
  32. 'BookRentalInstructionArgs'
  33. )
  34. /**
  35. * Accounts required by the _BookRental_ instruction
  36. *
  37. * @property [_writable_] rentalAccount The account that will represent the actual order for the rental
  38. * @property [] carAccount The account representing the Car being rented in this order
  39. * @property [_writable_] payer Fee payer
  40. * @category Instructions
  41. * @category BookRental
  42. * @category generated
  43. */
  44. export type BookRentalInstructionAccounts = {
  45. rentalAccount: web3.PublicKey
  46. carAccount: web3.PublicKey
  47. payer: web3.PublicKey
  48. systemProgram?: web3.PublicKey
  49. }
  50. export const bookRentalInstructionDiscriminator = 1
  51. /**
  52. * Creates a _BookRental_ instruction.
  53. *
  54. * @param accounts that will be accessed while the instruction is processed
  55. * @param args to provide as instruction data to the program
  56. *
  57. * @category Instructions
  58. * @category BookRental
  59. * @category generated
  60. */
  61. export function createBookRentalInstruction(
  62. accounts: BookRentalInstructionAccounts,
  63. args: BookRentalInstructionArgs,
  64. programId = new web3.PublicKey('8avNGHVXDwsELJaWMSoUZ44CirQd4zyU9Ez4ZmP4jNjZ')
  65. ) {
  66. const [data] = BookRentalStruct.serialize({
  67. instructionDiscriminator: bookRentalInstructionDiscriminator,
  68. ...args,
  69. })
  70. const keys: web3.AccountMeta[] = [
  71. {
  72. pubkey: accounts.rentalAccount,
  73. isWritable: true,
  74. isSigner: false,
  75. },
  76. {
  77. pubkey: accounts.carAccount,
  78. isWritable: false,
  79. isSigner: false,
  80. },
  81. {
  82. pubkey: accounts.payer,
  83. isWritable: true,
  84. isSigner: false,
  85. },
  86. {
  87. pubkey: accounts.systemProgram ?? web3.SystemProgram.programId,
  88. isWritable: false,
  89. isSigner: false,
  90. },
  91. ]
  92. const ix = new web3.TransactionInstruction({
  93. programId,
  94. keys,
  95. data,
  96. })
  97. return ix
  98. }