Ellipsis-Labs / phoenix-sdk

SDK for interacting with the Phoenix DEX.
83 stars 39 forks source link

Issue with 2.0.1 Unable to Create Client #128

Open R-K-H opened 1 year ago

R-K-H commented 1 year ago

With the latest SDK update with Javascript I'm running into this error. From my understanding there's something going on with what piece of the connection is being passed as I've confirmed that the connection.rpcUrl is being passed correctly with https, so not sure where to dig in further.

Happy to discuss / dig in. This wasn't an error in 2.0.0.

2023-07-18 14:15:19.686 ERROR   /src/connectors/phoenixConnector.ts:83
 TypeError  Only HTTP(S) protocols are supported
error stack:
  • index.js    getNodeRequestOptions
        /node_modules/node-fetch/lib/index.js:1331
  • index.js
        /node_modules/node-fetch/lib/index.js:1454
  • 

  • index.js    fetch
        /node_modules/node-fetch/lib/index.js:1451
  • zstddec.ts  Q.E.init
        /node_modules/zstddec/zstddec.ts:41
  • index.js
        /node_modules/@ellipsis-labs/phoenix-sdk/dist/index.js:1
  • 

  • index.js    s
        /node_modules/@ellipsis-labs/phoenix-sdk/dist/index.js:1
  • task_queues processTicksAndRejections
        internal/process/task_queues:95
/Users/~/Development/mev/src/connectors/phoenixConnector.ts:84
      throw new Error(`Error connecting to Phoenix Client SDK ${error}`)
            ^
Error: Error connecting to Phoenix Client SDK TypeError: Only HTTP(S) protocols are supported
    at PhoenixConnector.connect (/Users/~/Development/mev/src/connectors/phoenixConnector.ts:84:13)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async simpleMarketMaker (/Users/~/Development/mev/src/index.ts:67:3)
error Command failed with exit code 1.

Here's the function in my code where the error is originating:

connect = async () => {
    try {
      // @ts-ignore
      this.client = await Client.create(this.web3Connection)
    } catch (error) {
      log.error(error)
      throw new Error(`Error connecting to Phoenix Client SDK ${error}`)
    }
  }
R-K-H commented 1 year ago

Note: If you have this error with your RPC, you can instead pass the useZstd=false flag within the createFromConfig client constructor.

That resolved my issue when using Helius RPC on Devnet.

I still would like to be able to pass that flag with just create however, as the config requires the market data structure to be passed.

axssbug commented 5 months ago

thanks