Skip to content

Commit

Permalink
refactor: review
Browse files Browse the repository at this point in the history
  • Loading branch information
phamphong9981 committed Jul 24, 2024
1 parent 939a449 commit 8060c18
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
12 changes: 2 additions & 10 deletions src/services/evm/erc20_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,10 @@ export class Erc20Handler {
logger
);
if (activity) {
const index = erc20Activities.findIndex(
(e) => e.height > activity.height
);
// sort activity
if (index === -1) {
erc20Activities.splice(erc20Activities.length, 0, activity);
} else {
erc20Activities.splice(index, 0, activity);
}
erc20Activities.push(activity);
}
});
return erc20Activities;
return _.sortBy(erc20Activities, 'cosmos_tx_id');
}

static async getErc20Activities(
Expand Down
6 changes: 3 additions & 3 deletions test/unit/services/evm/erc20_handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export default class Erc20HandlerTest {
gas_wanted: '2456353',
hash: '1406F9DDCE529F0E6EB32E07A88E5BC4EE220D3A2AB6D57E89DD12EB1945CC19',
height: blockHeight,
id: 505671,
id: evmTransaction.id,
index: 0,
memo: 'memo',
timestamp: '2024-07-15T17:08:43.386+07:00',
Expand Down Expand Up @@ -432,7 +432,7 @@ export default class Erc20HandlerTest {
tx_hash:
'0x8a82a0c8848487d716f10a91f0aefb0526d35bd0f489166cc5141718a4d8aa64',
topic3: null,
tx_id: evmTransaction.id,
tx_id: evmTransaction.id - 1,
tx_index: 0,
}),
// transfer event
Expand All @@ -454,7 +454,7 @@ export default class Erc20HandlerTest {
tx_hash:
'0x8a82a0c8848487d716f10a91f0aefb0526d35bd0f489166cc5141718a4d8aa64',
topic3: null,
tx_id: evmTransaction.id,
tx_id: evmTransaction.id + 1,
tx_index: 0,
}),
];
Expand Down

0 comments on commit 8060c18

Please sign in to comment.