-
Notifications
You must be signed in to change notification settings - Fork 17
/
tag.go
41 lines (36 loc) · 923 Bytes
/
tag.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package operations
import (
"context"
"github.com/baking-bad/bcdhub/internal/config"
"github.com/baking-bad/bcdhub/internal/models/contract"
"github.com/baking-bad/bcdhub/internal/models/operation"
"github.com/baking-bad/bcdhub/internal/models/types"
)
func setTags(ctx context.Context, configCtx *config.Context, contract *contract.Contract, op *operation.Operation) error {
if op.Destination.Type != types.AccountTypeContract {
return nil
}
var tags types.Tags
if contract == nil {
c, err := configCtx.Cache.ContractTags(ctx, op.Destination.Address)
if err != nil {
if configCtx.Storage.IsRecordNotFound(err) {
return nil
}
return err
}
tags = c
} else {
tags = contract.Tags
}
if tags.Has(types.FA12Tag) {
op.Tags.Set(types.FA12Tag)
}
if tags.Has(types.FA2Tag) {
op.Tags.Set(types.FA2Tag)
}
if tags.Has(types.LedgerTag) {
op.Tags.Set(types.LedgerTag)
}
return nil
}