66 lines
2.2 KiB
Go
66 lines
2.2 KiB
Go
package tron
|
|||
|
|
|
||
|
|
// Token is a hardcoded TRC20 token definition.
|
||
|
|
type Token struct {
|
||
|
|
Key string
|
||
|
|
Contract string
|
||
|
|
Ticker string
|
||
|
|
ShowBalance bool
|
||
|
|
}
|
||
|
|
|
||
|
|
// Hardcoded network and scale constants matching the original kisstron.py.
|
||
|
|
const (
|
||
|
|
// DefaultNodeAddr is the public TRON node used for mainnet without an API key.
|
||
|
|
DefaultNodeAddr = "http://3.225.171.164:8090"
|
||
|
|
// FeeLimitMainnet is the default mainnet fee limit in SUN (100 TRX).
|
||
|
|
FeeLimitMainnet = 100000000
|
||
|
|
// FeeLimitTestnet is the default testnet fee limit in SUN (1000 TRX).
|
||
|
|
FeeLimitTestnet = 1000000000
|
||
|
|
// TrxScale is the number of SUN in one TRX.
|
||
|
|
TrxScale = 1000000.0
|
||
|
|
)
|
||
|
|
|
||
|
|
// tokensByNetwork preserves the insertion order of the original dict so wallet
|
||
|
|
// info output matches byte-for-byte.
|
||
|
|
var tokensByNetwork = map[string][]Token{
|
||
|
|
"mainnet": {
|
||
|
|
{Key: "usdt", Contract: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", Ticker: "USDT", ShowBalance: true},
|
||
|
|
{Key: "usdc", Contract: "TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8", Ticker: "USDC", ShowBalance: true},
|
||
|
|
{Key: "tusd", Contract: "TUpMhErZL2fhh4sVNULAbNKLokS4GjC1F4", Ticker: "TUSD", ShowBalance: true},
|
||
|
|
},
|
||
|
|
"nile": {
|
||
|
|
{Key: "usdt", Contract: "TXLAQ63Xg1NAzckPwKHvzw7CSEmLMEqcdj", Ticker: "USDT", ShowBalance: true},
|
||
|
|
{Key: "usdc", Contract: "TEMVynQpntMqkPxP6wXTW2K7e4sM3cRmWz", Ticker: "USDC", ShowBalance: true},
|
||
|
|
},
|
||
|
|
"shasta": {
|
||
|
|
{Key: "usdt", Contract: "TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs", Ticker: "USDT", ShowBalance: true},
|
||
|
|
{Key: "usdc", Contract: "TSdZwNqpHofzP6BsBKGQUWdBeJphLmF6id", Ticker: "USDC", ShowBalance: true},
|
||
|
|
},
|
||
|
|
}
|
||
|
|
|
||
|
|
var defaultEndpoints = map[string]string{
|
||
|
|
"mainnet": "",
|
||
|
|
"nile": "https://api.nileex.io",
|
||
|
|
"shasta": "https://api.shasta.trongrid.io",
|
||
|
|
}
|
||
|
|
|
||
|
|
// TokensForNetwork returns the tokens for a network in a stable order.
|
||
|
|
func TokensForNetwork(network string) []Token {
|
||
|
|
return tokensByNetwork[network]
|
||
|
|
}
|
||
|
|
|
||
|
|
// TokenByKey looks up a token by its ticker key for a network.
|
||
|
|
func TokenByKey(network, key string) (Token, bool) {
|
||
|
|
for _, t := range tokensByNetwork[network] {
|
||
|
|
if t.Key == key {
|
||
|
|
return t, true
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return Token{}, false
|
||
|
|
}
|
||
|
|
|
||
|
|
// DefaultEndpoint returns the default node endpoint for a network.
|
||
|
|
func DefaultEndpoint(network string) string {
|
||
|
|
return defaultEndpoints[network]
|
||
|
|
}
|