Skip to content

Commit

Permalink
feat: docs and examples for publication submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysu committed Sep 12, 2023
1 parent 063dc9c commit 3585bda
Show file tree
Hide file tree
Showing 12 changed files with 317 additions and 162 deletions.
27 changes: 0 additions & 27 deletions examples/node/scripts/fetchPublications.ts

This file was deleted.

18 changes: 16 additions & 2 deletions examples/node/scripts/publication/fetchAll.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LensClient, development } from "@lens-protocol/client";
import { LensClient, development, isPostPublication } from "@lens-protocol/client";

async function main() {
const client = new LensClient({
Expand All @@ -13,11 +13,25 @@ async function main() {
});

console.log(
`Publications from profileId ${profileId}: `,
`All publications from profileId ${profileId}: `,
result.items.map((p) => ({
id: p.id,
}))
);

const posts = result.items.filter(isPostPublication);

console.log(
`Only posts: `,
JSON.stringify(
posts.map((i) => ({
id: i.id,
metadata: i.metadata,
})),
null,
2
)
);
}

main();
18 changes: 18 additions & 0 deletions examples/node/scripts/publication/hide.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { getAuthenticatedClientFromEthersWallet } from "../shared/getAuthenticatedClient";
import { setupWallet } from "../shared/setupWallet";

async function main() {
const wallet = setupWallet();
const client = await getAuthenticatedClientFromEthersWallet(wallet);

// get user's publications
// hide one of them

const result = await client.publication.hide({
for: "0x014e-0x0a",
});

console.log(`Publication was hidden: `, result);
}

main();
26 changes: 26 additions & 0 deletions examples/node/scripts/publication/report.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {
PublicationReportingReason,
PublicationReportingSpamSubreason,
} 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 result = await client.publication.report({
for: "0x014e-0x0a",
reason: {
spamReason: {
reason: PublicationReportingReason.Spam,
subreason: PublicationReportingSpamSubreason.FakeEngagement,
},
},
additionalComments: "comment",
});

console.log(`Publication was hidden: `, result);
}

main();
6 changes: 3 additions & 3 deletions packages/client/codegen-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ config:
CreateHandle: string
Cursor: string
DateTime: string
EncryptedPath: string
EncryptedValue: string
Ens: string
EvmAddress: string
Handle: string
ImageSizeTransform: ImageSizeTransform
IpfsCid: string
Jwt: string
# TODO: should 'Scalar' be appended here?
LimitScalar: number
Locale: string
Markdown: string
Expand All @@ -33,6 +32,7 @@ config:
NftGalleryId: string
NftGalleryName: string
Nonce: string
OnchainPublicationId: string
ProfileId: string
PublicationId: string
Signature: string
Expand All @@ -42,8 +42,8 @@ config:
UnixTimestamp: string
URI: string
URL: string
UUID: string
Void: string
OnchainPublicationId: string

avoidOptionals:
field: true
Expand Down
Loading

0 comments on commit 3585bda

Please sign in to comment.