mirror of
https://github.com/0xbow-io/privacy-pools-core.git
synced 2026-01-09 17:37:58 -05:00
fix: ignore duplicated precommitments in the events (#85)
This commit is contained in:
@@ -24,11 +24,11 @@ import { EventError } from "../errors/events.error.js";
|
||||
|
||||
type AccountServiceConfig =
|
||||
| {
|
||||
mnemonic: string;
|
||||
}
|
||||
mnemonic: string;
|
||||
}
|
||||
| {
|
||||
account: PrivacyPoolAccount;
|
||||
};
|
||||
account: PrivacyPoolAccount;
|
||||
};
|
||||
|
||||
/**
|
||||
* Service responsible for managing privacy pool accounts and their associated commitments.
|
||||
@@ -781,11 +781,11 @@ export class AccountService {
|
||||
dataService: DataService,
|
||||
source:
|
||||
| {
|
||||
mnemonic: string;
|
||||
}
|
||||
mnemonic: string;
|
||||
}
|
||||
| {
|
||||
service: AccountService;
|
||||
},
|
||||
service: AccountService;
|
||||
},
|
||||
pools: PoolInfo[]
|
||||
): Promise<{ account: AccountService; errors: PoolEventsError[] }> {
|
||||
// Log the start of the history retrieval process
|
||||
@@ -876,7 +876,9 @@ export class AccountService {
|
||||
// Create a map of deposits by precommitment for efficient lookup
|
||||
const depositMap = new Map<Hash, DepositEvent>();
|
||||
for (const deposit of deposits) {
|
||||
depositMap.set(deposit.precommitment, deposit);
|
||||
if (!depositMap.has(deposit.precommitment)) {
|
||||
depositMap.set(deposit.precommitment, deposit);
|
||||
}
|
||||
}
|
||||
|
||||
// Track found deposits for logging and debugging
|
||||
|
||||
@@ -104,7 +104,7 @@ export class DataService {
|
||||
_merkleRoot: precommitment,
|
||||
} = log.args;
|
||||
|
||||
if (!depositor || !commitment || !label || !value || !precommitment || !log.blockNumber || !log.transactionHash) {
|
||||
if (!depositor || !commitment || !label || !precommitment || !log.blockNumber || !log.transactionHash) {
|
||||
throw DataError.invalidLog("deposit", "missing required fields");
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ export class DataService {
|
||||
depositor: depositor.toLowerCase(),
|
||||
commitment: commitment as Hash,
|
||||
label: label as Hash,
|
||||
value,
|
||||
value: value || BigInt(0),
|
||||
precommitment: precommitment as Hash,
|
||||
blockNumber: BigInt(log.blockNumber),
|
||||
transactionHash: log.transactionHash,
|
||||
|
||||
Reference in New Issue
Block a user