mirror of
https://github.com/luxfi/cli.git
synced 2026-10-30 17:01:20 +00:00
66 lines
1.6 KiB
Go
66 lines
1.6 KiB
Go
// Copyright (C) 2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package validatormanager
|
|
|
|
import (
|
|
"github.com/luxfi/cli/v2/pkg/contract"
|
|
"github.com/luxfi/geth/core/types"
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/luxfi/ids"
|
|
)
|
|
|
|
// PoAValidatorManagerInitialize initializes contract [managerAddress] at [rpcURL], to
|
|
// manage validators on [subnetID], with
|
|
// owner given by [ownerAddress]
|
|
func PoAValidatorManagerInitialize(
|
|
rpcURL string,
|
|
managerAddress common.Address,
|
|
privateKey string,
|
|
subnetID ids.ID,
|
|
ownerAddress common.Address,
|
|
useACP99 bool,
|
|
) (*types.Transaction, *types.Receipt, error) {
|
|
const (
|
|
defaultChurnPeriodSeconds = uint64(0)
|
|
defaultMaximumChurnPercentage = uint8(20)
|
|
)
|
|
if useACP99 {
|
|
return contract.TxToMethod(
|
|
rpcURL,
|
|
false,
|
|
common.Address{},
|
|
privateKey,
|
|
managerAddress,
|
|
nil,
|
|
"initialize PoA manager",
|
|
ErrorSignatureToError,
|
|
"initialize((address, bytes32,uint64,uint8))",
|
|
ACP99ValidatorManagerSettings{
|
|
Admin: ownerAddress,
|
|
SubnetID: subnetID,
|
|
ChurnPeriodSeconds: defaultChurnPeriodSeconds,
|
|
MaximumChurnPercentage: defaultMaximumChurnPercentage,
|
|
},
|
|
)
|
|
}
|
|
return contract.TxToMethod(
|
|
rpcURL,
|
|
false,
|
|
common.Address{},
|
|
privateKey,
|
|
managerAddress,
|
|
nil,
|
|
"initialize PoA manager",
|
|
ErrorSignatureToError,
|
|
"initialize((bytes32,uint64,uint8),address)",
|
|
ValidatorManagerSettings{
|
|
SubnetID: subnetID,
|
|
ChurnPeriodSeconds: defaultChurnPeriodSeconds,
|
|
MaximumChurnPercentage: defaultMaximumChurnPercentage,
|
|
},
|
|
ownerAddress,
|
|
)
|
|
}
|