@nearBindgen export class TextMessage { sender: string = defaultValue(); text: string = defaultValue(); number: u64 = defaultValue(); isRead: bool = defaultValue(); decode<_V = Uint8Array>(buf: _V): TextMessage { let json: JSON.Obj; if (buf instanceof Uint8Array) { json = JSON.parse(buf); } else { assert(buf instanceof JSON.Obj, "argument must be Uint8Array or Json Object"); json = buf; } return this._decode(json); } static decode(buf: Uint8Array): TextMessage { return decode(buf); } private _decode(obj: JSON.Obj): TextMessage { this.sender = obj.has("sender") ? decode(obj, "sender"): defaultValue(); this.text = obj.has("text") ? decode(obj, "text"): defaultValue(); this.number = obj.has("number") ? decode(obj, "number"): defaultValue(); this.isRead = obj.has("isRead") ? decode(obj, "isRead"): defaultValue(); return this; } _encode(name: string | null = "", _encoder: JSONEncoder | null = null): JSONEncoder { let encoder = _encoder == null ? new JSONEncoder() : _encoder; encoder.pushObject(name); encode(this.sender, "sender", encoder); encode(this.text, "text", encoder); encode(this.number, "number", encoder); encode(this.isRead, "isRead", encoder); encoder.popObject(); return encoder; } encode(): Uint8Array { return this._encode().serialize(); } serialize(): Uint8Array { return this.encode(); } toJSON(): string { return this._encode().toString(); } } @nearBindgen export class Word { constructor(public text: string) {} decode<_V = Uint8Array>(buf: _V): Word { let json: JSON.Obj; if (buf instanceof Uint8Array) { json = JSON.parse(buf); } else { assert(buf instanceof JSON.Obj, "argument must be Uint8Array or Json Object"); json = buf; } return this._decode(json); } static decode(buf: Uint8Array): Word { return decode(buf); } private _decode(obj: JSON.Obj): Word { this.text = obj.has("text") ? decode(obj, "text"): defaultValue(); return this; } _encode(name: string | null = "", _encoder: JSONEncoder | null = null): JSONEncoder { let encoder = _encoder == null ? new JSONEncoder() : _encoder; encoder.pushObject(name); encode(this.text, "text", encoder); encoder.popObject(); return encoder; } encode(): Uint8Array { return this._encode().serialize(); } serialize(): Uint8Array { return this.encode(); } toJSON(): string { return this._encode().toString(); } } @nearBindgen function capitalize(s: string): string { return s.toUpperCase(); } @nearBindgen function __wrapper_capitalize(): void { const obj = getInput(); let result: string = capitalize(obj.has('s') ? decode(obj, "s") : requireParameter("s")); const val = encode(result); value_return(val.byteLength, val.dataStart); } export { __wrapper_capitalize as capitalize }