From 790888e77779e1a9954fae60c02cdb586eaa9605 Mon Sep 17 00:00:00 2001 From: keiff3r Date: Thu, 23 Jan 2025 18:31:54 +0100 Subject: [PATCH 1/3] feat: add SELL_VOUCHER_NEW_POL support across contract handling - Introduced new selector STAKEKIT_SELL_VOUCHER_NEW_POL in contract.c. - Updated handle_finalize, handle_init_contract, handle_provide_parameter, handle_query_contract_id, and handle_query_contract_ui to support SELL_VOUCHER_NEW_POL case. - Incremented NUM_STAKEKIT_SELECTORS to 60 in stakekit_plugin.h. --- src/contract.c | 5 +++++ src/handle_finalize.c | 1 + src/handle_init_contract.c | 1 + src/handle_provide_parameter.c | 1 + src/handle_query_contract_id.c | 3 +++ src/handle_query_contract_ui.c | 2 ++ src/stakekit_plugin.h | 2 +- 7 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/contract.c b/src/contract.c index bc0a10b..92d9240 100644 --- a/src/contract.c +++ b/src/contract.c @@ -21,6 +21,10 @@ static const uint8_t STAKEKIT_CLAIM_TOKENS_SELECTOR[SELECTOR_SIZE] = {0x46, 0xe0 static const uint8_t STAKEKIT_BUY_VOUCHER_SELECTOR[SELECTOR_SIZE] = {0x6a, 0xb1, 0x50, 0x71}; static const uint8_t STAKEKIT_BUY_VOUCHER_POL_SELECTOR[SELECTOR_SIZE] = {0xe4, 0x45, 0x7a, 0x8a}; static const uint8_t STAKEKIT_SELL_VOUCHER_NEW_SELECTOR[SELECTOR_SIZE] = {0xc8, 0x3e, 0xc0, 0x4d}; +static const uint8_t STAKEKIT_SELL_VOUCHER_NEW_POL_SELECTOR[SELECTOR_SIZE] = {0xe5, + 0x70, + 0xb7, + 0x8b}; static const uint8_t STAKEKIT_MORPHO_SUPPLY_1_SELECTOR[SELECTOR_SIZE] = {0x0c, 0x0a, 0x76, 0x9b}; static const uint8_t STAKEKIT_MORPHO_SUPPLY_2_SELECTOR[SELECTOR_SIZE] = {0xf2, 0xb9, 0xfd, 0xb8}; static const uint8_t STAKEKIT_MORPHO_SUPPLY_3_SELECTOR[SELECTOR_SIZE] = {0xf6, 0x22, 0x56, 0xc7}; @@ -122,6 +126,7 @@ const uint8_t *const STAKEKIT_SELECTORS[NUM_STAKEKIT_SELECTORS] = { STAKEKIT_BUY_VOUCHER_SELECTOR, STAKEKIT_BUY_VOUCHER_POL_SELECTOR, STAKEKIT_SELL_VOUCHER_NEW_SELECTOR, + STAKEKIT_SELL_VOUCHER_NEW_POL_SELECTOR, STAKEKIT_MORPHO_SUPPLY_1_SELECTOR, STAKEKIT_MORPHO_SUPPLY_2_SELECTOR, STAKEKIT_MORPHO_SUPPLY_3_SELECTOR, diff --git a/src/handle_finalize.c b/src/handle_finalize.c index c1f7331..16a79d1 100644 --- a/src/handle_finalize.c +++ b/src/handle_finalize.c @@ -110,6 +110,7 @@ void handle_finalize(ethPluginFinalize_t *msg) { break; case CLAIM_TOKENS: case SELL_VOUCHER_NEW: + case SELL_VOUCHER_NEW_POL: case AVALANCHE_REDEEM_2: case AVALANCHE_REDEEM_OVERDUE_SHARES_2: msg->numScreens = 1; diff --git a/src/handle_init_contract.c b/src/handle_init_contract.c index ad4925e..4d5c8fb 100644 --- a/src/handle_init_contract.c +++ b/src/handle_init_contract.c @@ -40,6 +40,7 @@ void handle_init_contract(ethPluginInitContract_t *msg) { case BUY_VOUCHER: case BUY_VOUCHER_POL: case SELL_VOUCHER_NEW: + case SELL_VOUCHER_NEW_POL: case ENTER: case LEAVE: case UNLOCK: diff --git a/src/handle_provide_parameter.c b/src/handle_provide_parameter.c index 974ac88..ed87a4d 100644 --- a/src/handle_provide_parameter.c +++ b/src/handle_provide_parameter.c @@ -500,6 +500,7 @@ void handle_provide_parameter(ethPluginProvideParameter_t *msg) { break; case BUY_VOUCHER: case SELL_VOUCHER_NEW: + case SELL_VOUCHER_NEW_POL: case BUY_VOUCHER_POL: // Save the amount sent to the context and skip. copy_parameter(context->amount_sent, msg->parameter, INT256_LENGTH); diff --git a/src/handle_query_contract_id.c b/src/handle_query_contract_id.c index ec3bd9c..ee55e86 100644 --- a/src/handle_query_contract_id.c +++ b/src/handle_query_contract_id.c @@ -45,6 +45,9 @@ void handle_query_contract_id(ethQueryContractID_t *msg) { case SELL_VOUCHER_NEW: strlcpy(msg->version, "Sell Voucher New", msg->versionLength); break; + case SELL_VOUCHER_NEW_POL: + strlcpy(msg->version, "Sell Voucher New POL", msg->versionLength); + break; case MORPHO_SUPPLY_1: case MORPHO_SUPPLY_2: case MORPHO_SUPPLY_3: diff --git a/src/handle_query_contract_ui.c b/src/handle_query_contract_ui.c index d736d68..c6f06df 100644 --- a/src/handle_query_contract_ui.c +++ b/src/handle_query_contract_ui.c @@ -12,6 +12,7 @@ static bool set_send_ui(ethQueryContractUI_t *msg, plugin_parameters_t *context) case BUY_VOUCHER: case BUY_VOUCHER_POL: case SELL_VOUCHER_NEW: + case SELL_VOUCHER_NEW_POL: case MORPHO_SUPPLY_1: case MORPHO_SUPPLY_2: case MORPHO_SUPPLY_3: @@ -650,6 +651,7 @@ static screens_t get_screen(ethQueryContractUI_t *msg, case BUY_VOUCHER: case BUY_VOUCHER_POL: case SELL_VOUCHER_NEW: + case SELL_VOUCHER_NEW_POL: case ENTER: case LEAVE: case UNLOCK: diff --git a/src/stakekit_plugin.h b/src/stakekit_plugin.h index b7c5796..52f45e2 100644 --- a/src/stakekit_plugin.h +++ b/src/stakekit_plugin.h @@ -7,7 +7,7 @@ #define PLUGIN_NAME "StakeKit" -#define NUM_STAKEKIT_SELECTORS 59u +#define NUM_STAKEKIT_SELECTORS 60u #define TICKER_LEN 30u From 61d57474a58fe8ada0a866697ccc4aff391f6e40 Mon Sep 17 00:00:00 2001 From: keiff3r Date: Thu, 23 Jan 2025 18:59:40 +0100 Subject: [PATCH 2/3] feat: add SELL_VOUCHER_NEW_POL support and related tests - Introduced SELL_VOUCHER_NEW_POL enum in stakekit_plugin.h. - Updated b2c.json to include new contract and method selectors for SELL_VOUCHER_NEW_POL. - Added ABI definition for ValidatorShareProxy with new methods. - Created tests for SELL_VOUCHER_NEW_POL functionality in ethereum_sell_voucher_new_pol.test.js. --- src/stakekit_plugin.h | 1 + ...a8e0b998c57a428bf1c26a8baca50524e.abi.json | 834 ++++++++++++++++++ tests/networks/ethereum/stakekit/b2c.json | 47 + .../ethereum_sell_voucher_new_pol.test.js | 39 + 4 files changed, 921 insertions(+) create mode 100644 tests/networks/ethereum/stakekit/abis/0x56d783ca8e0b998c57a428bf1c26a8baca50524e.abi.json create mode 100644 tests/src/ethereum/ethereum_sell_voucher_new_pol.test.js diff --git a/src/stakekit_plugin.h b/src/stakekit_plugin.h index 52f45e2..410f7c9 100644 --- a/src/stakekit_plugin.h +++ b/src/stakekit_plugin.h @@ -49,6 +49,7 @@ typedef enum { BUY_VOUCHER, BUY_VOUCHER_POL, SELL_VOUCHER_NEW, + SELL_VOUCHER_NEW_POL, MORPHO_SUPPLY_1, MORPHO_SUPPLY_2, MORPHO_SUPPLY_3, diff --git a/tests/networks/ethereum/stakekit/abis/0x56d783ca8e0b998c57a428bf1c26a8baca50524e.abi.json b/tests/networks/ethereum/stakekit/abis/0x56d783ca8e0b998c57a428bf1c26a8baca50524e.abi.json new file mode 100644 index 0000000..d4ab850 --- /dev/null +++ b/tests/networks/ethereum/stakekit/abis/0x56d783ca8e0b998c57a428bf1c26a8baca50524e.abi.json @@ -0,0 +1,834 @@ +[ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "constant": false, + "inputs": [{ "internalType": "bool", "name": "pol", "type": "bool" }], + "name": "_restake", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "uint256", "name": "claimAmount", "type": "uint256" }, + { + "internalType": "uint256", + "name": "maximumSharesToBurn", + "type": "uint256" + }, + { "internalType": "bool", "name": "pol", "type": "bool" } + ], + "name": "_sellVoucher_new", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "activeAmount", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "address", "name": "spender", "type": "address" } + ], + "name": "allowance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" } + ], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "uint256", "name": "_amount", "type": "uint256" }, + { + "internalType": "uint256", + "name": "_minSharesToMint", + "type": "uint256" + } + ], + "name": "buyVoucher", + "outputs": [ + { + "internalType": "uint256", + "name": "amountToDeposit", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "uint256", "name": "_amount", "type": "uint256" }, + { + "internalType": "uint256", + "name": "_minSharesToMint", + "type": "uint256" + } + ], + "name": "buyVoucherPOL", + "outputs": [ + { + "internalType": "uint256", + "name": "amountToDeposit", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "uint256", "name": "_amount", "type": "uint256" }, + { + "internalType": "uint256", + "name": "_minSharesToMint", + "type": "uint256" + }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "buyVoucherWithPermit", + "outputs": [ + { + "internalType": "uint256", + "name": "amountToDeposit", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "commissionRate_deprecated", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "delegation", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { + "internalType": "address payable", + "name": "destination", + "type": "address" + }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "drain", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "eventsHub", + "outputs": [ + { "internalType": "contract EventsHub", "name": "", "type": "address" } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "exchangeRate", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "user", "type": "address" } + ], + "name": "getLiquidRewards", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getRewardPerShare", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "user", "type": "address" } + ], + "name": "getTotalStake", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "addedValue", "type": "uint256" } + ], + "name": "increaseAllowance", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "initalRewardPerShare", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "uint256", "name": "_validatorId", "type": "uint256" }, + { + "internalType": "address", + "name": "_stakingLogger", + "type": "address" + }, + { "internalType": "address", "name": "_stakeManager", "type": "address" } + ], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isOwner", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "lastCommissionUpdate_deprecated", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "lock", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "locked", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "user", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "migrateIn", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "user", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "migrateOut", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "minAmount", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "polToken", + "outputs": [ + { "internalType": "contract IERC20Permit", "name": "", "type": "address" } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "restake", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "restakePOL", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "rewardPerShare", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "uint256", "name": "claimAmount", "type": "uint256" }, + { + "internalType": "uint256", + "name": "maximumSharesToBurn", + "type": "uint256" + } + ], + "name": "sellVoucher", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "uint256", "name": "claimAmount", "type": "uint256" }, + { + "internalType": "uint256", + "name": "maximumSharesToBurn", + "type": "uint256" + } + ], + "name": "sellVoucherPOL", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "uint256", "name": "claimAmount", "type": "uint256" }, + { + "internalType": "uint256", + "name": "maximumSharesToBurn", + "type": "uint256" + } + ], + "name": "sellVoucher_new", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "uint256", "name": "claimAmount", "type": "uint256" }, + { + "internalType": "uint256", + "name": "maximumSharesToBurn", + "type": "uint256" + } + ], + "name": "sellVoucher_newPOL", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "validatorStake", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "delegatedAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalAmountToSlash", + "type": "uint256" + } + ], + "name": "slash", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "stakeManager", + "outputs": [ + { + "internalType": "contract IStakeManager", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "stakingLogger", + "outputs": [ + { "internalType": "contract StakingInfo", "name": "", "type": "address" } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalStake_deprecated", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "from", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "newOwner", "type": "address" } + ], + "name": "transferOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "transferPOL", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "unbondNonces", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "unbonds", + "outputs": [ + { "internalType": "uint256", "name": "shares", "type": "uint256" }, + { "internalType": "uint256", "name": "withdrawEpoch", "type": "uint256" } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "name": "unbonds_new", + "outputs": [ + { "internalType": "uint256", "name": "shares", "type": "uint256" }, + { "internalType": "uint256", "name": "withdrawEpoch", "type": "uint256" } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "unlock", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "unstakeClaimTokens", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "unstakeClaimTokensPOL", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "uint256", "name": "unbondNonce", "type": "uint256" } + ], + "name": "unstakeClaimTokens_new", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "uint256", "name": "unbondNonce", "type": "uint256" } + ], + "name": "unstakeClaimTokens_newPOL", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "bool", "name": "_delegation", "type": "bool" } + ], + "name": "updateDelegation", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "validatorId", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "validatorRewards_deprecated", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "withdrawExchangeRate", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "withdrawPool", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "withdrawRewards", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "withdrawRewardsPOL", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "withdrawShares", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/tests/networks/ethereum/stakekit/b2c.json b/tests/networks/ethereum/stakekit/b2c.json index e71f411..3ac500c 100644 --- a/tests/networks/ethereum/stakekit/b2c.json +++ b/tests/networks/ethereum/stakekit/b2c.json @@ -126,6 +126,53 @@ } } }, + + { + "address": "0x56d783ca8e0b998c57a428bf1c26a8baca50524e", + "contractName": "ValidatorShareProxy", + "selectors": { + "0x6ab15071": { + "erc20OfInterest": [], + "method": "buyVoucher", + "plugin": "StakeKit" + }, + "0xe4457a8a": { + "erc20OfInterest": [], + "method": "buyVoucherPOL", + "plugin": "StakeKit" + }, + "0xc83ec04d": { + "erc20OfInterest": [], + "method": "sellVoucher_new", + "plugin": "StakeKit" + }, + "0xe570b78b": { + "erc20OfInterest": [], + "method": "sellVoucher_newPOL", + "plugin": "StakeKit" + }, + "0xe97fddc2": { + "erc20OfInterest": [], + "method": "unstakeClaimTokens_new", + "plugin": "StakeKit" + }, + "0x8759c234": { + "erc20OfInterest": [], + "method": "unstakeClaimTokens_newPOL", + "plugin": "StakeKit" + }, + "0xc7b8981c": { + "erc20OfInterest": [], + "method": "withdrawRewards", + "plugin": "StakeKit" + }, + "0xe0db556b": { + "erc20OfInterest": [], + "method": "withdrawRewardsPOL", + "plugin": "StakeKit" + } + } + }, { "address": "0xc5c9fb6223a989208df27dcee33fc59ff5c26fff", "contractName": "InitializableAdminUpgradeabilityProxy", diff --git a/tests/src/ethereum/ethereum_sell_voucher_new_pol.test.js b/tests/src/ethereum/ethereum_sell_voucher_new_pol.test.js new file mode 100644 index 0000000..a5fb75e --- /dev/null +++ b/tests/src/ethereum/ethereum_sell_voucher_new_pol.test.js @@ -0,0 +1,39 @@ +import { processTest, populateTransaction } from "../test.fixture"; + +const contractName = "ValidatorShareProxy"; // <= Name of the smart contract + +const testLabel = "ethereum_sell_voucher_new_pol"; // <= Name of the test +const testDirSuffix = "ethereum_sell_voucher_new_pol"; // <= directory to compare device snapshots to +const testNetwork = "ethereum"; +const signedPlugin = false; + +const contractAddr = "0x56d783Ca8e0b998C57a428Bf1c26A8baca50524e"; // <= Address of the smart contract +const chainID = 1; + +// From : https://etherscan.io/tx/0x05497a760f918f43533d2608272ac0f9df729063cf10d3f93d823241380b200d +const inputData = "0xe570b78b00000000000000000000000000000000000000000000001491ed349675f9000000000000000000000000000000000000000000000000001491ed349675f90000"; + +// Create serializedTx and remove the "0x" prefix +const serializedTx = populateTransaction(contractAddr, inputData, chainID); + +const devices = [ + { + name: "nanos", + label: "Nano S", + steps: 5, // <= Define the number of steps for this test case and this device + }, + { + name: "nanox", + label: "Nano X", + steps: 4, // <= Define the number of steps for this test case and this device + }, + { + name: "nanosp", + label: "Nano S+", + steps: 4, // <= Define the number of steps for this test case and this device + } +]; + +devices.forEach((device) => + processTest(device, contractName, testLabel, testDirSuffix, "", signedPlugin, serializedTx, testNetwork) +); From d7bc814e0fd0deae0abdd8922fa808e863d576a6 Mon Sep 17 00:00:00 2001 From: keiff3r Date: Thu, 23 Jan 2025 19:15:55 +0100 Subject: [PATCH 3/3] fix: increment NUM_STAKEKIT_SELECTORS to 61 for new SELL_VOUCHER_NEW_POL support --- src/stakekit_plugin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stakekit_plugin.h b/src/stakekit_plugin.h index fff733a..afa1cf2 100644 --- a/src/stakekit_plugin.h +++ b/src/stakekit_plugin.h @@ -7,7 +7,7 @@ #define PLUGIN_NAME "StakeKit" -#define NUM_STAKEKIT_SELECTORS 60u +#define NUM_STAKEKIT_SELECTORS 61u #define TICKER_LEN 30u