From 89adc714aa1941d3cdb9c86fe14a91488dc33f32 Mon Sep 17 00:00:00 2001 From: JC Date: Thu, 18 Jul 2024 13:05:35 -0600 Subject: [PATCH 01/12] fix: new zennies fir zingo address added --- .../java/org/ZingoLabs/Zingo/RPCModule.kt | 12 ++++ app/LoadedApp/LoadedApp.tsx | 8 +-- app/translations/en.json | 5 +- app/translations/es.json | 5 +- app/translations/pt.json | 5 +- app/translations/ru.json | 5 +- app/utils/Utils.ts | 62 ++++++++++++++++--- components/Send/Send.tsx | 30 +++++---- ios/RPCModule.swift | 20 ++++++ ios/RPCModuleBridge.m | 3 + rust/Cargo.lock | 30 ++++----- rust/Cargo.toml | 4 +- rust/android/Cargo.toml | 4 +- rust/lib/src/lib.rs | 4 ++ rust/lib/src/zingo.udl | 1 + 15 files changed, 147 insertions(+), 51 deletions(-) diff --git a/android/app/src/main/java/org/ZingoLabs/Zingo/RPCModule.kt b/android/app/src/main/java/org/ZingoLabs/Zingo/RPCModule.kt index 77f7cf47c..4510de00a 100644 --- a/android/app/src/main/java/org/ZingoLabs/Zingo/RPCModule.kt +++ b/android/app/src/main/java/org/ZingoLabs/Zingo/RPCModule.kt @@ -443,6 +443,18 @@ class RPCModule internal constructor(private val reactContext: ReactApplicationC promise.resolve(resp) } + @ReactMethod + fun getZenniesDonationAddress(promise: Promise) { + // Log.i("MAIN", "Initialize Light Client") + + uniffi.zingo.initLogging() + + // Initialize Light Client + val resp = uniffi.zingo.getZenniesForZingoDonationAddress() + + promise.resolve(resp) + } + @ReactMethod fun getValueTransfersList(promise: Promise) { // Log.i("MAIN", "Initialize Light Client") diff --git a/app/LoadedApp/LoadedApp.tsx b/app/LoadedApp/LoadedApp.tsx index 211c75c51..469258dc3 100644 --- a/app/LoadedApp/LoadedApp.tsx +++ b/app/LoadedApp/LoadedApp.tsx @@ -1038,7 +1038,7 @@ export class LoadedAppClass extends Component { @@ -1055,9 +1055,9 @@ export class LoadedAppClass extends Component { // donations only for mainnet. if (chainName === ChainNameEnum.mainChainName) { @@ -117,16 +118,58 @@ export default class Utils { return ''; } - static getDefaultDonationAmount(): string { + static getDonationAmount(): string { const { decimalSeparator } = getNumberFormatSettings(); return '0' + decimalSeparator + '01'; } - static getDefaultDonationMemo(translate: (key: string) => TranslateType): string { + static getDonationMemo(translate: (key: string) => TranslateType): string { return translate('donation') as string; } + // ZENNIES FOR ZINGO + static async getZenniesDonationAddress(chainName: ChainNameEnum): Promise { + // donations only for mainnet. + if (chainName === ChainNameEnum.mainChainName) { + // UA -> we need a fresh one. + const ua: string = await RPCModule.getZenniesDonationAddress(); + return ua; + } + return ''; + } + + static getZenniesDonationAmount(): string { + const { decimalSeparator } = getNumberFormatSettings(); + + return '0' + decimalSeparator + '01'; + } + + static getZenniesDonationMemo(translate: (key: string) => TranslateType): string { + return translate('zennies-donation') as string; + } + + // NYM + static async getNymDonationAddress(chainName: ChainNameEnum): Promise { + // donations only for mainnet. + if (chainName === ChainNameEnum.mainChainName) { + // UA -> we need a fresh one. + const ua: string = await RPCModule.getDonationAddress(); + return ua; + } + return ''; + } + + static getNymDonationAmount(): string { + const { decimalSeparator } = getNumberFormatSettings(); + + return '0' + decimalSeparator + '01'; + } + + static getNymDonationMemo(translate: (key: string) => TranslateType): string { + return translate('nym-donation') as string; + } + static utf16Split(s: string, chunksize: number): string[] { const ans = []; @@ -206,7 +249,10 @@ export default class Utils { const memo = `${to.memo || ''}${to.includeUAMemo ? '\nReply to: \n' + uaAddress : ''}`; const amount = parseInt((Utils.parseStringLocaleToNumberFloat(to.amount) * 10 ** 8).toFixed(0), 10); - donationAddress = to.to === (await Utils.getDonationAddress(server.chainName)); + donationAddress = + to.to === (await Utils.getDonationAddress(server.chainName)) || + to.to === (await Utils.getZenniesDonationAddress(server.chainName)) || + to.to === (await Utils.getNymDonationAddress(server.chainName)); if (memo === '') { return [{ address: to.to, amount } as SendJsonToTypeType]; @@ -240,16 +286,16 @@ export default class Utils { const donationTransaction: SendJsonToTypeType[] = []; // we need to exclude 2 use cases: - // 1. send to self (make no sense to do a donation here) - // 2. send to donation UA (make no sense to do a double donation) + // 2. send to one of our donation UA's + // (make no sense to do a double donation) if (donation && server.chainName === ChainNameEnum.mainChainName && !donationAddress) { donationTransaction.push({ - address: await Utils.getDonationAddress(server.chainName), + address: await Utils.getZenniesDonationAddress(server.chainName), amount: parseInt( - (Utils.parseStringLocaleToNumberFloat(Utils.getDefaultDonationAmount()) * 10 ** 8).toFixed(0), + (Utils.parseStringLocaleToNumberFloat(Utils.getZenniesDonationAmount()) * 10 ** 8).toFixed(0), 10, ), - memo: Utils.getDefaultDonationMemo(translate) + '\n' + translate('settings.donation-title'), + memo: Utils.getZenniesDonationMemo(translate), }); } diff --git a/components/Send/Send.tsx b/components/Send/Send.tsx index 0c7252579..373365250 100644 --- a/components/Send/Send.tsx +++ b/components/Send/Send.tsx @@ -183,7 +183,9 @@ const Send: React.FunctionComponent = ({ const max = totalBalance.spendableOrchard + totalBalance.spendablePrivate - - (donation && !donationAddress ? Utils.parseStringLocaleToNumberFloat(Utils.getDefaultDonationAmount()) : 0); + (donation && server.chainName === ChainNameEnum.mainChainName && !donationAddress + ? Utils.parseStringLocaleToNumberFloat(Utils.getZenniesDonationAmount()) + : 0); if (max >= 0) { // if max is 0 then the user can send a memo with amount 0. setMaxAmount(max); @@ -194,7 +196,7 @@ const Send: React.FunctionComponent = ({ setNegativeMaxAmount(true); } setSpendableBalanceLastError(''); - }, [donation, donationAddress, totalBalance.spendableOrchard, totalBalance.spendablePrivate]); + }, [donation, donationAddress, server.chainName, totalBalance.spendableOrchard, totalBalance.spendablePrivate]); const calculateFeeWithPropose = useCallback( async ( @@ -283,8 +285,8 @@ const Send: React.FunctionComponent = ({ if (runProposeJson.amount) { const newAmount = runProposeJson.amount / 10 ** 8 - - (donation && !donationAddress - ? Utils.parseStringLocaleToNumberFloat(Utils.getDefaultDonationAmount()) + (donation && server.chainName === ChainNameEnum.mainChainName && !donationAddress + ? Utils.parseStringLocaleToNumberFloat(Utils.getZenniesDonationAmount()) : 0); console.log('AMOUNT', newAmount); updateToField(null, Utils.parseNumberFloatToStringLocale(newAmount, 8), null, null, null); @@ -719,7 +721,10 @@ const Send: React.FunctionComponent = ({ const address = sendPageState.toaddr.to; if (address) { (async () => { - const donationA = address === (await Utils.getDonationAddress(server.chainName)); + const donationA = + address === (await Utils.getDonationAddress(server.chainName)) || + address === (await Utils.getZenniesDonationAddress(server.chainName)) || + address === (await Utils.getNymDonationAddress(server.chainName)); setDonationAddress(donationA); })(); } else { @@ -861,7 +866,7 @@ const Send: React.FunctionComponent = ({ calculatedFee={fee} donationAmount={ donation && server.chainName === ChainNameEnum.mainChainName && !donationAddress - ? Utils.parseStringLocaleToNumberFloat(Utils.getDefaultDonationAmount()) + ? Utils.parseStringLocaleToNumberFloat(Utils.getZenniesDonationAmount()) : 0 } closeModal={() => { @@ -1226,7 +1231,7 @@ const Send: React.FunctionComponent = ({ /> - {donation && !donationAddress && ( + {donation && server.chainName === ChainNameEnum.mainChainName && !donationAddress && ( = ({ {(translate('send.confirm-donation') as string) + ': ' + - Utils.getDefaultDonationAmount() + + Utils.getZenniesDonationAmount() + ' '} {')'} @@ -1616,12 +1621,13 @@ const Send: React.FunctionComponent = ({ onPress={() => { // donation - a Zenny is the minimum if ( + server.chainName === ChainNameEnum.mainChainName && donationAddress && Utils.parseStringLocaleToNumberFloat(sendPageState.toaddr.amount) < - Utils.parseStringLocaleToNumberFloat(Utils.getDefaultDonationAmount()) + Utils.parseStringLocaleToNumberFloat(Utils.getZenniesDonationAmount()) ) { addLastSnackbar({ message: `${translate('send.donation-minimum-message') as string}` }); - updateToField(null, Utils.getDefaultDonationAmount(), null, null, false); + updateToField(null, Utils.getZenniesDonationAmount(), null, null, false); return; } if (!netInfo.isConnected) { @@ -1695,9 +1701,9 @@ const Send: React.FunctionComponent = ({ if (update) { updateToField( await Utils.getDonationAddress(server.chainName), - Utils.getDefaultDonationAmount(), + Utils.getDonationAmount(), null, - Utils.getDefaultDonationMemo(translate), + Utils.getDonationMemo(translate), true, ); } diff --git a/ios/RPCModule.swift b/ios/RPCModule.swift index 1bf089d67..396b2ce27 100644 --- a/ios/RPCModule.swift +++ b/ios/RPCModule.swift @@ -377,6 +377,26 @@ class RPCModule: NSObject { self.getDonationAddressAsync(dict) } + func getZenniesDonationAddressAsync(_ dict: [AnyHashable: Any]) { + if let resolve = dict["resolve"] as? RCTPromiseResolveBlock { + let resp = getZenniesForZingoDonationAddress() + let respStr = String(resp) + resolve(respStr) + } else { + let err = "Error: [Native] Getting zennies donation address. Command arguments problem." + NSLog(err) + if let resolve = dict["resolve"] as? RCTPromiseResolveBlock { + resolve(err) + } + } + } + + @objc(getZenniesDonationAddress:reject:) + func getZenniesDonationAddress(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { + let dict: [String: Any] = ["resolve": resolve] + self.getZenniesDonationAddressAsync(dict) + } + @objc(getValueTransfersList:reject:) func getValueTransfersList(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { let dict: [String: Any] = ["resolve": resolve] diff --git a/ios/RPCModuleBridge.m b/ios/RPCModuleBridge.m index 40f7a8492..837091677 100644 --- a/ios/RPCModuleBridge.m +++ b/ios/RPCModuleBridge.m @@ -66,6 +66,9 @@ @interface RCT_EXTERN_MODULE(RPCModule, NSObject) RCT_EXTERN_METHOD(getDonationAddress: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) +RCT_EXTERN_METHOD(getZenniesDonationAddress: + (RCTPromiseResolveBlock)resolve + reject:(RCTPromiseRejectBlock)reject) RCT_EXTERN_METHOD(getValueTransfersList: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index b2e805066..b860f9595 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -537,7 +537,7 @@ dependencies = [ [[package]] name = "build_utils" version = "0.1.0" -source = "git+https://github.com/zingolabs/zingolib?tag=mob-release-1.4.2#6e1a16fe31e466ce525de39f7c10603822d58bed" +source = "git+https://github.com/zingolabs/zingolib?tag=mob-release-1.4.3#9fa9940760431c137c2e46e115dd2a296808ca7f" [[package]] name = "bumpalo" @@ -800,7 +800,7 @@ dependencies = [ [[package]] name = "darkside-tests" version = "0.1.0" -source = "git+https://github.com/zingolabs/zingolib?tag=mob-release-1.4.2#6e1a16fe31e466ce525de39f7c10603822d58bed" +source = "git+https://github.com/zingolabs/zingolib?tag=mob-release-1.4.3#9fa9940760431c137c2e46e115dd2a296808ca7f" dependencies = [ "futures-util", "hex", @@ -3347,18 +3347,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.62" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2675633b1499176c2dff06b0856a27976a8f9d436737b4cf4f312d4d91d8bbb" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.62" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d20468752b09f49e909e55a5d338caa8bedf615594e9d80bc4c565d30faf798c" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", @@ -3433,9 +3433,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.0" +version = "1.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df" dependencies = [ "backtrace", "bytes 1.6.1", @@ -4545,7 +4545,7 @@ dependencies = [ [[package]] name = "zingo-memo" version = "0.1.0" -source = "git+https://github.com/zingolabs/zingolib?tag=mob-release-1.4.2#6e1a16fe31e466ce525de39f7c10603822d58bed" +source = "git+https://github.com/zingolabs/zingolib?tag=mob-release-1.4.3#9fa9940760431c137c2e46e115dd2a296808ca7f" dependencies = [ "zcash_address", "zcash_client_backend", @@ -4557,7 +4557,7 @@ dependencies = [ [[package]] name = "zingo-netutils" version = "0.1.0" -source = "git+https://github.com/zingolabs/zingolib?tag=mob-release-1.4.2#6e1a16fe31e466ce525de39f7c10603822d58bed" +source = "git+https://github.com/zingolabs/zingolib?tag=mob-release-1.4.3#9fa9940760431c137c2e46e115dd2a296808ca7f" dependencies = [ "http 0.2.12", "http-body 0.4.6", @@ -4576,7 +4576,7 @@ dependencies = [ [[package]] name = "zingo-status" version = "0.1.0" -source = "git+https://github.com/zingolabs/zingolib?tag=mob-release-1.4.2#6e1a16fe31e466ce525de39f7c10603822d58bed" +source = "git+https://github.com/zingolabs/zingolib?tag=mob-release-1.4.3#9fa9940760431c137c2e46e115dd2a296808ca7f" dependencies = [ "zcash_primitives", ] @@ -4584,7 +4584,7 @@ dependencies = [ [[package]] name = "zingo-testutils" version = "0.1.0" -source = "git+https://github.com/zingolabs/zingolib?tag=mob-release-1.4.2#6e1a16fe31e466ce525de39f7c10603822d58bed" +source = "git+https://github.com/zingolabs/zingolib?tag=mob-release-1.4.3#9fa9940760431c137c2e46e115dd2a296808ca7f" dependencies = [ "http 0.2.12", "incrementalmerkletree", @@ -4609,7 +4609,7 @@ dependencies = [ [[package]] name = "zingo-testvectors" version = "0.1.0" -source = "git+https://github.com/zingolabs/zingolib?tag=mob-release-1.4.2#6e1a16fe31e466ce525de39f7c10603822d58bed" +source = "git+https://github.com/zingolabs/zingolib?tag=mob-release-1.4.3#9fa9940760431c137c2e46e115dd2a296808ca7f" dependencies = [ "zcash_primitives", "zingoconfig", @@ -4618,7 +4618,7 @@ dependencies = [ [[package]] name = "zingoconfig" version = "0.1.0" -source = "git+https://github.com/zingolabs/zingolib?tag=mob-release-1.4.2#6e1a16fe31e466ce525de39f7c10603822d58bed" +source = "git+https://github.com/zingolabs/zingolib?tag=mob-release-1.4.3#9fa9940760431c137c2e46e115dd2a296808ca7f" dependencies = [ "dirs", "http 0.2.12", @@ -4631,7 +4631,7 @@ dependencies = [ [[package]] name = "zingolib" version = "0.2.0" -source = "git+https://github.com/zingolabs/zingolib?tag=mob-release-1.4.2#6e1a16fe31e466ce525de39f7c10603822d58bed" +source = "git+https://github.com/zingolabs/zingolib?tag=mob-release-1.4.3#9fa9940760431c137c2e46e115dd2a296808ca7f" dependencies = [ "append-only-vec", "base58", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index d500b6ff7..878d1bc2f 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -7,8 +7,8 @@ members = [ resolver = "2" [workspace.dependencies] -zingolib = { git="https://github.com/zingolabs/zingolib", default-features=true, tag = "mob-release-1.4.2" } -zingoconfig = { git="https://github.com/zingolabs/zingolib", default-features=true, tag = "mob-release-1.4.2" } +zingolib = { git="https://github.com/zingolabs/zingolib", default-features=true, tag = "mob-release-1.4.3" } +zingoconfig = { git="https://github.com/zingolabs/zingolib", default-features=true, tag = "mob-release-1.4.3" } uniffi = "0.27" tokio = { version = "1.24", features = [ "full" ] } diff --git a/rust/android/Cargo.toml b/rust/android/Cargo.toml index 840816079..4adaa2fda 100644 --- a/rust/android/Cargo.toml +++ b/rust/android/Cargo.toml @@ -12,8 +12,8 @@ regchest = [] zingoconfig = { workspace = true } zingomobile_utils = { path = "../zingomobile_utils" } regchest_utils = { git="https://github.com/zingolabs/zingo-regchest", default-features=true, branch = "dev" } -zingo-testutils = { git="https://github.com/zingolabs/zingolib", default-features=true, tag = "mob-release-1.4.2" } -darkside-tests = { git="https://github.com/zingolabs/zingolib", default-features=true, tag = "mob-release-1.4.2" } +zingo-testutils = { git="https://github.com/zingolabs/zingolib", default-features=true, tag = "mob-release-1.4.3" } +darkside-tests = { git="https://github.com/zingolabs/zingolib", default-features=true, tag = "mob-release-1.4.3" } json = "0.12.4" env_logger = "0.10.0" tokio = { workspace = true } diff --git a/rust/lib/src/lib.rs b/rust/lib/src/lib.rs index 9baf68b99..ab1ec1337 100644 --- a/rust/lib/src/lib.rs +++ b/rust/lib/src/lib.rs @@ -247,6 +247,10 @@ pub fn get_developer_donation_address() -> String { zingoconfig::DEVELOPER_DONATION_ADDRESS.to_string() } +pub fn get_zennies_for_zingo_donation_address() -> String { + zingoconfig::ZENNIES_FOR_ZINGO_DONATION_ADDRESS.to_string() +} + pub fn get_transaction_summaries() -> String { let resp: String; { diff --git a/rust/lib/src/zingo.udl b/rust/lib/src/zingo.udl index 01027dc42..431da032f 100644 --- a/rust/lib/src/zingo.udl +++ b/rust/lib/src/zingo.udl @@ -37,6 +37,7 @@ namespace zingo { string save_to_b64(); string get_latest_block_server(string serveruri); string get_developer_donation_address(); + string get_zennies_for_zingo_donation_address(); string get_transaction_summaries(); string get_value_transfers(); }; \ No newline at end of file From 40720cd06992cb66349b9b3a0159b5ae9c528432 Mon Sep 17 00:00:00 2001 From: JC Date: Thu, 18 Jul 2024 14:57:19 -0600 Subject: [PATCH 02/12] fix: cargo update zingolib --- rust/Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index b860f9595..cbc97db12 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2352,7 +2352,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ "bytes 1.6.1", - "heck 0.5.0", + "heck 0.4.1", "itertools", "log", "multimap", @@ -3367,9 +3367,9 @@ dependencies = [ [[package]] name = "thread-id" -version = "4.2.1" +version = "4.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0ec81c46e9eb50deaa257be2f148adf052d1fb7701cfd55ccfab2525280b70b" +checksum = "cfe8f25bbdd100db7e1d34acf7fd2dc59c4bf8f7483f505eaa7d4f12f76cc0ea" dependencies = [ "libc", "winapi", From b77d508d1b27de72fcc42979ac5905542206158c Mon Sep 17 00:00:00 2001 From: JC Date: Fri, 19 Jul 2024 10:32:06 -0600 Subject: [PATCH 03/12] fix: adding zenny tips new address to the address book automatically --- app/LoadedApp/LoadedApp.tsx | 7 ++- app/translations/en.json | 1 + app/translations/es.json | 1 + app/translations/pt.json | 1 + app/translations/ru.json | 1 + components/AddressBook/AddressBook.tsx | 49 ++++++++++++++- .../AddressBook/components/AbSummaryLine.tsx | 62 ++++++++++++------- components/Components/AddressItem.tsx | 5 +- .../components/ValueTransferDetail.tsx | 14 +++++ 9 files changed, 112 insertions(+), 29 deletions(-) diff --git a/app/LoadedApp/LoadedApp.tsx b/app/LoadedApp/LoadedApp.tsx index 469258dc3..97ec8d51d 100644 --- a/app/LoadedApp/LoadedApp.tsx +++ b/app/LoadedApp/LoadedApp.tsx @@ -262,8 +262,11 @@ export default function LoadedApp(props: LoadedAppProps) { setBackground(backgroundJson); } - // reading the address book - const ab = await AddressBookFileImpl.readAddressBook(); + // adding `Zenny Tips` address always. + const ab = await AddressBookFileImpl.writeAddressBookItem( + translate('zenny-tips-ab') as string, + await Utils.getZenniesDonationAddress(server.chainName), + ); setAddressBook(ab); setLoading(false); diff --git a/app/translations/en.json b/app/translations/en.json index 9fb33097f..4a61291ec 100644 --- a/app/translations/en.json +++ b/app/translations/en.json @@ -23,6 +23,7 @@ "menu-acc": "Open Menu", "donation": "Donation to Zingo!\nThanks for supporting ZingoLabs!", "zennies-donation": "A Zenny for Zingo!\nThanks for supporting ZingoLabs!", + "zenny-tips-ab": "Zenny Tips", "nym-donation": "I need Nym network security!", "restarting": "Error connecting to the Server, the App will restart in a few seconds.", "change-privacy": "New privacy policy: ", diff --git a/app/translations/es.json b/app/translations/es.json index 006e38cbb..6778ff0a4 100644 --- a/app/translations/es.json +++ b/app/translations/es.json @@ -23,6 +23,7 @@ "menu-acc": "Abrir Menú", "donation": "¡Donación a Zingo!\n¡Gracias por apoyar a ZingoLabs!", "zennies-donation": "¡Un Zenny para Zingo!\n¡Gracias por apoyar a ZingoLabs!", + "zenny-tips-ab": "Zenny Propinas", "nym-donation": "¡Necesito seguridad de red Nym!", "restarting": "Error conectando con el servidor, la Aplicación se reiniciará en breves segundos.", "change-privacy": "Nueva Política de Privacidad: ", diff --git a/app/translations/pt.json b/app/translations/pt.json index 12ecf4928..b7d757c9e 100644 --- a/app/translations/pt.json +++ b/app/translations/pt.json @@ -23,6 +23,7 @@ "menu-acc": "Abrir Menu", "donation": "Doação para o Zingo!\nObrigado por apoiar o ZingoLabs!", "zennies-donation": "Um Zenny pelo Zingo!\nObrigado por apoiar o ZingoLabs!", + "zenny-tips-ab": "Zenny Gorjetas", "nym-donation": "Eu preciso de segurança de rede Nym!", "restarting": "Erro ao conectar ao servidor, o aplicativo será reiniciado em alguns segundos.", "change-privacy": "Nova política de privacidade: ", diff --git a/app/translations/ru.json b/app/translations/ru.json index 6b2d6311d..84ec9f655 100644 --- a/app/translations/ru.json +++ b/app/translations/ru.json @@ -23,6 +23,7 @@ "menu-acc": "Открыть меню", "donation": "Пожертвование в пользу Zingo!\nСпасибо за поддержку ZingoLabs!", "zennies-donation": "Zenny для Zingo!\nСпасибо за поддержку ZingoLabs!", + "zenny-tips-ab": "Zenny советы", "nym-donation": "Мне нужна сетевая безопасность Nym!", "restarting": "Ошибка подключения к Серверу, приложение перезапустится через несколько секунд.", "change-privacy": "Новая политика конфиденциальности: ", diff --git a/components/AddressBook/AddressBook.tsx b/components/AddressBook/AddressBook.tsx index b1080848b..c27b7740a 100644 --- a/components/AddressBook/AddressBook.tsx +++ b/components/AddressBook/AddressBook.tsx @@ -36,6 +36,7 @@ import AddressBookFileImpl from './AddressBookFileImpl'; import RPC from '../../app/rpc'; import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'; import { faAnglesUp } from '@fortawesome/free-solid-svg-icons'; +import Utils from '../../app/utils'; type AddressBookProps = { closeModal: () => void; @@ -45,13 +46,14 @@ type AddressBookProps = { const AddressBook: React.FunctionComponent = ({ closeModal, setAddressBook, setSendPageState }) => { const context = useContext(ContextAppLoaded); - const { translate, language, addressBook, addressBookCurrentAddress, addressBookOpenPriorModal } = context; + const { translate, language, addressBook, addressBookCurrentAddress, addressBookOpenPriorModal, server } = context; const { colors } = useTheme() as unknown as ThemeType; moment.locale(language); const [numAb, setNumAb] = useState(50); const [loadMoreButton, setLoadMoreButton] = useState(false); const [addressBookSorted, setAddressBookSorted] = useState([]); + const [addressBookProtected, setAddressBookProtected] = useState([]); const [currentItem, setCurrentItem] = useState(null); const [titleViewHeight, setTitleViewHeight] = useState(0); @@ -64,7 +66,10 @@ const AddressBook: React.FunctionComponent = ({ closeModal, se useScrollToTop(scrollViewRef); const fetchAddressBookSorted = useMemo(async () => { + // excluding this address from the list + const zennyTips = await Utils.getZenniesDonationAddress(server.chainName); return addressBook + .filter((ab: AddressBookFileClass) => ab.address !== zennyTips) .sort((a, b) => { const nA = a.label.toUpperCase(); const nB = b.label.toUpperCase(); @@ -77,7 +82,25 @@ const AddressBook: React.FunctionComponent = ({ closeModal, se } }) .slice(0, numAb); - }, [addressBook, numAb]); + }, [addressBook, numAb, server.chainName]); + + const fetchAddressBookProtected = useMemo(async () => { + // only protected address to use internally ZingoLabs. + const zennyTips = await Utils.getZenniesDonationAddress(server.chainName); + return addressBook + .filter((ab: AddressBookFileClass) => ab.address === zennyTips) + .sort((a, b) => { + const nA = a.label.toUpperCase(); + const nB = b.label.toUpperCase(); + if (nA < nB) { + return -1; + } else if (nA > nB) { + return 1; + } else { + return 0; + } + }); + }, [addressBook, server.chainName]); // because this screen is fired from more places than the menu. useEffect(() => { @@ -87,8 +110,10 @@ const AddressBook: React.FunctionComponent = ({ closeModal, se useEffect(() => { (async () => { const abs = await fetchAddressBookSorted; + const abp = await fetchAddressBookProtected; setLoadMoreButton(numAb < (abs.length || 0)); setAddressBookSorted(abs); + setAddressBookProtected(abp); // find the current address if (addressBookCurrentAddress) { const index: number = abs.findIndex((i: AddressBookFileClass) => i.address === addressBookCurrentAddress); @@ -100,7 +125,7 @@ const AddressBook: React.FunctionComponent = ({ closeModal, se setCurrentItem(index); } })(); - }, [addressBookCurrentAddress, fetchAddressBookSorted, numAb]); + }, [addressBookCurrentAddress, fetchAddressBookProtected, fetchAddressBookSorted, numAb]); useEffect(() => { const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => { @@ -204,6 +229,24 @@ const AddressBook: React.FunctionComponent = ({ closeModal, se alignItems: 'stretch', justifyContent: 'flex-start', }}> + {addressBookProtected.flatMap((aBItem, index) => { + return ( + + + + ); + })} {currentItem === -1 && action !== null && ( void; handleScrollToTop: () => void; doAction: (action: AddressBookActionEnum, label: string, address: string) => void; + addressProtected?: boolean; }; const AbSummaryLine: React.FunctionComponent = ({ index, @@ -42,6 +43,7 @@ const AbSummaryLine: React.FunctionComponent = ({ closeModal, handleScrollToTop, doAction, + addressProtected, }) => { const context = useContext(ContextAppLoaded); const { translate, navigation, readOnly, mode, totalBalance, language } = context; @@ -80,25 +82,34 @@ const AbSummaryLine: React.FunctionComponent = ({ flexDirection: 'row', marginTop: 15, paddingBottom: 15, - borderBottomWidth: 1, - borderBottomColor: colors.border, + borderBottomWidth: addressProtected ? 3 : 1, + borderBottomColor: addressProtected ? colors.zingo : colors.border, + opacity: addressProtected ? 0.5 : 1, }}> { - setCurrentItem(index); - setAction(AddressBookActionEnum.Modify); - handleScrollToTop(); + if (!addressProtected) { + setCurrentItem(index); + setAction(AddressBookActionEnum.Modify); + handleScrollToTop(); + } }}> + style={{ + fontSize: 18, + marginHorizontal: 10, + color: addressProtected ? colors.zingo : colors.primary, + opacity: 1, + fontWeight: 'bold', + }}> {displayContact} @@ -110,18 +121,21 @@ const AbSummaryLine: React.FunctionComponent = ({ - - { - setCurrentItem(index); - setAction(AddressBookActionEnum.Modify); - handleScrollToTop(); - }}> - - - + {!addressProtected && ( + + { + setCurrentItem(index); + setAction(AddressBookActionEnum.Modify); + handleScrollToTop(); + }}> + + + + )} {!readOnly && + !addressProtected && !(mode === ModeEnum.basic && totalBalance.spendableOrchard + totalBalance.spendablePrivate <= 0) && ( = ({ )} - - onPressDelete()}> - - - + {!addressProtected && ( + + onPressDelete()}> + + + + )} ); diff --git a/components/Components/AddressItem.tsx b/components/Components/AddressItem.tsx index 73005e8c5..878376dc3 100644 --- a/components/Components/AddressItem.tsx +++ b/components/Components/AddressItem.tsx @@ -31,6 +31,7 @@ type AddressItemProps = { withIcon?: boolean; withSendIcon?: boolean; setSendPageState?: (s: SendPageStateClass) => void; + addressProtected?: boolean; }; const AddressItem: React.FunctionComponent = ({ @@ -42,6 +43,7 @@ const AddressItem: React.FunctionComponent = ({ closeModal, openModal, setSendPageState, + addressProtected, }) => { const context = useContext(ContextAppLoaded); const { @@ -127,7 +129,7 @@ const AddressItem: React.FunctionComponent = ({ {(!oneLine || (oneLine && !contact)) && !onlyContact && ( { - if (address && !oneLine) { + if (address && !oneLine && !addressProtected) { Clipboard.setString(address); addLastSnackbar({ message: translate('history.addresscopied') as string, @@ -178,6 +180,7 @@ const AddressItem: React.FunctionComponent = ({ )} {withSendIcon && setSendPageState && + !addressProtected && contact && !readOnly && !(mode === ModeEnum.basic && totalBalance.spendableOrchard + totalBalance.spendablePrivate <= 0) && ( diff --git a/components/History/components/ValueTransferDetail.tsx b/components/History/components/ValueTransferDetail.tsx index 9f6005126..53d5826b4 100644 --- a/components/History/components/ValueTransferDetail.tsx +++ b/components/History/components/ValueTransferDetail.tsx @@ -67,6 +67,7 @@ const ValueTransferDetail: React.FunctionComponent = ( const [spendColor, setSpendColor] = useState(colors.primaryDisabled); const [expandTxid, setExpandTxid] = useState(false); const [showNavigator, setShowNavigator] = useState(true); + const [addressProtected, setAddressProtected] = useState(false); const isTheFirstMount = useRef(true); const memoTotal = vt.memos && vt.memos.length > 0 ? vt.memos.join('\n') : ''; @@ -91,6 +92,13 @@ const ValueTransferDetail: React.FunctionComponent = ( setSpendColor(spendCo); }, [colors.primary, colors.primaryDisabled, colors.text, vt.confirmations, vt.kind]); + useEffect(() => { + (async () => { + setAddressProtected(await isAddressProtected(vt.address ? vt.address : '')); + })(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [vt.address]); + const handleTxIDClick = (txid?: string) => { if (!txid) { return; @@ -130,6 +138,11 @@ const ValueTransferDetail: React.FunctionComponent = ( return address.length >= 1; }; + const isAddressProtected: (add: string) => Promise = async (add: string) => { + const zennyTips = await Utils.getZenniesDonationAddress(server.chainName); + return zennyTips === add; + }; + //console.log('vt', index, totalLength, isTheFirstMount); return ( @@ -287,6 +300,7 @@ const ValueTransferDetail: React.FunctionComponent = ( setSendPageState={setSendPageState} closeModal={closeModal} openModal={openModal} + addressProtected={addressProtected} /> )} From f790bee7fbfd4f51b1f7d901f4f11e8fca1cecfb Mon Sep 17 00:00:00 2001 From: JC Date: Fri, 19 Jul 2024 10:38:49 -0600 Subject: [PATCH 04/12] fix: address book fix when you launch the add mode from other component --- components/AddressBook/AddressBook.tsx | 39 +++++++++++++------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/components/AddressBook/AddressBook.tsx b/components/AddressBook/AddressBook.tsx index c27b7740a..f8cdef09a 100644 --- a/components/AddressBook/AddressBook.tsx +++ b/components/AddressBook/AddressBook.tsx @@ -229,24 +229,25 @@ const AddressBook: React.FunctionComponent = ({ closeModal, se alignItems: 'stretch', justifyContent: 'flex-start', }}> - {addressBookProtected.flatMap((aBItem, index) => { - return ( - - - - ); - })} + {!addressBookCurrentAddress && + addressBookProtected.flatMap((aBItem, index) => { + return ( + + + + ); + })} {currentItem === -1 && action !== null && ( = ({ closeModal, se doAction={doAction} /> )} - {addressBookSorted.length === 0 && currentItem !== -1 && ( + {!addressBookCurrentAddress && addressBookSorted.length === 0 && currentItem !== -1 && ( Date: Fri, 19 Jul 2024 11:09:36 -0600 Subject: [PATCH 05/12] fix: sends about zennies for zingo do not have Memo --- app/LoadedApp/LoadedApp.tsx | 4 ++-- app/translations/en.json | 1 - app/translations/es.json | 1 - app/translations/pt.json | 1 - app/translations/ru.json | 1 - app/utils/Utils.ts | 7 +------ components/Send/Send.tsx | 9 +-------- 7 files changed, 4 insertions(+), 20 deletions(-) diff --git a/app/LoadedApp/LoadedApp.tsx b/app/LoadedApp/LoadedApp.tsx index 97ec8d51d..076b408bc 100644 --- a/app/LoadedApp/LoadedApp.tsx +++ b/app/LoadedApp/LoadedApp.tsx @@ -917,8 +917,8 @@ export class LoadedAppClass extends Component void): Promise => { try { // Construct a sendJson from the sendPage state - const { sendPageState, uaAddress, addresses, server, donation, translate } = this.state; - const sendJson = await Utils.getSendManyJSON(sendPageState, uaAddress, addresses, server, donation, translate); + const { sendPageState, uaAddress, addresses, server, donation } = this.state; + const sendJson = await Utils.getSendManyJSON(sendPageState, uaAddress, addresses, server, donation); const txid = await this.rpc.sendTransaction(sendJson, setSendProgress); return txid; diff --git a/app/translations/en.json b/app/translations/en.json index 4a61291ec..08d8ef6c8 100644 --- a/app/translations/en.json +++ b/app/translations/en.json @@ -22,7 +22,6 @@ "menudrawer-acc": "Open Menu Drawer", "menu-acc": "Open Menu", "donation": "Donation to Zingo!\nThanks for supporting ZingoLabs!", - "zennies-donation": "A Zenny for Zingo!\nThanks for supporting ZingoLabs!", "zenny-tips-ab": "Zenny Tips", "nym-donation": "I need Nym network security!", "restarting": "Error connecting to the Server, the App will restart in a few seconds.", diff --git a/app/translations/es.json b/app/translations/es.json index 6778ff0a4..b671b991d 100644 --- a/app/translations/es.json +++ b/app/translations/es.json @@ -22,7 +22,6 @@ "menudrawer-acc": "Abrir Menú Lateral", "menu-acc": "Abrir Menú", "donation": "¡Donación a Zingo!\n¡Gracias por apoyar a ZingoLabs!", - "zennies-donation": "¡Un Zenny para Zingo!\n¡Gracias por apoyar a ZingoLabs!", "zenny-tips-ab": "Zenny Propinas", "nym-donation": "¡Necesito seguridad de red Nym!", "restarting": "Error conectando con el servidor, la Aplicación se reiniciará en breves segundos.", diff --git a/app/translations/pt.json b/app/translations/pt.json index b7d757c9e..da9c7ba33 100644 --- a/app/translations/pt.json +++ b/app/translations/pt.json @@ -22,7 +22,6 @@ "menudrawer-acc": "Abrir Menu Lateral", "menu-acc": "Abrir Menu", "donation": "Doação para o Zingo!\nObrigado por apoiar o ZingoLabs!", - "zennies-donation": "Um Zenny pelo Zingo!\nObrigado por apoiar o ZingoLabs!", "zenny-tips-ab": "Zenny Gorjetas", "nym-donation": "Eu preciso de segurança de rede Nym!", "restarting": "Erro ao conectar ao servidor, o aplicativo será reiniciado em alguns segundos.", diff --git a/app/translations/ru.json b/app/translations/ru.json index 84ec9f655..b6fdcc919 100644 --- a/app/translations/ru.json +++ b/app/translations/ru.json @@ -22,7 +22,6 @@ "menudrawer-acc": "Открыть панель меню", "menu-acc": "Открыть меню", "donation": "Пожертвование в пользу Zingo!\nСпасибо за поддержку ZingoLabs!", - "zennies-donation": "Zenny для Zingo!\nСпасибо за поддержку ZingoLabs!", "zenny-tips-ab": "Zenny советы", "nym-donation": "Мне нужна сетевая безопасность Nym!", "restarting": "Ошибка подключения к Серверу, приложение перезапустится через несколько секунд.", diff --git a/app/utils/Utils.ts b/app/utils/Utils.ts index 65e80d3ae..67d264215 100644 --- a/app/utils/Utils.ts +++ b/app/utils/Utils.ts @@ -145,10 +145,6 @@ export default class Utils { return '0' + decimalSeparator + '01'; } - static getZenniesDonationMemo(translate: (key: string) => TranslateType): string { - return translate('zennies-donation') as string; - } - // NYM static async getNymDonationAddress(chainName: ChainNameEnum): Promise { // donations only for mainnet. @@ -241,7 +237,6 @@ export default class Utils { addresses: AddressClass[], server: ServerType, donation: boolean, - translate: (key: string) => TranslateType, ): Promise { let donationAddress: boolean = false; const json: Promise = Promise.all( @@ -295,7 +290,7 @@ export default class Utils { (Utils.parseStringLocaleToNumberFloat(Utils.getZenniesDonationAmount()) * 10 ** 8).toFixed(0), 10, ), - memo: Utils.getZenniesDonationMemo(translate), + memo: '', // zancas decision to not leak info with no reason. }); } diff --git a/components/Send/Send.tsx b/components/Send/Send.tsx index 373365250..a7afb3a11 100644 --- a/components/Send/Send.tsx +++ b/components/Send/Send.tsx @@ -229,14 +229,7 @@ const Send: React.FunctionComponent = ({ sendPageStateCalculateFee.toaddr.includeUAMemo = includeUAMemo; sendPageStateCalculateFee.toaddr.amount = amount; - sendJson = await Utils.getSendManyJSON( - sendPageStateCalculateFee, - uaAddress, - addresses, - server, - donation, - translate, - ); + sendJson = await Utils.getSendManyJSON(sendPageStateCalculateFee, uaAddress, addresses, server, donation); console.log('SEND', sendJson); } From 82502bd9032883a5eeabce87e309aebb4bbea855 Mon Sep 17 00:00:00 2001 From: JC Date: Mon, 22 Jul 2024 09:58:32 -0600 Subject: [PATCH 06/12] fix: address book - the protected zennies address the last one. --- components/AddressBook/AddressBook.tsx | 62 +++++++++++--------------- 1 file changed, 25 insertions(+), 37 deletions(-) diff --git a/components/AddressBook/AddressBook.tsx b/components/AddressBook/AddressBook.tsx index f8cdef09a..87f7aa2e8 100644 --- a/components/AddressBook/AddressBook.tsx +++ b/components/AddressBook/AddressBook.tsx @@ -71,15 +71,9 @@ const AddressBook: React.FunctionComponent = ({ closeModal, se return addressBook .filter((ab: AddressBookFileClass) => ab.address !== zennyTips) .sort((a, b) => { - const nA = a.label.toUpperCase(); - const nB = b.label.toUpperCase(); - if (nA < nB) { - return -1; - } else if (nA > nB) { - return 1; - } else { - return 0; - } + const aLabel = a.label; + const bLabel = b.label; + return aLabel.localeCompare(bLabel); }) .slice(0, numAb); }, [addressBook, numAb, server.chainName]); @@ -90,15 +84,9 @@ const AddressBook: React.FunctionComponent = ({ closeModal, se return addressBook .filter((ab: AddressBookFileClass) => ab.address === zennyTips) .sort((a, b) => { - const nA = a.label.toUpperCase(); - const nB = b.label.toUpperCase(); - if (nA < nB) { - return -1; - } else if (nA > nB) { - return 1; - } else { - return 0; - } + const aLabel = a.label; + const bLabel = b.label; + return aLabel.localeCompare(bLabel); }); }, [addressBook, server.chainName]); @@ -229,25 +217,6 @@ const AddressBook: React.FunctionComponent = ({ closeModal, se alignItems: 'stretch', justifyContent: 'flex-start', }}> - {!addressBookCurrentAddress && - addressBookProtected.flatMap((aBItem, index) => { - return ( - - - - ); - })} {currentItem === -1 && action !== null && ( = ({ closeModal, se ); })} + {!addressBookCurrentAddress && + addressBookProtected.flatMap((aBItem, index) => { + return ( + + + + ); + })} {loadMoreButton ? ( Date: Tue, 23 Jul 2024 10:50:54 -0600 Subject: [PATCH 07/12] fix: excluding ZFZ address the address book list in send screen --- components/Send/Send.tsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/components/Send/Send.tsx b/components/Send/Send.tsx index a7afb3a11..557089683 100644 --- a/components/Send/Send.tsx +++ b/components/Send/Send.tsx @@ -693,12 +693,17 @@ const Send: React.FunctionComponent = ({ }, [mode, setZecPrice]); useEffect(() => { - const items = addressBook.map((item: AddressBookFileClass) => ({ - label: item.label, - value: item.address, - })); - setItemsPicker(items); - }, [addressBook]); + (async () => { + const zennyTips = await Utils.getZenniesDonationAddress(server.chainName); + const items = addressBook + .filter((item: AddressBookFileClass) => item.address !== zennyTips) + .map((item: AddressBookFileClass) => ({ + label: item.label, + value: item.address, + })); + setItemsPicker(items); + })(); + }, [addressBook, server.chainName]); useEffect(() => { (async () => { From 1d2503b229b976a7a75fcbf0eeb86fdea75af5b6 Mon Sep 17 00:00:00 2001 From: JC Date: Tue, 23 Jul 2024 12:58:11 -0600 Subject: [PATCH 08/12] fix: little adjustment --- components/History/components/ValueTransferDetail.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/History/components/ValueTransferDetail.tsx b/components/History/components/ValueTransferDetail.tsx index 53d5826b4..33dee7de3 100644 --- a/components/History/components/ValueTransferDetail.tsx +++ b/components/History/components/ValueTransferDetail.tsx @@ -67,7 +67,7 @@ const ValueTransferDetail: React.FunctionComponent = ( const [spendColor, setSpendColor] = useState(colors.primaryDisabled); const [expandTxid, setExpandTxid] = useState(false); const [showNavigator, setShowNavigator] = useState(true); - const [addressProtected, setAddressProtected] = useState(false); + const [addressProtected, setAddressProtected] = useState(true); const isTheFirstMount = useRef(true); const memoTotal = vt.memos && vt.memos.length > 0 ? vt.memos.join('\n') : ''; From 0ffb82502d3fee9e200e9d575305770f1cb5d731 Mon Sep 17 00:00:00 2001 From: JC Date: Tue, 23 Jul 2024 13:51:00 -0600 Subject: [PATCH 09/12] fix: send address book list sorted --- components/Send/Send.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/Send/Send.tsx b/components/Send/Send.tsx index 557089683..29c522d91 100644 --- a/components/Send/Send.tsx +++ b/components/Send/Send.tsx @@ -697,6 +697,11 @@ const Send: React.FunctionComponent = ({ const zennyTips = await Utils.getZenniesDonationAddress(server.chainName); const items = addressBook .filter((item: AddressBookFileClass) => item.address !== zennyTips) + .sort((a, b) => { + const aLabel = a.label; + const bLabel = b.label; + return aLabel.localeCompare(bLabel); + }) .map((item: AddressBookFileClass) => ({ label: item.label, value: item.address, From 6b5c677e49846bb4b5cc41d34653d88713aee90f Mon Sep 17 00:00:00 2001 From: JC Date: Tue, 23 Jul 2024 14:44:24 -0600 Subject: [PATCH 10/12] fix: IOS address picker list fixed --- components/Send/Send.tsx | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/components/Send/Send.tsx b/components/Send/Send.tsx index 29c522d91..c95de1e76 100644 --- a/components/Send/Send.tsx +++ b/components/Send/Send.tsx @@ -144,6 +144,7 @@ const Send: React.FunctionComponent = ({ const [spendableBalanceLastError, setSpendableBalanceLastError] = useState(''); const [keyboardVisible, setKeyboardVisible] = useState(false); const [contentHeight, setContentHeight] = useState(0); + const [pickerTempSelectedAddress, setPickerTempSelectedAddress] = useState(''); const isFocused = useIsFocused(); const slideAnim = useSharedValue(0); @@ -1034,12 +1035,18 @@ const Send: React.FunctionComponent = ({ color: colors.primary, }} useNativeAndroidPickerStyle={false} - onValueChange={async (itemValue: string) => { - if (validAddress === 1 && ta.to && itemValue && ta.to !== itemValue) { + onDonePress={async () => { + // only for IOS + if ( + validAddress === 1 && + ta.to && + pickerTempSelectedAddress && + ta.to !== pickerTempSelectedAddress + ) { setUpdatingToField(true); await ShowAddressAlertAsync(translate) .then(() => { - updateToField(itemValue, null, null, null, null); + updateToField(pickerTempSelectedAddress, null, null, null, null); }) .catch(() => { updateToField(ta.to, null, null, null, null); @@ -1047,8 +1054,30 @@ const Send: React.FunctionComponent = ({ setTimeout(() => { setUpdatingToField(false); }, 500); - } else if (ta.to !== itemValue) { - updateToField(itemValue, null, null, null, null); + } else if (ta.to !== pickerTempSelectedAddress) { + updateToField(pickerTempSelectedAddress, null, null, null, null); + } + }} + onValueChange={async (itemValue: string) => { + // only for Android + if (Platform.OS === GlobalConst.platformOSandroid) { + if (validAddress === 1 && ta.to && itemValue && ta.to !== itemValue) { + setUpdatingToField(true); + await ShowAddressAlertAsync(translate) + .then(() => { + updateToField(itemValue, null, null, null, null); + }) + .catch(() => { + updateToField(ta.to, null, null, null, null); + }); + setTimeout(() => { + setUpdatingToField(false); + }, 500); + } else if (ta.to !== itemValue) { + updateToField(itemValue, null, null, null, null); + } + } else { + setPickerTempSelectedAddress(itemValue); } }}> Date: Tue, 23 Jul 2024 15:12:56 -0600 Subject: [PATCH 11/12] fix: IOS address selection fixed --- components/Send/Send.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/Send/Send.tsx b/components/Send/Send.tsx index c95de1e76..1fe9b5b41 100644 --- a/components/Send/Send.tsx +++ b/components/Send/Send.tsx @@ -1027,7 +1027,7 @@ const Send: React.FunctionComponent = ({ {!updatingToField ? ( = ({ } else if (ta.to !== pickerTempSelectedAddress) { updateToField(pickerTempSelectedAddress, null, null, null, null); } + setPickerTempSelectedAddress(''); }} onValueChange={async (itemValue: string) => { // only for Android @@ -1693,6 +1694,7 @@ const Send: React.FunctionComponent = ({ defaultValueFee(); defaultValuesSpendableMaxAmount(); clearToAddr(); + setPickerTempSelectedAddress(''); }} /> From 504cdb29a613b2f476260530a0f81b4f9c08e432 Mon Sep 17 00:00:00 2001 From: JC Date: Tue, 23 Jul 2024 15:17:19 -0600 Subject: [PATCH 12/12] fix: lint format fixed --- components/Send/Send.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/Send/Send.tsx b/components/Send/Send.tsx index 1fe9b5b41..06704964d 100644 --- a/components/Send/Send.tsx +++ b/components/Send/Send.tsx @@ -1027,7 +1027,11 @@ const Send: React.FunctionComponent = ({ {!updatingToField ? (