Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: sync w/ API release #1064

Merged
merged 8 commits into from
Jan 24, 2025
Merged
1 change: 1 addition & 0 deletions packages/client/src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export * from './notifications';
export * from './post';
export * from './posts';
export * from './sns';
export * from './sponsorship';
export * from './timeline';
export * from './transactions';
export * from './username';
4 changes: 2 additions & 2 deletions packages/client/src/actions/namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export function createUsernameNamespace(
*
* ```ts
* const result = await setNamespaceMetadata(sessionClient, {
* namespace: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* metadataUri: uri("lens://4f91..."),
* namespace: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* metadataUri: uri("lens://4f91..."),
* });
* ```
*
Expand Down
27 changes: 17 additions & 10 deletions packages/client/src/actions/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
PostReactionsRequest,
PostReferencesRequest,
PostRequest,
PostTag,
PostsRequest,
} from '@lens-protocol/graphql';
import {
Expand All @@ -26,14 +27,16 @@ import {
} from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';

import type { PostTagsRequest } from '@lens-protocol/graphql';
import type { PostReactionStatusRequest } from '@lens-protocol/graphql';
import type { PostReactionStatus } from '@lens-protocol/graphql';
import type { WhoReferencedPostRequest } from '@lens-protocol/graphql';
import type { Account } from '@lens-protocol/graphql';
import type { WhoActedOnPostQueryRequest } from '@lens-protocol/graphql';
import type { PostEditsRequest } from '@lens-protocol/graphql';
import type { PostEdit } from '@lens-protocol/graphql';
import type {
Account,
PostEdit,
PostEditsRequest,
PostReactionStatus,
PostReactionStatusRequest,
PostTagsRequest,
WhoActedOnPostQueryRequest,
WhoReferencedPostRequest,
} from '@lens-protocol/graphql';
import type { AnyClient, SessionClient } from '../clients';
import type { UnauthenticatedError, UnexpectedError } from '../errors';

Expand Down Expand Up @@ -166,7 +169,11 @@ export function fetchPostReferences(
*
* ```ts
* const result = await fetchPostTags(anyClient, {
* forFeeds: [evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5')],
* filter: [
* {
* feed: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* }
* ],
* });
* ```
*
Expand All @@ -177,7 +184,7 @@ export function fetchPostReferences(
export function fetchPostTags(
client: AnyClient,
request: PostTagsRequest,
): ResultAsync<Paginated<string>, UnexpectedError> {
): ResultAsync<Paginated<PostTag>, UnexpectedError> {
return client.query(PostTagsQuery, { request });
}

Expand Down
269 changes: 269 additions & 0 deletions packages/client/src/actions/sponsorship.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
import {
CreateSponsorshipMutation,
type CreateSponsorshipRequest,
type CreateSponsorshipResult,
type Paginated,
SetSponsorshipMetadataMutation,
type SetSponsorshipMetadataRequest,
type SetSponsorshipMetadataResult,
type Sponsorship,
SponsorshipLimitExclusionsQuery,
type SponsorshipLimitExclusionsRequest,
type SponsorshipLimitsExempt,
SponsorshipQuery,
type SponsorshipRequest,
type SponsorshipSigner,
SponsorshipSignerQuery,
type SponsorshipSignersRequest,
SponsorshipsQuery,
type SponsorshipsRequest,
UpdateSponsorshipExclusionListMutation,
type UpdateSponsorshipExclusionListRequest,
type UpdateSponsorshipExclusionListResult,
UpdateSponsorshipLimitsMutation,
type UpdateSponsorshipLimitsRequest,
type UpdateSponsorshipLimitsResult,
UpdateSponsorshipSignersMutation,
type UpdateSponsorshipSignersRequest,
type UpdateSponsorshipSignersResult,
} from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';
import type { AnyClient, SessionClient } from '../clients';
import type { UnauthenticatedError, UnexpectedError } from '../errors';

/**
* Fetch a Sponsorship.
*
* ```ts
* const result = await fetchSponsorship(anyClient, {
* address: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* });
* ```
*
* @param client - Any Lens client.
* @param request - The query request.
* @returns The details of Sponsorship or null if not found.
*/
export function fetchSponsorship(
client: AnyClient,
request: SponsorshipRequest,
): ResultAsync<Sponsorship | null, UnexpectedError> {
return client.query(SponsorshipQuery, { request });
}

/**
* Fetch paginated Sponsorships.
*
* ```ts
* const result = await fetchSponsorships(anyClient, {
* filter: {
* managedBy: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* }
* });
* ```
*
* @param client - Any Lens client.
* @param request - The query request.
* @returns The paginated list of Sponsorships.
*/
export function fetchSponsorships(
client: AnyClient,
request: SponsorshipsRequest,
): ResultAsync<Paginated<Sponsorship>, UnexpectedError> {
return client.query(SponsorshipsQuery, { request });
}

/**
* Fetch paginated Sponsorship Signers.
*
* ```ts
* const result = await fetchSponsorshipSigners(anyClient, {
* filter: {
* sponsorship: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* }
* });
* ```
*
* @param client - Any Lens client.
* @param request - The query request.
* @returns The paginated list of Sponsorship Signers.
*/
export function fetchSponsorshipSigners(
client: AnyClient,
request: SponsorshipSignersRequest,
): ResultAsync<Paginated<SponsorshipSigner>, UnexpectedError> {
return client.query(SponsorshipSignerQuery, { request });
}

/**
* Fetch paginated exclusion list from rate limits of a given Sponsorship.
*
* ```ts
* const result = await fetchSponsorshipLimitExclusions(anyClient, {
* filter: {
* sponsorship: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* }
* });
* ```
*
* @param client - Any Lens client.
* @param request - The query request.
* @returns The paginated list of Sponsorship Signers.
*/
export function fetchSponsorshipLimitExclusions(
client: AnyClient,
request: SponsorshipLimitExclusionsRequest,
): ResultAsync<Paginated<SponsorshipLimitsExempt>, UnexpectedError> {
return client.query(SponsorshipLimitExclusionsQuery, { request });
}

/**
* Create a Sponsorship.
*
* ```ts
* const result = await createSponsorship(sessionClient, {
* allowLensAccess: true,
* });
* ```
*
* @param client - The session client logged in as a builder.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function createSponsorship(
client: SessionClient,
request: CreateSponsorshipRequest,
): ResultAsync<CreateSponsorshipResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(CreateSponsorshipMutation, { request });
}

/**
* Set Sponsorship metadata.
*
* ```ts
* const result = await setSponsorshipMetadata(sessionClient, {
* sponsorship: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* metadataUri: uri("lens://4f91..."),
* });
* ```
*
* @param client - The session client logged in as a builder.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function setSponsorshipMetadata(
client: SessionClient,
request: SetSponsorshipMetadataRequest,
): ResultAsync<SetSponsorshipMetadataResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(SetSponsorshipMetadataMutation, { request });
}

/**
* Update Sponsorship rate limits.
*
* ```ts
* const result = await updateSponsorshipLimits(sessionClient, {
* sponsorship: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* rateLimits: {
* user: {
* window: SponsorshipRateLimitWindow.Hour,
* limit: 100,
* },
* global: {
* window: SponsorshipRateLimitWindow.Day,
* limit: 1_000_000,
* },
* }
* });
* ```
*
* Remove one limit by setting it to null or not providing it.
* ```ts
* const result = await updateSponsorshipLimits(sessionClient, {
* sponsorship: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* rateLimits: {
* user: null,
* global: {
* window: SponsorshipRateLimitWindow.Day,
* limit: 1_000_000,
* },
* },
* });
* ```
*
* Remove all rate limits by setting them to null.
* ```ts
* const result = await updateSponsorshipLimits(sessionClient, {
* sponsorship: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* rateLimits: null,
* });
* ```
*
* @param client - The session client logged in as a builder.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function updateSponsorshipLimits(
client: SessionClient,
request: UpdateSponsorshipLimitsRequest,
): ResultAsync<UpdateSponsorshipLimitsResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(UpdateSponsorshipLimitsMutation, { request });
}

/**
* Update exclusion list from rate limits for a given Sponsorship.
*
* ```ts
* const result = await updateSponsorshipExclusionList(sessionClient, {
* sponsorship: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* toAdd: [
* {
* address: evmAddress('0x1234…'),
* label: "Bob The Builder",
* },
* ],
* toRemove: [
* evmAddress('0x5678…'),
* ],
* });
* ```
*
* @param client - The session client logged in as a builder.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function updateSponsorshipExclusionList(
client: SessionClient,
request: UpdateSponsorshipExclusionListRequest,
): ResultAsync<UpdateSponsorshipExclusionListResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(UpdateSponsorshipExclusionListMutation, { request });
}

/**
* Update the list of signers for a given Sponsorship.
*
* ```ts
* const result = await updateSponsorshipSigners(sessionClient, {
* sponsorship: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* toAdd: [
* {
* address: evmAddress('0x1234…'),
* label: "Server A",
* },
* ],
* toRemove: [
* evmAddress('0x5678…'),
* ],
* });
* ```
*
* @param client - The session client logged in as a builder.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function updateSponsorshipSigners(
client: SessionClient,
request: UpdateSponsorshipSignersRequest,
): ResultAsync<UpdateSponsorshipSignersResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(UpdateSponsorshipSignersMutation, { request });
}
Loading
Loading