Skip to content

Commit

Permalink
feat: block & link
Browse files Browse the repository at this point in the history
  • Loading branch information
reecejohnson authored and krzysu committed Sep 18, 2023
1 parent 4117a7d commit 950403b
Show file tree
Hide file tree
Showing 12 changed files with 431 additions and 105 deletions.
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();
30 changes: 28 additions & 2 deletions examples/node/scripts/profile/linkHandleToProfileViaTypedData.ts
Original file line number Diff line number Diff line change
@@ -1,13 +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 client = await getAuthenticatedClientFromEthersWallet(wallet);
const lensClient = await getAuthenticatedClientFromEthersWallet(wallet);

await client.profile.linkHandle({
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();
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();
21 changes: 3 additions & 18 deletions packages/client/src/graphql/fragments.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ export type MirrorFragment = {
createdAt: string;
publishedOn: AppFragment | null;
momoka: MomokaInfoFragment | null;
mirrorOn: CommentFragment | PostFragment | QuoteFragment;
mirrorOf: CommentFragment | PostFragment | QuoteFragment;
};

export type QuoteBaseFragment = {
Expand Down Expand Up @@ -911,9 +911,7 @@ export type QuoteBaseFragment = {
| null;
};

export type QuoteFragment = {
quoteOn: CommentBaseFragment | PostFragment | QuoteBaseFragment;
} & QuoteBaseFragment;
export type QuoteFragment = QuoteBaseFragment;

export type Eip712TypedDataDomainFragment = {
name: string;
Expand Down Expand Up @@ -2960,21 +2958,8 @@ export const CommentFragmentDoc = gql`
export const QuoteFragmentDoc = gql`
fragment Quote on Quote {
...QuoteBase
quoteOn {
... on Post {
...Post
}
... on Comment {
...CommentBase
}
... on Quote {
...QuoteBase
}
}
}
${QuoteBaseFragmentDoc}
${PostFragmentDoc}
${CommentBaseFragmentDoc}
`;
export const MirrorFragmentDoc = gql`
fragment Mirror on Mirror {
Expand All @@ -2989,7 +2974,7 @@ export const MirrorFragmentDoc = gql`
}
txHash
createdAt
mirrorOn {
mirrorOf {
... on Post {
...Post
}
Expand Down
29 changes: 17 additions & 12 deletions packages/client/src/graphql/types.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ export type MomokaCommentRequest = {
};

export type MomokaMirrorRequest = {
mirrorOn: Scalars['PublicationId']['input'];
mirrorOf: Scalars['PublicationId']['input'];
};

export type MomokaPostRequest = {
Expand Down Expand Up @@ -839,8 +839,6 @@ export type OnchainCommentRequest = {
};

export type OnchainMirrorRequest = {
/** You can add information like app on a mirror or tracking stuff */
metadataURI?: InputMaybe<Scalars['URI']['input']>;
mirrorOn: Scalars['PublicationId']['input'];
mirrorReferenceModuleData?: InputMaybe<Scalars['BlockchainData']['input']>;
referrers?: InputMaybe<Array<OnchainReferrer>>;
Expand Down Expand Up @@ -1155,7 +1153,7 @@ export type PublicationBookmarksWhere = {
metadata?: InputMaybe<PublicationMetadataFilters>;
};

export type PublicationCommentOn = {
export type PublicationCommentOf = {
commentsRankingFilter?: InputMaybe<CommentRankingFilterType>;
id: Scalars['PublicationId']['input'];
};
Expand All @@ -1166,8 +1164,14 @@ export enum PublicationContentWarningType {
Spoiler = 'SPOILER',
}

export type PublicationForYouRequest = {
cursor?: InputMaybe<Scalars['Cursor']['input']>;
for?: InputMaybe<Scalars['ProfileId']['input']>;
limit?: InputMaybe<LimitType>;
};

export type PublicationMetadataContentWarningFilter = {
oneOf: Array<PublicationContentWarningType>;
oneOf?: InputMaybe<Array<PublicationContentWarningType>>;
};

export type PublicationMetadataFilters = {
Expand Down Expand Up @@ -1318,7 +1322,8 @@ export type PublicationSearchRequest = {

export type PublicationSearchWhere = {
customFilters?: InputMaybe<Array<CustomFiltersType>>;
metadata?: InputMaybe<PublicationMetadataFilters>;
publicationTypes?: InputMaybe<Array<PublicationType>>;
publishedOn?: InputMaybe<Array<Scalars['AppId']['input']>>;
};

export type PublicationStatsCountOpenActionArgs = {
Expand All @@ -1327,7 +1332,7 @@ export type PublicationStatsCountOpenActionArgs = {

export type PublicationStatsInput = {
customFilters?: InputMaybe<Array<CustomFiltersType>>;
metadata?: InputMaybe<PublicationMetadataFilters>;
forApps?: InputMaybe<Array<Scalars['AppId']['input']>>;
};

export type PublicationStatsReactionArgs = {
Expand Down Expand Up @@ -1358,7 +1363,7 @@ export type PublicationsRequest = {
cursor?: InputMaybe<Scalars['Cursor']['input']>;
limit?: InputMaybe<LimitType>;
orderBy?: InputMaybe<PublicationsOrderByType>;
where?: InputMaybe<PublicationsWhere>;
where: PublicationsWhere;
};

export type PublicationsTagsRequest = {
Expand All @@ -1373,15 +1378,15 @@ export type PublicationsTagsWhere = {
};

export type PublicationsWhere = {
actedBy?: InputMaybe<Scalars['ProfileId']['input']>;
commentOn?: InputMaybe<PublicationCommentOn>;
acted?: InputMaybe<Array<OpenActionFilter>>;
commentsOf?: InputMaybe<PublicationCommentOf>;
customFilters?: InputMaybe<Array<CustomFiltersType>>;
from?: InputMaybe<Array<Scalars['ProfileId']['input']>>;
metadata?: InputMaybe<PublicationMetadataFilters>;
mirrorOn?: InputMaybe<Scalars['PublicationId']['input']>;
mirrorOf?: InputMaybe<Scalars['PublicationId']['input']>;
publicationIds?: InputMaybe<Array<Scalars['PublicationId']['input']>>;
publicationTypes?: InputMaybe<Array<PublicationType>>;
quoteOn?: InputMaybe<Scalars['PublicationId']['input']>;
quoteOf?: InputMaybe<Scalars['PublicationId']['input']>;
withOpenActions?: InputMaybe<Array<OpenActionFilter>>;
};

Expand Down
Loading

0 comments on commit 950403b

Please sign in to comment.