diff --git a/docs/cli/test.md b/docs/cli/test.md index e3ba73c8..2998f909 100644 --- a/docs/cli/test.md +++ b/docs/cli/test.md @@ -23,8 +23,9 @@ const { assert } = require("chai"); Helper and utilities for AEproject use, e.g. prefunded wallets, network definition and utility functions for SDK initialization and snapshotting. ```js -const { networks, utils, wallets } = require("@aeternity/aeproject"); -const { getFileSystem } = require("@aeternity/aepp-sdk"); +const { utils } = require("@aeternity/aeproject"); +import * as AeppSdk from "@aeternity/aepp-sdk"; +const { Contract, getFileSystem } = require("@aeternity/aepp-sdk"); ``` Read [AEproject Library](../lib.md) for a more detailed explanation about the usage of these imports. @@ -40,7 +41,7 @@ before(async () => ...) Initialize the default SDK instance with provided utils: ```js -aeSdk = utils.getSdk(); +aeSdk = utils.getSdk(AeppSdk, {}); ``` Get the filesystem definition for (custom) `includes` of the given contract: diff --git a/docs/lib.md b/docs/lib.md index 36b14972..ad868cdb 100644 --- a/docs/lib.md +++ b/docs/lib.md @@ -17,7 +17,8 @@ utils.getContractContent(contractPath); Read the contract source from given path, just a wrapper for `fs.readFileSync` using `utf-8` encoding. ```javascript -utils.getSdk(); +import * as AeppSdk from "@aeternity/aepp-sdk"; +utils.getSdk(AeppSdk, {}); ``` Initialize the æternity SDK, pre-configured for optimal use in an AEproject project using æternity node devmode. diff --git a/docs/migration-from-4.x.x-to-5.x.x.md b/docs/migration-from-4.x.x-to-5.x.x.md index 8ec8308b..743b5f6a 100644 --- a/docs/migration-from-4.x.x-to-5.x.x.md +++ b/docs/migration-from-4.x.x-to-5.x.x.md @@ -13,6 +13,7 @@ npm install -g @aeternity/aeproject - **dropped commonjs support**, newly created projects will be created as esm projects, old cjs projects will not continue to work with newer aeproject versions, to keep using old cjs projects, `@aeternity/aeproject@4` will continue to work for now. - `node@16` is no longer supported, please update to v18 or higher - updated to `@aeternity/aepp-sdk@14` to the latest version, see the [migration guide](https://github.com/aeternity/aepp-sdk-js/blob/v14.0.0/docs/guides/migration/14.md) for additional reference. + - the aeproject provided `utils.getSdk({})` has to be adjusted to pass a reference to the sdk used `utils.getSdk(AeppSdk, {})` where AeppSdk can be imported using `import * as AeppSdk from "@aeternity/aepp-sdk";` ## Removed from libs diff --git a/src/init/update-artifacts/test/exampleTest.js b/src/init/update-artifacts/test/exampleTest.js index c2fd0fe1..d911ac31 100644 --- a/src/init/update-artifacts/test/exampleTest.js +++ b/src/init/update-artifacts/test/exampleTest.js @@ -1,9 +1,9 @@ import { utils } from "@aeternity/aeproject"; -import { getFileSystem } from "@aeternity/aepp-sdk"; +import * as AeppSdk from "@aeternity/aepp-sdk"; +import { Contract, getFileSystem } from "@aeternity/aepp-sdk"; +import * as chai from "chai"; import { assert } from "chai"; import chaiAsPromised from "chai-as-promised"; -import * as chai from "chai"; -const { Contract } = require("@aeternity/aepp-sdk"); import { before, describe, afterEach, it } from "mocha"; chai.use(chaiAsPromised); @@ -15,8 +15,7 @@ describe("ExampleContract", () => { let contract; before(async () => { - aeSdk = utils.getSdk(); - + aeSdk = utils.getSdk(AeppSdk, {}); // 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 bd502ac5..44afa0e5 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,6 +1,6 @@ import fs from "fs"; - -import { AeSdk, MemoryAccount, Node, CompilerHttp, Encoded } from "@aeternity/aepp-sdk"; +import * as AeppSdkType from "@aeternity/aepp-sdk"; +import { AeSdk, MemoryAccount, Encoded } from "@aeternity/aepp-sdk"; import { readFile } from "fs/promises"; export const networks = JSON.parse( @@ -26,13 +26,13 @@ export function getDefaultAccounts(): MemoryAccount[] { ); } -export function getSdk(options: {}): AeSdk { - const instance = new Node(networks.devmode.nodeUrl, options); +export function getSdk(AeppSdk: typeof AeppSdkType, options: {}): AeSdk { + const instance = new AeppSdk.Node(networks.devmode.nodeUrl, options); - return new AeSdk({ + return new AeppSdk.AeSdk({ accounts: getDefaultAccounts(), nodes: [{ name: "node", instance }], - onCompiler: new CompilerHttp(networks.devmode.compilerUrl, options), + onCompiler: new AeppSdk.CompilerHttp(networks.devmode.compilerUrl, options), interval: 50, }); } diff --git a/tests/lib.test.mjs b/tests/lib.test.mjs index c53d8254..8543c6c6 100644 --- a/tests/lib.test.mjs +++ b/tests/lib.test.mjs @@ -1,6 +1,8 @@ import * as utils from "./../src/lib/utils"; import { exec, cwd, prepareLocal, cleanLocal, linkLocalLib } from "./util"; +import * as AeppSdk from "@aeternity/aepp-sdk"; + import { MemoryAccount } from "@aeternity/aepp-sdk"; describe("library usage", () => { @@ -13,7 +15,7 @@ describe("library usage", () => { await exec("aeproject env", { cwd }); - aeSdk = utils.getSdk(); + aeSdk = utils.getSdk(AeppSdk, {}); }); afterAll(async () => {