Add return data implementation

This consists of:
 - syscalls
 - passing return data from invoked to invoker
 - printing to stable log
 - rust and C SDK changes
This commit is contained in:
Sean Young
2021-09-01 10:14:01 +01:00
parent 2dee098b91
commit 098585234d
23 changed files with 641 additions and 35 deletions

View File

@ -0,0 +1,41 @@
#pragma once
/**
* @brief Solana return data system calls
**/
#include <sol/types.h>
#include <sol/pubkey.h>
#ifdef __cplusplus
extern "C"
{
#endif
/**
* Maximum size of return data
*/
#define MAX_RETURN_DATA 1024
/**
* Set the return data
*
* @param bytes byte array to set
* @param bytes_len length of byte array. This may not exceed MAX_RETURN_DATA.
*/
void sol_set_return_data(const uint8_t *bytes, uint64_t bytes_len);
/**
* Get the return data
*
* @param bytes byte buffer
* @param bytes_len maximum length of buffer
* @param program_id the program_id which set the return data. Only set if there was some return data (the function returns non-zero).
* @param result length of return data (may exceed bytes_len if the return data is longer)
*/
uint64_t sol_get_return_data(const uint8_t *bytes, uint64_t bytes_len, SolPubkey *program_id);
#ifdef __cplusplus
}
#endif
/**@}*/

View File

@ -12,6 +12,7 @@
#include <sol/keccak.h>
#include <sol/log.h>
#include <sol/pubkey.h>
#include <sol/return_data.h>
#include <sol/secp256k1.h>
#include <sol/sha.h>
#include <sol/string.h>