mirror of
https://github.com/0xbow-io/privacy-pools-core.git
synced 2026-01-09 17:37:58 -05:00
feat: add withdrawal simulation to relayer
This commit is contained in:
@@ -59,6 +59,14 @@ export class PrivacyPoolRelayer {
|
|||||||
throw ZkError.invalidProof();
|
throw ZkError.invalidProof();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// simulate tx before broadcasting
|
||||||
|
const simulationResult = await this.sdkProvider.simulateWithdrawal(req, chainId);
|
||||||
|
|
||||||
|
if (!simulationResult.success) {
|
||||||
|
const simulationError = simulationResult.error || "Unknown simulation failure";
|
||||||
|
throw BlockchainError.txSimulationError(`Relay simulation failed: ${simulationError}`);
|
||||||
|
}
|
||||||
|
|
||||||
const response = await this.broadcastWithdrawal(req, chainId);
|
const response = await this.broadcastWithdrawal(req, chainId);
|
||||||
await this.db.updateBroadcastedRequest(requestId, response.hash);
|
await this.db.updateBroadcastedRequest(requestId, response.hash);
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,12 @@ export interface ContractInteractions {
|
|||||||
scope: Hash,
|
scope: Hash,
|
||||||
): Promise<TransactionResponse>;
|
): Promise<TransactionResponse>;
|
||||||
|
|
||||||
|
simulateRelay(
|
||||||
|
withdrawal: Withdrawal,
|
||||||
|
withdrawalProof: WithdrawalProof,
|
||||||
|
scope: Hash
|
||||||
|
): Promise<{ success: boolean; gasEstimate?: bigint; error?: string }>;
|
||||||
|
|
||||||
ragequit(
|
ragequit(
|
||||||
commitmentProof: CommitmentProof,
|
commitmentProof: CommitmentProof,
|
||||||
privacyPoolAddress: Address,
|
privacyPoolAddress: Address,
|
||||||
|
|||||||
Reference in New Issue
Block a user