@ozdao/prometheus-framework 0.2.132 → 0.2.134

Sign up to get free protection for your applications and to get access to all the features.
Files changed (228) hide show
  1. package/dist/_virtual/alignment-pattern.cjs +1 -0
  2. package/dist/_virtual/alignment-pattern.js +4 -0
  3. package/dist/_virtual/browser.cjs +1 -0
  4. package/dist/_virtual/browser.js +4 -0
  5. package/dist/_virtual/canvas.cjs +1 -0
  6. package/dist/_virtual/canvas.js +4 -0
  7. package/dist/_virtual/dijkstra.cjs +1 -0
  8. package/dist/_virtual/dijkstra.js +4 -0
  9. package/dist/_virtual/error-correction-code.cjs +1 -0
  10. package/dist/_virtual/error-correction-code.js +4 -0
  11. package/dist/_virtual/error-correction-level.cjs +1 -0
  12. package/dist/_virtual/error-correction-level.js +4 -0
  13. package/dist/_virtual/finder-pattern.cjs +1 -0
  14. package/dist/_virtual/finder-pattern.js +4 -0
  15. package/dist/_virtual/format-info.cjs +1 -0
  16. package/dist/_virtual/format-info.js +4 -0
  17. package/dist/_virtual/galois-field.cjs +1 -0
  18. package/dist/_virtual/galois-field.js +4 -0
  19. package/dist/_virtual/mask-pattern.cjs +1 -0
  20. package/dist/_virtual/mask-pattern.js +4 -0
  21. package/dist/_virtual/mode.cjs +1 -0
  22. package/dist/_virtual/mode.js +4 -0
  23. package/dist/_virtual/polynomial.cjs +1 -0
  24. package/dist/_virtual/polynomial.js +4 -0
  25. package/dist/_virtual/qrcode.cjs +1 -0
  26. package/dist/_virtual/qrcode.js +4 -0
  27. package/dist/_virtual/regex.cjs +1 -0
  28. package/dist/_virtual/regex.js +4 -0
  29. package/dist/_virtual/segments.cjs +1 -0
  30. package/dist/_virtual/segments.js +4 -0
  31. package/dist/_virtual/svg-tag.cjs +1 -0
  32. package/dist/_virtual/svg-tag.js +4 -0
  33. package/dist/_virtual/utils.cjs +1 -0
  34. package/dist/_virtual/utils.js +4 -0
  35. package/dist/_virtual/utils2.cjs +1 -0
  36. package/dist/_virtual/utils2.js +4 -0
  37. package/dist/_virtual/version-check.cjs +1 -0
  38. package/dist/_virtual/version-check.js +4 -0
  39. package/dist/_virtual/version.cjs +1 -0
  40. package/dist/_virtual/version.js +4 -0
  41. package/dist/auth.server.js +1 -1
  42. package/dist/auth.server.mjs +1 -1
  43. package/dist/community.server.js +1 -1
  44. package/dist/community.server.mjs +1 -1
  45. package/dist/events.server.js +1 -1
  46. package/dist/events.server.mjs +1 -1
  47. package/dist/files.server.js +1 -1
  48. package/dist/files.server.mjs +1 -1
  49. package/dist/gallery.server.js +1 -1
  50. package/dist/gallery.server.mjs +1 -1
  51. package/dist/index-C-8xOJnM.mjs +244 -0
  52. package/dist/index-CDbtWkBj.js +243 -0
  53. package/dist/main-5IrI2IOV.js +92 -0
  54. package/dist/main-BY2OvGB9.mjs +14509 -0
  55. package/dist/main.css +1 -1
  56. package/dist/middlewares.server.js +1 -1
  57. package/dist/middlewares.server.mjs +1 -1
  58. package/dist/node_modules/dijkstrajs/dijkstra.cjs +1 -0
  59. package/dist/node_modules/dijkstrajs/dijkstra.js +70 -0
  60. package/dist/node_modules/encode-utf8/index.cjs +1 -0
  61. package/dist/node_modules/encode-utf8/index.js +30 -0
  62. package/dist/node_modules/qrcode/lib/browser.cjs +1 -0
  63. package/dist/node_modules/qrcode/lib/browser.js +45 -0
  64. package/dist/node_modules/qrcode/lib/can-promise.cjs +1 -0
  65. package/dist/node_modules/qrcode/lib/can-promise.js +6 -0
  66. package/dist/node_modules/qrcode/lib/core/alignment-pattern.cjs +1 -0
  67. package/dist/node_modules/qrcode/lib/core/alignment-pattern.js +21 -0
  68. package/dist/node_modules/qrcode/lib/core/alphanumeric-data.cjs +1 -0
  69. package/dist/node_modules/qrcode/lib/core/alphanumeric-data.js +73 -0
  70. package/dist/node_modules/qrcode/lib/core/bit-buffer.cjs +1 -0
  71. package/dist/node_modules/qrcode/lib/core/bit-buffer.js +24 -0
  72. package/dist/node_modules/qrcode/lib/core/bit-matrix.cjs +1 -0
  73. package/dist/node_modules/qrcode/lib/core/bit-matrix.js +22 -0
  74. package/dist/node_modules/qrcode/lib/core/byte-data.cjs +1 -0
  75. package/dist/node_modules/qrcode/lib/core/byte-data.js +24 -0
  76. package/dist/node_modules/qrcode/lib/core/error-correction-code.cjs +1 -0
  77. package/dist/node_modules/qrcode/lib/core/error-correction-code.js +359 -0
  78. package/dist/node_modules/qrcode/lib/core/error-correction-level.cjs +1 -0
  79. package/dist/node_modules/qrcode/lib/core/error-correction-level.js +35 -0
  80. package/dist/node_modules/qrcode/lib/core/finder-pattern.cjs +1 -0
  81. package/dist/node_modules/qrcode/lib/core/finder-pattern.js +18 -0
  82. package/dist/node_modules/qrcode/lib/core/format-info.cjs +1 -0
  83. package/dist/node_modules/qrcode/lib/core/format-info.js +14 -0
  84. package/dist/node_modules/qrcode/lib/core/galois-field.cjs +1 -0
  85. package/dist/node_modules/qrcode/lib/core/galois-field.js +22 -0
  86. package/dist/node_modules/qrcode/lib/core/kanji-data.cjs +2 -0
  87. package/dist/node_modules/qrcode/lib/core/kanji-data.js +37 -0
  88. package/dist/node_modules/qrcode/lib/core/mask-pattern.cjs +1 -0
  89. package/dist/node_modules/qrcode/lib/core/mask-pattern.js +96 -0
  90. package/dist/node_modules/qrcode/lib/core/mode.cjs +1 -0
  91. package/dist/node_modules/qrcode/lib/core/mode.js +64 -0
  92. package/dist/node_modules/qrcode/lib/core/numeric-data.cjs +1 -0
  93. package/dist/node_modules/qrcode/lib/core/numeric-data.js +26 -0
  94. package/dist/node_modules/qrcode/lib/core/polynomial.cjs +1 -0
  95. package/dist/node_modules/qrcode/lib/core/polynomial.js +29 -0
  96. package/dist/node_modules/qrcode/lib/core/qrcode.cjs +4 -0
  97. package/dist/node_modules/qrcode/lib/core/qrcode.js +159 -0
  98. package/dist/node_modules/qrcode/lib/core/reed-solomon-encoder.cjs +1 -0
  99. package/dist/node_modules/qrcode/lib/core/reed-solomon-encoder.js +25 -0
  100. package/dist/node_modules/qrcode/lib/core/regex.cjs +2 -0
  101. package/dist/node_modules/qrcode/lib/core/regex.js +24 -0
  102. package/dist/node_modules/qrcode/lib/core/segments.cjs +2 -0
  103. package/dist/node_modules/qrcode/lib/core/segments.js +143 -0
  104. package/dist/node_modules/qrcode/lib/core/utils.cjs +1 -0
  105. package/dist/node_modules/qrcode/lib/core/utils.js +74 -0
  106. package/dist/node_modules/qrcode/lib/core/version-check.cjs +1 -0
  107. package/dist/node_modules/qrcode/lib/core/version-check.js +7 -0
  108. package/dist/node_modules/qrcode/lib/core/version.cjs +1 -0
  109. package/dist/node_modules/qrcode/lib/core/version.js +74 -0
  110. package/dist/node_modules/qrcode/lib/renderer/canvas.cjs +1 -0
  111. package/dist/node_modules/qrcode/lib/renderer/canvas.js +27 -0
  112. package/dist/node_modules/qrcode/lib/renderer/svg-tag.cjs +2 -0
  113. package/dist/node_modules/qrcode/lib/renderer/svg-tag.js +28 -0
  114. package/dist/node_modules/qrcode/lib/renderer/utils.cjs +1 -0
  115. package/dist/node_modules/qrcode/lib/renderer/utils.js +52 -0
  116. package/dist/orders.server.js +1 -1
  117. package/dist/orders.server.mjs +1 -1
  118. package/dist/organizations.server.js +1 -1
  119. package/dist/organizations.server.mjs +1 -1
  120. package/dist/products.server.js +1 -1
  121. package/dist/products.server.mjs +1 -1
  122. package/dist/prometheus-framework/src/components/Chips/Chips.vue.cjs +1 -1
  123. package/dist/prometheus-framework/src/components/Chips/Chips.vue.js +12 -13
  124. package/dist/prometheus-framework/src/components/Dropdown/Dropdown.vue.cjs +1 -1
  125. package/dist/prometheus-framework/src/components/Dropdown/Dropdown.vue.js +14 -15
  126. package/dist/prometheus-framework/src/components/Field/Field.vue.cjs +1 -1
  127. package/dist/prometheus-framework/src/components/Field/Field.vue.js +19 -20
  128. package/dist/prometheus-framework/src/components/FieldBig/FieldBig.vue.js +4 -4
  129. package/dist/prometheus-framework/src/components/Popup/Popup.vue2.cjs +1 -0
  130. package/dist/prometheus-framework/src/components/Popup/Popup.vue2.js +77 -0
  131. package/dist/prometheus-framework/src/modules/auth/components/pages/EnterPassword.vue.js +14 -14
  132. package/dist/prometheus-framework/src/modules/auth/components/pages/Invite.vue.js +15 -15
  133. package/dist/prometheus-framework/src/modules/auth/components/pages/ResetPassword.vue.js +11 -11
  134. package/dist/prometheus-framework/src/modules/auth/components/pages/SignIn.vue.js +34 -34
  135. package/dist/prometheus-framework/src/modules/auth/components/pages/SignUp.vue.js +27 -27
  136. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.cjs +1 -1
  137. package/dist/prometheus-framework/src/modules/backoffice/components/pages/Dashboard.vue.js +1 -1
  138. package/dist/prometheus-framework/src/modules/community/components/pages/Blog.vue.cjs +1 -1
  139. package/dist/prometheus-framework/src/modules/community/components/pages/Blog.vue.js +1 -1
  140. package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.cjs +1 -1
  141. package/dist/prometheus-framework/src/modules/community/components/pages/Community.vue.js +1 -1
  142. package/dist/prometheus-framework/src/modules/community/components/pages/CreateBlogPost.vue.js +22 -22
  143. package/dist/prometheus-framework/src/modules/constructor/components/elements/Embed.vue.js +13 -13
  144. package/dist/prometheus-framework/src/modules/events/components/pages/EditEvent.vue.js +9 -9
  145. package/dist/prometheus-framework/src/modules/events/components/pages/EditEventTickets.vue.js +19 -19
  146. package/dist/prometheus-framework/src/modules/globals/components/blocks/BlockSearch.vue.js +7 -7
  147. package/dist/prometheus-framework/src/modules/globals/localization/vue-i18n.cjs +1 -1
  148. package/dist/prometheus-framework/src/modules/globals/localization/vue-i18n.js +8 -8
  149. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.cjs +1 -1
  150. package/dist/prometheus-framework/src/modules/legal/components/pages/Legal.vue.js +1 -1
  151. package/dist/prometheus-framework/src/modules/orders/components/sections/FormCustomerDetails.vue.js +3 -3
  152. package/dist/prometheus-framework/src/modules/orders/components/sections/FormDelivery.vue.js +8 -8
  153. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
  154. package/dist/prometheus-framework/src/modules/organizations/components/pages/Members.vue.js +1 -1
  155. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.cjs +1 -1
  156. package/dist/prometheus-framework/src/modules/organizations/components/pages/Organization.vue.js +1 -1
  157. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationBackoffice.vue.cjs +1 -1
  158. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationBackoffice.vue.js +1 -1
  159. package/dist/prometheus-framework/src/modules/organizations/components/pages/OrganizationEdit.vue.js +4 -4
  160. package/dist/prometheus-framework/src/modules/organizations/components/sections/Documents.vue.js +9 -9
  161. package/dist/prometheus-framework/src/modules/organizations/components/sections/MembersAdd.vue.js +13 -13
  162. package/dist/prometheus-framework/src/modules/products/components/blocks/CardPosition.vue.js +17 -17
  163. package/dist/prometheus-framework/src/modules/products/components/blocks/LeftoverPositions.vue.js +6 -6
  164. package/dist/prometheus-framework/src/modules/products/components/pages/CategoryEdit.vue.js +10 -10
  165. package/dist/prometheus-framework/src/modules/products/components/pages/EditLeftover.vue.js +17 -17
  166. package/dist/prometheus-framework/src/modules/products/components/pages/ProductEdit.vue.js +30 -30
  167. package/dist/prometheus-framework/src/modules/products/components/sections/EditModifications.vue.js +9 -9
  168. package/dist/prometheus-framework/src/modules/products/components/sections/EditProductInfo.vue.js +2 -2
  169. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.cjs +1 -1
  170. package/dist/prometheus-framework/src/modules/users/components/pages/Profile.vue.js +1 -1
  171. package/dist/prometheus-framework/src/modules/users/components/pages/ProfileEdit.vue.js +7 -7
  172. package/dist/prometheus-framework/src/modules/wallet/components/blocks/CardDeposite.vue.cjs +1 -1
  173. package/dist/prometheus-framework/src/modules/wallet/components/blocks/CardDeposite.vue.js +1 -1
  174. package/dist/prometheus-framework/src/modules/wallet/components/blocks/CryptoDeposite.vue.cjs +1 -1
  175. package/dist/prometheus-framework/src/modules/wallet/components/blocks/CryptoDeposite.vue.js +1 -1
  176. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CardBalanceReplenished.vue.cjs +1 -0
  177. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CardBalanceReplenished.vue.js +34 -0
  178. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CardDeposit.vue.cjs +1 -0
  179. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CardDeposit.vue.js +42 -0
  180. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CashDeposit.vue.cjs +1 -0
  181. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CashDeposit.vue.js +26 -0
  182. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.cjs +1 -0
  183. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.js +76 -0
  184. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CryptoDepositProcessing.vue.cjs +1 -0
  185. package/dist/prometheus-framework/src/modules/wallet/views/components/blocks/CryptoDepositProcessing.vue.js +105 -0
  186. package/dist/prometheus-framework/src/modules/wallet/views/components/elements/ConnectMetamask.vue.cjs +1 -0
  187. package/dist/prometheus-framework/src/modules/wallet/views/components/elements/ConnectMetamask.vue.js +106 -0
  188. package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.cjs +1 -1
  189. package/dist/prometheus-framework/src/modules/wallet/views/components/pages/Wallet.vue.js +137 -122
  190. package/dist/prometheus-framework/src/modules/wallet/views/localization/wallet.json.cjs +1 -0
  191. package/dist/prometheus-framework/src/modules/wallet/views/localization/wallet.json.js +41 -0
  192. package/dist/prometheus-framework/src/modules/wallet/views/store/wallet.store.cjs +1 -1
  193. package/dist/prometheus-framework/src/modules/wallet/views/store/wallet.store.js +98 -22
  194. package/dist/prometheus-framework.cjs.js +1 -1
  195. package/dist/prometheus-framework.es.js +1 -1
  196. package/dist/reports.server.js +1 -1
  197. package/dist/reports.server.mjs +1 -1
  198. package/dist/style.css +1 -1
  199. package/dist/wallet.server.js +103 -13
  200. package/dist/wallet.server.mjs +103 -13
  201. package/dist/web-5eyiz9L7.mjs +54 -0
  202. package/dist/web-C04IcLk4.js +1 -0
  203. package/package.json +1 -1
  204. package/src/components/Field/Field.vue +1 -1
  205. package/src/modules/community/components/pages/Blog.vue +1 -1
  206. package/src/modules/globals/components/partials/Header.vue +2 -2
  207. package/src/modules/globals/localization/vue-i18n.js +5 -5
  208. package/src/modules/landing/components/sections/HowToBuyWDR.vue +2 -3
  209. package/src/modules/landing/components/sections/SectionEarn.vue +1 -6
  210. package/src/modules/middlewares/server/authSecret.js +22 -0
  211. package/src/modules/middlewares/server/index.js +7 -5
  212. package/src/modules/wallet/controllers/factories/rewards.factory.js +87 -2
  213. package/src/modules/wallet/controllers/routes/rewards.routes.js +27 -3
  214. package/src/modules/wallet/models/wallet.model.js +5 -5
  215. package/src/modules/wallet/{components → views/components}/blocks/CardBalanceReplenished.vue +17 -7
  216. package/src/modules/wallet/{components/blocks/CardDeposite.vue → views/components/blocks/CardDeposit.vue} +4 -4
  217. package/src/modules/wallet/views/components/blocks/CryptoDeposit.vue +98 -0
  218. package/src/modules/wallet/views/components/blocks/CryptoDepositProcessing.vue +144 -0
  219. package/src/modules/wallet/views/components/elements/ConnectMetamask.vue +131 -0
  220. package/src/modules/wallet/views/components/pages/Wallet.vue +95 -68
  221. package/src/modules/wallet/views/localization/wallet.json +37 -0
  222. package/src/modules/wallet/views/store/wallet.store.js +145 -28
  223. package/src/modules/wallet/wallet.server.js +2 -2
  224. package/src/modules/wallet/components/blocks/CryptoDeposite.vue +0 -55
  225. package/src/modules/wallet/controllers/factories/rewards.factory.aggr.js +0 -181
  226. package/src/modules/wallet/controllers/factories/rewards.factory.population.js +0 -213
  227. package/src/modules/wallet/localization/Wallet.json +0 -22
  228. /package/src/modules/wallet/{components/blocks/CashDeposite.vue → views/components/blocks/CashDeposit.vue} +0 -0
@@ -1,5 +1,5 @@
1
1
  import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-CUmg6egw.mjs";
2
- import { s as server } from "./index-DKtnWDNC.mjs";
2
+ import { s as server } from "./index-C-8xOJnM.mjs";
3
3
  import "axios";
4
4
  import "bcryptjs";
5
5
  import "crypto";
@@ -20,11 +20,13 @@ var wallet_model = (db) => {
20
20
  },
21
21
  required: true
22
22
  },
23
- amount: {
24
- type: Number,
25
- required: true,
26
- default: 0
27
- }
23
+ balances: [{
24
+ name: String,
25
+ // Name of currency
26
+ amount: Number,
27
+ // Amount
28
+ locked_amount: Number
29
+ }]
28
30
  },
29
31
  {
30
32
  timestamps: {
@@ -318,6 +320,9 @@ var payments_routes = function(app, db, origins, publicPath) {
318
320
  };
319
321
  const ObjectId = require$$0.Types.ObjectId;
320
322
  const { BigNumber } = require$$1$1;
323
+ BigNumber.config({
324
+ EXPONENTIAL_AT: [-1e3, 2e3]
325
+ });
321
326
  const VIEWS_REWARD_COEFF = "0.1";
322
327
  const WDT_DECIMALS = 8;
323
328
  const calculateRewardForPost = (snapshot, viewsCount, reactionsCount, commentsCount) => {
@@ -327,11 +332,21 @@ const calculateRewardForPost = (snapshot, viewsCount, reactionsCount, commentsCo
327
332
  }
328
333
  return new BigNumber("10").plus(new BigNumber(viewsCount).multipliedBy(VIEWS_REWARD_COEFF)).plus(reactionsCount).plus(commentsCount);
329
334
  };
330
- const rewardsControllerFactory$1 = (db, wdmClient) => {
335
+ const rewardsControllerFactory$1 = (db, wdmClient, wss) => {
331
336
  const Blogpost = db.blogpost;
332
337
  const Reaction = db.reaction;
333
338
  const Comment = db.comment;
334
339
  const Reward = db.reward;
340
+ const Wallet = db.wallet;
341
+ const lookup = {};
342
+ wss.on("connection", (ws, req) => {
343
+ if (req.userId) {
344
+ lookup[req.userId] = ws;
345
+ ws.on("close", () => {
346
+ delete lookup[req.userId];
347
+ });
348
+ }
349
+ });
335
350
  const listRewards = async (req, res) => {
336
351
  const userId = new ObjectId(req.userId);
337
352
  try {
@@ -450,14 +465,69 @@ const rewardsControllerFactory$1 = (db, wdmClient) => {
450
465
  }
451
466
  res.status(200).send();
452
467
  };
453
- return { listRewards, collectTokens };
468
+ const requestDeposit = async (req, res) => {
469
+ const response = await wdmClient.createDepositRequest(
470
+ req.body.network,
471
+ req.body.amount,
472
+ req.body.token,
473
+ req.userId
474
+ );
475
+ res.status(200).send(response.data);
476
+ };
477
+ const cancelDeposit = async (req, res) => {
478
+ const response = await wdmClient.cancelDeposit(
479
+ req.body.id,
480
+ req.userId
481
+ );
482
+ res.status(200).send(response.data);
483
+ };
484
+ const getDepositConfig = async (req, res) => {
485
+ const response = await wdmClient.getDepositConfig();
486
+ res.status(200).send(response.data);
487
+ };
488
+ const handleDepositUpdate = async (req, res) => {
489
+ if (req.body.status === "TRANSFER_STATUS_COMPLETED") {
490
+ const userWallet = await Wallet.findOne({ owner: new ObjectId(req.body.user) });
491
+ const amount = new BigNumber(req.body.amount).shiftedBy(-WDT_DECIMALS).dividedBy(process.env.TOKEN_EXCHANGE_RATE).toString();
492
+ if (userWallet) {
493
+ const topupIndex = userWallet.balances.findIndex((b) => b.name === "WDT");
494
+ if (topupIndex < 0) {
495
+ userWallet.balances.push({ name: "WDT", amount: +amount, locked_amount: 0 });
496
+ } else {
497
+ userWallet.balances[topupIndex] = {
498
+ name: "WDT",
499
+ amount: userWallet.balances[topupIndex].amount + +amount,
500
+ locked_amount: userWallet.balances[topupIndex].locked_amount
501
+ };
502
+ }
503
+ await userWallet.save();
504
+ } else {
505
+ await Wallet.create({
506
+ owner: new ObjectId(req.body.user),
507
+ balances: [{ name: "WDT", amount: +amount, locked_amount: 0 }]
508
+ });
509
+ }
510
+ }
511
+ if (lookup[req.body.user]) {
512
+ lookup[req.body.user].send(JSON.stringify(req.body));
513
+ }
514
+ res.status(200).send();
515
+ };
516
+ return {
517
+ listRewards,
518
+ collectTokens,
519
+ requestDeposit,
520
+ getDepositConfig,
521
+ cancelDeposit,
522
+ handleDepositUpdate
523
+ };
454
524
  };
455
525
  var rewards_factory = rewardsControllerFactory$1;
456
526
  const rewardsControllerFactory = rewards_factory;
457
527
  const middlewareFactory = server;
458
- var rewards_routes = (app, db, wdmClient, origins) => {
459
- const controller = rewardsControllerFactory(db, wdmClient);
460
- const { authJwt } = middlewareFactory(db);
528
+ var rewards_routes = (app, db, wss, wdmClient, origins) => {
529
+ const controller = rewardsControllerFactory(db, wdmClient, wss);
530
+ const { authJwt, authSecret } = middlewareFactory(db);
461
531
  app.use((req, res, next) => {
462
532
  const origin = req.headers.origin;
463
533
  if (origins.includes(origin)) {
@@ -476,6 +546,26 @@ var rewards_routes = (app, db, wdmClient, origins) => {
476
546
  [authJwt.verifyToken],
477
547
  controller.collectTokens
478
548
  );
549
+ app.post(
550
+ "/api/crypto/deposit",
551
+ [authJwt.verifyToken],
552
+ controller.requestDeposit
553
+ );
554
+ app.post(
555
+ "/api/crypto/deposit/cancel",
556
+ [authJwt.verifyToken],
557
+ controller.cancelDeposit
558
+ );
559
+ app.post(
560
+ "/api/crypto/deposit/update",
561
+ [authSecret.verifySecret("POST", "/api/crypto/deposit/update", process.env.WDM_SECRET)],
562
+ controller.handleDepositUpdate
563
+ );
564
+ app.get(
565
+ "/api/crypto/deposit/config",
566
+ [],
567
+ controller.getDepositConfig
568
+ );
479
569
  };
480
570
  const ModelWallet = wallet_model;
481
571
  const ModelPayment = payment_model;
@@ -483,13 +573,13 @@ const ModelReward = reward_model;
483
573
  const RoutesPayments = payments_routes;
484
574
  const RoutesRewards = rewards_routes;
485
575
  const FactoryPayments = payments_factory;
486
- function initializePayments(app, db, wdmClient, origins, publicPath) {
576
+ function initializePayments(app, db, wss, wdmClient, origins, publicPath) {
487
577
  db.wallet = ModelWallet(db);
488
578
  db.payment = ModelPayment(db);
489
579
  db.reward = ModelReward(db);
490
580
  if (app) {
491
581
  RoutesPayments(app, db, origins, publicPath);
492
- RoutesRewards(app, db, wdmClient, origins);
582
+ RoutesRewards(app, db, wss, wdmClient, origins);
493
583
  }
494
584
  }
495
585
  var wallet_server = {
@@ -0,0 +1,54 @@
1
+ import { W as p } from "./main-BY2OvGB9.mjs";
2
+ class f extends p {
3
+ constructor() {
4
+ super(...arguments), this.group = "CapacitorStorage";
5
+ }
6
+ async configure({ group: e }) {
7
+ typeof e == "string" && (this.group = e);
8
+ }
9
+ async get(e) {
10
+ return { value: this.impl.getItem(this.applyPrefix(e.key)) };
11
+ }
12
+ async set(e) {
13
+ this.impl.setItem(this.applyPrefix(e.key), e.value);
14
+ }
15
+ async remove(e) {
16
+ this.impl.removeItem(this.applyPrefix(e.key));
17
+ }
18
+ async keys() {
19
+ return { keys: this.rawKeys().map((t) => t.substring(this.prefix.length)) };
20
+ }
21
+ async clear() {
22
+ for (const e of this.rawKeys())
23
+ this.impl.removeItem(e);
24
+ }
25
+ async migrate() {
26
+ var e;
27
+ const t = [], s = [], n = "_cap_", o = Object.keys(this.impl).filter((i) => i.indexOf(n) === 0);
28
+ for (const i of o) {
29
+ const r = i.substring(n.length), a = (e = this.impl.getItem(i)) !== null && e !== void 0 ? e : "", { value: l } = await this.get({ key: r });
30
+ typeof l == "string" ? s.push(r) : (await this.set({ key: r, value: a }), t.push(r));
31
+ }
32
+ return { migrated: t, existing: s };
33
+ }
34
+ async removeOld() {
35
+ const e = "_cap_", t = Object.keys(this.impl).filter((s) => s.indexOf(e) === 0);
36
+ for (const s of t)
37
+ this.impl.removeItem(s);
38
+ }
39
+ get impl() {
40
+ return window.localStorage;
41
+ }
42
+ get prefix() {
43
+ return this.group === "NativeStorage" ? "" : `${this.group}.`;
44
+ }
45
+ rawKeys() {
46
+ return Object.keys(this.impl).filter((e) => e.indexOf(this.prefix) === 0);
47
+ }
48
+ applyPrefix(e) {
49
+ return this.prefix + e;
50
+ }
51
+ }
52
+ export {
53
+ f as PreferencesWeb
54
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./main-5IrI2IOV.js");class p extends c.WebPlugin{constructor(){super(...arguments),this.group="CapacitorStorage"}async configure({group:e}){typeof e=="string"&&(this.group=e)}async get(e){return{value:this.impl.getItem(this.applyPrefix(e.key))}}async set(e){this.impl.setItem(this.applyPrefix(e.key),e.value)}async remove(e){this.impl.removeItem(this.applyPrefix(e.key))}async keys(){return{keys:this.rawKeys().map(t=>t.substring(this.prefix.length))}}async clear(){for(const e of this.rawKeys())this.impl.removeItem(e)}async migrate(){var e;const t=[],s=[],n="_cap_",o=Object.keys(this.impl).filter(i=>i.indexOf(n)===0);for(const i of o){const r=i.substring(n.length),a=(e=this.impl.getItem(i))!==null&&e!==void 0?e:"",{value:l}=await this.get({key:r});typeof l=="string"?s.push(r):(await this.set({key:r,value:a}),t.push(r))}return{migrated:t,existing:s}}async removeOld(){const e="_cap_",t=Object.keys(this.impl).filter(s=>s.indexOf(e)===0);for(const s of t)this.impl.removeItem(s)}get impl(){return window.localStorage}get prefix(){return this.group==="NativeStorage"?"":`${this.group}.`}rawKeys(){return Object.keys(this.impl).filter(e=>e.indexOf(this.prefix)===0)}applyPrefix(e){return this.prefix+e}}exports.PreferencesWeb=p;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ozdao/prometheus-framework",
3
- "version": "0.2.132",
3
+ "version": "0.2.134",
4
4
  "description": "Web3 Framework focused on user experience and ease of development.",
5
5
  "author": "OZ DAO <hello@ozdao.dev>",
6
6
  "license": "GPL-3.0-or-later",
@@ -88,7 +88,7 @@
88
88
  </transition>
89
89
  </template>
90
90
 
91
- <style lang="scss" scoped>
91
+ <style lang="scss" >
92
92
  input, textarea, span {
93
93
  line-height: 1;
94
94
  color: inherit;
@@ -23,7 +23,7 @@
23
23
  v-slot="{
24
24
  items
25
25
  }"
26
- class="mobile:w-50 desktop:w-100 tablet:w-75 row-1 gap-thin"
26
+ class="row-1 gap-thin"
27
27
  >
28
28
  <CardBlogpost
29
29
  v-for="item in items"
@@ -172,7 +172,7 @@
172
172
  </Button>
173
173
 
174
174
 
175
- <!-- <Select
175
+ <Select
176
176
  v-model:select="$i18n.locale"
177
177
  :options="[{name: '🌎&nbsp;En', value: 'en'}, {name: '🇷🇺&nbsp;Ru', value: 'ru'}]"
178
178
  :property="'value'"
@@ -181,7 +181,7 @@
181
181
  'bg-light t-black': theme === 'light',
182
182
  'bg-dark t-white': theme === 'dark'
183
183
  }"
184
- /> -->
184
+ />
185
185
  </header>
186
186
  </template>
187
187
 
@@ -20,11 +20,11 @@ const i18n = createI18n({
20
20
  locale: 'en',
21
21
  fallbackLocale: {
22
22
  'en': ['en-default'],
23
- 'ru': ['ru-default'],
24
- 'zh': ['zh-default'],
25
- 'fr': ['fr-default'],
26
- 'de': ['de-default'],
27
- 'it': ['it-default'],
23
+ 'ru': ['ru-default', 'en-default'],
24
+ 'zh': ['zh-default', 'en-default'],
25
+ 'fr': ['fr-default', 'en-default'],
26
+ 'de': ['de-default', 'en-default'],
27
+ 'it': ['it-default', 'en-default'],
28
28
  },
29
29
  legacy: false,
30
30
  globalInjection: true,
@@ -41,9 +41,8 @@
41
41
 
42
42
  <script setup>
43
43
  import { useI18n } from 'vue-i18n';
44
- import ConnectMetamask from '@/components/elements/ConnectMetamask.vue'
45
- import ButtonAddWDT from '@/components/elements/ButtonAddWDT.vue'
46
- import ButtonSwitchToPolygon from '@/components/elements/ButtonSwitchToPolygon.vue'
44
+
45
+ import ConnectMetamask from '@pf/src/modules/wallet/views/components/elements/ConnectMetamask.vue'
47
46
 
48
47
  const text = {
49
48
  messages: {
@@ -48,14 +48,9 @@ import { useI18n } from 'vue-i18n';
48
48
  import Shader from '@pf/src/components/Shader/Shader.vue'
49
49
 
50
50
  import IconEarn from '@pf/src/modules/icons/entities/IconEarn.vue'
51
-
52
51
  import IconInfo from '@pf/src/modules/icons/navigation/IconInfo.vue'
53
52
 
54
-
55
- import ConnectMetamask from '@/components/elements/ConnectMetamask.vue'
56
-
57
- import ButtonAddWDT from '@/components/elements/ButtonAddWDT.vue'
58
- import ButtonSwitchToPolygon from '@/components/elements/ButtonSwitchToPolygon.vue'
53
+ import ConnectMetamask from '@pf/src/modules/wallet/views/components/elements/ConnectMetamask.vue'
59
54
 
60
55
  const props = defineProps({
61
56
  mockupImage: {
@@ -0,0 +1,22 @@
1
+ const crypto = require('crypto');
2
+
3
+ const middlewareFactory = () => {
4
+ const verifySecret = (method, endpoint, secret) => async (req, res, next) => {
5
+ const requestSignature = req.headers.signature;
6
+
7
+ const signature = crypto
8
+ .createHmac('sha256', secret)
9
+ .update(method + endpoint)
10
+ .digest('hex');
11
+
12
+ if (signature === requestSignature) {
13
+ return next();
14
+ }
15
+
16
+ res.status(403).send('Forbidden');
17
+ };
18
+
19
+ return { verifySecret };
20
+ };
21
+
22
+ module.exports = middlewareFactory;
@@ -1,14 +1,16 @@
1
1
  // middlewareIndexFactory.js
2
2
 
3
3
  const middlewareIndexFactory = (db) => {
4
- const authJwt = require("./authJwt")(db);;
5
- const verifySignUp = require("./verifySignUp")(db);;
6
- const verifyUser = require("./verifyUser")(db);;
7
- const verifyInvites = require("./verifyInvites")(db);;
8
- const verifyCategory = require("./verifyCategory")(db);;
4
+ const authJwt = require("./authJwt")(db);
5
+ const authSecret = require("./authSecret")();
6
+ const verifySignUp = require("./verifySignUp")(db);
7
+ const verifyUser = require("./verifyUser")(db);
8
+ const verifyInvites = require("./verifyInvites")(db);
9
+ const verifyCategory = require("./verifyCategory")(db);
9
10
 
10
11
  return {
11
12
  authJwt,
13
+ authSecret,
12
14
  verifySignUp,
13
15
  verifyUser,
14
16
  verifyInvites,
@@ -3,6 +3,10 @@ const { BigNumber } = require('bignumber.js');
3
3
 
4
4
  const queryProcessorGlobals = require('@pf/src/modules/globals/controllers/utils/queryProcessor');
5
5
 
6
+ BigNumber.config({
7
+ EXPONENTIAL_AT: [-1000, 2000],
8
+ });
9
+
6
10
  const VIEWS_REWARD_COEFF = '0.1';
7
11
  const WDT_DECIMALS = 8;
8
12
 
@@ -23,13 +27,24 @@ const calculateRewardForPost = (snapshot, viewsCount, reactionsCount, commentsCo
23
27
  .plus(commentsCount);
24
28
  };
25
29
 
26
- const rewardsControllerFactory = (db, wdmClient) => {
30
+ const rewardsControllerFactory = (db, wdmClient, wss) => {
27
31
  const Blogpost = db.blogpost;
28
32
  const Reaction = db.reaction;
29
33
  const Comment = db.comment;
30
34
  const Reward = db.reward;
35
+ const Wallet = db.wallet;
36
+
37
+ const lookup = {};
31
38
 
39
+ wss.on('connection', (ws, req) => {
40
+ if (req.userId) {
41
+ lookup[req.userId] = ws;
32
42
 
43
+ ws.on('close', () => {
44
+ delete lookup[req.userId];
45
+ });
46
+ }
47
+ });
33
48
 
34
49
  const listRewards = async (req, res) => {
35
50
 
@@ -176,7 +191,77 @@ const rewardsControllerFactory = (db, wdmClient) => {
176
191
  res.status(200).send();
177
192
  };
178
193
 
179
- return { listRewards, collectTokens };
194
+ const requestDeposit = async (req, res) => {
195
+ const response = await wdmClient.createDepositRequest(
196
+ req.body.network,
197
+ req.body.amount,
198
+ req.body.token,
199
+ req.userId
200
+ );
201
+
202
+ res.status(200).send(response.data);
203
+ };
204
+
205
+ const cancelDeposit = async (req, res) => {
206
+ const response = await wdmClient.cancelDeposit(
207
+ req.body.id,
208
+ req.userId
209
+ );
210
+
211
+ res.status(200).send(response.data);
212
+ };
213
+
214
+ const getDepositConfig = async (req, res) => {
215
+ const response = await wdmClient.getDepositConfig();
216
+
217
+ res.status(200).send(response.data);
218
+ };
219
+
220
+ const handleDepositUpdate = async (req, res) => {
221
+ if (req.body.status === "TRANSFER_STATUS_COMPLETED") {
222
+ const userWallet = await Wallet.findOne({ owner: new ObjectId(req.body.user) });
223
+ const amount = new BigNumber(req.body.amount)
224
+ .shiftedBy(-WDT_DECIMALS)
225
+ .dividedBy(process.env.TOKEN_EXCHANGE_RATE)
226
+ .toString();
227
+
228
+ if (userWallet) {
229
+ const topupIndex = userWallet.balances.findIndex((b) => b.name === 'WDT');
230
+
231
+ if (topupIndex < 0) {
232
+ userWallet.balances.push({ name: 'WDT', amount: +amount, locked_amount: 0 });
233
+ } else {
234
+ userWallet.balances[topupIndex] = {
235
+ name: 'WDT',
236
+ amount: userWallet.balances[topupIndex].amount + +amount,
237
+ locked_amount: userWallet.balances[topupIndex].locked_amount
238
+ };
239
+ }
240
+
241
+ await userWallet.save();
242
+ } else {
243
+ await Wallet.create({
244
+ owner: new ObjectId(req.body.user),
245
+ balances: [{ name: 'WDT', amount: +amount, locked_amount: 0 }],
246
+ });
247
+ }
248
+ }
249
+
250
+ if (lookup[req.body.user]) {
251
+ lookup[req.body.user].send(JSON.stringify(req.body));
252
+ }
253
+
254
+ res.status(200).send();
255
+ }
256
+
257
+ return {
258
+ listRewards,
259
+ collectTokens,
260
+ requestDeposit,
261
+ getDepositConfig,
262
+ cancelDeposit,
263
+ handleDepositUpdate
264
+ };
180
265
  };
181
266
 
182
267
  module.exports = rewardsControllerFactory;
@@ -5,10 +5,10 @@ const rewardsControllerFactory = require('../factories/rewards.factory');
5
5
  const middlewareFactory = require('@pf/src/modules/middlewares/server');
6
6
 
7
7
  // Routes
8
- module.exports = (app, db, wdmClient, origins) => {
9
- const controller = rewardsControllerFactory(db, wdmClient);
8
+ module.exports = (app, db, wss, wdmClient, origins) => {
9
+ const controller = rewardsControllerFactory(db, wdmClient, wss);
10
10
 
11
- const { authJwt } = middlewareFactory(db);
11
+ const { authJwt, authSecret } = middlewareFactory(db);
12
12
 
13
13
  app.use((req, res, next) => {
14
14
  const origin = req.headers.origin;
@@ -33,4 +33,28 @@ module.exports = (app, db, wdmClient, origins) => {
33
33
  [authJwt.verifyToken],
34
34
  controller.collectTokens
35
35
  );
36
+
37
+ app.post(
38
+ "/api/crypto/deposit",
39
+ [authJwt.verifyToken],
40
+ controller.requestDeposit
41
+ );
42
+
43
+ app.post(
44
+ "/api/crypto/deposit/cancel",
45
+ [authJwt.verifyToken],
46
+ controller.cancelDeposit
47
+ );
48
+
49
+ app.post(
50
+ "/api/crypto/deposit/update",
51
+ [authSecret.verifySecret('POST', '/api/crypto/deposit/update', process.env.WDM_SECRET)],
52
+ controller.handleDepositUpdate
53
+ );
54
+
55
+ app.get(
56
+ "/api/crypto/deposit/config",
57
+ [],
58
+ controller.getDepositConfig
59
+ )
36
60
  };
@@ -9,11 +9,11 @@ module.exports = (db) => {
9
9
  },
10
10
  required: true,
11
11
  },
12
- amount: {
13
- type: Number,
14
- required: true,
15
- default: 0
16
- },
12
+ balances: [{
13
+ name: String, // Name of currency
14
+ amount: Number, // Amount
15
+ locked_amount: Number,
16
+ }]
17
17
  },
18
18
  {
19
19
  timestamps: {
@@ -1,27 +1,30 @@
1
1
  <template>
2
- <h2 class="mn-b-small t-center t-bold">{{ t('balanceReplenished') }}</h2>
2
+ <h2 class="mn-b-small t-center t-bold">{{ t('wallet.balanceReplenished') }}</h2>
3
3
 
4
4
  <div class="radius-medium br-1px br-black br-solid pd-big flex flex-column flex-justify-center flex-items-center">
5
5
  <h3 class="t-semi">
6
- {{ t('youReceived') }}
6
+ {{ t('wallet.youReceived') }}
7
7
  </h3>
8
8
  <h3 class="t-semi">
9
- 500 WDT
9
+ {{ receiveAmount }} WDT
10
10
  </h3>
11
-
12
11
  </div>
13
12
 
14
13
  <button
15
14
  class="uppercase w-100 bg-main t-black pd-thin radius-medium t-center br-solid br-2px br-black-transp-10 mn-t-small"
16
15
  @click="close"
17
16
  >
18
- {{ t('backToWallet') }}
17
+ {{ t('wallet.backToWallet') }}
19
18
  </button>
20
19
  </template>
21
20
 
22
21
  <script setup>
23
- import text from '@pf/src/modules/wallet/localization/Wallet.json'
24
22
  import { useI18n } from 'vue-i18n'
23
+ import { computed } from 'vue'
24
+ import { BigNumber } from 'bignumber.js'
25
+
26
+ import text from '@pf/src/modules/wallet/views/localization/wallet.json'
27
+ import { state } from '@pf/src/modules/wallet/views/store/wallet.store';
25
28
 
26
29
  const emits = defineEmits(['close'])
27
30
 
@@ -31,10 +34,17 @@
31
34
  ...text
32
35
  })
33
36
 
37
+ const receiveAmount = computed(() =>
38
+ new BigNumber(state.depositInfo.amount)
39
+ .shiftedBy(-8)
40
+ .dividedBy(process.env.TOKEN_EXCHANGE_RATE)
41
+ .toString()
42
+ )
43
+
34
44
  function close() {
35
45
  emits("close")
36
46
  }
37
47
  </script>
38
48
 
39
49
  <style scoped>
40
- </style>
50
+ </style>
@@ -3,7 +3,7 @@
3
3
 
4
4
  <div class="bg-grey radius-big mn-t-semi mn-b-semi flex flex-justify-between">
5
5
  <Field
6
- :placeholder="t('enterAmount')"
6
+ :placeholder="t('wallet.enterAmount')"
7
7
  class="pd-medium radius-small"
8
8
  />
9
9
 
@@ -18,19 +18,19 @@
18
18
  class="uppercase w-100 bg-main t-black pd-thin radius-medium t-center br-solid br-2px br-black-transp-10 mn-t-small"
19
19
  @click="switchMenu(3)"
20
20
  >
21
- {{ t('pay') }}
21
+ {{ t('wallet.pay') }}
22
22
  </button>
23
23
 
24
24
  <button
25
25
  class="uppercase w-100 bg-main t-black pd-thin radius-medium t-center br-solid br-2px br-black-transp-10 mn-t-small"
26
26
  @click="backSelection"
27
27
  >
28
- {{ t('backToSelection') }}
28
+ {{ t('wallet.backToSelection') }}
29
29
  </button>
30
30
  </template>
31
31
 
32
32
  <script setup>
33
- import text from '@pf/src/modules/wallet/localization/Wallet.json'
33
+ import text from '@pf/src/modules/wallet/views/localization/wallet.json'
34
34
  import Field from '@pf/src/components/Field/Field.vue'
35
35
  import { useI18n } from 'vue-i18n'
36
36