Skip to content

Commit

Permalink
Process manifest with new types
Browse files Browse the repository at this point in the history
  • Loading branch information
relatko committed Mar 18, 2024
1 parent 594594f commit bdfae1d
Show file tree
Hide file tree
Showing 254 changed files with 431 additions and 398 deletions.
1 change: 1 addition & 0 deletions src/parser_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ parser_error_t parser_getItem_internal(int8_t *displayIdx,
SCREEN(true) {
snprintf(outKey, outKeyLen, "Type");
snprintf(outVal, outValLen, "%s", parser_tx_obj.metadata.txName);
zemu_log(outVal);zemu_log("\n");
return PARSER_OK;
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/tx_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ struct {
} txMetadataState;

static const uint8_t merkleTreeRoot[METADATA_HASH_SIZE] = {
0xfe, 0xd8, 0x31, 0x77, 0xf6, 0x98, 0x29, 0xb4, 0x55, 0xce, 0xa6, 0xea, 0x33, 0x4a, 0x22, 0x60,
0xd0, 0x72, 0x79, 0xa7, 0x3c, 0x3e, 0xf0, 0x99, 0xbf, 0x11, 0x01, 0x6b, 0x30, 0xbd, 0x25, 0x82,
0xe5, 0xde, 0x7e, 0x03, 0x15, 0x1b, 0x79, 0xa5, 0x30, 0xf2, 0x98, 0x06, 0x44, 0x4d, 0x17, 0x64,
0xa0, 0xdb, 0xd4, 0x82, 0x3e, 0xa3, 0x8e, 0xb5, 0x81, 0x44, 0xf2, 0xe5, 0x51, 0xef, 0x90, 0xd9
};

static const char *STRING_TYPE_STRING = "String";
Expand Down
106 changes: 53 additions & 53 deletions tests/application_client/txMerkleTree.py

Large diffs are not rendered by default.

120 changes: 60 additions & 60 deletions tests/manifestPayloadCases.json

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanos/test_transaction_params/part1/00007.png
Binary file modified tests/snapshots/nanos/test_transaction_params/part1/00008.png
Binary file modified tests/snapshots/nanos/test_transaction_params/part2/00007.png
Binary file modified tests/snapshots/nanos/test_transaction_params/part2/00008.png
Binary file modified tests/snapshots/nanos/test_transaction_params/part3/00007.png
Binary file modified tests/snapshots/nanos/test_transaction_params/part3/00008.png
Binary file modified tests/snapshots/nanos/test_transaction_params/part4/00007.png
Binary file modified tests/snapshots/nanos/test_transaction_params/part4/00008.png
Binary file modified tests/snapshots/nanos/test_transaction_params/part5/00007.png
Binary file modified tests/snapshots/nanos/test_transaction_params/part5/00008.png
Binary file modified tests/snapshots/nanos/test_transaction_params/part6/00007.png
Binary file modified tests/snapshots/nanos/test_transaction_params/part6/00008.png
Binary file modified tests/snapshots/nanos/test_transaction_params/part7/00007.png
Binary file modified tests/snapshots/nanos/test_transaction_params/part7/00008.png
Binary file modified tests/snapshots/nanos/test_transaction_params/part8/00007.png
Binary file modified tests/snapshots/nanos/test_transaction_params/part8/00008.png
Binary file modified tests/snapshots/nanos/test_transaction_refused/00007.png
Binary file modified tests/snapshots/nanos/test_transaction_refused/00008.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part0/00007.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part0/00008.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part10/00007.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part10/00008.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part12/00007.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part12/00008.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part14/00007.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part14/00008.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part15/00007.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part15/00008.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part2/00007.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part2/00008.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part3/00007.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part3/00008.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part4/00007.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part4/00008.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part6/00007.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part6/00008.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part8/00007.png
Binary file modified tests/snapshots/nanos/test_transaction_slot/part8/00008.png
Binary file modified tests/snapshots/nanosp/test_transaction_params/part1/00006.png
Binary file modified tests/snapshots/nanosp/test_transaction_params/part1/00007.png
Binary file modified tests/snapshots/nanosp/test_transaction_params/part2/00006.png
Binary file modified tests/snapshots/nanosp/test_transaction_params/part2/00007.png
Binary file modified tests/snapshots/nanosp/test_transaction_params/part3/00006.png
Binary file modified tests/snapshots/nanosp/test_transaction_params/part3/00007.png
Binary file modified tests/snapshots/nanosp/test_transaction_params/part4/00006.png
Binary file modified tests/snapshots/nanosp/test_transaction_params/part4/00007.png
Binary file modified tests/snapshots/nanosp/test_transaction_params/part5/00006.png
Binary file modified tests/snapshots/nanosp/test_transaction_params/part5/00007.png
Binary file modified tests/snapshots/nanosp/test_transaction_params/part6/00006.png
Binary file modified tests/snapshots/nanosp/test_transaction_params/part6/00007.png
Binary file modified tests/snapshots/nanosp/test_transaction_params/part7/00006.png
Binary file modified tests/snapshots/nanosp/test_transaction_params/part7/00007.png
Binary file modified tests/snapshots/nanosp/test_transaction_params/part8/00006.png
Binary file modified tests/snapshots/nanosp/test_transaction_params/part8/00007.png
Binary file modified tests/snapshots/nanosp/test_transaction_refused/00006.png
Binary file modified tests/snapshots/nanosp/test_transaction_refused/00007.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part0/00006.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part0/00007.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part10/00006.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part10/00007.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part12/00006.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part12/00007.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part14/00006.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part14/00007.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part15/00006.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part15/00007.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part2/00006.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part2/00007.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part3/00006.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part3/00007.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part4/00006.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part4/00007.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part6/00006.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part6/00007.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part8/00006.png
Binary file modified tests/snapshots/nanosp/test_transaction_slot/part8/00007.png
Binary file modified tests/snapshots/nanox/test_transaction_params/part1/00006.png
Binary file modified tests/snapshots/nanox/test_transaction_params/part1/00007.png
Binary file modified tests/snapshots/nanox/test_transaction_params/part2/00006.png
Binary file modified tests/snapshots/nanox/test_transaction_params/part2/00007.png
Binary file modified tests/snapshots/nanox/test_transaction_params/part3/00006.png
Binary file modified tests/snapshots/nanox/test_transaction_params/part3/00007.png
Binary file modified tests/snapshots/nanox/test_transaction_params/part4/00006.png
Binary file modified tests/snapshots/nanox/test_transaction_params/part4/00007.png
Binary file modified tests/snapshots/nanox/test_transaction_params/part5/00006.png
Binary file modified tests/snapshots/nanox/test_transaction_params/part5/00007.png
Binary file modified tests/snapshots/nanox/test_transaction_params/part6/00006.png
Binary file modified tests/snapshots/nanox/test_transaction_params/part6/00007.png
Binary file modified tests/snapshots/nanox/test_transaction_params/part7/00006.png
Binary file modified tests/snapshots/nanox/test_transaction_params/part7/00007.png
Binary file modified tests/snapshots/nanox/test_transaction_params/part8/00006.png
Binary file modified tests/snapshots/nanox/test_transaction_params/part8/00007.png
Binary file modified tests/snapshots/nanox/test_transaction_refused/00006.png
Binary file modified tests/snapshots/nanox/test_transaction_refused/00007.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part0/00006.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part0/00007.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part10/00006.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part10/00007.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part12/00006.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part12/00007.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part14/00006.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part14/00007.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part15/00006.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part15/00007.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part2/00006.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part2/00007.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part3/00006.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part3/00007.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part4/00006.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part4/00007.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part6/00006.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part6/00007.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part8/00006.png
Binary file modified tests/snapshots/nanox/test_transaction_slot/part8/00007.png
Binary file modified tests/snapshots/stax/test_transaction_params/part1/00003.png
Binary file modified tests/snapshots/stax/test_transaction_params/part2/00003.png
Binary file modified tests/snapshots/stax/test_transaction_params/part3/00003.png
Binary file modified tests/snapshots/stax/test_transaction_params/part4/00003.png
Binary file modified tests/snapshots/stax/test_transaction_params/part5/00003.png
Binary file modified tests/snapshots/stax/test_transaction_params/part6/00003.png
Binary file modified tests/snapshots/stax/test_transaction_params/part7/00003.png
Binary file modified tests/snapshots/stax/test_transaction_params/part8/00003.png
Binary file modified tests/snapshots/stax/test_transaction_slot/part0/00003.png
Binary file modified tests/snapshots/stax/test_transaction_slot/part10/00003.png
Binary file modified tests/snapshots/stax/test_transaction_slot/part12/00003.png
Binary file modified tests/snapshots/stax/test_transaction_slot/part14/00003.png
Binary file modified tests/snapshots/stax/test_transaction_slot/part15/00003.png
Binary file modified tests/snapshots/stax/test_transaction_slot/part2/00003.png
Binary file modified tests/snapshots/stax/test_transaction_slot/part3/00003.png
Binary file modified tests/snapshots/stax/test_transaction_slot/part4/00003.png
Binary file modified tests/snapshots/stax/test_transaction_slot/part6/00003.png
Binary file modified tests/snapshots/stax/test_transaction_slot/part8/00003.png
120 changes: 60 additions & 60 deletions transaction_metadata/testvectors/manifestEnvelopeCases.json

Large diffs are not rendered by default.

120 changes: 60 additions & 60 deletions transaction_metadata/testvectors/manifestPayloadCases.json

Large diffs are not rendered by default.

40 changes: 36 additions & 4 deletions transaction_metadata/tree/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ const MAX_ARRAY_LENGTH = 3
const ARGUMENT_TYPE_NORMAL = 1;
const ARGUMENT_TYPE_OPTIONAL = 2;
const ARGUMENT_TYPE_ARRAY = 3;
const ARGUMENT_TYPE_OPTIONALARRAY = 4;
const ARGUMENT_TYPE_STRING = 4;
const ARGUMENT_TYPE_HASH_ALGO = 5;
const ARGUMENT_TYPE_SIGNATURE_ALGO = 6;
const ARGUMENT_TYPE_NODE_ROLE = 7;
const JSMN_STRING = 3;

const uint8_to_buff = (n) => {
Expand All @@ -33,13 +36,26 @@ const legerifyArgLabel = (name) => {
"Networking Address":"Netw. Address",
"Networking Key":"Netw. Key",
"Public Keys":"Pub. Key",
"Machine Account Public Key":"MA PubKey",
"Raw Value for Machine Account Hash Algorithm Enum":"MA HAlg",
"Raw Value for Machine Account Signature Algorithm Enum":"MA SAlg",
"Machine Account Public Key":"MA Pub. Key",
"Raw Value for Machine Account Hash Algorithm Enum":"MA Hash Alg.",
"Raw Value for Machine Account Signature Algorithm Enum":"MA Sign. Alg.",
"Raw Value for Signature Algorithm Enum":"Signature Alg.",
"Raw Value for Hash Algorithm Enum":"Hash Alg.",
}
return txArgTransforms[name]?txArgTransforms[name]:name
}

const enumToType = (name) => {
const argTransforms = {
"Raw Value for Machine Account Hash Algorithm Enum":ARGUMENT_TYPE_HASH_ALGO,
"Raw Value for Machine Account Signature Algorithm Enum":ARGUMENT_TYPE_SIGNATURE_ALGO,
"Raw Value for Signature Algorithm Enum":ARGUMENT_TYPE_SIGNATURE_ALGO,
"Raw Value for Hash Algorithm Enum":ARGUMENT_TYPE_HASH_ALGO,
"Node Role": ARGUMENT_TYPE_NODE_ROLE
}
return argTransforms[name]?argTransforms[name]:ARGUMENT_TYPE_NORMAL
}

const readManifest = (testnetFile, mainnetFile) => {
const sortFun = (template1, template2) => template1.id > template2.id ? 1 : (template1.id < template2.id ? -1 : 0);
const testnetTemplates = [...JSON.parse(fs.readFileSync(testnetFile)).templates].sort(sortFun);
Expand All @@ -54,6 +70,22 @@ const readManifest = (testnetFile, mainnetFile) => {

const templatesToMetadata = (templateTestnet, templateMainnet) => {
const processArg = (arg, idx) => {
if (arg.type == "String") {
return Buffer.concat([
uint8_to_buff(ARGUMENT_TYPE_STRING), //argument type
Buffer.from(legerifyArgLabel(arg.label)), //argument label
Buffer.from("00", "hex"), //trailing 0
uint8_to_buff(idx), //order in which should arguments display
])
}
if (arg.type == "UInt8" && enumToType(arg.label) != ARGUMENT_TYPE_NORMAL) {
return Buffer.concat([
uint8_to_buff(enumToType(arg.label)), //argument type
Buffer.from(legerifyArgLabel(arg.label)), //argument label
Buffer.from("00", "hex"), //trailing 0
uint8_to_buff(idx), //order in which should arguments display
])
}
if (arg.type[0] !== '[' && arg.type[arg.type.length-1] !== '?') {
return Buffer.concat([
uint8_to_buff(ARGUMENT_TYPE_NORMAL), //argument type
Expand Down
106 changes: 53 additions & 53 deletions transaction_metadata/txMerkleTree.js

Large diffs are not rendered by default.

106 changes: 53 additions & 53 deletions transaction_metadata/txMerkleTree.mjs

Large diffs are not rendered by default.

106 changes: 53 additions & 53 deletions transaction_metadata/txMerkleTree.py

Large diffs are not rendered by default.

0 comments on commit bdfae1d

Please sign in to comment.