Comments (4)
Ah ok, thank you for clarifying, and I fully understand the issue now. I can see you do have a good grasp of the SDK and APIs, so I hope you don't mind the proper explainer.
I hope I can give you enough context so we can find a solution that works in you case and hopefully make things better for others as well.
Present: Wallets-follow-Profiles
In the current version of the Lens Protocol the actor who follows is technically a Wallet and not a Lens Profile. This is due to the underlying nature of a follow relationship, which is modelled as an NFT. NFTs are hold into the user's wallet. Profile are also NFTs hold into user's wallet. This was a decision made back in the days to stay true to the underlying NFT spec (i.e. ERC-721).
The implications of this is that Wallet is currently a central part to the definition of a social graph on Lens. A Wallet can hold 1 or many Lens Profile. A Wallet can hold 1 or many Follow relationships (NFT) with Lens profiles and conversely a Lens Profile
can be followed by many Wallets 1.
(Near) future: Profiles-follow-Profiles
We think this is not ideal, and that profiles-follow-profiles is a better way to express the relationship in a social graph. We are working on making this possible at the Lens Protocol level. We will make clear communication once this is possible.
In the meantime
In the meantime we made some adjustments a the Lens API and Lens SDK level so to start bridging the gap between the current Lens protocol constraints and the future iteration.
The "observer" concept in the Lens SDK is part of this. Currently for profile queries it does impact just one edge called isFollowingObserver
which returns true
if the observed profile (the wallet owner of the observed profile to be precise) is following the observer profile.
The isFollowedByMe
instead, is still surfacing the underlying wallets-follow-profiles. I understand this is not ideal. It basically tells you if the authenticated wallet is following the observed profile.
I can see 2 way to address this:
a) can your UX change so to login the user (via the useWalletLogin
)? This will work out of the box and the isFollowedByMe
edge will return true as you expect it (you won't need to provide an observerId
as per my previous comment).
OR
b) we need to create a new field (e.g. isFollowedByObserver
) which does what is says on the tin.
What do you think? If you have any other ideas/suggestion, please let me know.
Footnotes
-
You might have noticed some Lens API features that foes under the label "default profile". This was and interim attempt to overcome the fact that, although profiles are followed by wallets, any meaningful UI wants to show a profile. So the default profile feature was meant to allow UIs to build a way for user's to define the default profile to show when an action is associated with their wallet (follow, but also collect). Since then we are progressing the Lens Protocol so that Lens profile will be the "actor" of those actions so the "default profile" feature will be decommissioned at some point. It's not even exposed directly by the Lens SDK cause it will become obsolete soon, so we just didn't want to promote it. ↩
from lens-sdk.
Thank you for the suggestions! And for helping make this better for the developers building on top of lens.
The following helped to figure this out for us:
This is due to the underlying nature of a follow relationship, which is modelled as an NFT. NFTs are hold into the user's wallet. Profile are also NFTs hold into user's wallet.
Since we are directly talking to the lens contract, we will just read through the follow NFTs and check whether the observer is a holder.
from lens-sdk.
Hi @chazzaoui thank you for taking the time to document this.
When you said:
Expected result is that it should give me the data back from the profiled in my observerId.
If I understand correctly you are expecting the useProfile
to return profile data of the profile specified as Observer ID.
Expected result is that it should give me the data back from the profiled in my observerId.
I totally understand this is not fully documented yet, but the observer ID does not serve this purpose. The Observer ID is the profile that is, sort to say, "watching the data". This is necessary in order to customize some of the fields so that they show the relationship between the observed profile (the one we are aiming to retrieve) and the profile that observes it (usually the logged-in user profile).
Think of it as the subject that is watching the data.
Since v0.6.0 we auto-wired the current Active Profile ID into it1.
So with exception of very rare use cases you should not worry about providing an observerId
.
We didn't get yet to fully document the useProfile
hook, but in the reference you will find that several other hooks do accept the observerId
, take for example useExplorePublications
for which we already have comprehensive reference documentation here.
Coming back at your query, what you want to use here is profileId
:
const { data, loading, error } = useProfile({
profileId: currentClubProfileId?._hex as ProfileId
})
Bear in mind that useProfile
accepts profileId
OR handle
, it will throw a dev friendly error to let you know that are mutually exclusive. So you don't need the handle at all.
Footnotes
-
there is a relatively new documentation page explaining the Active Profile and how it works with the current logged-in wallet: https://docs.lens.xyz/docs/profile-management ↩
from lens-sdk.
Thank you for the thorough response!
I think I failed to convey my issue in my original post. I believe I understand correctly that the observerId is meant to customize some of the fields to show the relationship between the observed profile and the profile that observes it, but in this case, it does not work as expected. Could this be a bug?
Additionally, I want to clarify that we do not use the API to authenticate, which is why we need to use the observerId to force the perspective.
const { data, loading, error } = useProfile({
handle: 'bugsmasher.lens',
observerId: '0x01a572' as ProfileId
})
// `data.isFollowedByMe` should be true, but it isn't
from lens-sdk.
Related Issues (20)
- Add WalletAuthetificationToProfileAuthetification to sdk HOT 3
- Here is the diff that solved my problem: HOT 2
- The 'useOwnedHandles' hook failed to execute correctly in the production environment
- It seems that the data provided by useOwnedHandles is not sufficiently real-time. I am unable to retrieve the profile I purchased through this hook. HOT 2
- Support Node Engine 20 HOT 3
- When I switch to a new wallet, LensProvider doesn't replace with the new signer. Can anyone help me look at this issue HOT 3
- useSetProfileMetadata should update the profile cache returned by useSession HOT 2
- Support wagmi v2 HOT 5
- In the useOpenAction react hook, when the user doesn't have enough funds to collect, an unhandled promise is being thrown instead of being handled by the SDK HOT 7
- Add support for React suspense HOT 9
- Regression in latest version of the SDK 2.0.0-alpha.29 when creating a publication HOT 9
- Get a refreshed access token if expired HOT 29
- SSR support with the React SDK HOT 2
- export 'isObject' (imported as 'isObject') was not found in '@lens-protocol/shared-kernel' HOT 3
- Apollo cache issue when liking or bookmarking your own posts HOT 5
- @lens-protocol/react-web HOT 4
- usePublications failed to execute if one of publication on scope have an invalid encryption condition HOT 1
- verifyFrameSignature: SIGNER_ADDRESS_CANNOT_USE_PROFILE(Lens Frame) HOT 1
- Migrate from `traverse` to `neotraverse`
- Using LensProvider in a page.js router Next.js project HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lens-sdk.