mirror of
https://github.com/luxfi/sdk.git
synced 2026-10-30 15:19:23 +00:00
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]>
102 lines
2.5 KiB
Go
102 lines
2.5 KiB
Go
// Copyright (C) 2025, Lux Industries Inc All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package validatormanager
|
|
|
|
import (
|
|
_ "embed"
|
|
"math/big"
|
|
|
|
"github.com/luxfi/geth/core/types"
|
|
"github.com/luxfi/sdk/contract"
|
|
"github.com/luxfi/sdk/evm"
|
|
|
|
"github.com/luxfi/crypto"
|
|
)
|
|
|
|
func SetupValidatorProxyImplementation(
|
|
rpcURL string,
|
|
proxyManagerPrivateKey string,
|
|
validatorManager crypto.Address,
|
|
) (*types.Transaction, *types.Receipt, error) {
|
|
return contract.TxToMethod(
|
|
rpcURL,
|
|
false,
|
|
crypto.Address{},
|
|
proxyManagerPrivateKey,
|
|
crypto.HexToAddress(ValidatorProxyAdminContractAddress),
|
|
big.NewInt(0),
|
|
"set validator proxy implementation",
|
|
ErrorSignatureToError,
|
|
"upgrade(address,address)",
|
|
crypto.HexToAddress(ValidatorProxyContractAddress),
|
|
validatorManager,
|
|
)
|
|
}
|
|
|
|
func GetValidatorProxyImplementation(
|
|
rpcURL string,
|
|
) (crypto.Address, error) {
|
|
out, err := contract.CallToMethod(
|
|
rpcURL,
|
|
crypto.HexToAddress(ValidatorProxyAdminContractAddress),
|
|
"getProxyImplementation(address)->(address)",
|
|
crypto.HexToAddress(ValidatorProxyContractAddress),
|
|
)
|
|
if err != nil {
|
|
return crypto.Address{}, err
|
|
}
|
|
return contract.GetSmartContractCallResult[crypto.Address]("getProxyImplementation", out)
|
|
}
|
|
|
|
func ValidatorProxyHasImplementationSet(
|
|
rpcURL string,
|
|
) (bool, error) {
|
|
validatorManagerAddress, err := GetValidatorProxyImplementation(rpcURL)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
client, err := evm.GetClient(rpcURL)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
return client.ContractAlreadyDeployed(
|
|
validatorManagerAddress.Hex(),
|
|
)
|
|
}
|
|
|
|
func GetSpecializedValidatorProxyImplementation(
|
|
rpcURL string,
|
|
) (crypto.Address, error) {
|
|
out, err := contract.CallToMethod(
|
|
rpcURL,
|
|
crypto.HexToAddress(SpecializationProxyAdminContractAddress),
|
|
"getProxyImplementation(address)->(address)",
|
|
crypto.HexToAddress(SpecializationProxyContractAddress),
|
|
)
|
|
if err != nil {
|
|
return crypto.Address{}, err
|
|
}
|
|
return contract.GetSmartContractCallResult[crypto.Address]("getProxyImplementation", out)
|
|
}
|
|
|
|
func SetupSpecializationProxyImplementation(
|
|
rpcURL string,
|
|
proxyManagerPrivateKey string,
|
|
validatorManager crypto.Address,
|
|
) (*types.Transaction, *types.Receipt, error) {
|
|
return contract.TxToMethod(
|
|
rpcURL,
|
|
false,
|
|
crypto.Address{},
|
|
proxyManagerPrivateKey,
|
|
crypto.HexToAddress(SpecializationProxyAdminContractAddress),
|
|
big.NewInt(0),
|
|
"set specialization proxy implementation",
|
|
ErrorSignatureToError,
|
|
"upgrade(address,address)",
|
|
crypto.HexToAddress(SpecializationProxyContractAddress),
|
|
validatorManager,
|
|
)
|
|
}
|