diff --git a/examples/composite_queries/src/canister1/index.ts b/examples/composite_queries/src/canister1/index.ts index a186c4994f..69a13742a6 100644 --- a/examples/composite_queries/src/canister1/index.ts +++ b/examples/composite_queries/src/canister1/index.ts @@ -64,12 +64,11 @@ const CompQueryCanister = Canister({ }), // Composite query calling queries on the same canister incCanister1: query([], nat, async () => { - // TODO This is not an ideal solution but will work for now const self: any = CompQueryCanister(ic.id()); counter += 1n; - const canister1AResult: any = await ic.call(self.incCounter); + const canister1AResult = await ic.call(self.incCounter); const canister1BResult = await ic.call(self.incCounter); return counter + canister1AResult + canister1BResult; diff --git a/examples/motoko_examples/whoami/src/index.did b/examples/motoko_examples/whoami/src/index.did index 938102e04d..29556c8d4c 100644 --- a/examples/motoko_examples/whoami/src/index.did +++ b/examples/motoko_examples/whoami/src/index.did @@ -4,4 +4,4 @@ service: (principal) -> { idQuick: () -> (principal) query; installer: () -> (principal) query; whoami: () -> (principal); -} \ No newline at end of file +} diff --git a/examples/motoko_examples/whoami/src/index.ts b/examples/motoko_examples/whoami/src/index.ts index 16387afade..da1e1b0e2b 100644 --- a/examples/motoko_examples/whoami/src/index.ts +++ b/examples/motoko_examples/whoami/src/index.ts @@ -5,55 +5,51 @@ import { postUpgrade, Principal, query, - Recursive, - update, - Void + update } from 'azle'; // We use the zero principal but any principal could be used. let install: Principal = Principal.fromText('aaaaa-aa'); let someone: Principal = Principal.fromText('aaaaa-aa'); -const WhoAmI = Recursive(() => - Canister({ - // Manually save the calling principal and argument for later access. - init: init([Principal], (somebody) => { - install = ic.caller(); - someone = somebody; - }), - // Manually re-save these variables after new deploys. - postUpgrade: postUpgrade([Principal], (somebody) => { - install = ic.caller(); - someone = somebody; - }), - // Return the principal identifier of the wallet canister that installed this - // canister. - installer: query([], Principal, () => { - return install; - }), - // Return the principal identifier that was provided as an installation - // argument to this canister. - argument: query([], Principal, () => { - return someone; - }), - // Return the principal identifier of the caller of this method. - whoami: update([], Principal, () => { - return ic.caller(); - }), - // Return the principal identifier of this canister. - id: update([], Principal, async () => { - const self = WhoAmI(ic.id()); +const WhoAmI = Canister({ + // Manually save the calling principal and argument for later access. + init: init([Principal], (somebody) => { + install = ic.caller(); + someone = somebody; + }), + // Manually re-save these variables after new deploys. + postUpgrade: postUpgrade([Principal], (somebody) => { + install = ic.caller(); + someone = somebody; + }), + // Return the principal identifier of the wallet canister that installed this + // canister. + installer: query([], Principal, () => { + return install; + }), + // Return the principal identifier that was provided as an installation + // argument to this canister. + argument: query([], Principal, () => { + return someone; + }), + // Return the principal identifier of the caller of this method. + whoami: update([], Principal, () => { + return ic.caller(); + }), + // Return the principal identifier of this canister. + id: update([], Principal, async () => { + const self: any = WhoAmI(ic.id()); - return await ic.call(self.whoami); - }), - // Return the principal identifier of this canister via the global `ic` object. - // This is much quicker than `id()` above because it isn't making a cross- - // canister call to itself. Additionally, it can now be a `Query` which means it - // doesn't have to go through consensus. - idQuick: query([], Principal, () => { - return ic.id(); - }) + return await ic.call(self.whoami); + }), + // Return the principal identifier of this canister via the global `ic` object. + // This is much quicker than `id()` above because it isn't making a cross- + // canister call to itself. Additionally, it can now be a `Query` which means it + // doesn't have to go through consensus. + idQuick: query([], Principal, () => { + return ic.id(); }) -); +}); export default WhoAmI; diff --git a/src/lib_new/ic.ts b/src/lib_new/ic.ts index ac17a075fb..2fd19746c3 100644 --- a/src/lib_new/ic.ts +++ b/src/lib_new/ic.ts @@ -442,8 +442,8 @@ type Ic = { trap: (message: string) => never; }; -type ArgsType = T extends (...args: infer U) => any ? U : never; -type ReturnTypeOf = T extends (...args: any[]) => infer R ? R : never; +type ArgsType = T extends (...args: infer U) => any ? U : any; +type ReturnTypeOf = T extends (...args: any[]) => infer R ? R : any; type ReturnTypeOfPromise = T extends (...args: any[]) => infer R ? Promise : never;