CAKE-192 | merged main branch into current; fixed call unstoppable domains api for different sdk versions; fixed italian and croatian locales

OleksandrSobol committed May 24, 2021 at 21:06 UTC 4d6cc87529cb25f860d227992a962ea70c623cd7
12 files changed +85 -90
android/app/src/main/java/com/cakewallet/cake_wallet/MainActivity.java
+30 -38
@@ -10,29 +10,29 @@ import io.flutter.plugin.common.MethodCall;
10 import io.flutter.plugin.common.MethodChannel;
11
12 import android.os.AsyncTask;
13 +import android.os.Build;
14 import android.os.Handler;
15 import android.os.Looper;
16
16 -import java.security.SecureRandom;
17 import com.unstoppabledomains.resolution.DomainResolution;
18 import com.unstoppabledomains.resolution.Resolution;
19
20 -import android.os.AsyncTask;
21 -import android.os.Handler;
22 -import android.os.Looper;
23 -
24 -import io.flutter.plugin.common.MethodCall;
25 -import io.flutter.plugin.common.MethodChannel;
20 +import java.security.SecureRandom;
21
22 public class MainActivity extends FlutterFragmentActivity {
23 final String UTILS_CHANNEL = "com.cake_wallet/native_utils";
29 -
24 final String UNSTOPPABLE_DOMAIN_CHANNEL = "com.cakewallet.cake_wallet/unstoppable-domain";
25
26 @Override
27 public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
28 GeneratedPluginRegistrant.registerWith(flutterEngine);
29
30 + MethodChannel utilsChannel =
31 + new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(),
32 + UTILS_CHANNEL);
33 +
34 + utilsChannel.setMethodCallHandler(this::handle);
35 +
36 MethodChannel unstoppableDomainChannel =
37 new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(),
38 UNSTOPPABLE_DOMAIN_CHANNEL);
@@ -41,14 +41,30 @@ public class MainActivity extends FlutterFragmentActivity {
41 }
42
43 private void handle(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
44 + Handler handler = new Handler(Looper.getMainLooper());
45 +
46 try {
45 - if (call.method.equals("getUnstoppableDomainAddress")) {
46 - getUnstoppableDomainAddress(call, result);
47 - } else {
48 - result.notImplemented();
47 + switch (call.method) {
48 + case "sec_random":
49 + int count = call.argument("count");
50 + SecureRandom random = new SecureRandom();
51 + byte bytes[] = new byte[count];
52 + random.nextBytes(bytes);
53 + handler.post(() -> result.success(bytes));
54 + break;
55 + case "getUnstoppableDomainAddress":
56 + int version = Build.VERSION.SDK_INT;
57 + if (version >= 24) {
58 + getUnstoppableDomainAddress(call, result);
59 + } else {
60 + handler.post(() -> result.success(""));
61 + }
62 + break;
63 + default:
64 + handler.post(() -> result.notImplemented());
65 }
66 } catch (Exception e) {
51 - result.error("UNCAUGHT_ERROR", e.getMessage(), null);
67 + handler.post(() -> result.error("UNCAUGHT_ERROR", e.getMessage(), null));
68 }
69 }
70
@@ -66,29 +82,5 @@ public class MainActivity extends FlutterFragmentActivity {
82 handler.post(() -> result.error("INVALID DOMAIN", e.getMessage(), null));
83 }
84 });
69 -
70 - MethodChannel utilsChannel =
71 - new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(),
72 - UTILS_CHANNEL);
73 -
74 - utilsChannel.setMethodCallHandler(this::handle);
75 - }
76 -
77 - private void handle(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
78 - Handler handler = new Handler(Looper.getMainLooper());
79 -
80 - try {
81 - if (call.method.equals("sec_random")) {
82 - int count = call.argument("count");
83 - SecureRandom random = new SecureRandom();
84 - byte bytes[] = new byte[count];
85 - random.nextBytes(bytes);
86 - handler.post(() -> result.success(bytes));
87 - } else {
88 - handler.post(() -> result.notImplemented());
89 - }
90 - } catch (Exception e) {
91 - handler.post(() -> result.error("UNCAUGHT_ERROR", e.getMessage(), null));
92 - }
85 }
94 -}
86 +}
\ No newline at end of file
ios/Runner/AppDelegate.swift
+37 -41
@@ -5,9 +5,9 @@ import UnstoppableDomainsResolution
5 @UIApplicationMain
6 @objc class AppDelegate: FlutterAppDelegate {
7 lazy var resolution : Resolution? = {
8 - return try? Resolution()
9 - }()
10 -
8 + return try? Resolution()
9 + }()
10 +
11 override func application(
12 _ application: UIApplication,
13 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
@@ -17,11 +17,6 @@ import UnstoppableDomainsResolution
17 name: "com.cakewallet.cakewallet/legacy_wallet_migration",
18 binaryMessenger: controller.binaryMessenger)
19 legacyMigrationChannel.setMethodCallHandler({
20 - let batteryChannel = FlutterMethodChannel(name: "com.cakewallet.cakewallet/legacy_wallet_migration",
21 - binaryMessenger: controller.binaryMessenger)
22 - let unstoppableDomainChannel = FlutterMethodChannel(name: "com.cakewallet.cake_wallet/unstoppable-domain", binaryMessenger: controller.binaryMessenger)
23 -
24 - batteryChannel.setMethodCallHandler({
20 (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
21
22 switch call.method {
@@ -62,7 +57,7 @@ import UnstoppableDomainsResolution
57 result(FlutterMethodNotImplemented)
58 }
59 })
65 -
60 +
61 let utilsChannel = FlutterMethodChannel(
62 name: "com.cake_wallet/native_utils",
63 binaryMessenger: controller.binaryMessenger)
@@ -80,40 +75,41 @@ import UnstoppableDomainsResolution
75 result(FlutterMethodNotImplemented)
76 }
77 })
83 -
78 +
79 + let unstoppableDomainChannel = FlutterMethodChannel(name: "com.cakewallet.cake_wallet/unstoppable-domain", binaryMessenger: controller.binaryMessenger)
80 unstoppableDomainChannel.setMethodCallHandler({ [weak self]
85 - (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
86 - switch call.method {
87 - case "getUnstoppableDomainAddress":
88 - guard let args = call.arguments as? Dictionary<String, String>,
89 - let domain = args["domain"],
90 - let ticker = args["ticker"] else {
91 - result(nil)
92 - return
93 - }
94 -
95 - guard let resolution = self?.resolution else {
96 - result(nil)
97 - return
98 - }
99 -
100 - resolution.addr(domain: domain, ticker: ticker) { addrResult in
101 - var address : String = ""
102 -
103 - switch addrResult {
104 - case .success(let returnValue):
105 - address = returnValue
106 - case .failure(let error):
107 - print("Expected Address, but got \(error)")
81 + (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
82 + switch call.method {
83 + case "getUnstoppableDomainAddress":
84 + guard let args = call.arguments as? Dictionary<String, String>,
85 + let domain = args["domain"],
86 + let ticker = args["ticker"] else {
87 + result(nil)
88 + return
89 + }
90 +
91 + guard let resolution = self?.resolution else {
92 + result(nil)
93 + return
94 + }
95 +
96 + resolution.addr(domain: domain, ticker: ticker) { addrResult in
97 + var address : String = ""
98 +
99 + switch addrResult {
100 + case .success(let returnValue):
101 + address = returnValue
102 + case .failure(let error):
103 + print("Expected Address, but got \(error)")
104 + }
105 +
106 + result(address)
107 + }
108 + default:
109 + result(FlutterMethodNotImplemented)
110 }
109 -
110 - result(address)
111 - }
112 - default:
113 - result(FlutterMethodNotImplemented)
114 - }
115 - })
116 -
111 + })
112 +
113 GeneratedPluginRegistrant.register(with: self)
114 return super.application(application, didFinishLaunchingWithOptions: launchOptions)
115 }
pubspec.lock
+3 -3
@@ -70,7 +70,7 @@ packages:
70 path: "."
71 ref: cake
72 resolved-ref: "02fef082f20af13de00b4e64efb93a2c1e5e1cf2"
73 - url: "git@github.com:cake-tech/bech32.git"
73 + url: "https://github.com/cake-tech/bech32.git"
74 source: git
75 version: "0.2.0"
76 bip32:
@@ -92,8 +92,8 @@ packages:
92 description:
93 path: "."
94 ref: cake
95 - resolved-ref: b3ab2926c665f0e68b74a4a5f31059f7fcd817b7
96 - url: "git@github.com:cake-tech/bitcoin_flutter.git"
95 + resolved-ref: cbabfd87b6ce3cae6051a3e86ddb56e7a934e188
96 + url: "https://github.com/cake-tech/bitcoin_flutter.git"
97 source: git
98 version: "2.0.2"
99 boolean_selector:
res/values/strings_de.arb
+1 -1
@@ -474,7 +474,7 @@
474 "buy_alert_content" : "Derzeit unterstützen wir nur den Kauf von Bitcoin. Um Bitcoin zu kaufen, erstellen Sie bitte Ihre Bitcoin-Brieftasche oder wechseln Sie zu dieser",
475
476 "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.",
477 - "understand" : "I understand"
477 + "understand" : "I understand",
478
479 "address_detected" : "Adresse erkannt",
480 "address_from_domain" : "Sie haben die Adresse von der unaufhaltsamen Domain ${domain} erhalten"
res/values/strings_en.arb
+1 -1
@@ -474,7 +474,7 @@
474 "buy_alert_content" : "Currently we only support the purchase of Bitcoin. To buy Bitcoin, please create or switch to your Bitcoin wallet",
475
476 "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.",
477 - "understand" : "I understand"
477 + "understand" : "I understand",
478
479 "address_detected" : "Address detected",
480 "address_from_domain" : "You got address from unstoppable domain ${domain}"
res/values/strings_es.arb
+1 -1
@@ -474,7 +474,7 @@
474 "buy_alert_content" : "Actualmente solo apoyamos la compra de Bitcoin. Para comprar Bitcoin, cree o cambie a su billetera Bitcoin",
475
476 "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.",
477 - "understand" : "I understand"
477 + "understand" : "I understand",
478
479 "address_detected" : "Dirección detectada",
480 "address_from_domain" : "Tienes la dirección de unstoppable domain ${domain}"
res/values/strings_hi.arb
+1 -1
@@ -474,7 +474,7 @@
474 "buy_alert_content" : "वर्तमान में हम केवल बिटकॉइन की खरीद का समर्थन करते हैं। बिटकॉइन खरीदने के लिए, कृपया अपना बिटकॉइन वॉलेट बनाएं या स्विच करें",
475
476 "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.",
477 - "understand" : "I understand"
477 + "understand" : "I understand",
478
479 "address_detected" : "पता लग गया",
480 "address_from_domain" : "आपको अजेय डोमेन ${domain} से पता मिला है"
res/values/strings_hr.arb
+4 -1
@@ -474,5 +474,8 @@
474 "buy_alert_content" : "Currently we only support the purchase of Bitcoin. To buy Bitcoin, please create or switch to your Bitcoin wallet",
475
476 "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.",
477 - "understand" : "I understand"
477 + "understand" : "I understand",
478 +
479 + "address_detected" : "Adresa je otkrivena",
480 + "address_from_domain" : "Dobili ste adresu od unstoppable domain ${domain}"
481 }
\ No newline at end of file
res/values/strings_it.arb
+4 -1
@@ -474,5 +474,8 @@
474 "buy_alert_content" : "Currently we only support the purchase of Bitcoin. To buy Bitcoin, please create or switch to your Bitcoin wallet",
475
476 "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.",
477 - "understand" : "I understand"
477 + "understand" : "I understand",
478 +
479 + "address_detected" : "Indirizzo rilevato",
480 + "address_from_domain" : "Hai l'indirizzo da unstoppable domain ${domain}"
481 }
\ No newline at end of file
res/values/strings_ja.arb
+1 -1
@@ -474,7 +474,7 @@
474 "buy_alert_content" : "現在、ビットコインの購入のみをサポートしています。 ビットコインを購入するには、ビットコインウォレットを作成するか切り替えてください",
475
476 "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.",
477 - "understand" : "I understand"
477 + "understand" : "I understand",
478
479 "address_detected" : "アドレスが検出されました",
480 "address_from_domain" : "あなたはからアドレスを得ました unstoppable domain ${domain}"
res/values/strings_ko.arb
+1 -1
@@ -474,7 +474,7 @@
474 "buy_alert_content" : "현재 우리는 비트 코인 구매 만 지원합니다. 비트 코인을 구매하려면 비트 코인 지갑을 생성하거나 전환하십시오",
475
476 "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.",
477 - "understand" : "I understand"
477 + "understand" : "I understand",
478
479 "address_detected" : "주소 감지",
480 "address_from_domain" : "주소는 unstoppable domain ${domain}"
res/values/strings_zh.arb
+1
@@ -469,6 +469,7 @@
469 "displayable" : "可显示",
470
471 "submit_request" : "提交请求",
472 +
473 "buy_alert_content" : "目前,我們僅支持購買比特幣。 要購買比特幣,請創建或切換到您的比特幣錢包",
474
475 "outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have a 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-word wallet, and stop using wallets with a 12-word seed. Please do this immediately to secure your funds.",