github.com/status-im/status-go@v1.1.0/protocol/messenger_profile_showcase_proto_conversions.go (about) 1 package protocol 2 3 import ( 4 "github.com/status-im/status-go/protocol/identity" 5 "github.com/status-im/status-go/protocol/protobuf" 6 ) 7 8 func FromProfileShowcaseCommunityPreferenceProto(p *protobuf.ProfileShowcaseCommunityPreference) *identity.ProfileShowcaseCommunityPreference { 9 return &identity.ProfileShowcaseCommunityPreference{ 10 CommunityID: p.GetCommunityId(), 11 ShowcaseVisibility: identity.ProfileShowcaseVisibility(p.ShowcaseVisibility), 12 Order: int(p.Order), 13 } 14 } 15 16 func FromProfileShowcaseCommunitiesPreferencesProto(preferences []*protobuf.ProfileShowcaseCommunityPreference) []*identity.ProfileShowcaseCommunityPreference { 17 out := make([]*identity.ProfileShowcaseCommunityPreference, 0, len(preferences)) 18 for _, p := range preferences { 19 out = append(out, FromProfileShowcaseCommunityPreferenceProto(p)) 20 } 21 return out 22 } 23 24 func ToProfileShowcaseCommunityPreferenceProto(p *identity.ProfileShowcaseCommunityPreference) *protobuf.ProfileShowcaseCommunityPreference { 25 return &protobuf.ProfileShowcaseCommunityPreference{ 26 CommunityId: p.CommunityID, 27 ShowcaseVisibility: protobuf.ProfileShowcaseVisibility(p.ShowcaseVisibility), 28 Order: uint32(p.Order), 29 } 30 } 31 32 func ToProfileShowcaseCommunitiesPreferencesProto(preferences []*identity.ProfileShowcaseCommunityPreference) []*protobuf.ProfileShowcaseCommunityPreference { 33 out := make([]*protobuf.ProfileShowcaseCommunityPreference, 0, len(preferences)) 34 for _, p := range preferences { 35 out = append(out, ToProfileShowcaseCommunityPreferenceProto(p)) 36 } 37 return out 38 } 39 40 func FromProfileShowcaseAccountPreferenceProto(p *protobuf.ProfileShowcaseAccountPreference) *identity.ProfileShowcaseAccountPreference { 41 return &identity.ProfileShowcaseAccountPreference{ 42 Address: p.GetAddress(), 43 ShowcaseVisibility: identity.ProfileShowcaseVisibility(p.ShowcaseVisibility), 44 Order: int(p.Order), 45 } 46 } 47 48 func FromProfileShowcaseAccountsPreferencesProto(preferences []*protobuf.ProfileShowcaseAccountPreference) []*identity.ProfileShowcaseAccountPreference { 49 out := make([]*identity.ProfileShowcaseAccountPreference, 0, len(preferences)) 50 for _, p := range preferences { 51 out = append(out, FromProfileShowcaseAccountPreferenceProto(p)) 52 } 53 return out 54 } 55 56 func ToProfileShowcaseAccountPreferenceProto(p *identity.ProfileShowcaseAccountPreference) *protobuf.ProfileShowcaseAccountPreference { 57 return &protobuf.ProfileShowcaseAccountPreference{ 58 Address: p.Address, 59 ShowcaseVisibility: protobuf.ProfileShowcaseVisibility(p.ShowcaseVisibility), 60 Order: uint32(p.Order), 61 } 62 } 63 64 func ToProfileShowcaseAccountsPreferenceProto(preferences []*identity.ProfileShowcaseAccountPreference) []*protobuf.ProfileShowcaseAccountPreference { 65 out := make([]*protobuf.ProfileShowcaseAccountPreference, 0, len(preferences)) 66 for _, p := range preferences { 67 out = append(out, ToProfileShowcaseAccountPreferenceProto(p)) 68 } 69 return out 70 } 71 72 func FromProfileShowcaseCollectiblePreferenceProto(p *protobuf.ProfileShowcaseCollectiblePreference) *identity.ProfileShowcaseCollectiblePreference { 73 return &identity.ProfileShowcaseCollectiblePreference{ 74 ContractAddress: p.GetContractAddress(), 75 ChainID: p.GetChainId(), 76 TokenID: p.GetTokenId(), 77 ShowcaseVisibility: identity.ProfileShowcaseVisibility(p.ShowcaseVisibility), 78 Order: int(p.Order), 79 } 80 } 81 82 func FromProfileShowcaseCollectiblesPreferencesProto(preferences []*protobuf.ProfileShowcaseCollectiblePreference) []*identity.ProfileShowcaseCollectiblePreference { 83 out := make([]*identity.ProfileShowcaseCollectiblePreference, 0, len(preferences)) 84 for _, p := range preferences { 85 out = append(out, FromProfileShowcaseCollectiblePreferenceProto(p)) 86 } 87 return out 88 } 89 90 func ToProfileShowcaseCollectiblePreferenceProto(p *identity.ProfileShowcaseCollectiblePreference) *protobuf.ProfileShowcaseCollectiblePreference { 91 return &protobuf.ProfileShowcaseCollectiblePreference{ 92 ContractAddress: p.ContractAddress, 93 ChainId: p.ChainID, 94 TokenId: p.TokenID, 95 ShowcaseVisibility: protobuf.ProfileShowcaseVisibility(p.ShowcaseVisibility), 96 Order: uint32(p.Order), 97 } 98 } 99 100 func ToProfileShowcaseCollectiblesPreferenceProto(preferences []*identity.ProfileShowcaseCollectiblePreference) []*protobuf.ProfileShowcaseCollectiblePreference { 101 out := make([]*protobuf.ProfileShowcaseCollectiblePreference, 0, len(preferences)) 102 for _, p := range preferences { 103 out = append(out, ToProfileShowcaseCollectiblePreferenceProto(p)) 104 } 105 return out 106 } 107 108 func FromProfileShowcaseVerifiedTokenPreferenceProto(p *protobuf.ProfileShowcaseVerifiedTokenPreference) *identity.ProfileShowcaseVerifiedTokenPreference { 109 return &identity.ProfileShowcaseVerifiedTokenPreference{ 110 Symbol: p.GetSymbol(), 111 ShowcaseVisibility: identity.ProfileShowcaseVisibility(p.ShowcaseVisibility), 112 Order: int(p.Order), 113 } 114 } 115 116 func FromProfileShowcaseVerifiedTokensPreferencesProto(preferences []*protobuf.ProfileShowcaseVerifiedTokenPreference) []*identity.ProfileShowcaseVerifiedTokenPreference { 117 out := make([]*identity.ProfileShowcaseVerifiedTokenPreference, 0, len(preferences)) 118 for _, p := range preferences { 119 out = append(out, FromProfileShowcaseVerifiedTokenPreferenceProto(p)) 120 } 121 return out 122 } 123 124 func ToProfileShowcaseVerifiedTokenPreferenceProto(p *identity.ProfileShowcaseVerifiedTokenPreference) *protobuf.ProfileShowcaseVerifiedTokenPreference { 125 return &protobuf.ProfileShowcaseVerifiedTokenPreference{ 126 Symbol: p.Symbol, 127 ShowcaseVisibility: protobuf.ProfileShowcaseVisibility(p.ShowcaseVisibility), 128 Order: uint32(p.Order), 129 } 130 131 } 132 133 func ToProfileShowcaseVerifiedTokensPreferenceProto(preferences []*identity.ProfileShowcaseVerifiedTokenPreference) []*protobuf.ProfileShowcaseVerifiedTokenPreference { 134 out := make([]*protobuf.ProfileShowcaseVerifiedTokenPreference, 0, len(preferences)) 135 for _, p := range preferences { 136 out = append(out, ToProfileShowcaseVerifiedTokenPreferenceProto(p)) 137 } 138 return out 139 } 140 141 func FromProfileShowcaseUnverifiedTokenPreferenceProto(p *protobuf.ProfileShowcaseUnverifiedTokenPreference) *identity.ProfileShowcaseUnverifiedTokenPreference { 142 return &identity.ProfileShowcaseUnverifiedTokenPreference{ 143 ContractAddress: p.GetContractAddress(), 144 ChainID: p.GetChainId(), 145 ShowcaseVisibility: identity.ProfileShowcaseVisibility(p.ShowcaseVisibility), 146 Order: int(p.Order), 147 } 148 } 149 150 func FromProfileShowcaseUnverifiedTokensPreferencesProto(preferences []*protobuf.ProfileShowcaseUnverifiedTokenPreference) []*identity.ProfileShowcaseUnverifiedTokenPreference { 151 out := make([]*identity.ProfileShowcaseUnverifiedTokenPreference, 0, len(preferences)) 152 for _, p := range preferences { 153 out = append(out, FromProfileShowcaseUnverifiedTokenPreferenceProto(p)) 154 } 155 return out 156 } 157 158 func ToProfileShowcaseUnverifiedTokenPreferenceProto(p *identity.ProfileShowcaseUnverifiedTokenPreference) *protobuf.ProfileShowcaseUnverifiedTokenPreference { 159 return &protobuf.ProfileShowcaseUnverifiedTokenPreference{ 160 ContractAddress: p.ContractAddress, 161 ChainId: p.ChainID, 162 ShowcaseVisibility: protobuf.ProfileShowcaseVisibility(p.ShowcaseVisibility), 163 Order: uint32(p.Order), 164 } 165 } 166 167 func ToProfileShowcaseUnverifiedTokensPreferenceProto(preferences []*identity.ProfileShowcaseUnverifiedTokenPreference) []*protobuf.ProfileShowcaseUnverifiedTokenPreference { 168 out := make([]*protobuf.ProfileShowcaseUnverifiedTokenPreference, 0, len(preferences)) 169 for _, p := range preferences { 170 out = append(out, ToProfileShowcaseUnverifiedTokenPreferenceProto(p)) 171 } 172 return out 173 } 174 175 func FromProfileShowcaseSocialLinkPreferenceProto(p *protobuf.ProfileShowcaseSocialLinkPreference) *identity.ProfileShowcaseSocialLinkPreference { 176 return &identity.ProfileShowcaseSocialLinkPreference{ 177 Text: p.GetText(), 178 URL: p.GetUrl(), 179 ShowcaseVisibility: identity.ProfileShowcaseVisibility(p.ShowcaseVisibility), 180 Order: int(p.Order), 181 } 182 } 183 184 func FromProfileShowcaseSocialLinksPreferencesProto(preferences []*protobuf.ProfileShowcaseSocialLinkPreference) []*identity.ProfileShowcaseSocialLinkPreference { 185 out := make([]*identity.ProfileShowcaseSocialLinkPreference, 0, len(preferences)) 186 for _, p := range preferences { 187 out = append(out, FromProfileShowcaseSocialLinkPreferenceProto(p)) 188 } 189 return out 190 } 191 192 func ToProfileShowcaseSocialLinkPreferenceProto(p *identity.ProfileShowcaseSocialLinkPreference) *protobuf.ProfileShowcaseSocialLinkPreference { 193 return &protobuf.ProfileShowcaseSocialLinkPreference{ 194 Text: p.Text, 195 Url: p.URL, 196 ShowcaseVisibility: protobuf.ProfileShowcaseVisibility(p.ShowcaseVisibility), 197 Order: uint32(p.Order), 198 } 199 } 200 201 func ToProfileShowcaseSocialLinksPreferenceProto(preferences []*identity.ProfileShowcaseSocialLinkPreference) []*protobuf.ProfileShowcaseSocialLinkPreference { 202 out := make([]*protobuf.ProfileShowcaseSocialLinkPreference, 0, len(preferences)) 203 for _, p := range preferences { 204 out = append(out, ToProfileShowcaseSocialLinkPreferenceProto(p)) 205 } 206 return out 207 } 208 209 func FromProfileShowcasePreferencesProto(p *protobuf.SyncProfileShowcasePreferences) *identity.ProfileShowcasePreferences { 210 return &identity.ProfileShowcasePreferences{ 211 Clock: p.GetClock(), 212 Communities: FromProfileShowcaseCommunitiesPreferencesProto(p.Communities), 213 Accounts: FromProfileShowcaseAccountsPreferencesProto(p.Accounts), 214 Collectibles: FromProfileShowcaseCollectiblesPreferencesProto(p.Collectibles), 215 VerifiedTokens: FromProfileShowcaseVerifiedTokensPreferencesProto(p.VerifiedTokens), 216 UnverifiedTokens: FromProfileShowcaseUnverifiedTokensPreferencesProto(p.UnverifiedTokens), 217 SocialLinks: FromProfileShowcaseSocialLinksPreferencesProto(p.SocialLinks), 218 } 219 } 220 221 func ToProfileShowcasePreferencesProto(p *identity.ProfileShowcasePreferences) *protobuf.SyncProfileShowcasePreferences { 222 return &protobuf.SyncProfileShowcasePreferences{ 223 Clock: p.Clock, 224 Communities: ToProfileShowcaseCommunitiesPreferencesProto(p.Communities), 225 Accounts: ToProfileShowcaseAccountsPreferenceProto(p.Accounts), 226 Collectibles: ToProfileShowcaseCollectiblesPreferenceProto(p.Collectibles), 227 VerifiedTokens: ToProfileShowcaseVerifiedTokensPreferenceProto(p.VerifiedTokens), 228 UnverifiedTokens: ToProfileShowcaseUnverifiedTokensPreferenceProto(p.UnverifiedTokens), 229 SocialLinks: ToProfileShowcaseSocialLinksPreferenceProto(p.SocialLinks), 230 } 231 }