Issue in importing SDK
aga7hokakological opened this issue · 2 comments
aga7hokakological commented
I am creating file same workspace file as similar to your files
import { chaiSolana } from "@saberhq/chai-solana";
import { SolanaProvider } from "@saberhq/solana-contrib";
import * as chai from "chai";
// import type { Programs } from "../src";
import { GokiSDK } from "@gokiprotocol/client";
chai.use(chaiSolana);
// export type Workspace = Programs;
export const makeSDK = (): GokiSDK => {
const anchorProvider = anchor.Provider.env();
anchor.setProvider(anchorProvider);
const provider = SolanaProvider.init({
connection: anchorProvider.connection,
wallet: anchorProvider.wallet,
opts: anchorProvider.opts,
});
return GokiSDK.load({
provider,
});
};
and then importing it in my anchor test file.
import * as anchor from '@project-serum/anchor';
import { Program } from '@project-serum/anchor';
import { LiquidityMiner } from '../target/types/liquidity_miner';
import { GokiSDK } from '@gokiprotocol/client';
import { newProgramMap } from "@saberhq/anchor-contrib";
import { SolanaProvider } from "@saberhq/solana-contrib"
import mapValues from "lodash.mapvalues";
import { makeSDK } from './workspace';
describe('liquidityMiner', () => {
// Configure the client to use the local cluster.
// const anchorProvider = anchor.setProvider(anchor.Provider.env());
const anchorProvider = anchor.Provider.env();
anchor.setProvider(anchorProvider);
const program = anchor.workspace.NewContract as Program<LiquidityMiner>;
const sdk = makeSDK();
before(async () => {
// const gokiSDK = GokiSDK.load({ provider: provider});
})
});
And after running anchor test getting following error:
Require stack:
- /home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/node_modules/@ubeswap/token-math/dist/
cjs/constants.js
- /home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/node_modules/@ubeswap/token-math/dist/
cjs/index.js
- /home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/node_modules/@saberhq/token-utils/dist
/cjs/price.js
- /home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/node_modules/@saberhq/token-utils/dist
/cjs/index.js
- /home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/node_modules/@saberhq/chai-solana/dist
/cjs/index.js
- /home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/tests/workspace.ts
- /home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/tests/liquidityMiner.ts
- /home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/node_modules/mocha/lib/nodejs/esm-util
s.js
- /home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/node_modules/mocha/lib/mocha.js
- /home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/node_modules/mocha/lib/cli/one-and-don
es.js
- /home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/node_modules/mocha/lib/cli/options.js
- /home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/node_modules/mocha/bin/mocha
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/node_modules/
@ubeswap/token-math/src/constants.ts:1:1)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155: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> (/home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/node_modules/
@ubeswap/token-math/src/index.ts:1:1)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155: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> (/home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/node_modules/
@saberhq/token-utils/src/price.ts:2:1)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155: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> (/home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/node_modules/
@saberhq/token-utils/src/index.ts:4:1)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155: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> (/home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/node_modules/
@saberhq/chai-solana/src/index.ts:5:1)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155: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> (/home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/tests/workspa
ce.ts:2:1)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Module.m._compile (/home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/node_modules/t
s-node/src/index.ts:439:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Object.require.extensions.<computed> [as .ts] (/home/agathokako/saurabh/cyclos/newcontract/li
quidity-miner/node_modules/ts-node/src/index.ts:442:12)
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> (/home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/tests/liquidi
tyMiner.ts:10:1)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Module.m._compile (/home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/node_modules/t
s-node/src/index.ts:439:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Object.require.extensions.<computed> [as .ts] (/home/agathokako/saurabh/cyclos/newcontract/li
quidity-miner/node_modules/ts-node/src/index.ts:442:12)
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.exports.requireOrImport (/home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/n
ode_modules/mocha/lib/nodejs/esm-utils.js:60:20)
at Object.exports.loadFilesAsync (/home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/no
de_modules/mocha/lib/nodejs/esm-utils.js:103:20)
at singleRun (/home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/node_modules/mocha/lib
/cli/run-helpers.js:125:3)
at Object.exports.handler (/home/agathokako/saurabh/cyclos/newcontract/liquidity-miner/node_modu
les/mocha/lib/cli/run.js:374:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
secretshardul commented
Resolved by downgrading to older dependencies. This also affects other Ship capital SDKs like Tribeca. Kindly update to Anchor 0.21
"@project-serum/anchor": "0.20.1",
"@saberhq/chai-solana": "1.12.36",
"@saberhq/solana-contrib": "1.12.36",
"@saberhq/token-utils": "1.12.36",
sungoki commented
Should be fixed. Let me know if this issue still exists.