mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-27 12:56:01 +01:00
31 lines
753 B
JavaScript
31 lines
753 B
JavaScript
|
// *********************************************
|
||
|
// data transformation utils
|
||
|
// *********************************************
|
||
|
export const transformTxDecoding = (params) => {
|
||
|
return params.map((node) => {
|
||
|
const nodeName = node.name;
|
||
|
const nodeValue = node.value;
|
||
|
const nodeKind = nodeValue.kind;
|
||
|
const nodeTypeClass = nodeValue.type.typeClass;
|
||
|
|
||
|
const treeItem = {
|
||
|
name: nodeName,
|
||
|
kind: nodeKind,
|
||
|
typeClass: nodeTypeClass,
|
||
|
type: nodeValue.type,
|
||
|
};
|
||
|
|
||
|
if (nodeTypeClass === 'struct') {
|
||
|
return {
|
||
|
...treeItem,
|
||
|
children: transformTxDecoding(nodeValue.value),
|
||
|
};
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
...treeItem,
|
||
|
value: nodeValue.value ? nodeValue.value : nodeValue,
|
||
|
};
|
||
|
});
|
||
|
};
|