Skip to content

Commit ad05920

Browse files
authored
chore: define metadata more precisely (#65)
1 parent 66bebf2 commit ad05920

File tree

5 files changed

+104
-23
lines changed

5 files changed

+104
-23
lines changed

schema/metadata/collectible.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ func (c CollectibleTransfer) Type() schema.Type {
1313
return typex.CollectibleTransfer
1414
}
1515

16+
var _ Metadata = (*CollectibleMint)(nil)
17+
18+
type CollectibleMint Token
19+
20+
func (c CollectibleMint) Type() schema.Type {
21+
return typex.CollectibleMint
22+
}
23+
24+
var _ Metadata = (*CollectibleBurn)(nil)
25+
26+
type CollectibleBurn Token
27+
28+
func (c CollectibleBurn) Type() schema.Type {
29+
return typex.CollectibleBurn
30+
}
31+
1632
//go:generate go run --mod=mod github.com/dmarkham/enumer --values --type=CollectibleApprovalAction --transform=snake --trimprefix=ActionCollectibleApproval --output collectible_approval.go --json --sql
1733
type CollectibleApprovalAction uint64
1834

schema/metadata/governance.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ import (
77

88
var _ Metadata = (*GovernanceProposal)(nil)
99

10-
func (t GovernanceProposal) Type() schema.Type {
11-
return typex.GovernanceProposal
12-
}
13-
1410
type GovernanceProposal struct {
1511
ID string `json:"id"`
1612
Body string `json:"body,omitempty"`
@@ -20,16 +16,11 @@ type GovernanceProposal struct {
2016
Link string `json:"link,omitempty"`
2117
}
2218

23-
var _ Metadata = (*GovernanceVote)(nil)
24-
25-
func (t GovernanceVote) Type() schema.Type {
26-
return typex.GovernanceVote
19+
func (t GovernanceProposal) Type() schema.Type {
20+
return typex.GovernanceProposal
2721
}
2822

29-
//go:generate go run --mod=mod github.com/dmarkham/enumer --values --type=GovernanceVoteAction --transform=snake --trimprefix=ActionGovernanceVote --output governance_vote.go --json --sql
30-
type GovernanceVoteAction uint64
31-
32-
var _ Metadata = (*GovernanceVoteAction)(nil)
23+
var _ Metadata = (*GovernanceVote)(nil)
3324

3425
type GovernanceVote struct {
3526
Action GovernanceVoteAction `json:"action"`
@@ -38,10 +29,13 @@ type GovernanceVote struct {
3829
Proposal GovernanceProposal `json:"token"`
3930
}
4031

41-
func (r GovernanceVoteAction) Type() schema.Type {
32+
func (t GovernanceVote) Type() schema.Type {
4233
return typex.GovernanceVote
4334
}
4435

36+
//go:generate go run --mod=mod github.com/dmarkham/enumer --values --type=GovernanceVoteAction --transform=snake --trimprefix=ActionGovernanceVote --output governance_vote.go --json --sql
37+
type GovernanceVoteAction uint64
38+
4539
const (
4640
ActionGovernanceVoteFor GovernanceVoteAction = iota + 1
4741
ActionGovernanceVoteAgainst

schema/metadata/metaverse.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package metadata
22

33
import (
44
"github.com/rss3-network/protocol-go/schema"
5-
"github.com/rss3-network/protocol-go/schema/tag"
65
"github.com/rss3-network/protocol-go/schema/typex"
76
)
87

@@ -24,14 +23,26 @@ var _ Metadata = (*MetaverseTransfer)(nil)
2423

2524
type MetaverseTransfer Token
2625

27-
func (m MetaverseTransfer) Tag() tag.Tag {
28-
return tag.Metaverse
29-
}
30-
3126
func (m MetaverseTransfer) Type() schema.Type {
3227
return typex.MetaverseTransfer
3328
}
3429

30+
var _ Metadata = (*MetaverseMint)(nil)
31+
32+
type MetaverseMint Token
33+
34+
func (m MetaverseMint) Type() schema.Type {
35+
return typex.MetaverseMint
36+
}
37+
38+
var _ Metadata = (*MetaverseBurn)(nil)
39+
40+
type MetaverseBurn Token
41+
42+
func (m MetaverseBurn) Type() schema.Type {
43+
return typex.MetaverseBurn
44+
}
45+
3546
var _ Metadata = (*MetaverseTrade)(nil)
3647

3748
type MetaverseTrade struct {
@@ -41,10 +52,6 @@ type MetaverseTrade struct {
4152
Cost Token `json:"cost,omitempty"`
4253
}
4354

44-
func (m MetaverseTrade) Tag() tag.Tag {
45-
return tag.Metaverse
46-
}
47-
4855
func (m MetaverseTrade) Type() schema.Type {
4956
return typex.MetaverseTrade
5057
}

schema/metadata/social.go

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,58 @@ type Media struct {
3434
MimeType string `json:"mime_type"`
3535
}
3636

37-
func (p SocialPost) Type() schema.Type {
37+
func (s SocialPost) Type() schema.Type {
3838
return typex.SocialPost
3939
}
4040

41+
var _ Metadata = (*SocialComment)(nil)
42+
43+
type SocialComment SocialPost
44+
45+
func (s SocialComment) Type() schema.Type {
46+
return typex.SocialComment
47+
}
48+
49+
var _ Metadata = (*SocialRevise)(nil)
50+
51+
type SocialRevise SocialPost
52+
53+
func (s SocialRevise) Type() schema.Type {
54+
return typex.SocialRevise
55+
}
56+
57+
var _ Metadata = (*SocialReward)(nil)
58+
59+
type SocialReward SocialPost
60+
61+
func (s SocialReward) Type() schema.Type {
62+
return typex.SocialReward
63+
}
64+
65+
var _ Metadata = (*SocialShare)(nil)
66+
67+
type SocialShare SocialPost
68+
69+
func (s SocialShare) Type() schema.Type {
70+
return typex.SocialShare
71+
}
72+
73+
var _ Metadata = (*SocialDelete)(nil)
74+
75+
type SocialDelete SocialPost
76+
77+
func (s SocialDelete) Type() schema.Type {
78+
return typex.SocialDelete
79+
}
80+
81+
var _ Metadata = (*SocialMint)(nil)
82+
83+
type SocialMint SocialPost
84+
85+
func (s SocialMint) Type() schema.Type {
86+
return typex.SocialMint
87+
}
88+
4189
var _ Metadata = (*SocialProfileAction)(nil)
4290

4391
//go:generate go run --mod=mod github.com/dmarkham/enumer --values --type=SocialProfileAction --transform=snake --trimprefix=ActionSocialProfile --output social_profile.go --json --sql

schema/metadata/transaction.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@ func (t TransactionTransfer) Type() schema.Type {
1414
return typex.TransactionTransfer
1515
}
1616

17+
var _ Metadata = (*TransactionMint)(nil)
18+
19+
type TransactionMint Token
20+
21+
func (t TransactionMint) Type() schema.Type {
22+
return typex.TransactionMint
23+
}
24+
25+
var _ Metadata = (*TransactionBurn)(nil)
26+
27+
type TransactionBurn Token
28+
29+
func (t TransactionBurn) Type() schema.Type {
30+
return typex.TransactionBurn
31+
}
32+
1733
//go:generate go run --mod=mod github.com/dmarkham/enumer --values --type=TransactionApprovalAction --transform=snake --trimprefix=ActionTransaction --output transaction_approval.go --json --sql
1834
type TransactionApprovalAction uint64
1935

0 commit comments

Comments
 (0)