From 6f14711fe4d87e33e5a158060032e0e9f7dce01b Mon Sep 17 00:00:00 2001 From: Jared Date: Sun, 29 Jan 2023 02:15:23 -0500 Subject: [PATCH] Change some data types, introduce infrastructure to send payments to contributors --- package-lock.json | 87 +- package.json | 1 + src/api/composed.ts | 8 + src/api/types.ts | 11 +- src/lib/helpers.ts | 13 +- src/views/AddFundView.vue | 27 +- src/views/AdminDashboardView.vue | 11 +- src/views/FundView.vue | 246 +- yarn.lock | 13252 +++++++++++++++-------------- 9 files changed, 6992 insertions(+), 6664 deletions(-) diff --git a/package-lock.json b/package-lock.json index 919ed1f..7b6d659 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,10 +12,14 @@ "@vueuse/core": "^9.5.0", "bulma": "^0.9.4", "core-js": "^3.8.3", + "decimal.js": "^10.4.3", "jenesius-vue-modal": "^1.8.2", + "jwt-decode": "^3.1.2", "luxon": "^3.1.0", "vue": "^3.2.13", + "vue-draggable-next": "^2.1.1", "vue-router": "^4.0.3", + "vuedraggable": "^4.1.0", "vuex": "^4.0.0" }, "devDependencies": { @@ -5609,11 +5613,9 @@ } }, "node_modules/decimal.js": { - "version": "10.4.2", - "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.2.tgz", - "integrity": "sha512-ic1yEvwT6GuvaYwBLLY6/aFFgjZdySKTE8en/fkU3QICTmRtgtSlFn0u0BXN06InZwtfCelR7j8LRiDI/02iGA==", - "dev": true, - "license": "MIT" + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", + "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==" }, "node_modules/decode-uri-component": { "version": "0.2.0", @@ -8922,6 +8924,11 @@ "graceful-fs": "^4.1.6" } }, + "node_modules/jwt-decode": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-3.1.2.tgz", + "integrity": "sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A==" + }, "node_modules/kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", @@ -12671,6 +12678,12 @@ "websocket-driver": "^0.7.4" } }, + "node_modules/sortablejs": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.15.0.tgz", + "integrity": "sha512-bv9qgVMjUMf89wAvM6AxVvS/4MX3sPeN0+agqShejLU5z5GX4C75ow1O2e5k4L6XItUyAK3gH6AxSbXrOM5e8w==", + "peer": true + }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -13847,6 +13860,15 @@ } } }, + "node_modules/vue-draggable-next": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/vue-draggable-next/-/vue-draggable-next-2.1.1.tgz", + "integrity": "sha512-f5lmA7t6LMaL4viR7dU30zzvqJzaKQs0ymL0Jy9UDT9uiZ2tXF3MzPzEvpTH2UODXZJkT+SnjeV1fXHMsgXLYA==", + "peerDependencies": { + "sortablejs": "^1.14.0", + "vue": "^3.2.2" + } + }, "node_modules/vue-eslint-parser": { "version": "8.3.0", "resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-8.3.0.tgz", @@ -14002,6 +14024,22 @@ "dev": true, "license": "MIT" }, + "node_modules/vuedraggable": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/vuedraggable/-/vuedraggable-4.1.0.tgz", + "integrity": "sha512-FU5HCWBmsf20GpP3eudURW3WdWTKIbEIQxh9/8GE806hydR9qZqRRxRE3RjqX7PkuLuMQG/A7n3cfj9rCEchww==", + "dependencies": { + "sortablejs": "1.14.0" + }, + "peerDependencies": { + "vue": "^3.0.1" + } + }, + "node_modules/vuedraggable/node_modules/sortablejs": { + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.14.0.tgz", + "integrity": "sha512-pBXvQCs5/33fdN1/39pPL0NZF20LeRbLQ5jtnheIPN9JQAaufGjKdWduZn4U7wCtVuzKhmRkI0DFYHYRbB2H1w==" + }, "node_modules/vuex": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/vuex/-/vuex-4.1.0.tgz", @@ -18648,10 +18686,9 @@ "dev": true }, "decimal.js": { - "version": "10.4.2", - "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.2.tgz", - "integrity": "sha512-ic1yEvwT6GuvaYwBLLY6/aFFgjZdySKTE8en/fkU3QICTmRtgtSlFn0u0BXN06InZwtfCelR7j8LRiDI/02iGA==", - "dev": true + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", + "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==" }, "decode-uri-component": { "version": "0.2.0", @@ -20934,6 +20971,11 @@ "universalify": "^2.0.0" } }, + "jwt-decode": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-3.1.2.tgz", + "integrity": "sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A==" + }, "kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", @@ -23530,6 +23572,12 @@ "websocket-driver": "^0.7.4" } }, + "sortablejs": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.15.0.tgz", + "integrity": "sha512-bv9qgVMjUMf89wAvM6AxVvS/4MX3sPeN0+agqShejLU5z5GX4C75ow1O2e5k4L6XItUyAK3gH6AxSbXrOM5e8w==", + "peer": true + }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -24339,6 +24387,12 @@ "integrity": "sha512-IR8HoEEGM65YY3ZJYAjMlKygDQn25D5ajNFNoKh9RSDMQtlzCxtfQjdQgv9jjK+m3377SsJXY8ysq8kLCZL25A==", "requires": {} }, + "vue-draggable-next": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/vue-draggable-next/-/vue-draggable-next-2.1.1.tgz", + "integrity": "sha512-f5lmA7t6LMaL4viR7dU30zzvqJzaKQs0ymL0Jy9UDT9uiZ2tXF3MzPzEvpTH2UODXZJkT+SnjeV1fXHMsgXLYA==", + "requires": {} + }, "vue-eslint-parser": { "version": "8.3.0", "resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-8.3.0.tgz", @@ -24443,6 +24497,21 @@ "integrity": "sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==", "dev": true }, + "vuedraggable": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/vuedraggable/-/vuedraggable-4.1.0.tgz", + "integrity": "sha512-FU5HCWBmsf20GpP3eudURW3WdWTKIbEIQxh9/8GE806hydR9qZqRRxRE3RjqX7PkuLuMQG/A7n3cfj9rCEchww==", + "requires": { + "sortablejs": "1.14.0" + }, + "dependencies": { + "sortablejs": { + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.14.0.tgz", + "integrity": "sha512-pBXvQCs5/33fdN1/39pPL0NZF20LeRbLQ5jtnheIPN9JQAaufGjKdWduZn4U7wCtVuzKhmRkI0DFYHYRbB2H1w==" + } + } + }, "vuex": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/vuex/-/vuex-4.1.0.tgz", diff --git a/package.json b/package.json index 0500462..7d1e68a 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@vueuse/core": "^9.5.0", "bulma": "^0.9.4", "core-js": "^3.8.3", + "decimal.js": "^10.4.3", "jenesius-vue-modal": "^1.8.2", "jwt-decode": "^3.1.2", "luxon": "^3.1.0", diff --git a/src/api/composed.ts b/src/api/composed.ts index 3d8664c..700c459 100644 --- a/src/api/composed.ts +++ b/src/api/composed.ts @@ -23,6 +23,7 @@ import { NearlyCompleteFundsRequest, NearlyCompleteFundsResponse, QueueMember, + SubmitRewardFundRequest, SuccessResponse, } from '@/api/types'; @@ -49,6 +50,7 @@ export const createQueue = (name: string) => controller.post controller.post('CreateRewardFund', { asset, fundWallet, + fundSecret, sellingWallet, issuerWallet, memo, @@ -112,3 +115,8 @@ export const reorderQueue = (queueID: number, fundOrders: QueueMember[]) => cont queueID, fundOrders, }); + +export const submitRewardFund = (fundID: number, submit: boolean) => controller.post('SubmitRewardFund', { + fundID, + submit, +}); diff --git a/src/api/types.ts b/src/api/types.ts index cd25ab3..68b38b5 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -1,3 +1,6 @@ +// eslint-disable-next-line no-shadow +import Decimal from 'decimal.js'; + // eslint-disable-next-line no-shadow export enum Privileges { None = -1, @@ -8,7 +11,7 @@ export enum Privileges { export interface Contribution { createdAt: string; - amount: number; + amount: Decimal; rewardFundID: number; transactionID: string; wallet: string; @@ -71,6 +74,7 @@ export interface Bonus { export interface CreateRewardFundRequest { asset: string; fundWallet: string; + fundSecret: string; sellingWallet: string; issuerWallet: string; memo: string; @@ -188,3 +192,8 @@ export interface EditQueueRequest { queueID: number; fundOrders: QueueMember[]; } + +export interface SubmitRewardFundRequest { + fundID: number; + submit: boolean; +} diff --git a/src/lib/helpers.ts b/src/lib/helpers.ts index e841c51..06825af 100644 --- a/src/lib/helpers.ts +++ b/src/lib/helpers.ts @@ -1,4 +1,11 @@ -export const truncateWallet: (wallet: string, preDigits: number, postDigits: number | undefined) => string = (wallet: string, preDigits: number, postDigits = preDigits) => `${wallet.slice(0, preDigits)}...${wallet.slice(-(postDigits + 1), -1)}`; +export const truncateWallet: ( + wallet: string, + preDigits: number, + postDigits: number | undefined, +) => string = (wallet: string, preDigits: number, postDigits = preDigits) => { + const [med, mtd] = [Math.max(preDigits, 3), Math.max(postDigits, 3)]; + return `${wallet.slice(0, med)}...${wallet.slice(-(mtd + 1), -1)}`; +}; export const isNumber = (s: string) => /^[0-9]+$/.test(s); export const sanitize = (s: string) => { @@ -7,8 +14,8 @@ export const sanitize = (s: string) => { '<': '<', '>': '>', '"': '"', - "'": ''', + '\'': ''', '/': '/', - } as {[key: string]: string}; + } as { [key: string]: string }; return s.replace(/[&<>"'/]/ig, (match) => chars[match]); }; diff --git a/src/views/AddFundView.vue b/src/views/AddFundView.vue index efb5ee5..a78391e 100644 --- a/src/views/AddFundView.vue +++ b/src/views/AddFundView.vue @@ -6,12 +6,7 @@
Post
-
-
- + placeholder="Telegram Link" aria-label="Telegram Link" v-model="telegramLink">
@@ -20,6 +15,10 @@ +
+ +
@@ -68,7 +67,6 @@