From aaca78c81c7832688b5379f8c74b559b98a3f630 Mon Sep 17 00:00:00 2001 From: Kris Urbas <605420+krzysu@users.noreply.github.com> Date: Wed, 20 Sep 2023 14:28:58 +0200 Subject: [PATCH] ref docs for transaction module + relayQueues query --- .../followProfileUsingLensProfileManager.ts | 2 +- .../follow/followProfileViaTypedData.ts | 2 +- ...rofileFollowModuleViaLensProfileManager.ts | 2 +- .../setProfileFollowModuleViaTypedData.ts | 2 +- .../unfollowProfileUsingLensProfileManager.ts | 2 +- .../follow/unfollowProfileViaTypedData.ts | 2 +- examples/node/scripts/misc/relayQueues.ts | 13 ++ .../blockProfileViaLensProfileManager.ts | 2 +- .../profile/blockProfileViaTypedData.ts | 2 +- examples/node/scripts/profile/claimProfile.ts | 2 +- .../node/scripts/profile/createProfile.ts | 2 +- .../linkHandleToProfileViaTypedData.ts | 2 +- .../setProfileMetadataViaLensManager.ts | 2 +- .../profile/setProfileMetadataViaTypedData.ts | 2 +- .../unblockProfileViaLensProfileManager.ts | 2 +- .../profile/unblockProfileViaTypedData.ts | 2 +- .../unlinkHandleToProfileViaTypedData.ts | 2 +- .../node/scripts/publication/actions/actOn.ts | 2 +- .../actions/createActOnTypedData.ts | 2 +- .../scripts/publication/commentOnChain.ts | 2 +- .../createLegacyCollectTypedData.ts | 2 +- .../publication/createOnChainPostTypedData.ts | 2 +- .../createOnchainCommentTypedData.ts | 2 +- .../createOnchainMirrorTypedData.ts | 2 +- .../createOnchainQuoteTypedData.ts | 2 +- .../node/scripts/publication/legacyCollect.ts | 2 +- .../node/scripts/publication/mirrorOnChain.ts | 2 +- .../node/scripts/publication/postOnChain.ts | 2 +- .../node/scripts/publication/quoteOnChain.ts | 2 +- packages/client/src/index.ts | 2 + .../modules/graphql/modules.generated.ts | 14 +++ .../submodules/nfts/graphql/nfts.generated.ts | 14 +++ .../actions/graphql/actions.generated.ts | 4 - .../src/submodules/transaction/Transaction.ts | 117 +++++++++++++++--- .../graphql/transaction.generated.ts | 55 +++++++- .../transaction/graphql/transaction.graphql | 14 +++ 36 files changed, 240 insertions(+), 49 deletions(-) create mode 100644 examples/node/scripts/misc/relayQueues.ts diff --git a/examples/node/scripts/follow/followProfileUsingLensProfileManager.ts b/examples/node/scripts/follow/followProfileUsingLensProfileManager.ts index d66148284f..2f69d201cc 100644 --- a/examples/node/scripts/follow/followProfileUsingLensProfileManager.ts +++ b/examples/node/scripts/follow/followProfileUsingLensProfileManager.ts @@ -37,7 +37,7 @@ async function main() { throw new Error(`Something went wrong`); } - await lensClient.transaction.waitUntilComplete({ txId: followResultValue.txId }); + await lensClient.transaction.waitUntilComplete({ forTxId: followResultValue.txId }); } main(); diff --git a/examples/node/scripts/follow/followProfileViaTypedData.ts b/examples/node/scripts/follow/followProfileViaTypedData.ts index d613eb41ab..c74e50b987 100644 --- a/examples/node/scripts/follow/followProfileViaTypedData.ts +++ b/examples/node/scripts/follow/followProfileViaTypedData.ts @@ -39,7 +39,7 @@ async function main() { // wait for follow to be indexed console.log(`Waiting for the transaction to be indexed...`); - await lensClient.transaction.waitUntilComplete({ txId: followBroadcastResultValue.txId }); + await lensClient.transaction.waitUntilComplete({ forTxId: followBroadcastResultValue.txId }); } main(); diff --git a/examples/node/scripts/follow/setProfileFollowModuleViaLensProfileManager.ts b/examples/node/scripts/follow/setProfileFollowModuleViaLensProfileManager.ts index 3e80d01618..2b4058117e 100644 --- a/examples/node/scripts/follow/setProfileFollowModuleViaLensProfileManager.ts +++ b/examples/node/scripts/follow/setProfileFollowModuleViaLensProfileManager.ts @@ -46,7 +46,7 @@ async function main() { throw new Error('Failed to set follow module'); } - await lensClient.transaction.waitUntilComplete({ txId: followModuleResultValue.txId }); + await lensClient.transaction.waitUntilComplete({ forTxId: followModuleResultValue.txId }); } main(); diff --git a/examples/node/scripts/follow/setProfileFollowModuleViaTypedData.ts b/examples/node/scripts/follow/setProfileFollowModuleViaTypedData.ts index eefca56167..9a1f8d5e79 100644 --- a/examples/node/scripts/follow/setProfileFollowModuleViaTypedData.ts +++ b/examples/node/scripts/follow/setProfileFollowModuleViaTypedData.ts @@ -65,7 +65,7 @@ async function main() { ); // wait for follow to be indexed - await lensClient.transaction.waitUntilComplete({ txId: followBroadcastResultValue.txId }); + await lensClient.transaction.waitUntilComplete({ forTxId: followBroadcastResultValue.txId }); } main(); diff --git a/examples/node/scripts/follow/unfollowProfileUsingLensProfileManager.ts b/examples/node/scripts/follow/unfollowProfileUsingLensProfileManager.ts index 2cafc18f7f..2e144f03ad 100644 --- a/examples/node/scripts/follow/unfollowProfileUsingLensProfileManager.ts +++ b/examples/node/scripts/follow/unfollowProfileUsingLensProfileManager.ts @@ -24,7 +24,7 @@ async function main() { throw new Error(`Something went wrong`); } - await lensClient.transaction.waitUntilComplete({ txId: unfollowResultValue.txId }); + await lensClient.transaction.waitUntilComplete({ forTxId: unfollowResultValue.txId }); } main(); diff --git a/examples/node/scripts/follow/unfollowProfileViaTypedData.ts b/examples/node/scripts/follow/unfollowProfileViaTypedData.ts index 42d45d610c..a0eccaa447 100644 --- a/examples/node/scripts/follow/unfollowProfileViaTypedData.ts +++ b/examples/node/scripts/follow/unfollowProfileViaTypedData.ts @@ -41,7 +41,7 @@ async function main() { // wait for follow to be indexed console.log(`Waiting for the transaction to be indexed...`); - await lensClient.transaction.waitUntilComplete({ txId: followBroadcastResultValue.txId }); + await lensClient.transaction.waitUntilComplete({ forTxId: followBroadcastResultValue.txId }); // check the isFollowedByMe property const justFollowedProfile = await lensClient.profile.fetch({ diff --git a/examples/node/scripts/misc/relayQueues.ts b/examples/node/scripts/misc/relayQueues.ts new file mode 100644 index 0000000000..0c0bdd99a3 --- /dev/null +++ b/examples/node/scripts/misc/relayQueues.ts @@ -0,0 +1,13 @@ +import { LensClient, development } from '@lens-protocol/client'; + +async function main() { + const client = new LensClient({ + environment: development, + }); + + const result = await client.transaction.relayQueues(); + + console.log(`Relay queues: `, result); +} + +main(); diff --git a/examples/node/scripts/profile/blockProfileViaLensProfileManager.ts b/examples/node/scripts/profile/blockProfileViaLensProfileManager.ts index 723208504e..d4477f1179 100644 --- a/examples/node/scripts/profile/blockProfileViaLensProfileManager.ts +++ b/examples/node/scripts/profile/blockProfileViaLensProfileManager.ts @@ -18,7 +18,7 @@ async function main() { return; } - await lensClient.transaction.waitUntilComplete({ txId: data.txId }); + await lensClient.transaction.waitUntilComplete({ forTxId: data.txId }); } main(); diff --git a/examples/node/scripts/profile/blockProfileViaTypedData.ts b/examples/node/scripts/profile/blockProfileViaTypedData.ts index d941fa0bde..2e882594f1 100644 --- a/examples/node/scripts/profile/blockProfileViaTypedData.ts +++ b/examples/node/scripts/profile/blockProfileViaTypedData.ts @@ -31,7 +31,7 @@ async function main() { return; } - await lensClient.transaction.waitUntilComplete({ txId: broadcastResultValue.txId }); + await lensClient.transaction.waitUntilComplete({ forTxId: broadcastResultValue.txId }); console.log(`Transaction was successfully broadcasted with txId ${broadcastResultValue.txId}`); } diff --git a/examples/node/scripts/profile/claimProfile.ts b/examples/node/scripts/profile/claimProfile.ts index a23b44fa64..9e4ffb510f 100644 --- a/examples/node/scripts/profile/claimProfile.ts +++ b/examples/node/scripts/profile/claimProfile.ts @@ -29,7 +29,7 @@ async function main() { ); console.log(`Waiting for the transaction to be indexed...`); - await lensClient.transaction.waitUntilComplete({ txId: claimResultValue.txId }); + await lensClient.transaction.waitUntilComplete({ forTxId: claimResultValue.txId }); } main(); diff --git a/examples/node/scripts/profile/createProfile.ts b/examples/node/scripts/profile/createProfile.ts index 50142b4176..d8f566e42c 100644 --- a/examples/node/scripts/profile/createProfile.ts +++ b/examples/node/scripts/profile/createProfile.ts @@ -28,7 +28,7 @@ async function main() { ); console.log(`Waiting for the transaction to be indexed...`); - await client.transaction.waitUntilComplete({ txId: profileCreateResult.txId }); + await client.transaction.waitUntilComplete({ forTxId: profileCreateResult.txId }); const allOwnedProfiles = await client.profile.fetchAll({ where: { diff --git a/examples/node/scripts/profile/linkHandleToProfileViaTypedData.ts b/examples/node/scripts/profile/linkHandleToProfileViaTypedData.ts index 2910dbf4a4..6ac68710a2 100644 --- a/examples/node/scripts/profile/linkHandleToProfileViaTypedData.ts +++ b/examples/node/scripts/profile/linkHandleToProfileViaTypedData.ts @@ -31,7 +31,7 @@ async function main() { return; } - await lensClient.transaction.waitUntilComplete({ txId: broadcastResultValue.txId }); + await lensClient.transaction.waitUntilComplete({ forTxId: broadcastResultValue.txId }); console.log(`Transaction was successfully broadcasted with txId ${broadcastResultValue.txId}`); } diff --git a/examples/node/scripts/profile/setProfileMetadataViaLensManager.ts b/examples/node/scripts/profile/setProfileMetadataViaLensManager.ts index f0bbd6570d..a66a640676 100644 --- a/examples/node/scripts/profile/setProfileMetadataViaLensManager.ts +++ b/examples/node/scripts/profile/setProfileMetadataViaLensManager.ts @@ -18,7 +18,7 @@ async function main() { return; } - await lensClient.transaction.waitUntilComplete({ txId: data.txId }); + await lensClient.transaction.waitUntilComplete({ forTxId: data.txId }); } main(); diff --git a/examples/node/scripts/profile/setProfileMetadataViaTypedData.ts b/examples/node/scripts/profile/setProfileMetadataViaTypedData.ts index ec021d0bb2..d865bb29e4 100644 --- a/examples/node/scripts/profile/setProfileMetadataViaTypedData.ts +++ b/examples/node/scripts/profile/setProfileMetadataViaTypedData.ts @@ -36,7 +36,7 @@ async function main() { } // or wait till transaction is indexed - await lensClient.transaction.waitUntilComplete({ txId: broadcastResultValue.txId }); + await lensClient.transaction.waitUntilComplete({ forTxId: broadcastResultValue.txId }); console.log(`Transaction was successfully broadcasted with txId ${broadcastResultValue.txId}`); } diff --git a/examples/node/scripts/profile/unblockProfileViaLensProfileManager.ts b/examples/node/scripts/profile/unblockProfileViaLensProfileManager.ts index eacf2f63d8..735b9143c9 100644 --- a/examples/node/scripts/profile/unblockProfileViaLensProfileManager.ts +++ b/examples/node/scripts/profile/unblockProfileViaLensProfileManager.ts @@ -18,7 +18,7 @@ async function main() { return; } - await lensClient.transaction.waitUntilComplete({ txId: data.txId }); + await lensClient.transaction.waitUntilComplete({ forTxId: data.txId }); } main(); diff --git a/examples/node/scripts/profile/unblockProfileViaTypedData.ts b/examples/node/scripts/profile/unblockProfileViaTypedData.ts index 618cc1613d..5f9b378670 100644 --- a/examples/node/scripts/profile/unblockProfileViaTypedData.ts +++ b/examples/node/scripts/profile/unblockProfileViaTypedData.ts @@ -31,7 +31,7 @@ async function main() { return; } - await lensClient.transaction.waitUntilComplete({ txId: broadcastResultValue.txId }); + await lensClient.transaction.waitUntilComplete({ forTxId: broadcastResultValue.txId }); console.log(`Transaction was successfully broadcasted with txId ${broadcastResultValue.txId}`); } diff --git a/examples/node/scripts/profile/unlinkHandleToProfileViaTypedData.ts b/examples/node/scripts/profile/unlinkHandleToProfileViaTypedData.ts index 5727e1639a..ef6b063b48 100644 --- a/examples/node/scripts/profile/unlinkHandleToProfileViaTypedData.ts +++ b/examples/node/scripts/profile/unlinkHandleToProfileViaTypedData.ts @@ -31,7 +31,7 @@ async function main() { return; } - await lensClient.transaction.waitUntilComplete({ txId: broadcastResultValue.txId }); + await lensClient.transaction.waitUntilComplete({ forTxId: broadcastResultValue.txId }); console.log(`Transaction was successfully broadcasted with txId ${broadcastResultValue.txId}`); } diff --git a/examples/node/scripts/publication/actions/actOn.ts b/examples/node/scripts/publication/actions/actOn.ts index d0ea8d1fe4..45f05ea166 100644 --- a/examples/node/scripts/publication/actions/actOn.ts +++ b/examples/node/scripts/publication/actions/actOn.ts @@ -25,7 +25,7 @@ async function main() { // wait in a loop console.log(`Waiting for the transaction to be indexed...`); - await client.transaction.waitUntilComplete({ txId: resultValue.txId }); + await client.transaction.waitUntilComplete({ forTxId: resultValue.txId }); } main(); diff --git a/examples/node/scripts/publication/actions/createActOnTypedData.ts b/examples/node/scripts/publication/actions/createActOnTypedData.ts index a6a8ed1254..514d47f240 100644 --- a/examples/node/scripts/publication/actions/createActOnTypedData.ts +++ b/examples/node/scripts/publication/actions/createActOnTypedData.ts @@ -43,7 +43,7 @@ async function main() { // wait in a loop console.log(`Waiting for the transaction to be indexed...`); - await client.transaction.waitUntilComplete({ txId: broadcastValue.txId }); + await client.transaction.waitUntilComplete({ forTxId: broadcastValue.txId }); } main(); diff --git a/examples/node/scripts/publication/commentOnChain.ts b/examples/node/scripts/publication/commentOnChain.ts index 208e41b50a..a47fb40eeb 100644 --- a/examples/node/scripts/publication/commentOnChain.ts +++ b/examples/node/scripts/publication/commentOnChain.ts @@ -23,7 +23,7 @@ async function main() { // wait in a loop console.log(`Waiting for the transaction to be indexed...`); - await client.transaction.waitUntilComplete({ txId: resultValue.txId }); + await client.transaction.waitUntilComplete({ forTxId: resultValue.txId }); } main(); diff --git a/examples/node/scripts/publication/createLegacyCollectTypedData.ts b/examples/node/scripts/publication/createLegacyCollectTypedData.ts index ad654f5302..ed9fa10ee3 100644 --- a/examples/node/scripts/publication/createLegacyCollectTypedData.ts +++ b/examples/node/scripts/publication/createLegacyCollectTypedData.ts @@ -40,7 +40,7 @@ async function main() { // wait in a loop console.log(`Waiting for the transaction to be indexed...`); - await client.transaction.waitUntilComplete({ txId: broadcastValue.txId }); + await client.transaction.waitUntilComplete({ forTxId: broadcastValue.txId }); } main(); diff --git a/examples/node/scripts/publication/createOnChainPostTypedData.ts b/examples/node/scripts/publication/createOnChainPostTypedData.ts index fe54f87305..7078fea6eb 100644 --- a/examples/node/scripts/publication/createOnChainPostTypedData.ts +++ b/examples/node/scripts/publication/createOnChainPostTypedData.ts @@ -42,7 +42,7 @@ async function main() { // wait in a loop console.log(`Waiting for the transaction to be indexed...`); - await client.transaction.waitUntilComplete({ txId: broadcastValue.txId }); + await client.transaction.waitUntilComplete({ forTxId: broadcastValue.txId }); } main(); diff --git a/examples/node/scripts/publication/createOnchainCommentTypedData.ts b/examples/node/scripts/publication/createOnchainCommentTypedData.ts index 6e6effb8ab..283b81bd6e 100644 --- a/examples/node/scripts/publication/createOnchainCommentTypedData.ts +++ b/examples/node/scripts/publication/createOnchainCommentTypedData.ts @@ -41,7 +41,7 @@ async function main() { // wait in a loop console.log(`Waiting for the transaction to be indexed...`); - await client.transaction.waitUntilComplete({ txId: broadcastValue.txId }); + await client.transaction.waitUntilComplete({ forTxId: broadcastValue.txId }); } main(); diff --git a/examples/node/scripts/publication/createOnchainMirrorTypedData.ts b/examples/node/scripts/publication/createOnchainMirrorTypedData.ts index 09dd2afbb5..6820bf362c 100644 --- a/examples/node/scripts/publication/createOnchainMirrorTypedData.ts +++ b/examples/node/scripts/publication/createOnchainMirrorTypedData.ts @@ -40,7 +40,7 @@ async function main() { // wait in a loop console.log(`Waiting for the transaction to be indexed...`); - await client.transaction.waitUntilComplete({ txId: broadcastValue.txId }); + await client.transaction.waitUntilComplete({ forTxId: broadcastValue.txId }); } main(); diff --git a/examples/node/scripts/publication/createOnchainQuoteTypedData.ts b/examples/node/scripts/publication/createOnchainQuoteTypedData.ts index b27d37b298..d28005f9fd 100644 --- a/examples/node/scripts/publication/createOnchainQuoteTypedData.ts +++ b/examples/node/scripts/publication/createOnchainQuoteTypedData.ts @@ -41,7 +41,7 @@ async function main() { // wait in a loop console.log(`Waiting for the transaction to be indexed...`); - await client.transaction.waitUntilComplete({ txId: broadcastValue.txId }); + await client.transaction.waitUntilComplete({ forTxId: broadcastValue.txId }); } main(); diff --git a/examples/node/scripts/publication/legacyCollect.ts b/examples/node/scripts/publication/legacyCollect.ts index 4620b7874f..8edd37fa36 100644 --- a/examples/node/scripts/publication/legacyCollect.ts +++ b/examples/node/scripts/publication/legacyCollect.ts @@ -22,7 +22,7 @@ async function main() { // wait in a loop console.log(`Waiting for the transaction to be indexed...`); - await client.transaction.waitUntilComplete({ txId: resultValue.txId }); + await client.transaction.waitUntilComplete({ forTxId: resultValue.txId }); } main(); diff --git a/examples/node/scripts/publication/mirrorOnChain.ts b/examples/node/scripts/publication/mirrorOnChain.ts index 203fee7b67..a0ed0d616e 100644 --- a/examples/node/scripts/publication/mirrorOnChain.ts +++ b/examples/node/scripts/publication/mirrorOnChain.ts @@ -22,7 +22,7 @@ async function main() { // wait in a loop console.log(`Waiting for the transaction to be indexed...`); - await client.transaction.waitUntilComplete({ txId: resultValue.txId }); + await client.transaction.waitUntilComplete({ forTxId: resultValue.txId }); } main(); diff --git a/examples/node/scripts/publication/postOnChain.ts b/examples/node/scripts/publication/postOnChain.ts index 0ca3839398..907a2c3a14 100644 --- a/examples/node/scripts/publication/postOnChain.ts +++ b/examples/node/scripts/publication/postOnChain.ts @@ -24,7 +24,7 @@ async function main() { // wait in a loop console.log(`Waiting for the transaction to be indexed...`); - await client.transaction.waitUntilComplete({ txId: resultValue.txId }); + await client.transaction.waitUntilComplete({ forTxId: resultValue.txId }); } main(); diff --git a/examples/node/scripts/publication/quoteOnChain.ts b/examples/node/scripts/publication/quoteOnChain.ts index 1e4c042969..68195458e1 100644 --- a/examples/node/scripts/publication/quoteOnChain.ts +++ b/examples/node/scripts/publication/quoteOnChain.ts @@ -23,7 +23,7 @@ async function main() { // wait in a loop console.log(`Waiting for the transaction to be indexed...`); - await client.transaction.waitUntilComplete({ txId: resultValue.txId }); + await client.transaction.waitUntilComplete({ forTxId: resultValue.txId }); } main(); diff --git a/packages/client/src/index.ts b/packages/client/src/index.ts index 069aa482da..e27386e7b4 100644 --- a/packages/client/src/index.ts +++ b/packages/client/src/index.ts @@ -88,6 +88,8 @@ export type { UnblockRequest, UnfollowRequest, ValidatePublicationMetadataRequest, + BroadcastRequest, + LensTransactionStatusRequest, // options TypedDataOptions, diff --git a/packages/client/src/submodules/modules/graphql/modules.generated.ts b/packages/client/src/submodules/modules/graphql/modules.generated.ts index b96eb66f25..617cf97527 100644 --- a/packages/client/src/submodules/modules/graphql/modules.generated.ts +++ b/packages/client/src/submodules/modules/graphql/modules.generated.ts @@ -7,6 +7,13 @@ import { Erc20Fragment, PaginatedResultInfoFragment, ImageFragment, + RelaySuccessFragment, + LensProfileManagerRelayErrorFragment, + Eip712TypedDataFieldFragment, + Eip712TypedDataDomainFragment, + ProfileFragment, + RelayErrorFragment, + CreateMomokaPublicationResultFragment, } from '../../../graphql/fragments.generated'; import { GraphQLClient } from 'graphql-request'; import { GraphQLClientRequestHeaders } from 'graphql-request/build/cjs/types'; @@ -18,6 +25,13 @@ import { Erc20FragmentDoc, PaginatedResultInfoFragmentDoc, ImageFragmentDoc, + RelaySuccessFragmentDoc, + LensProfileManagerRelayErrorFragmentDoc, + Eip712TypedDataFieldFragmentDoc, + Eip712TypedDataDomainFragmentDoc, + ProfileFragmentDoc, + RelayErrorFragmentDoc, + CreateMomokaPublicationResultFragmentDoc, } from '../../../graphql/fragments.generated'; export type ModuleInfoFragment = { name: string; type: string }; diff --git a/packages/client/src/submodules/nfts/graphql/nfts.generated.ts b/packages/client/src/submodules/nfts/graphql/nfts.generated.ts index 85f9432796..19f52b5d03 100644 --- a/packages/client/src/submodules/nfts/graphql/nfts.generated.ts +++ b/packages/client/src/submodules/nfts/graphql/nfts.generated.ts @@ -7,6 +7,13 @@ import { Erc20Fragment, PaginatedResultInfoFragment, ImageFragment, + RelaySuccessFragment, + LensProfileManagerRelayErrorFragment, + Eip712TypedDataFieldFragment, + Eip712TypedDataDomainFragment, + ProfileFragment, + RelayErrorFragment, + CreateMomokaPublicationResultFragment, } from '../../../graphql/fragments.generated'; import { GraphQLClient } from 'graphql-request'; import { GraphQLClientRequestHeaders } from 'graphql-request/build/cjs/types'; @@ -18,6 +25,13 @@ import { Erc20FragmentDoc, PaginatedResultInfoFragmentDoc, ImageFragmentDoc, + RelaySuccessFragmentDoc, + LensProfileManagerRelayErrorFragmentDoc, + Eip712TypedDataFieldFragmentDoc, + Eip712TypedDataDomainFragmentDoc, + ProfileFragmentDoc, + RelayErrorFragmentDoc, + CreateMomokaPublicationResultFragmentDoc, } from '../../../graphql/fragments.generated'; export type OwnerFragment = { amount: string; address: string }; diff --git a/packages/client/src/submodules/publication/submodules/actions/graphql/actions.generated.ts b/packages/client/src/submodules/publication/submodules/actions/graphql/actions.generated.ts index 778f701708..2f5638597b 100644 --- a/packages/client/src/submodules/publication/submodules/actions/graphql/actions.generated.ts +++ b/packages/client/src/submodules/publication/submodules/actions/graphql/actions.generated.ts @@ -8,8 +8,6 @@ import { Eip712TypedDataDomainFragment, ProfileFragment, PaginatedResultInfoFragment, - RelayErrorFragment, - CreateMomokaPublicationResultFragment, } from '../../../../../graphql/fragments.generated'; import { GraphQLClient } from 'graphql-request'; import { GraphQLClientRequestHeaders } from 'graphql-request/build/cjs/types'; @@ -22,8 +20,6 @@ import { Eip712TypedDataDomainFragmentDoc, ProfileFragmentDoc, PaginatedResultInfoFragmentDoc, - RelayErrorFragmentDoc, - CreateMomokaPublicationResultFragmentDoc, } from '../../../../../graphql/fragments.generated'; export type ActOnOpenActionMutationVariables = Types.Exact<{ request: Types.ActOnOpenActionLensManagerRequest; diff --git a/packages/client/src/submodules/transaction/Transaction.ts b/packages/client/src/submodules/transaction/Transaction.ts index 9d7caca563..1195cf00db 100644 --- a/packages/client/src/submodules/transaction/Transaction.ts +++ b/packages/client/src/submodules/transaction/Transaction.ts @@ -11,11 +11,16 @@ import type { } from '../../graphql/fragments.generated'; import { LensTransactionStatusType, - type BroadcastRequest, - type LensTransactionStatusRequest, + BroadcastRequest, + LensTransactionStatusRequest, } from '../../graphql/types.generated'; import { poll, requireAuthHeaders, sdkAuthHeaderWrapper } from '../../helpers'; -import { getSdk, LensTransactionResultFragment, Sdk } from './graphql/transaction.generated'; +import { + getSdk, + LensTransactionResultFragment, + RelayQueueResultFragment, + Sdk, +} from './graphql/transaction.generated'; export class TransactionPollingError extends Error { name = 'TransactionPollingError' as const; @@ -44,18 +49,53 @@ export class Transaction { this.authentication = authentication; } - async status( - request: LensTransactionStatusRequest, - ): Promise { - const result = await this.sdk.LensTransactionStatus({ request }); + /** + * Get the transaction hash for a transaction id. + * @param txId - The transaction id + * @returns The transaction hash + * + * @example + * ```ts + * const txHash = await client.transaction.txIdToTxHash(txId); + * ``` + */ + async txIdToTxHash(txId: string): Promise { + const result = await this.sdk.TxIdToTxHash({ for: txId }); return result.data.result; } - async txIdToTxHash(txId: string): Promise { - const result = await this.sdk.TxIdToTxHash({ for: txId }); + /** + * Use to see the size of relayers queue + * if there are delays in txs being submitted onchain. + * + * @returns The relay queues + * + * @example + * ```ts + * const queues = await client.transaction.relayQueues(); + * ``` + */ + async relayQueues(): Promise { + const result = await this.sdk.RelayQueues(); return result.data.result; } + /** + * Broadcast a signed typed data for a gasless transaction onchain. + * + * ⚠️ Requires authenticated LensClient. + * + * @param request - Request object for the mutation + * @returns {@link PromiseResult} with {@link RelaySuccessFragment} or {@link RelayErrorFragment} + * + * @example + * ```ts + * const result = await client.transaction.broadcastOnchain({ + * id: data.id, + * signature: signedTypedData, + * }); + * ``` + */ async broadcastOnchain( request: BroadcastRequest, ): PromiseResult< @@ -68,6 +108,22 @@ export class Transaction { }); } + /** + * Broadcast a signed typed data for a Momoka transaction. + * + * ⚠️ Requires authenticated LensClient. + * + * @param request - Request object for the mutation + * @returns {@link PromiseResult} with {@link CreateMomokaPublicationResultFragment} or {@link RelayErrorFragment} + * + * @example + * ```ts + * const result = await client.transaction.broadcastOnMomoka({ + * id: data.id, + * signature: signedTypedData, + * }); + * ``` + */ async broadcastOnMomoka( request: BroadcastRequest, ): PromiseResult< @@ -80,13 +136,44 @@ export class Transaction { }); } - async waitUntilComplete({ - txId, - }: { - txId: string; - }): Promise { + /** + * Get the status of a transaction. + * + * @param request - Request object for the query + * @returns The transaction status + * + * @example + * ```ts + * const result = await client.transaction.status({ + * forTxId: txId + * }); + * ``` + */ + async status( + request: LensTransactionStatusRequest, + ): Promise { + const result = await this.sdk.LensTransactionStatus({ request }); + return result.data.result; + } + + /** + * Poll the transaction status until it has been completed. + * + * @param txId - transaction id + * @returns {@link PromiseResult} with {@link TransactionIndexedResultFragment} or {@link TransactionErrorFragment} + * + * @example + * ```ts + * const result = await client.transaction.waitUntilComplete({ + * forTxId: txId + * }); + * ``` + */ + async waitUntilComplete( + request: LensTransactionStatusRequest, + ): Promise { return poll({ - fn: () => this.status({ forTxId: txId }), + fn: () => this.status(request), validate: (result: Awaited>) => { return result?.status === LensTransactionStatusType.Complete; }, diff --git a/packages/client/src/submodules/transaction/graphql/transaction.generated.ts b/packages/client/src/submodules/transaction/graphql/transaction.generated.ts index 2432d2632d..a203551ceb 100644 --- a/packages/client/src/submodules/transaction/graphql/transaction.generated.ts +++ b/packages/client/src/submodules/transaction/graphql/transaction.generated.ts @@ -2,12 +2,16 @@ import * as Types from '../../../graphql/types.generated'; import { + NetworkAddressFragment, + AmountFragment, + Erc20Fragment, + PaginatedResultInfoFragment, + ImageFragment, RelaySuccessFragment, LensProfileManagerRelayErrorFragment, Eip712TypedDataFieldFragment, Eip712TypedDataDomainFragment, ProfileFragment, - PaginatedResultInfoFragment, RelayErrorFragment, CreateMomokaPublicationResultFragment, } from '../../../graphql/fragments.generated'; @@ -16,12 +20,16 @@ import { GraphQLClientRequestHeaders } from 'graphql-request/build/cjs/types'; import { print } from 'graphql'; import gql from 'graphql-tag'; import { + NetworkAddressFragmentDoc, + AmountFragmentDoc, + Erc20FragmentDoc, + PaginatedResultInfoFragmentDoc, + ImageFragmentDoc, RelaySuccessFragmentDoc, LensProfileManagerRelayErrorFragmentDoc, Eip712TypedDataFieldFragmentDoc, Eip712TypedDataDomainFragmentDoc, ProfileFragmentDoc, - PaginatedResultInfoFragmentDoc, RelayErrorFragmentDoc, CreateMomokaPublicationResultFragmentDoc, } from '../../../graphql/fragments.generated'; @@ -38,6 +46,16 @@ export type TxIdToTxHashQueryVariables = Types.Exact<{ export type TxIdToTxHashQuery = { result: string | null }; +export type RelayQueueResultFragment = { + key: Types.RelayRoleKey; + queue: number; + relay: NetworkAddressFragment; +}; + +export type RelayQueuesQueryVariables = Types.Exact<{ [key: string]: never }>; + +export type RelayQueuesQuery = { result: Array }; + export type LensTransactionStatusQueryVariables = Types.Exact<{ request: Types.LensTransactionStatusRequest; }>; @@ -66,11 +84,29 @@ export const LensTransactionResultFragmentDoc = gql` extraInfo } `; +export const RelayQueueResultFragmentDoc = gql` + fragment RelayQueueResult on RelayQueueResult { + key + relay { + ...NetworkAddress + } + queue + } + ${NetworkAddressFragmentDoc} +`; export const TxIdToTxHashDocument = gql` query TxIdToTxHash($for: TxId!) { result: txIdToTxHash(for: $for) } `; +export const RelayQueuesDocument = gql` + query RelayQueues { + result: relayQueues { + ...RelayQueueResult + } + } + ${RelayQueueResultFragmentDoc} +`; export const LensTransactionStatusDocument = gql` query LensTransactionStatus($request: LensTransactionStatusRequest!) { result: lensTransactionStatus(request: $request) { @@ -116,6 +152,7 @@ export type SdkFunctionWrapper = ( const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType) => action(); const TxIdToTxHashDocumentString = print(TxIdToTxHashDocument); +const RelayQueuesDocumentString = print(RelayQueuesDocument); const LensTransactionStatusDocumentString = print(LensTransactionStatusDocument); const BroadcastOnchainDocumentString = print(BroadcastOnchainDocument); const BroadcastOnMomokaDocumentString = print(BroadcastOnMomokaDocument); @@ -140,6 +177,20 @@ export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = 'query', ); }, + RelayQueues( + variables?: RelayQueuesQueryVariables, + requestHeaders?: GraphQLClientRequestHeaders, + ): Promise<{ data: RelayQueuesQuery; extensions?: any; headers: Dom.Headers; status: number }> { + return withWrapper( + (wrappedRequestHeaders) => + client.rawRequest(RelayQueuesDocumentString, variables, { + ...requestHeaders, + ...wrappedRequestHeaders, + }), + 'RelayQueues', + 'query', + ); + }, LensTransactionStatus( variables: LensTransactionStatusQueryVariables, requestHeaders?: GraphQLClientRequestHeaders, diff --git a/packages/client/src/submodules/transaction/graphql/transaction.graphql b/packages/client/src/submodules/transaction/graphql/transaction.graphql index 38f55d1362..0972661886 100644 --- a/packages/client/src/submodules/transaction/graphql/transaction.graphql +++ b/packages/client/src/submodules/transaction/graphql/transaction.graphql @@ -9,6 +9,20 @@ query TxIdToTxHash($for: TxId!) { result: txIdToTxHash(for: $for) } +fragment RelayQueueResult on RelayQueueResult { + key + relay { + ...NetworkAddress + } + queue +} + +query RelayQueues { + result: relayQueues { + ...RelayQueueResult + } +} + query LensTransactionStatus($request: LensTransactionStatusRequest!) { result: lensTransactionStatus(request: $request) { ...LensTransactionResult