Skip to content

Commit

Permalink
Merge pull request #35 from blooo-io/feat/LDG-636-implement-claim-method
Browse files Browse the repository at this point in the history
feat(claim): added new abi and info in b2c.json + implemented claim m…
  • Loading branch information
GuilaneDen authored Dec 31, 2024
2 parents 5f6e3ef + cedc9cc commit bd55170
Show file tree
Hide file tree
Showing 47 changed files with 1,981 additions and 58 deletions.
33 changes: 11 additions & 22 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
name: "nanosp"
- sdk: "$STAX_SDK"
name: "stax"
- sdk: "$FLEX_SDK"
name: "flex"

runs-on: ubuntu-latest
container:
Expand All @@ -38,27 +40,6 @@ jobs:
run: |
make BOLOS_SDK=${{ matrix.sdk }} -j
job_scan_build:
name: Clang Static Analyzer
runs-on: ubuntu-latest
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Build with Clang Static Analyzer
run: |
scan-build --use-cc=clang -analyze-headers -enable-checker security -enable-checker unix -enable-checker valist -o scan-build --status-bugs make default
- uses: actions/upload-artifact@v3
if: failure()
with:
name: scan-build
path: scan-build

job_build_debug_plugin:
name: Build debug plugin
strategy:
Expand All @@ -70,6 +51,10 @@ jobs:
name: "nanox"
- sdk: "$NANOSP_SDK"
name: "nanosp"
- sdk: "$STAX_SDK"
name: "stax"
- sdk: "$FLEX_SDK"
name: "flex"

runs-on: ubuntu-latest
container:
Expand Down Expand Up @@ -106,6 +91,10 @@ jobs:
name: "nanox"
- sdk: "$NANOSP_SDK"
name: "nanosp"
- sdk: "$STAX_SDK"
name: "stax"
- sdk: "$FLEX_SDK"
name: "flex"

runs-on: ubuntu-latest
container:
Expand All @@ -116,8 +105,8 @@ jobs:
uses: actions/checkout@v3
with:
repository: LedgerHQ/app-ethereum
submodules: recursive
ref: ${{ ((github.base_ref || github.ref_name) == 'main' && 'master') || (github.base_ref || github.ref_name) }}
submodules: true

- name: Build
run: |
Expand Down
3 changes: 2 additions & 1 deletion src/contract.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ static const uint8_t STAKEKIT_VIC_VOTE_SELECTOR[SELECTOR_SIZE] = {0x6d, 0xd7, 0x
static const uint8_t STAKEKIT_VIC_RESIGN_SELECTOR[SELECTOR_SIZE] = {0xae, 0x6e, 0x43, 0xf5};
static const uint8_t STAKEKIT_VIC_UNVOTE_SELECTOR[SELECTOR_SIZE] = {0x02, 0xaa, 0x9b, 0xe2};
static const uint8_t STAKEKIT_VIC_WITHDRAW_SELECTOR[SELECTOR_SIZE] = {0x44, 0x1a, 0x3e, 0x70};
static const uint8_t STAKEKIT_CLAIM_SELECTOR[SELECTOR_SIZE] = {0xaa, 0xd3, 0xec, 0x96};

// Array of all the different StakeKit selectors.
const uint8_t *const STAKEKIT_SELECTORS[NUM_STAKEKIT_SELECTORS] = {
Expand Down Expand Up @@ -161,7 +162,7 @@ const uint8_t *const STAKEKIT_SELECTORS[NUM_STAKEKIT_SELECTORS] = {
STAKEKIT_VIC_RESIGN_SELECTOR,
STAKEKIT_VIC_UNVOTE_SELECTOR,
STAKEKIT_VIC_WITHDRAW_SELECTOR,
};
STAKEKIT_CLAIM_SELECTOR};

// Null address
const uint8_t NULL_ETH_ADDRESS[ADDRESS_LENGTH] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down
1 change: 1 addition & 0 deletions src/handle_finalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ void handle_finalize(ethPluginFinalize_t *msg) {
if (context->valid) {
switch (context->selectorIndex) {
case COMET_CLAIM:
case CLAIM:
msg->numScreens = 2;
msg->result = ETH_PLUGIN_RESULT_OK;
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 @@ -80,6 +80,7 @@ void handle_init_contract(ethPluginInitContract_t *msg) {
case VOTE:
case REVOKE_ACTIVE:
case VIC_UNVOTE:
case CLAIM:
context->next_param = RECIPIENT;
break;
case MORPHO_SUPPLY_1:
Expand Down
25 changes: 25 additions & 0 deletions src/handle_provide_parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,28 @@ static void handle_comet_claim(ethPluginProvideParameter_t *msg, plugin_paramete
}
}

// Save 1 amount and 1 recipient in the context.
// The first param is the operator saved in recipient.
// The second param is the request number saved in amount_sent.
static void handle_claim(ethPluginProvideParameter_t *msg, plugin_parameters_t *context) {
switch (context->next_param) {
case RECIPIENT: // Put the operator address in recipient
copy_address(context->recipient, msg->parameter, ADDRESS_LENGTH);
context->next_param = AMOUNT_SENT;
break;
case AMOUNT_SENT:
copy_parameter(context->amount_sent, msg->parameter, INT256_LENGTH);
context->next_param = NONE;
break;
case NONE:
break;
default:
PRINTF("Param not supported\n");
msg->result = ETH_PLUGIN_RESULT_ERROR;
break;
}
}

// Save 1 amount and 3 recipients in the context.
// The first param is the second recipient saved in recipient.
// The second param is the amount sent saved in amount_sent.
Expand Down Expand Up @@ -536,6 +558,9 @@ void handle_provide_parameter(ethPluginProvideParameter_t *msg) {
case LIDO_CLAIM_WITHDRAWALS:
handle_lido_claim_withdrawal(msg, context);
break;
case CLAIM:
handle_claim(msg, context);
break;
case VIC_VOTE:
case VIC_RESIGN:
// Only save the recipient to the context.
Expand Down
1 change: 1 addition & 0 deletions src/handle_query_contract_id.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ void handle_query_contract_id(ethQueryContractID_t *msg) {
strlcpy(msg->version, "Leave", msg->versionLength);
break;
case COMET_CLAIM:
case CLAIM:
strlcpy(msg->version, "Claim", msg->versionLength);
break;
case TRANSFER_OUT:
Expand Down
7 changes: 7 additions & 0 deletions src/handle_query_contract_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ static bool set_send_ui(ethQueryContractUI_t *msg, plugin_parameters_t *context)
case VIC_UNVOTE:
strlcpy(msg->title, "Cap", msg->titleLength);
break;
case CLAIM:
strlcpy(msg->title, "Request Number", msg->titleLength);
break;
default:
PRINTF("Unhandled selector Index: %d\n", context->selectorIndex);
return false;
Expand Down Expand Up @@ -257,6 +260,9 @@ static bool set_recipient_ui(ethQueryContractUI_t *msg, plugin_parameters_t *con
case VIC_UNVOTE:
strlcpy(msg->title, "Candidate", msg->titleLength);
break;
case CLAIM:
strlcpy(msg->title, "Operator", msg->titleLength);
break;
default:
PRINTF("Unhandled selector Index: %d\n", context->selectorIndex);
return false;
Expand Down Expand Up @@ -620,6 +626,7 @@ static screens_t get_screen(ethQueryContractUI_t *msg,
case YEARN_VAULT_WITHDRAW_3:
case LIDO_REQUEST_WITHDRAWALS:
case VIC_UNVOTE:
case CLAIM:
return get_screen_amount_sent_recipient(msg, context);
case MORPHO_SUPPLY_1:
case MORPHO_SUPPLY_2:
Expand Down
3 changes: 2 additions & 1 deletion src/stakekit_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#define PLUGIN_NAME "StakeKit"

#define NUM_STAKEKIT_SELECTORS 55u
#define NUM_STAKEKIT_SELECTORS 56u

#define TICKER_LEN 30u

Expand Down Expand Up @@ -91,6 +91,7 @@ typedef enum {
VIC_RESIGN,
VIC_UNVOTE,
VIC_WITHDRAW,
CLAIM,
} selector_t;

extern const uint8_t *const STAKEKIT_SELECTORS[NUM_STAKEKIT_SELECTORS];
Expand Down
Loading

0 comments on commit bd55170

Please sign in to comment.