Skip to content

Commit d16b9e8

Browse files
j0ntzJon Tzeng
authored andcommitted
Accept ".zec" ZNS
1 parent c8be8f0 commit d16b9e8

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## 4.48.1 (2026-04-28)
66

7-
- added: Resolve and display ZcashNames (.zcash) in the Zcash send flow and transaction history.
7+
- added: Resolve and display ZNS names (.zcash/.zec) in the Zcash send flow and transaction history.
88
- changed: Remove free FIO handle creation flows.
99
- changed: Migrate Thorchain Savers and Thorchain Yield endpoints off NineRealms to gateway.liquify.com.
1010

src/util/zns.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { ZNS } from 'zcashname-sdk'
22

3+
// Canonical suffix used when rendering a name resolved from an address.
34
export const ZNS_SUFFIX = '.zcash'
45

6+
// All suffixes accepted as ZNS input. Order matters for `stripZnsSuffix`:
7+
// longer suffixes must be checked first so that e.g. ".zcash" is preferred
8+
// over a hypothetical ".z" prefix-match.
9+
const ZNS_INPUT_SUFFIXES = ['.zcash', '.zec'] as const
10+
511
// The SDK's `network` option only selects the registry address; its `url`
612
// always falls back to the testnet indexer unless overridden explicitly.
713
const ZNS_MAINNET_URL = 'https://main.zcashnames.com'
@@ -17,14 +23,18 @@ export const resetZnsClient = (): void => {
1723
znsClient = null
1824
}
1925

20-
export const isZnsName = (input: string): boolean =>
21-
input.toLowerCase().endsWith(ZNS_SUFFIX)
26+
export const isZnsName = (input: string): boolean => {
27+
const lower = input.toLowerCase()
28+
return ZNS_INPUT_SUFFIXES.some(suffix => lower.endsWith(suffix))
29+
}
2230

2331
export const stripZnsSuffix = (input: string): string => {
2432
const lower = input.toLowerCase()
25-
return lower.endsWith(ZNS_SUFFIX)
26-
? lower.slice(0, lower.length - ZNS_SUFFIX.length)
27-
: lower
33+
for (const suffix of ZNS_INPUT_SUFFIXES) {
34+
if (lower.endsWith(suffix))
35+
return lower.slice(0, lower.length - suffix.length)
36+
}
37+
return lower
2838
}
2939

3040
export const resolveZnsName = async (input: string): Promise<string | null> => {

0 commit comments

Comments
 (0)