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

added RedeemClaims command #65

Merged
merged 1 commit into from
Apr 29, 2024
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 lib/default/rddl-sdk
1 change: 1 addition & 0 deletions tasmota/include/i18n.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@
#define D_CMND_POPINIT "PoPInit"
#define D_CMND_CHALLENGE "Challenge"
#define D_CMND_POPCHALLENGERESULT "PoPChallengeResult"
#define D_CMND_REDEEMCLAIMS "RedeemClaims"
#define D_CMND_ATTESTMACHINE "AttestMachine"
#define D_CMND_NOTARIZATION_PERIODICITY "NotarizationPeriodicity"
#define D_CMND_NOTARIZE "Notarize"
Expand Down
30 changes: 24 additions & 6 deletions tasmota/tasmota_support/support_command.ino
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const char kTasmotaCommands[] PROGMEM = "|" // No prefix
D_CMND_BALANCE "|" D_CMND_RESOLVEID "|" D_CMND_PLANETMINTDENOM "|" D_CMND_GETACCOUNTID "|"
D_CMND_PLANETMINTCHAINID "|" D_CMND_MACHINEDATA "|" D_CMND_POPCHALLENGE "|" D_CMND_ATTESTMACHINE "|"
D_CMND_NOTARIZATION_PERIODICITY "|" D_CMND_NOTARIZE "|" D_CMND_REMOVE_FILES "|" D_CMND_POPINIT "|"
D_CMND_CHALLENGE "|" D_CMND_POPCHALLENGERESULT "|"
D_CMND_CHALLENGE "|" D_CMND_POPCHALLENGERESULT "|" D_CMND_REDEEMCLAIMS "|"
#ifdef USE_I2C
D_CMND_I2CSCAN "|" D_CMND_I2CDRIVER "|"
#endif
Expand Down Expand Up @@ -92,7 +92,7 @@ void (* const TasmotaCommand[])(void) PROGMEM = {
&CmndBalance, &CmdResolveCid, &CmndPlanetmintDenom, &CmndGetAccountID,
&CmndPlanetmintChainID, &CmndMachineData, &CmndPoPChallenge, &CmndAttestMachine,
&CmndNotarizationPeriodicity, &CmndNotarize, &CmndRemoveFiles, &CmndPoPInit,
&CmndChallenge, &CmndPoPChallengeResult,
&CmndChallenge, &CmndPoPChallengeResult, &CmndRedeemClaims,
#ifdef USE_I2C
&CmndI2cScan, &CmndI2cDriver,
#endif
Expand Down Expand Up @@ -932,7 +932,6 @@ void CmndPlanetmintChainID(void) {
}

void CmndMachineData(void) {

if( !sdkGetPlntmntKeys() ){
Response_P("{ \"%s\":\"%s\" }", D_CMND_MACHINEDATA, "Initialize Keys first (Mnemonic)");
}
Expand All @@ -953,7 +952,6 @@ void CmndMachineData(void) {
}

void CmndPoPChallenge(void) {

if( XdrvMailbox.data_len )
{
sdkClearStack();
Expand Down Expand Up @@ -1052,7 +1050,6 @@ void CmndRemoveFiles(void) {


void CmndPoPInit(void) {

if( XdrvMailbox.data_len )
{
sdkClearStack();
Expand All @@ -1075,7 +1072,6 @@ void CmndPoPInit(void) {
}

void CmndChallenge(void) {

if( XdrvMailbox.data_len )
{
sdkClearStack();
Expand Down Expand Up @@ -1119,6 +1115,28 @@ void CmndPoPChallengeResult(void) {
ResponseClear();
}

void CmndRedeemClaims(void) {
if( XdrvMailbox.data_len )
{
sdkClearStack();
char* liquidAddress = (char*)sdkGetStack( XdrvMailbox.data_len + 1);
memset( liquidAddress, 0, XdrvMailbox.data_len + 1);
strncpy( liquidAddress, (const char*) XdrvMailbox.data, XdrvMailbox.data_len);
bool result = RDDLSDKRedeemClaim( (const char*)liquidAddress );
if( result ){
Response_P( "{ \"%s\": \"%s\" }", D_CMND_REDEEMCLAIMS, "Success: redeemed the claims!" );
} else {
Response_P( "{ \"%s\": \"%s\" }", D_CMND_REDEEMCLAIMS, "Failed: to redeem the claims" );
}
}
else{
Response_P( "{ \"%s\": \"%s\" }", D_CMND_REDEEMCLAIMS, "Please define a liquid recipient address" );
}
CmndStatusResponse(38);
ResponseClear();
}


void CmndStatus(void)
{
int32_t payload = XdrvMailbox.payload;
Expand Down