From ccf759a54183c3157da717a82f4c204f595d0616 Mon Sep 17 00:00:00 2001 From: Mikelle Date: Fri, 3 May 2024 19:12:09 +0200 Subject: [PATCH] chore: added wait receipt for testing --- p2p/pkg/contracts/preconf/preconf.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/p2p/pkg/contracts/preconf/preconf.go b/p2p/pkg/contracts/preconf/preconf.go index e9706fcb6..8339a42d1 100644 --- a/p2p/pkg/contracts/preconf/preconf.go +++ b/p2p/pkg/contracts/preconf/preconf.go @@ -91,6 +91,24 @@ func (p *preconfContract) StoreEncryptedCommitment( return common.Hash{}, err } + // todo: delete after testing + receipt, err := p.client.WaitForReceipt(ctx, txnHash) + if err != nil { + return common.Hash{}, err + } + + p.logger.Info("preconf contract storeEncryptedCommitment successful", "txnHash", txnHash) + eventTopicHash := p.preconfABI.Events["EncryptedCommitmentStored"].ID + + for _, log := range receipt.Logs { + if len(log.Topics) > 0 && log.Topics[0] == eventTopicHash { + commitmentIndex := log.Topics[1] + p.logger.Info("Encrypted commitment stored", "commitmentIndex", commitmentIndex.Hex()) + + return txnHash, nil + } + } + return txnHash, nil }