Skip to content

Commit

Permalink
Merge pull request #36 from blooo-io/feat/LDG-637-implement-redelegat…
Browse files Browse the repository at this point in the history
…e-method

Feat/ldg 637 implement redelegate method
  • Loading branch information
GuilaneDen authored Jan 2, 2025
2 parents bd55170 + 5dfe19e commit 8c1f5cc
Show file tree
Hide file tree
Showing 118 changed files with 256 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ APPNAME = "StakeKit"

# Application version
APPVERSION_M = 1
APPVERSION_N = 2
APPVERSION_P = 2
APPVERSION_N = 3
APPVERSION_P = 0

include ethereum-plugin-sdk/standard_plugin.mk
7 changes: 5 additions & 2 deletions src/contract.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ static const uint8_t STAKEKIT_VIC_RESIGN_SELECTOR[SELECTOR_SIZE] = {0xae, 0x6e,
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};

static const uint8_t STAKEKIT_DELEGATE_SELECTOR[SELECTOR_SIZE] = {0x98, 0x2e, 0xf0, 0xa7};
static const uint8_t STAKEKIT_REDELEGATE_SELECTOR[SELECTOR_SIZE] = {0x59, 0x49, 0x18, 0x71};
// Array of all the different StakeKit selectors.
const uint8_t *const STAKEKIT_SELECTORS[NUM_STAKEKIT_SELECTORS] = {
STAKEKIT_DEPOSIT_SELF_APECOIN_SELECTOR,
Expand Down Expand Up @@ -162,7 +163,9 @@ const uint8_t *const STAKEKIT_SELECTORS[NUM_STAKEKIT_SELECTORS] = {
STAKEKIT_VIC_RESIGN_SELECTOR,
STAKEKIT_VIC_UNVOTE_SELECTOR,
STAKEKIT_VIC_WITHDRAW_SELECTOR,
STAKEKIT_CLAIM_SELECTOR};
STAKEKIT_CLAIM_SELECTOR,
STAKEKIT_DELEGATE_SELECTOR,
STAKEKIT_REDELEGATE_SELECTOR};

// Null address
const uint8_t NULL_ETH_ADDRESS[ADDRESS_LENGTH] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down
5 changes: 5 additions & 0 deletions src/handle_finalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,14 @@ void handle_finalize(ethPluginFinalize_t *msg) {
switch (context->selectorIndex) {
case COMET_CLAIM:
case CLAIM:
case DELEGATE:
msg->numScreens = 2;
msg->result = ETH_PLUGIN_RESULT_OK;
break;
case REDELEGATE:
msg->numScreens = 3;
msg->result = ETH_PLUGIN_RESULT_OK;
break;
case VOTE:
msg->numScreens = 4;
msg->result = ETH_PLUGIN_RESULT_OK;
Expand Down
2 changes: 2 additions & 0 deletions src/handle_init_contract.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ void handle_init_contract(ethPluginInitContract_t *msg) {
case REVOKE_ACTIVE:
case VIC_UNVOTE:
case CLAIM:
case DELEGATE:
case REDELEGATE:
context->next_param = RECIPIENT;
break;
case MORPHO_SUPPLY_1:
Expand Down
39 changes: 36 additions & 3 deletions src/handle_provide_parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,9 @@ 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) {
// The second param is the [request number | vote power | shares] saved in amount_sent.
static void handle_claim_and_delegate(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);
Expand All @@ -243,6 +244,34 @@ static void handle_claim(ethPluginProvideParameter_t *msg, plugin_parameters_t *
}
}

// Save 2 operator and 1 amount in the context.
// The first param is the old operator address saved in recipient.
// The second param is the new operator address saved in contract_address.
// The third param is the delegateVotePower saved in amount_received.
static void handle_redelegate(ethPluginProvideParameter_t *msg, plugin_parameters_t *context) {
switch (context->next_param) {
case RECIPIENT: // Put the old operator address in recipient
copy_address(context->recipient, msg->parameter, ADDRESS_LENGTH);
context->next_param = RECIPIENT_2;
break;
case RECIPIENT_2: // Put the new operator address in contract_address
copy_address(context->contract_address, msg->parameter, ADDRESS_LENGTH);
context->next_param = AMOUNT_SENT;
context->skip = 1;
break;
case AMOUNT_SENT: // Skip shares and put the delegateVotePower in amount_sent
copy_parameter(context->amount_sent, msg->parameter, INT256_LENGTH);
context->next_param = AMOUNT_RECEIVED;
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 @@ -559,7 +588,11 @@ void handle_provide_parameter(ethPluginProvideParameter_t *msg) {
handle_lido_claim_withdrawal(msg, context);
break;
case CLAIM:
handle_claim(msg, context);
case DELEGATE:
handle_claim_and_delegate(msg, context);
break;
case REDELEGATE:
handle_redelegate(msg, context);
break;
case VIC_VOTE:
case VIC_RESIGN:
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 @@ -66,11 +66,15 @@ void handle_query_contract_id(ethQueryContractID_t *msg) {
strlcpy(msg->version, "Deposit", msg->versionLength);
break;
case GRT_DELEGATE:
case DELEGATE:
strlcpy(msg->version, "Delegate", msg->versionLength);
break;
case GRT_UNDELEGATE:
strlcpy(msg->version, "Undelegate", msg->versionLength);
break;
case REDELEGATE:
strlcpy(msg->version, "Redelegate", msg->versionLength);
break;
case GRT_WITHDRAW_DELEGATED:
strlcpy(msg->version, "Withdraw Delegated", msg->versionLength);
break;
Expand Down
57 changes: 57 additions & 0 deletions src/handle_query_contract_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ static bool set_send_ui(ethQueryContractUI_t *msg, plugin_parameters_t *context)
case CLAIM:
strlcpy(msg->title, "Request Number", msg->titleLength);
break;
case DELEGATE:
strlcpy(msg->title, "Vote Power", msg->titleLength);
break;
default:
PRINTF("Unhandled selector Index: %d\n", context->selectorIndex);
return false;
Expand Down Expand Up @@ -261,8 +264,12 @@ static bool set_recipient_ui(ethQueryContractUI_t *msg, plugin_parameters_t *con
strlcpy(msg->title, "Candidate", msg->titleLength);
break;
case CLAIM:
case DELEGATE:
strlcpy(msg->title, "Operator", msg->titleLength);
break;
case REDELEGATE:
strlcpy(msg->title, "Old Operator", msg->titleLength);
break;
default:
PRINTF("Unhandled selector Index: %d\n", context->selectorIndex);
return false;
Expand All @@ -286,6 +293,9 @@ static bool set_recipient_2_ui(ethQueryContractUI_t *msg, plugin_parameters_t *c
case ANGLE_WITHDRAW:
strlcpy(msg->title, "Owner", msg->titleLength);
break;
case REDELEGATE:
strlcpy(msg->title, "New Operator", msg->titleLength);
break;
default:
PRINTF("Unhandled selector Index: %d\n", context->selectorIndex);
return false;
Expand Down Expand Up @@ -370,6 +380,18 @@ static bool set_warning_ui(ethQueryContractUI_t *msg,
return true;
}

// Set UI for "Vote Power" screen.
static bool set_delegate_vote_power_ui(ethQueryContractUI_t *msg,
plugin_parameters_t *context __attribute__((unused))) {
strlcpy(msg->title, "Vote Power", msg->titleLength);
if (ADDRESS_IS_NULL(context->amount_sent)) {
strlcpy(msg->msg, "False", msg->msgLength);
} else {
strlcpy(msg->msg, "True", msg->msgLength);
}
return true;
}

// Set UI for the methods needing a send screen.
static screens_t get_screen_amount_sent(ethQueryContractUI_t *msg,
plugin_parameters_t *context __attribute__((unused))) {
Expand Down Expand Up @@ -406,6 +428,34 @@ static screens_t get_screen_amount_sent_recipient(ethQueryContractUI_t *msg,
}
}

// Set UI for the methods needing a send and vote power screens.
static screens_t get_screen_delegate(ethQueryContractUI_t *msg,
plugin_parameters_t *context __attribute__((unused))) {
switch (msg->screenIndex) {
case 0:
return DELEGATE_VOTE_POWER_SCREEN;
case 1:
return RECIPIENT_SCREEN;
default:
return ERROR;
}
}

// Set UI for the methods needing a send and vote power screens.
static screens_t get_screen_redelegate(ethQueryContractUI_t *msg,
plugin_parameters_t *context __attribute__((unused))) {
switch (msg->screenIndex) {
case 0:
return DELEGATE_VOTE_POWER_SCREEN;
case 1:
return RECIPIENT_SCREEN;
case 2:
return RECIPIENT_2_SCREEN;
default:
return ERROR;
}
}

// Set UI for the methods needing a send and recipient screens.
// If the token is not found, we need an additional screen to display a warning message.
static screens_t get_screen_supply(ethQueryContractUI_t *msg,
Expand Down Expand Up @@ -628,6 +678,10 @@ static screens_t get_screen(ethQueryContractUI_t *msg,
case VIC_UNVOTE:
case CLAIM:
return get_screen_amount_sent_recipient(msg, context);
case DELEGATE:
return get_screen_delegate(msg, context);
case REDELEGATE:
return get_screen_redelegate(msg, context);
case MORPHO_SUPPLY_1:
case MORPHO_SUPPLY_2:
case MORPHO_SUPPLY_3:
Expand Down Expand Up @@ -709,6 +763,9 @@ void handle_query_contract_ui(ethQueryContractUI_t *msg) {
case RECEIVE_2_SCREEN:
ret = set_receive_2_ui(msg, context);
break;
case DELEGATE_VOTE_POWER_SCREEN:
ret = set_delegate_vote_power_ui(msg, context);
break;
case WARN_SCREEN:
ret = set_warning_ui(msg, context);
break;
Expand Down
5 changes: 4 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 56u
#define NUM_STAKEKIT_SELECTORS 58u

#define TICKER_LEN 30u

Expand Down Expand Up @@ -92,6 +92,8 @@ typedef enum {
VIC_UNVOTE,
VIC_WITHDRAW,
CLAIM,
DELEGATE,
REDELEGATE,
} selector_t;

extern const uint8_t *const STAKEKIT_SELECTORS[NUM_STAKEKIT_SELECTORS];
Expand All @@ -108,6 +110,7 @@ typedef enum {
WARN_SCREEN,
SEND_2_SCREEN,
RECEIVE_2_SCREEN,
DELEGATE_VOTE_POWER_SCREEN,
ERROR,
} screens_t;

Expand Down
Binary file added tests/snapshots/bsc_flex_bsc_delegate/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_flex_bsc_delegate/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_flex_bsc_delegate/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_flex_bsc_delegate/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_flex_bsc_delegate/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_flex_bsc_redelegate/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_flex_bsc_redelegate/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_flex_bsc_redelegate/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_flex_bsc_redelegate/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_flex_bsc_undelegate/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_flex_bsc_undelegate/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_flex_bsc_undelegate/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_flex_bsc_undelegate/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_nanos_bsc_delegate/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_nanos_bsc_delegate/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_nanos_bsc_delegate/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_nanos_bsc_delegate/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_nanos_bsc_delegate/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_nanos_bsc_delegate/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_nanos_bsc_delegate/00006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_nanos_bsc_delegate/00007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_nanos_bsc_delegate/00008.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_nanos_bsc_delegate/00009.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_nanos_bsc_redelegate/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/bsc_nanos_bsc_redelegate/00001.png
Binary file added tests/snapshots/bsc_nanos_bsc_redelegate/00002.png
Binary file added tests/snapshots/bsc_nanos_bsc_redelegate/00003.png
Binary file added tests/snapshots/bsc_nanos_bsc_redelegate/00004.png
Binary file added tests/snapshots/bsc_nanos_bsc_redelegate/00005.png
Binary file added tests/snapshots/bsc_nanos_bsc_redelegate/00006.png
Binary file added tests/snapshots/bsc_nanos_bsc_redelegate/00007.png
Binary file added tests/snapshots/bsc_nanos_bsc_redelegate/00008.png
Binary file added tests/snapshots/bsc_nanos_bsc_redelegate/00009.png
Binary file added tests/snapshots/bsc_nanos_bsc_redelegate/00010.png
Binary file added tests/snapshots/bsc_nanos_bsc_redelegate/00011.png
Binary file added tests/snapshots/bsc_nanos_bsc_redelegate/00012.png
Binary file added tests/snapshots/bsc_nanos_bsc_undelegate/00000.png
Binary file added tests/snapshots/bsc_nanos_bsc_undelegate/00001.png
Binary file added tests/snapshots/bsc_nanos_bsc_undelegate/00002.png
Binary file added tests/snapshots/bsc_nanos_bsc_undelegate/00003.png
Binary file added tests/snapshots/bsc_nanos_bsc_undelegate/00004.png
Binary file added tests/snapshots/bsc_nanos_bsc_undelegate/00005.png
Binary file added tests/snapshots/bsc_nanos_bsc_undelegate/00006.png
Binary file added tests/snapshots/bsc_nanos_bsc_undelegate/00007.png
Binary file added tests/snapshots/bsc_nanos_bsc_undelegate/00008.png
Binary file added tests/snapshots/bsc_nanosp_bsc_delegate/00000.png
Binary file added tests/snapshots/bsc_nanosp_bsc_delegate/00001.png
Binary file added tests/snapshots/bsc_nanosp_bsc_delegate/00002.png
Binary file added tests/snapshots/bsc_nanosp_bsc_delegate/00003.png
Binary file added tests/snapshots/bsc_nanosp_bsc_delegate/00004.png
Binary file added tests/snapshots/bsc_nanosp_bsc_delegate/00005.png
Binary file added tests/snapshots/bsc_nanosp_bsc_delegate/00006.png
Binary file added tests/snapshots/bsc_nanosp_bsc_delegate/00007.png
Binary file added tests/snapshots/bsc_nanosp_bsc_redelegate/00000.png
Binary file added tests/snapshots/bsc_nanosp_bsc_redelegate/00001.png
Binary file added tests/snapshots/bsc_nanosp_bsc_redelegate/00002.png
Binary file added tests/snapshots/bsc_nanosp_bsc_redelegate/00003.png
Binary file added tests/snapshots/bsc_nanosp_bsc_redelegate/00004.png
Binary file added tests/snapshots/bsc_nanosp_bsc_redelegate/00005.png
Binary file added tests/snapshots/bsc_nanosp_bsc_redelegate/00006.png
Binary file added tests/snapshots/bsc_nanosp_bsc_redelegate/00007.png
Binary file added tests/snapshots/bsc_nanosp_bsc_redelegate/00008.png
Binary file added tests/snapshots/bsc_nanosp_bsc_undelegate/00000.png
Binary file added tests/snapshots/bsc_nanosp_bsc_undelegate/00001.png
Binary file added tests/snapshots/bsc_nanosp_bsc_undelegate/00002.png
Binary file added tests/snapshots/bsc_nanosp_bsc_undelegate/00003.png
Binary file added tests/snapshots/bsc_nanosp_bsc_undelegate/00004.png
Binary file added tests/snapshots/bsc_nanosp_bsc_undelegate/00005.png
Binary file added tests/snapshots/bsc_nanosp_bsc_undelegate/00006.png
Binary file added tests/snapshots/bsc_nanox_bsc_delegate/00000.png
Binary file added tests/snapshots/bsc_nanox_bsc_delegate/00001.png
Binary file added tests/snapshots/bsc_nanox_bsc_delegate/00002.png
Binary file added tests/snapshots/bsc_nanox_bsc_delegate/00003.png
Binary file added tests/snapshots/bsc_nanox_bsc_delegate/00004.png
Binary file added tests/snapshots/bsc_nanox_bsc_delegate/00005.png
Binary file added tests/snapshots/bsc_nanox_bsc_delegate/00006.png
Binary file added tests/snapshots/bsc_nanox_bsc_delegate/00007.png
Binary file added tests/snapshots/bsc_nanox_bsc_redelegate/00000.png
Binary file added tests/snapshots/bsc_nanox_bsc_redelegate/00001.png
Binary file added tests/snapshots/bsc_nanox_bsc_redelegate/00002.png
Binary file added tests/snapshots/bsc_nanox_bsc_redelegate/00003.png
Binary file added tests/snapshots/bsc_nanox_bsc_redelegate/00004.png
Binary file added tests/snapshots/bsc_nanox_bsc_redelegate/00005.png
Binary file added tests/snapshots/bsc_nanox_bsc_redelegate/00006.png
Binary file added tests/snapshots/bsc_nanox_bsc_redelegate/00007.png
Binary file added tests/snapshots/bsc_nanox_bsc_redelegate/00008.png
Binary file added tests/snapshots/bsc_nanox_bsc_undelegate/00000.png
Binary file added tests/snapshots/bsc_nanox_bsc_undelegate/00001.png
Binary file added tests/snapshots/bsc_nanox_bsc_undelegate/00002.png
Binary file added tests/snapshots/bsc_nanox_bsc_undelegate/00003.png
Binary file added tests/snapshots/bsc_nanox_bsc_undelegate/00004.png
Binary file added tests/snapshots/bsc_nanox_bsc_undelegate/00005.png
Binary file added tests/snapshots/bsc_nanox_bsc_undelegate/00006.png
Binary file added tests/snapshots/bsc_stax_bsc_delegate/00001.png
Binary file added tests/snapshots/bsc_stax_bsc_delegate/00002.png
Binary file added tests/snapshots/bsc_stax_bsc_delegate/00003.png
Binary file added tests/snapshots/bsc_stax_bsc_redelegate/00000.png
Binary file added tests/snapshots/bsc_stax_bsc_redelegate/00001.png
Binary file added tests/snapshots/bsc_stax_bsc_redelegate/00003.png
Binary file added tests/snapshots/bsc_stax_bsc_redelegate/00004.png
Binary file added tests/snapshots/bsc_stax_bsc_undelegate/00000.png
Binary file added tests/snapshots/bsc_stax_bsc_undelegate/00001.png
Binary file added tests/snapshots/bsc_stax_bsc_undelegate/00002.png
Binary file added tests/snapshots/bsc_stax_bsc_undelegate/00003.png
47 changes: 47 additions & 0 deletions tests/src/bsc/bsc_delegate.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { processTest, populateTransaction } from "../test.fixture";

const contractName = "StakeHub"; // <= Name of the smart contract

const testLabel = "bsc_delegate"; // <= Name of the test
const testDirSuffix = "bsc_delegate"; // <= directory to compare device snapshots to
const testNetwork = "bsc";
const signedPlugin = false;

const contractAddr = "0x0000000000000000000000000000000000002002"; // <= Address of the smart contract
const chainID = 56;

// From : https://bscscan.com/tx/0x16a08e90b09c97842f2656d1b2bb0f3f65c9d8cbcd1e318d45a89cceaa7c397b
const inputData = "0x982ef0a700000000000000000000000031738238b6a4fcb00ba4de9ee923986b6df55ae60000000000000000000000000000000000000000000000000000000000000000";

// Create serializedTx and remove the "0x" prefix
const serializedTx = populateTransaction(contractAddr, inputData, chainID);

const devices = [
{
name: "nanos",
label: "Nano S",
steps: 8, // <= Define the number of steps for this test case and this device
},
{
name: "nanox",
label: "Nano X",
steps: 6, // <= Define the number of steps for this test case and this device
},
{
name: "nanosp",
label: "Nano S+",
steps: 6, // <= Define the number of steps for this test case and this device
},
{
name: "stax",
label: "Stax",
},
{
name: "flex",
label: "Flex",
}
];

devices.forEach((device) =>
processTest(device, contractName, testLabel, testDirSuffix, "", signedPlugin, serializedTx, testNetwork)
);
47 changes: 47 additions & 0 deletions tests/src/bsc/bsc_redelegate.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { processTest, populateTransaction } from "../test.fixture";

const contractName = "StakeHub"; // <= Name of the smart contract

const testLabel = "bsc_redelegate"; // <= Name of the test
const testDirSuffix = "bsc_redelegate"; // <= directory to compare device snapshots to
const testNetwork = "bsc";
const signedPlugin = false;

const contractAddr = "0x0000000000000000000000000000000000002002"; // <= Address of the smart contract
const chainID = 56;

// From : https://bscscan.com/tx/0x7e69d623b177ef2b1dc7e4342e05e68104ff63a0cfccc44b4badefcfc07a2b63
const inputData = "0x594918710000000000000000000000009941bce2601fc93478df9f5f6cc83f4ffc1d71d800000000000000000000000031738238b6a4fcb00ba4de9ee923986b6df55ae6000000000000000000000000000000000000000000000000468aa1967d98533d0000000000000000000000000000000000000000000000000000000000000000";

// Create serializedTx and remove the "0x" prefix
const serializedTx = populateTransaction(contractAddr, inputData, chainID);

const devices = [
{
name: "nanos",
label: "Nano S",
steps: 11, // <= Define the number of steps for this test case and this device
},
{
name: "nanox",
label: "Nano X",
steps: 7, // <= Define the number of steps for this test case and this device
},
{
name: "nanosp",
label: "Nano S+",
steps: 7, // <= Define the number of steps for this test case and this device
},
{
name: "stax",
label: "Stax",
},
{
name: "flex",
label: "Flex",
}
];

devices.forEach((device) =>
processTest(device, contractName, testLabel, testDirSuffix, "", signedPlugin, serializedTx, testNetwork)
);
Loading

0 comments on commit 8c1f5cc

Please sign in to comment.