Skip to content

Commit

Permalink
feat: use boarsh schema type
Browse files Browse the repository at this point in the history
  • Loading branch information
fospring committed Mar 10, 2024
1 parent 61fe54e commit 915aabe
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 8 deletions.
15 changes: 8 additions & 7 deletions examples/src/status-deserialize-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import {
LookupMap,
Vector,
UnorderedSet,
BorshSchema,
} from "near-sdk-js";

class Car {
static schema = {
name: "string",
speed: "number",
name: BorshSchema.String,
speed: BorshSchema.u64,
};
constructor() {
this.name = "";
Expand All @@ -26,9 +27,9 @@ class Car {

class Truck {
static schema = {
name: "string",
speed: "number",
loads: UnorderedMap
name: BorshSchema.String,
speed: BorshSchema.u64,
loads: BorshSchema.Struct(UnorderedMap)
};
constructor() {
this.name = "";
Expand All @@ -47,8 +48,8 @@ class Truck {
@NearBindgen({})
export class StatusDeserializeClass {
static schema = {
truck: Truck,
efficient_recordes: UnorderedMap,
truck: BorshSchema.Struct(Truck),
efficient_recordes: BorshSchema.Struct(UnorderedMap),
nested_efficient_recordes: {class: UnorderedMap, value: UnorderedMap},
nested_lookup_recordes: {class: UnorderedMap, value: LookupMap},
vector_nested_group: {class: Vector, value: LookupMap},
Expand Down
2 changes: 2 additions & 0 deletions packages/near-sdk-js/lib/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/near-sdk-js/lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/near-sdk-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"json5": "^2.2.3",
"npm-run-all": "^4.1.5",
"prettier": "^2.7.1",
"typescript": "^4.7.2"
"typescript": "^4.7.2",
"borsher": "^1.2.1"
}
}
2 changes: 2 additions & 0 deletions packages/near-sdk-js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ export * as near from "./api";
export * from "./near-bindgen";
export * from "./promise";
export * from "./utils";
import { BorshSchema } from "borsher";
export { BorshSchema };
29 changes: 29 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 915aabe

Please sign in to comment.