Skip to content

Commit

Permalink
add id generator for eth logs type (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelm41 authored Oct 23, 2023
1 parent dec395b commit 4142015
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions types/transaction.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package types

import (
"crypto/sha256"
"encoding/json"
"github.com/filecoin-project/lotus/chain/types/ethtypes"
"math/big"
"reflect"
Expand Down Expand Up @@ -47,6 +49,18 @@ type EthLog struct {
TransactionCid string `json:"transactionCid"`
}

func (t EthLog) GetId() (string, error) {
h := sha256.New()
rawData, err := json.Marshal(t)
if err != nil {
return "", err
}

h.Write(rawData)
hash := h.Sum(nil)
return string(hash), nil
}

type GenesisBalances struct {
Actors struct {
All []struct {
Expand Down

0 comments on commit 4142015

Please sign in to comment.