-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
115 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import type { | ||
AddAdminsRequest, | ||
AddAdminsResult, | ||
RemoveAdminsRequest, | ||
RemoveAdminsResult, | ||
} from '@lens-protocol/graphql'; | ||
import { AddAdminsMutation, RemoveAdminsMutation } from '@lens-protocol/graphql'; | ||
import type { ResultAsync } from '@lens-protocol/types'; | ||
|
||
import type { SessionClient } from '../clients'; | ||
import type { UnauthenticatedError, UnexpectedError } from '../errors'; | ||
|
||
/** | ||
* Add Admins | ||
* | ||
* ```ts | ||
* const result = await addAdmins(sessionClient{ | ||
* admins: [evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5')], | ||
* address: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'), | ||
* }); | ||
* ``` | ||
* | ||
* @param client - The session client logged as a builder. | ||
* @param request - The mutation request. | ||
* @returns Tiered transaction result. | ||
*/ | ||
export function addAdmins( | ||
client: SessionClient, | ||
request: AddAdminsRequest, | ||
): ResultAsync<AddAdminsResult, UnexpectedError | UnauthenticatedError> { | ||
return client.mutation(AddAdminsMutation, { request }); | ||
} | ||
|
||
/** | ||
* Remove admins | ||
* | ||
* ```ts | ||
* const result = await removeAdmins(sessionClient{ | ||
* admins: [evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5')], | ||
* address: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'), | ||
* }); | ||
* ``` | ||
* | ||
* @param client - The session client for the authenticated Account. | ||
* @param request - The mutation request. | ||
* @returns Tiered transaction result. | ||
*/ | ||
export function removeAdmins( | ||
client: SessionClient, | ||
request: RemoveAdminsRequest, | ||
): ResultAsync<RemoveAdminsResult, UnexpectedError | UnauthenticatedError> { | ||
return client.mutation(RemoveAdminsMutation, { request }); | ||
} |
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
export * from './account'; | ||
export * from './admins'; | ||
export * from './app'; | ||
export * from './authentication'; | ||
export * from './follow'; | ||
export * from './post'; | ||
export * from './posts'; | ||
export * from './transactions'; | ||
export * from './timeline'; | ||
export * from './transactions'; |
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,59 @@ | ||
import type { FragmentOf } from 'gql.tada'; | ||
import { | ||
SelfFundedTransactionRequest, | ||
SponsoredTransactionRequest, | ||
TransactionWillFail, | ||
} from './fragments'; | ||
import { type RequestOf, graphql } from './graphql'; | ||
|
||
const AddAdminsResult = graphql( | ||
`fragment AddAdminsResult on AddAdminsResult { | ||
...on SponsoredTransactionRequest { | ||
...SponsoredTransactionRequest | ||
} | ||
...on SelfFundedTransactionRequest { | ||
...SelfFundedTransactionRequest | ||
} | ||
...on TransactionWillFail { | ||
...TransactionWillFail | ||
} | ||
}`, | ||
[SponsoredTransactionRequest, SelfFundedTransactionRequest, TransactionWillFail], | ||
); | ||
export type AddAdminsResult = FragmentOf<typeof AddAdminsResult>; | ||
|
||
export const AddAdminsMutation = graphql( | ||
`mutation AddAdmins($request: AddAdminsRequest!) { | ||
value: addAdmins(request: $request) { | ||
...AddAdminsResult | ||
} | ||
}`, | ||
[AddAdminsResult], | ||
); | ||
export type AddAdminsRequest = RequestOf<typeof AddAdminsMutation>; | ||
|
||
const RemoveAdminsResult = graphql( | ||
`fragment RemoveAdminsResult on RemoveAdminsResult { | ||
...on SponsoredTransactionRequest { | ||
...SponsoredTransactionRequest | ||
} | ||
...on SelfFundedTransactionRequest { | ||
...SelfFundedTransactionRequest | ||
} | ||
...on TransactionWillFail { | ||
...TransactionWillFail | ||
} | ||
}`, | ||
[SponsoredTransactionRequest, SelfFundedTransactionRequest, TransactionWillFail], | ||
); | ||
export type RemoveAdminsResult = FragmentOf<typeof RemoveAdminsResult>; | ||
|
||
export const RemoveAdminsMutation = graphql( | ||
`mutation RemoveAdmins($request: RemoveAdminsRequest!) { | ||
value: removeAdmins(request: $request) { | ||
...RemoveAdminsResult | ||
} | ||
}`, | ||
[RemoveAdminsResult], | ||
); | ||
export type RemoveAdminsRequest = RequestOf<typeof RemoveAdminsMutation>; |
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