Skip to content

Commit

Permalink
feat: icgames
Browse files Browse the repository at this point in the history
  • Loading branch information
chuhemiao committed Jun 20, 2023
1 parent 65578f2 commit 3687957
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,12 @@
"nnsdao",
"npmrc"
],
"emmet.excludeLanguages": ["markdown", "javascript", "sh"]
"emmet.excludeLanguages": [
"markdown",
"javascript",
"sh"
],
"[candid]": {
"editor.defaultFormatter": "dfinity-foundation.vscode-motoko"
}
}
27 changes: 27 additions & 0 deletions src/icgames/icgames.did
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
type GameItem = record {
tag : vec text;
is_delete : bool;
desc : text;
name : text;
banner : vec text;
follow : nat64;
avatar : text;
};
type Result = variant { Ok; Err : text };
type Result_1 = variant { Ok : UserInfo; Err : text };
type UserBaseInfo = record { name : text; avatar : text };
type UserInfo = record { name : text; follow : vec nat64; avatar : text };
service : {
add_owner : (principal) -> ();
cancel_follow : (nat64) -> (Result);
create_game : (GameItem) -> ();
delete_owner : (principal) -> ();
follow : (nat64) -> (Result);
get_game : (nat64) -> (opt GameItem) query;
get_game_list : () -> (vec record { nat64; GameItem }) query;
get_owner : () -> (vec principal) query;
get_user_info : () -> (Result_1) query;
set_heat : (nat64, nat64) -> (Result);
set_user_info : (UserBaseInfo) -> ();
update_game : (nat64, GameItem) -> (Result);
};
36 changes: 36 additions & 0 deletions src/icgames/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export const idlFactory = ({ IDL }) => {
const Result = IDL.Variant({ Ok: IDL.Null, Err: IDL.Text });
const GameItem = IDL.Record({
tag: IDL.Vec(IDL.Text),
is_delete: IDL.Bool,
desc: IDL.Text,
name: IDL.Text,
banner: IDL.Vec(IDL.Text),
follow: IDL.Nat64,
avatar: IDL.Text,
});
const UserInfo = IDL.Record({
name: IDL.Text,
follow: IDL.Vec(IDL.Nat64),
avatar: IDL.Text,
});
const Result_1 = IDL.Variant({ Ok: UserInfo, Err: IDL.Text });
const UserBaseInfo = IDL.Record({ name: IDL.Text, avatar: IDL.Text });
return IDL.Service({
add_owner: IDL.Func([IDL.Principal], [], []),
cancel_follow: IDL.Func([IDL.Nat64], [Result], []),
create_game: IDL.Func([GameItem], [], []),
delete_owner: IDL.Func([IDL.Principal], [], []),
follow: IDL.Func([IDL.Nat64], [Result], []),
get_game: IDL.Func([IDL.Nat64], [IDL.Opt(GameItem)], ['query']),
get_game_list: IDL.Func([], [IDL.Vec(IDL.Tuple(IDL.Nat64, GameItem))], ['query']),
get_owner: IDL.Func([], [IDL.Vec(IDL.Principal)], ['query']),
get_user_info: IDL.Func([], [Result_1], ['query']),
set_heat: IDL.Func([IDL.Nat64, IDL.Nat64], [Result], []),
set_user_info: IDL.Func([UserBaseInfo], [], []),
update_game: IDL.Func([IDL.Nat64, GameItem], [Result], []),
});
};
export const init = ({ IDL }) => {
return [];
};
35 changes: 35 additions & 0 deletions src/icgames/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { Principal } from '@dfinity/agent';
export interface GameItem {
tag: Array<string>;
is_delete: boolean;
desc: string;
name: string;
banner: Array<string>;
follow: bigint;
avatar: string;
}
export type Result = { Ok: null } | { Err: string };
export type Result_1 = { Ok: UserInfo } | { Err: string };
export interface UserBaseInfo {
name: string;
avatar: string;
}
export interface UserInfo {
name: string;
follow: Array<bigint>;
avatar: string;
}
export default interface _SERVICE {
add_owner: (arg_0: Principal) => Promise<undefined>;
cancel_follow: (arg_0: bigint) => Promise<Result>;
create_game: (arg_0: GameItem) => Promise<undefined>;
delete_owner: (arg_0: Principal) => Promise<undefined>;
follow: (arg_0: bigint) => Promise<Result>;
get_game: (arg_0: bigint) => Promise<[] | [GameItem]>;
get_game_list: () => Promise<Array<[bigint, GameItem]>>;
get_owner: () => Promise<Array<Principal>>;
get_user_info: () => Promise<Result_1>;
set_heat: (arg_0: bigint, arg_1: bigint) => Promise<Result>;
set_user_info: (arg_0: UserBaseInfo) => Promise<undefined>;
update_game: (arg_0: bigint, arg_1: GameItem) => Promise<Result>;
}

0 comments on commit 3687957

Please sign in to comment.