Skip to content

Commit

Permalink
debug getProfile
Browse files Browse the repository at this point in the history
  • Loading branch information
bjartek committed Jul 24, 2024
1 parent aa23dd4 commit e84e439
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions scripts/getProfile.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,35 @@ import "Profile"
import "FIND"

access(all) fun main(user: String) : Profile.UserReport? {
let resolveAddress = FIND.resolve(user)
if resolveAddress == nil {return nil}
let address = resolveAddress!
let account = getAccount(address)
if account.balance == 0.0 {
return nil
}
let resolveAddress = FIND.resolve(user)
if resolveAddress == nil {return nil}
let address = resolveAddress!
let account = getAccount(address)
if account.balance == 0.0 {
return nil
}

var profileReport = account
.getCapability<&{Profile.Public}>(Profile.publicPath)
.borrow()?.asReport()
var profileReport = account.capabilities.borrow<&{Profile.Public}>(Profile.publicPath)?.asReport()

if profileReport != nil && profileReport!.findName != FIND.reverseLookup(address) {
profileReport = Profile.UserReport(
findName: "",
address: profileReport!.address,
name: profileReport!.name,
gender: profileReport!.gender,
description: profileReport!.description,
tags: profileReport!.tags,
avatar: profileReport!.avatar,
links: profileReport!.links,
wallets: profileReport!.wallets,
following: profileReport!.following,
followers: profileReport!.followers,
allowStoringFollowers: profileReport!.allowStoringFollowers,
createdAt: profileReport!.createdAt
)
}
if profileReport != nil && profileReport!.findName != FIND.reverseLookup(address) {
profileReport = Profile.UserReport(
findName: "",
address: profileReport!.address,
name: profileReport!.name,
gender: profileReport!.gender,
description: profileReport!.description,
tags: profileReport!.tags,
avatar: profileReport!.avatar,
links: profileReport!.links,
wallets: profileReport!.wallets,
following: profileReport!.following,
followers: profileReport!.followers,
allowStoringFollowers: profileReport!.allowStoringFollowers,
createdAt: profileReport!.createdAt
)
}

return profileReport
return profileReport


}

0 comments on commit e84e439

Please sign in to comment.