-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'lens-v2' into fix/set-profile-metadata
- Loading branch information
Showing
96 changed files
with
3,331 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@lens-protocol/react": minor | ||
"@lens-protocol/react-web": minor | ||
--- | ||
|
||
refactors hook arguments to be passed to the callback |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@lens-protocol/api-bindings": minor | ||
"@lens-protocol/react": minor | ||
"@lens-protocol/react-web": minor | ||
--- | ||
|
||
adds `useNotInterestedToggle` hook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@lens-protocol/client": patch | ||
--- | ||
|
||
Added profile.fetchDefault and profile.setDefault methods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@lens-protocol/api-bindings": minor | ||
"@lens-protocol/react": minor | ||
"@lens-protocol/react-web": minor | ||
--- | ||
|
||
Added useOwnedHandles hook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { LensClient, development } from '@lens-protocol/client'; | ||
|
||
import { setupWallet } from '../shared/setupWallet'; | ||
|
||
async function main() { | ||
const client = new LensClient({ | ||
environment: development, | ||
}); | ||
|
||
const wallet = setupWallet(); | ||
|
||
const defaultProfile = await client.profile.fetchDefault({ | ||
for: wallet.address, | ||
}); | ||
|
||
console.log(`Default profile for wallet ${wallet.address}: `, { | ||
id: defaultProfile?.id, | ||
handle: defaultProfile?.handle, | ||
}); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
examples/node/scripts/profile/recipes/fetchAllOwnedByMe.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { LensClient, development } from '@lens-protocol/client'; | ||
|
||
import { setupWallet } from '../../shared/setupWallet'; | ||
|
||
async function main() { | ||
const client = new LensClient({ | ||
environment: development, | ||
}); | ||
|
||
const wallet = setupWallet(); | ||
|
||
const allOwnedProfiles = await client.profile.fetchAll({ | ||
where: { ownedBy: [wallet.address] }, | ||
}); | ||
|
||
console.log( | ||
`Profiles owned by address: ${wallet.address}: `, | ||
allOwnedProfiles.items.map((i) => ({ id: i.id, handle: i.handle })), | ||
); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { getAuthenticatedClientFromEthersWallet } from '../shared/getAuthenticatedClient'; | ||
import { getOwnedProfileId } from '../shared/getOwnedProfileId'; | ||
import { setupWallet } from '../shared/setupWallet'; | ||
|
||
async function main() { | ||
const wallet = setupWallet(); | ||
const client = await getAuthenticatedClientFromEthersWallet(wallet); | ||
const profileId = await getOwnedProfileId(client, wallet.address); | ||
|
||
console.log(`Setting default profile for wallet ${wallet.address} to ${profileId}`); | ||
await client.profile.setDefault({ | ||
profileId, | ||
}); | ||
|
||
const defaultProfile = await client.profile.fetchDefault({ | ||
for: wallet.address, | ||
}); | ||
|
||
console.log(`Default profile for wallet ${wallet.address}: `, { | ||
id: defaultProfile?.id, | ||
handle: defaultProfile?.handle, | ||
}); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
import { | ||
EvmAddress, | ||
Profile, | ||
useLinkHandle, | ||
useOwnedHandles, | ||
useProfiles, | ||
useUnlinkHandle, | ||
} from '@lens-protocol/react-web'; | ||
|
||
import { UnauthenticatedFallback, WhenLoggedIn, WhenLoggedOut } from '../components/auth'; | ||
import { ErrorMessage } from '../components/error/ErrorMessage'; | ||
import { Loading } from '../components/loading/Loading'; | ||
|
||
type LinkHandleButtonProps = { | ||
handle: string; | ||
}; | ||
|
||
function LinkHandleButton({ handle }: LinkHandleButtonProps) { | ||
const { execute, error, loading } = useLinkHandle(); | ||
|
||
return ( | ||
<> | ||
<button onClick={() => execute({ handle })} disabled={loading} style={{ padding: '1px 6px' }}> | ||
Link | ||
</button> | ||
{error && <p>{error.message}</p>} | ||
</> | ||
); | ||
} | ||
|
||
type UnlinkHandleButtonProps = { | ||
handle: string; | ||
}; | ||
|
||
function UnlinkHandleButton({ handle }: UnlinkHandleButtonProps) { | ||
const { execute, error, loading } = useUnlinkHandle(); | ||
|
||
return ( | ||
<> | ||
<button onClick={() => execute({ handle })} disabled={loading} style={{ padding: '1px 6px' }}> | ||
Unlink | ||
</button> | ||
{error && <p>{error.message}</p>} | ||
</> | ||
); | ||
} | ||
|
||
function UseOwnedProfiles({ address }: { address: EvmAddress }) { | ||
const { | ||
data: profiles, | ||
loading, | ||
error, | ||
} = useProfiles({ | ||
where: { | ||
ownedBy: [address], | ||
}, | ||
}); | ||
|
||
if (loading) return <Loading />; | ||
|
||
if (error) return <ErrorMessage error={error} />; | ||
|
||
return ( | ||
<div> | ||
<h4>Owned profiles</h4> | ||
<ul> | ||
{profiles.map((p, index) => ( | ||
<li key={index}> | ||
{p.id} {p.handle || 'NOT LINKED'} | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
} | ||
|
||
// eslint-disable-next-line | ||
function UseOwnedHandlesInner({ address }: { address: EvmAddress }) { | ||
const { | ||
data: handleResult, | ||
loading, | ||
error, | ||
} = useOwnedHandles({ | ||
for: address, | ||
}); | ||
|
||
if (loading) return <Loading />; | ||
|
||
if (error) return <ErrorMessage error={error} />; | ||
|
||
return ( | ||
<div> | ||
<h4>Owned handles</h4> | ||
<ul> | ||
{handleResult.map((handle, index) => ( | ||
<li key={index}> | ||
<div>{handle.handle}</div> | ||
<LinkHandleButton handle={handle.handle} />{' '} | ||
<UnlinkHandleButton handle={handle.handle} /> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
} | ||
|
||
type ContentProps = { | ||
address: EvmAddress; | ||
profile: Profile; | ||
}; | ||
|
||
function Content({ address, profile }: ContentProps) { | ||
return ( | ||
<div> | ||
<p>Wallet address: {address}.</p> | ||
<p> | ||
Active profile: {profile.id}. Current handle {profile.handle || 'NOT LINKED'} | ||
</p> | ||
<div style={{ display: 'flex' }}> | ||
<UseOwnedProfiles address={address} /> | ||
{/* <UseOwnedHandlesInner address={address} /> */} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export function UseOwnedHandles() { | ||
return ( | ||
<div> | ||
<h1> | ||
{/* <code>useOwnedHandles & useLinkHandle & useUnlinkHandle</code> */} | ||
<code>useOwnedHandles</code> | ||
</h1> | ||
|
||
<WhenLoggedIn> | ||
{({ address, profile }) => <Content address={address} profile={profile} />} | ||
</WhenLoggedIn> | ||
|
||
<WhenLoggedOut> | ||
<UnauthenticatedFallback /> | ||
</WhenLoggedOut> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.