Skip to content

Commit

Permalink
feat: change fn name
Browse files Browse the repository at this point in the history
  • Loading branch information
AbigailDeng authored and AbigailDeng committed May 10, 2024
1 parent 6a62607 commit ebc00b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

| Statements | Branches | Functions | Lines |
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
| ![Statements](https://img.shields.io/badge/statements-96.72%25-brightgreen.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-93.49%25-brightgreen.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-96.72%25-brightgreen.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-96.91%25-brightgreen.svg?style=flat) |
| ![Statements](https://img.shields.io/badge/statements-96.72%25-brightgreen.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-93.7%25-brightgreen.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-96.72%25-brightgreen.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-96.91%25-brightgreen.svg?style=flat) |


## 1. Introduction
Expand Down
14 changes: 7 additions & 7 deletions src/util/proto.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export const getTransaction = (from, to, methodName, params) => {
return Transaction.create(txn);
};

const getDeserializeLogResult = (serializedData, dataType) => {
const deserializeIndexedAndNonIndexed = (serializedData, dataType) => {
let deserializeLogResult = serializedData.reduce((acc, v) => {
let deserialize = dataType.decode(Buffer.from(v, 'base64'));
deserialize = dataType.toObject(deserialize, {
Expand All @@ -217,7 +217,7 @@ const getDeserializeLogResult = (serializedData, dataType) => {
deserializeLogResult = transformArrayToMap(dataType, deserializeLogResult);
return deserializeLogResult;
};
const handleLogs = (logs = [], services, Root) => {
const deserializeWithServicesAndRoot = (logs, services, Root) => {
// filter by address and name
if (logs.length === 0) {
return [];
Expand All @@ -240,10 +240,10 @@ const handleLogs = (logs = [], services, Root) => {
// VirtualTransactionCreated is system-default
try {
dataType = Root.VirtualTransactionCreated;
return getDeserializeLogResult(serializedData, dataType);
return deserializeIndexedAndNonIndexed(serializedData, dataType);
} catch (e) {
// if normal contract has a method called VirtualTransactionCreated
return getDeserializeLogResult(serializedData, dataType);
return deserializeIndexedAndNonIndexed(serializedData, dataType);
}
} else {
// if dataType cannot be found and also is not VirtualTransactionCreated
Expand All @@ -253,7 +253,7 @@ const handleLogs = (logs = [], services, Root) => {
};
}
// other method
return getDeserializeLogResult(serializedData, dataType);
return deserializeIndexedAndNonIndexed(serializedData, dataType);
}
});
return results;
Expand All @@ -268,7 +268,7 @@ const handleLogs = (logs = [], services, Root) => {
*/
export const deserializeLog = async (logs = [], services) => {
const Root = await protobuf.load('proto/virtual_transaction.proto');
return handleLogs(logs, services, Root);
return deserializeWithServicesAndRoot(logs, services, Root);
};
/**
* deserialize logs sync
Expand All @@ -280,7 +280,7 @@ export const deserializeLog = async (logs = [], services) => {
*/
export const deserializeLogSync = (logs = [], services) => {
const Root = protobuf.loadSync('proto/virtual_transaction.proto');
return handleLogs(logs, services, Root);
return deserializeWithServicesAndRoot(logs, services, Root);
};

/* eslint-enable */

0 comments on commit ebc00b7

Please sign in to comment.