feat_: add unique key to each activity entry
This commit is contained in:
parent
cdc41c3b64
commit
7be222a1d2
|
@ -85,9 +85,21 @@ type Entry struct {
|
|||
isNew bool // isNew is used to indicate if the entry is newer than session start (changed state also)
|
||||
}
|
||||
|
||||
func (e *Entry) Key() string {
|
||||
if e.payloadType == MultiTransactionPT {
|
||||
key := fmt.Sprintf("%d", e.id)
|
||||
for _, t := range e.transactions {
|
||||
key += fmt.Sprintf("-%s", t.Key())
|
||||
}
|
||||
return key
|
||||
}
|
||||
return e.transaction.Key()
|
||||
}
|
||||
|
||||
// Only used for JSON marshalling
|
||||
type EntryData struct {
|
||||
PayloadType PayloadType `json:"payloadType"`
|
||||
Key string `json:"key"`
|
||||
Transaction *transfer.TransactionIdentity `json:"transaction,omitempty"`
|
||||
ID *common.MultiTransactionIDType `json:"id,omitempty"`
|
||||
Transactions []*transfer.TransactionIdentity `json:"transactions,omitempty"`
|
||||
|
@ -118,6 +130,7 @@ type EntryData struct {
|
|||
|
||||
func (e *Entry) MarshalJSON() ([]byte, error) {
|
||||
data := EntryData{
|
||||
Key: e.Key(),
|
||||
Timestamp: &e.timestamp,
|
||||
ActivityType: &e.activityType,
|
||||
ActivityStatus: &e.activityStatus,
|
||||
|
|
|
@ -276,6 +276,7 @@ func (s *Service) getActivityDetails(ctx context.Context, entries []Entry) ([]*E
|
|||
}
|
||||
for _, e := range entryList {
|
||||
data := &EntryData{
|
||||
Key: e.Key(),
|
||||
NftName: nftName,
|
||||
NftURL: nftURL,
|
||||
}
|
||||
|
|
|
@ -456,6 +456,7 @@ func (s *Service) processEntryDataUpdates(sessionID SessionID, entries []Entry,
|
|||
}
|
||||
|
||||
data := &EntryData{
|
||||
Key: e.Key(),
|
||||
ActivityStatus: &e.activityStatus,
|
||||
}
|
||||
if e.payloadType == MultiTransactionPT {
|
||||
|
|
|
@ -126,6 +126,10 @@ type TransactionIdentity struct {
|
|||
Address common.Address `json:"address"`
|
||||
}
|
||||
|
||||
func (tid *TransactionIdentity) Key() string {
|
||||
return fmt.Sprintf("%d-%s-%s", tid.ChainID, tid.Hash.Hex(), tid.Address.Hex())
|
||||
}
|
||||
|
||||
type TxResponse struct {
|
||||
KeyUID string `json:"keyUid,omitempty"`
|
||||
Address types.Address `json:"address,omitempty"`
|
||||
|
|
Loading…
Reference in New Issue