mirror of
https://github.com/luxfi/cli.git
synced 2026-10-30 17:01:20 +00:00
- Update github.com/luxfi/netrunner v1.15.3 → v1.15.4 - Update github.com/luxfi/node v1.22.77 → v1.22.80 - Remove local replace directive for netrunner - Use published package versions for reproducible builds
44 lines
922 B
Go
44 lines
922 B
Go
// Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package contract
|
|
|
|
import "github.com/luxfi/crypto"
|
|
|
|
// GetContractOwner gets owner for https://docs.openzeppelin.com/contracts/2.x/api/ownership#Ownable-owner contracts
|
|
func GetContractOwner(
|
|
rpcURL string,
|
|
contractAddress crypto.Address,
|
|
) (crypto.Address, error) {
|
|
out, err := CallToMethod(
|
|
rpcURL,
|
|
contractAddress,
|
|
"owner()->(address)",
|
|
)
|
|
if err != nil {
|
|
return crypto.Address{}, err
|
|
}
|
|
return GetSmartContractCallResult[crypto.Address]("owner", out)
|
|
}
|
|
|
|
func TransferOwnership(
|
|
rpcURL string,
|
|
contractAddress crypto.Address,
|
|
ownerPrivateKey string,
|
|
newOwner crypto.Address,
|
|
) error {
|
|
_, _, err := TxToMethod(
|
|
rpcURL,
|
|
false,
|
|
crypto.Address{},
|
|
ownerPrivateKey,
|
|
contractAddress,
|
|
nil,
|
|
"transfer ownership",
|
|
nil,
|
|
"transferOwnership(address)",
|
|
newOwner,
|
|
)
|
|
return err
|
|
}
|