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

Dependency version mismatches causing borsh error #54

Open
BobbyRadford opened this issue Jun 15, 2023 · 0 comments
Open

Dependency version mismatches causing borsh error #54

BobbyRadford opened this issue Jun 15, 2023 · 0 comments

Comments

@BobbyRadford
Copy link

BobbyRadford commented Jun 15, 2023

When using @keypom/[email protected], I get the following error from the borsh library when calling createDrop().

Error: Class PublicKey is missing in schema: publicKey
    at serializeStruct (/Users/bobby/workspace/rownd/api-server/node_modules/borsh/lib/index.js:323:15)
    at serializeField (/Users/bobby/workspace/rownd/api-server/node_modules/borsh/lib/index.js:306:13)
    at /Users/bobby/workspace/rownd/api-server/node_modules/borsh/lib/index.js:327:13
    at Array.map (<anonymous>)
    at serializeStruct (/Users/bobby/workspace/rownd/api-server/node_modules/borsh/lib/index.js:326:29)
    at serialize (/Users/bobby/workspace/rownd/api-server/node_modules/borsh/lib/index.js:349:5)
    at encodeTransaction (/Users/bobby/workspace/rownd/api-server/node_modules/@near-js/transactions/lib/schema.js:33:34)
    at /Users/bobby/workspace/rownd/api-server/node_modules/@near-js/transactions/lib/sign.js:30:56
    at Generator.next (<anonymous>)
    at /Users/bobby/workspace/rownd/api-server/node_modules/@near-js/transactions/lib/sign.js:8:71

This seems to be related to a known bug documented in near-api-js https://docs.near.org/tools/near-api-js/faq#class-x-is-missing-in-schema-publickey caused by importing multiple versions of near dependencies. It at least got me looking in the right direction for a workaround.

Examining the versions of @near-js/xxxx in my package-lock.json file revealed multiple resolved versions of @near-js/crypto (0.0.4 and 0.0.5). The web of peer dependencies and dependencies of those @near-js/xxxx packages is a mess, but I finally got a workaround by installing specific versions of three packages in my package.json

"@near-js/accounts": "0.1.3",
"@near-js/signers": "0.0.4",
"@near-js/transactions": "0.2.0",

With those specific versions installed, I can now call createDrop() without any issues. This should get fixed at the @keypom/core level so everything works out of the box for everyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant