Skip to content

Commit

Permalink
Merge branch 'hotfix/address-book-validate' into feature/2.7.1-union
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-zhaolei committed Jan 6, 2025
2 parents 31535ce + 40b6960 commit 2b4b8c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}$" },
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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
{
Expand All @@ -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]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 2b4b8c7

Please sign in to comment.