instructions.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import * as borsh from "borsh";
  2. class Assignable {
  3. constructor(properties) {
  4. Object.keys(properties).map((key) => {
  5. return (this[key] = properties[key]);
  6. });
  7. };
  8. };
  9. export enum NftMinterInstruction {
  10. Init,
  11. Create,
  12. Mint,
  13. }
  14. export class InitArgs extends Assignable {
  15. toBuffer() {
  16. return Buffer.from(borsh.serialize(InitArgsSchema, this));
  17. }
  18. }
  19. const InitArgsSchema = new Map([
  20. [
  21. InitArgs, {
  22. kind: 'struct',
  23. fields: [
  24. ['instruction', 'u8'],
  25. ]
  26. }
  27. ]
  28. ]);
  29. export class CreateTokenArgs extends Assignable {
  30. toBuffer() {
  31. return Buffer.from(borsh.serialize(CreateTokenArgsSchema, this));
  32. }
  33. };
  34. const CreateTokenArgsSchema = new Map([
  35. [
  36. CreateTokenArgs, {
  37. kind: 'struct',
  38. fields: [
  39. ['instruction', 'u8'],
  40. ['nft_title', 'string'],
  41. ['nft_symbol', 'string'],
  42. ['nft_uri', 'string'],
  43. ]
  44. }
  45. ]
  46. ]);
  47. export class MintToArgs extends Assignable {
  48. toBuffer() {
  49. return Buffer.from(borsh.serialize(MintToArgsSchema, this));
  50. }
  51. };
  52. const MintToArgsSchema = new Map([
  53. [
  54. MintToArgs, {
  55. kind: 'struct',
  56. fields: [
  57. ['instruction', 'u8'],
  58. ]
  59. }
  60. ]
  61. ]);