Skip to content

Commit

Permalink
Merge pull request #1991 from demergent-labs/experimental_flag
Browse files Browse the repository at this point in the history
Experimental flag: azle/experimental and Node APIs
  • Loading branch information
lastmjs authored Aug 19, 2024
2 parents a5ab26e + 859279e commit 2e337a7
Show file tree
Hide file tree
Showing 406 changed files with 1,895 additions and 482 deletions.
2 changes: 1 addition & 1 deletion benchmark/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { execSync } from 'child_process';
import { writeFileSync } from 'fs';

import { nat64 } from '../src/lib';
import { nat64 } from '../src/lib/experimental';
import { create_csv_report } from './csv';
import { create_markdown_report } from './markdown';
import { run_setup } from './setup';
Expand Down
2 changes: 1 addition & 1 deletion canisters/ledger/address/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getCrc32 } from '@dfinity/principal/lib/esm/utils/getCrc';
import { sha224 } from 'js-sha256';

import { blob, Principal } from '../../../src/lib';
import { blob, Principal } from '../../../src/lib/experimental';
import { Address } from '../index';

// TODO we need to review these heavily
Expand Down
5 changes: 4 additions & 1 deletion examples/basic_bitcoin/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"basic_bitcoin": {
"type": "azle",
"main": "src/index.ts",
"env": ["BITCOIN_NETWORK"]
"env": ["BITCOIN_NETWORK"],
"custom": {
"experimental": true
}
}
},
"networks": {
Expand Down
2 changes: 2 additions & 0 deletions examples/basic_bitcoin/test/tests.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'azle/test/set_experimental';

import { beforeAll } from '@jest/globals';
import { jsonParse, jsonStringify } from 'azle/experimental';
import { GetUtxosResult, Utxo } from 'azle/experimental/canisters/management';
Expand Down
5 changes: 4 additions & 1 deletion examples/bitcoin_psbt/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"bitcoin_psbt": {
"type": "azle",
"main": "src/index.ts",
"env": ["BITCOIN_NETWORK"]
"env": ["BITCOIN_NETWORK"],
"custom": {
"experimental": true
}
}
},
"networks": {
Expand Down
5 changes: 4 additions & 1 deletion examples/hello_world/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"type": "azle",
"main": "src/backend/index.ts",
"assets": [["src/frontend/dist", "dist"]],
"build_assets": "npm run build"
"build_assets": "npm run build",
"custom": {
"experimental": true
}
}
}
}
6 changes: 6 additions & 0 deletions experimental/canisters/icrc/errors.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

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

import { nat, Record, text } from '../../';

export const BadFee = Record({
Expand Down
6 changes: 6 additions & 0 deletions experimental/canisters/icrc/icrc_1.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

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

import {
blob,
int,
Expand Down
6 changes: 6 additions & 0 deletions experimental/canisters/icrc/icrc_2.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

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

import { blob, nat, nat64, Null, Opt, Record, Variant } from '../../';
import {
BadBurn,
Expand Down
6 changes: 6 additions & 0 deletions experimental/canisters/icrc/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

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

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

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

import { getCrc32 } from '@dfinity/principal/lib/esm/utils/getCrc';
import { sha224 } from 'js-sha256';

Expand Down
6 changes: 6 additions & 0 deletions experimental/canisters/ledger/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

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

// Some JS docs licensed under:
//
// - https://github.com/dfinity/cdk-rs/blob/main/LICENSE
Expand Down
6 changes: 6 additions & 0 deletions experimental/canisters/management/bitcoin.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

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

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

import {
Expand Down
6 changes: 6 additions & 0 deletions experimental/canisters/management/canister_info.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

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

// JS docs licensed under:
//
// - https://github.com/dfinity/cdk-rs/blob/main/LICENSE
Expand Down
6 changes: 6 additions & 0 deletions experimental/canisters/management/canister_management.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

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

import {
blob,
nat,
Expand Down
6 changes: 6 additions & 0 deletions experimental/canisters/management/http_request.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

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

import {
blob,
Func,
Expand Down
6 changes: 6 additions & 0 deletions experimental/canisters/management/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

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

// Some JS docs licensed under:
//
// - https://github.com/dfinity/cdk-rs/blob/main/LICENSE
Expand Down
6 changes: 6 additions & 0 deletions experimental/canisters/management/t_ecdsa.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { experimentalMessage } from '../../../src/lib/experimental/experimental';

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

import { blob, Null, Opt, Principal, Record, text, Variant, Vec } from '../../';

export const EcdsaCurve = Variant({
Expand Down
8 changes: 7 additions & 1 deletion experimental/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
export * from '../src/lib';
import { experimentalMessage } from '../src/lib/experimental/experimental';

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

export * from '../src/lib/experimental';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fc from 'fast-check';

import { CandidType as RuntimeCandidType } from '../../../../src/lib/candid/candid_type';
import { CandidType as RuntimeCandidType } from '../../../../src/lib/experimental/candid/candid_type';
import { CandidType } from '../candid_type';
import { RecursiveShapes } from '../recursive';
import { ServiceMethodDefinition } from '../reference/service_arb/service_method_arb';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fc from 'fast-check';

import { CandidType as RuntimeCandidType } from '../../../src/lib';
import { CandidType as RuntimeCandidType } from '../../../src/lib/experimental';
import { CandidValueConstraints } from './candid_values_arb';
import { BlobArb } from './constructed/blob_arb';
import { OptArb } from './constructed/opt_arb';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fc from 'fast-check';

import { blob } from '../../../../../src/lib';
import { blob } from '../../../../../src/lib/experimental';
import { UniqueIdentifierArb } from '../../../unique_identifier_arb';
import {
BlobCandidDefinition,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fc from 'fast-check';

import { CandidType, Opt } from '../../../../../src/lib';
import { CandidType, Opt } from '../../../../../src/lib/experimental';
import { UniqueIdentifierArb } from '../../../unique_identifier_arb';
import {
CandidDefinition,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fc from 'fast-check';

import { CandidType, Record } from '../../../../../src/lib';
import { CandidType, Record } from '../../../../../src/lib/experimental';
import { JsFunctionNameArb } from '../../../js_function_name_arb';
import { UniqueIdentifierArb } from '../../../unique_identifier_arb';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fc from 'fast-check';

import { CandidType, Tuple } from '../../../../../src/lib';
import { CandidType, Tuple } from '../../../../../src/lib/experimental';
import { UniqueIdentifierArb } from '../../../unique_identifier_arb';
import {
CandidDefinition,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fc from 'fast-check';

import { CandidType, Variant } from '../../../../../src/lib';
import { CandidType, Variant } from '../../../../../src/lib/experimental';
import { JsFunctionNameArb } from '../../../js_function_name_arb';
import { UniqueIdentifierArb } from '../../../unique_identifier_arb';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fc from 'fast-check';

import { CandidType, Vec } from '../../../../../src/lib';
import { CandidType, Vec } from '../../../../../src/lib/experimental';
import { UniqueIdentifierArb } from '../../../unique_identifier_arb';
import {
CandidDefinition,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fc from 'fast-check';

import { CandidType, Recursive } from '../../../../src/lib';
import { CandidType, Recursive } from '../../../../src/lib/experimental';
import { UniqueIdentifierArb } from '../../unique_identifier_arb';
import {
CandidDefinition,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fc from 'fast-check';

import { CandidType, Func } from '../../../../../src/lib';
import { CandidType, Func } from '../../../../../src/lib/experimental';
import { UniqueIdentifierArb } from '../../../unique_identifier_arb';
import {
CandidDefinition,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fc from 'fast-check';

import { Canister } from '../../../../../src/lib/candid/types/reference/service';
import { Canister } from '../../../../../src/lib/experimental/candid/types/reference/service';
import { UniqueIdentifierArb } from '../../../unique_identifier_arb';
import {
CandidDefinition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import fc from 'fast-check';
import {
query,
update
} from '../../../../../src/lib/canister_methods/methods/';
import { CanisterMethodInfo } from '../../../../../src/lib/canister_methods/types/canister_method_info';
} from '../../../../../src/lib/experimental/canister_methods/methods/';
import { CanisterMethodInfo } from '../../../../../src/lib/experimental/canister_methods/types/canister_method_info';
import { JsFunctionNameArb } from '../../../js_function_name_arb';
import {
CandidDefinition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
Principal,
text,
Void
} from '../../../../src/lib';
} from '../../../../src/lib/experimental';
import { SimpleCandidType } from '../candid_type';

export function candidTypeToRuntimeCandidTypeObject(
Expand Down
2 changes: 1 addition & 1 deletion property_tests/arbitraries/http/request_arb.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fc from 'fast-check';

import { HttpRequest, None, Some } from '../../../src/lib';
import { HttpRequest, None, Some } from '../../../src/lib/experimental';
import { CandidValueAndMeta } from '../candid/candid_value_and_meta_arb';
import { blobToSrcLiteral } from '../candid/to_src_literal/blob';
import { stringToSrcLiteral } from '../candid/to_src_literal/string';
Expand Down
2 changes: 1 addition & 1 deletion property_tests/arbitraries/http/response_arb.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fc from 'fast-check';

import { HttpResponse, None } from '../../../src/lib';
import { HttpResponse, None } from '../../../src/lib/experimental';
import { CandidValueAndMeta } from '../candid/candid_value_and_meta_arb';
import { CorrespondingJSType } from '../candid/corresponding_js_type';
import { blobToSrcLiteral } from '../candid/to_src_literal/blob';
Expand Down
2 changes: 2 additions & 0 deletions property_tests/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import './set_experimental';

import { execSync } from 'child_process';
// @ts-ignore
import libraryDeepEqual from 'deep-is';
Expand Down
1 change: 1 addition & 0 deletions property_tests/set_experimental.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
globalThis._azleExperimental = true;
2 changes: 1 addition & 1 deletion property_tests/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const deepEqual = require('deep-is');

import { jsonStringify } from '../../src/lib/json';
import { jsonStringify } from '../../src/lib/experimental/json';

export type Test<> = {
name: string;
Expand Down
3 changes: 3 additions & 0 deletions property_tests/tests/blob/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"declarations": {
"output": "test/dfx_generated/canister",
"node_compatibility": true
},
"custom": {
"experimental": true
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions property_tests/tests/bool/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"declarations": {
"output": "test/dfx_generated/canister",
"node_compatibility": true
},
"custom": {
"experimental": true
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions property_tests/tests/canister_methods/http_request/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"declarations": {
"output": "test/dfx_generated/canister",
"node_compatibility": true
},
"custom": {
"experimental": true
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"declarations": {
"output": "test/dfx_generated/canister",
"node_compatibility": true
},
"custom": {
"experimental": true
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions property_tests/tests/canister_methods/init/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"declarations": {
"output": "test/dfx_generated/canister",
"node_compatibility": true
},
"custom": {
"experimental": true
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"declarations": {
"output": "test/dfx_generated/canister",
"node_compatibility": true
},
"custom": {
"experimental": true
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions property_tests/tests/canister_methods/post_upgrade/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"declarations": {
"output": "test/dfx_generated/canister",
"node_compatibility": true
},
"custom": {
"experimental": true
}
}
}
Expand Down
Loading

0 comments on commit 2e337a7

Please sign in to comment.