Files
zeekay 579f53c3cc chore: remove local replace directives and update dependencies
- Update github.com/luxfi/netrunner v1.15.3 → v1.15.4
- Update github.com/luxfi/node v1.22.77 → v1.22.80
- Remove local replace directive for netrunner
- Use published package versions for reproducible builds
2026-01-03 07:09:01 -08:00

52 lines
1.3 KiB
Go

// Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package warp
import (
"github.com/luxfi/crypto"
"github.com/luxfi/erc20-go/erc20"
"github.com/luxfi/geth/common"
"github.com/luxfi/geth/ethclient"
)
func GetTokenParams(endpoint string, tokenAddress crypto.Address) (string, string, uint8, error) {
client, err := ethclient.Dial(endpoint)
if err != nil {
return "", "", 0, err
}
// Convert crypto.Address to geth common.Address
gethAddr := common.BytesToAddress(tokenAddress.Bytes())
token, err := erc20.NewGGToken(gethAddr, client)
if err != nil {
return "", "", 0, err
}
tokenName, err := token.Name(nil)
if err != nil {
return "", "", 0, err
}
tokenSymbol, err := token.Symbol(nil)
if err != nil {
return "", "", 0, err
}
tokenDecimals, err := token.Decimals(nil)
if err != nil {
return "", "", 0, err
}
return tokenSymbol, tokenName, tokenDecimals, nil
}
func GetTokenDecimals(endpoint string, tokenAddress crypto.Address) (uint8, error) {
client, err := ethclient.Dial(endpoint)
if err != nil {
return 0, err
}
// Convert crypto.Address to geth common.Address
gethAddr := common.BytesToAddress(tokenAddress.Bytes())
token, err := erc20.NewGGToken(gethAddr, client)
if err != nil {
return 0, err
}
return token.Decimals(nil)
}