instructions.ts 969 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import * as borsh from 'borsh';
  2. class Assignable {
  3. constructor(properties) {
  4. for (const [key, value] of Object.entries(properties)) {
  5. this[key] = value;
  6. }
  7. }
  8. }
  9. export enum SplMinterInstruction {
  10. Create = 0,
  11. Mint = 1,
  12. }
  13. export class CreateTokenArgs extends Assignable {
  14. toBuffer() {
  15. return Buffer.from(borsh.serialize(CreateTokenArgsSchema, this));
  16. }
  17. }
  18. const CreateTokenArgsSchema = new Map([
  19. [
  20. CreateTokenArgs,
  21. {
  22. kind: 'struct',
  23. fields: [
  24. ['instruction', 'u8'],
  25. ['token_title', 'string'],
  26. ['token_symbol', 'string'],
  27. ['token_uri', 'string'],
  28. ],
  29. },
  30. ],
  31. ]);
  32. export class MintToArgs extends Assignable {
  33. toBuffer() {
  34. return Buffer.from(borsh.serialize(MintToArgsSchema, this));
  35. }
  36. }
  37. const MintToArgsSchema = new Map([
  38. [
  39. MintToArgs,
  40. {
  41. kind: 'struct',
  42. fields: [
  43. ['instruction', 'u8'],
  44. ['quantity', 'u64'],
  45. ],
  46. },
  47. ],
  48. ]);