-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v2/profile methods and examples (#531)
- Loading branch information
1 parent
805548e
commit 92642d4
Showing
27 changed files
with
511 additions
and
16 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
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
24 changes: 24 additions & 0 deletions
24
examples/node/scripts/profile/blockProfileViaLensProfileManager.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,24 @@ | ||
import { isRelaySuccess } from '@lens-protocol/client'; | ||
|
||
import { getAuthenticatedClientFromEthersWallet } from '../shared/getAuthenticatedClient'; | ||
import { setupWallet } from '../shared/setupWallet'; | ||
|
||
async function main() { | ||
const wallet = setupWallet(); | ||
const lensClient = await getAuthenticatedClientFromEthersWallet(wallet); | ||
|
||
const result = await lensClient.profile.block({ | ||
profiles: ['PROFILE_ID_TO_BLOCK'], | ||
}); | ||
|
||
const data = result.unwrap(); | ||
|
||
if (!isRelaySuccess(data)) { | ||
console.log(`Something went wrong`, data); | ||
return; | ||
} | ||
|
||
await lensClient.transaction.waitUntilComplete({ txId: data.txId }); | ||
} | ||
|
||
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,39 @@ | ||
import { isRelaySuccess } from '@lens-protocol/client'; | ||
|
||
import { getAuthenticatedClientFromEthersWallet } from '../shared/getAuthenticatedClient'; | ||
import { setupWallet } from '../shared/setupWallet'; | ||
|
||
async function main() { | ||
const wallet = setupWallet(); | ||
const lensClient = await getAuthenticatedClientFromEthersWallet(wallet); | ||
|
||
const blockProfilesTypedData = await lensClient.profile.createBlockProfilesTypedData({ | ||
profiles: ['PROFILE_ID_TO_BLOCK'], | ||
}); | ||
|
||
const data = blockProfilesTypedData.unwrap(); | ||
|
||
const signedTypedData = await wallet._signTypedData( | ||
data.typedData.domain, | ||
data.typedData.types, | ||
data.typedData.value, | ||
); | ||
|
||
const broadcastResult = await lensClient.transaction.broadcastOnchain({ | ||
id: data.id, | ||
signature: signedTypedData, | ||
}); | ||
|
||
const broadcastResultValue = broadcastResult.unwrap(); | ||
|
||
if (!isRelaySuccess(broadcastResultValue)) { | ||
console.log(`Something went wrong`, broadcastResultValue); | ||
return; | ||
} | ||
|
||
await lensClient.transaction.waitUntilComplete({ txId: broadcastResultValue.txId }); | ||
|
||
console.log(`Transaction was successfully broadcasted with txId ${broadcastResultValue.txId}`); | ||
} | ||
|
||
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,35 @@ | ||
import { isRelaySuccess } from '@lens-protocol/client'; | ||
|
||
import { getAuthenticatedClientFromEthersWallet } from '../shared/getAuthenticatedClient'; | ||
import { setupWallet } from '../shared/setupWallet'; | ||
|
||
async function main() { | ||
const wallet = setupWallet(); | ||
const address = await wallet.getAddress(); | ||
const lensClient = await getAuthenticatedClientFromEthersWallet(wallet); | ||
|
||
const handle = Date.now().toString(); | ||
|
||
console.log(`Claiming a profile for ${address} with handle "${handle}"`); | ||
|
||
const result = await lensClient.profile.claim({ | ||
id: 'ID', | ||
freeTextHandle: 'CHOSEN_HANDLE', | ||
}); | ||
|
||
const claimResultValue = result.unwrap(); | ||
|
||
if (!isRelaySuccess(claimResultValue)) { | ||
console.log(`Something went wrong`, result); | ||
return; | ||
} | ||
|
||
console.log( | ||
`Transaction to claim profile with handle "${handle}" was successfully broadcasted with txId ${claimResultValue.txId}`, | ||
); | ||
|
||
console.log(`Waiting for the transaction to be indexed...`); | ||
await lensClient.transaction.waitUntilComplete({ txId: claimResultValue.txId }); | ||
} | ||
|
||
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
13 changes: 13 additions & 0 deletions
13
examples/node/scripts/profile/linkHandleToProfileViaLensManager.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,13 @@ | ||
import { getAuthenticatedClientFromEthersWallet } from '../shared/getAuthenticatedClient'; | ||
import { setupWallet } from '../shared/setupWallet'; | ||
|
||
async function main() { | ||
const wallet = setupWallet(); | ||
const client = await getAuthenticatedClientFromEthersWallet(wallet); | ||
|
||
await client.profile.linkHandle({ | ||
handle: 'HANDLE', | ||
}); | ||
} | ||
|
||
main(); |
39 changes: 39 additions & 0 deletions
39
examples/node/scripts/profile/linkHandleToProfileViaTypedData.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,39 @@ | ||
import { isRelaySuccess } from '@lens-protocol/client'; | ||
|
||
import { getAuthenticatedClientFromEthersWallet } from '../shared/getAuthenticatedClient'; | ||
import { setupWallet } from '../shared/setupWallet'; | ||
|
||
async function main() { | ||
const wallet = setupWallet(); | ||
const lensClient = await getAuthenticatedClientFromEthersWallet(wallet); | ||
|
||
const linkHandleToProfileTypedData = await lensClient.profile.createLinkHandleTypedData({ | ||
handle: 'HANDLE', | ||
}); | ||
|
||
const data = linkHandleToProfileTypedData.unwrap(); | ||
|
||
const signedTypedData = await wallet._signTypedData( | ||
data.typedData.domain, | ||
data.typedData.types, | ||
data.typedData.value, | ||
); | ||
|
||
const broadcastResult = await lensClient.transaction.broadcastOnchain({ | ||
id: data.id, | ||
signature: signedTypedData, | ||
}); | ||
|
||
const broadcastResultValue = broadcastResult.unwrap(); | ||
|
||
if (!isRelaySuccess(broadcastResultValue)) { | ||
console.log(`Something went wrong`, broadcastResultValue); | ||
return; | ||
} | ||
|
||
await lensClient.transaction.waitUntilComplete({ txId: broadcastResultValue.txId }); | ||
|
||
console.log(`Transaction was successfully broadcasted with txId ${broadcastResultValue.txId}`); | ||
} | ||
|
||
main(); |
24 changes: 24 additions & 0 deletions
24
examples/node/scripts/profile/unblockProfileViaLensProfileManager.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,24 @@ | ||
import { isRelaySuccess } from '@lens-protocol/client'; | ||
|
||
import { getAuthenticatedClientFromEthersWallet } from '../shared/getAuthenticatedClient'; | ||
import { setupWallet } from '../shared/setupWallet'; | ||
|
||
async function main() { | ||
const wallet = setupWallet(); | ||
const lensClient = await getAuthenticatedClientFromEthersWallet(wallet); | ||
|
||
const result = await lensClient.profile.unblock({ | ||
profiles: ['PROFILE_ID_TO_BLOCK'], | ||
}); | ||
|
||
const data = result.unwrap(); | ||
|
||
if (!isRelaySuccess(data)) { | ||
console.log(`Something went wrong`, data); | ||
return; | ||
} | ||
|
||
await lensClient.transaction.waitUntilComplete({ txId: data.txId }); | ||
} | ||
|
||
main(); |
39 changes: 39 additions & 0 deletions
39
examples/node/scripts/profile/unblockProfileViaTypedData.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,39 @@ | ||
import { isRelaySuccess } from '@lens-protocol/client'; | ||
|
||
import { getAuthenticatedClientFromEthersWallet } from '../shared/getAuthenticatedClient'; | ||
import { setupWallet } from '../shared/setupWallet'; | ||
|
||
async function main() { | ||
const wallet = setupWallet(); | ||
const lensClient = await getAuthenticatedClientFromEthersWallet(wallet); | ||
|
||
const unblockProfilesTypedData = await lensClient.profile.createUnblockProfileTypedData({ | ||
profiles: ['PROFILE_ID_TO_BLOCK'], | ||
}); | ||
|
||
const data = unblockProfilesTypedData.unwrap(); | ||
|
||
const signedTypedData = await wallet._signTypedData( | ||
data.typedData.domain, | ||
data.typedData.types, | ||
data.typedData.value, | ||
); | ||
|
||
const broadcastResult = await lensClient.transaction.broadcastOnchain({ | ||
id: data.id, | ||
signature: signedTypedData, | ||
}); | ||
|
||
const broadcastResultValue = broadcastResult.unwrap(); | ||
|
||
if (!isRelaySuccess(broadcastResultValue)) { | ||
console.log(`Something went wrong`, broadcastResultValue); | ||
return; | ||
} | ||
|
||
await lensClient.transaction.waitUntilComplete({ txId: broadcastResultValue.txId }); | ||
|
||
console.log(`Transaction was successfully broadcasted with txId ${broadcastResultValue.txId}`); | ||
} | ||
|
||
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,13 @@ | ||
import { getAuthenticatedClientFromEthersWallet } from '../shared/getAuthenticatedClient'; | ||
import { setupWallet } from '../shared/setupWallet'; | ||
|
||
async function main() { | ||
const wallet = setupWallet(); | ||
const client = await getAuthenticatedClientFromEthersWallet(wallet); | ||
|
||
await client.profile.unlinkHandle({ | ||
handle: 'HANDLE', | ||
}); | ||
} | ||
|
||
main(); |
39 changes: 39 additions & 0 deletions
39
examples/node/scripts/profile/unlinkHandleToProfileViaTypedData.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,39 @@ | ||
import { isRelaySuccess } from '@lens-protocol/client'; | ||
|
||
import { getAuthenticatedClientFromEthersWallet } from '../shared/getAuthenticatedClient'; | ||
import { setupWallet } from '../shared/setupWallet'; | ||
|
||
async function main() { | ||
const wallet = setupWallet(); | ||
const lensClient = await getAuthenticatedClientFromEthersWallet(wallet); | ||
|
||
const unlinkHandleFromProfileTypedData = await lensClient.profile.createUnlinkHandleTypedData({ | ||
handle: 'HANDLE', | ||
}); | ||
|
||
const data = unlinkHandleFromProfileTypedData.unwrap(); | ||
|
||
const signedTypedData = await wallet._signTypedData( | ||
data.typedData.domain, | ||
data.typedData.types, | ||
data.typedData.value, | ||
); | ||
|
||
const broadcastResult = await lensClient.transaction.broadcastOnchain({ | ||
id: data.id, | ||
signature: signedTypedData, | ||
}); | ||
|
||
const broadcastResultValue = broadcastResult.unwrap(); | ||
|
||
if (!isRelaySuccess(broadcastResultValue)) { | ||
console.log(`Something went wrong`, broadcastResultValue); | ||
return; | ||
} | ||
|
||
await lensClient.transaction.waitUntilComplete({ txId: broadcastResultValue.txId }); | ||
|
||
console.log(`Transaction was successfully broadcasted with txId ${broadcastResultValue.txId}`); | ||
} | ||
|
||
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
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
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
Oops, something went wrong.