@@ -387,7 +387,7 @@ export const readCoinBalances = (contractAddress: string, address: string) =>
387
387
} )
388
388
return coins
389
389
} )
390
-
390
+
391
391
export const getAllCoinsUnique = ( address : string ) =>
392
392
Effect . gen ( function * ( ) {
393
393
const client = ( yield * PublicClient ) . client
@@ -430,6 +430,58 @@ export const readCoinBalances = (contractAddress: string, address: string) =>
430
430
return result
431
431
} )
432
432
433
+ export const getCoinName = ( address : string ) =>
434
+ Effect . gen ( function * ( ) {
435
+ const client = ( yield * PublicClient ) . client
436
+
437
+ const name = yield * Effect . tryPromise ( {
438
+ try : async ( ) => {
439
+ const result = await client . getCoinMetadata ( { coinType : address } )
440
+ return result ?. name
441
+ } ,
442
+ catch : err =>
443
+ new ReadCoinError ( {
444
+ cause : extractErrorDetails ( err as ReadCoinError ) ,
445
+ } ) ,
446
+ } )
447
+ return name
448
+ } )
449
+
450
+ export const getCoinDecimals = ( address : string ) =>
451
+ Effect . gen ( function * ( ) {
452
+ const client = ( yield * PublicClient ) . client
453
+
454
+ const decimals = yield * Effect . tryPromise ( {
455
+ try : async ( ) => {
456
+ const result = await client . getCoinMetadata ( { coinType : address } )
457
+ return result ?. decimals
458
+ } ,
459
+ catch : err =>
460
+ new ReadCoinError ( {
461
+ cause : extractErrorDetails ( err as ReadCoinError ) ,
462
+ } ) ,
463
+ } )
464
+ return decimals
465
+ } )
466
+
467
+ export const readCoinSymbol = ( address : string ) =>
468
+ Effect . gen ( function * ( ) {
469
+ const client = ( yield * PublicClient ) . client
470
+
471
+ const symbol = yield * Effect . tryPromise ( {
472
+ try : async ( ) => {
473
+ const result = await client . getCoinMetadata ( { coinType : address } )
474
+ return result ?. symbol
475
+ } ,
476
+ catch : err =>
477
+ new ReadCoinError ( {
478
+ cause : extractErrorDetails ( err as ReadCoinError ) ,
479
+ } ) ,
480
+ } )
481
+ return symbol
482
+ } )
483
+
484
+
433
485
// /**
434
486
// * Read the balance of an ERC20 token for a specific address
435
487
// *
0 commit comments