From 6fe7e4c9a21a62e3671fea2347faa3ad30742c1c Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 24 Mar 2022 14:30:51 +0100 Subject: [PATCH 01/20] set max memo length to 255 --- frontend/src/components/GddSend/TransactionForm.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/GddSend/TransactionForm.vue b/frontend/src/components/GddSend/TransactionForm.vue index 8fc5d267c..022c5008a 100644 --- a/frontend/src/components/GddSend/TransactionForm.vue +++ b/frontend/src/components/GddSend/TransactionForm.vue @@ -102,7 +102,7 @@ :rules="{ required: true, min: 5, - max: 150, + max: 255, }" :name="$t('form.message')" v-slot="{ errors }" From 30543942d855719418c3c2cc24b2408228d31098 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 24 Mar 2022 14:36:16 +0100 Subject: [PATCH 02/20] check for valid min/max length of memeo before executing transaction --- backend/src/graphql/resolver/TransactionResolver.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index ed9528b48..0ff43486c 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -34,6 +34,9 @@ import { virtualLinkTransaction, virtualDecayTransaction } from '@/util/virtualT import Decimal from 'decimal.js-light' import { calculateDecay } from '@/util/decay' +const MEMO_MAX_CHARS = 255 +const MEMO_MIN_CHARS = 5 + export const executeTransaction = async ( amount: Decimal, memo: string, @@ -45,6 +48,14 @@ export const executeTransaction = async ( throw new Error('Sender and Recipient are the same.') } + if (memo.length > MEMO_MAX_CHARS) { + throw new Error(`memo text is too long (${MEMO_MAX_CHARS} characters maximum)`) + } + + if (memo.length < MEMO_MIN_CHARS) { + throw new Error(`memo text is too short (${MEMO_MIN_CHARS} characters minimum)`) + } + // validate amount const receivedCallDate = new Date() const sendBalance = await calculateBalance(sender.id, amount.mul(-1), receivedCallDate) From 92952f3d75aaeaeb7d6b8f34af87bfb5dc60e1a8 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 24 Mar 2022 14:54:25 +0100 Subject: [PATCH 03/20] test same email, test memo too long --- .../GddSend/TransactionForm.spec.js | 54 ++++++++++++++++--- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/GddSend/TransactionForm.spec.js b/frontend/src/components/GddSend/TransactionForm.spec.js index e4e3d54cf..e03a39a13 100644 --- a/frontend/src/components/GddSend/TransactionForm.spec.js +++ b/frontend/src/components/GddSend/TransactionForm.spec.js @@ -61,11 +61,8 @@ describe('TransactionForm', () => { }) }) - describe('is selected: "send"', () => { + describe('send GDD', () => { beforeEach(async () => { - // await wrapper.setData({ - // selected: 'send', - // }) await wrapper.findAll('input[type="radio"]').at(0).setChecked() }) @@ -73,15 +70,18 @@ describe('TransactionForm', () => { beforeEach(() => { wrapper.setProps({ balance: 100.0 }) }) + describe('transaction form show because balance 100,0 GDD', () => { it('has no warning message ', () => { expect(wrapper.find('.errors').exists()).toBeFalsy() }) + it('has a reset button', () => { expect(wrapper.find('.test-buttons').findAll('button').at(0).attributes('type')).toBe( 'reset', ) }) + it('has a submit button', () => { expect(wrapper.find('.test-buttons').findAll('button').at(1).attributes('type')).toBe( 'submit', @@ -116,6 +116,12 @@ describe('TransactionForm', () => { expect(wrapper.find('span.errors').text()).toBe('validations.messages.email') }) + it('flushes an error message when email is the email of logged in user', async () => { + await wrapper.find('#input-group-1').find('input').setValue('user@example.org') + await flushPromises() + expect(wrapper.find('span.errors').text()).toBe('form.validation.is-not') + }) + it('trims the email after blur', async () => { await wrapper.find('#input-group-1').find('input').setValue(' valid@email.com ') await wrapper.find('#input-group-1').find('input').trigger('blur') @@ -190,6 +196,41 @@ describe('TransactionForm', () => { expect(wrapper.find('span.errors').text()).toBe('validations.messages.min') }) + it('flushes an error message when memo is more than 255 characters', async () => { + await wrapper.find('#input-group-3').find('textarea').setValue(` +Es ist ein König in Thule, der trinkt +Champagner, es geht ihm nichts drüber; +Und wenn er seinen Champagner trinkt, +Dann gehen die Augen ihm über. + +Die Ritter sitzen um ihn her, +Die ganze Historische Schule; +Ihm aber wird die Zunge schwer, +Es lallt der König von Thule: + +„Als Alexander, der Griechenheld, +Mit seinem kleinen Haufen +Erobert hatte die ganze Welt, +Da gab er sich ans Saufen. + +Ihn hatten so durstig gemacht der Krieg +Und die Schlachten, die er geschlagen; +Er soff sich zu Tode nach dem Sieg, +Er konnte nicht viel vertragen. + +Ich aber bin ein stärkerer Mann +Und habe mich klüger besonnen: +Wie jener endete, fang ich an, +Ich hab mit dem Trinken begonnen. + +Im Rausche wird der Heldenzug +Mir später weit besser gelingen; +Dann werde ich, taumelnd von Krug zu Krug, +Die ganze Welt bezwingen.“`) + await flushPromises() + expect(wrapper.find('span.errors').text()).toBe('validations.messages.max') + }) + it('flushes no error message when memo is valid', async () => { await wrapper.find('#input-group-3').find('textarea').setValue('Long enough') await flushPromises() @@ -248,11 +289,8 @@ describe('TransactionForm', () => { }) }) - describe('is selected: "link"', () => { + describe('send link', () => { beforeEach(async () => { - // await wrapper.setData({ - // selected: 'link', - // }) await wrapper.findAll('input[type="radio"]').at(1).setChecked() }) From e4c7a8dddaf4c8dd250c76ff7fc6d79671cb72ef Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 24 Mar 2022 17:20:06 +0100 Subject: [PATCH 04/20] linting --- frontend/src/components/GddSend/TransactionForm.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/GddSend/TransactionForm.spec.js b/frontend/src/components/GddSend/TransactionForm.spec.js index e03a39a13..0e2675584 100644 --- a/frontend/src/components/GddSend/TransactionForm.spec.js +++ b/frontend/src/components/GddSend/TransactionForm.spec.js @@ -121,7 +121,7 @@ describe('TransactionForm', () => { await flushPromises() expect(wrapper.find('span.errors').text()).toBe('form.validation.is-not') }) - + it('trims the email after blur', async () => { await wrapper.find('#input-group-1').find('input').setValue(' valid@email.com ') await wrapper.find('#input-group-1').find('input').trigger('blur') From 62831a71df3faac4f0fe76e797dd32b707210e4f Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 25 Mar 2022 21:46:38 +0100 Subject: [PATCH 05/20] add transactionLinkId on query --- frontend/src/graphql/queries.js | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index 60b929c6d..e47da0fea 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -70,6 +70,7 @@ export const transactionsQuery = gql` linkedUser { email } + transactionLinkId } } } From 095dffc7e6c3219e7dcd1c136802d313484a61ea Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 25 Mar 2022 21:47:16 +0100 Subject: [PATCH 06/20] add locales redeemed-title --- frontend/src/locales/de.json | 1 + frontend/src/locales/en.json | 1 + 2 files changed, 2 insertions(+) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 35155ca79..e0b23583d 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -116,6 +116,7 @@ "redeem-text": "Willst du den Betrag jetzt einlösen?", "redeemed": "Erfolgreich eingelöst! Deinem Konto wurden {n} GDD gutgeschrieben.", "redeemed-at": "Der Link wurde bereits am {date} eingelöst.", + "redeemed-title": "eingelöst", "to-login": "Log dich ein", "to-register": "Registriere ein neues Konto" }, diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index af54f3b50..ede4c4f2e 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -116,6 +116,7 @@ "redeem-text": "Do you want to redeem the amount now?", "redeemed": "Successfully redeemed! Your account has been credited with {n} GDD.", "redeemed-at": "The link was already redeemed on {date}.", + "redeemed-title": "redeemed", "to-login": "Log in", "to-register": "Register a new account" }, From fe2d1caa108d951456e42a46496cd43c0cf5835b Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 25 Mar 2022 21:48:47 +0100 Subject: [PATCH 07/20] add icon if transactionLinkId on transaction --- frontend/src/components/TransactionRows/TypeIcon.vue | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/frontend/src/components/TransactionRows/TypeIcon.vue b/frontend/src/components/TransactionRows/TypeIcon.vue index ff8aa8647..24cede717 100644 --- a/frontend/src/components/TransactionRows/TypeIcon.vue +++ b/frontend/src/components/TransactionRows/TypeIcon.vue @@ -2,6 +2,13 @@
+
@@ -17,6 +24,11 @@ export default { type: String, required: true, }, + transactionLinkId: { + type: Number, + required: false, + default: null, + }, }, } From 5c099cd01fddc4ac32a55dd6673371c06cf4bbe8 Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 25 Mar 2022 21:49:35 +0100 Subject: [PATCH 08/20] add props transactionLinkId --- .../src/components/Transactions/TransactionReceive.vue | 10 +++++++++- .../src/components/Transactions/TransactionSend.vue | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Transactions/TransactionReceive.vue b/frontend/src/components/Transactions/TransactionReceive.vue index d1947a91a..3c9f3d0f8 100644 --- a/frontend/src/components/Transactions/TransactionReceive.vue +++ b/frontend/src/components/Transactions/TransactionReceive.vue @@ -8,7 +8,11 @@ - + @@ -86,6 +90,10 @@ export default { type: Date, required: true, }, + transactionLinkId: { + type: Number, + required: false, + }, }, data() { return { diff --git a/frontend/src/components/Transactions/TransactionSend.vue b/frontend/src/components/Transactions/TransactionSend.vue index dfe50225a..19616cbfb 100644 --- a/frontend/src/components/Transactions/TransactionSend.vue +++ b/frontend/src/components/Transactions/TransactionSend.vue @@ -8,7 +8,11 @@ - + @@ -87,6 +91,10 @@ export default { type: Date, required: true, }, + transactionLinkId: { + type: Number, + required: false, + }, }, data() { return { From 184b94891615b4932c38d41d0b982a78776a9294 Mon Sep 17 00:00:00 2001 From: ogerly Date: Sat, 26 Mar 2022 09:33:48 +0100 Subject: [PATCH 09/20] add locales via_link --- frontend/src/locales/de.json | 3 ++- frontend/src/locales/en.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index e0b23583d..7ca63fff4 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -250,5 +250,6 @@ }, "transaction-link": { "send_you": "sendet dir" - } + }, + "via_link":"über einen Link" } diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index ede4c4f2e..45c046389 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -250,5 +250,6 @@ }, "transaction-link": { "send_you": "wants to send you" - } + }, + "via_link":"via Link" } From bcfc60150b16f1f8e49fe8b88342a60f4bb87d26 Mon Sep 17 00:00:00 2001 From: ogerly Date: Sat, 26 Mar 2022 09:34:53 +0100 Subject: [PATCH 10/20] remove linkk icon if redeemed --- frontend/src/components/TransactionRows/TypeIcon.vue | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/frontend/src/components/TransactionRows/TypeIcon.vue b/frontend/src/components/TransactionRows/TypeIcon.vue index 24cede717..ff8aa8647 100644 --- a/frontend/src/components/TransactionRows/TypeIcon.vue +++ b/frontend/src/components/TransactionRows/TypeIcon.vue @@ -2,13 +2,6 @@
-
@@ -24,11 +17,6 @@ export default { type: String, required: true, }, - transactionLinkId: { - type: Number, - required: false, - default: null, - }, }, } From eecab9248d0df8326855cfa150046c01ab23a046 Mon Sep 17 00:00:00 2001 From: ogerly Date: Sat, 26 Mar 2022 09:35:29 +0100 Subject: [PATCH 11/20] add link icon and locales via_link if redeemed --- .../TransactionRows/AmountAndNameRow.vue | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/frontend/src/components/TransactionRows/AmountAndNameRow.vue b/frontend/src/components/TransactionRows/AmountAndNameRow.vue index be71b57f6..6ee6462ad 100644 --- a/frontend/src/components/TransactionRows/AmountAndNameRow.vue +++ b/frontend/src/components/TransactionRows/AmountAndNameRow.vue @@ -12,6 +12,15 @@
{{ itemText }} + + , {{ $t('via_link') }} + + {{ itemText }}
@@ -35,6 +44,11 @@ export default { type: String, required: false, }, + transactionLinkId: { + type: Number, + required: false, + default: null, + }, }, methods: { tunnelEmail() { From f9cc754ca0710e79568a8b873a7430baa6aed8b0 Mon Sep 17 00:00:00 2001 From: ogerly Date: Sat, 26 Mar 2022 09:36:35 +0100 Subject: [PATCH 12/20] add props transactionLinkId in TransactionReceive --- .../components/Transactions/TransactionReceive.vue | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/Transactions/TransactionReceive.vue b/frontend/src/components/Transactions/TransactionReceive.vue index 3c9f3d0f8..29fae11f4 100644 --- a/frontend/src/components/Transactions/TransactionReceive.vue +++ b/frontend/src/components/Transactions/TransactionReceive.vue @@ -8,16 +8,17 @@ - + - + From 871a8ed14d8a51fa9faed648a523f8a2a8463833 Mon Sep 17 00:00:00 2001 From: ogerly Date: Sat, 26 Mar 2022 09:36:48 +0100 Subject: [PATCH 13/20] add props transactionLinkId in TransactionSend --- .../src/components/Transactions/TransactionSend.vue | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/Transactions/TransactionSend.vue b/frontend/src/components/Transactions/TransactionSend.vue index 19616cbfb..ecc47dc43 100644 --- a/frontend/src/components/Transactions/TransactionSend.vue +++ b/frontend/src/components/Transactions/TransactionSend.vue @@ -8,16 +8,17 @@ - + - + From 543b389f8c62099ec7918bf6256cc66c53b88640 Mon Sep 17 00:00:00 2001 From: ogerly Date: Sat, 26 Mar 2022 09:39:14 +0100 Subject: [PATCH 14/20] add comma on via_link --- frontend/src/locales/de.json | 2 +- frontend/src/locales/en.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 7ca63fff4..8d9a7c9e1 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -251,5 +251,5 @@ "transaction-link": { "send_you": "sendet dir" }, - "via_link":"über einen Link" + "via_link": ", über einen Link" } diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 45c046389..ec94534fe 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -251,5 +251,5 @@ "transaction-link": { "send_you": "wants to send you" }, - "via_link":"via Link" + "via_link": ", via Link" } From 4909254a0237ef9b25006bdd927d5e755c31d9a7 Mon Sep 17 00:00:00 2001 From: ogerly Date: Sat, 26 Mar 2022 09:39:46 +0100 Subject: [PATCH 15/20] remove comma in text --- frontend/src/components/TransactionRows/AmountAndNameRow.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/TransactionRows/AmountAndNameRow.vue b/frontend/src/components/TransactionRows/AmountAndNameRow.vue index 6ee6462ad..c98154909 100644 --- a/frontend/src/components/TransactionRows/AmountAndNameRow.vue +++ b/frontend/src/components/TransactionRows/AmountAndNameRow.vue @@ -13,7 +13,7 @@ {{ itemText }} - , {{ $t('via_link') }} + {{ $t('via_link') }} Date: Sat, 26 Mar 2022 16:58:50 +0100 Subject: [PATCH 16/20] change, via_link text outer link --- .../src/components/TransactionRows/AmountAndNameRow.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/TransactionRows/AmountAndNameRow.vue b/frontend/src/components/TransactionRows/AmountAndNameRow.vue index c98154909..322ad7dfa 100644 --- a/frontend/src/components/TransactionRows/AmountAndNameRow.vue +++ b/frontend/src/components/TransactionRows/AmountAndNameRow.vue @@ -10,8 +10,10 @@
- - {{ itemText }} +
+ + {{ itemText }} + {{ $t('via_link') }} - +
{{ itemText }}
From 3f7d9e73b3f68f82e4818d0d397a201185c1834b Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Mon, 28 Mar 2022 13:45:11 +0200 Subject: [PATCH 17/20] remove comma from via link --- frontend/src/locales/de.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 8d9a7c9e1..81bc900e0 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -251,5 +251,5 @@ "transaction-link": { "send_you": "sendet dir" }, - "via_link": ", über einen Link" + "via_link": "über einen Link" } From 666f176b35afaa775c7d1f4f8fb3ec99bbca73ff Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Mon, 28 Mar 2022 13:46:34 +0200 Subject: [PATCH 18/20] remove comma from via link --- frontend/src/locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index ec94534fe..249664183 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -251,5 +251,5 @@ "transaction-link": { "send_you": "wants to send you" }, - "via_link": ", via Link" + "via_link": "via Link" } From 640923dd5065eb2c1810f353c84ffac3124e3db3 Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Mon, 28 Mar 2022 13:47:45 +0200 Subject: [PATCH 19/20] sorting properties --- frontend/src/components/Transactions/TransactionSend.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Transactions/TransactionSend.vue b/frontend/src/components/Transactions/TransactionSend.vue index ecc47dc43..2f9ef54d2 100644 --- a/frontend/src/components/Transactions/TransactionSend.vue +++ b/frontend/src/components/Transactions/TransactionSend.vue @@ -14,9 +14,9 @@ From 193e085439f2bcb10cd5d8cecd002a93ecceb7f8 Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Mon, 28 Mar 2022 13:51:24 +0200 Subject: [PATCH 20/20] sorting properties --- frontend/src/components/Transactions/TransactionReceive.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Transactions/TransactionReceive.vue b/frontend/src/components/Transactions/TransactionReceive.vue index 29fae11f4..f83c84e53 100644 --- a/frontend/src/components/Transactions/TransactionReceive.vue +++ b/frontend/src/components/Transactions/TransactionReceive.vue @@ -14,9 +14,9 @@