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

Ldg 653 implement method create reward vault #5

Merged
merged 6 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/handle_finalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ void handle_finalize(ethPluginFinalize_t *msg) {
msg->uiType = ETH_UI_TYPE_GENERIC;

switch (context->selectorIndex) {
case CREATE_REWARD_VAULT:
case DELEGATE:
msg->numScreens = 1;
break;
Expand Down
1 change: 1 addition & 0 deletions src/handle_init_contract.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void handle_init_contract(ethPluginInitContract_t *msg) {
// EDIT THIS: Adapt the `cases`, and set the `next_param` to be the first parameter you expect
// to parse.
switch (context->selectorIndex) {
case CREATE_REWARD_VAULT:
case DELEGATE:
context->next_param = BENEFICIARY;
break;
Expand Down
6 changes: 3 additions & 3 deletions src/handle_provide_parameter.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "plugin.h"

static void handle_delegate(ethPluginProvideParameter_t *msg, context_t *context) {
static void handle_beneficiary(ethPluginProvideParameter_t *msg, context_t *context) {
switch (context->next_param) {
case BENEFICIARY:
copy_address(context->beneficiary, msg->parameter, sizeof(context->beneficiary));
Expand All @@ -24,13 +24,13 @@ void handle_provide_parameter(ethPluginProvideParameter_t *msg) {
msg->parameterOffset,
PARAMETER_LENGTH,
msg->parameter);

msg->result = ETH_PLUGIN_RESULT_OK;

// EDIT THIS: adapt the cases and the names of the functions.
switch (context->selectorIndex) {
case CREATE_REWARD_VAULT:
case DELEGATE:
handle_delegate(msg, context);
handle_beneficiary(msg, context);
break;
default:
PRINTF("Selector Index not supported: %d\n", context->selectorIndex);
Expand Down
4 changes: 4 additions & 0 deletions src/handle_query_contract_id.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ void handle_query_contract_id(ethQueryContractID_t *msg) {

// EDIT THIS: Adapt the cases by modifying the strings you pass to `strlcpy`.
switch (context->selectorIndex) {
case CREATE_REWARD_VAULT:
strlcpy(msg->version, "Create Reward Vault", msg->versionLength);
msg->result = ETH_PLUGIN_RESULT_OK;
break;
case DELEGATE:
strlcpy(msg->version, "Delegate", msg->versionLength);
msg->result = ETH_PLUGIN_RESULT_OK;
Expand Down
16 changes: 13 additions & 3 deletions src/handle_query_contract_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,18 @@
} */

// Set UI for "Beneficiary" screen.
// EDIT THIS: Adapt / remove this function to your needs.
static bool set_beneficiary_ui(ethQueryContractUI_t *msg, context_t *context) {
strlcpy(msg->title, "Beneficiary", msg->titleLength);
switch (context->selectorIndex) {
case CREATE_REWARD_VAULT:
strlcpy(msg->title, "Address", msg->titleLength);
break;
case DELEGATE:
strlcpy(msg->title, "Beneficiary", msg->titleLength);
break;
default:
PRINTF("Received an invalid selectorIndex\n");
break;
}

// Prefix the address with `0x`.
msg->msg[0] = '0';
Expand Down Expand Up @@ -77,6 +86,7 @@ void handle_query_contract_ui(ethQueryContractUI_t *msg) {

// EDIT THIS: Adapt the cases for the screens you'd like to display.
switch (context->selectorIndex) {
case CREATE_REWARD_VAULT:
case DELEGATE:
switch (msg->screenIndex) {
case 0:
Expand All @@ -88,7 +98,7 @@ void handle_query_contract_ui(ethQueryContractUI_t *msg) {
}
break;
default:
PRINTF("Received an invalid screenIndex\n");
PRINTF("Received an invalid selectorIndex\n");
break;
}
msg->result = ret ? ETH_PLUGIN_RESULT_OK : ETH_PLUGIN_RESULT_ERROR;
Expand Down
4 changes: 3 additions & 1 deletion src/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
// A Xmacro below will create for you:
// - an enum named selector_t with every NAME
// - a map named SELECTORS associating each NAME with it's value
#define SELECTORS_LIST(X) X(DELEGATE, 0x5c19a95c)
#define SELECTORS_LIST(X) \
X(CREATE_REWARD_VAULT, 0x577ee5c7) \
X(DELEGATE, 0x5c19a95c)

// Xmacro helpers to define the enum and map
// Do not modify !
Expand Down
Loading
Loading