Skip to content

Commit

Permalink
v2/profile methods and examples (#531)
Browse files Browse the repository at this point in the history
  • Loading branch information
reecejohnson authored Sep 18, 2023
1 parent 805548e commit 92642d4
Show file tree
Hide file tree
Showing 27 changed files with 511 additions and 16 deletions.
2 changes: 1 addition & 1 deletion examples/node/scripts/follow/followProfileViaTypedData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function main() {
}

console.log(
`Transaction to follow ${following.items[1].id} was successfuly broadcasted with txId ${followBroadcastResultValue.txId}`,
`Transaction to follow ${following.items[1].id} was successfully broadcasted with txId ${followBroadcastResultValue.txId}`,
);

// wait for follow to be indexed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function main() {
}

console.log(
`Transaction to follow ${profileToUnfollowId} was successfuly broadcasted with txId ${followBroadcastResultValue.txId}`,
`Transaction to follow ${profileToUnfollowId} was successfully broadcasted with txId ${followBroadcastResultValue.txId}`,
);

// wait for follow to be indexed
Expand Down
24 changes: 24 additions & 0 deletions examples/node/scripts/profile/blockProfileViaLensProfileManager.ts
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();
39 changes: 39 additions & 0 deletions examples/node/scripts/profile/blockProfileViaTypedData.ts
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();
35 changes: 35 additions & 0 deletions examples/node/scripts/profile/claimProfile.ts
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();
2 changes: 1 addition & 1 deletion examples/node/scripts/profile/createProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function main() {
}

console.log(
`Transaction to create a new profile with handle "${handle}" was successfuly broadcasted with txId ${profileCreateResult.txId}`,
`Transaction to create a new profile with handle "${handle}" was successfully broadcasted with txId ${profileCreateResult.txId}`,
);

console.log(`Waiting for the transaction to be indexed...`);
Expand Down
13 changes: 13 additions & 0 deletions examples/node/scripts/profile/linkHandleToProfileViaLensManager.ts
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 examples/node/scripts/profile/linkHandleToProfileViaTypedData.ts
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();
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 examples/node/scripts/profile/unblockProfileViaTypedData.ts
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();
13 changes: 13 additions & 0 deletions examples/node/scripts/profile/unlinkHandleFromProfile.ts
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 examples/node/scripts/profile/unlinkHandleToProfileViaTypedData.ts
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();
2 changes: 1 addition & 1 deletion examples/node/scripts/publication/actions/actOn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function main() {
return;
}

console.log(`Transaction was successfuly broadcasted with txId ${resultValue.txId}`);
console.log(`Transaction was successfully broadcasted with txId ${resultValue.txId}`);

// wait in a loop
console.log(`Waiting for the transaction to be indexed...`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function main() {
return;
}

console.log(`Transaction was successfuly broadcasted with txId ${broadcastValue.txId}`);
console.log(`Transaction was successfully broadcasted with txId ${broadcastValue.txId}`);

// wait in a loop
console.log(`Waiting for the transaction to be indexed...`);
Expand Down
2 changes: 1 addition & 1 deletion examples/node/scripts/publication/commentOnChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function main() {
return;
}

console.log(`Transaction was successfuly broadcasted with txId ${resultValue.txId}`);
console.log(`Transaction was successfully broadcasted with txId ${resultValue.txId}`);

// wait in a loop
console.log(`Waiting for the transaction to be indexed...`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function main() {
return;
}

console.log(`Transaction was successfuly broadcasted with txId ${broadcastValue.txId}`);
console.log(`Transaction was successfully broadcasted with txId ${broadcastValue.txId}`);

// wait in a loop
console.log(`Waiting for the transaction to be indexed...`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function main() {
return;
}

console.log(`Transaction was successfuly broadcasted with txId ${broadcastValue.txId}`);
console.log(`Transaction was successfully broadcasted with txId ${broadcastValue.txId}`);

// wait in a loop
console.log(`Waiting for the transaction to be indexed...`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function main() {
return;
}

console.log(`Transaction was successfuly broadcasted with txId ${broadcastValue.txId}`);
console.log(`Transaction was successfully broadcasted with txId ${broadcastValue.txId}`);

// wait in a loop
console.log(`Waiting for the transaction to be indexed...`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function main() {
return;
}

console.log(`Transaction was successfuly broadcasted with txId ${broadcastValue.txId}`);
console.log(`Transaction was successfully broadcasted with txId ${broadcastValue.txId}`);

// wait in a loop
console.log(`Waiting for the transaction to be indexed...`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function main() {
return;
}

console.log(`Transaction was successfuly broadcasted with txId ${broadcastValue.txId}`);
console.log(`Transaction was successfully broadcasted with txId ${broadcastValue.txId}`);

// wait in a loop
console.log(`Waiting for the transaction to be indexed...`);
Expand Down
2 changes: 1 addition & 1 deletion examples/node/scripts/publication/legacyCollect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function main() {
return;
}

console.log(`Transaction was successfuly broadcasted with txId ${resultValue.txId}`);
console.log(`Transaction was successfully broadcasted with txId ${resultValue.txId}`);

// wait in a loop
console.log(`Waiting for the transaction to be indexed...`);
Expand Down
2 changes: 1 addition & 1 deletion examples/node/scripts/publication/mirrorOnChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function main() {
return;
}

console.log(`Transaction was successfuly broadcasted with txId ${resultValue.txId}`);
console.log(`Transaction was successfully broadcasted with txId ${resultValue.txId}`);

// wait in a loop
console.log(`Waiting for the transaction to be indexed...`);
Expand Down
2 changes: 1 addition & 1 deletion examples/node/scripts/publication/postOnChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function main() {
return;
}

console.log(`Transaction was successfuly broadcasted with txId ${resultValue.txId}`);
console.log(`Transaction was successfully broadcasted with txId ${resultValue.txId}`);

// wait in a loop
console.log(`Waiting for the transaction to be indexed...`);
Expand Down
Loading

0 comments on commit 92642d4

Please sign in to comment.