Skip to content

Commit

Permalink
chore: use the same sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk authored and thepiwo committed Nov 25, 2024
1 parent abb6e6d commit 5421c6f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/init/update-artifacts/test/exampleTest.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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);

Expand Down
17 changes: 11 additions & 6 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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,
});
}
Expand Down
2 changes: 1 addition & 1 deletion tests/cli.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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, "");
Expand Down
10 changes: 7 additions & 3 deletions tests/util.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}

0 comments on commit 5421c6f

Please sign in to comment.