Closed LFSCamargo closed 8 months ago
I'm having the same issue here.
Important to notice, in order for the repo to run the tests it's needed to add a folder neardev/shared-test in the contracts folder. In this folder, you'll need to place the access keys for test.near (genesis account for the test chain):
{"account_id":"test.near","public_key":"ed25519:22skMptHjFWNyuEWY22ftn2AbLPSYpmYwGJRGwpNHbTV","private_key":"ed25519:2wyRcSwSuHtRVmkMCGjPwnzZmQLeXLzLLyED1NDMt4BjnKgQL6tF85yBx6Jr26D2dUNeC716RBoTxntVHsegogYw"}
Running into so many issues with Borsh and serialization and Near API JS. This is becoming by far my biggest frustration with Near at the moment.
Its feeling like a wall at the moment, I've run into it during development- where I had to ensure that when building my transactions, the classes were pulled from the exact same library import in the same way (more difficult than it sounds in complex dev environments). Even though they technically were exactly the same classes (dev tools do strange things sometimes when you have a monorepo and there are multiple projects doing imports of the same thing).
Now I'm running into serialization issues, with almost the exact same error message as the post here, after bundling my code for production deployment:
Content.tsx:201 Error: Class ut is missing in schema: publicKey
at serializeStruct (index.js:323:15)
at serializeField (index.js:306:13)
at index.js:327:13
at Array.map (<anonymous>)
at serializeStruct (index.js:326:29)
at Object.serialize (index.js:349:5)
at lt (transaction.js:219:29)
at Object.ft [as signTransaction] (transaction.js:237:16)
at async ConnectedMeteorWalletAccount.signTransaction (account.js:99:16)
at async account.js:118:34
Please can there be a better way for this serialization / de-serialization of transactions that doesn't depend on actual exact classes being imported from near-api-js
, which is prone to version mismatches and obscure errors. There has to be a better way.
EDIT: As suspected- these kinds of errors are almost always because of duplication- you are creating a transaction using a certain class import, and then trying to serialized it in a place that uses the exact same class import, but for some reason your dev or build tool is pulling that class from a different place. Internally this makes borsch see these two classes as different entities and throws the error.
I am using Vite at the moment. My dev environment was finally working but my builds were failing. To fix this in the build as well (I figured out that near-api-js
was being duplicated 3 times in the build output!) I had to force Vite to not duplicate this dependency, using resolve.dedupe: ["near-api-js"]
(its a Vite option you can set in your config). I hope this helps someone else running into similar issues!
Hey everyone you can try out the newest version of NAJ. The issue should be resolved by the following commit: https://github.com/near/near-api-js/commit/61349aeca3af830f702b24654e0f13cd428192d8. Please let me know if the issue persists. Otherwise I'll close the issue in 7 days. Thanks!
Closing as issue should be resolved.
Describe the bug Unable to use the change methods of the contract on jest with near test-environment. I get this error when trying to use the change methods
To Reproduce Steps to reproduce the behavior:
greeting.spec.ts
:Expected behavior Pass both of the tests using the near config from the near-test-environment
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context If someone knows a way to bypass this will be cool also
😄