Skip to content

Commit

Permalink
CAST transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
relatko committed Aug 25, 2022
1 parent 1b8928e commit 1d320b2
Show file tree
Hide file tree
Showing 183 changed files with 1,308 additions and 2 deletions.
156 changes: 156 additions & 0 deletions app/src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2110,6 +2110,144 @@ parser_error_t parser_getItemTransferUSDC(const parser_context_t *ctx,
return parser_getItemAfterArguments(ctx, displayIdx, outKey, outKeyLen, outVal, outValLen, pageIdx, pageCount);
}

//CAST.01
parser_error_t parser_getItemCast01(const parser_context_t *ctx,
uint16_t displayIdx,
char *outKey, uint16_t outKeyLen,
char *outVal, uint16_t outValLen,
uint8_t pageIdx, uint8_t *pageCount) {
*pageCount = 1;
switch (displayIdx) {
case 0:
snprintf(outKey, outKeyLen, "Type");
snprintf(outVal, outValLen, "Create A Proposal");
return PARSER_OK;
case 1:
snprintf(outKey, outKeyLen, "ChainID");
return parser_printChainID(&parser_tx_obj.payer,
outVal, outValLen, pageIdx, pageCount);
default:
break;
}
displayIdx -= 2;
return parser_getItemAfterArguments(ctx, displayIdx, outKey, outKeyLen, outVal, outValLen, pageIdx, pageCount);
}

//CAST.02
parser_error_t parser_getItemCast02(const parser_context_t *ctx,
uint16_t displayIdx,
char *outKey, uint16_t outKeyLen,
char *outVal, uint16_t outValLen,
uint8_t pageIdx, uint8_t *pageCount) {
*pageCount = 1;
switch (displayIdx) {
case 0:
snprintf(outKey, outKeyLen, "Type");
snprintf(outVal, outValLen, "Cast Your Vote");
return PARSER_OK;
case 1:
snprintf(outKey, outKeyLen, "ChainID");
return parser_printChainID(&parser_tx_obj.payer,
outVal, outValLen, pageIdx, pageCount);
default:
break;
}
displayIdx -= 2;
return parser_getItemAfterArguments(ctx, displayIdx, outKey, outKeyLen, outVal, outValLen, pageIdx, pageCount);
}

//CAST.03
parser_error_t parser_getItemCast03(const parser_context_t *ctx,
uint16_t displayIdx,
char *outKey, uint16_t outKeyLen,
char *outVal, uint16_t outValLen,
uint8_t pageIdx, uint8_t *pageCount) {
*pageCount = 1;
switch (displayIdx) {
case 0:
snprintf(outKey, outKeyLen, "Type");
snprintf(outVal, outValLen, "Update Membership Status");
return PARSER_OK;
case 1:
snprintf(outKey, outKeyLen, "ChainID");
return parser_printChainID(&parser_tx_obj.payer,
outVal, outValLen, pageIdx, pageCount);
default:
break;
}
displayIdx -= 2;
return parser_getItemAfterArguments(ctx, displayIdx, outKey, outKeyLen, outVal, outValLen, pageIdx, pageCount);
}

//CAST.04
parser_error_t parser_getItemCast04(const parser_context_t *ctx,
uint16_t displayIdx,
char *outKey, uint16_t outKeyLen,
char *outVal, uint16_t outValLen,
uint8_t pageIdx, uint8_t *pageCount) {
*pageCount = 1;
switch (displayIdx) {
case 0:
snprintf(outKey, outKeyLen, "Type");
snprintf(outVal, outValLen, "Update Proposal Status");
return PARSER_OK;
case 1:
snprintf(outKey, outKeyLen, "ChainID");
return parser_printChainID(&parser_tx_obj.payer,
outVal, outValLen, pageIdx, pageCount);
default:
break;
}
displayIdx -= 2;
return parser_getItemAfterArguments(ctx, displayIdx, outKey, outKeyLen, outVal, outValLen, pageIdx, pageCount);
}

//CAST.05
parser_error_t parser_getItemCast05(const parser_context_t *ctx,
uint16_t displayIdx,
char *outKey, uint16_t outKeyLen,
char *outVal, uint16_t outValLen,
uint8_t pageIdx, uint8_t *pageCount) {
*pageCount = 1;
switch (displayIdx) {
case 0:
snprintf(outKey, outKeyLen, "Type");
snprintf(outVal, outValLen, "Update Your Community");
return PARSER_OK;
case 1:
snprintf(outKey, outKeyLen, "ChainID");
return parser_printChainID(&parser_tx_obj.payer,
outVal, outValLen, pageIdx, pageCount);
default:
break;
}
displayIdx -= 2;
return parser_getItemAfterArguments(ctx, displayIdx, outKey, outKeyLen, outVal, outValLen, pageIdx, pageCount);
}

//CAST.06
parser_error_t parser_getItemCast06(const parser_context_t *ctx,
uint16_t displayIdx,
char *outKey, uint16_t outKeyLen,
char *outVal, uint16_t outValLen,
uint8_t pageIdx, uint8_t *pageCount) {
*pageCount = 1;
switch (displayIdx) {
case 0:
snprintf(outKey, outKeyLen, "Type");
snprintf(outVal, outValLen, "Create A Community");
return PARSER_OK;
case 1:
snprintf(outKey, outKeyLen, "ChainID");
return parser_printChainID(&parser_tx_obj.payer,
outVal, outValLen, pageIdx, pageCount);
default:
break;
}
displayIdx -= 2;
return parser_getItemAfterArguments(ctx, displayIdx, outKey, outKeyLen, outVal, outValLen, pageIdx, pageCount);
}



parser_error_t parser_getItem(const parser_context_t *ctx,
Expand Down Expand Up @@ -2276,6 +2414,24 @@ parser_error_t parser_getItem(const parser_context_t *ctx,
case SCRIPT_SCO0302_REGISTER_NODE:
return parser_getItemRegisterNodeSCO2(ctx, displayIdx, outKey, outKeyLen, outVal,
outValLen, pageIdx, pageCount);
case SCRIPT_CAST01:
return parser_getItemCast01(ctx, displayIdx, outKey, outKeyLen, outVal,
outValLen, pageIdx, pageCount);
case SCRIPT_CAST02:
return parser_getItemCast02(ctx, displayIdx, outKey, outKeyLen, outVal,
outValLen, pageIdx, pageCount);
case SCRIPT_CAST03:
return parser_getItemCast03(ctx, displayIdx, outKey, outKeyLen, outVal,
outValLen, pageIdx, pageCount);
case SCRIPT_CAST04:
return parser_getItemCast04(ctx, displayIdx, outKey, outKeyLen, outVal,
outValLen, pageIdx, pageCount);
case SCRIPT_CAST05:
return parser_getItemCast05(ctx, displayIdx, outKey, outKeyLen, outVal,
outValLen, pageIdx, pageCount);
case SCRIPT_CAST06:
return parser_getItemCast06(ctx, displayIdx, outKey, outKeyLen, outVal,
outValLen, pageIdx, pageCount);
}

return PARSER_UNEXPECTED_SCRIPT;
Expand Down
15 changes: 15 additions & 0 deletions app/src/parser_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,13 @@ parser_error_t _matchScriptType(uint8_t scriptHash[32], script_type_e *scriptTyp
{SCRIPT_SCO0302_REGISTER_NODE, TEMPLATE_HASH_SCO0303_REGISTER_NODE_TESTNET},
{SCRIPT_SCO0302_REGISTER_NODE, TEMPLATE_HASH_SCO0303_REGISTER_NODE_MAINNET},

{SCRIPT_CAST01, TEMPLATE_HASH_CAST01},
{SCRIPT_CAST02, TEMPLATE_HASH_CAST02},
{SCRIPT_CAST03, TEMPLATE_HASH_CAST03},
{SCRIPT_CAST04, TEMPLATE_HASH_CAST04},
{SCRIPT_CAST05, TEMPLATE_HASH_CAST05},
{SCRIPT_CAST06, TEMPLATE_HASH_CAST06},

// sentinel, do not remove
{0, NULL}
};
Expand Down Expand Up @@ -949,6 +956,14 @@ parser_error_t _getNumItems(__Z_UNUSED const parser_context_t *c, const parser_t
CHECK_PARSER_ERR(_countArgumentOptionalItems(&v->arguments, 7, UINT8_MAX, &argArrayLength));
*numItems = 15 + argArrayLength + extraItems;
return PARSER_OK;
case SCRIPT_CAST01:
case SCRIPT_CAST02:
case SCRIPT_CAST03:
case SCRIPT_CAST04:
case SCRIPT_CAST05:
case SCRIPT_CAST06:
*numItems = 8 + extraItems;
return PARSER_OK;
case SCRIPT_UNKNOWN:
default:
return PARSER_UNEXPECTED_SCRIPT;
Expand Down
6 changes: 6 additions & 0 deletions app/src/parser_txdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ typedef enum {
SCRIPT_TH0602_REGISTER_NODE,
SCRIPT_TH1602_REGISTER_OPERATOR_NODE,
SCRIPT_SCO0302_REGISTER_NODE,
SCRIPT_CAST01,
SCRIPT_CAST02,
SCRIPT_CAST03,
SCRIPT_CAST04,
SCRIPT_CAST05,
SCRIPT_CAST06,
} script_type_e;

typedef enum {
Expand Down
7 changes: 7 additions & 0 deletions app/src/template_hashes.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ extern "C" {
#define TEMPLATE_HASH_SCO0303_REGISTER_NODE_TESTNET "1508b7713725280e999de85ad0d559781d82da42bb902ae76189324c44ae9bcf"
#define TEMPLATE_HASH_SCO0303_REGISTER_NODE_MAINNET "809d4a5d80ba7240a743be6579b0c03fe38ce1cb6e461aaef20b84e29c3c0c73"

#define TEMPLATE_HASH_CAST01 "2d9b8149a6e7eaabc8d4f7ecacd743bcfe2b15100ad8137f6b655018f3ab3a2c"
#define TEMPLATE_HASH_CAST02 "98bb483a4cb4598dca55c09720af0cd69e7751674821340c9c60fe3f5af15042"
#define TEMPLATE_HASH_CAST03 "ca6239b9b54c293457dc44ea08d4d0bd10ff4231f88c2f5e235c2a6bf9f7e4ce"
#define TEMPLATE_HASH_CAST04 "6579cefb3c0bd1b679c093bc821387ab0476222723bb1f51f8e2dc9b9465caf0"
#define TEMPLATE_HASH_CAST05 "bd6cd28bc496eca367b030df21a152fbb5105131daaf574440b8f43829e04065"
#define TEMPLATE_HASH_CAST06 "1ae5239999cd182439af8dfedfd963db8ed6370037fdd04742c4dda7b730eac6"

#ifdef __cplusplus
}
#endif
50 changes: 49 additions & 1 deletion tests/generate-transaction-tests/manifest.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -1738,6 +1738,54 @@
],
"network": "mainnet",
"hash": "809d4a5d80ba7240a743be6579b0c03fe38ce1cb6e461aaef20b84e29c3c0c73"
}
},
{
"id": "CAST.01",
"name": "Create A Proposal",
"source": "\ntransaction() {\n prepare(acct: AuthAccount) {\n // create proposal:\n //\n // this transaction does nothing and will not be run,\n // it is only used to collect a signature.\n //\n }\n}",
"arguments": [],
"network": "mainnet",
"hash": "2d9b8149a6e7eaabc8d4f7ecacd743bcfe2b15100ad8137f6b655018f3ab3a2c"
},
{
"id": "CAST.02",
"name": "Cast Your Vote",
"source": "\ntransaction() {\n prepare(acct: AuthAccount) {\n // cast vote:\n //\n // this transaction does nothing and will not be run,\n // it is only used to collect a signature.\n //\n }\n}",
"arguments": [],
"network": "mainnet",
"hash": "98bb483a4cb4598dca55c09720af0cd69e7751674821340c9c60fe3f5af15042"
},
{
"id": "CAST.03",
"name": "Update Membership Status",
"source": "\ntransaction() {\n prepare(acct: AuthAccount) {\n // update community membership:\n //\n // this transaction does nothing and will not be run,\n // it is only used to collect a signature.\n //\n }\n}",
"arguments": [],
"network": "mainnet",
"hash": "ca6239b9b54c293457dc44ea08d4d0bd10ff4231f88c2f5e235c2a6bf9f7e4ce"
},
{
"id": "CAST.04",
"name": "Update Proposal Status",
"source": "\ntransaction() {\n prepare(acct: AuthAccount) {\n // update proposal:\n //\n // this transaction does nothing and will not be run,\n // it is only used to collect a signature.\n //\n }\n}",
"arguments": [],
"network": "mainnet",
"hash": "6579cefb3c0bd1b679c093bc821387ab0476222723bb1f51f8e2dc9b9465caf0"
},
{
"id": "CAST.05",
"name": "Update Your Community",
"source": "\ntransaction() {\n prepare(acct: AuthAccount) {\n // update community:\n //\n // this transaction does nothing and will not be run,\n // it is only used to collect a signature.\n //\n }\n}",
"arguments": [],
"network": "mainnet",
"hash": "bd6cd28bc496eca367b030df21a152fbb5105131daaf574440b8f43829e04065"
},
{
"id": "CAST.06",
"name": "Create A Community",
"source": "\ntransaction() {\n prepare(acct: AuthAccount) {\n // create community:\n //\n // this transaction does nothing and will not be run,\n // it is only used to collect a signature.\n //\n }\n}\n",
"arguments": [],
"network": "mainnet",
"hash": "1ae5239999cd182439af8dfedfd963db8ed6370037fdd04742c4dda7b730eac6"
}
]
}
50 changes: 49 additions & 1 deletion tests/generate-transaction-tests/manifest.testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -1738,7 +1738,55 @@
],
"network": "testnet",
"hash": "1508b7713725280e999de85ad0d559781d82da42bb902ae76189324c44ae9bcf"
}
},
{
"id": "CAST.01",
"name": "Create A Proposal",
"source": "\ntransaction() {\n prepare(acct: AuthAccount) {\n // create proposal:\n //\n // this transaction does nothing and will not be run,\n // it is only used to collect a signature.\n //\n }\n}",
"arguments": [],
"network": "testnet",
"hash": "2d9b8149a6e7eaabc8d4f7ecacd743bcfe2b15100ad8137f6b655018f3ab3a2c"
},
{
"id": "CAST.02",
"name": "Cast Your Vote",
"source": "\ntransaction() {\n prepare(acct: AuthAccount) {\n // cast vote:\n //\n // this transaction does nothing and will not be run,\n // it is only used to collect a signature.\n //\n }\n}",
"arguments": [],
"network": "testnet",
"hash": "98bb483a4cb4598dca55c09720af0cd69e7751674821340c9c60fe3f5af15042"
},
{
"id": "CAST.03",
"name": "Update Membership Status",
"source": "\ntransaction() {\n prepare(acct: AuthAccount) {\n // update community membership:\n //\n // this transaction does nothing and will not be run,\n // it is only used to collect a signature.\n //\n }\n}",
"arguments": [],
"network": "testnet",
"hash": "ca6239b9b54c293457dc44ea08d4d0bd10ff4231f88c2f5e235c2a6bf9f7e4ce"
},
{
"id": "CAST.04",
"name": "Update Proposal Status",
"source": "\ntransaction() {\n prepare(acct: AuthAccount) {\n // update proposal:\n //\n // this transaction does nothing and will not be run,\n // it is only used to collect a signature.\n //\n }\n}",
"arguments": [],
"network": "testnet",
"hash": "6579cefb3c0bd1b679c093bc821387ab0476222723bb1f51f8e2dc9b9465caf0"
},
{
"id": "CAST.05",
"name": "Update Your Community",
"source": "\ntransaction() {\n prepare(acct: AuthAccount) {\n // update community:\n //\n // this transaction does nothing and will not be run,\n // it is only used to collect a signature.\n //\n }\n}",
"arguments": [],
"network": "testnet",
"hash": "bd6cd28bc496eca367b030df21a152fbb5105131daaf574440b8f43829e04065"
},
{
"id": "CAST.06",
"name": "Create A Community",
"source": "\ntransaction() {\n prepare(acct: AuthAccount) {\n // create community:\n //\n // this transaction does nothing and will not be run,\n // it is only used to collect a signature.\n //\n }\n}\n",
"arguments": [],
"network": "testnet",
"hash": "1ae5239999cd182439af8dfedfd963db8ed6370037fdd04742c4dda7b730eac6"
}
]
}

Loading

0 comments on commit 1d320b2

Please sign in to comment.