Skip to content

Commit

Permalink
Added soulbound field for collectibles (#5026)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuteivist authored Apr 9, 2024
1 parent f9df853 commit d3d155a
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.179.0
0.179.1
1 change: 1 addition & 0 deletions services/ext/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ func (s *Service) FillCollectibleMetadata(collectible *thirdparty.FullCollectibl
collectible.CollectibleData.Description = tokenMetadata.GetDescription()
collectible.CollectibleData.ImagePayload = imagePayload
collectible.CollectibleData.Traits = getCollectibleCommunityTraits(communityToken)
collectible.CollectibleData.Soulbound = !communityToken.Transferable

if collectible.CollectionData == nil {
collectible.CollectionData = &thirdparty.CollectionData{
Expand Down
6 changes: 4 additions & 2 deletions services/wallet/collectibles/collectible_data_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewCollectibleDataDB(sqlDb *sql.DB) *CollectibleDataDB {
}
}

const collectibleDataColumns = "chain_id, contract_address, token_id, provider, name, description, permalink, image_url, image_payload, animation_url, animation_media_type, background_color, token_uri, community_id"
const collectibleDataColumns = "chain_id, contract_address, token_id, provider, name, description, permalink, image_url, image_payload, animation_url, animation_media_type, background_color, token_uri, community_id, soulbound"
const collectibleCommunityDataColumns = "community_privileges_level"
const collectibleTraitsColumns = "chain_id, contract_address, token_id, trait_type, trait_value, display_type, max_value"
const selectCollectibleTraitsColumns = "trait_type, trait_value, display_type, max_value"
Expand Down Expand Up @@ -108,7 +108,7 @@ func upsertCollectibleTraits(creator sqlite.StatementCreator, id thirdparty.Coll

func setCollectiblesData(creator sqlite.StatementCreator, collectibles []thirdparty.CollectibleData, allowUpdate bool) error {
insertCollectible, err := creator.Prepare(fmt.Sprintf(`%s INTO collectible_data_cache (%s)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, insertStatement(allowUpdate), collectibleDataColumns))
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, insertStatement(allowUpdate), collectibleDataColumns))
if err != nil {
return err
}
Expand All @@ -129,6 +129,7 @@ func setCollectiblesData(creator sqlite.StatementCreator, collectibles []thirdpa
c.BackgroundColor,
c.TokenURI,
c.CommunityID,
c.Soulbound,
)
if err != nil {
return err
Expand Down Expand Up @@ -194,6 +195,7 @@ func scanCollectiblesDataRow(row *sql.Row) (*thirdparty.CollectibleData, error)
&c.BackgroundColor,
&c.TokenURI,
&c.CommunityID,
&c.Soulbound,
)
if err != nil {
return nil, err
Expand Down
3 changes: 3 additions & 0 deletions services/wallet/collectibles/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type CollectibleData struct {
AnimationMediaType *string `json:"animation_media_type,omitempty"`
Traits *[]thirdparty.CollectibleTrait `json:"traits,omitempty"`
BackgroundColor *string `json:"background_color,omitempty"`
Soulbound *bool `json:"soulbound,omitempty"`
}

type CollectionData struct {
Expand Down Expand Up @@ -84,6 +85,7 @@ func fullCollectibleDataToHeader(c thirdparty.FullCollectibleData) Collectible {
AnimationURL: &c.CollectibleData.AnimationURL,
AnimationMediaType: &c.CollectibleData.AnimationMediaType,
BackgroundColor: &c.CollectibleData.BackgroundColor,
Soulbound: &c.CollectibleData.Soulbound,
},
}
if c.CollectionData != nil {
Expand Down Expand Up @@ -125,6 +127,7 @@ func fullCollectibleDataToDetails(c thirdparty.FullCollectibleData) Collectible
AnimationMediaType: &c.CollectibleData.AnimationMediaType,
BackgroundColor: &c.CollectibleData.BackgroundColor,
Traits: &c.CollectibleData.Traits,
Soulbound: &c.CollectibleData.Soulbound,
},
}
if c.CollectionData != nil {
Expand Down
1 change: 1 addition & 0 deletions services/wallet/thirdparty/collectible_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ type CollectibleData struct {
BackgroundColor string `json:"background_color"`
TokenURI string `json:"token_uri"`
IsFirst bool `json:"is_first"`
Soulbound bool `json:"soulbound"`
}

// Community-related collectible info. Present only for collectibles minted in a community.
Expand Down
23 changes: 23 additions & 0 deletions walletdatabase/migrations/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE collectible_data_cache ADD COLUMN soulbound BOOL DEFAULT FALSE;

0 comments on commit d3d155a

Please # to comment.