starkware-libs / starkex-js

JavaScript SDK for StarkEx
https://starkware.co/starkex/api/
28 stars 18 forks source link

Cannot find module '@starkware-industries/starkex-js/node' #10

Closed toffzz closed 2 years ago

toffzz commented 2 years ago

Describe the bug

Using: const StarkExAPI = require('@starkware-industries/starkex-js/node');

I get the error: Cannot find module '@starkware-industries/starkex-js/node'

To Reproduce Steps to reproduce the behavior:

Expected behavior require('@starkware-industries/starkex-js/node') should return package.

var StarkExAPI = require('@starkware-industries/starkex-js seems to work.

Screenshots image

Desktop (please complete the following information):

Additional context I just want to build with StarkEx!

toffzz commented 2 years ago

It works if I copy dist/node.js and reference it directly as a utils function.

Also, while I'm here and exploring StarkEx. This is using v2 Gateway which has a bunch of deprecated functions, correct? Like deposit referenced in https://starkware.co/StarkExRESTAPI/gateway.html?

Is there a JS library for v4 planned? Thanks for all the help! Excited about this.

I think I am confused as the readme says this is version2, but https://docs.starkware.co/starkex-v4/ links to that gateway reference as v4 rest API. If anyone can clear up what I am using please, thanks!

lsbyerley commented 2 years ago

Can confirm const StarkExAPI = require('@starkware-industries/starkex-js/node'); does not work in a node environment

DanyylSocol commented 2 years ago

It also does not work for me I use "@starkware-industries/starkex-js/dist/node" to make it work

dan-ziv commented 2 years ago

Hi @toffzz and thank you for reporting this issue! After checking, we had an issue in our packing process. We will fix it in the next release. In the meanwhile, keep using .../dist/node of course.

Regarding your first question, I will start from the end and then explain - this JS library does support StarkEx v4.

  1. The gateway is indeed still in its version2, the StarkEx itself as a package is in v4. The difference is not in the API but only in the way it is used. For example, in v4 in order to make a withdrawal, you must first make a transfer and only then a withdrawal.

  2. The deprecated functions you see are indeed such, but in this SDK we use internally the non-deprecated API add_transaction, so the external gateway functions of the SDK such as transfer/withdrawal/deposit are just a matter of ease of use for those who use the SDK.

toffzz commented 2 years ago

Thanks @dan-ziv !

letzdoo-js commented 2 years ago

And for module in nodeJS :

import StarkExAPI from '@starkware-industries/starkex-js/dist/node.js';

dan-ziv commented 2 years ago

Solved in https://github.com/starkware-libs/starkex-js/pull/14