From 9515e981011eb55236528fe1164f63fdff147c11 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 27 Sep 2023 21:42:26 -0600 Subject: [PATCH] update to Canister from Service --- examples/recursion/src/index.ts | 10 +++++----- src/lib_new/method_decorators.ts | 13 ++++++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/examples/recursion/src/index.ts b/examples/recursion/src/index.ts index 6d0a3f0ae2..9237d9ab1b 100644 --- a/examples/recursion/src/index.ts +++ b/examples/recursion/src/index.ts @@ -4,7 +4,7 @@ import { None, Principal, query, - Service, + Canister, Some, text, Tuple, @@ -35,15 +35,15 @@ const myTupleVar = Variant({ num: int8, varTuple: varTuple }); // Vec can't be recursive by itself. At the end of it all it needs to have a concrete type. // Opt // Service -const myService = Recursive(() => - Service({ - serviceQuery: query([myService], myService, (param) => param) +const MyCanister = Recursive(() => + Canister({ + myQuery: query([MyCanister], MyCanister, (param) => param) }) ); // Func const myFunc = Recursive(() => Func([myFunc], myFunc, 'query')); -export default Service({ +export default Canister({ testRecRecordWithOpt: query([optRecord], optRecord, (param) => param), testRecRecordWithVec: query([vecRecord], vecRecord, (param) => param), testRecRecordWithVariant: query([varRecord], varRecord, (param) => param), diff --git a/src/lib_new/method_decorators.ts b/src/lib_new/method_decorators.ts index 78da74a66c..7040b915bb 100644 --- a/src/lib_new/method_decorators.ts +++ b/src/lib_new/method_decorators.ts @@ -8,7 +8,8 @@ import { toReturnIDLType, CandidTypesDefs, CandidDef, - extractCandid + extractCandid, + Parent } from './utils'; import { display } from './utils'; import { @@ -181,18 +182,20 @@ export function newTypesToStingArr(newTypes: CandidTypesDefs): string[] { } export function handleRecursiveParams( - idls: CandidClass[] + idls: CandidClass[], + parents: Parent[] = [] ): [IDL.Type[], CandidDef[], CandidTypesDefs] { - const paramIdls = toParamIDLTypes(idls); + const paramIdls = toParamIDLTypes(idls, parents); const paramInfo = paramIdls.map((paramIdl) => display(paramIdl, {})); return [paramIdls, ...extractCandid(paramInfo, {})]; } export function handleRecursiveReturn( returnIdl: ReturnCandidClass, - paramCandidTypeDefs: CandidTypesDefs + paramCandidTypeDefs: CandidTypesDefs, + parents: Parent[] = [] ): [IDL.Type[], CandidDef[], CandidTypesDefs] { - const returnIdls = toReturnIDLType(returnIdl); + const returnIdls = toReturnIDLType(returnIdl, parents); const returnInfo = returnIdls.map((returnIdl) => display(returnIdl, {})); return [returnIdls, ...extractCandid(returnInfo, paramCandidTypeDefs)]; }