Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdk: fix broken C examples #33701

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion programs/sbf/c/src/move_funds/move_funds.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <solana_sdk.h>

/**
* Number of SolKeyedAccount expected. The program should bail if an
* Number of SolAccountInfo expected. The program should bail if an
* unexpected number of accounts are passed to the program's entrypoint
*/
#define NUM_KA 3
Expand Down
14 changes: 6 additions & 8 deletions sdk/bpf/c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ and `src/program.c` containing:
```c
#include <solana_sdk.h>

bool entrypoint(const uint8_t *input) {
SolKeyedAccount ka[1];
uint8_t *data;
uint64_t data_len;
extern uint64_t entrypoint(const uint8_t *input) {
SolAccountInfo ka[1];
SolParameters params = (SolParameters) { .ka = ka };

if (!sol_deserialize(buf, ka, SOL_ARRAY_SIZE(ka), NULL, &data, &data_len)) {
return false;
if (!sol_deserialize(input, &params, SOL_ARRAY_SIZE(ka))) {
return ERROR_INVALID_ARGUMENT;
}
print_params(1, ka, data, data_len);
return true;
return SUCCESS;
}
```

Expand Down
14 changes: 6 additions & 8 deletions sdk/sbf/c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ and `src/program.c` containing:
```c
#include <solana_sdk.h>

bool entrypoint(const uint8_t *input) {
SolKeyedAccount ka[1];
uint8_t *data;
uint64_t data_len;
extern uint64_t entrypoint(const uint8_t *input) {
SolAccountInfo ka[1];
SolParameters params = (SolParameters) { .ka = ka };

if (!sol_deserialize(buf, ka, SOL_ARRAY_SIZE(ka), NULL, &data, &data_len)) {
return false;
if (!sol_deserialize(input, &params, SOL_ARRAY_SIZE(ka))) {
return ERROR_INVALID_ARGUMENT;
}
print_params(1, ka, data, data_len);
return true;
return SUCCESS;
}
```

Expand Down