Files
zeekayandHanzo Dev da299df77d the corporate name is Lux Industries Inc
Lux Partners Limited is not the entity behind this work. Every place the
old name stood — copyright lines, site footers, brand config, legal and
compliance text — now names the company that actually holds it.

lux.fund is the exception and is not renamed to match: that site belongs
to Lux Assets Management LLC, a different company, and it says so.

Two kinds of line were left for a person rather than rewritten. A dated
news item recording that Lux Partners Limited was established in the Isle
of Man is a historical fact, and renaming it would falsify the record. And
a sentence asserting that the company is domiciled in the Isle of Man is a
claim about a jurisdiction, not a name — an Inc or an LLC is not an Isle
of Man company, so swapping the name there would assert something untrue.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-28 13:05:15 -07:00

113 lines
2.3 KiB
Go

// Copyright (C) 2020-2025, Lux Industries Inc All rights reserved.
// See the file LICENSE for licensing terms.
package network
import (
"fmt"
"github.com/luxfi/constants"
)
// NetworkKind represents the kind of network
type NetworkKind int
const (
Undefined NetworkKind = iota
Mainnet
Testnet
Local
Devnet
)
// LegacyNetwork represents a network configuration with endpoint
// This is for compatibility with existing code
type LegacyNetwork struct {
Kind NetworkKind
ID uint32
Endpoint string
Name string
}
var (
// UndefinedNetwork is an undefined network
UndefinedNetwork = LegacyNetwork{
Kind: Undefined,
ID: 0,
Name: "undefined",
}
// MainnetNetwork is the mainnet network
MainnetNetwork = LegacyNetwork{
Kind: Mainnet,
ID: constants.MainnetID,
Endpoint: "https://api.lux.network",
Name: constants.MainnetName,
}
// TestnetNetwork is the testnet network
TestnetNetwork = LegacyNetwork{
Kind: Testnet,
ID: constants.TestnetID,
Endpoint: "https://api-test.lux.network",
Name: constants.TestnetName,
}
// LocalNetwork is the local network
LocalNetwork = LegacyNetwork{
Kind: Local,
ID: constants.LocalID,
Endpoint: "http://127.0.0.1:9630",
Name: constants.LocalName,
}
)
// NetworkFromNetworkID returns a network from network ID
func NetworkFromNetworkID(networkID uint32) LegacyNetwork {
switch networkID {
case constants.MainnetID:
return MainnetNetwork
case constants.TestnetID:
return TestnetNetwork
case constants.LocalID:
return LocalNetwork
default:
return LegacyNetwork{
Kind: Devnet,
ID: networkID,
Endpoint: "",
Name: fmt.Sprintf("network-%d", networkID),
}
}
}
// GetNetworkByName returns a network by name
func GetNetworkByName(name string) (LegacyNetwork, error) {
switch name {
case constants.MainnetName:
return MainnetNetwork, nil
case constants.TestnetName:
return TestnetNetwork, nil
case constants.LocalName:
return LocalNetwork, nil
default:
return UndefinedNetwork, fmt.Errorf("unknown network: %s", name)
}
}
// String returns string representation of NetworkKind
func (k NetworkKind) String() string {
switch k {
case Mainnet:
return "mainnet"
case Testnet:
return "testnet"
case Local:
return "local"
case Devnet:
return "devnet"
default:
return "undefined"
}
}