mirror of
https://github.com/luxfi/cli.git
synced 2026-10-30 17:01:20 +00:00
Deep audit changes: - Replace stub signature aggregator with real SDK warp implementation - Remove dead pkg/lpm package (SDK lpmintegration used instead) - Fix fs imports: use local utils.FileExists, DirExists, ExpandHome - Fix secp256k1fx imports: use node/vms/secp256k1fx - Fix platformvm imports: use node/vms/platformvm - Fix e2e test TODOs: uncomment BootstrapValidators assertions - Improve localnet stub implementations with real logic - Fix node.go fs.FileExists reference Note: Build requires GOWORK=off due to workspace dependency issues
132 lines
4.1 KiB
Go
132 lines
4.1 KiB
Go
// Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
// Package models contains data structures and types used throughout the CLI.
|
|
package models
|
|
|
|
import (
|
|
"github.com/luxfi/ids"
|
|
"github.com/luxfi/netrunner/utils"
|
|
)
|
|
|
|
// TokenInfo contains token metadata.
|
|
type TokenInfo struct {
|
|
Name string `json:"name"`
|
|
Symbol string `json:"symbol"`
|
|
Decimals uint8 `json:"decimals"`
|
|
Supply string `json:"supply"`
|
|
}
|
|
|
|
// NetworkData contains deployment information for a network.
|
|
type NetworkData struct {
|
|
ChainID ids.ID
|
|
BlockchainID ids.ID
|
|
RPCVersion int
|
|
RPCEndpoints []string // RPC endpoints for the network
|
|
WSEndpoints []string // WebSocket endpoints for the network
|
|
TeleporterRegistryAddress string // Teleporter registry address
|
|
TeleporterMessengerAddress string // Teleporter messenger address
|
|
ValidatorManagerAddress string // Validator manager contract address
|
|
BootstrapValidators []ChainValidator // Bootstrap validators for the network
|
|
}
|
|
|
|
// MultisigTxInfo contains multisig transaction information.
|
|
type MultisigTxInfo struct {
|
|
Threshold uint32 `json:"threshold"`
|
|
Addresses []string `json:"addresses"`
|
|
}
|
|
|
|
// PermissionlessValidators contains permissionless validator information.
|
|
type PermissionlessValidators struct {
|
|
TxID ids.ID
|
|
}
|
|
|
|
// ElasticChain contains elastic chain configuration.
|
|
type ElasticChain struct {
|
|
ChainID ids.ID
|
|
AssetID ids.ID
|
|
PChainTXID ids.ID
|
|
TokenName string
|
|
TokenSymbol string
|
|
Validators map[string]PermissionlessValidators
|
|
Txs map[string]ids.ID
|
|
}
|
|
|
|
// Sidecar contains chain configuration metadata.
|
|
type Sidecar struct {
|
|
Name string
|
|
VM VMType
|
|
VMVersion string
|
|
RPCVersion int
|
|
Chain string
|
|
ChainID ids.ID
|
|
BlockchainID ids.ID
|
|
TokenName string
|
|
TokenSymbol string
|
|
EVMChainID string
|
|
Version string
|
|
Networks map[string]NetworkData
|
|
ElasticChain map[string]ElasticChain
|
|
ImportedFromLPM bool
|
|
ImportedVMID string
|
|
|
|
// Custom VM support
|
|
CustomVMRepoURL string
|
|
CustomVMBranch string
|
|
CustomVMBuildScript string
|
|
|
|
// L1/L2 Architecture (2025)
|
|
Sovereign bool `json:"sovereign"` // true for L1, false for L2/chain
|
|
BaseChain string `json:"baseChain"` // For L2s: ethereum, lux-l1, lux, op-mainnet
|
|
BasedRollup bool `json:"basedRollup"` // true for L1-sequenced rollups
|
|
SequencerType string `json:"sequencerType"` // based, centralized, distributed
|
|
|
|
// Based Rollup Configuration
|
|
InboxContract string `json:"inboxContract"` // Contract on base chain
|
|
L1BlockTime int `json:"l1BlockTime"` // Base chain block time in ms
|
|
PreconfirmEnabled bool `json:"preconfirmEnabled"` // Fast confirmations
|
|
|
|
// Token & Economics
|
|
TokenInfo TokenInfo `json:"tokenInfo"`
|
|
RentalPlan string `json:"rentalPlan"` // For L1s: monthly, annual, perpetual
|
|
|
|
// Validator Management
|
|
ValidatorManagement string `json:"validatorManagement"` // proof-of-authority, proof-of-stake
|
|
|
|
// Migration info
|
|
MigratedAt int64 `json:"migratedAt"` // When chain became L1
|
|
|
|
// Chain layer (1=L1, 2=L2, 3=L3)
|
|
ChainLayer int `json:"chainLayer"` // Default 2 for backward compat
|
|
}
|
|
|
|
// GetVMID returns the VM ID for the sidecar.
|
|
func (sc Sidecar) GetVMID() (string, error) {
|
|
// get vmid
|
|
var vmid string
|
|
if sc.ImportedFromLPM {
|
|
vmid = sc.ImportedVMID
|
|
} else {
|
|
chainVMID, err := utils.VMID(sc.Name)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
vmid = chainVMID.String()
|
|
}
|
|
return vmid, nil
|
|
}
|
|
|
|
// MigrationTx represents a chain to L1 migration transaction
|
|
type MigrationTx struct {
|
|
ChainID ids.ID `json:"chainId"`
|
|
BlockchainID ids.ID `json:"blockchainId"`
|
|
ValidatorManagement string `json:"validatorManagement"`
|
|
RentalPlan string `json:"rentalPlan"`
|
|
Timestamp int64 `json:"timestamp"`
|
|
}
|
|
|
|
// NetworkDataIsEmpty checks if the sidecar has no network data
|
|
func (sc *Sidecar) NetworkDataIsEmpty() bool {
|
|
return len(sc.Networks) == 0
|
|
}
|