From dd2f8ee2cca088e105bbfe2ccca4a1d12d2da5e6 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 2 Jul 2024 15:44:40 -0600 Subject: [PATCH] final fixes --- src/lib/stable/system_types/result.ts | 4 +-- .../class_syntax/async_await/dfx.json | 1 - .../candid_rpc/class_syntax/bitcoin/dfx.json | 1 - .../candid_rpc/class_syntax/canister/dfx.json | 2 +- .../candid_rpc/class_syntax/ckbtc/dfx.json | 2 +- .../class_syntax/ckbtc/package-lock.json | 4 +-- .../ckbtc/wallet/backend/index.ts | 30 ++----------------- .../class_syntax/composite_queries/dfx.json | 5 ++-- .../cross_canister_calls/dfx.json | 2 +- .../candid_rpc/class_syntax/cycles/dfx.json | 2 +- .../class_syntax/ethereum_json_rpc/dfx.json | 1 - .../class_syntax/func_types/dfx.json | 2 +- .../class_syntax/heartbeat/dfx.json | 1 - .../candid_rpc/class_syntax/icrc/dfx.json | 2 +- .../class_syntax/ledger_canister/dfx.json | 2 +- .../class_syntax/management_canister/dfx.json | 1 - .../motoko_examples/threshold_ecdsa/dfx.json | 1 - .../motoko_examples/whoami/dfx.json | 1 - .../outgoing_http_requests/dfx.json | 1 - .../class_syntax/recursion/dfx.json | 2 +- .../class_syntax/rejections/dfx.json | 2 +- .../candid_rpc/class_syntax/timers/dfx.json | 1 - 22 files changed, 17 insertions(+), 53 deletions(-) diff --git a/src/lib/stable/system_types/result.ts b/src/lib/stable/system_types/result.ts index fc7ef2a57a..c4e9225958 100644 --- a/src/lib/stable/system_types/result.ts +++ b/src/lib/stable/system_types/result.ts @@ -3,8 +3,8 @@ import { IDL } from '..'; export function Result, E extends IDL.Type>( Ok: T, Err: E -): IDL.RecordClass { - return IDL.Record({ +): IDL.VariantClass { + return IDL.Variant({ Ok: Ok, Err: Err }); diff --git a/tests/end_to_end/candid_rpc/class_syntax/async_await/dfx.json b/tests/end_to_end/candid_rpc/class_syntax/async_await/dfx.json index dbf3b93b2d..43b3dafd7a 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/async_await/dfx.json +++ b/tests/end_to_end/candid_rpc/class_syntax/async_await/dfx.json @@ -5,7 +5,6 @@ "main": "src/async_await.ts", "candid": "src/async_await.did", "candid_gen": "custom", - "env": ["AZLE_TEST_FETCH"], "declarations": { "output": "test/dfx_generated/async_await", "node_compatibility": true diff --git a/tests/end_to_end/candid_rpc/class_syntax/bitcoin/dfx.json b/tests/end_to_end/candid_rpc/class_syntax/bitcoin/dfx.json index 35f1583803..eee3a40e79 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/bitcoin/dfx.json +++ b/tests/end_to_end/candid_rpc/class_syntax/bitcoin/dfx.json @@ -5,7 +5,6 @@ "main": "src/index.ts", "candid": "src/index.did", "candid_gen": "custom", - "env": ["AZLE_TEST_FETCH"], "declarations": { "output": "test/dfx_generated/bitcoin", "node_compatibility": true diff --git a/tests/end_to_end/candid_rpc/class_syntax/canister/dfx.json b/tests/end_to_end/candid_rpc/class_syntax/canister/dfx.json index f840ee96f1..70c91f9b0a 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/canister/dfx.json +++ b/tests/end_to_end/candid_rpc/class_syntax/canister/dfx.json @@ -5,7 +5,7 @@ "main": "src/index.ts", "candid": "src/index.did", "candid_gen": "custom", - "env": ["SOME_CANISTER_PRINCIPAL", "AZLE_TEST_FETCH"], + "env": ["SOME_CANISTER_PRINCIPAL"], "assets": [["src/some_canister.did", "candid/some_canister.did"]], "declarations": { "output": "test/dfx_generated/canister", diff --git a/tests/end_to_end/candid_rpc/class_syntax/ckbtc/dfx.json b/tests/end_to_end/candid_rpc/class_syntax/ckbtc/dfx.json index d5fbd3a187..b78aa81f82 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/ckbtc/dfx.json +++ b/tests/end_to_end/candid_rpc/class_syntax/ckbtc/dfx.json @@ -25,7 +25,7 @@ "main": "wallet/backend/index.ts", "candid": "wallet/backend/index.did", "candid_gen": "custom", - "env": ["CK_BTC_PRINCIPAL", "MINTER_PRINCIPAL", "AZLE_TEST_FETCH"], + "env": ["CK_BTC_PRINCIPAL", "MINTER_PRINCIPAL"], "assets": [["minter/minter.did", "minter/minter.did"]], "declarations": { "node_compatibility": true, diff --git a/tests/end_to_end/candid_rpc/class_syntax/ckbtc/package-lock.json b/tests/end_to_end/candid_rpc/class_syntax/ckbtc/package-lock.json index ac3d9b49d0..bfd91dd411 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/ckbtc/package-lock.json +++ b/tests/end_to_end/candid_rpc/class_syntax/ckbtc/package-lock.json @@ -1,10 +1,9 @@ { - "name": "ckbtc_end_to_end_test_functional_syntax", + "name": "ckbtc", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "ckbtc_end_to_end_test_functional_syntax", "hasInstallScript": true, "dependencies": { "azle": "0.22.0" @@ -20,6 +19,7 @@ } }, "../../../../../examples/ckbtc": { + "name": "ckbtc_end_to_end_test_functional_syntax", "dev": true, "hasInstallScript": true, "dependencies": { diff --git a/tests/end_to_end/candid_rpc/class_syntax/ckbtc/wallet/backend/index.ts b/tests/end_to_end/candid_rpc/class_syntax/ckbtc/wallet/backend/index.ts index 261bde546e..ab47f564f5 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/ckbtc/wallet/backend/index.ts +++ b/tests/end_to_end/candid_rpc/class_syntax/ckbtc/wallet/backend/index.ts @@ -20,7 +20,7 @@ export default class { async getBalance() { return await call(getCkBtcPrincipal(), 'icrc1_balance_of', { paramIdls: [Account], - returnIdl: IDL.Nat64, + returnIdl: IDL.Nat, args: [ { owner: id(), @@ -50,33 +50,6 @@ export default class { ); return updateBalanceResult; - - // TODO get rid of Result - // if ('Err' in updateBalanceResult) { - // const err = updateBalanceResult.Err; - // if ('TemporarilyUnavailable' in err) { - // throw new Error( - // `Temporarily Unavailable: ${err.TemporarilyUnavailable}` - // ); - // } - // if ('AlreadyProcessing' in err) { - // throw new Error('Already processing'); - // } - // if ('GenericError' in err) { - // throw new Error( - // `Error: ${err.GenericError.error_code}: ${err.GenericError.error_message}` - // ); - // } - // if ('NoNewUtxos' in err) { - // throw new Error( - // `No new UTXOs: ${err.NoNewUtxos.current_confirmations}/${err.NoNewUtxos.required_confirmations}` - // ); - // } - // } - - // if ('Ok' in updateBalanceResult) { - // return updateBalanceResult.Ok; - // } } @update([], IDL.Text) @@ -130,6 +103,7 @@ function padPrincipalWithZeros(blob: Uint8Array): Uint8Array { function getCkBtcPrincipal(): string { if (process.env.CK_BTC_PRINCIPAL !== undefined) { + console.log(process.env.CK_BTC_PRINCIPAL); return process.env.CK_BTC_PRINCIPAL; } diff --git a/tests/end_to_end/candid_rpc/class_syntax/composite_queries/dfx.json b/tests/end_to_end/candid_rpc/class_syntax/composite_queries/dfx.json index 8be5536969..bd9b4a5c6e 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/composite_queries/dfx.json +++ b/tests/end_to_end/candid_rpc/class_syntax/composite_queries/dfx.json @@ -8,8 +8,7 @@ "env": [ "CANISTER1_PRINCIPAL", "CANISTER2_PRINCIPAL", - "CANISTER3_PRINCIPAL", - "AZLE_TEST_FETCH" + "CANISTER3_PRINCIPAL" ], "assets": [ ["src/canister2/index.did", "candid/canister2.did"], @@ -25,7 +24,7 @@ "main": "src/canister2/index.ts", "candid": "src/canister2/index.did", "candid_gen": "custom", - "env": ["CANISTER3_PRINCIPAL", "AZLE_TEST_FETCH"], + "env": ["CANISTER3_PRINCIPAL"], "assets": [["src/canister3/index.did", "candid/canister3.did"]], "declarations": { "output": "test/dfx_generated/canister2", diff --git a/tests/end_to_end/candid_rpc/class_syntax/cross_canister_calls/dfx.json b/tests/end_to_end/candid_rpc/class_syntax/cross_canister_calls/dfx.json index d4fcbadc6e..01dd5de576 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/cross_canister_calls/dfx.json +++ b/tests/end_to_end/candid_rpc/class_syntax/cross_canister_calls/dfx.json @@ -5,7 +5,7 @@ "main": "src/canister1/index.ts", "candid": "src/canister1/index.did", "candid_gen": "custom", - "env": ["CANISTER2_PRINCIPAL", "AZLE_TEST_FETCH"], + "env": ["CANISTER2_PRINCIPAL"], "assets": [["src/canister2/index.did", "candid/canister2.did"]], "declarations": { "output": "test/dfx_generated/canister1", diff --git a/tests/end_to_end/candid_rpc/class_syntax/cycles/dfx.json b/tests/end_to_end/candid_rpc/class_syntax/cycles/dfx.json index a94bb33854..8a7e4835c8 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/cycles/dfx.json +++ b/tests/end_to_end/candid_rpc/class_syntax/cycles/dfx.json @@ -15,7 +15,7 @@ "main": "src/intermediary/index.ts", "candid": "src/intermediary/index.did", "candid_gen": "custom", - "env": ["CYCLES_PRINCIPAL", "AZLE_TEST_FETCH"], + "env": ["CYCLES_PRINCIPAL"], "assets": [["src/cycles/index.did", "candid/cycles.did"]], "declarations": { "output": "test/dfx_generated/intermediary", diff --git a/tests/end_to_end/candid_rpc/class_syntax/ethereum_json_rpc/dfx.json b/tests/end_to_end/candid_rpc/class_syntax/ethereum_json_rpc/dfx.json index d085cb9515..d33bdff4b6 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/ethereum_json_rpc/dfx.json +++ b/tests/end_to_end/candid_rpc/class_syntax/ethereum_json_rpc/dfx.json @@ -5,7 +5,6 @@ "main": "src/index.ts", "candid": "src/index.did", "candid_gen": "custom", - "env": ["AZLE_TEST_FETCH"], "declarations": { "output": "test/dfx_generated/ethereum_json_rpc", "node_compatibility": true diff --git a/tests/end_to_end/candid_rpc/class_syntax/func_types/dfx.json b/tests/end_to_end/candid_rpc/class_syntax/func_types/dfx.json index aa9bcdeaf0..7e651ee667 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/func_types/dfx.json +++ b/tests/end_to_end/candid_rpc/class_syntax/func_types/dfx.json @@ -5,7 +5,7 @@ "main": "canisters/func_types/index.ts", "candid": "canisters/func_types/index.did", "candid_gen": "custom", - "env": ["NOTIFIERS_PRINCIPAL", "AZLE_TEST_FETCH"], + "env": ["NOTIFIERS_PRINCIPAL"], "assets": [ ["canisters/notifiers/index.did", "candid/notifiers.did"] ], diff --git a/tests/end_to_end/candid_rpc/class_syntax/heartbeat/dfx.json b/tests/end_to_end/candid_rpc/class_syntax/heartbeat/dfx.json index a14a9fabbe..9c2986789f 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/heartbeat/dfx.json +++ b/tests/end_to_end/candid_rpc/class_syntax/heartbeat/dfx.json @@ -5,7 +5,6 @@ "main": "src/heartbeat_async/index.ts", "candid": "src/heartbeat_async/index.did", "candid_gen": "custom", - "env": ["AZLE_TEST_FETCH"], "declarations": { "output": "test/dfx_generated/heartbeat_async", "node_compatibility": true diff --git a/tests/end_to_end/candid_rpc/class_syntax/icrc/dfx.json b/tests/end_to_end/candid_rpc/class_syntax/icrc/dfx.json index 74104ff66f..eef3cf9c64 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/icrc/dfx.json +++ b/tests/end_to_end/candid_rpc/class_syntax/icrc/dfx.json @@ -5,7 +5,7 @@ "main": "canisters/proxy/index.ts", "candid": "canisters/proxy/index.did", "candid_gen": "custom", - "env": ["ICRC_PRINCIPAL", "AZLE_TEST_FETCH"], + "env": ["ICRC_PRINCIPAL"], "declarations": { "output": "test/dfx_generated/proxy", "node_compatibility": true diff --git a/tests/end_to_end/candid_rpc/class_syntax/ledger_canister/dfx.json b/tests/end_to_end/candid_rpc/class_syntax/ledger_canister/dfx.json index ce1dac83b1..dd06f023bb 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/ledger_canister/dfx.json +++ b/tests/end_to_end/candid_rpc/class_syntax/ledger_canister/dfx.json @@ -5,7 +5,7 @@ "main": "src/ledger_canister/index.ts", "candid": "src/ledger_canister/index.did", "candid_gen": "custom", - "env": ["ICP_CANISTER_PRINCIPAL", "AZLE_TEST_FETCH"], + "env": ["ICP_CANISTER_PRINCIPAL"], "assets": [["src/icp_ledger/ledger.public.did", "src/ledger.did"]], "declarations": { "output": "test/dfx_generated/ledger_canister", diff --git a/tests/end_to_end/candid_rpc/class_syntax/management_canister/dfx.json b/tests/end_to_end/candid_rpc/class_syntax/management_canister/dfx.json index e30d09252c..805469437b 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/management_canister/dfx.json +++ b/tests/end_to_end/candid_rpc/class_syntax/management_canister/dfx.json @@ -5,7 +5,6 @@ "main": "src/index.ts", "candid": "src/index.did", "candid_gen": "custom", - "env": ["AZLE_TEST_FETCH"], "declarations": { "output": "test/dfx_generated/management_canister", "node_compatibility": true diff --git a/tests/end_to_end/candid_rpc/class_syntax/motoko_examples/threshold_ecdsa/dfx.json b/tests/end_to_end/candid_rpc/class_syntax/motoko_examples/threshold_ecdsa/dfx.json index 282b90ddf8..012aca0c3d 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/motoko_examples/threshold_ecdsa/dfx.json +++ b/tests/end_to_end/candid_rpc/class_syntax/motoko_examples/threshold_ecdsa/dfx.json @@ -5,7 +5,6 @@ "main": "src/index.ts", "candid": "src/index.did", "candid_gen": "custom", - "env": ["AZLE_TEST_FETCH"], "declarations": { "output": "test/dfx_generated/threshold_ecdsa", "node_compatibility": true diff --git a/tests/end_to_end/candid_rpc/class_syntax/motoko_examples/whoami/dfx.json b/tests/end_to_end/candid_rpc/class_syntax/motoko_examples/whoami/dfx.json index 5ad1e2e5af..195757fecb 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/motoko_examples/whoami/dfx.json +++ b/tests/end_to_end/candid_rpc/class_syntax/motoko_examples/whoami/dfx.json @@ -5,7 +5,6 @@ "main": "src/index.ts", "candid": "src/index.did", "candid_gen": "custom", - "env": ["AZLE_TEST_FETCH"], "declarations": { "output": "test/dfx_generated/whoami", "node_compatibility": true diff --git a/tests/end_to_end/candid_rpc/class_syntax/outgoing_http_requests/dfx.json b/tests/end_to_end/candid_rpc/class_syntax/outgoing_http_requests/dfx.json index b0677463ed..c61bbf849f 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/outgoing_http_requests/dfx.json +++ b/tests/end_to_end/candid_rpc/class_syntax/outgoing_http_requests/dfx.json @@ -5,7 +5,6 @@ "main": "src/index.ts", "candid": "src/index.did", "candid_gen": "custom", - "env": ["AZLE_TEST_FETCH"], "declarations": { "output": "test/dfx_generated/outgoing_http_requests", "node_compatibility": true diff --git a/tests/end_to_end/candid_rpc/class_syntax/recursion/dfx.json b/tests/end_to_end/candid_rpc/class_syntax/recursion/dfx.json index d7a922d7aa..a23c1b1a03 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/recursion/dfx.json +++ b/tests/end_to_end/candid_rpc/class_syntax/recursion/dfx.json @@ -5,7 +5,7 @@ "main": "src/recursion/index.ts", "candid": "src/recursion/index.did", "candid_gen": "custom", - "env": ["MY_CANISTER_PRINCIPAL", "AZLE_TEST_FETCH"], + "env": ["MY_CANISTER_PRINCIPAL"], "assets": [ [ "src/recursive_canister/index.did", diff --git a/tests/end_to_end/candid_rpc/class_syntax/rejections/dfx.json b/tests/end_to_end/candid_rpc/class_syntax/rejections/dfx.json index dcb04f3350..2f6323d3c8 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/rejections/dfx.json +++ b/tests/end_to_end/candid_rpc/class_syntax/rejections/dfx.json @@ -5,7 +5,7 @@ "main": "src/rejections/index.ts", "candid": "src/rejections/index.did", "candid_gen": "custom", - "env": ["SOME_CANISTER_PRINCIPAL", "AZLE_TEST_FETCH"], + "env": ["SOME_CANISTER_PRINCIPAL"], "assets": [ ["src/some_canister/index.did", "candid/some_canister.did"], ["src/nonexistent.did", "candid/nonexistent.did"] diff --git a/tests/end_to_end/candid_rpc/class_syntax/timers/dfx.json b/tests/end_to_end/candid_rpc/class_syntax/timers/dfx.json index 1ec9bb50ba..a032aa0225 100644 --- a/tests/end_to_end/candid_rpc/class_syntax/timers/dfx.json +++ b/tests/end_to_end/candid_rpc/class_syntax/timers/dfx.json @@ -5,7 +5,6 @@ "main": "src/timers.ts", "candid": "src/timers.did", "candid_gen": "custom", - "env": ["AZLE_TEST_FETCH"], "declarations": { "output": "test/dfx_generated/timers", "node_compatibility": true