@reyaxyz/community-sdk 0.1.5 → 0.1.7

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 (43) hide show
  1. package/dist/client/index.js +6 -6
  2. package/dist/client/index.js.map +1 -1
  3. package/dist/index.js +3 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/modules/vote/services/get-vote-details/index.js.map +1 -1
  6. package/dist/modules/vote/services/get-vote-details/types.js +3 -0
  7. package/dist/modules/vote/services/get-vote-details/types.js.map +1 -0
  8. package/dist/modules/vote/services/get-vote-status/index.js.map +1 -1
  9. package/dist/modules/vote/services/get-vote-status/types.js +3 -0
  10. package/dist/modules/vote/services/get-vote-status/types.js.map +1 -0
  11. package/dist/modules/vote/services/index.js +3 -0
  12. package/dist/modules/vote/services/index.js.map +1 -1
  13. package/dist/modules/vote/services/vote/index.js.map +1 -1
  14. package/dist/modules/vote/services/vote/types.js +3 -0
  15. package/dist/modules/vote/services/vote/types.js.map +1 -0
  16. package/dist/types/client/index.d.ts +4 -1
  17. package/dist/types/client/index.d.ts.map +1 -1
  18. package/dist/types/index.d.ts +3 -0
  19. package/dist/types/index.d.ts.map +1 -1
  20. package/dist/types/modules/vote/services/get-vote-details/index.d.ts +1 -5
  21. package/dist/types/modules/vote/services/get-vote-details/index.d.ts.map +1 -1
  22. package/dist/types/modules/vote/services/get-vote-details/types.d.ts +6 -0
  23. package/dist/types/modules/vote/services/get-vote-details/types.d.ts.map +1 -0
  24. package/dist/types/modules/vote/services/get-vote-status/index.d.ts +1 -6
  25. package/dist/types/modules/vote/services/get-vote-status/index.d.ts.map +1 -1
  26. package/dist/types/modules/vote/services/get-vote-status/types.d.ts +7 -0
  27. package/dist/types/modules/vote/services/get-vote-status/types.d.ts.map +1 -0
  28. package/dist/types/modules/vote/services/index.d.ts +3 -0
  29. package/dist/types/modules/vote/services/index.d.ts.map +1 -1
  30. package/dist/types/modules/vote/services/vote/index.d.ts +1 -10
  31. package/dist/types/modules/vote/services/vote/index.d.ts.map +1 -1
  32. package/dist/types/modules/vote/services/vote/types.d.ts +11 -0
  33. package/dist/types/modules/vote/services/vote/types.d.ts.map +1 -0
  34. package/package.json +2 -2
  35. package/src/client/index.ts +10 -6
  36. package/src/index.ts +3 -0
  37. package/src/modules/vote/services/get-vote-details/index.ts +1 -4
  38. package/src/modules/vote/services/get-vote-details/types.ts +6 -0
  39. package/src/modules/vote/services/get-vote-status/index.ts +2 -7
  40. package/src/modules/vote/services/get-vote-status/types.ts +7 -0
  41. package/src/modules/vote/services/index.ts +3 -0
  42. package/src/modules/vote/services/vote/index.ts +1 -11
  43. package/src/modules/vote/services/vote/types.ts +11 -0
@@ -21,17 +21,17 @@ var vote_1 = __importDefault(require("../modules/vote"));
21
21
  * @description Client for Community SDK
22
22
  */
23
23
  var CommunityClient = /** @class */ (function () {
24
- function CommunityClient(config) {
25
- CommunityClient.config = __assign(__assign({}, CommunityClient.config), config);
24
+ function CommunityClient(params) {
25
+ CommunityClient.config = constants_1.SERVICE_CONFIG[params.environment];
26
+ CommunityClient.config = __assign(__assign({}, CommunityClient.config), params);
26
27
  this._vote = new vote_1.default(CommunityClient.config.chainId);
27
28
  }
28
- CommunityClient.configure = function (config) {
29
- CommunityClient.config = config;
30
- CommunityClient.instance = new CommunityClient(config);
29
+ CommunityClient.configure = function (params) {
30
+ CommunityClient.instance = new CommunityClient(params);
31
31
  };
32
32
  CommunityClient.getInstance = function () {
33
33
  if (!CommunityClient.instance) {
34
- throw new Error('ApiClient is not configured. Please configure it before using.');
34
+ throw new Error('Client is not configured. Please configure it before using.');
35
35
  }
36
36
  return CommunityClient.instance;
37
37
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yCAA4D;AAC5D,yDAAyC;AAGzC;;GAEG;AACH;IAKE,yBAAoB,MAAqB;QACvC,eAAe,CAAC,MAAM,yBAAQ,eAAe,CAAC,MAAM,GAAK,MAAM,CAAE,CAAC;QAClE,IAAI,CAAC,KAAK,GAAG,IAAI,cAAU,CAAC,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;IAEa,yBAAS,GAAvB,UAAwB,MAAqB;QAC3C,eAAe,CAAC,MAAM,GAAG,MAAM,CAAC;QAChC,eAAe,CAAC,QAAQ,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC;IAEc,2BAAW,GAA1B;QACE,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;QACJ,CAAC;QACD,OAAO,eAAe,CAAC,QAAQ,CAAC;IAClC,CAAC;IASD,sBAAkB,uBAAI;QAPtB;;;;;;WAMG;aACH;YACE,OAAO,eAAe,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC;QAC7C,CAAC;;;OAAA;IAED,sBAAkB,kCAAe;aAAjC;YACE,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC1C,CAAC;;;OAAA;IAnCc,sBAAM,GAAkB,0BAAc,CAAC,MAAM,CAAC,CAAC;IAoChE,sBAAC;CAAA,AAtCD,IAsCC;AAtCY,0CAAe","sourcesContent":["import { SERVICE_CONFIG, ServiceConfig } from './constants';\nimport VoteModule from '../modules/vote';\nimport { ReyaChainId } from '@reyaxyz/common';\n\n/**\n * @description Client for Community SDK\n */\nexport class CommunityClient {\n private static instance: CommunityClient;\n private static config: ServiceConfig = SERVICE_CONFIG['test'];\n private readonly _vote: VoteModule;\n\n private constructor(config: ServiceConfig) {\n CommunityClient.config = { ...CommunityClient.config, ...config };\n this._vote = new VoteModule(CommunityClient.config.chainId);\n }\n\n public static configure(config: ServiceConfig): void {\n CommunityClient.config = config;\n CommunityClient.instance = new CommunityClient(config);\n }\n\n private static getInstance(): CommunityClient {\n if (!CommunityClient.instance) {\n throw new Error(\n 'ApiClient is not configured. Please configure it before using.',\n );\n }\n return CommunityClient.instance;\n }\n\n /**\n * Provides access to the VoteModule instance.\n * This getter allows for interacting with vote-related functionalities.\n *\n * @returns {VoteModule} An instance of VoteModule for vote operations.\n * @memberof CommunityClient\n */\n public static get vote(): VoteModule {\n return CommunityClient.getInstance()._vote;\n }\n\n public static get supportedChains(): ReyaChainId[] {\n return [CommunityClient.config.chainId];\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yCAA4D;AAC5D,yDAAyC;AAOzC;;GAEG;AACH;IAKE,yBAAoB,MAAuB;QACzC,eAAe,CAAC,MAAM,GAAG,0BAAc,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC5D,eAAe,CAAC,MAAM,yBAAQ,eAAe,CAAC,MAAM,GAAK,MAAM,CAAE,CAAC;QAClE,IAAI,CAAC,KAAK,GAAG,IAAI,cAAU,CAAC,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;IAEa,yBAAS,GAAvB,UAAwB,MAAuB;QAC7C,eAAe,CAAC,QAAQ,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC;IAEc,2BAAW,GAA1B;QACE,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;QACJ,CAAC;QACD,OAAO,eAAe,CAAC,QAAQ,CAAC;IAClC,CAAC;IASD,sBAAkB,uBAAI;QAPtB;;;;;;WAMG;aACH;YACE,OAAO,eAAe,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC;QAC7C,CAAC;;;OAAA;IAED,sBAAkB,kCAAe;aAAjC;YACE,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC1C,CAAC;;;OAAA;IAnCc,sBAAM,GAAkB,0BAAc,CAAC,MAAM,CAAC,CAAC;IAoChE,sBAAC;CAAA,AAtCD,IAsCC;AAtCY,0CAAe","sourcesContent":["import { SERVICE_CONFIG, ServiceConfig } from './constants';\nimport VoteModule from '../modules/vote';\nimport { ReyaChainId } from '@reyaxyz/common';\n\nexport type ConfigureParams = {\n environment: ServiceConfig['environment'];\n};\n\n/**\n * @description Client for Community SDK\n */\nexport class CommunityClient {\n private static instance: CommunityClient;\n private static config: ServiceConfig = SERVICE_CONFIG['test'];\n private readonly _vote: VoteModule;\n\n private constructor(params: ConfigureParams) {\n CommunityClient.config = SERVICE_CONFIG[params.environment];\n CommunityClient.config = { ...CommunityClient.config, ...params };\n this._vote = new VoteModule(CommunityClient.config.chainId);\n }\n\n public static configure(params: ConfigureParams): void {\n CommunityClient.instance = new CommunityClient(params);\n }\n\n private static getInstance(): CommunityClient {\n if (!CommunityClient.instance) {\n throw new Error(\n 'Client is not configured. Please configure it before using.',\n );\n }\n return CommunityClient.instance;\n }\n\n /**\n * Provides access to the VoteModule instance.\n * This getter allows for interacting with vote-related functionalities.\n *\n * @returns {VoteModule} An instance of VoteModule for vote operations.\n * @memberof CommunityClient\n */\n public static get vote(): VoteModule {\n return CommunityClient.getInstance()._vote;\n }\n\n public static get supportedChains(): ReyaChainId[] {\n return [CommunityClient.config.chainId];\n }\n}\n"]}
package/dist/index.js CHANGED
@@ -16,4 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./types"), exports);
18
18
  __exportStar(require("./client"), exports);
19
+ __exportStar(require("./modules/vote/services/get-vote-details/types"), exports);
20
+ __exportStar(require("./modules/vote/services/get-vote-status/types"), exports);
21
+ __exportStar(require("./modules/vote/services/vote/types"), exports);
19
22
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2CAAyB","sourcesContent":["export * from './types';\nexport * from './client';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2CAAyB;AACzB,iFAA+D;AAC/D,gFAA8D;AAC9D,qEAAmD","sourcesContent":["export * from './types';\nexport * from './client';\nexport * from './modules/vote/services/get-vote-details/types';\nexport * from './modules/vote/services/get-vote-status/types';\nexport * from './modules/vote/services/vote/types';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/vote/services/get-vote-details/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,cAAc,CAAC,EAAU;IAChC,IAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,gCAAgC;IAClG,OAAO;QACL,EAAE,IAAA;QACF,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;QACrB,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,SAAS,EAAE,yBAAyB;QAChF,gBAAgB,EAAE,CAAC;QACnB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;QACzC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;KACzC,CAAC;AACJ,CAAC;AAMD,oCAAoC;AACpC,gHAAgH;AACzG,IAAM,cAAc,GAAG,UAAO,EAEd;QADrB,EAAE,QAAA;;;;wBAEK,qBAAM,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;wBACvC,UAAU,CACR;4BACE,IAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;4BACvC,IAAI,KAAK,EAAE,CAAC;gCACV,MAAM,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;4BACtC,CAAC;4BACD,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC;wBAC9B,CAAC,EACD,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,IAAI,CAC3B,CAAC;oBACJ,CAAC,CAAC,EAAA;wBAXF,sBAAO,SAWL,EAAC;;;;CACJ,CAAC;AAfW,QAAA,cAAc,kBAezB","sourcesContent":["import { VoteDetailsEntity } from '../../../../types';\n\nfunction mockVoteEntity(id: number): VoteDetailsEntity {\n const daysToAdd = Math.floor(Math.random() * (30 - 14 + 1)) + 14; // Random days between 14 and 30\n return {\n id,\n startDate: Date.now(),\n endDate: Date.now() + 1000 * 60 * 60 * 24 * daysToAdd, // 14 to 30 days from now\n percentageToPass: 4,\n yesCount: Math.floor(Math.random() * 100),\n noCount: Math.floor(Math.random() * 100),\n };\n}\n\nexport type GetVoteDetailsParams = {\n id: VoteDetailsEntity['id'];\n};\nexport type GetVoteDetailsResult = VoteDetailsEntity;\n// TODO: Write proper implementation\n// TODO: Note if vote details cannot be found throw new Error('Vote not found') UI will have logic based on this\nexport const getVoteDetails = async ({\n id,\n}: GetVoteDetailsParams): Promise<GetVoteDetailsResult> => {\n return await new Promise((resolve, reject) => {\n setTimeout(\n () => {\n const error = Math.random() * 100 > 50;\n if (error) {\n reject(new Error('Vote not found'));\n }\n resolve(mockVoteEntity(id));\n },\n Math.random() * 100 + 1000,\n );\n });\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/vote/services/get-vote-details/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAS,cAAc,CAAC,EAAU;IAChC,IAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,gCAAgC;IAClG,OAAO;QACL,EAAE,IAAA;QACF,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;QACrB,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,SAAS,EAAE,yBAAyB;QAChF,gBAAgB,EAAE,CAAC;QACnB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;QACzC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;KACzC,CAAC;AACJ,CAAC;AAED,oCAAoC;AACpC,gHAAgH;AACzG,IAAM,cAAc,GAAG,UAAO,EAEd;QADrB,EAAE,QAAA;;;;wBAEK,qBAAM,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;wBACvC,UAAU,CACR;4BACE,IAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;4BACvC,IAAI,KAAK,EAAE,CAAC;gCACV,MAAM,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;4BACtC,CAAC;4BACD,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC;wBAC9B,CAAC,EACD,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,IAAI,CAC3B,CAAC;oBACJ,CAAC,CAAC,EAAA;wBAXF,sBAAO,SAWL,EAAC;;;;CACJ,CAAC;AAfW,QAAA,cAAc,kBAezB","sourcesContent":["import { VoteDetailsEntity } from '../../../../types';\nimport { GetVoteDetailsParams, GetVoteDetailsResult } from './types';\n\nfunction mockVoteEntity(id: number): VoteDetailsEntity {\n const daysToAdd = Math.floor(Math.random() * (30 - 14 + 1)) + 14; // Random days between 14 and 30\n return {\n id,\n startDate: Date.now(),\n endDate: Date.now() + 1000 * 60 * 60 * 24 * daysToAdd, // 14 to 30 days from now\n percentageToPass: 4,\n yesCount: Math.floor(Math.random() * 100),\n noCount: Math.floor(Math.random() * 100),\n };\n}\n\n// TODO: Write proper implementation\n// TODO: Note if vote details cannot be found throw new Error('Vote not found') UI will have logic based on this\nexport const getVoteDetails = async ({\n id,\n}: GetVoteDetailsParams): Promise<GetVoteDetailsResult> => {\n return await new Promise((resolve, reject) => {\n setTimeout(\n () => {\n const error = Math.random() * 100 > 50;\n if (error) {\n reject(new Error('Vote not found'));\n }\n resolve(mockVoteEntity(id));\n },\n Math.random() * 100 + 1000,\n );\n });\n};\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["modules/vote/services/get-vote-details/types.ts"],"names":[],"mappings":"","sourcesContent":["import { VoteDetailsEntity } from '../../../../types';\n\nexport type GetVoteDetailsParams = {\n id: VoteDetailsEntity['id'];\n};\nexport type GetVoteDetailsResult = VoteDetailsEntity;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/vote/services/get-vote-status/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,oBAAoB;IAC3B,OAAO;QACL,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,wCAAwC;QACvF,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,EAAE,yBAAyB;KACzD,CAAC;AACJ,CAAC;AAQD,oCAAoC;AAC7B,IAAM,aAAa,GAAG,UAAO,EAGd;QAFpB,EAAE,QAAA,EACF,OAAO,aAAA;;;;wBAEA,qBAAM,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;wBACvC,UAAU,CACR;4BACE,IAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;4BACvC,IAAI,KAAK,EAAE,CAAC;gCACV,MAAM,CAAC,IAAI,KAAK,CAAC,eAAQ,EAAE,eAAK,OAAO,WAAQ,CAAC,CAAC,CAAC;4BACpD,CAAC;4BACD,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;wBAClC,CAAC,EACD,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,IAAI,CAC3B,CAAC;oBACJ,CAAC,CAAC,EAAA;wBAXF,sBAAO,SAWL,EAAC;;;;CACJ,CAAC;AAhBW,QAAA,aAAa,iBAgBxB","sourcesContent":["import { VoteDetailsEntity, VoteStatusEntity } from '../../../../types';\n\nfunction mockVoteStatusEntity(): VoteStatusEntity {\n return {\n votingPower: Math.floor(Math.random() * 1000), // Random voting power between 0 and 999\n hasVoted: Math.random() < 0.5, // Randomly true or false\n };\n}\n\nexport type GetVoteStatusParams = {\n address: string;\n id: VoteDetailsEntity['id'];\n};\nexport type GetVoteStatusResult = VoteStatusEntity;\n\n// TODO: Write proper implementation\nexport const getVoteStatus = async ({\n id,\n address,\n}: GetVoteStatusParams): Promise<GetVoteStatusResult> => {\n return await new Promise((resolve, reject) => {\n setTimeout(\n () => {\n const error = Math.random() * 100 > 50;\n if (error) {\n reject(new Error(`Vote ${id}, ${address} error`));\n }\n resolve(mockVoteStatusEntity());\n },\n Math.random() * 100 + 1000,\n );\n });\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/vote/services/get-vote-status/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAS,oBAAoB;IAC3B,OAAO;QACL,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,wCAAwC;QACvF,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,EAAE,yBAAyB;KACzD,CAAC;AACJ,CAAC;AAED,oCAAoC;AAC7B,IAAM,aAAa,GAAG,UAAO,EAGd;QAFpB,EAAE,QAAA,EACF,OAAO,aAAA;;;;wBAEA,qBAAM,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;wBACvC,UAAU,CACR;4BACE,IAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;4BACvC,IAAI,KAAK,EAAE,CAAC;gCACV,MAAM,CAAC,IAAI,KAAK,CAAC,eAAQ,EAAE,eAAK,OAAO,WAAQ,CAAC,CAAC,CAAC;4BACpD,CAAC;4BACD,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;wBAClC,CAAC,EACD,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,IAAI,CAC3B,CAAC;oBACJ,CAAC,CAAC,EAAA;wBAXF,sBAAO,SAWL,EAAC;;;;CACJ,CAAC;AAhBW,QAAA,aAAa,iBAgBxB","sourcesContent":["import { VoteStatusEntity } from '../../../../types';\nimport { GetVoteStatusParams, GetVoteStatusResult } from './types';\n\nfunction mockVoteStatusEntity(): VoteStatusEntity {\n return {\n votingPower: Math.floor(Math.random() * 1000), // Random voting power between 0 and 999\n hasVoted: Math.random() < 0.5, // Randomly true or false\n };\n}\n\n// TODO: Write proper implementation\nexport const getVoteStatus = async ({\n id,\n address,\n}: GetVoteStatusParams): Promise<GetVoteStatusResult> => {\n return await new Promise((resolve, reject) => {\n setTimeout(\n () => {\n const error = Math.random() * 100 > 50;\n if (error) {\n reject(new Error(`Vote ${id}, ${address} error`));\n }\n resolve(mockVoteStatusEntity());\n },\n Math.random() * 100 + 1000,\n );\n });\n};\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["modules/vote/services/get-vote-status/types.ts"],"names":[],"mappings":"","sourcesContent":["import { VoteDetailsEntity, VoteStatusEntity } from '../../../../types';\n\nexport type GetVoteStatusParams = {\n address: string;\n id: VoteDetailsEntity['id'];\n};\nexport type GetVoteStatusResult = VoteStatusEntity;\n"]}
@@ -17,4 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./get-vote-details"), exports);
18
18
  __exportStar(require("./get-vote-status"), exports);
19
19
  __exportStar(require("./vote"), exports);
20
+ __exportStar(require("./get-vote-details/types"), exports);
21
+ __exportStar(require("./get-vote-status/types"), exports);
22
+ __exportStar(require("./vote/types"), exports);
20
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/vote/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,oDAAkC;AAClC,yCAAuB","sourcesContent":["export * from './get-vote-details';\nexport * from './get-vote-status';\nexport * from './vote';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/vote/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,oDAAkC;AAClC,yCAAuB;AACvB,2DAAyC;AACzC,0DAAwC;AACxC,+CAA6B","sourcesContent":["export * from './get-vote-details';\nexport * from './get-vote-status';\nexport * from './vote';\nexport * from './get-vote-details/types';\nexport * from './get-vote-status/types';\nexport * from './vote/types';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/vote/services/vote/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,oCAAoC;AAC7B,IAAM,IAAI,GAAG,UAAO,EAAkB;QAAhB,EAAE,QAAA;;;;wBACtB,qBAAM,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;wBACvC,UAAU,CACR;4BACE,IAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;4BACvC,IAAI,KAAK,EAAE,CAAC;gCACV,MAAM,CAAC,IAAI,KAAK,CAAC,eAAQ,EAAE,WAAQ,CAAC,CAAC,CAAC;4BACxC,CAAC;4BACD,OAAO,CAAC;gCACN,eAAe,EAAE,WAAW;6BAC7B,CAAC,CAAC;wBACL,CAAC,EACD,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,IAAI,CAC3B,CAAC;oBACJ,CAAC,CAAC,EAAA;wBAbF,sBAAO,SAaL,EAAC;;;;CACJ,CAAC;AAfW,QAAA,IAAI,QAef","sourcesContent":["import { VoteDetailsEntity } from '../../../../types';\nimport { Signer, JsonRpcSigner } from 'ethers';\n\nexport type VoteParams = {\n id: VoteDetailsEntity['id'];\n voted: 'yes' | 'no';\n signer: Signer | JsonRpcSigner;\n};\nexport type VoteResult = {\n transactionHash: string;\n};\n\n// TODO: Write proper implementation\nexport const vote = async ({ id }: VoteParams): Promise<VoteResult> => {\n return await new Promise((resolve, reject) => {\n setTimeout(\n () => {\n const error = Math.random() * 100 > 50;\n if (error) {\n reject(new Error(`Vote ${id} error`));\n }\n resolve({\n transactionHash: '0x123fake',\n });\n },\n Math.random() * 100 + 1000,\n );\n });\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/vote/services/vote/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,oCAAoC;AAC7B,IAAM,IAAI,GAAG,UAAO,EAAkB;QAAhB,EAAE,QAAA;;;;wBACtB,qBAAM,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;wBACvC,UAAU,CACR;4BACE,IAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;4BACvC,IAAI,KAAK,EAAE,CAAC;gCACV,MAAM,CAAC,IAAI,KAAK,CAAC,eAAQ,EAAE,WAAQ,CAAC,CAAC,CAAC;4BACxC,CAAC;4BACD,OAAO,CAAC;gCACN,eAAe,EAAE,WAAW;6BAC7B,CAAC,CAAC;wBACL,CAAC,EACD,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,IAAI,CAC3B,CAAC;oBACJ,CAAC,CAAC,EAAA;wBAbF,sBAAO,SAaL,EAAC;;;;CACJ,CAAC;AAfW,QAAA,IAAI,QAef","sourcesContent":["import { VoteParams, VoteResult } from './types';\n\n// TODO: Write proper implementation\nexport const vote = async ({ id }: VoteParams): Promise<VoteResult> => {\n return await new Promise((resolve, reject) => {\n setTimeout(\n () => {\n const error = Math.random() * 100 > 50;\n if (error) {\n reject(new Error(`Vote ${id} error`));\n }\n resolve({\n transactionHash: '0x123fake',\n });\n },\n Math.random() * 100 + 1000,\n );\n });\n};\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["modules/vote/services/vote/types.ts"],"names":[],"mappings":"","sourcesContent":["import { VoteDetailsEntity } from '../../../../types';\nimport { JsonRpcSigner, Signer } from 'ethers';\n\nexport type VoteParams = {\n id: VoteDetailsEntity['id'];\n voted: 'yes' | 'no';\n signer: Signer | JsonRpcSigner;\n};\nexport type VoteResult = {\n transactionHash: string;\n};\n"]}
@@ -1,6 +1,9 @@
1
1
  import { ServiceConfig } from './constants';
2
2
  import VoteModule from '../modules/vote';
3
3
  import { ReyaChainId } from '@reyaxyz/common';
4
+ export type ConfigureParams = {
5
+ environment: ServiceConfig['environment'];
6
+ };
4
7
  /**
5
8
  * @description Client for Community SDK
6
9
  */
@@ -9,7 +12,7 @@ export declare class CommunityClient {
9
12
  private static config;
10
13
  private readonly _vote;
11
14
  private constructor();
12
- static configure(config: ServiceConfig): void;
15
+ static configure(params: ConfigureParams): void;
13
16
  private static getInstance;
14
17
  /**
15
18
  * Provides access to the VoteModule instance.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAkB;IACzC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAyC;IAC9D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IAEnC,OAAO;WAKO,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAKpD,OAAO,CAAC,MAAM,CAAC,WAAW;IAS1B;;;;;;OAMG;IACH,WAAkB,IAAI,IAAI,UAAU,CAEnC;IAED,WAAkB,eAAe,IAAI,WAAW,EAAE,CAEjD;CACF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAkB;IACzC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAyC;IAC9D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IAEnC,OAAO;WAMO,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAItD,OAAO,CAAC,MAAM,CAAC,WAAW;IAS1B;;;;;;OAMG;IACH,WAAkB,IAAI,IAAI,UAAU,CAEnC;IAED,WAAkB,eAAe,IAAI,WAAW,EAAE,CAEjD;CACF"}
@@ -1,3 +1,6 @@
1
1
  export * from './types';
2
2
  export * from './client';
3
+ export * from './modules/vote/services/get-vote-details/types';
4
+ export * from './modules/vote/services/get-vote-status/types';
5
+ export * from './modules/vote/services/vote/types';
3
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,gDAAgD,CAAC;AAC/D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,oCAAoC,CAAC"}
@@ -1,7 +1,3 @@
1
- import { VoteDetailsEntity } from '../../../../types';
2
- export type GetVoteDetailsParams = {
3
- id: VoteDetailsEntity['id'];
4
- };
5
- export type GetVoteDetailsResult = VoteDetailsEntity;
1
+ import { GetVoteDetailsParams, GetVoteDetailsResult } from './types';
6
2
  export declare const getVoteDetails: ({ id, }: GetVoteDetailsParams) => Promise<GetVoteDetailsResult>;
7
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/vote/services/get-vote-details/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AActD,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;CAC7B,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AAGrD,eAAO,MAAM,cAAc,YAExB,oBAAoB,KAAG,QAAQ,oBAAoB,CAarD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/vote/services/get-vote-details/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAgBrE,eAAO,MAAM,cAAc,YAExB,oBAAoB,KAAG,QAAQ,oBAAoB,CAarD,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { VoteDetailsEntity } from '../../../../types';
2
+ export type GetVoteDetailsParams = {
3
+ id: VoteDetailsEntity['id'];
4
+ };
5
+ export type GetVoteDetailsResult = VoteDetailsEntity;
6
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["modules/vote/services/get-vote-details/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;CAC7B,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAC"}
@@ -1,8 +1,3 @@
1
- import { VoteDetailsEntity, VoteStatusEntity } from '../../../../types';
2
- export type GetVoteStatusParams = {
3
- address: string;
4
- id: VoteDetailsEntity['id'];
5
- };
6
- export type GetVoteStatusResult = VoteStatusEntity;
1
+ import { GetVoteStatusParams, GetVoteStatusResult } from './types';
7
2
  export declare const getVoteStatus: ({ id, address, }: GetVoteStatusParams) => Promise<GetVoteStatusResult>;
8
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/vote/services/get-vote-status/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AASxE,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;CAC7B,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAGnD,eAAO,MAAM,aAAa,qBAGvB,mBAAmB,KAAG,QAAQ,mBAAmB,CAanD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/vote/services/get-vote-status/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAUnE,eAAO,MAAM,aAAa,qBAGvB,mBAAmB,KAAG,QAAQ,mBAAmB,CAanD,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { VoteDetailsEntity, VoteStatusEntity } from '../../../../types';
2
+ export type GetVoteStatusParams = {
3
+ address: string;
4
+ id: VoteDetailsEntity['id'];
5
+ };
6
+ export type GetVoteStatusResult = VoteStatusEntity;
7
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["modules/vote/services/get-vote-status/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAExE,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;CAC7B,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,CAAC"}
@@ -1,4 +1,7 @@
1
1
  export * from './get-vote-details';
2
2
  export * from './get-vote-status';
3
3
  export * from './vote';
4
+ export * from './get-vote-details/types';
5
+ export * from './get-vote-status/types';
6
+ export * from './vote/types';
4
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/vote/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/vote/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC"}
@@ -1,12 +1,3 @@
1
- import { VoteDetailsEntity } from '../../../../types';
2
- import { Signer, JsonRpcSigner } from 'ethers';
3
- export type VoteParams = {
4
- id: VoteDetailsEntity['id'];
5
- voted: 'yes' | 'no';
6
- signer: Signer | JsonRpcSigner;
7
- };
8
- export type VoteResult = {
9
- transactionHash: string;
10
- };
1
+ import { VoteParams, VoteResult } from './types';
11
2
  export declare const vote: ({ id }: VoteParams) => Promise<VoteResult>;
12
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/vote/services/vote/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE/C,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC5B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;CAChC,CAAC;AACF,MAAM,MAAM,UAAU,GAAG;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAGF,eAAO,MAAM,IAAI,WAAkB,UAAU,KAAG,QAAQ,UAAU,CAejE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/vote/services/vote/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGjD,eAAO,MAAM,IAAI,WAAkB,UAAU,KAAG,QAAQ,UAAU,CAejE,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { VoteDetailsEntity } from '../../../../types';
2
+ import { JsonRpcSigner, Signer } from 'ethers';
3
+ export type VoteParams = {
4
+ id: VoteDetailsEntity['id'];
5
+ voted: 'yes' | 'no';
6
+ signer: Signer | JsonRpcSigner;
7
+ };
8
+ export type VoteResult = {
9
+ transactionHash: string;
10
+ };
11
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["modules/vote/services/vote/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE/C,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC5B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;CAChC,CAAC;AACF,MAAM,MAAM,UAAU,GAAG;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/community-sdk",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -37,5 +37,5 @@
37
37
  "generate:coverage-badges": "npx istanbul-badges-readme --silent"
38
38
  },
39
39
  "packageManager": "pnpm@8.10.4",
40
- "gitHead": "20065af445294262cd034d36e1725772826c5448"
40
+ "gitHead": "354d56c5e307a768a4ffeb419aa328eddea7b89c"
41
41
  }
@@ -2,6 +2,10 @@ import { SERVICE_CONFIG, ServiceConfig } from './constants';
2
2
  import VoteModule from '../modules/vote';
3
3
  import { ReyaChainId } from '@reyaxyz/common';
4
4
 
5
+ export type ConfigureParams = {
6
+ environment: ServiceConfig['environment'];
7
+ };
8
+
5
9
  /**
6
10
  * @description Client for Community SDK
7
11
  */
@@ -10,20 +14,20 @@ export class CommunityClient {
10
14
  private static config: ServiceConfig = SERVICE_CONFIG['test'];
11
15
  private readonly _vote: VoteModule;
12
16
 
13
- private constructor(config: ServiceConfig) {
14
- CommunityClient.config = { ...CommunityClient.config, ...config };
17
+ private constructor(params: ConfigureParams) {
18
+ CommunityClient.config = SERVICE_CONFIG[params.environment];
19
+ CommunityClient.config = { ...CommunityClient.config, ...params };
15
20
  this._vote = new VoteModule(CommunityClient.config.chainId);
16
21
  }
17
22
 
18
- public static configure(config: ServiceConfig): void {
19
- CommunityClient.config = config;
20
- CommunityClient.instance = new CommunityClient(config);
23
+ public static configure(params: ConfigureParams): void {
24
+ CommunityClient.instance = new CommunityClient(params);
21
25
  }
22
26
 
23
27
  private static getInstance(): CommunityClient {
24
28
  if (!CommunityClient.instance) {
25
29
  throw new Error(
26
- 'ApiClient is not configured. Please configure it before using.',
30
+ 'Client is not configured. Please configure it before using.',
27
31
  );
28
32
  }
29
33
  return CommunityClient.instance;
package/src/index.ts CHANGED
@@ -1,2 +1,5 @@
1
1
  export * from './types';
2
2
  export * from './client';
3
+ export * from './modules/vote/services/get-vote-details/types';
4
+ export * from './modules/vote/services/get-vote-status/types';
5
+ export * from './modules/vote/services/vote/types';
@@ -1,4 +1,5 @@
1
1
  import { VoteDetailsEntity } from '../../../../types';
2
+ import { GetVoteDetailsParams, GetVoteDetailsResult } from './types';
2
3
 
3
4
  function mockVoteEntity(id: number): VoteDetailsEntity {
4
5
  const daysToAdd = Math.floor(Math.random() * (30 - 14 + 1)) + 14; // Random days between 14 and 30
@@ -12,10 +13,6 @@ function mockVoteEntity(id: number): VoteDetailsEntity {
12
13
  };
13
14
  }
14
15
 
15
- export type GetVoteDetailsParams = {
16
- id: VoteDetailsEntity['id'];
17
- };
18
- export type GetVoteDetailsResult = VoteDetailsEntity;
19
16
  // TODO: Write proper implementation
20
17
  // TODO: Note if vote details cannot be found throw new Error('Vote not found') UI will have logic based on this
21
18
  export const getVoteDetails = async ({
@@ -0,0 +1,6 @@
1
+ import { VoteDetailsEntity } from '../../../../types';
2
+
3
+ export type GetVoteDetailsParams = {
4
+ id: VoteDetailsEntity['id'];
5
+ };
6
+ export type GetVoteDetailsResult = VoteDetailsEntity;
@@ -1,4 +1,5 @@
1
- import { VoteDetailsEntity, VoteStatusEntity } from '../../../../types';
1
+ import { VoteStatusEntity } from '../../../../types';
2
+ import { GetVoteStatusParams, GetVoteStatusResult } from './types';
2
3
 
3
4
  function mockVoteStatusEntity(): VoteStatusEntity {
4
5
  return {
@@ -7,12 +8,6 @@ function mockVoteStatusEntity(): VoteStatusEntity {
7
8
  };
8
9
  }
9
10
 
10
- export type GetVoteStatusParams = {
11
- address: string;
12
- id: VoteDetailsEntity['id'];
13
- };
14
- export type GetVoteStatusResult = VoteStatusEntity;
15
-
16
11
  // TODO: Write proper implementation
17
12
  export const getVoteStatus = async ({
18
13
  id,
@@ -0,0 +1,7 @@
1
+ import { VoteDetailsEntity, VoteStatusEntity } from '../../../../types';
2
+
3
+ export type GetVoteStatusParams = {
4
+ address: string;
5
+ id: VoteDetailsEntity['id'];
6
+ };
7
+ export type GetVoteStatusResult = VoteStatusEntity;
@@ -1,3 +1,6 @@
1
1
  export * from './get-vote-details';
2
2
  export * from './get-vote-status';
3
3
  export * from './vote';
4
+ export * from './get-vote-details/types';
5
+ export * from './get-vote-status/types';
6
+ export * from './vote/types';
@@ -1,14 +1,4 @@
1
- import { VoteDetailsEntity } from '../../../../types';
2
- import { Signer, JsonRpcSigner } from 'ethers';
3
-
4
- export type VoteParams = {
5
- id: VoteDetailsEntity['id'];
6
- voted: 'yes' | 'no';
7
- signer: Signer | JsonRpcSigner;
8
- };
9
- export type VoteResult = {
10
- transactionHash: string;
11
- };
1
+ import { VoteParams, VoteResult } from './types';
12
2
 
13
3
  // TODO: Write proper implementation
14
4
  export const vote = async ({ id }: VoteParams): Promise<VoteResult> => {
@@ -0,0 +1,11 @@
1
+ import { VoteDetailsEntity } from '../../../../types';
2
+ import { JsonRpcSigner, Signer } from 'ethers';
3
+
4
+ export type VoteParams = {
5
+ id: VoteDetailsEntity['id'];
6
+ voted: 'yes' | 'no';
7
+ signer: Signer | JsonRpcSigner;
8
+ };
9
+ export type VoteResult = {
10
+ transactionHash: string;
11
+ };