From 5421c6f95bff2ecf73f9b4e06d0bca8fc9bb27d9 Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Thu, 14 Nov 2024 15:32:49 +0100 Subject: [PATCH] chore: use the same sdk --- src/init/update-artifacts/test/exampleTest.js | 3 +-- src/lib/utils.ts | 17 +++++++++++------ tests/cli.test.mjs | 2 +- tests/util.mjs | 10 +++++++--- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/init/update-artifacts/test/exampleTest.js b/src/init/update-artifacts/test/exampleTest.js index d911ac31..070c4d64 100644 --- a/src/init/update-artifacts/test/exampleTest.js +++ b/src/init/update-artifacts/test/exampleTest.js @@ -1,5 +1,4 @@ import { utils } from "@aeternity/aeproject"; -import * as AeppSdk from "@aeternity/aepp-sdk"; import { Contract, getFileSystem } from "@aeternity/aepp-sdk"; import * as chai from "chai"; import { assert } from "chai"; @@ -15,7 +14,7 @@ describe("ExampleContract", () => { let contract; before(async () => { - aeSdk = utils.getSdk(AeppSdk, {}); + aeSdk = utils.getSdk({}); // a filesystem object must be passed to the compiler if the contract uses custom includes const fileSystem = await getFileSystem(EXAMPLE_CONTRACT_SOURCE); diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 44afa0e5..c69631fd 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,6 +1,11 @@ import fs from "fs"; -import * as AeppSdkType from "@aeternity/aepp-sdk"; -import { AeSdk, MemoryAccount, Encoded } from "@aeternity/aepp-sdk"; +import { + AeSdk, + CompilerHttp, + Encoded, + MemoryAccount, + Node, +} from "@aeternity/aepp-sdk"; import { readFile } from "fs/promises"; export const networks = JSON.parse( @@ -26,13 +31,13 @@ export function getDefaultAccounts(): MemoryAccount[] { ); } -export function getSdk(AeppSdk: typeof AeppSdkType, options: {}): AeSdk { - const instance = new AeppSdk.Node(networks.devmode.nodeUrl, options); +export function getSdk(options: {}): AeSdk { + const instance = new Node(networks.devmode.nodeUrl, options); - return new AeppSdk.AeSdk({ + return new AeSdk({ accounts: getDefaultAccounts(), nodes: [{ name: "node", instance }], - onCompiler: new AeppSdk.CompilerHttp(networks.devmode.compilerUrl, options), + onCompiler: new CompilerHttp(networks.devmode.compilerUrl, options), interval: 50, }); } diff --git a/tests/cli.test.mjs b/tests/cli.test.mjs index e9bcfa86..ab141f4b 100644 --- a/tests/cli.test.mjs +++ b/tests/cli.test.mjs @@ -92,7 +92,7 @@ describe("command line usage", () => { if (!process.env.AUX_CI_RUN) { const res = await exec("aeproject init --update --next -y", { cwd }); // link to use local aeproject utils - await linkLocalLib(null); + await linkLocalLib(); assert.equal(res.code, 0); assert.equal(res.stderr, ""); diff --git a/tests/util.mjs b/tests/util.mjs index 9f6be770..c54220e3 100644 --- a/tests/util.mjs +++ b/tests/util.mjs @@ -23,7 +23,11 @@ export function cleanLocal() { } export async function linkLocalLib(folder) { - await exec("npm link @aeternity/aeproject", { - cwd: folder ? path.join(cwd, folder) : cwd, - }); + const c = folder ? path.join(cwd, folder) : cwd; + await exec("npm i .. -D", { cwd: c }); + await exec( + 'perl -i -pe \'s/"prepare"/"rem-prepare"/g\' ../node_modules/@aeternity/aepp-sdk/package.json', + { cwd: c }, + ); + await exec("npm i ../node_modules/@aeternity/aepp-sdk", { cwd: c }); }