jup-ag / jupiter-core-example

95 stars 57 forks source link

Buffer Layout Type throwing error - causes Jupiter SDK to globally fail and crash app #7

Open h4rkl opened 2 years ago

h4rkl commented 2 years ago

I'm getting a resolution issue related to the "@solana/buffer-layout": "4.0.0" resolution and breaking changes to the lib.

There's an extensive thread related to this issue located at https://github.com/solana-labs/solana-program-library/issues/2534 and I've tried all the options suggested without success.

The issue first surfaces when doing a yarn install where the following warning appears: warning Resolution field "@solana/buffer-layout@4.0.0" is incompatible with requested version "@solana/buffer-layout@^3.0.0"

If I use typescript types I get the following stack trace error:

TypeError: fields must be array of Layout instances
    at new Structure (~/arby/node_modules/@jup-ag/lifinity-sdk/node_modules/@project-serum/anchor/node_modules/@solana/buffer-layout/src/Layout.ts:1107:13)
    at Object.struct (~/arby/node_modules/@jup-ag/lifinity-sdk/node_modules/@project-serum/anchor/node_modules/@solana/buffer-layout/src/Layout.ts:2615:5)
    at Object.<anonymous> (~/arby/node_modules/@jup-ag/lifinity-sdk/node_modules/@project-serum/anchor/node_modules/@solana/web3.js/src/system-program.ts:648:26)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Object.require.extensions.<computed> [as .js] (~/arby/node_modules/ts-node/src/index.ts:1445:43)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
[nodemon] app crashed - waiting for file changes before starting...

If I switch to JS without the need for types I get the following stack trace error:

~/arby/node_modules/@jup-ag/lifinity-sdk/node_modules/@project-serum/anchor/node_modules/@solana/buffer-layout/lib/Layout.js:999
            throw new TypeError('fields must be array of Layout instances');
            ^

TypeError: fields must be array of Layout instances
    at new Structure (~/arby/node_modules/@jup-ag/lifinity-sdk/node_modules/@project-serum/anchor/node_modules/@solana/buffer-layout/lib/Layout.js:999:19)
    at Object.exports.struct (~/arby/node_modules/@jup-ag/lifinity-sdk/node_modules/@project-serum/anchor/node_modules/@solana/buffer-layout/lib/Layout.js:2373:57)
    at Object.<anonymous> (~/arby/node_modules/@jup-ag/lifinity-sdk/node_modules/@project-serum/anchor/node_modules/@solana/web3.js/lib/index.cjs.js:3525:37)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (~/arby/node_modules/@jup-ag/lifinity-sdk/node_modules/@project-serum/anchor/dist/cjs/index.js:32:29)

Here's my package.json deps:

{
"dependencies": {
    "@jup-ag/core": "^1.0.0-beta.24",
    "@solana/web3.js": "^1.42.0",
    "axios": "^0.27.2",
    "bcrypt": "^5.0.1",
    "client-sessions": "^0.8.0",
    "crypto-js": "^4.1.1",
    "dotenv": "^16.0.1",
    "express": "^4.17.1",
    "helmet": "^4.6.0",
    "migrate": "^1.7.0",
    "morgan": "^1.10.0",
    "pg": "^8.7.1",
    "sql-template-strings": "^2.2.2",
    "uuid": "^8.3.2"
  },
  "devDependencies": {
    "@types/client-sessions": "^0.8.3",
    "@types/express": "^4.17.13",
    "@types/morgan": "^1.9.3",
    "@types/node": "^17.0.33",
    "nodemon": "^2.0.12",
    "ts-node": "^10.7.0",
    "typescript": "^4.6.4"
  },
  "resolutions": {
    "@solana/buffer-layout": "4.0.0"
  }
}

I'm out of options for this one. Any help, feedback or fix suggestions welcome.

tunjayhuseynov commented 2 years ago

I got it too. Any progress?

solotop999 commented 2 years ago

same problem

Tosinpeter commented 2 years ago

Any update on this ?