instructions.ts 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. Create,
  11. Mint,
  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. kind: 'struct',
  22. fields: [
  23. ['instruction', 'u8'],
  24. ['nft_title', 'string'],
  25. ['nft_symbol', 'string'],
  26. ['nft_uri', 'string'],
  27. ]
  28. }
  29. ]
  30. ]);
  31. export class MintToArgs extends Assignable {
  32. toBuffer() {
  33. return Buffer.from(borsh.serialize(MintToArgsSchema, this));
  34. }
  35. };
  36. const MintToArgsSchema = new Map([
  37. [
  38. MintToArgs, {
  39. kind: 'struct',
  40. fields: [
  41. ['instruction', 'u8'],
  42. ]
  43. }
  44. ]
  45. ]);