work-info.ts 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import * as borsh from "borsh";
  2. import { Buffer } from "buffer";
  3. export class WorkInfo {
  4. name: string;
  5. position: string;
  6. company: string;
  7. years_employed: number;
  8. constructor(props: {
  9. name: string,
  10. position: string,
  11. company: string,
  12. years_employed: number,
  13. }) {
  14. this.name = props.name;
  15. this.position = props.position;
  16. this.company = props.company;
  17. this.years_employed = props.years_employed;
  18. }
  19. toBase58() {
  20. return borsh.serialize(WorkInfoSchema, this).toString()
  21. };
  22. toBuffer() {
  23. return Buffer.from(borsh.serialize(WorkInfoSchema, this))
  24. };
  25. static fromBuffer(buffer: Buffer) {
  26. return borsh.deserialize(WorkInfoSchema, WorkInfo, buffer);
  27. };
  28. };
  29. export const WorkInfoSchema = new Map([
  30. [ WorkInfo, {
  31. kind: 'struct',
  32. fields: [
  33. ['name', 'string'],
  34. ['position', 'string'],
  35. ['company', 'string'],
  36. ['years_employed', 'u8'],
  37. ],
  38. }]
  39. ]);