Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Jul 1, 2024
1 parent 8da5f82 commit 7384419
Show file tree
Hide file tree
Showing 43 changed files with 46,993 additions and 10,678 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ jobs:
"tests/end_to_end/candid_rpc/class_syntax/init",
"tests/end_to_end/candid_rpc/class_syntax/inspect_message",
"tests/end_to_end/candid_rpc/class_syntax/key_value_store",
"tests/end_to_end/candid_rpc/class_syntax/large_files",
"tests/end_to_end/candid_rpc/class_syntax/ledger_canister",
"tests/end_to_end/candid_rpc/class_syntax/list_of_lists",
"tests/end_to_end/candid_rpc/class_syntax/management_canister",
Expand Down
3 changes: 2 additions & 1 deletion examples/icrc/package-lock.json

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

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"scripts": {
"pre_tests": "ts-node --transpile-only --ignore=false test/pretest.ts",
"tests": "npm run pre_tests && jest",
"test": "AZLE_TEST_FETCH=false npm run tests && AZLE_TEST_FETCH=true npm run tests"
"pretest": "ts-node --transpile-only --ignore=false test/pretest.ts",
"test": "jest"
},
"dependencies": {
"azle": "0.22.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "canister_end_to_end_test_functional_syntax",
"scripts": {
"pre_tests": "ts-node --transpile-only --ignore=false test/pretest.ts",
"tests": "npm run pre_tests && jest",
"test": "AZLE_TEST_FETCH=false npm run tests && AZLE_TEST_FETCH=true npm run tests"
"pretest": "ts-node --transpile-only --ignore=false test/pretest.ts",
"test": "jest"
},
"dependencies": {
"azle": "0.22.0"
Expand Down
5 changes: 2 additions & 3 deletions tests/end_to_end/candid_rpc/class_syntax/ckbtc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
"frontend": "npx open-cli http://ryjl3-tyaaa-aaaaa-aaaba-cai.localhost:8000/",
"mint": ".bitcoin/bin/bitcoin-cli -conf=$(pwd)/.bitcoin.conf generatetoaddress 1 $npm_config_address",
"build": "cd wallet/frontend && npm run build",
"pre_tests": "ts-node --transpile-only --ignore=false test/pretest.ts",
"tests": "npm run pre_tests && jest",
"test": "AZLE_TEST_FETCH=false npm run tests && AZLE_TEST_FETCH=true npm run tests"
"pretest": "ts-node --transpile-only --ignore=false test/pretest.ts",
"test": "jest"
},
"dependencies": {
"azle": "0.22.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { execSync } from 'child_process';
import { join } from 'path';

async function pretest() {
linkAndInstallPatch(join('examples', 'composite_query'));
linkAndInstallPatch(join('examples', 'composite_queries'));

execSync(`dfx canister uninstall-code canister1 || true`, {
stdio: 'inherit'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class {

@update([], IDL.Empty)
async trap(): Promise<never> {
return await call(canister2Id, 'trap');
return (await call(canister2Id, 'trap')) as never;
}

@update([])
Expand Down

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

5 changes: 2 additions & 3 deletions tests/end_to_end/candid_rpc/class_syntax/cycles/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "cycles_end_to_end_test_functional_syntax",
"scripts": {
"pre_tests": "ts-node --transpile-only --ignore=false test/pretest.ts",
"tests": "npm run pre_tests && jest",
"test": "AZLE_TEST_FETCH=false npm run tests && AZLE_TEST_FETCH=true npm run tests"
"pretest": "ts-node --transpile-only --ignore=false test/pretest.ts",
"test": "jest"
},
"dependencies": {
"azle": "0.22.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,55 +1,63 @@
import { call, IDL, init, query, update } from 'azle';

import Cycles from '../cycles';

let cyclesCanister: typeof Cycles;
import {
call,
canisterBalance,
canisterBalance128,
IDL,
msgCyclesRefunded128,
notify,
query,
trap,
update
} from 'azle';

export default class {
@init([])
init() {
cyclesCanister = Cycles(Principal.fromText(getCyclesPrincipal()));
}
// Reports the number of cycles returned from the Cycles canister
@update([], IDL.Nat64)
async sendCycles() {
return await call(cyclesCanister.receiveCycles, {
cycles: 1_000_000n
return await call(getCyclesPrincipal(), 'receiveCycles', {
returnIdl: IDL.Nat64,
payment: 1_000_000n
});
}

@update([])
sendCyclesNotify() {
return ic.notify(cyclesCanister.receiveCycles, {
cycles: 1_000_000n
return notify(getCyclesPrincipal(), 'receiveCycles', {
payment: 1_000_000n
});
}

// Reports the number of cycles returned from the Cycles canister
@update([], IDL.Nat)
async sendCycles128() {
await call(cyclesCanister.receiveCycles128, {
cycles128: 1_000_000n
await call(getCyclesPrincipal(), 'receiveCycles128', {
payment: 1_000_000n
});

return ic.msgCyclesRefunded128();
return msgCyclesRefunded128();
}

@update([])
sendCycles128Notify() {
return ic.notify(cyclesCanister.receiveCycles128, {
cycles: 1_000_000n
return notify(getCyclesPrincipal(), 'receiveCycles128', {
payment: 1_000_000n
});
}

@query([], IDL.Nat64)
getCanisterBalance() {
return ic.canisterBalance();
return canisterBalance();
}

@query([], IDL.Nat)
getCanisterBalance128() {
return ic.canisterBalance128();
return canisterBalance128();
}
}

function getCyclesPrincipal(): string {
return (
process.env.CYCLES_PRINCIPAL ??
ic.trap('process.env.CYCLES_PRINCIPAL is undefined')
trap('process.env.CYCLES_PRINCIPAL is undefined')
);
}

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

Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "ethereum_json_rpc_end_to_end_test_functional_syntax",
"scripts": {
"pre_tests": "ETHEREUM_URL=https://rpc.ankr.com/eth ts-node --transpile-only --ignore=false test/pretest.ts",
"tests": "ETHEREUM_URL=https://rpc.ankr.com/eth npm run pre_tests && jest",
"test": "ETHEREUM_URL=https://rpc.ankr.com/eth AZLE_TEST_FETCH=false npm run tests && ETHEREUM_URL=https://rpc.ankr.com/eth AZLE_TEST_FETCH=true npm run tests"
"pretest": "ETHEREUM_URL=https://rpc.ankr.com/eth ts-node --transpile-only --ignore=false test/pretest.ts",
"test": "jest"
},
"dependencies": {
"azle": "0.22.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ export default class {

@update([], NotifierFunc)
async getNotifierFromNotifiersCanister(): Promise<NotifierFunc> {
return await call(getNotifierPrincipal(), 'getNotifier');
return await call(getNotifierPrincipal(), 'getNotifier', {
returnIdl: NotifierFunc
});
}
}

Expand Down

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

Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "func_types_end_to_end_test_functional_syntax",
"scripts": {
"pre_tests": "ts-node --transpile-only --ignore=false test/pretest.ts",
"tests": "npm run pre_tests && jest",
"test": "AZLE_TEST_FETCH=false npm run tests && AZLE_TEST_FETCH=true npm run tests"
"pretest": "ts-node --transpile-only --ignore=false test/pretest.ts",
"test": "jest"
},
"dependencies": {
"azle": "0.22.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { linkAndInstallPatch } from 'azle/test/jest_link';
import { execSync } from 'child_process';
import { join } from 'path';

async function pretest() {
linkAndInstallPatch(join('examples', 'func_types'));

execSync(`dfx canister uninstall-code guard_functions || true`, {
stdio: 'inherit'
});
Expand Down
4 changes: 1 addition & 3 deletions tests/end_to_end/candid_rpc/class_syntax/ic_api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default class {
return true;
}

@query([IDL.Text], [IDL.Empty], { manual: true })
@query([IDL.Text], IDL.Empty, { manual: true })
reject(message: string): void {
reject(message);
}
Expand All @@ -175,7 +175,5 @@ export default class {
@query([IDL.Text], IDL.Bool)
trap(message: string): boolean {
trap(message);

return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
service: () -> {
icrc1_balance_of: (record {owner:principal; subaccount:opt vec nat8}) -> (nat) query;
icrc1_decimals: () -> (nat8) query;
icrc1_fee: () -> (nat) query;
icrc1_metadata: () -> (vec record {text; variant {Int:int; Nat:nat; Blob:vec nat8; Text:text}}) query;
icrc1_minting_account: () -> (opt record {owner:principal; subaccount:opt vec nat8}) query;
icrc1_name: () -> (text) query;
icrc1_supported_standards: () -> (vec record {url:text; name:text}) query;
icrc1_symbol: () -> (text) query;
icrc1_total_supply: () -> (nat) query;
icrc1_transfer: (record {to:record {owner:principal; subaccount:opt vec nat8}; fee:opt nat; memo:opt vec nat8; from_subaccount:opt vec nat8; created_at_time:opt nat64; amount:nat}) -> (variant {Ok:nat; Err:variant {GenericError:record {message:text; error_code:nat}; TemporarilyUnavailable; BadBurn:record {min_burn_amount:nat}; Duplicate:record {duplicate_of:nat}; BadFee:record {expected_fee:nat}; CreatedInFuture:record {ledger_time:nat64}; TooOld; InsufficientFunds:record {balance:nat}}});
icrc2_allowance: (record {account:record {owner:principal; subaccount:opt vec nat8}; spender:record {owner:principal; subaccount:opt vec nat8}}) -> (record {allowance:nat; expires_at:opt nat64});
icrc2_approve: (record {fee:opt nat; memo:opt vec nat8; from_subaccount:opt vec nat8; created_at_time:opt nat64; amount:nat; expected_allowance:opt nat; expires_at:opt nat64; spender:record {owner:principal; subaccount:opt vec nat8}}) -> (variant {Ok:nat; Err:variant {GenericError:record {message:text; error_code:nat}; TemporarilyUnavailable; Duplicate:record {duplicate_of:nat}; BadFee:record {expected_fee:nat}; AllowanceChanged:record {current_allowance:nat}; CreatedInFuture:record {ledger_time:nat64}; TooOld; Expired:record {ledger_time:nat64}; InsufficientFunds:record {balance:nat}}});
icrc2_transfer_from: (record {to:record {owner:principal; subaccount:opt vec nat8}; fee:opt nat; spender_subaccount:opt vec nat8; from:record {owner:principal; subaccount:opt vec nat8}; memo:opt vec nat8; created_at_time:opt nat64; amount:nat}) -> (variant {Ok:nat; Err:variant {GenericError:record {message:text; error_code:nat}; TemporarilyUnavailable; InsufficientAllowance:record {allowance:nat}; BadBurn:record {min_burn_amount:nat}; Duplicate:record {duplicate_of:nat}; BadFee:record {expected_fee:nat}; CreatedInFuture:record {ledger_time:nat64}; TooOld; InsufficientFunds:record {balance:nat}}});
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,63 +14,85 @@ import {
} from 'azle/canisters/icrc';

export default class {
@query([], IDL.Vec(IDL.Tuple(IDL.Text, Value)))
@query([], IDL.Vec(IDL.Tuple(IDL.Text, Value)), { composite: true })
async icrc1_metadata(): Promise<[Text, Value][]> {
return await call(getIcrcPrincipal(), 'icrc1_metadata');
return await call(getIcrcPrincipal(), 'icrc1_metadata', {
returnIdl: IDL.Vec(IDL.Tuple(IDL.Text, Value))
});
}

@query([], IDL.Text)
@query([], IDL.Text, { composite: true })
async icrc1_name(): Promise<string> {
return await call(getIcrcPrincipal(), 'icrc1_name');
return await call(getIcrcPrincipal(), 'icrc1_name', {
returnIdl: IDL.Text
});
}

@query([], IDL.Nat8)
@query([], IDL.Nat8, { composite: true })
async icrc1_decimals(): Promise<number> {
return await call(getIcrcPrincipal(), 'icrc1_decimals');
return await call(getIcrcPrincipal(), 'icrc1_decimals', {
returnIdl: IDL.Nat8
});
}

@query([], IDL.Text)
@query([], IDL.Text, { composite: true })
async icrc1_symbol(): Promise<string> {
return await call(getIcrcPrincipal(), 'icrc1_symbol');
return await call(getIcrcPrincipal(), 'icrc1_symbol', {
returnIdl: IDL.Text
});
}

@query([], IDL.Nat)
@query([], IDL.Nat, { composite: true })
async icrc1_fee(): Promise<string> {
return await call(getIcrcPrincipal(), 'icrc1_fee');
return await call(getIcrcPrincipal(), 'icrc1_fee', {
returnIdl: IDL.Nat
});
}

@query([], IDL.Nat)
@query([], IDL.Nat, { composite: true })
async icrc1_total_supply(): Promise<bigint> {
return await call(getIcrcPrincipal(), 'icrc1_total_supply');
return await call(getIcrcPrincipal(), 'icrc1_total_supply', {
returnIdl: IDL.Nat
});
}

@query([], IDL.Opt(Account))
@query([], IDL.Opt(Account), { composite: true })
async icrc1_minting_account(): Promise<[Account] | []> {
return await call(getIcrcPrincipal(), 'icrc1_minting_account');
return await call(getIcrcPrincipal(), 'icrc1_minting_account', {
returnIdl: IDL.Opt(Account)
});
}

@query([Account], IDL.Nat)
@query([Account], IDL.Nat, { composite: true })
async icrc1_balance_of(account: Account): Promise<bigint> {
return await call(getIcrcPrincipal(), 'icrc1_balance_of', {
paramIdls: [Account],
returnIdl: IDL.Nat,
args: [account]
});
}

@update([TransferArgs], TransferResult)
async icrc1_transfer(transferArgs: TransferArgs): Promise<TransferResult> {
return await call(getIcrcPrincipal(), 'icrc1_transfer', {
paramIdls: [TransferArgs],
returnIdl: TransferResult,
args: [transferArgs]
});
}

@query([], IDL.Vec(SupportedStandard))
@query([], IDL.Vec(SupportedStandard), { composite: true })
async icrc1_supported_standards(): Promise<SupportedStandard[]> {
return await call(getIcrcPrincipal(), 'icrc1_supported_standards');
return await call(getIcrcPrincipal(), 'icrc1_supported_standards', {
returnIdl: IDL.Vec(SupportedStandard)
});
}

@update([ApproveArgs], ApproveResult)
async icrc2_approve(approveArgs: ApproveArgs): Promise<ApproveResult> {
return await call(getIcrcPrincipal(), 'icrc2_approve', {
paramIdls: [ApproveArgs],
returnIdl: ApproveResult,
args: [approveArgs]
});
}
Expand All @@ -80,6 +102,8 @@ export default class {
transferFromArgs: TransferFromArgs
): Promise<TransferFromResult> {
return await call(getIcrcPrincipal(), 'icrc2_transfer_from', {
paramIdls: [TransferFromArgs],
returnIdl: TransferFromResult,
args: [transferFromArgs]
});
}
Expand All @@ -89,6 +113,8 @@ export default class {
allowanceArgs: AllowanceArgs
): Promise<AllowanceResult> {
return await call(getIcrcPrincipal(), 'icrc2_allowance', {
paramIdls: [AllowanceArgs],
returnIdl: AllowanceResult,
args: [allowanceArgs]
});
}
Expand Down
Loading

0 comments on commit 7384419

Please sign in to comment.