Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wasmedge improved installation #2024

Merged
merged 14 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ declarations
property_tests/tests/**/src/*
dist
static_canister_template_licenses.yml
wasmedge_quickjs
3 changes: 0 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,6 @@ jobs:
shell: bash -l {0}
working-directory: ${{ matrix.example_directories }}
run: npm link azle
- if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }}
lastmjs marked this conversation as resolved.
Show resolved Hide resolved
working-directory: ${{ matrix.example_directories }}
run: npx azle install-dfx-extension
- if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }}
working-directory: ${{ matrix.example_directories }}
run: dfx start --clean --background --host 127.0.0.1:8000
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
dist
node_modules
target
wasmedge_quickjs
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@
!package.json
!README.md
!server.did
!wasmedge_quickjs/**
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ target
/the_azle_book/book
/docs
static_canister_template_licenses.yml
/wasmedge_quickjs
6 changes: 1 addition & 5 deletions experimental/canisters/icrc/errors.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

if (globalThis._azleExperimental !== true) {
throw new Error(experimentalMessage('azle/experimental'));
}
import '../../../src/lib/experimental/experimental';

import { Record } from '../../../src/lib/experimental/candid/types/constructed/record';
import { nat } from '../../../src/lib/experimental/candid/types/primitive/nats/nat';
Expand Down
6 changes: 1 addition & 5 deletions experimental/canisters/icrc/icrc_1.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

if (globalThis._azleExperimental !== true) {
throw new Error(experimentalMessage('azle/experimental'));
}
import '../../../src/lib/experimental/experimental';

import {
blob,
Expand Down
6 changes: 1 addition & 5 deletions experimental/canisters/icrc/icrc_2.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

if (globalThis._azleExperimental !== true) {
throw new Error(experimentalMessage('azle/experimental'));
}
import '../../../src/lib/experimental/experimental';

import { blob } from '../../../src/lib/experimental/candid/types/constructed/blob';
import { Opt } from '../../../src/lib/experimental/candid/types/constructed/opt';
Expand Down
6 changes: 1 addition & 5 deletions experimental/canisters/icrc/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

if (globalThis._azleExperimental !== true) {
throw new Error(experimentalMessage('azle/experimental'));
}
import '../../../src/lib/experimental/experimental';

import {
Canister,
Expand Down
6 changes: 1 addition & 5 deletions experimental/canisters/ledger/address/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { experimentalMessage } from '../../../../src/lib/experimental/experimental';

if (globalThis._azleExperimental !== true) {
throw new Error(experimentalMessage('azle/experimental'));
}
import '../../../../src/lib/experimental/experimental';

import { Principal } from '@dfinity/principal';
import { getCrc32 } from '@dfinity/principal/lib/esm/utils/getCrc';
Expand Down
7 changes: 1 addition & 6 deletions experimental/canisters/ledger/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

if (globalThis._azleExperimental !== true) {
throw new Error(experimentalMessage('azle/experimental'));
}
import '../../../src/lib/experimental/experimental';

// Some JS docs licensed under:
//
Expand All @@ -11,7 +7,6 @@ if (globalThis._azleExperimental !== true) {
// - https://github.com/dfinity/portal/blob/master/LICENSE
//
// Some documentation changed from original work.

import {
blob,
Canister,
Expand Down
7 changes: 1 addition & 6 deletions experimental/canisters/management/bitcoin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

if (globalThis._azleExperimental !== true) {
throw new Error(experimentalMessage('azle/experimental'));
}
import '../../../src/lib/experimental/experimental';

// TODO I am thinking we should use the same names as ic-btc-types

import {
blob,
nat32,
Expand Down
7 changes: 1 addition & 6 deletions experimental/canisters/management/canister_info.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

if (globalThis._azleExperimental !== true) {
throw new Error(experimentalMessage('azle/experimental'));
}
import '../../../src/lib/experimental/experimental';

// JS docs licensed under:
//
// - https://github.com/dfinity/cdk-rs/blob/main/LICENSE
//
// Some documentation changed from original work.

import { Opt } from '../../../src/lib/experimental/candid/types/constructed/opt';
import { Record } from '../../../src/lib/experimental/candid/types/constructed/record';
import { Variant } from '../../../src/lib/experimental/candid/types/constructed/variant';
Expand Down
6 changes: 1 addition & 5 deletions experimental/canisters/management/canister_management.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

if (globalThis._azleExperimental !== true) {
throw new Error(experimentalMessage('azle/experimental'));
}
import '../../../src/lib/experimental/experimental';

import {
blob,
Expand Down
6 changes: 1 addition & 5 deletions experimental/canisters/management/http_request.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

if (globalThis._azleExperimental !== true) {
throw new Error(experimentalMessage('azle/experimental'));
}
import '../../../src/lib/experimental/experimental';

import {
blob,
Expand Down
7 changes: 1 addition & 6 deletions experimental/canisters/management/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

if (globalThis._azleExperimental !== true) {
throw new Error(experimentalMessage('azle/experimental'));
}
import '../../../src/lib/experimental/experimental';

// Some JS docs licensed under:
//
// - https://github.com/dfinity/cdk-rs/blob/main/LICENSE
//
// Some documentation changed from original work.

import { blob } from '../../../src/lib/experimental/candid/types/constructed/blob';
import { Vec } from '../../../src/lib/experimental/candid/types/constructed/vec';
import { Void } from '../../../src/lib/experimental/candid/types/primitive/void';
Expand Down
6 changes: 1 addition & 5 deletions experimental/canisters/management/t_ecdsa.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

if (globalThis._azleExperimental !== true) {
throw new Error(experimentalMessage('azle/experimental'));
}
import '../../../src/lib/experimental/experimental';

import { blob } from '../../../src/lib/experimental/candid/types/constructed/blob';
import { Opt } from '../../../src/lib/experimental/candid/types/constructed/opt';
Expand Down
6 changes: 1 addition & 5 deletions experimental/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import { experimentalMessage } from '../src/lib/experimental/experimental';

if (globalThis._azleExperimental !== true) {
throw new Error(experimentalMessage('azle/experimental'));
}
import '../src/lib/experimental/experimental';

export * from '../src/lib/experimental';
11 changes: 0 additions & 11 deletions install_script.sh

This file was deleted.

8 changes: 7 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"typecheck": "tsc --noEmit",
"lint": "if [ \"$npm_config_fix\" ]; then eslint . --ext .js,.ts --cache --fix; else eslint . --ext .js,.ts --cache; fi",
"prepare": "husky install",
"test": "test/test.sh",
"install": "./install_script.sh"
"install": "cd dfx_extension && ./install.sh",
"test": "test/test.sh"
},
"type": "module",
"bin": {
Expand Down Expand Up @@ -52,7 +52,8 @@
"text-encoding": "0.7.0",
"tsx": "^4.15.7",
"typescript": "^5.2.2",
"uuid": "^9.0.1"
"uuid": "^9.0.1",
"wasmedge_quickjs": "github:demergent-labs/wasmedge-quickjs#3b3b0ee91248ccf9cd954ffafbac7e024648af92"
},
"devDependencies": {
"@types/deep-equal": "^1.0.4",
Expand Down
1 change: 1 addition & 0 deletions publish-github-action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ directories=$(echo "$directories_json_string" | jq -c -r '.[]')

sed -E -i "s/(\"version\": \")(.*)(\")/\1$VERSION\3/" package.json
sed -E -i "s/(\"version\": \")(.*)(\")/\1$VERSION\3/" dfx_extension/extension.json
# TODO we need to keep the dependencies.json file up-to-date as well
npm install

if [[ "$VERSION" == *"-rc."* ]];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ let actor: ActorReloadJs | undefined;
const reloadedJsPath = process.argv[2];
const canisterId = process.argv[3];
const mainPath = process.argv[4];
const wasmedgeQuickJsPath = process.argv[5];
const esmAliases = JSON.parse(process.argv[6]);
const esmExternals = JSON.parse(process.argv[7]);
const canisterName = process.argv[8];
const postUpgradeIndex = Number(process.argv[9]);
const esmAliases = JSON.parse(process.argv[5]);
const esmExternals = JSON.parse(process.argv[6]);
const canisterName = process.argv[7];
const postUpgradeIndex = Number(process.argv[8]);

// TODO https://github.com/demergent-labs/azle/issues/1664
const watcher = watch([`**/*.ts`, `**/*.js`], {
Expand All @@ -44,12 +43,7 @@ watcher.on('all', async (event, path) => {

if (event === 'change') {
try {
await reloadJs(
actor,
reloadedJsPath,
mainPath,
wasmedgeQuickJsPath
);
await reloadJs(actor, reloadedJsPath, mainPath);
} catch (error) {
console.error(error);
}
Expand All @@ -59,12 +53,10 @@ watcher.on('all', async (event, path) => {
async function reloadJs(
actor: ActorReloadJs,
reloadedJsPath: string,
mainPath: string,
wasmedgeQuickJsPath: string
mainPath: string
): Promise<void> {
const javaScript = await compileJavaScript(
mainPath,
wasmedgeQuickJsPath,
esmAliases,
esmExternals
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export function setupFileWatcher(
reloadedJsPath: string,
canisterId: string,
mainPath: string,
wasmedgeQuickJsPath: string,
esmAliases: Record<string, string>,
esmExternals: string[],
canisterName: string,
Expand Down Expand Up @@ -45,7 +44,6 @@ export function setupFileWatcher(
reloadedJsPath,
canisterId,
mainPath,
wasmedgeQuickJsPath,
JSON.stringify(esmAliases),
JSON.stringify(esmExternals),
canisterName,
Expand Down
15 changes: 2 additions & 13 deletions src/build/experimental/commands/compile/get_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ import { readFile } from 'fs/promises';
import { join } from 'path';

import { getCanisterId } from '../../../../../dfx';
import { version } from '../../../../../package.json';
import { getContext as getStableContext } from '../../../stable/commands/compile/get_context';
import {
AZLE_PACKAGE_PATH,
GLOBAL_AZLE_CONFIG_DIR
} from '../../../stable/utils/global_paths';
import { AZLE_PACKAGE_PATH } from '../../../stable/utils/global_paths';
import { CanisterConfig } from '../../../stable/utils/types';
import { Context, WasmData } from '../../utils/types';
import { getConsumer } from './open_value_sharing/consumer';
Expand Down Expand Up @@ -37,19 +33,12 @@ export async function getContext(
managementDid
};

const wasmedgeQuickJsName = `wasmedge-quickjs_${version}`;
const wasmedgeQuickJsPath = join(
GLOBAL_AZLE_CONFIG_DIR,
wasmedgeQuickJsName
);

return {
...stableContext,
canisterId,
esmAliases,
esmExternals,
reloadedJsPath,
wasmData,
wasmedgeQuickJsPath
wasmData
};
}
11 changes: 2 additions & 9 deletions src/build/experimental/commands/compile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,12 @@ export async function runCommand(
main,
reloadedJsPath,
wasmBinaryPath,
wasmData,
wasmedgeQuickJsPath
wasmData
} = await getContext(canisterName, canisterConfig);

await createHiddenAzleDirectories(canisterPath);

const javaScript = await compileJavaScript(
main,
wasmedgeQuickJsPath,
esmAliases,
esmExternals
);
const javaScript = await compileJavaScript(main, esmAliases, esmExternals);

const { candid, methodMeta } = await getCandidAndMethodMeta(
canisterName,
Expand Down Expand Up @@ -74,7 +68,6 @@ export async function runCommand(
reloadedJsPath,
canisterId,
main,
wasmedgeQuickJsPath,
esmAliases,
esmExternals,
canisterName,
Expand Down
Loading
Loading