AddCar.ts 2.3 KB

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