Skip to content

Commit

Permalink
Merge pull request #5 from blooo-io/LDG-653-implement-method-createRe…
Browse files Browse the repository at this point in the history
…wardVault

Ldg 653 implement method create reward vault
  • Loading branch information
Steven2505 authored Jan 21, 2025
2 parents f6ec017 + 9045067 commit b5a2c92
Show file tree
Hide file tree
Showing 31 changed files with 1,037 additions and 8 deletions.
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

0 comments on commit b5a2c92

Please sign in to comment.