near-sdk-js icon indicating copy to clipboard operation
near-sdk-js copied to clipboard

feat(WIP): use boarsh schema type

Open fospring opened this issue 1 year ago • 5 comments

Pre-flight checklist

  • [ ] I have read the Contributing Guidelines on pull requests.
  • [ ] Commit messages follow the conventional commits spec
  • [ ] If this is a code change: I have written unit tests.
  • [ ] If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

related issue: https://github.com/near/near-sdk-js/pull/377

Test Plan

Related issues/PRs

fospring avatar Mar 10 '24 14:03 fospring

Hi @gagdiez , I re-exported BorshSchema from "borsher" and imported BorshSchema in test file, but it build failed withe error, do you know what's the problem on the re-exported error:

cd examples
pnpm run build:status-deserialize-class

major error info:

Error: 'BorshSchema' is not exported by ../node_modules/.pnpm/[email protected]/node_modules/borsher/dist/index.js, imported by ../packages/near-sdk-js/lib/index.js

fospring avatar Mar 10 '24 14:03 fospring

summoning @hanakannzashi

gagdiez avatar Mar 11 '24 17:03 gagdiez

https://www.npmjs.com/package/borsher?activeTab=code borsher dosen't contains a lib directory, maybe this is the reason that not suppport in .js file. @hanakannzashi, can you please have a check? image

fospring avatar May 05 '24 02:05 fospring

https://www.npmjs.com/package/borsher?activeTab=code borsher dosen't contains a lib directory, maybe this is the reason that not suppport in .js file. @hanakannzashi, can you please have a check? image

but I created examples/src/index2.js,

import { BorshSchema, borshSerialize, borshDeserialize } from 'borsher';
const n = 100;
const buffer = borshSerialize(BorshSchema.u8, n);

and then run:

cd examples
node src/index2.js

the result was OK, quite strange.

fospring avatar May 05 '24 03:05 fospring

@fospring the problem is probably borsher isn't ESM packaged. CommonJS packaging is not supported by near-sdk-js builder. Let's skip this one from the 2.0 release and introduce it in a later version

ailisp avatar May 07 '24 08:05 ailisp