From 3268fedb3dd6700553493bc69e1de2eda90e2a9b Mon Sep 17 00:00:00 2001 From: Aasim Khan Date: Wed, 21 Feb 2024 18:20:14 +0400 Subject: [PATCH] fix: Added extra slash truncation from the string `uri` of block explorer --- .../mirai_web3/lib/services/web_modal_service.dart | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/mirai_web3/lib/services/web_modal_service.dart b/packages/mirai_web3/lib/services/web_modal_service.dart index ed554399..234acfc3 100644 --- a/packages/mirai_web3/lib/services/web_modal_service.dart +++ b/packages/mirai_web3/lib/services/web_modal_service.dart @@ -328,7 +328,7 @@ class Web3ModalService { tokenName: contractToken.name, timestamp: "", explorer: Uri.https( - "${_service.selectedChain?.blockExplorer?.url}/tx/${l.blockHash}"), + "${_service.selectedChain?.blockExplorer?.url.truncatedSlash}/tx/${l.blockHash}"), ), ); } @@ -364,3 +364,15 @@ class Web3ModalService { await _service.disconnect(); } } + +extension StringExt on String? { + String get truncatedSlash { + if (this == null || this!.isEmpty) { + return W3MChainPresets.chains['1']?.blockExplorer?.url ?? ''; + } else if (this!.endsWith('/')) { + return this!.substring(0, (this!.length) - 1); + } else { + return this!; + } + } +}