@arken/seer-protocol 0.1.1 → 0.1.3

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 (118) hide show
  1. package/.rush/temp/shrinkwrap-deps.json +778 -53
  2. package/area/area.models.ts +15 -0
  3. package/area/area.router.ts +74 -0
  4. package/area/area.schema.ts +22 -0
  5. package/area/area.types.ts +25 -0
  6. package/area/index.ts +4 -0
  7. package/asset/asset.models.ts +59 -0
  8. package/asset/asset.router.ts +55 -0
  9. package/asset/asset.schema.ts +30 -0
  10. package/asset/asset.types.ts +21 -0
  11. package/asset/index.ts +4 -0
  12. package/chain/chain.models.ts +50 -0
  13. package/chain/chain.router.ts +104 -0
  14. package/chain/chain.schema.ts +67 -0
  15. package/chain/chain.types.ts +23 -0
  16. package/chain/index.ts +4 -0
  17. package/character/character.models.ts +174 -0
  18. package/character/character.router.ts +314 -0
  19. package/character/character.schema.ts +150 -0
  20. package/character/character.types.ts +63 -0
  21. package/character/index.ts +4 -0
  22. package/chat/chat.models.ts +43 -0
  23. package/chat/chat.router.ts +67 -0
  24. package/chat/chat.schema.ts +39 -0
  25. package/chat/chat.types.ts +19 -0
  26. package/chat/index.ts +4 -0
  27. package/collection/collection.models.ts +76 -0
  28. package/collection/collection.router.ts +91 -0
  29. package/collection/collection.schema.ts +90 -0
  30. package/collection/collection.types.ts +35 -0
  31. package/collection/index.ts +4 -0
  32. package/core/core.models.ts +1380 -0
  33. package/core/core.router.ts +1781 -0
  34. package/core/core.schema.ts +940 -0
  35. package/core/core.types.ts +339 -0
  36. package/core/index.ts +4 -0
  37. package/evolution/evolution.models.ts +1 -1
  38. package/evolution/evolution.router.ts +19 -19
  39. package/evolution/evolution.schema.ts +1 -1
  40. package/evolution/evolution.types.ts +2 -3
  41. package/evolution/index.ts +0 -1
  42. package/game/game.models.ts +53 -0
  43. package/game/game.router.ts +110 -0
  44. package/game/game.schema.ts +23 -0
  45. package/game/game.types.ts +27 -0
  46. package/game/index.ts +4 -0
  47. package/index.ts +43 -6
  48. package/infinite/index.ts +0 -1
  49. package/infinite/infinite.models.ts +1 -1
  50. package/infinite/infinite.router.ts +9 -9
  51. package/infinite/infinite.schema.ts +1 -1
  52. package/infinite/infinite.types.ts +2 -3
  53. package/interface/index.ts +4 -0
  54. package/interface/interface.canonicalize.ts +279 -0
  55. package/interface/interface.models.ts +40 -0
  56. package/interface/interface.router.ts +175 -0
  57. package/interface/interface.schema.ts +59 -0
  58. package/interface/interface.types.ts +24 -0
  59. package/isles/index.ts +0 -1
  60. package/isles/isles.models.ts +1 -1
  61. package/isles/isles.router.ts +9 -9
  62. package/isles/isles.schema.ts +1 -1
  63. package/isles/isles.types.ts +2 -3
  64. package/item/index.ts +4 -0
  65. package/item/item.models.ts +124 -0
  66. package/item/item.router.ts +103 -0
  67. package/item/item.schema.ts +150 -0
  68. package/item/item.types.ts +73 -0
  69. package/job/index.ts +4 -0
  70. package/job/job.models.ts +14 -0
  71. package/job/job.router.ts +44 -0
  72. package/job/job.schema.ts +9 -0
  73. package/job/job.types.ts +22 -0
  74. package/market/index.ts +4 -0
  75. package/market/market.models.ts +113 -0
  76. package/market/market.router.ts +73 -0
  77. package/market/market.schema.ts +149 -0
  78. package/market/market.types.ts +55 -0
  79. package/oasis/index.ts +0 -1
  80. package/oasis/oasis.models.ts +1 -1
  81. package/oasis/oasis.router.ts +5 -6
  82. package/oasis/oasis.schema.ts +1 -1
  83. package/oasis/oasis.types.ts +2 -3
  84. package/package.json +17 -4
  85. package/product/index.ts +4 -0
  86. package/product/product.models.ts +166 -0
  87. package/product/product.router.ts +93 -0
  88. package/product/product.schema.ts +186 -0
  89. package/product/product.types.ts +32 -0
  90. package/profile/index.ts +4 -0
  91. package/profile/profile.models.ts +214 -0
  92. package/profile/profile.router.ts +72 -0
  93. package/profile/profile.schema.ts +219 -0
  94. package/profile/profile.types.ts +21 -0
  95. package/raffle/index.ts +4 -0
  96. package/raffle/raffle.models.ts +44 -0
  97. package/raffle/raffle.router.ts +90 -0
  98. package/raffle/raffle.schema.ts +32 -0
  99. package/raffle/raffle.types.ts +29 -0
  100. package/router.ts +23 -29
  101. package/schema.ts +321 -0
  102. package/skill/index.ts +4 -0
  103. package/skill/skill.models.ts +16 -0
  104. package/skill/skill.router.ts +201 -0
  105. package/skill/skill.schema.ts +52 -0
  106. package/skill/skill.types.ts +32 -0
  107. package/trek/index.ts +0 -1
  108. package/trek/trek.models.ts +1 -1
  109. package/trek/trek.router.ts +2 -2
  110. package/trek/trek.schema.ts +1 -1
  111. package/trek/trek.types.ts +1 -1
  112. package/tsconfig.json +25 -17
  113. package/types.ts +174 -26
  114. package/video/index.ts +4 -0
  115. package/video/video.models.ts +25 -0
  116. package/video/video.router.ts +143 -0
  117. package/video/video.schema.ts +46 -0
  118. package/video/video.types.ts +32 -0
@@ -0,0 +1,15 @@
1
+ import * as mongo from '@arken/node/mongo';
2
+ import type * as Types from './area.types';
3
+
4
+ export const Area = mongo.createModel<Types.AreaDocument>('Area', {
5
+ type: { type: String, default: 'Zone' },
6
+ shortDescription: { type: String },
7
+ // landmarks: [{ type: mongo.Schema.Types.ObjectId, ref: 'AreaLandmark' }],
8
+ });
9
+
10
+ export const AreaLandmark = mongo.createModel<Types.AreaLandmarkDocument>('AreaLandmark', {
11
+ areaId: { type: mongo.Schema.Types.ObjectId, ref: 'Area' },
12
+ });
13
+
14
+ export const AreaType = mongo.createModel<Types.AreaTypeDocument>('AreaType', {});
15
+ export const AreaNameChoice = mongo.createModel<Types.AreaNameChoiceDocument>('AreaNameChoice', {});
@@ -0,0 +1,74 @@
1
+ import { z as zod } from 'zod';
2
+ import { initTRPC } from '@trpc/server';
3
+ import { customErrorFormatter, hasRole } from '@arken/node/rpc';
4
+ import type { RouterContext } from '../types';
5
+ import { Area, AreaLandmark, AreaType } from './area.schema';
6
+ import { Query, getQueryInput, inferRouterOutputs, inferRouterInputs } from '../schema';
7
+
8
+ export const z = zod;
9
+ export const t = initTRPC.context<RouterContext>().create();
10
+ export const router = t.router;
11
+ export const procedure = t.procedure;
12
+
13
+ export const createRouter = () =>
14
+ router({
15
+ getArea: procedure
16
+ .use(hasRole('guest', t))
17
+ .use(customErrorFormatter(t))
18
+ .input(getQueryInput(Area))
19
+ .query(({ input, ctx }) => (ctx.app.service.Area.getArea as any)(input, ctx)),
20
+
21
+ getAreas: procedure
22
+ .use(hasRole('guest', t))
23
+ .use(customErrorFormatter(t))
24
+ .input(getQueryInput(Area))
25
+ .query(({ input, ctx }) => (ctx.app.service.Area.getAreas as any)(input, ctx)),
26
+
27
+ saveArea: procedure
28
+ .use(hasRole('admin', t))
29
+ .use(customErrorFormatter(t))
30
+ .input(getQueryInput(Area))
31
+ .output(Area.pick({ id: true }))
32
+ .mutation(({ input, ctx }) => (ctx.app.service.Area.saveArea as any)(input, ctx)),
33
+
34
+ getAreaLandmark: procedure
35
+ .use(hasRole('guest', t))
36
+ .use(customErrorFormatter(t))
37
+ .input(z.object({ query: Query }))
38
+ .query(({ input, ctx }) => (ctx.app.service.Area.getAreaLandmark as any)(input, ctx)),
39
+
40
+ createAreaLandmark: procedure
41
+ .use(hasRole('admin', t))
42
+ .use(customErrorFormatter(t))
43
+ .input(z.object({ data: AreaLandmark.omit({ id: true }) }))
44
+ .mutation(({ input, ctx }) => (ctx.app.service.Area.createAreaLandmark as any)(input, ctx)),
45
+
46
+ updateAreaLandmark: procedure
47
+ .use(hasRole('admin', t))
48
+ .use(customErrorFormatter(t))
49
+ .input(z.object({ query: Query, data: AreaLandmark.partial() }))
50
+ .mutation(({ input, ctx }) => (ctx.app.service.Area.updateAreaLandmark as any)(input, ctx)),
51
+
52
+ getAreaType: procedure
53
+ .use(hasRole('guest', t))
54
+ .use(customErrorFormatter(t))
55
+ .input(z.object({ query: Query }))
56
+ .query(({ input, ctx }) => (ctx.app.service.Area.getAreaType as any)(input, ctx)),
57
+
58
+ createAreaType: procedure
59
+ .use(hasRole('admin', t))
60
+ .use(customErrorFormatter(t))
61
+ .input(z.object({ data: AreaType.omit({ id: true }) }))
62
+ .mutation(({ input, ctx }) => (ctx.app.service.Area.createAreaType as any)(input, ctx)),
63
+
64
+ updateAreaType: procedure
65
+ .use(hasRole('admin', t))
66
+ .use(customErrorFormatter(t))
67
+ .input(z.object({ query: Query, data: AreaType.partial() }))
68
+ .output(AreaType.partial())
69
+ .mutation(({ input, ctx }) => (ctx.app.service.Area.updateAreaType as any)(input, ctx)),
70
+ });
71
+
72
+ export type Router = ReturnType<typeof createRouter>;
73
+ export type RouterInput = inferRouterInputs<Router>;
74
+ export type RouterOutput = inferRouterOutputs<Router>;
@@ -0,0 +1,22 @@
1
+ // arken/packages/node/modules/area/area.schema.ts
2
+ //
3
+ import { z, ObjectId, Entity } from '../schema';
4
+
5
+ export const Area = Entity.merge(
6
+ z.object({
7
+ type: z.string().default('Zone'),
8
+ landmarks: z.array(ObjectId).optional(),
9
+ shortDescription: z.string(),
10
+ })
11
+ );
12
+
13
+ export const AreaLandmark = Entity.merge(
14
+ z.object({
15
+ areaId: ObjectId.optional(),
16
+ area: ObjectId.optional(),
17
+ })
18
+ );
19
+
20
+ export const AreaType = Entity.merge(z.object({}));
21
+
22
+ export const AreaNameChoice = Entity.merge(z.object({}));
@@ -0,0 +1,25 @@
1
+ import { z } from 'zod';
2
+ import * as schema from './area.schema';
3
+ import { Document, Model } from '@arken/node/mongo';
4
+
5
+ export type * from './area.router';
6
+ export type { RouterContext } from '../types';
7
+
8
+ export type Area = z.infer<typeof schema.Area>;
9
+ export type AreaDocument = Area & Document;
10
+
11
+ export type AreaLandmark = z.infer<typeof schema.AreaLandmark>;
12
+ export type AreaLandmarkDocument = AreaLandmark & Document;
13
+
14
+ export type AreaType = z.infer<typeof schema.AreaType>;
15
+ export type AreaTypeDocument = AreaType & Document;
16
+
17
+ export type AreaNameChoice = z.infer<typeof schema.AreaNameChoice>;
18
+ export type AreaNameChoiceDocument = AreaNameChoice & Document;
19
+
20
+ export type Mappings = {
21
+ Area: Model<AreaDocument>;
22
+ AreaLandmark: Model<AreaLandmarkDocument>;
23
+ AreaType: Model<AreaTypeDocument>;
24
+ AreaNameChoice: Model<AreaNameChoiceDocument>;
25
+ };
package/area/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * as Types from './area.types';
2
+ export * as Models from './area.models';
3
+ export * as Schemas from './area.schema';
4
+ export * from './area.router';
@@ -0,0 +1,59 @@
1
+ import * as mongo from '@arken/node/mongo';
2
+ import type * as Types from './asset.types';
3
+
4
+ export const AssetStandard = mongo.createModel<Types.AssetStandardDocument>(
5
+ 'AssetStandard',
6
+ {
7
+ version: { type: String, required: false },
8
+ parentId: { type: mongo.Schema.Types.ObjectId, ref: 'AssetStandard', required: false },
9
+ },
10
+ {
11
+ virtuals: [
12
+ {
13
+ name: 'children',
14
+ ref: 'AssetStandard',
15
+ localField: '_id',
16
+ foreignField: 'parent',
17
+ justOne: false,
18
+ },
19
+ ],
20
+ }
21
+ );
22
+
23
+ export const Asset = mongo.createModel<Types.AssetDocument>(
24
+ 'Asset',
25
+ {
26
+ uri: { type: String, required: true },
27
+ type: { type: String, maxlength: 100, required: true },
28
+ standards: [{ type: mongo.Schema.Types.ObjectId, ref: 'AssetStandard', required: true }],
29
+ licenseId: { type: mongo.Schema.Types.ObjectId, ref: 'AssetLicense' },
30
+ chainId: { type: mongo.Schema.Types.ObjectId, ref: 'Chain' },
31
+ ownerId: { type: mongo.Schema.Types.ObjectId, ref: 'Profile' }, // Added ownerId
32
+ // skin: { type: String },
33
+ // transmuteCount: { type: Number },
34
+ // score: { type: Number },
35
+ },
36
+ {
37
+ virtuals: [
38
+ {
39
+ name: 'items',
40
+ ref: 'Item',
41
+ localField: '_id',
42
+ foreignField: 'assetId',
43
+ },
44
+ {
45
+ name: 'offers',
46
+ ref: 'Node',
47
+ localField: '_id',
48
+ foreignField: 'fromOfferId',
49
+ justOne: false,
50
+ match: { relationKey: 'offers' },
51
+ },
52
+ ],
53
+ }
54
+ );
55
+
56
+ export const AssetLicense = mongo.createModel<Types.AssetLicenseDocument>('AssetLicense', {
57
+ value: { type: String, required: true },
58
+ // assets: [{ type: mongo.Schema.Types.ObjectId, ref: 'Asset' }],
59
+ });
@@ -0,0 +1,55 @@
1
+ // module/asset.router.ts
2
+
3
+ import { z as zod } from 'zod';
4
+ import { initTRPC, inferRouterInputs, inferRouterOutputs } from '@trpc/server';
5
+ import { customErrorFormatter, hasRole } from '@arken/node/rpc';
6
+ import type { RouterContext } from '../types';
7
+ import { Asset, AssetLicense } from './asset.schema';
8
+
9
+ export const z = zod;
10
+ export const t = initTRPC.context<RouterContext>().create();
11
+ export const router = t.router;
12
+ export const procedure = t.procedure;
13
+
14
+ export const createRouter = () =>
15
+ router({
16
+ getAsset: procedure
17
+ .use(hasRole('guest', t))
18
+ .use(customErrorFormatter(t))
19
+ .input(z.object({ assetId: z.string() }))
20
+ .query(({ input, ctx }) => (ctx.app.service.Asset.getAsset as any)(input, ctx)),
21
+
22
+ createAsset: procedure
23
+ .use(hasRole('admin', t))
24
+ .use(customErrorFormatter(t))
25
+ .input(Asset)
26
+ .mutation(({ input, ctx }) => (ctx.app.service.Asset.createAsset as any)(input, ctx)),
27
+
28
+ updateAsset: procedure
29
+ .use(hasRole('admin', t))
30
+ .use(customErrorFormatter(t))
31
+ .input(z.object({ assetId: z.string(), data: Asset.partial() }))
32
+ .mutation(({ input, ctx }) => (ctx.app.service.Asset.updateAsset as any)(input, ctx)),
33
+
34
+ getAssetLicense: procedure
35
+ .use(hasRole('guest', t))
36
+ .use(customErrorFormatter(t))
37
+ .input(z.object({ assetLicenseId: z.string() }))
38
+ .query(({ input, ctx }) => (ctx.app.service.Asset.getAssetLicense as any)(input, ctx)),
39
+
40
+ createAssetLicense: procedure
41
+ .use(hasRole('admin', t))
42
+ .use(customErrorFormatter(t))
43
+ .input(AssetLicense)
44
+ .mutation(({ input, ctx }) => (ctx.app.service.Asset.createAssetLicense as any)(input, ctx)),
45
+
46
+ updateAssetLicense: procedure
47
+ .use(hasRole('admin', t))
48
+ .use(customErrorFormatter(t))
49
+ .input(z.object({ assetLicenseId: z.string(), data: AssetLicense.partial() }))
50
+ .mutation(({ input, ctx }) => (ctx.app.service.Asset.updateAssetLicense as any)(input, ctx)),
51
+ });
52
+
53
+ export type Router = ReturnType<typeof createRouter>;
54
+ export type RouterInput = inferRouterInputs<Router>;
55
+ export type RouterOutput = inferRouterOutputs<Router>;
@@ -0,0 +1,30 @@
1
+ import { z, ObjectId, Entity } from '../schema';
2
+
3
+ export const AssetStandard = Entity.merge(
4
+ z.object({
5
+ version: z.string().optional(),
6
+ parentId: ObjectId.optional(),
7
+ })
8
+ );
9
+
10
+ export const Asset = Entity.merge(
11
+ z.object({
12
+ uri: z.string().min(1),
13
+ type: z
14
+ .string()
15
+ .max(100)
16
+ .min(1),
17
+ standards: z.array(ObjectId),
18
+ licenseId: ObjectId.optional(),
19
+ license: ObjectId.optional(),
20
+ chainId: ObjectId.optional(),
21
+ items: z.array(ObjectId).optional(),
22
+ })
23
+ );
24
+
25
+ export const AssetLicense = Entity.merge(
26
+ z.object({
27
+ value: z.string().min(1),
28
+ assets: z.array(ObjectId).optional(),
29
+ })
30
+ );
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ import * as schema from './asset.schema';
3
+ import { Document, Model } from '@arken/node/mongo';
4
+
5
+ export type * from './asset.router';
6
+ export type { RouterContext } from '../types';
7
+
8
+ export type Asset = z.infer<typeof schema.Asset>;
9
+ export type AssetDocument = Asset & Document;
10
+
11
+ export type AssetStandard = z.infer<typeof schema.AssetStandard>;
12
+ export type AssetStandardDocument = AssetStandard & Document;
13
+
14
+ export type AssetLicense = z.infer<typeof schema.AssetLicense>;
15
+ export type AssetLicenseDocument = AssetLicense & Document;
16
+
17
+ export type Mappings = {
18
+ Asset: Model<AssetDocument>;
19
+ AssetStandard: Model<AssetStandardDocument>;
20
+ AssetLicense: Model<AssetLicenseDocument>;
21
+ };
package/asset/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * as Types from './asset.types';
2
+ export * as Models from './asset.models';
3
+ export * as Schemas from './asset.schema';
4
+ export * from './asset.router';
@@ -0,0 +1,50 @@
1
+ import * as mongo from '@arken/node/mongo';
2
+ import type * as Types from './chain.types';
3
+
4
+ export const Chain = mongo.createModel<Types.ChainDocument>('Chain', {
5
+ content: { type: String, required: true },
6
+ type: { type: String, maxlength: 100, required: true },
7
+ });
8
+
9
+ export const ChainContract = mongo.createModel<Types.ChainContractDocument>('ChainContract', {
10
+ chainId: { type: mongo.Schema.Types.ObjectId, ref: 'Chain', required: true },
11
+ content: { type: String },
12
+ address: { type: String },
13
+ type: { type: String, maxlength: 100, required: true },
14
+ standards: [{ type: mongo.Schema.Types.ObjectId, ref: 'AssetStandard', required: true }],
15
+ });
16
+
17
+ export const ChainToken = mongo.createModel<Types.ChainTokenDocument>(
18
+ 'ChainToken',
19
+ {
20
+ chainId: { type: mongo.Schema.Types.ObjectId, ref: 'Chain', required: true },
21
+ chainContractId: { type: mongo.Schema.Types.ObjectId, ref: 'ChainContract', required: true },
22
+ rank: { type: Number, min: 0, default: 0 },
23
+ description: { type: String, trim: true },
24
+ address: { type: String },
25
+ content: { type: String },
26
+ decimals: { type: Number, default: 0 },
27
+ price: { type: Number, min: 0, default: 0 },
28
+ hourChange: { type: Number, default: 0 },
29
+ dayChange: { type: Number, default: 0 },
30
+ weekChange: { type: Number, default: 0 },
31
+ marketCap: { type: Number, min: 0, default: 0 },
32
+ volume: { type: Number, min: 0, default: 0 },
33
+ symbol: { type: String, required: true, trim: true },
34
+ circulatingSupply: { type: Number, min: 0, default: 0 },
35
+ cmcLink: { type: String, trim: true },
36
+ movementDown: { type: Number, min: 0, default: 0 },
37
+ movementUp: { type: Number, min: 0, default: 0 },
38
+ enteredTop100: { type: Number, min: 0, default: 0 },
39
+ exitedTop100: { type: Number, min: 0, default: 0 },
40
+ largeMoveDown: { type: Number, min: 0, default: 0 },
41
+ },
42
+ {
43
+ indexes: [{ applicationId: 1, symbol: 1, unique: true }],
44
+ }
45
+ );
46
+
47
+ export const ChainTransaction = mongo.createModel<Types.ChainTransactionDocument>('ChainTransaction', {
48
+ value: { type: String, required: true },
49
+ chainId: { type: mongo.Schema.Types.ObjectId, ref: 'Chain', required: true },
50
+ });
@@ -0,0 +1,104 @@
1
+ // module/chain.router.ts
2
+
3
+ import { z as zod } from 'zod';
4
+ import { initTRPC, inferRouterInputs } from '@trpc/server';
5
+ import { customErrorFormatter, hasRole } from '@arken/node/rpc';
6
+ import type { RouterContext } from '../types';
7
+ import { Chain, ChainContract, ChainToken, ChainTransaction } from './chain.schema';
8
+ import { Query, getQueryInput, getQueryOutput, inferRouterOutputs } from '../schema';
9
+
10
+ export const z = zod;
11
+ export const t = initTRPC.context<RouterContext>().create();
12
+ export const router = t.router;
13
+ export const procedure = t.procedure;
14
+
15
+ export const createRouter = () =>
16
+ router({
17
+ getChain: procedure
18
+ .use(hasRole('guest', t))
19
+ .use(customErrorFormatter(t))
20
+ .input(getQueryInput(Chain))
21
+ .output(Chain)
22
+ .query(({ input, ctx }) => (ctx.app.service.Chain.getChain as any)(input, ctx)),
23
+
24
+ createChain: procedure
25
+ .use(hasRole('admin', t))
26
+ .use(customErrorFormatter(t))
27
+ .input(getQueryInput(Chain))
28
+ .output(Chain.pick({ id: true }))
29
+ .mutation(({ input, ctx }) => (ctx.app.service.Chain.createChain as any)(input, ctx)),
30
+
31
+ updateChain: procedure
32
+ .use(hasRole('admin', t))
33
+ .use(customErrorFormatter(t))
34
+ .input(getQueryInput(Chain))
35
+ .output(Chain.pick({ id: true }))
36
+ .mutation(({ input, ctx }) => (ctx.app.service.Chain.updateChain as any)(input, ctx)),
37
+
38
+ getChainContract: procedure
39
+ .use(hasRole('guest', t))
40
+ .use(customErrorFormatter(t))
41
+ .input(getQueryInput(ChainContract))
42
+ .output(ChainContract)
43
+ .query(({ input, ctx }) => (ctx.app.service.Chain.getChainContract as any)(input, ctx)),
44
+
45
+ createChainContract: procedure
46
+ .use(hasRole('admin', t))
47
+ .use(customErrorFormatter(t))
48
+ .input(getQueryInput(ChainContract))
49
+ .output(ChainContract.pick({ id: true }))
50
+ .mutation(({ input, ctx }) => (ctx.app.service.Chain.createChainContract as any)(input, ctx)),
51
+
52
+ updateChainContract: procedure
53
+ .use(hasRole('admin', t))
54
+ .use(customErrorFormatter(t))
55
+ .input(getQueryInput(ChainContract))
56
+ .output(ChainContract.pick({ id: true }))
57
+ .mutation(({ input, ctx }) => (ctx.app.service.Chain.updateChainContract as any)(input, ctx)),
58
+
59
+ getChainToken: procedure
60
+ .use(hasRole('guest', t))
61
+ .use(customErrorFormatter(t))
62
+ .input(getQueryInput(ChainToken))
63
+ .output(ChainToken)
64
+ .query(({ input, ctx }) => (ctx.app.service.Chain.getChainToken as any)(input, ctx)),
65
+
66
+ createChainToken: procedure
67
+ .use(hasRole('admin', t))
68
+ .use(customErrorFormatter(t))
69
+ .input(getQueryInput(ChainToken))
70
+ .output(ChainToken.pick({ id: true }))
71
+ .mutation(({ input, ctx }) => (ctx.app.service.Chain.createChainToken as any)(input, ctx)),
72
+
73
+ updateChainToken: procedure
74
+ .use(hasRole('admin', t))
75
+ .use(customErrorFormatter(t))
76
+ .input(getQueryInput(ChainToken))
77
+ .output(ChainToken.pick({ id: true }))
78
+ .mutation(({ input, ctx }) => (ctx.app.service.Chain.updateChainToken as any)(input, ctx)),
79
+
80
+ getChainTransaction: procedure
81
+ .use(hasRole('guest', t))
82
+ .use(customErrorFormatter(t))
83
+ .input(getQueryInput(ChainTransaction))
84
+ .output(ChainTransaction)
85
+ .query(({ input, ctx }) => (ctx.app.service.Chain.getChainTransaction as any)(input, ctx)),
86
+
87
+ createChainTransaction: procedure
88
+ .use(hasRole('admin', t))
89
+ .use(customErrorFormatter(t))
90
+ .input(getQueryInput(ChainTransaction))
91
+ .output(ChainTransaction.pick({ id: true }))
92
+ .mutation(({ input, ctx }) => (ctx.app.service.Chain.createChainTransaction as any)(input, ctx)),
93
+
94
+ updateChainTransaction: procedure
95
+ .use(hasRole('admin', t))
96
+ .use(customErrorFormatter(t))
97
+ .input(getQueryInput(ChainTransaction))
98
+ .output(ChainTransaction.pick({ id: true }))
99
+ .mutation(({ input, ctx }) => (ctx.app.service.Chain.updateChainTransaction as any)(input, ctx)),
100
+ });
101
+
102
+ export type Router = ReturnType<typeof createRouter>;
103
+ export type RouterInput = inferRouterInputs<Router>;
104
+ export type RouterOutput = inferRouterOutputs<Router>;
@@ -0,0 +1,67 @@
1
+ import { z, ObjectId, Entity } from '../schema';
2
+
3
+ export const Chain = Entity.merge(
4
+ z.object({
5
+ content: z.string().min(1),
6
+ type: z
7
+ .string()
8
+ .max(100)
9
+ .min(1),
10
+ standard: z
11
+ .string()
12
+ .max(100)
13
+ .min(1),
14
+ })
15
+ );
16
+
17
+ export const ChainContract = Entity.merge(
18
+ z.object({
19
+ chainId: ObjectId,
20
+ content: z
21
+ .string()
22
+ .min(1)
23
+ .optional(),
24
+ address: z.string().max(100),
25
+ type: z
26
+ .string()
27
+ .max(100)
28
+ .min(1),
29
+ standards: z.array(ObjectId),
30
+ })
31
+ );
32
+
33
+ export const ChainToken = Entity.merge(
34
+ z.object({
35
+ chainId: ObjectId,
36
+ chainContractId: ObjectId,
37
+ address: z.string().max(100), // TODO: validate address?
38
+ decimals: z.number().optional(),
39
+ rank: z.number().optional(),
40
+ description: z.string().optional(),
41
+ content: z
42
+ .string()
43
+ .min(1)
44
+ .optional(),
45
+ price: z.number().optional(),
46
+ hourChange: z.number().optional(),
47
+ dayChange: z.number().optional(),
48
+ weekChange: z.number().optional(),
49
+ marketCap: z.number().optional(),
50
+ volume: z.number().optional(),
51
+ symbol: z.string().min(1),
52
+ circulatingSupply: z.number().optional(),
53
+ cmcLink: z.string().optional(),
54
+ movementDown: z.number().optional(),
55
+ movementUp: z.number().optional(),
56
+ enteredTop100: z.number().optional(),
57
+ exitedTop100: z.number().optional(),
58
+ largeMoveDown: z.number().optional(),
59
+ })
60
+ );
61
+
62
+ export const ChainTransaction = Entity.merge(
63
+ z.object({
64
+ value: z.string().min(1),
65
+ chainId: ObjectId,
66
+ })
67
+ );
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+ import * as schema from './chain.schema';
3
+ import { Document, Model } from '@arken/node/mongo';
4
+
5
+ export type * from './chain.router';
6
+ export type { RouterContext } from '../types';
7
+
8
+ export type Chain = z.infer<typeof schema.Chain>;
9
+ export type ChainContract = z.infer<typeof schema.ChainContract>;
10
+ export type ChainToken = z.infer<typeof schema.ChainToken>;
11
+ export type ChainTransaction = z.infer<typeof schema.ChainTransaction>;
12
+
13
+ export type ChainDocument = Chain & Document;
14
+ export type ChainContractDocument = ChainContract & Document;
15
+ export type ChainTokenDocument = ChainToken & Document;
16
+ export type ChainTransactionDocument = ChainTransaction & Document;
17
+
18
+ export type Mappings = {
19
+ Chain: Model<ChainDocument>;
20
+ ChainContract: Model<ChainContractDocument>;
21
+ ChainToken: Model<ChainTokenDocument>;
22
+ ChainTransaction: Model<ChainTransactionDocument>;
23
+ };
package/chain/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * as Types from './chain.types';
2
+ export * as Models from './chain.models';
3
+ export * as Schemas from './chain.schema';
4
+ export * from './chain.router';