File tree Expand file tree Collapse file tree 3 files changed +35
-4
lines changed Expand file tree Collapse file tree 3 files changed +35
-4
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @snapshot-labs/snapshot.js" ,
3
- "version" : " 0.12.2 " ,
3
+ "version" : " 0.12.3 " ,
4
4
"repository" : " snapshot-labs/snapshot.js" ,
5
5
"license" : " MIT" ,
6
6
"main" : " dist/snapshot.cjs.js" ,
Original file line number Diff line number Diff line change 5
5
validateSchema ,
6
6
getScores ,
7
7
getVp ,
8
- getFormattedAddress
8
+ getFormattedAddress ,
9
+ getEnsOwner ,
10
+ getEnsTextRecord
9
11
} from './utils' ;
10
12
11
13
vi . mock ( 'cross-fetch' , async ( ) => {
@@ -611,4 +613,18 @@ describe('utils', () => {
611
613
expect ( result ) . not . toBe ( true ) ;
612
614
} ) ;
613
615
} ) ;
616
+
617
+ describe ( 'getEnsOwner' , ( ) => {
618
+ test ( 'should return null when the ENS is not valid' , ( ) => {
619
+ // special hidden characters after the k
620
+ expect ( getEnsOwner ( 'elonmusk.eth' ) ) . resolves . toBe ( null ) ;
621
+ } ) ;
622
+ } ) ;
623
+
624
+ describe ( 'getEnsTextRecord' , ( ) => {
625
+ test ( 'should return null when the ENS is not valid' , ( ) => {
626
+ // special hidden characters after the k
627
+ expect ( getEnsTextRecord ( 'elonmusk.eth' ) ) . resolves . toBe ( null ) ;
628
+ } ) ;
629
+ } ) ;
614
630
} ) ;
Original file line number Diff line number Diff line change @@ -544,7 +544,14 @@ export async function getEnsTextRecord(
544
544
...multicallOptions
545
545
} = options ;
546
546
547
- const ensHash = namehash ( ensNormalize ( ens ) ) ;
547
+ let ensHash : string ;
548
+
549
+ try {
550
+ ensHash = namehash ( ensNormalize ( ens ) ) ;
551
+ } catch ( e : any ) {
552
+ return null ;
553
+ }
554
+
548
555
const provider = getProvider ( network , { broviderUrl } ) ;
549
556
550
557
const calls = [
@@ -592,9 +599,17 @@ export async function getEnsOwner(
592
599
[ 'function owner(bytes32) view returns (address)' ] ,
593
600
provider
594
601
) ;
602
+
603
+ let ensHash : string ;
604
+
605
+ try {
606
+ ensHash = namehash ( ensNormalize ( ens ) ) ;
607
+ } catch ( e : any ) {
608
+ return null ;
609
+ }
610
+
595
611
const ensNameWrapper =
596
612
options . ensNameWrapper || networks [ network ] . ensNameWrapper ;
597
- const ensHash = namehash ( ensNormalize ( ens ) ) ;
598
613
let owner = await ensRegistry . owner ( ensHash ) ;
599
614
// If owner is the ENSNameWrapper contract, resolve the owner of the name
600
615
if ( owner === ensNameWrapper ) {
You can’t perform that action at this time.
0 commit comments