Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
openCommitment return txHash
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikelle committed Apr 15, 2024
1 parent 1ad227a commit 7b426ed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions pkg/contracts/preconf/preconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ func (p *preconfContract) OpenCommitment(
callData, err := p.preconfABI.Pack(
"openCommitment",
eciBytes,
bidAmt,
big.NewInt(blockNumber),
bidAmt.Uint64(),
big.NewInt(blockNumber).Uint64(),
txnHash,
big.NewInt(decayStartTimeStamp),
big.NewInt(decayEndTimeStamp),
big.NewInt(decayStartTimeStamp).Uint64(),
big.NewInt(decayEndTimeStamp).Uint64(),
bidSignature,
commitmentSignature,
sharedSecretKey,
Expand All @@ -142,13 +142,13 @@ func (p *preconfContract) OpenCommitment(
return common.Hash{}, err
}

_, err = p.client.Send(ctx, &evmclient.TxRequest{
txHash, err := p.client.Send(ctx, &evmclient.TxRequest{
To: &p.preconfContractAddr,
CallData: callData,
})
if err != nil {
return common.Hash{}, err
}

return common.Hash{}, fmt.Errorf("commitmentIndex not found in transaction receipt")
return txHash, nil
}
4 changes: 2 additions & 2 deletions pkg/preconfirmation/preconfirmation.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func (p *Preconfirmation) HandleNewL1BlockEvent(ctx context.Context, event block
p.logger.Info("New L1 Block event received", "blockNumber", event.BlockNumber, "winner", event.Winner, "window", event.Window)
// todo: for provider check if winner == providerAddress, for bidder if committerAddress
for _, commitment := range p.commitmentByBlockNumber[event.BlockNumber.Int64()] {
_, err := p.commitmentDA.OpenCommitment(
txHash, err := p.commitmentDA.OpenCommitment(
ctx,
commitment.EncryptedPreConfirmation.CommitmentIndex,
commitment.PreConfirmation.Bid.BidAmount,
Expand All @@ -368,7 +368,7 @@ func (p *Preconfirmation) HandleNewL1BlockEvent(ctx context.Context, event block
p.logger.Error("Failed to open commitment", "error", err)
continue
} else {
p.logger.Info("Opened commitment", "txHash", commitment.PreConfirmation.Bid.TxHash)
p.logger.Info("Opened commitment", "txHash", txHash)
}
}
delete(p.commitmentByBlockNumber, event.BlockNumber.Int64())
Expand Down

0 comments on commit 7b426ed

Please sign in to comment.