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

Support sample application using haveno-ts library [3 XMR] #1482

Open
woodser opened this issue Dec 18, 2024 · 7 comments
Open

Support sample application using haveno-ts library [3 XMR] #1482

woodser opened this issue Dec 18, 2024 · 7 comments
Labels
💰bounty There is a bounty on this issue

Comments

@woodser
Copy link
Contributor

woodser commented Dec 18, 2024

This issue requests getting the sample Node.js application to work using the haveno-ts library.

Currently, haveno-ts does not package its dist assets correctly to be used as a NPM dependency via npm install haveno-ts, causing this error when used:

Error: Cannot find module './HavenoClient'

There is a pull request in progress, haveno-dex/haveno-ts#332, to start fixing haveno-ts to be used as a NPM dependency, but it's only meant as a starting point.

Apply the PR to haveno-ts and run these steps to test the latest fixes in the sample application:

  1. cd haveno-ts
  2. npm install
  3. npm pack
  4. cd ~/git/haveno-sample-app
  5. npm install ../haveno-ts/haveno-ts-0.0.30.tgz
  6. npm run start

With the fixes from the PR applied, you should see this output in the sample application for further debugging:

Sample app using haveno-ts
/Users/woodser/git/haveno-sample-app/node_modules/haveno-ts/dist/HavenoClient.js:666
            throw new HavenoError_1.default(e.message, e.code);
                  ^

HavenoError: XMLHttpRequest is not defined
    at HavenoClient.getBalances (/Users/woodser/git/haveno-sample-app/node_modules/haveno-ts/dist/HavenoClient.js:666:19)
    at async main (file:///Users/woodser/git/haveno-sample-app/dist/index.js:8:22) {
  code: undefined
}
@woodser woodser changed the title Support sample application using haveno-ts library Support sample application using haveno-ts library [3 XMR] Dec 18, 2024
@woodser woodser added the 💰bounty There is a bounty on this issue label Dec 18, 2024
Copy link

There is a bounty on this issue. The amount is in the title. The reward will be awarded to the first person or group of people whose solution is accepted and merged.

In some cases, we may assign the issue to specific contributors. We expect contributors to provide a PR in a reasonable time frame or, in case of an extensive work, updates on their progress. We will unassign the issue if we feel the assignee is not responsive or has abandoned the task.

Read the full conditions and details of our bounty system.

@im-adithya
Copy link

Would like to help here.

But I'm seeing these errors on doing make skip-tests:

Could not determine the dependencies of task ':desktop:shadowJar'.
> Could not resolve all dependencies for configuration ':desktop:runtimeClasspath'.
   > Could not resolve com.github.bisq-network:bitcoinj:2a80db4.
     Required by:
         project :desktop
         project :desktop > project :assets
         project :desktop > project :common
         project :desktop > project :p2p
         project :desktop > project :core
      > Skipped due to earlier error
   > Could not resolve com.github.bisq-network:jtorctl:b2a172f44edcd8deaa5ed75d936dcbb007f0d774.
     Required by:
         project :desktop > project :common
      > Skipped due to earlier error
   > Could not resolve com.github.haveno-dex.netlayer:tor.external:e2ce2a142c.
     Required by:
         project :desktop > project :p2p
         project :desktop > project :core
      > Skipped due to earlier error
   > Could not resolve com.github.haveno-dex.netlayer:tor.native:e2ce2a142c.
     Required by:
         project :desktop > project :p2p
         project :desktop > project :core
      > Skipped due to earlier error
   > Could not resolve com.github.bisq-network:jsonrpc4j:1.6.0.bisq.1.
     Required by:
         project :desktop > project :core
      > Skipped due to earlier error

Would appreciate some help

@im-adithya
Copy link

@woodser can you please review the fix? it should now package xhr2 within haveno-ts

Although it results in a small error during buildtime as xhr2 doesn't have @types/xhr2

@bl4ck-cod3
Copy link

I would like to point out this introduces vulnerabilities, per npm audit

@woodser
Copy link
Contributor Author

woodser commented Dec 27, 2024

@im-adithya Can you open the PR on https://github.com/haveno-dex/haveno-ts please?

@im-adithya
Copy link

@woodser done: haveno-dex/haveno-ts#339

@woodser
Copy link
Contributor Author

woodser commented Dec 28, 2024

@bl4ck-cod3 What do you think about @everoddandeven's solution here: haveno-dex/haveno-ts#338

  • Uses node-xmlhttprequest which is currently used in the jest tests
  • Only imports types to the global object if not present
  • Exports the types for clients to use without additional imports
  • Ignores type warnings
  • Doesn't introduce vulnerabilities (actually fixes the current high severity vulnerability).

This looks good and works well for me. Otherwise I don't know how it can be improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💰bounty There is a bounty on this issue
Projects
None yet
Development

No branches or pull requests

3 participants