@arken/seer-protocol 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/.editorconfig +9 -0
  2. package/.eslintrc +123 -0
  3. package/.prettierrc +12 -0
  4. package/.rush/temp/shrinkwrap-deps.json +420 -0
  5. package/LICENSE +21 -0
  6. package/README.md +3 -0
  7. package/package.json +25 -0
  8. package/src/index.ts +22 -0
  9. package/src/modules/evolution/evolution.models.ts +3 -0
  10. package/src/modules/evolution/evolution.router.ts +3738 -0
  11. package/src/modules/evolution/evolution.schema.ts +1 -0
  12. package/src/modules/evolution/evolution.service.ts +2000 -0
  13. package/src/modules/evolution/evolution.types.ts +20 -0
  14. package/src/modules/evolution/index.ts +5 -0
  15. package/src/modules/infinite/index.ts +5 -0
  16. package/src/modules/infinite/infinite.models.ts +3 -0
  17. package/src/modules/infinite/infinite.router.ts +3648 -0
  18. package/src/modules/infinite/infinite.schema.ts +1 -0
  19. package/src/modules/infinite/infinite.service.ts +40 -0
  20. package/src/modules/infinite/infinite.types.ts +20 -0
  21. package/src/modules/isles/index.ts +5 -0
  22. package/src/modules/isles/isles.models.ts +3 -0
  23. package/src/modules/isles/isles.router.ts +3648 -0
  24. package/src/modules/isles/isles.schema.ts +1 -0
  25. package/src/modules/isles/isles.service.ts +40 -0
  26. package/src/modules/isles/isles.types.ts +20 -0
  27. package/src/modules/oasis/index.ts +5 -0
  28. package/src/modules/oasis/oasis.models.ts +3 -0
  29. package/src/modules/oasis/oasis.router.ts +68 -0
  30. package/src/modules/oasis/oasis.schema.ts +1 -0
  31. package/src/modules/oasis/oasis.service.ts +38 -0
  32. package/src/modules/oasis/oasis.types.ts +20 -0
  33. package/src/modules/trek/index.ts +5 -0
  34. package/src/modules/trek/trek.models.ts +1 -0
  35. package/src/modules/trek/trek.router.ts +78 -0
  36. package/src/modules/trek/trek.schema.ts +1 -0
  37. package/src/modules/trek/trek.service.ts +1031 -0
  38. package/src/modules/trek/trek.types.ts +1 -0
  39. package/src/router.ts +130 -0
  40. package/src/types.ts +106 -0
  41. package/tsconfig.json +25 -0
@@ -0,0 +1 @@
1
+ import { z, ObjectId, Entity } from '@arken/node/schema';
package/src/router.ts ADDED
@@ -0,0 +1,130 @@
1
+ import util from '@arken/node/util';
2
+ import { initTRPC } from '@trpc/server';
3
+ import { observable } from '@trpc/server/observable';
4
+ import { serialize, deserialize } from '@arken/node/util/rpc';
5
+ import { z } from 'zod';
6
+ import { customErrorFormatter, hasRole } from '@arken/node/util/rpc';
7
+ import { Query, getQueryInput, getQueryOutput, inferRouterOutputs } from '@arken/node/schema';
8
+ import * as Arken from '@arken/node/types';
9
+ import * as Schema from '@arken/node/schema';
10
+ import * as Area from '@arken/node/modules/area/area.router';
11
+ import * as Asset from '@arken/node/modules/asset/asset.router';
12
+ import * as Character from '@arken/node/modules/character/character.router';
13
+ import * as Chain from '@arken/node/modules/chain/chain.router';
14
+ import * as Chat from '@arken/node/modules/chat/chat.router';
15
+ import * as Collection from '@arken/node/modules/collection/collection.router';
16
+ import * as Core from '@arken/node/modules/core/core.router';
17
+ import * as Game from '@arken/node/modules/game/game.router';
18
+ import * as Interface from '@arken/node/modules/interface/interface.router';
19
+ import * as Item from '@arken/node/modules/item/item.router';
20
+ import * as Job from '@arken/node/modules/job/job.router';
21
+ import * as Market from '@arken/node/modules/market/market.router';
22
+ import * as Product from '@arken/node/modules/product/product.router';
23
+ import * as Profile from '@arken/node/modules/profile/profile.router';
24
+ import * as Raffle from '@arken/node/modules/raffle/raffle.router';
25
+ import * as Skill from '@arken/node/modules/skill/skill.router';
26
+ import * as Video from '@arken/node/modules/video/video.router';
27
+ import * as Trek from './modules/trek/trek.router';
28
+ import * as Isles from './modules/isles/isles.router';
29
+ import * as Evolution from './modules/evolution/evolution.router';
30
+ import * as Infinite from './modules/infinite/infinite.router';
31
+ import * as Oasis from './modules/oasis/oasis.router';
32
+ import type * as Types from './types';
33
+
34
+ export type RouterContext = {
35
+ app: Types.ApplicationType;
36
+ };
37
+ export const t = initTRPC.context<RouterContext>().create();
38
+ export const router = t.router;
39
+ export const procedure = t.procedure;
40
+ export const createCallerFactory = t.createCallerFactory;
41
+
42
+ export const createRouter = () => {
43
+ return router({
44
+ area: Area.createRouter(),
45
+ asset: Asset.createRouter(),
46
+ chain: Chain.createRouter(),
47
+ character: Character.createRouter(),
48
+ chat: Chat.createRouter(),
49
+ collection: Collection.createRouter(),
50
+ core: Core.createRouter(),
51
+ game: Game.createRouter(),
52
+ interface: Interface.createRouter(),
53
+ item: Item.createRouter(),
54
+ job: Job.createRouter(),
55
+ market: Market.createRouter(),
56
+ product: Product.createRouter(),
57
+ profile: Profile.createRouter(),
58
+ raffle: Raffle.createRouter(),
59
+ skill: Skill.createRouter(),
60
+ video: Video.createRouter(),
61
+
62
+ trek: Trek.createRouter(),
63
+ evolution: Evolution.createRouter(),
64
+ infinite: Infinite.createRouter(),
65
+ oasis: Oasis.createRouter(),
66
+ isles: Isles.createRouter(),
67
+
68
+ info: procedure.query(({ input, ctx }) => {
69
+ return { stuff: 1 };
70
+ }),
71
+
72
+ // TODO: use protocol types
73
+ // updateRealm: procedure
74
+ // .use(hasRole('guest', t))
75
+ // .use(customErrorFormatter(t))
76
+ // .input(
77
+ // getQueryInput(
78
+ // z.object({
79
+ // realmId: z.string(),
80
+ // status: z.string(),
81
+ // clientCount: z.number(),
82
+ // regionCode: z.string(),
83
+ // realmShards: z.array(z.object({ endpoint: z.string(), status: z.string(), clientCount: z.number() })),
84
+ // })
85
+ // )
86
+ // )
87
+ // .output(getQueryOutput(Arken.Core.Schemas.Realm))
88
+ // .mutation(({ input, ctx }) => (ctx.app.updateRealm as any)(input, ctx)),
89
+
90
+ auth: procedure
91
+ .input(
92
+ z.object({
93
+ data: z.any(),
94
+ signature: z.object({ hash: z.string(), address: z.string() }),
95
+ })
96
+ )
97
+ .mutation(({ input, ctx }) => {
98
+ let data: any = {
99
+ roundId: 1,
100
+ };
101
+
102
+ if (input.data.applicationId === '668e4e805f9a03927caf883b') {
103
+ data = {
104
+ ...data,
105
+ };
106
+ } else if (input.data.applicationId === '669095d20b1da555f6346cdb') {
107
+ data = {
108
+ ...data,
109
+ roundId: 1,
110
+ };
111
+ }
112
+
113
+ return data;
114
+ }),
115
+
116
+ banProfile: procedure
117
+ .input(
118
+ z.object({
119
+ target: z.string(),
120
+ banReason: z.string(),
121
+ banExpireDate: z.string(),
122
+ })
123
+ )
124
+ .mutation(({ input, ctx }) => {}),
125
+ });
126
+ };
127
+
128
+ export type Router = ReturnType<typeof createRouter>;
129
+ export type RouterInput = Schema.inferRouterInputs<Router>;
130
+ export type RouterOutput = Schema.inferRouterOutputs<Router>;
package/src/types.ts ADDED
@@ -0,0 +1,106 @@
1
+ import * as Arken from '@arken/node';
2
+ import { Router, RouterInput, RouterOutput } from './router';
3
+ import * as Evolution from './modules/evolution';
4
+ import * as Infinite from './modules/infinite';
5
+ import * as Oasis from './modules/oasis';
6
+ import * as Trek from './modules/trek';
7
+ import type * as Types from './types';
8
+
9
+ export type { Router, RouterInput, RouterOutput };
10
+
11
+ export type ApplicationServiceType = Partial<{
12
+ Trek: Trek.Service;
13
+ Evolution: Evolution.Service;
14
+ Infinite: Infinite.Service;
15
+ Oasis: Oasis.Service;
16
+ }> &
17
+ Arken.ApplicationServiceType;
18
+
19
+ export type ApplicationModelType = Partial<Evolution.Types.Mappings & Infinite.Types.Mappings> &
20
+ Arken.ApplicationModelType;
21
+
22
+ export class Application {
23
+ router: Router;
24
+ service: ApplicationServiceType = {};
25
+ model: ApplicationModelType = {};
26
+ realms: Arken.Core.Types.Realm[] = [];
27
+
28
+ server: any;
29
+ http: any;
30
+ https: any;
31
+ isHttps: boolean;
32
+ cache: any;
33
+ db: any;
34
+ services: any;
35
+ applications: any;
36
+ application: any;
37
+ contracts: any;
38
+ contractInfo: any;
39
+ contractMetadata: any;
40
+ ethersProvider: any;
41
+ data: any;
42
+ signers: any;
43
+ filters: Record<string, any> = { applicationId: null };
44
+
45
+ // async getRealms(
46
+ // input: Types.RouterInput['getRealms'],
47
+ // ctx: Types.ServiceContext
48
+ // ): Promise<Types.RouterOutput['getRealms']> {
49
+ // throw new Error('Not implemented');
50
+ // }
51
+
52
+ // async updateRealm(
53
+ // input: Types.RouterInput['updateRealm'],
54
+ // ctx: Types.ServiceContext
55
+ // ): Promise<Types.RouterOutput['updateRealm']> {
56
+ // throw new Error('Not implemented');
57
+ // }
58
+ }
59
+
60
+ export type ApplicationType = typeof Application;
61
+ // export type Seer =
62
+ // export type Seer = {
63
+ // service: ApplicationServiceType;
64
+ // model: ApplicationModelType;
65
+ // realms: Arken.Core.Types.Realm[];
66
+
67
+ // server: any;
68
+ // http: any;
69
+ // https: any;
70
+ // isHttps: boolean;
71
+ // cache: any;
72
+ // db: any;
73
+ // services: any;
74
+ // applications: any;
75
+ // application: any;
76
+ // filters: Record<string, any>;
77
+ // contracts: any;
78
+ // contractInfo: any;
79
+ // contractMetadata: any;
80
+ // signers: any;
81
+ // };
82
+
83
+ export type RouterContext = {
84
+ app: Application;
85
+ } & Arken.RouterContext;
86
+
87
+ export interface Client {
88
+ id: string;
89
+ name: string;
90
+ ip: string;
91
+ socket: any;
92
+ endpoint: string;
93
+ ioCallbacks: any;
94
+ info: any;
95
+ lastReportedTime: number;
96
+ isMod: boolean;
97
+ isAdmin: boolean;
98
+ isSeer: boolean;
99
+ log: {
100
+ clientDisconnected: number;
101
+ };
102
+ }
103
+
104
+ export interface ServiceContext {
105
+ client: Client;
106
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "CommonJS",
4
+ "preserveSymlinks": true,
5
+ "esModuleInterop": true,
6
+ "experimentalDecorators": true,
7
+ "emitDecoratorMetadata": true,
8
+ "resolveJsonModule": true,
9
+ "allowSyntheticDefaultImports": true,
10
+ "noImplicitAny": false,
11
+ "sourceMap": true,
12
+ "strictNullChecks": false,
13
+ "outDir": "./dist",
14
+ "baseUrl": ".",
15
+ "types": ["node", "jest"],
16
+ "paths": {
17
+ "~/*": ["./src/*"]
18
+ },
19
+ "target": "ESNext",
20
+ "lib": ["ESNext"],
21
+ "moduleResolution": "Node"
22
+ },
23
+ "include": ["./src/**/*"],
24
+ "exclude": []
25
+ }