Skip to content

Commit

Permalink
Merge pull request #7 from rocket-pool/use-time
Browse files Browse the repository at this point in the history
Update master w/ latest features
  • Loading branch information
kanewallmann authored May 17, 2021
2 parents c949e49 + a6a1634 commit c873863
Show file tree
Hide file tree
Showing 33 changed files with 882 additions and 130 deletions.
40 changes: 40 additions & 0 deletions auction/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,16 @@ func GetLotAddressBidAmount(rp *rocketpool.RocketPool, lotIndex uint64, bidder c
}


// Estimate the gas of CreateLot
func EstimateCreateLotGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) {
rocketAuctionManager, err := getRocketAuctionManager(rp)
if err != nil {
return rocketpool.GasInfo{}, err
}
return rocketAuctionManager.GetTransactionGasInfo(opts, "createLot")
}


// Create a new lot
func CreateLot(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (uint64, common.Hash, error) {
rocketAuctionManager, err := getRocketAuctionManager(rp)
Expand All @@ -527,6 +537,16 @@ func CreateLot(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (uint64, comm
}


// Estimate the gas of PlaceBid
func EstimatePlaceBidGas(rp *rocketpool.RocketPool, lotIndex uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) {
rocketAuctionManager, err := getRocketAuctionManager(rp)
if err != nil {
return rocketpool.GasInfo{}, err
}
return rocketAuctionManager.GetTransactionGasInfo(opts, "placeBid", big.NewInt(int64(lotIndex)))
}


// Place a bid on a lot
func PlaceBid(rp *rocketpool.RocketPool, lotIndex uint64, opts *bind.TransactOpts) (common.Hash, error) {
rocketAuctionManager, err := getRocketAuctionManager(rp)
Expand All @@ -541,6 +561,16 @@ func PlaceBid(rp *rocketpool.RocketPool, lotIndex uint64, opts *bind.TransactOpt
}


// Estimate the gas of ClaimBid
func EstimateClaimBidGas(rp *rocketpool.RocketPool, lotIndex uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) {
rocketAuctionManager, err := getRocketAuctionManager(rp)
if err != nil {
return rocketpool.GasInfo{}, err
}
return rocketAuctionManager.GetTransactionGasInfo(opts, "claimBid", big.NewInt(int64(lotIndex)))
}


// Claim RPL from a lot that was bid on
func ClaimBid(rp *rocketpool.RocketPool, lotIndex uint64, opts *bind.TransactOpts) (common.Hash, error) {
rocketAuctionManager, err := getRocketAuctionManager(rp)
Expand All @@ -555,6 +585,16 @@ func ClaimBid(rp *rocketpool.RocketPool, lotIndex uint64, opts *bind.TransactOpt
}


// Estimate the gas of RecoverUnclaimedRPL
func EstimateRecoverUnclaimedRPLGas(rp *rocketpool.RocketPool, lotIndex uint64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) {
rocketAuctionManager, err := getRocketAuctionManager(rp)
if err != nil {
return rocketpool.GasInfo{}, err
}
return rocketAuctionManager.GetTransactionGasInfo(opts, "recoverUnclaimedRPL", big.NewInt(int64(lotIndex)))
}


// Recover unclaimed RPL from a lot
func RecoverUnclaimedRPL(rp *rocketpool.RocketPool, lotIndex uint64, opts *bind.TransactOpts) (common.Hash, error) {
rocketAuctionManager, err := getRocketAuctionManager(rp)
Expand Down
40 changes: 40 additions & 0 deletions dao/protocol/dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ import (
"github.com/rocket-pool/rocketpool-go/utils/eth"
)

// Estimate the gas of BootstrapBool
func EstimateBootstrapBoolGas(rp *rocketpool.RocketPool, contractName, settingPath string, value bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) {
rocketDAOProtocol, err := getRocketDAOProtocol(rp)
if err != nil {
return rocketpool.GasInfo{}, err
}
return rocketDAOProtocol.GetTransactionGasInfo(opts, "bootstrapSettingBool", contractName, settingPath, value)
}


// Bootstrap a bool setting
func BootstrapBool(rp *rocketpool.RocketPool, contractName, settingPath string, value bool, opts *bind.TransactOpts) (common.Hash, error) {
rocketDAOProtocol, err := getRocketDAOProtocol(rp)
Expand All @@ -26,6 +36,16 @@ func BootstrapBool(rp *rocketpool.RocketPool, contractName, settingPath string,
}


// Estimate the gas of BootstrapUint
func EstimateBootstrapUintGas(rp *rocketpool.RocketPool, contractName, settingPath string, value *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) {
rocketDAOProtocol, err := getRocketDAOProtocol(rp)
if err != nil {
return rocketpool.GasInfo{}, err
}
return rocketDAOProtocol.GetTransactionGasInfo(opts, "bootstrapSettingUint", contractName, settingPath, value)
}


// Bootstrap a uint256 setting
func BootstrapUint(rp *rocketpool.RocketPool, contractName, settingPath string, value *big.Int, opts *bind.TransactOpts) (common.Hash, error) {
rocketDAOProtocol, err := getRocketDAOProtocol(rp)
Expand All @@ -40,6 +60,16 @@ func BootstrapUint(rp *rocketpool.RocketPool, contractName, settingPath string,
}


// Estimate the gas of BootstrapAddress
func EstimateBootstrapAddressGas(rp *rocketpool.RocketPool, contractName, settingPath string, value common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) {
rocketDAOProtocol, err := getRocketDAOProtocol(rp)
if err != nil {
return rocketpool.GasInfo{}, err
}
return rocketDAOProtocol.GetTransactionGasInfo(opts, "bootstrapSettingAddress", contractName, settingPath, value)
}


// Bootstrap an address setting
func BootstrapAddress(rp *rocketpool.RocketPool, contractName, settingPath string, value common.Address, opts *bind.TransactOpts) (common.Hash, error) {
rocketDAOProtocol, err := getRocketDAOProtocol(rp)
Expand All @@ -54,6 +84,16 @@ func BootstrapAddress(rp *rocketpool.RocketPool, contractName, settingPath strin
}


// Estimate the gas of BootstrapClaimer
func EstimateBootstrapClaimerGas(rp *rocketpool.RocketPool, contractName string, amount float64, opts *bind.TransactOpts) (rocketpool.GasInfo, error) {
rocketDAOProtocol, err := getRocketDAOProtocol(rp)
if err != nil {
return rocketpool.GasInfo{}, err
}
return rocketDAOProtocol.GetTransactionGasInfo(opts, "bootstrapSettingClaimer", contractName, eth.EthToWei(amount))
}


// Bootstrap a rewards claimer
func BootstrapClaimer(rp *rocketpool.RocketPool, contractName string, amount float64, opts *bind.TransactOpts) (common.Hash, error) {
rocketDAOProtocol, err := getRocketDAOProtocol(rp)
Expand Down
40 changes: 40 additions & 0 deletions dao/trustednode/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ import (
"github.com/rocket-pool/rocketpool-go/rocketpool"
)

// Estimate the gas of Join
func EstimateJoinGas(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) {
rocketDAONodeTrustedActions, err := getRocketDAONodeTrustedActions(rp)
if err != nil {
return rocketpool.GasInfo{}, err
}
return rocketDAONodeTrustedActions.GetTransactionGasInfo(opts, "actionJoin")
}


// Join the trusted node DAO
// Requires an executed invite proposal
func Join(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (common.Hash, error) {
Expand All @@ -25,6 +35,16 @@ func Join(rp *rocketpool.RocketPool, opts *bind.TransactOpts) (common.Hash, erro
}


// Estimate the gas of Leave
func EstimateLeaveGas(rp *rocketpool.RocketPool, rplBondRefundAddress common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) {
rocketDAONodeTrustedActions, err := getRocketDAONodeTrustedActions(rp)
if err != nil {
return rocketpool.GasInfo{}, err
}
return rocketDAONodeTrustedActions.GetTransactionGasInfo(opts, "actionLeave", rplBondRefundAddress)
}


// Leave the trusted node DAO
// Requires an executed leave proposal
func Leave(rp *rocketpool.RocketPool, rplBondRefundAddress common.Address, opts *bind.TransactOpts) (common.Hash, error) {
Expand All @@ -40,6 +60,16 @@ func Leave(rp *rocketpool.RocketPool, rplBondRefundAddress common.Address, opts
}


// Estimate the gas of MakeChallenge
func EstimateMakeChallengeGas(rp *rocketpool.RocketPool, memberAddress common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) {
rocketDAONodeTrustedActions, err := getRocketDAONodeTrustedActions(rp)
if err != nil {
return rocketpool.GasInfo{}, err
}
return rocketDAONodeTrustedActions.GetTransactionGasInfo(opts, "actionChallengeMake", memberAddress)
}


// Make a challenge against a node
func MakeChallenge(rp *rocketpool.RocketPool, memberAddress common.Address, opts *bind.TransactOpts) (common.Hash, error) {
rocketDAONodeTrustedActions, err := getRocketDAONodeTrustedActions(rp)
Expand All @@ -54,6 +84,16 @@ func MakeChallenge(rp *rocketpool.RocketPool, memberAddress common.Address, opts
}


// Estimate the gas of DecideChallenge
func EstimateDecideChallengeGas(rp *rocketpool.RocketPool, memberAddress common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) {
rocketDAONodeTrustedActions, err := getRocketDAONodeTrustedActions(rp)
if err != nil {
return rocketpool.GasInfo{}, err
}
return rocketDAONodeTrustedActions.GetTransactionGasInfo(opts, "actionChallengeDecide", memberAddress)
}


// Decide a challenge against a node
func DecideChallenge(rp *rocketpool.RocketPool, memberAddress common.Address, opts *bind.TransactOpts) (common.Hash, error) {
rocketDAONodeTrustedActions, err := getRocketDAONodeTrustedActions(rp)
Expand Down
55 changes: 54 additions & 1 deletion dao/trustednode/dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package trustednode
import (
"fmt"
"math/big"
"net/mail"
"sync"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
Expand Down Expand Up @@ -357,6 +358,16 @@ func GetMemberIsChallenged(rp *rocketpool.RocketPool, memberAddress common.Addre
}


// Estimate the gas of BootstrapBool
func EstimateBootstrapBoolGas(rp *rocketpool.RocketPool, contractName, settingPath string, value bool, opts *bind.TransactOpts) (rocketpool.GasInfo, error) {
rocketDAONodeTrusted, err := getRocketDAONodeTrusted(rp)
if err != nil {
return rocketpool.GasInfo{}, err
}
return rocketDAONodeTrusted.GetTransactionGasInfo(opts, "bootstrapSettingBool", contractName, settingPath, value)
}


// Bootstrap a bool setting
func BootstrapBool(rp *rocketpool.RocketPool, contractName, settingPath string, value bool, opts *bind.TransactOpts) (common.Hash, error) {
rocketDAONodeTrusted, err := getRocketDAONodeTrusted(rp)
Expand All @@ -371,6 +382,16 @@ func BootstrapBool(rp *rocketpool.RocketPool, contractName, settingPath string,
}


// Estimate the gas of BootstrapUint
func EstimateBootstrapUintGas(rp *rocketpool.RocketPool, contractName, settingPath string, value *big.Int, opts *bind.TransactOpts) (rocketpool.GasInfo, error) {
rocketDAONodeTrusted, err := getRocketDAONodeTrusted(rp)
if err != nil {
return rocketpool.GasInfo{}, err
}
return rocketDAONodeTrusted.GetTransactionGasInfo(opts, "bootstrapSettingUint", contractName, settingPath, value)
}


// Bootstrap a uint256 setting
func BootstrapUint(rp *rocketpool.RocketPool, contractName, settingPath string, value *big.Int, opts *bind.TransactOpts) (common.Hash, error) {
rocketDAONodeTrusted, err := getRocketDAONodeTrusted(rp)
Expand All @@ -385,20 +406,52 @@ func BootstrapUint(rp *rocketpool.RocketPool, contractName, settingPath string,
}


// Estimate the gas of BootstrapMember
func EstimateBootstrapMemberGas(rp *rocketpool.RocketPool, id, email string, nodeAddress common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) {
rocketDAONodeTrusted, err := getRocketDAONodeTrusted(rp)
if err != nil {
return rocketpool.GasInfo{}, err
}
address, err := mail.ParseAddress(email)
if err != nil {
return rocketpool.GasInfo{}, err
}
return rocketDAONodeTrusted.GetTransactionGasInfo(opts, "bootstrapMember", id, address.Address, nodeAddress)
}


// Bootstrap a DAO member
func BootstrapMember(rp *rocketpool.RocketPool, id, email string, nodeAddress common.Address, opts *bind.TransactOpts) (common.Hash, error) {
rocketDAONodeTrusted, err := getRocketDAONodeTrusted(rp)
if err != nil {
return common.Hash{}, err
}
hash, err := rocketDAONodeTrusted.Transact(opts, "bootstrapMember", id, email, nodeAddress)
address, err := mail.ParseAddress(email)
if err != nil {
return common.Hash{}, err
}
hash, err := rocketDAONodeTrusted.Transact(opts, "bootstrapMember", id, address.Address, nodeAddress)
if err != nil {
return common.Hash{}, fmt.Errorf("Could not bootstrap trusted node member %s: %w", id, err)
}
return hash, nil
}


// Estimate the gas of BootstrapUpgrade
func EstimateBootstrapUpgradeGas(rp *rocketpool.RocketPool, upgradeType, contractName, contractAbi string, contractAddress common.Address, opts *bind.TransactOpts) (rocketpool.GasInfo, error) {
compressedAbi, err := rocketpool.EncodeAbiStr(contractAbi)
if err != nil {
return rocketpool.GasInfo{}, err
}
rocketDAONodeTrusted, err := getRocketDAONodeTrusted(rp)
if err != nil {
return rocketpool.GasInfo{}, err
}
return rocketDAONodeTrusted.GetTransactionGasInfo(opts, "bootstrapUpgrade", upgradeType, contractName, compressedAbi, contractAddress)
}


// Bootstrap a contract upgrade
func BootstrapUpgrade(rp *rocketpool.RocketPool, upgradeType, contractName, contractAbi string, contractAddress common.Address, opts *bind.TransactOpts) (common.Hash, error) {
compressedAbi, err := rocketpool.EncodeAbiStr(contractAbi)
Expand Down
Loading

0 comments on commit c873863

Please sign in to comment.