-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from nodeset-org/ns-client
Move the NodeSet client into HD Daemon
- Loading branch information
Showing
32 changed files
with
1,500 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package client | ||
|
||
import ( | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/nodeset-org/hyperdrive-daemon/shared/types/api" | ||
apiv1 "github.com/nodeset-org/nodeset-client-go/api-v1" | ||
"github.com/rocket-pool/node-manager-core/api/client" | ||
"github.com/rocket-pool/node-manager-core/api/types" | ||
"github.com/rocket-pool/node-manager-core/beacon" | ||
) | ||
|
||
// Requester for StakeWise module calls to the nodeset.io service | ||
type NodeSetStakeWiseRequester struct { | ||
context client.IRequesterContext | ||
} | ||
|
||
func NewNodeSetStakeWiseRequester(context client.IRequesterContext) *NodeSetStakeWiseRequester { | ||
return &NodeSetStakeWiseRequester{ | ||
context: context, | ||
} | ||
} | ||
|
||
func (r *NodeSetStakeWiseRequester) GetName() string { | ||
return "NodeSet-StakeWise" | ||
} | ||
func (r *NodeSetStakeWiseRequester) GetRoute() string { | ||
return "nodeset/stakewise" | ||
} | ||
func (r *NodeSetStakeWiseRequester) GetContext() client.IRequesterContext { | ||
return r.context | ||
} | ||
|
||
// Gets the list of validators that the node has registered with the provided vault | ||
func (r *NodeSetStakeWiseRequester) GetRegisteredValidators(vault common.Address) (*types.ApiResponse[api.NodeSetStakeWise_GetRegisteredValidatorsData], error) { | ||
args := map[string]string{ | ||
"vault": vault.Hex(), | ||
} | ||
return client.SendGetRequest[api.NodeSetStakeWise_GetRegisteredValidatorsData](r, "get-registered-validators", "GetRegisteredValidators", args) | ||
} | ||
|
||
// Gets the version of the latest deposit data set on the server for the provided vault | ||
func (r *NodeSetStakeWiseRequester) GetDepositDataSetVersion(vault common.Address) (*types.ApiResponse[api.NodeSetStakeWise_GetDepositDataSetVersionData], error) { | ||
args := map[string]string{ | ||
"vault": vault.Hex(), | ||
} | ||
return client.SendGetRequest[api.NodeSetStakeWise_GetDepositDataSetVersionData](r, "get-deposit-data-set/version", "GetDepositDataSetVersion", args) | ||
} | ||
|
||
// Gets the latest deposit data set on the server for the provided vault | ||
func (r *NodeSetStakeWiseRequester) GetDepositDataSet(vault common.Address) (*types.ApiResponse[api.NodeSetStakeWise_GetDepositDataSetData], error) { | ||
args := map[string]string{ | ||
"vault": vault.Hex(), | ||
} | ||
return client.SendGetRequest[api.NodeSetStakeWise_GetDepositDataSetData](r, "get-deposit-data-set", "GetDepositDataSet", args) | ||
} | ||
|
||
// Uploads new validator deposit data to the NodeSet service | ||
func (r *NodeSetStakeWiseRequester) UploadDepositData(data []beacon.ExtendedDepositData) (*types.ApiResponse[api.NodeSetStakeWise_UploadDepositDataData], error) { | ||
return client.SendPostRequest[api.NodeSetStakeWise_UploadDepositDataData](r, "upload-deposit-data", "UploadDepositData", data) | ||
} | ||
|
||
// Uploads signed exit messages to the NodeSet service | ||
func (r *NodeSetStakeWiseRequester) UploadSignedExits(data []apiv1.ExitData) (*types.ApiResponse[api.NodeSetStakeWise_UploadSignedExitsData], error) { | ||
return client.SendPostRequest[api.NodeSetStakeWise_UploadSignedExitsData](r, "upload-signed-exits", "UploadSignedExits", data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package client | ||
|
||
import ( | ||
"github.com/nodeset-org/hyperdrive-daemon/shared/types/api" | ||
"github.com/rocket-pool/node-manager-core/api/client" | ||
"github.com/rocket-pool/node-manager-core/api/types" | ||
) | ||
|
||
// Requester for core calls to the nodeset.io service | ||
type NodeSetRequester struct { | ||
context client.IRequesterContext | ||
} | ||
|
||
func NewNodeSetRequester(context client.IRequesterContext) *NodeSetRequester { | ||
return &NodeSetRequester{ | ||
context: context, | ||
} | ||
} | ||
|
||
func (r *NodeSetRequester) GetName() string { | ||
return "NodeSet" | ||
} | ||
func (r *NodeSetRequester) GetRoute() string { | ||
return "nodeset" | ||
} | ||
func (r *NodeSetRequester) GetContext() client.IRequesterContext { | ||
return r.context | ||
} | ||
|
||
// Gets the node's registration status with the NodeSet service | ||
func (r *NodeSetRequester) GetRegistrationStatus() (*types.ApiResponse[api.NodeSetGetRegistrationStatusData], error) { | ||
return client.SendGetRequest[api.NodeSetGetRegistrationStatusData](r, "get-registration-status", "GetRegistrationStatus", nil) | ||
} | ||
|
||
// Registers the node with the NodeSet service | ||
func (r *NodeSetRequester) RegisterNode(email string) (*types.ApiResponse[api.NodeSetRegisterNodeData], error) { | ||
args := map[string]string{ | ||
"email": email, | ||
} | ||
return client.SendGetRequest[api.NodeSetRegisterNodeData](r, "register-node", "RegisterNode", args) | ||
} |
Oops, something went wrong.