Skip to content
Snippets Groups Projects
Commit e9d905c4 authored by vjrj's avatar vjrj
Browse files

Better june:// amount/commnt urls @kimamila feedback

parent 4f0b3f7f
No related branches found
No related tags found
No related merge requests found
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
"online_terminal": "Online", "online_terminal": "Online",
"offline_terminal": "Offline", "offline_terminal": "Offline",
"show_qr_to_client": "Show your public key to your client", "show_qr_to_client": "Show your public key to your client",
"show_qr_to_client_amount": "Display this QR code with that amount to another Ğ1nkgo wallet", "show_qr_to_client_amount": "Display this QR code with that amount to your client",
"keys_tooltip": "Public and private keys in Ğ1 and Duniter are like a lock and key system, where the public key acts as the lock that can be opened by anyone with the corresponding private key, providing a secure way to authenticate and verify transactions", "keys_tooltip": "Public and private keys in Ğ1 and Duniter are like a lock and key system, where the public key acts as the lock that can be opened by anyone with the corresponding private key, providing a secure way to authenticate and verify transactions",
"card_validity": "Validity", "card_validity": "Validity",
"card_validity_tooltip": "Please note that this wallet is only accessible while using this specific browser or app and device. If you delete or reset the browser or app, you will lose access to this wallet and the funds stored in it.", "card_validity_tooltip": "Please note that this wallet is only accessible while using this specific browser or app and device. If you delete or reset the browser or app, you will lose access to this wallet and the funds stored in it.",
...@@ -157,7 +157,7 @@ ...@@ -157,7 +157,7 @@
"receiveMainKey_desc": "This works similarly to point of sale machines in stores, but instead of credit card payments, we use QR codes. Here you can generate QR codes for others to scan and make payments to you.", "receiveMainKey_desc": "This works similarly to point of sale machines in stores, but instead of credit card payments, we use QR codes. Here you can generate QR codes for others to scan and make payments to you.",
"receiveQrKey_desc": "On this screen you will find your own QR code that you can share with others to receive payments in Ğ1.", "receiveQrKey_desc": "On this screen you will find your own QR code that you can share with others to receive payments in Ğ1.",
"receiveAmountKey_title": "QR with Amounts", "receiveAmountKey_title": "QR with Amounts",
"receiveAmountKey_desc": "If you want to sell a product or service, you can generate a QR code with your public key and the amount to be charged in Ğ1. Please note that these QR codes only work between Ğ1nkgo wallets for now.", "receiveAmountKey_desc": "If you want to sell a product or service, you can generate a QR code with your public key and the amount to be charged in Ğ1.",
"receiveSumKey_title": "Quick Total", "receiveSumKey_title": "Quick Total",
"receiveSumKey_desc": "You can also generate a QR code with the total amount of a purchase by adding up the prices of the items you are selling.", "receiveSumKey_desc": "You can also generate a QR code with the total amount of a purchase by adding up the prices of the items you are selling.",
"contactsMainKey_title": "Contacts", "contactsMainKey_title": "Contacts",
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
"offline": "¡Estás desconectad@!", "offline": "¡Estás desconectad@!",
"online_terminal": "En línea", "online_terminal": "En línea",
"offline_terminal": "Fuera de línea", "offline_terminal": "Fuera de línea",
"show_qr_to_client": "Muestra su clave pública a su clientæ", "show_qr_to_client": "Muestra tu clave pública a tu clientæ",
"show_qr_to_client_amount": "Muestra este QR con esa cantidad a otro monedero Ğ1nkgo", "show_qr_to_client_amount": "Muestra este QR con esa cantidad a tu clientæ",
"keys_tooltip": "Las claves públicas y privadas en Ğ1 y Duniter son como un sistema de cerradura y llave, donde la clave pública actúa como la cerradura que puede ser abierta por cualquiera que tenga la clave privada correspondiente, proporcionando una forma segura de autenticar y verificar transacciones", "keys_tooltip": "Las claves públicas y privadas en Ğ1 y Duniter son como un sistema de cerradura y llave, donde la clave pública actúa como la cerradura que puede ser abierta por cualquiera que tenga la clave privada correspondiente, proporcionando una forma segura de autenticar y verificar transacciones",
"card_validity": "Validez", "card_validity": "Validez",
"card_validity_tooltip": "Tenga en cuenta que este monedero solo es accesible mientras utiliza este navegador o app y este dispositivo específico. Si borra o restablece el navegador o app, perderá el acceso a este monedero y los fondos almacenados en el.", "card_validity_tooltip": "Tenga en cuenta que este monedero solo es accesible mientras utiliza este navegador o app y este dispositivo específico. Si borra o restablece el navegador o app, perderá el acceso a este monedero y los fondos almacenados en el.",
...@@ -158,7 +158,7 @@ ...@@ -158,7 +158,7 @@
"receiveMainKey_desc": "Esto funciona de manera similar a los datáfonos que se usan en las tiendas para cobrar, pero en lugar de pagos con tarjeta de crédito, usamos códigos QR. Aquí puedes generar códigos QR para que otras personas los escaneen y te hagan pagos.", "receiveMainKey_desc": "Esto funciona de manera similar a los datáfonos que se usan en las tiendas para cobrar, pero en lugar de pagos con tarjeta de crédito, usamos códigos QR. Aquí puedes generar códigos QR para que otras personas los escaneen y te hagan pagos.",
"receiveQrKey_desc": "En esta pantalla encontrarás tu propio código QR que podrás compartir con otras personas para recibir pagos en Junas.", "receiveQrKey_desc": "En esta pantalla encontrarás tu propio código QR que podrás compartir con otras personas para recibir pagos en Junas.",
"receiveAmountKey_title": "QR con cantidades", "receiveAmountKey_title": "QR con cantidades",
"receiveAmountKey_desc": "Si quieres vender algún producto o servicio, puedes generar un código QR con tu llave pública y la cantidad a cobrar en Junas. Ten en cuenta que estos QRs por ahora solo funcionan entre monederos Ğ1nkgo.", "receiveAmountKey_desc": "Si quieres vender algún producto o servicio, puedes generar un código QR con tu llave pública y la cantidad a cobrar en Junas.",
"receiveSumKey_title": "Cuenta rápida", "receiveSumKey_title": "Cuenta rápida",
"receiveSumKey_desc": "También puedes generar un código QR con el total de una compra, sumando el precio de los artículos que estás vendiendo.", "receiveSumKey_desc": "También puedes generar un código QR con el total de una compra, sumando el precio de los artículos que estás vendiendo.",
"contactsMainKey_title": "Contactos", "contactsMainKey_title": "Contactos",
......
...@@ -117,7 +117,7 @@ String getQrUri( ...@@ -117,7 +117,7 @@ String getQrUri(
String uri; String uri;
if (amountD > 0) { if (amountD > 0) {
// there is something like this in other clients? // there is something like this in other clients?
uri = 'duniter:key/$pubKey?amount=$amountD'; uri = 'june://$pubKey?amount=$amountD';
} else { } else {
uri = pubKey; uri = pubKey;
} }
...@@ -125,20 +125,36 @@ String getQrUri( ...@@ -125,20 +125,36 @@ String getQrUri(
} }
PaymentState? parseScannedUri(String qr) { PaymentState? parseScannedUri(String qr) {
final RegExp regexKeyAmount = RegExp(r'duniter:key/(\w+)\?amount=([\d.]+)'); final RegExp regexKeyCommentAmount = RegExp(
r'(duniter\:key|june\:\/)/(\w+)\?(comment=([^&]+))&amount=([\d.]+)');
final RegExpMatch? matchKeyCommentAmount =
regexKeyCommentAmount.firstMatch(qr);
if (matchKeyCommentAmount != null) {
final String publicKey = matchKeyCommentAmount.group(2)!;
final String? comment = matchKeyCommentAmount.group(4);
final double amount = double.parse(matchKeyCommentAmount.group(5)!);
return PaymentState(
contact: Contact(pubKey: publicKey),
amount: amount,
comment: comment ?? '');
}
final RegExp regexKeyAmount =
RegExp(r'(duniter\:key|june\:\/)/(\w+)\?amount=([\d.]+)');
final RegExpMatch? matchKeyAmount = regexKeyAmount.firstMatch(qr); final RegExpMatch? matchKeyAmount = regexKeyAmount.firstMatch(qr);
if (matchKeyAmount != null) { if (matchKeyAmount != null) {
final String publicKey = matchKeyAmount.group(1)!; final String publicKey = matchKeyAmount.group(2)!;
final double amount = double.parse(matchKeyAmount.group(2)!); final double amount = double.parse(matchKeyAmount.group(3)!);
return PaymentState(contact: Contact(pubKey: publicKey), amount: amount); return PaymentState(contact: Contact(pubKey: publicKey), amount: amount);
} }
// Match no amount // Match no amount
final RegExp regexKey = RegExp(r'duniter:key/(\w+)'); final RegExp regexKey = RegExp(r'(duniter\:key|june\:\/)/(\w+)');
final RegExpMatch? matchKey = regexKey.firstMatch(qr); final RegExpMatch? matchKey = regexKey.firstMatch(qr);
if (matchKey != null) { if (matchKey != null) {
final String publicKey = matchKey.group(1)!; final String publicKey = matchKey.group(2)!;
return PaymentState(contact: Contact(pubKey: publicKey)); return PaymentState(contact: Contact(pubKey: publicKey));
} }
......
...@@ -153,6 +153,9 @@ class _PayContactSearchPageState extends State<PayContactSearchPage> { ...@@ -153,6 +153,9 @@ class _PayContactSearchPageState extends State<PayContactSearchPage> {
} else { } else {
paymentCubit.selectKey(contact); paymentCubit.selectKey(contact);
} }
if (pay.comment != null) {
paymentCubit.setComment(pay.comment!);
}
} }
if (!mounted) { if (!mounted) {
return; return;
......
...@@ -58,7 +58,7 @@ void main() { ...@@ -58,7 +58,7 @@ void main() {
const String publicKey = 'FRYyk57Pi456EJRu9vqVfSHLgmUfx4Qc3goS62a7dUSm'; const String publicKey = 'FRYyk57Pi456EJRu9vqVfSHLgmUfx4Qc3goS62a7dUSm';
final String uriA = getQrUri(pubKey: publicKey, amount: '10'); final String uriA = getQrUri(pubKey: publicKey, amount: '10');
final PaymentState? payA = parseScannedUri(uriA); final PaymentState? payA = parseScannedUri(uriA);
expect(payA!.amount, equals(10)); expect(payA!.amount, equals(10), reason: 'amount should be 10 in $uriA');
expect(payA.contact!.pubKey, equals(publicKey)); expect(payA.contact!.pubKey, equals(publicKey));
final String uriB = getQrUri(pubKey: publicKey); final String uriB = getQrUri(pubKey: publicKey);
...@@ -80,6 +80,18 @@ void main() { ...@@ -80,6 +80,18 @@ void main() {
final PaymentState? payE = parseScannedUri(uriE); final PaymentState? payE = parseScannedUri(uriE);
expect(payE!.amount, equals(10.10)); expect(payE!.amount, equals(10.10));
expect(payE.contact!.pubKey, equals(publicKey)); expect(payE.contact!.pubKey, equals(publicKey));
const String uriF = 'june://$publicKey?amount=100';
final PaymentState? payF = parseScannedUri(uriF);
expect(payF!.amount, equals(100));
expect(payF.contact!.pubKey, equals(publicKey));
const String uriJ =
'june://$publicKey?comment=GCHANGE:AYDI9JPOVIL9ZVG-PNCU&amount=100';
final PaymentState? payJ = parseScannedUri(uriJ);
expect(payJ!.comment, equals('GCHANGE:AYDI9JPOVIL9ZVG-PNCU'));
expect(payJ!.amount, equals(100));
expect(payJ.contact!.pubKey, equals(publicKey));
}); });
test('encrypt/decrypt of keys', () { test('encrypt/decrypt of keys', () {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment