Skip to content

Commit

Permalink
sdk: fix broken C examples (solana-labs#33701)
Browse files Browse the repository at this point in the history
fix C broken example
  • Loading branch information
Arrowana authored Oct 16, 2023
1 parent 69495f4 commit 8a20e7f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
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

0 comments on commit 8a20e7f

Please sign in to comment.