Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement pdao status and signalling address commands #599

Merged
merged 29 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1cbc298
Init rocketpool-cli pdao status
thomaspanf Jul 10, 2024
7f264f9
Init rocketpool-daemon pdao status
thomaspanf Jul 10, 2024
05b8a8f
Init RocketSignerRegistry binding
thomaspanf Jul 10, 2024
5c5fc4b
Add RocketSignerRegistry to ServiceProvider
thomaspanf Jul 11, 2024
59cf695
Add registry binding
thomaspanf Jul 11, 2024
f0c1ddc
Populating fields in API response
thomaspanf Jul 12, 2024
9cecead
Init ParseEIP712 helper function
thomaspanf Jul 13, 2024
83b7318
Init signalling address commands
thomaspanf Jul 14, 2024
2095587
Register routes for set/clear signalling address
thomaspanf Jul 15, 2024
4606c10
Add voteCount response
thomaspanf Jul 15, 2024
701c37a
Fixed issue in registry binding
thomaspanf Jul 16, 2024
3f4e01d
Add api route for clear signalling address
thomaspanf Jul 16, 2024
4dddd20
Add cli and api route for set/clear signalling address
thomaspanf Jul 17, 2024
5ff02e2
Remove unused structs
thomaspanf Jul 17, 2024
c03878e
Fix print statements and terminal escape codes
thomaspanf Jul 18, 2024
8a91b72
Add PrintNetwork and error handling for unregistered nodes
thomaspanf Jul 18, 2024
33a089c
Remove else after return and unused fields
thomaspanf Jul 18, 2024
32a7c96
Remove const, fix message and nil pointer
thomaspanf Jul 18, 2024
276d4ef
Add api call to grab active snapshot proposals
thomaspanf Jul 19, 2024
6fce08c
Edit response to improve error output
thomaspanf Jul 19, 2024
fee1e68
Moved eip712 signature validation logic into its own package
thomaspanf Jul 19, 2024
0d690b6
Refactor package eip712 to use Decode and Encode, added unit tests fo…
thomaspanf Jul 22, 2024
05e2934
Update shared/eip712/eip712.go
thomaspanf Jul 22, 2024
cab82dd
Add Validate to eip712 package
thomaspanf Jul 22, 2024
8b4317d
Add test for decoding invalid length signature, fix linter issues
thomaspanf Jul 22, 2024
a6cde79
Refactor Decode/Encode to fulfil TextMarshaler interface
thomaspanf Jul 23, 2024
edb9fc3
Add String method and unit tests for Validate
thomaspanf Jul 23, 2024
5895fce
Fix test case names
thomaspanf Jul 23, 2024
b669d2e
Refactor UnmarshalText and MarshalText
thomaspanf Jul 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions client/pdao.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,20 @@ func (r *PDaoRequester) GetCurrentVotingDelegate() (*types.ApiResponse[api.Proto
}

// Get the pDAO status
func (r *PDaoRequester) GetStatus() (*types.ApiResponse[api.ProtocolDAOStatusResponse], error) {
return client.SendGetRequest[api.ProtocolDAOStatusResponse](r, "get-status", "GetStatus", nil)
func (r *PDaoRequester) GetStatus() (*types.ApiResponse[api.ProtocolDaoStatusResponse], error) {
return client.SendGetRequest[api.ProtocolDaoStatusResponse](r, "get-status", "GetStatus", nil)
}

// Set the signalling address for the node
func (r *PDaoRequester) SetSignallingAddress(signallingAddress common.Address, signature string) (*types.ApiResponse[types.TxInfoData], error) {
args := map[string]string{
"signallingAddress": signallingAddress.Hex(),
"signature": string(signature),
}
return client.SendGetRequest[types.TxInfoData](r, "set-signalling-address", "SetSignallingAddress", args)
}

// Set the signalling address for the node
func (r *PDaoRequester) ClearSignallingAddress() (*types.ApiResponse[types.TxInfoData], error) {
return client.SendGetRequest[types.TxInfoData](r, "clear-signalling-address", "ClearSignallingAddress", nil)
}
4 changes: 2 additions & 2 deletions rocketpool-cli/commands/node/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ func getStatus(c *cli.Context) error {
return err
}

// rp.NodeStatus() will fail with an error, but we can short-circuit it here.
// rp.Api.Node.Status() will fail with an error, but we can short-circuit it here.
if !walletStatus.Address.HasAddress {
return errors.New("No node address is loaded.")
return errors.New("Node Wallet is not initialized.")
}

// Get node status
Expand Down
87 changes: 60 additions & 27 deletions rocketpool-cli/commands/pdao/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,66 @@ func RegisterCommands(app *cli.App, name string, aliases []string) {
},
},

{
Name: "initialize-voting",
Aliases: []string{"iv"},
Usage: "Unlocks a node operator's voting power (only required for node operators who registered before governance structure was in place)",
Action: func(c *cli.Context) error {
// Run
return initializeVoting(c)
},
},

{
Name: "set-signalling-address",
Aliases: []string{"ssa"},
Usage: "Set the address you want to use to represent your node on Snapshot",
ArgsUsage: "signalling-address signature",
Flags: []cli.Flag{
cliutils.YesFlag,
},
Action: func(c *cli.Context) error {
// Validate args
utils.ValidateArgCount(c, 2)

signallingAddress, err := input.ValidateAddress("signalling-address", c.Args().Get(0))
if err != nil {
return err
}
signature := c.Args().Get(1)

// Run
return setSignallingAddress(c, signallingAddress, signature)
},
},

{
Name: "clear-signalling-address",
Aliases: []string{"csa"},
Usage: "Clear the node's signalling address",
Action: func(c *cli.Context) error {
// Run
return clearSignallingAddress(c)
},
},

{
Name: "set-voting-delegate",
Aliases: []string{"svd"},
Usage: "Set the address you want to use when voting on Rocket Pool on-chain governance proposals, or the address you want to delegate your voting power to.",
ArgsUsage: "address",
Flags: []cli.Flag{
cliutils.YesFlag,
},
Action: func(c *cli.Context) error {
// Validate args
utils.ValidateArgCount(c, 1)
delegate := c.Args().Get(0)
// Run
return setVotingDelegate(c, delegate)
},
},

{
Name: "claim-bonds",
Aliases: []string{"cb"},
Expand Down Expand Up @@ -469,33 +529,6 @@ func RegisterCommands(app *cli.App, name string, aliases []string) {
},
},
},

{
Name: "initialize-voting",
Aliases: []string{"iv"},
Usage: "Unlocks a node operator's voting power (only required for node operators who registered before governance structure was in place)",
Action: func(c *cli.Context) error {
// Run
return initializeVoting(c)
},
},

{
Name: "set-voting-delegate",
Aliases: []string{"svd"},
Usage: "Set the address you want to use when voting on Rocket Pool on-chain governance proposals, or the address you want to delegate your voting power to.",
ArgsUsage: "address",
Flags: []cli.Flag{
cliutils.YesFlag,
},
Action: func(c *cli.Context) error {
// Validate args
utils.ValidateArgCount(c, 1)
delegate := c.Args().Get(0)
// Run
return setVotingDelegate(c, delegate)
},
},
},
})
}
70 changes: 70 additions & 0 deletions rocketpool-cli/commands/pdao/signalling-address.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package pdao

import (
"fmt"

"github.com/ethereum/go-ethereum/common"
"github.com/rocket-pool/smartnode/v2/rocketpool-cli/client"
"github.com/rocket-pool/smartnode/v2/rocketpool-cli/utils/tx"
"github.com/urfave/cli/v2"
)

func setSignallingAddress(c *cli.Context, signallingAddress common.Address, signature string) error {
// Get RP client
rp, err := client.NewClientFromCtx(c)
if err != nil {
return err
}

// Build the TX
response, err := rp.Api.PDao.SetSignallingAddress(signallingAddress, signature)
if err != nil {
return fmt.Errorf("Error setting the signalling address: %w", err)
}

validated, err := tx.HandleTx(c, rp, response.Data.TxInfo,
"Are you sure you want to set your signalling address?",
"setting signalling address",
"Setting signalling address...",
)
if err != nil {
return err
}
if !validated {
return nil
}

return nil

}

func clearSignallingAddress(c *cli.Context) error {

// Get RP client
rp, err := client.NewClientFromCtx(c)
if err != nil {
return err
}

// Build the TX
response, err := rp.Api.PDao.ClearSignallingAddress()
if err != nil {
return fmt.Errorf("Error clearing the signalling address: %w", err)
}

validated, err := tx.HandleTx(c, rp, response.Data.TxInfo,
"Are you sure you want to clear the current signalling address?",
"clearing signalling address",
"Clearing signalling address...",
)
if err != nil {
return err
}
if !validated {
return nil
}

// Log & return
fmt.Println("The node's signalling address has been sucessfully cleared.")
return nil
}
Loading
Loading