1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import * as borsh from "borsh";
- import { Buffer } from "buffer";
- export class AddressInfo {
- name: string;
- house_number: number;
- street: string;
- city: string;
- constructor(props: {
- name: string,
- house_number: number,
- street: string,
- city: string,
- }) {
- this.name = props.name;
- this.house_number = props.house_number;
- this.street = props.street;
- this.city = props.city;
- }
- toBase58() {
- return borsh.serialize(AddressInfoSchema, this).toString()
- };
- toBuffer() {
- return Buffer.from(borsh.serialize(AddressInfoSchema, this))
- };
-
- static fromBuffer(buffer: Buffer) {
- return borsh.deserialize(AddressInfoSchema, AddressInfo, buffer);
- };
- };
- export const AddressInfoSchema = new Map([
- [ AddressInfo, {
- kind: 'struct',
- fields: [
- ['name', 'string'],
- ['house_number', 'u8'],
- ['street', 'string'],
- ['city', 'string'],
- ],
- }]
- ]);
|