Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(WIP): use boarsh schema type #382

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: use boarsh schema type
fospring committed May 5, 2024
commit c9d57073e803d1f84652651102ec00de7bc77c7a
5 changes: 3 additions & 2 deletions examples/package.json
Original file line number Diff line number Diff line change
@@ -62,11 +62,12 @@
"author": "Near Inc <hello@nearprotocol.com>",
"license": "Apache-2.0",
"dependencies": {
"borsh": "^v1.0.0",
"borsher": "^3.5.0",
"lodash-es": "^4.17.21",
"near-contract-standards": "workspace:*",
"near-sdk-js": "workspace:*",
"typescript": "^4.7.4",
"borsh": "^v1.0.0"
"typescript": "^4.7.4"
},
"devDependencies": {
"@types/lodash-es": "^4.17.6",
16 changes: 9 additions & 7 deletions examples/src/status-deserialize-class.js
Original file line number Diff line number Diff line change
@@ -7,12 +7,14 @@ import {
LookupMap,
Vector,
UnorderedSet,
// BorshSchema,
} from "near-sdk-js";
import { BorshSchema, borshSerialize, borshDeserialize } from 'borsher';

class Car {
static schema = {
name: "string",
speed: "number",
name: BorshSchema.String,
speed: BorshSchema.u64,
};
constructor() {
this.name = "";
@@ -26,9 +28,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 = "";
@@ -47,8 +49,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},
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.

1 change: 1 addition & 0 deletions packages/near-sdk-js/package.json
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@
"@types/estree": "^1.0.0",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"borsher": "^3.5.0",
"commander": "^9.4.1",
"eslint": "^8.20.0",
"json-schema": "0.4.0",
2 changes: 2 additions & 0 deletions packages/near-sdk-js/src/index.ts
Original file line number Diff line number Diff line change
@@ -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 };
32 changes: 32 additions & 0 deletions pnpm-lock.yaml

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