Skip to content

Commit

Permalink
fix: fix duplicate contract when call create contract in erc20, erc721
Browse files Browse the repository at this point in the history
  • Loading branch information
fibonacci998 committed Nov 11, 2024
1 parent c567761 commit 2c0aa4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/services/evm/erc20.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ export default class Erc20Service extends BullableService {
async insertNewErc20Contracts(_payload: {
evmSmartContracts: { id: number; address: string }[];
}) {
const { evmSmartContracts } = _payload;
const evmSmartContracts = [
...new Map(
_payload.evmSmartContracts.map((item) => [item.address, item])
).values(),
];
if (evmSmartContracts.length > 0) {
const currentHeight = await this.viemClient.getBlockNumber();
const erc20Instances = await this.getErc20Instances(
Expand Down
6 changes: 5 additions & 1 deletion src/services/evm/erc721.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,11 @@ export default class Erc721Service extends BullableService {
async insertNewErc721Contracts(_payload: {
evmSmartContracts: { id: number; address: string }[];
}) {
const { evmSmartContracts } = _payload;
const evmSmartContracts = [
...new Map(
_payload.evmSmartContracts.map((item) => [item.address, item])
).values(),
];
if (evmSmartContracts.length > 0) {
const currentHeight = await this.viemClient.getBlockNumber();
const erc721Instances = await this.getErc721Instances(
Expand Down

0 comments on commit 2c0aa4c

Please sign in to comment.