Skip to content

Commit

Permalink
Formatting fixes (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xMMBD authored Jul 5, 2024
1 parent e37a5bb commit 6ab32ec
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 23 deletions.
6 changes: 3 additions & 3 deletions libsol/common_byte_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@
0x7c, 0x7c, 0x35, 0xb5, 0xdd, 0xbc, 0x92, 0xbb, 0x81, 0xe4, 0x1f, 0xa8, 0x40, 0x41, 0x05, \
0x44, 0x8d

#define PROGRAM_ID_COMPUTE_BUDGET /* "ComputeBudget111111111111111111111111111111" */ \
0x03, 0x06, 0x46, 0x6f, 0xe5, 0x21, 0x17, 0x32, 0xff, 0xec, 0xad, 0xba, 0x72, 0xc3, \
0x9b, 0xe7, 0xbc, 0x8c, 0xe5, 0xbb, 0xc5, 0xf7, 0x12, 0x6b, 0x2c, 0x43, 0x9b, 0x3a, 0x40, 0x00, \
#define PROGRAM_ID_COMPUTE_BUDGET /* "ComputeBudget111111111111111111111111111111" */ \
0x03, 0x06, 0x46, 0x6f, 0xe5, 0x21, 0x17, 0x32, 0xff, 0xec, 0xad, 0xba, 0x72, 0xc3, 0x9b, \
0xe7, 0xbc, 0x8c, 0xe5, 0xbb, 0xc5, 0xf7, 0x12, 0x6b, 0x2c, 0x43, 0x9b, 0x3a, 0x40, 0x00, \
0x00, 0x00

// Sysvars
Expand Down
14 changes: 10 additions & 4 deletions libsol/compute_budget_instruction.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ static int parse_unit_price_instruction(Parser* parse, ComputeBudgetChangeUnitPr
return 0;
}

static int parse_loaded_accounts_data_size_limit(Parser* parse, ComputeBudgetSetLoadedAccountsDataSizeLimitInfo* info) {
static int parse_loaded_accounts_data_size_limit(
Parser* parse,
ComputeBudgetSetLoadedAccountsDataSizeLimitInfo* info) {
BAIL_IF(parse_u32(parse, &info->units));

return 0;
}

static int print_compute_budget_unit_price(ComputeBudgetChangeUnitPriceInfo* info, const PrintConfig* print_config) {
static int print_compute_budget_unit_price(ComputeBudgetChangeUnitPriceInfo* info,
const PrintConfig* print_config) {
UNUSED(print_config);

SummaryItem* item;
Expand All @@ -55,7 +58,8 @@ static int print_compute_budget_unit_price(ComputeBudgetChangeUnitPriceInfo* inf
return 0;
}

static int print_compute_budget_unit_limit(ComputeBudgetChangeUnitLimitInfo* info, const PrintConfig* print_config) {
static int print_compute_budget_unit_limit(ComputeBudgetChangeUnitLimitInfo* info,
const PrintConfig* print_config) {
UNUSED(print_config);

SummaryItem* item;
Expand Down Expand Up @@ -92,7 +96,9 @@ int parse_compute_budget_instructions(const Instruction* instruction, ComputeBud
case ComputeBudgetChangeUnitPrice:
return parse_unit_price_instruction(&parser, &info->change_unit_price);
case ComputeBudgetSetLoadedAccountsDataSizeLimit:
return parse_loaded_accounts_data_size_limit(&parser, &info->set_loaded_accounts_data_size_limit);
return parse_loaded_accounts_data_size_limit(
&parser,
&info->set_loaded_accounts_data_size_limit);
default:
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion libsol/compute_budget_instruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef struct ComputeBudgetChangeUnitPriceInfo {
uint64_t units;
} ComputeBudgetChangeUnitPriceInfo;

typedef struct ComputeBudgetSetLoadedAccountsDataSizeLimitInfo{
typedef struct ComputeBudgetSetLoadedAccountsDataSizeLimitInfo {
uint32_t units;
} ComputeBudgetSetLoadedAccountsDataSizeLimitInfo;

Expand Down
14 changes: 5 additions & 9 deletions libsol/instruction_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void test_static_brief_initializer_macros() {
assert(memcmp(&stake_test, &stake_expect, sizeof(InstructionBrief)) == 0);
}

void test_instruction_info_matches_brief_constants(){
void test_instruction_info_matches_brief_constants() {
{
InstructionInfo info = {.kind = ProgramIdSerumAssertOwner};
InstructionBrief brief_pass = {.program_id = ProgramIdSerumAssertOwner};
Expand All @@ -160,14 +160,10 @@ void test_instruction_info_matches_brief_constants(){
}
}

void test_instruction_compute_budget_matches_brief(){
InstructionInfo info = {
.kind = ProgramIdComputeBudget,
.compute_budget = {
.kind = ComputeBudgetChangeUnitLimit,
.change_unit_price = {.units = 0xAABBCCDD}
}
};
void test_instruction_compute_budget_matches_brief() {
InstructionInfo info = {.kind = ProgramIdComputeBudget,
.compute_budget = {.kind = ComputeBudgetChangeUnitLimit,
.change_unit_price = {.units = 0xAABBCCDD}}};

{
InstructionBrief brief_pass = {.program_id = ProgramIdComputeBudget,
Expand Down
3 changes: 1 addition & 2 deletions libsol/system_instruction.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,7 @@ static int print_system_transfer_info(const SystemTransferInfo* info,
return 0;
}

int print_system_prefund_for_split(const SystemInfo* info,
const PrintConfig* print_config) {
int print_system_prefund_for_split(const SystemInfo* info, const PrintConfig* print_config) {
if (print_config->expert_mode) {
const SystemTransferInfo* transfer_info = &info->transfer;
SummaryItem* item;
Expand Down
9 changes: 5 additions & 4 deletions libsol/transaction_printers.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,12 +652,12 @@ static int print_transaction_nonce_processed(const PrintConfig* print_config,
// System allocate/assign have no interesting info, print
// stake split as if it were a single instruction
return print_stake_info(&infos[2]->stake, print_config);
} else if(is_stake_split_with_seed_v1_3(infos, infos_length)) {
} else if (is_stake_split_with_seed_v1_3(infos, infos_length)) {
return print_prefunded_split_with_seed(print_config, infos, infos_length);
}
break;
case 4:
if(is_stake_split_v1_3(infos, infos_length)) {
if (is_stake_split_v1_3(infos, infos_length)) {
return print_prefunded_split(print_config, infos, infos_length);
}
break;
Expand All @@ -683,8 +683,9 @@ int print_transaction(const PrintConfig* print_config,

if (infos_length > 1) {
// Iterate over infos and print compute budget instructions and offset pointers
// Handle ComputeBudget instructions first due to tech limitations of the print_transaction_nonce_processed.
// We can get one or 4 ComputeBudget instructions in a single transaction, so we are not able to handle it in a static switch case.
// Handle ComputeBudget instructions first due to tech limitations of the
// print_transaction_nonce_processed. We can get one or 4 ComputeBudget instructions in a
// single transaction, so we are not able to handle it in a static switch case.
size_t infos_length_initial = infos_length;
for (size_t info_idx = 0; info_idx < infos_length_initial; ++info_idx) {
InstructionInfo* instruction_info = infos[0];
Expand Down

0 comments on commit 6ab32ec

Please sign in to comment.