Skip to content

Commit

Permalink
added schema
Browse files Browse the repository at this point in the history
  • Loading branch information
gagdiez committed Aug 5, 2024
1 parent a84b240 commit e2b2014
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions contract-ts/src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class GuestBook {
messages: Vector<PostedMessage> = new Vector<PostedMessage>("v-uid");

static schema = {
'messages': Vector<PostedMessage>
'messages': { class: Vector, value: PostedMessage }
}

@call({ payableFunction: true })
Expand All @@ -16,7 +16,7 @@ class GuestBook {
const premium = near.attachedDeposit() >= BigInt(POINT_ONE);
const sender = near.predecessorAccountId();

const message: PostedMessage = { premium, sender, text };
const message = new PostedMessage(premium, sender, text);
this.messages.push(message);
}

Expand Down
6 changes: 4 additions & 2 deletions contract-ts/src/model.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { near } from "near-sdk-js";

export const POINT_ONE = '100000000000000000000000';

export class PostedMessage {
static schema = {
'premium': 'boolean',
'sender': 'string',
'text': 'string'
'text': 'string',
}

premium: boolean;
sender: string;
text: string;

constructor({ premium, sender, text }: PostedMessage) {
constructor(premium: boolean, sender: string, text: string) {
this.premium = premium;
this.sender = sender;
this.text = text;
Expand Down

0 comments on commit e2b2014

Please sign in to comment.