@@ -137,6 +137,7 @@ func (p *service) findNewTwitterRegistrations(ctx context.Context) error {
137
137
continue
138
138
}
139
139
140
+ // Attempt to find a tip account from the registration tweet
140
141
tipAccount , err := findTipAccountRegisteredInTweet (tweet )
141
142
switch err {
142
143
case nil :
@@ -146,6 +147,20 @@ func (p *service) findNewTwitterRegistrations(ctx context.Context) error {
146
147
return errors .Wrapf (err , "unexpected error processing tweet %s" , tweet .ID )
147
148
}
148
149
150
+ // Validate the new tip account
151
+ accountInfoRecord , err := p .data .GetAccountInfoByTokenAddress (ctx , tipAccount .PublicKey ().ToBase58 ())
152
+ switch err {
153
+ case nil :
154
+ // todo: potentially use a relationship account instead
155
+ if accountInfoRecord .AccountType != commonpb .AccountType_PRIMARY {
156
+ continue
157
+ }
158
+ case account .ErrAccountInfoNotFound :
159
+ continue
160
+ default :
161
+ return errors .Wrap (err , "error getting account info" )
162
+ }
163
+
149
164
processedUsernames [tweet .AdditionalMetadata .Author .Username ] = struct {}{}
150
165
151
166
err = p .updateCachedTwitterUser (ctx , tweet .AdditionalMetadata .Author , tipAccount )
@@ -197,21 +212,6 @@ func (p *service) updateCachedTwitterUser(ctx context.Context, user *twitter_lib
197
212
mu .Lock ()
198
213
defer mu .Unlock ()
199
214
200
- // Validate the new tip account if it's provided
201
- if newTipAccount != nil {
202
- accountInfoRecord , err := p .data .GetAccountInfoByTokenAddress (ctx , newTipAccount .PublicKey ().ToBase58 ())
203
- switch err {
204
- case nil :
205
- if accountInfoRecord .AccountType != commonpb .AccountType_PRIMARY {
206
- return nil
207
- }
208
- case account .ErrAccountInfoNotFound :
209
- return nil
210
- default :
211
- return errors .Wrap (err , "error getting account info" )
212
- }
213
- }
214
-
215
215
record , err := p .data .GetTwitterUser (ctx , user .Username )
216
216
switch err {
217
217
case twitter .ErrUserNotFound :
0 commit comments