From a603e9db315b8d1b25d9a9d7903db7246b8f03c7 Mon Sep 17 00:00:00 2001 From: JC Date: Sat, 3 Aug 2024 12:14:40 -0600 Subject: [PATCH] fix: shield txid button & keyb txs navigator --- native/Cargo.lock | 120 +++++++++++------- src/components/dashboard/Dashboard.tsx | 33 ++++- src/components/history/components/VtModal.tsx | 32 +++-- .../receive/components/AddressBlock.tsx | 59 ++++++--- .../send/components/ConfirmModal.tsx | 12 +- src/components/sidebar/Sidebar.tsx | 2 +- src/utils/utils.ts | 26 +++- 7 files changed, 193 insertions(+), 91 deletions(-) diff --git a/native/Cargo.lock b/native/Cargo.lock index e4096379..c801fe41 100644 --- a/native/Cargo.lock +++ b/native/Cargo.lock @@ -145,7 +145,7 @@ dependencies = [ "async-trait", "axum-core", "bitflags 1.3.2", - "bytes 1.6.1", + "bytes 1.7.1", "futures-util", "http 0.2.12", "http-body 0.4.6", @@ -171,7 +171,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" dependencies = [ "async-trait", - "bytes 1.6.1", + "bytes 1.7.1", "futures-util", "http 0.2.12", "http-body 0.4.6", @@ -398,9 +398,9 @@ dependencies = [ [[package]] name = "bytes" -version = "1.6.1" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "cbc" @@ -413,9 +413,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" +checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" [[package]] name = "cfg-if" @@ -914,13 +914,13 @@ version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ - "bytes 1.6.1", + "bytes 1.7.1", "fnv", "futures-core", "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.2.6", + "indexmap 2.3.0", "slab", "tokio", "tokio-util", @@ -934,12 +934,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" dependencies = [ "atomic-waker", - "bytes 1.6.1", + "bytes 1.7.1", "fnv", "futures-core", "futures-sink", "http 1.1.0", - "indexmap 2.2.6", + "indexmap 2.3.0", "slab", "tokio", "tokio-util", @@ -1053,7 +1053,7 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ - "bytes 1.6.1", + "bytes 1.7.1", "fnv", "itoa", ] @@ -1064,7 +1064,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ - "bytes 1.6.1", + "bytes 1.7.1", "fnv", "itoa", ] @@ -1075,7 +1075,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ - "bytes 1.6.1", + "bytes 1.7.1", "http 0.2.12", "pin-project-lite", ] @@ -1086,7 +1086,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ - "bytes 1.6.1", + "bytes 1.7.1", "http 1.1.0", ] @@ -1096,7 +1096,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ - "bytes 1.6.1", + "bytes 1.7.1", "futures-util", "http 1.1.0", "http-body 1.0.1", @@ -1127,7 +1127,7 @@ version = "0.14.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" dependencies = [ - "bytes 1.6.1", + "bytes 1.7.1", "futures-channel", "futures-core", "futures-util", @@ -1151,7 +1151,7 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ - "bytes 1.6.1", + "bytes 1.7.1", "futures-channel", "futures-util", "h2 0.4.5", @@ -1198,7 +1198,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ - "bytes 1.6.1", + "bytes 1.7.1", "http-body-util", "hyper 1.4.1", "hyper-util", @@ -1214,7 +1214,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" dependencies = [ - "bytes 1.6.1", + "bytes 1.7.1", "futures-channel", "futures-util", "http 1.1.0", @@ -1285,9 +1285,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -1878,7 +1878,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.2.6", + "indexmap 2.3.0", ] [[package]] @@ -1938,9 +1938,12 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "prettyplease" @@ -2011,7 +2014,7 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ - "bytes 1.6.1", + "bytes 1.7.1", "prost-derive", ] @@ -2021,7 +2024,7 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ - "bytes 1.6.1", + "bytes 1.7.1", "heck", "itertools", "log", @@ -2228,9 +2231,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.5" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -2271,7 +2274,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" dependencies = [ "base64 0.22.1", - "bytes 1.6.1", + "bytes 1.7.1", "encoding_rs", "futures-core", "futures-util", @@ -2290,7 +2293,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls-pemfile 2.1.2", + "rustls-pemfile 2.1.3", "serde", "serde_json", "serde_urlencoded", @@ -2456,9 +2459,9 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" dependencies = [ "base64 0.22.1", "rustls-pki-types", @@ -2667,9 +2670,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.121" +version = "1.0.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" +checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" dependencies = [ "itoa", "memchr", @@ -2695,7 +2698,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.3.0", "itoa", "ryu", "serde", @@ -2883,12 +2886,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.10.1" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", "windows-sys 0.52.0", ] @@ -3007,7 +3011,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" dependencies = [ "backtrace", - "bytes 1.6.1", + "bytes 1.7.1", "libc", "mio", "parking_lot", @@ -3087,7 +3091,7 @@ version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ - "bytes 1.6.1", + "bytes 1.7.1", "futures-core", "futures-sink", "pin-project-lite", @@ -3104,7 +3108,7 @@ dependencies = [ "async-trait", "axum", "base64 0.21.7", - "bytes 1.6.1", + "bytes 1.7.1", "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", @@ -3530,11 +3534,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3570,6 +3574,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -3898,6 +3911,27 @@ dependencies = [ "blake2b_simd", ] +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "zeroize" version = "1.8.1" diff --git a/src/components/dashboard/Dashboard.tsx b/src/components/dashboard/Dashboard.tsx index b6571158..05ccf353 100644 --- a/src/components/dashboard/Dashboard.tsx +++ b/src/components/dashboard/Dashboard.tsx @@ -36,7 +36,7 @@ const Dashboard: React.FC = ({shieldTransparentBalanceToOrchard, })(); } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [totalBalance.transparent]); + }, [totalBalance.transparent, anyPending]); const shieldButton = () => { openErrorModal("Computing Transaction", "Please wait...This could take a while"); @@ -55,14 +55,41 @@ const Dashboard: React.FC = ({shieldTransparentBalanceToOrchard, if (resultJSON.txids) { openErrorModal( "Successfully Broadcast Transaction", - `Transaction was successfully broadcast.\n${resultJSON.txids.length === 1 ? 'TXID' : "TXID's"}: ${resultJSON.txids.join(', ')}` +
+
+
{(resultJSON.txids.length === 1 ? 'Transaction was' : 'Transactions were') + ' successfully broadcast.'}
+
{`TXID: ${resultJSON.txids[0]}`}
+ {resultJSON.txids.length > 1 && ( +
{`TXID: ${resultJSON.txids[1]}`}
+ )} + {resultJSON.txids.length > 2 && ( +
{`TXID: ${resultJSON.txids[2]}`}
+ )} +
+
Utils.openTxid(resultJSON.txids[0], info.currencyName)}> + View TXID   + +
+ {resultJSON.txids.length > 1 && ( +
Utils.openTxid(resultJSON.txids[1], info.currencyName)}> + View TXID   + +
+ )} + {resultJSON.txids.length > 2 && ( +
Utils.openTxid(resultJSON.txids[2], info.currencyName)}> + View TXID   + +
+ )} +
); } if (resultJSON.error) { openErrorModal("Error Shielding Transaction", `${resultJSON.error}`); } } catch (err) { - // If there was an error, show the error modal + // If there was an error, show the error modal openErrorModal("Error Shielding Transaction", `${err}`); } })(); diff --git a/src/components/history/components/VtModal.tsx b/src/components/history/components/VtModal.tsx index a9a4a853..ea195768 100644 --- a/src/components/history/components/VtModal.tsx +++ b/src/components/history/components/VtModal.tsx @@ -12,8 +12,6 @@ import routes from "../../../constants/routes.json"; import { ContextApp } from "../../../context/ContextAppState"; const { clipboard } = window.require("electron"); -const { shell } = window.require("electron"); - type VtModalInternalProps = { index: number; length: number; @@ -61,6 +59,25 @@ const VtModalInternal: React.FC = ({ // eslint-disable-next-line react-hooks/exhaustive-deps }, [totalLength]); + const handleKeyDown = (event: any) => { + if (event.key === 'ArrowUp') { + // Mover a la transacción anterior + moveValueTransferDetail(index, -1); + } else if (event.key === 'ArrowDown') { + // Mover a la siguiente transacción + moveValueTransferDetail(index, 1); + } + }; + + useEffect(() => { + // Suscribirse al evento de teclado cuando el componente se monta + window.addEventListener('keydown', handleKeyDown); + return () => { + // Limpiar el evento cuando el componente se desmonta + window.removeEventListener('keydown', handleKeyDown); + }; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [index]); let txid: string = ""; let type: 'sent' | 'received' | 'send-to-self' | 'memo-to-self' | 'shield' | "" = ""; @@ -128,15 +145,6 @@ const VtModalInternal: React.FC = ({ } } - - const openTxid = (txid: string) => { - if (currencyName === "TAZ") { - shell.openExternal(`https://testnet.zcashexplorer.app/transactions/${txid}`); - } else { - shell.openExternal(`https://mainnet.zcashexplorer.app/transactions/${txid}`); - } - }; - const doReply = (address: string) => { setSendTo(new ZcashURITarget(address, undefined, undefined)); setExpandAddress(false); @@ -250,7 +258,7 @@ const VtModalInternal: React.FC = ({ )} -
openTxid(txid)}> +
Utils.openTxid(txid, currencyName)}> View TXID  
diff --git a/src/components/receive/components/AddressBlock.tsx b/src/components/receive/components/AddressBlock.tsx index dda42ed9..2acc138c 100644 --- a/src/components/receive/components/AddressBlock.tsx +++ b/src/components/receive/components/AddressBlock.tsx @@ -12,7 +12,7 @@ import Utils from "../../../utils/utils"; import { Address, AddressType } from "../../appstate"; import { ContextApp } from "../../../context/ContextAppState"; -const { shell, clipboard } = window.require("electron"); +const { clipboard } = window.require("electron"); type AddressBlockProps = { address: Address; @@ -25,7 +25,7 @@ type AddressBlockProps = { fetchAndSetSingleViewKey: (k: string) => void; shieldTransparentBalanceToOrchard?: () => Promise; calculateShieldFee?: () => Promise; - openErrorModal?: (title: string, body: string) => void; + openErrorModal?: (title: string, body: string | JSX.Element) => void; }; const AddressBlock: React.FC = ({ @@ -42,7 +42,7 @@ const AddressBlock: React.FC = ({ openErrorModal, }) => { const context = useContext(ContextApp); - const { readOnly } = context; + const { readOnly, addresses } = context; const { receivers, type } = address; const address_address = address.address; const balance = address.balance || 0; @@ -50,6 +50,8 @@ const AddressBlock: React.FC = ({ const [copied, setCopied] = useState(false); const [timerID, setTimerID] = useState(null); const [shieldFee, setShieldFee] = useState(0); + const [anyPending, setAnyPending] = useState(false); + useEffect(() => { return () => { @@ -59,25 +61,19 @@ const AddressBlock: React.FC = ({ }; }); + useEffect(() => { + const _anyPending: Address | undefined = !!addresses && addresses.find((i: Address) => i.containsPending === true); + setAnyPending(!!_anyPending); + }, [addresses]); + useEffect(() => { if (type === AddressType.transparent && calculateShieldFee && balance > 0) { (async () => { setShieldFee(await calculateShieldFee()); })(); } - }, [balance, calculateShieldFee, type]); - - const openAddress = () => { - if (currencyName === "TAZ") { - shell.openExternal(`https://testnet.zcashexplorer.app/address/${address_address}`); - } else { - if (address_address.startsWith('u')) { - shell.openExternal(`https://mainnet.zcashexplorer.app/ua/${address_address}`); - } else { - shell.openExternal(`https://mainnet.zcashexplorer.app/address/${address_address}`); - } - } - }; + }, [balance, calculateShieldFee, type, anyPending]); + const shieldButton = () => { if (!shieldTransparentBalanceToOrchard || !openErrorModal) { @@ -99,7 +95,34 @@ const AddressBlock: React.FC = ({ if (resultJSON.txids) { openErrorModal( "Successfully Broadcast Transaction", - `Transaction was successfully broadcast.\n${resultJSON.txids.length === 1 ? 'TXID' : "TXID's"}: ${resultJSON.txids.join(', ')}` +
+
+
{(resultJSON.txids.length === 1 ? 'Transaction was' : 'Transactions were') + ' successfully broadcast.'}
+
{`TXID: ${resultJSON.txids[0]}`}
+ {resultJSON.txids.length > 1 && ( +
{`TXID: ${resultJSON.txids[1]}`}
+ )} + {resultJSON.txids.length > 2 && ( +
{`TXID: ${resultJSON.txids[2]}`}
+ )} +
+
Utils.openTxid(resultJSON.txids[0], currencyName)}> + View TXID   + +
+ {resultJSON.txids.length > 1 && ( +
Utils.openTxid(resultJSON.txids[1], currencyName)}> + View TXID   + +
+ )} + {resultJSON.txids.length > 2 && ( +
Utils.openTxid(resultJSON.txids[2], currencyName)}> + View TXID   + +
+ )} +
); } if (resultJSON.error) { @@ -222,7 +245,7 @@ const AddressBlock: React.FC = ({ )} */} - {type === AddressType.transparent && balance >= shieldFee && shieldFee > 0 && !readOnly && ( diff --git a/src/components/send/components/ConfirmModal.tsx b/src/components/send/components/ConfirmModal.tsx index cfa426d0..8ff7d2ee 100644 --- a/src/components/send/components/ConfirmModal.tsx +++ b/src/components/send/components/ConfirmModal.tsx @@ -18,8 +18,6 @@ import ConfirmModalToAddr from "./ConfirmModalToAddr"; import native from "../../../native.node"; -const { shell } = window.require("electron"); - // Internal because we're using withRouter just below type ConfirmModalProps = { sendPageState: SendPageState; @@ -168,14 +166,6 @@ type ConfirmModalProps = { })(); },[getPrivacyLevel, sendFee, sendPageState.toaddrs]); - const openTxid = (txid: string) => { - if (currencyName === "TAZ") { - shell.openExternal(`https://testnet.zcashexplorer.app/transactions/${txid}`); - } else { - shell.openExternal(`https://mainnet.zcashexplorer.app/transactions/${txid}`); - } - }; - const sendButton = () => { // First, close the confirm modal. closeModal(); @@ -208,7 +198,7 @@ type ConfirmModalProps = {
{'Transaction was successfully broadcast.'}
{`TXID: ${txid}`}
-
openTxid(txid)}> +
Utils.openTxid(txid, currencyName)}> View TXID  
diff --git a/src/components/sidebar/Sidebar.tsx b/src/components/sidebar/Sidebar.tsx index 4187032b..f9348a4b 100644 --- a/src/components/sidebar/Sidebar.tsx +++ b/src/components/sidebar/Sidebar.tsx @@ -27,7 +27,7 @@ type SidebarProps = { setSendTo: (targets: ZcashURITarget[] | ZcashURITarget) => void; getPrivKeyAsString: (address: string) => Promise; importPrivKeys: (keys: string[], birthday: string) => boolean; - openErrorModal: (title: string, body: string | ReactElement) => void; + openErrorModal: (title: string, body: string | JSX.Element) => void; openPassword: ( confirmNeeded: boolean, passwordCallback: (p: string) => void, diff --git a/src/utils/utils.ts b/src/utils/utils.ts index d1c5d6ec..1cf7cbe4 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -5,10 +5,9 @@ import native from "../native.node"; export const NO_CONNECTION: string = "Could not connect to zcashd"; +const { shell } = window.require("electron"); + export default class Utils { - static ZCASH_COMMUNITY: string = "https://mainnet.lightwalletd.com:9067"; - //static ZEBRA: string = "https://zebra-lwd.zecwallet.co:9067"; - static V3_LIGHTWALLETD: string = "https://lwdv3.zecwallet.co:443"; static trimToSmall(addr?: string, numChars?: number): string { if (!addr) { @@ -207,4 +206,25 @@ export default class Utils { return colorList; } + + static openTxid = (txid: string, currencyName: string) => { + if (currencyName === "TAZ") { + shell.openExternal(`https://testnet.zcashexplorer.app/transactions/${txid}`); + } else { + shell.openExternal(`https://mainnet.zcashexplorer.app/transactions/${txid}`); + } + } + + static openAddress = (address: string, currencyName: string) => { + if (currencyName === "TAZ") { + shell.openExternal(`https://testnet.zcashexplorer.app/address/${address}`); + } else { + if (address.startsWith('u')) { + shell.openExternal(`https://mainnet.zcashexplorer.app/ua/${address}`); + } else { + shell.openExternal(`https://mainnet.zcashexplorer.app/address/${address}`); + } + } + } + }