Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

When importing JsSignature provider with common JS error occurs #474

@JesseAbram

Description

@JesseAbram

Version of EOSJS
"eosjs": "^20.0.0-beta3",

Describe the bug
when using eosJS to send a transaction in common JS. Following the documentation provides this error.

const signatureProvider = new JsSignatureProvider(privateKeys);
                          ^

TypeError: JsSignatureProvider is not a constructor
    at Object.<anonymous> (/Users/jesse/Desktop/blockx/eosTest/sendTransaction.js:7:27)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3

when console logging JsSignatureProvider you get

{ default: [Function: JsSignatureProvider] }

To Reproduce
follow your documentation for sending a transaction with commonJS.

Expected behavior
Receive a transaction hash

Desktop (please complete the following information):

  • macOS high Sierra

Additional context
I have solved this problem in 2 ways. One was by importing as .default. This would require a documentation change. However, this issue is only seen in typescript when exporting default and not when using module.export. So I have created a PR that makes that change when exporting the JsSignatureProvider.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions