Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions tests/assets/example.did
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import service "import/recursion.did";
import "import/a.did";
import service "import/b/b.did";

// Doc comment for prim type
type my_type = principal;
// Doc comment for List
type List = opt record {
// Doc comment for List head
head: int;
// Doc comment for List tail
tail: List
};
type f = func (List, func (int32) -> (int64)) -> (opt List, res);
// Doc comment for broker service
type broker = service {
find : (name: text) ->
(service {up:() -> (); current:() -> (nat32)});
};
// Doc comment for nested type
type nested = record {
nat;
nat;
// Doc comment for nested record
record {nat;int;};
record { nat; 0x2a:nat; nat8; };
42:nat;
40:nat;
variant{ A; 0x2a; B; C };
};
// Doc comment for res type
type res = variant {
// Doc comment for Ok variant
Ok: record{int;nat};
// Doc comment for Err variant
Err: record{
// Doc comment for error field in Err variant,
// on multiple lines
error: text
}
};
type nested_res = variant { Ok: variant { Ok; Err }; Err: variant {
// Doc comment for Ok in nested variant
Ok: record { content: text };
// Doc comment for Err in nested variant
Err: record { int }
} };
// Doc comment for nested_records
type nested_records = record {
// Doc comment for nested_records field nested
nested: opt record {
// Doc comment for nested_records field nested_field
nested_field: text
}
};
type my_variant = variant {
// Doc comment for my_variant field a
a: record {
// Doc comment for my_variant field a field b
b: text;
};
// Doc comment for my_variant field c
c: opt record {
// Doc comment for my_variant field c field d
d: text;
e: vec record {
// Doc comment for my_variant field c field e inner vec element
f: nat;
};
}
}

// Doc comment for service
service server : {
// Doc comment for f1 method of service
f1 : (list, test: blob, opt bool) -> () oneway;
g1 : (my_type, List, opt List, nested) -> (int, broker, nested_res) query;
h : (vec opt text, variant { A: nat; B: opt text }, opt List) -> (
record {
// Doc comment for id field in h method return, currently ignored
id: nat;
// Doc comment for 0x2a field in h method return, currently ignored
0x2a: record {};
}
);
// Doc comment for i method of service
i : f;
x : (a,b) -> (opt a, opt b, variant { Ok: record { result: text }; Err: variant {a;b} }) composite_query;
y : (nested_records) -> (record { nested_records; my_variant }) query;
}
5 changes: 5 additions & 0 deletions tests/assets/import/a.did
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import "b/b.did";
type a = variant {a;b:b};
service : (a,b) -> {
f : (b) -> (a);
}
5 changes: 5 additions & 0 deletions tests/assets/import/b/b.did
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type b = record { int;nat };
service : {
// Doc comment for imported bbbbb service method
bbbbb : (b) -> ();
}
14 changes: 14 additions & 0 deletions tests/assets/import/recursion.did
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type A = B;
type B = opt A;
type node = record {head:nat; tail:list};
type list = opt node;
type tree = variant {
leaf : int;
branch : record { left : tree; val : int; right : tree };
};
// Doc comment for service id
type s = service { f : t; g : (list) -> (B,tree,stream); };
type t = func (server : s) -> ();
type stream = opt record {head:nat; next:func ()-> (stream) query};

service A : s
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
/* eslint-disable */

// @ts-nocheck

// This file was automatically generated by @icp-sdk/bindgen.
// You should NOT make any changes in this file as it will be overwritten.
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.

import type { ActorMethod } from '@icp-sdk/core/agent';
import type { IDL } from '@icp-sdk/core/candid';
import type { Principal } from '@icp-sdk/core/principal';

export type A = B;
export type B = [] | [A];
/**
* Doc comment for List
*/
export type List = [] | [
{
/**
* Doc comment for List head
*/
'head' : bigint,
/**
* Doc comment for List tail
*/
'tail' : List,
}
];
export type a = { 'a' : null } |
{ 'b' : b };
export type b = [bigint, bigint];
/**
* Doc comment for broker service
*/
export interface broker { 'find' : ActorMethod<[string], Principal> }
export type f = ActorMethod<[List, [Principal, string]], [[] | [List], res]>;
export type list = [] | [node];
/**
* Doc comment for prim type
*/
export type my_type = Principal;
export type my_variant = {
/**
* Doc comment for my_variant field a
*/
'a' : {
/**
* Doc comment for my_variant field a field b
*/
'b' : string,
}
} |
{
/**
* Doc comment for my_variant field c
*/
'c' : [] | [
{
/**
* Doc comment for my_variant field c field d
*/
'd' : string,
'e' : Array<
{
/**
* Doc comment for my_variant field c field e inner vec element
*/
'f' : bigint,
}
>,
}
]
};
/**
* Doc comment for nested type
*/
export interface nested {
_0_ : bigint,
_1_ : bigint,
/**
* Doc comment for nested record
*/
_2_ : [bigint, bigint],
_3_ : { _0_ : bigint, _42_ : bigint, _43_ : number },
_40_ : bigint,
_41_ : { _42_ : null } |
{ 'A' : null } |
{ 'B' : null } |
{ 'C' : null },
_42_ : bigint,
}
/**
* Doc comment for nested_records
*/
export interface nested_records {
/**
* Doc comment for nested_records field nested
*/
'nested' : [] | [
{
/**
* Doc comment for nested_records field nested_field
*/
'nested_field' : string,
}
],
}
export type nested_res = { 'Ok' : { 'Ok' : null } | { 'Err' : null } } |
{
'Err' : {
/**
* Doc comment for Ok in nested variant
*/
'Ok' : { 'content' : string }
} |
{
/**
* Doc comment for Err in nested variant
*/
'Err' : [bigint]
}
};
export interface node { 'head' : bigint, 'tail' : list }
/**
* Doc comment for res type
*/
export type res = {
/**
* Doc comment for Ok variant
*/
'Ok' : [bigint, bigint]
} |
{
/**
* Doc comment for Err variant
*/
'Err' : {
/**
* Doc comment for error field in Err variant,
* on multiple lines
*/
'error' : string,
}
};
/**
* Doc comment for service id
*/
export interface s { 'f' : t, 'g' : ActorMethod<[list], [B, tree, stream]> }
export type stream = [] | [{ 'head' : bigint, 'next' : [Principal, string] }];
export type t = ActorMethod<[Principal], undefined>;
export type tree = {
'branch' : { 'val' : bigint, 'left' : tree, 'right' : tree }
} |
{ 'leaf' : bigint };
/**
* Doc comment for service
*/
export interface _SERVICE {
/**
* Doc comment for f1 method of service
*/
'f1' : ActorMethod<[list, Uint8Array | number[], [] | [boolean]], undefined>,
'g1' : ActorMethod<
[my_type, List, [] | [List], nested],
[bigint, Principal, nested_res]
>,
'h' : ActorMethod<
[
Array<[] | [string]>,
{ 'A' : bigint } |
{ 'B' : [] | [string] },
[] | [List],
],
{ _42_ : {}, 'id' : bigint }
>,
/**
* Doc comment for i method of service
*/
'i' : f,
'x' : ActorMethod<
[a, b],
[
[] | [a],
[] | [b],
{ 'Ok' : { 'result' : string } } |
{ 'Err' : { 'a' : null } | { 'b' : null } },
]
>,
'y' : ActorMethod<[nested_records], [nested_records, my_variant]>,
'f' : t,
'g' : ActorMethod<[list], [B, tree, stream]>,
/**
* Doc comment for imported bbbbb service method
*/
'bbbbb' : ActorMethod<[b], undefined>,
}
export declare const idlService: IDL.ServiceClass;
export declare const idlInitArgs: IDL.Type[];
export declare const idlFactory: IDL.InterfaceFactory;
export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
Loading