Skip to content

Dependency version mismatches causing borsh error #54

Description

@BobbyRadford

When using @keypom/core@1.0.2, 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions