From 40b6960fdb5d7fcae66ee22c111f13535bf31fcd Mon Sep 17 00:00:00 2001 From: felix-zhaolei Date: Mon, 6 Jan 2025 10:29:34 +0800 Subject: [PATCH] fix: TBSC address validate. --- .../Commons/ShiftChainHelper.cs | 9 +++++---- .../AddressBook/AddressBookAppService.cs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/CAServer.Application.Contracts/Commons/ShiftChainHelper.cs b/src/CAServer.Application.Contracts/Commons/ShiftChainHelper.cs index e9df4a9e1..181efe0b6 100644 --- a/src/CAServer.Application.Contracts/Commons/ShiftChainHelper.cs +++ b/src/CAServer.Application.Contracts/Commons/ShiftChainHelper.cs @@ -111,6 +111,7 @@ public static string FormatEBridgeChain(string chain) { "SETH", "^0x[a-fA-F0-9]{40}$" }, { "ETH", "^0x[a-fA-F0-9]{40}$" }, { "BSC", "^0x[a-fA-F0-9]{40}$" }, + { "TBSC", "^0x[a-fA-F0-9]{40}$" }, { "ARBITRUM", "^0x[a-fA-F0-9]{40}$" }, { "MATIC", "^0x[a-fA-F0-9]{40}$" }, { "OPTIMISM", "^0x[a-fA-F0-9]{40}$" }, @@ -165,7 +166,7 @@ public static AddressFormat GetAddressFormat(string fromChain, string address) { if (address.Contains(CommonConstant.Underline) && address.StartsWith(CommonConstant.ELF)) { - if (!IsAelfAddress(AddressHelper.ToShortAddress(address))) + if (!VerifyAelfAddress(AddressHelper.ToShortAddress(address))) { return AddressFormat.NoSupport; } @@ -181,7 +182,7 @@ public static AddressFormat GetAddressFormat(string fromChain, string address) return AddressFormat.NoSupport; } - if (IsAelfAddress(address)) + if (VerifyAelfAddress(address)) { return fromChain == CommonConstant.MainChainId ? AddressFormat.Main : AddressFormat.Dapp; } @@ -216,7 +217,7 @@ public static string ExtractAddress(string addressSuffix) .FirstOrDefault(p => p.Length == 50) ?? addressSuffix; } - public static bool IsAelfAddress(string address) + public static bool VerifyAelfAddress(string address) { try { @@ -242,7 +243,7 @@ public static bool VerifyAddress(string chain, string address) if(chain is CommonConstant.MainChainId or CommonConstant.TDVVChainId or CommonConstant.TDVWChainId) { - return AElf.AddressHelper.VerifyFormattedAddress(address); + return VerifyAelfAddress(address); } return !NetworkPatternMap.ContainsKey(chain) || Regex.IsMatch(address, NetworkPatternMap[chain]); diff --git a/src/CAServer.Application/AddressBook/AddressBookAppService.cs b/src/CAServer.Application/AddressBook/AddressBookAppService.cs index 90b5c8c25..e291e8c33 100644 --- a/src/CAServer.Application/AddressBook/AddressBookAppService.cs +++ b/src/CAServer.Application/AddressBook/AddressBookAppService.cs @@ -261,7 +261,7 @@ private async Task CheckSelfAsync(Guid userId, string address) private bool ValidateAddress(string network, string address) { return network == CommonConstant.ChainName - ? ShiftChainHelper.IsAelfAddress(AddressHelper.ToShortAddress(address)) + ? ShiftChainHelper.VerifyAelfAddress(AddressHelper.ToShortAddress(address)) : ShiftChainHelper.VerifyAddress(network, address); }