@@ -20,7 +20,10 @@ import {
20
20
idFromAddress ,
21
21
delegatedFromEthAddress ,
22
22
ethAddressFromDelegated ,
23
- ethAddressFromID
23
+ ethAddressFromID ,
24
+ idFromEthAddress ,
25
+ isEthIdMaskAddress ,
26
+ isEthAddress
24
27
} from '../index'
25
28
26
29
describe ( 'address' , ( ) => {
@@ -331,38 +334,92 @@ describe('address', () => {
331
334
} )
332
335
} )
333
336
334
- const hex = '0x52963EF50e27e06D72D59fcB4F3c2a687BE3cfEf'
335
- const del = 't410fkkld55ioe7qg24wvt7fu6pbknb56ht7pt4zamxa'
336
-
337
- describe ( 'decode f4 addresses' , ( ) => {
338
- expect ( decode ( del ) . toString ( ) ) . toBe ( del )
339
- } )
340
-
341
- describe ( 'delegatedFromEthAddress' , ( ) => {
342
- expect ( delegatedFromEthAddress ( hex , CoinType . TEST ) ) . toBe ( del )
343
- } )
344
-
345
- describe ( 'ethAddressFromDelegated' , ( ) => {
346
- expect ( ethAddressFromDelegated ( del ) ) . toBe ( hex )
347
- } )
348
-
349
- describe ( 'ethAddressFromID' , ( ) => {
350
- expect ( ethAddressFromID ( 't01' ) ) . toBe (
351
- '0xff00000000000000000000000000000000000001'
352
- )
353
- expect ( ethAddressFromID ( 't0100' ) ) . toBe (
354
- '0xff00000000000000000000000000000000000064'
355
- )
356
- expect ( ethAddressFromID ( 't05088' ) ) . toBe (
357
- '0xff000000000000000000000000000000000013e0'
358
- )
359
- } )
360
-
361
- test ( 'it should validate correct filecoin addresses' , ( ) => {
362
- expect ( validateAddressString ( del ) ) . toBe ( true )
363
- } )
364
-
365
- test ( 'it should invalidate incorrect filecoin addresses' , ( ) => {
366
- expect ( validateAddressString ( del . slice ( 0 , - 1 ) ) ) . toBe ( false )
337
+ describe ( 'FEVM' , ( ) => {
338
+ const eth = '0x52963EF50e27e06D72D59fcB4F3c2a687BE3cfEf'
339
+ const ethId01 = '0xff00000000000000000000000000000000000001'
340
+ const ethId0100 = '0xff00000000000000000000000000000000000064'
341
+ const ethId05088 = '0xff000000000000000000000000000000000013e0'
342
+ const ethInvalid = '0x8Ba1f109551bD432803012645Ac136ddd64DBa72'
343
+ const ethIcap = 'XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36'
344
+ const t01 = 't01'
345
+ const t0100 = 't0100'
346
+ const t05088 = 't05088'
347
+ const t1 = 't16xlkjp3dcfrsb257duoqfgj7glo2uvvgxyy4gmy'
348
+ const t2 = 't2e467euxin5y6vsmiw4ts3l4cme4zio4cvfx5b5a'
349
+ const t3 =
350
+ 't3vvmn62lofvhjd2ugzca6sof2j2ubwok6cj4xxbfzz4yuxfkgobpihhd2thlanmsh3w2ptld2gqkn2jvlss4a'
351
+ const t410f = 't410fkkld55ioe7qg24wvt7fu6pbknb56ht7pt4zamxa'
352
+ const t410fIdMask = 't410f74aaaaaaaaaaaaaaaaaaaaaaaaaaaaabvo5mkdi'
353
+ const t410fShort = 't410fkkld55ioe7qg24wvt7fu6pbkndgcenb6'
354
+ const t410fLong = 't410fkkld55ioe7qg24wvt7fu6pbknb56ht7pebagbaf3x4ox2'
355
+ const t411f = 't411fkkld55ioe7qg24wvt7fu6pbknb56ht7poxmy4mq'
356
+
357
+ test ( 'decode f4 addresses' , ( ) => {
358
+ expect ( decode ( t410f ) . toString ( ) ) . toBe ( t410f )
359
+ } )
360
+
361
+ test ( 'delegatedFromEthAddress' , ( ) => {
362
+ expect ( delegatedFromEthAddress ( eth , CoinType . TEST ) ) . toBe ( t410f )
363
+ expect ( ( ) => delegatedFromEthAddress ( ethId01 , CoinType . TEST ) ) . toThrow ( )
364
+ } )
365
+
366
+ test ( 'ethAddressFromDelegated' , ( ) => {
367
+ expect ( ( ) => ethAddressFromDelegated ( eth ) ) . toThrow ( )
368
+ expect ( ( ) => ethAddressFromDelegated ( t01 ) ) . toThrow ( )
369
+ expect ( ( ) => ethAddressFromDelegated ( t1 ) ) . toThrow ( )
370
+ expect ( ( ) => ethAddressFromDelegated ( t2 ) ) . toThrow ( )
371
+ expect ( ( ) => ethAddressFromDelegated ( t3 ) ) . toThrow ( )
372
+ expect ( ethAddressFromDelegated ( t410f ) ) . toBe ( eth )
373
+ expect ( ( ) => ethAddressFromDelegated ( t410fIdMask ) ) . toThrow ( )
374
+ expect ( ( ) => ethAddressFromDelegated ( t410fShort ) ) . toThrow ( )
375
+ expect ( ( ) => ethAddressFromDelegated ( t410fLong ) ) . toThrow ( )
376
+ expect ( ( ) => ethAddressFromDelegated ( t411f ) ) . toThrow ( )
377
+ } )
378
+
379
+ test ( 'isEthAddress' , ( ) => {
380
+ expect ( isEthAddress ( eth ) ) . toBe ( true )
381
+ expect ( isEthAddress ( ethId01 ) ) . toBe ( true )
382
+ expect ( isEthAddress ( ethId0100 ) ) . toBe ( true )
383
+ expect ( isEthAddress ( ethId05088 ) ) . toBe ( true )
384
+ expect ( isEthAddress ( ethInvalid ) ) . toBe ( false )
385
+ expect ( isEthAddress ( ethIcap ) ) . toBe ( false )
386
+ expect ( isEthAddress ( t01 ) ) . toBe ( false )
387
+ expect ( isEthAddress ( t1 ) ) . toBe ( false )
388
+ expect ( isEthAddress ( t2 ) ) . toBe ( false )
389
+ expect ( isEthAddress ( t3 ) ) . toBe ( false )
390
+ expect ( isEthAddress ( t410f ) ) . toBe ( false )
391
+ } )
392
+
393
+ test ( 'isEthIdMaskAddress' , ( ) => {
394
+ expect ( isEthIdMaskAddress ( eth ) ) . toBe ( false )
395
+ expect ( isEthIdMaskAddress ( ethId01 ) ) . toBe ( true )
396
+ expect ( isEthIdMaskAddress ( ethId0100 ) ) . toBe ( true )
397
+ expect ( isEthIdMaskAddress ( ethId05088 ) ) . toBe ( true )
398
+ } )
399
+
400
+ test ( 'idFromEthAddress' , ( ) => {
401
+ expect ( ( ) => idFromEthAddress ( eth , CoinType . TEST ) ) . toThrow ( )
402
+ expect ( idFromEthAddress ( ethId01 , CoinType . TEST ) ) . toBe ( t01 )
403
+ expect ( idFromEthAddress ( ethId0100 , CoinType . TEST ) ) . toBe ( t0100 )
404
+ expect ( idFromEthAddress ( ethId05088 , CoinType . TEST ) ) . toBe ( t05088 )
405
+ } )
406
+
407
+ test ( 'ethAddressFromID' , ( ) => {
408
+ expect ( ethAddressFromID ( t01 ) ) . toBe ( ethId01 )
409
+ expect ( ethAddressFromID ( t0100 ) ) . toBe ( ethId0100 )
410
+ expect ( ethAddressFromID ( t05088 ) ) . toBe ( ethId05088 )
411
+ expect ( ( ) => ethAddressFromID ( t1 ) ) . toThrow ( )
412
+ expect ( ( ) => ethAddressFromID ( t2 ) ) . toThrow ( )
413
+ expect ( ( ) => ethAddressFromID ( t3 ) ) . toThrow ( )
414
+ expect ( ( ) => ethAddressFromID ( t410f ) ) . toThrow ( )
415
+ } )
416
+
417
+ test ( 'it should validate correct filecoin addresses' , ( ) => {
418
+ expect ( validateAddressString ( t410f ) ) . toBe ( true )
419
+ } )
420
+
421
+ test ( 'it should invalidate incorrect filecoin addresses' , ( ) => {
422
+ expect ( validateAddressString ( t410f . slice ( 0 , - 1 ) ) ) . toBe ( false )
423
+ } )
367
424
} )
368
425
} )
0 commit comments