Skip to content

Commit

Permalink
Merge pull request #928 from lens-protocol/T-20246/fix-useCreateProfi…
Browse files Browse the repository at this point in the history
…le-first-run

T 20246/fix use create profile first run
  • Loading branch information
cesarenaldi committed Apr 30, 2024
2 parents 1e6b96c + ae74761 commit 9747e35
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 24 deletions.
7 changes: 7 additions & 0 deletions .changeset/old-moose-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@lens-protocol/react": patch
"@lens-protocol/react-native": patch
"@lens-protocol/react-web": patch
---

**fix:** `useCreateProfile` fails w/ `InvariantError` on first Profile created
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ export enum BroadcastingErrorReason {
export class BroadcastingError extends CausedError implements IEquatableError {
name = 'BroadcastingError' as const;

constructor(
readonly reason: BroadcastingErrorReason,
{ cause, details }: { cause?: Error; details?: string } = {},
) {
const message = `failed to broadcast transaction due to: ${reason}` + (details ? details : '');
constructor(readonly reason: BroadcastingErrorReason, { cause }: { cause?: Error } = {}) {
const message = `failed to broadcast transaction due to: ${reason}`;
super(message, { cause });
}
}
4 changes: 2 additions & 2 deletions packages/react/src/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ export function createSharedDependencies(userConfig: BaseConfig): SharedDependen
[TransactionKind.ACT_ON_PUBLICATION]: new RefreshPublicationResponder(publicationCacheManager),
[TransactionKind.APPROVE_MODULE]: new NoopResponder(),
[TransactionKind.BLOCK_PROFILE]: new BlockProfilesResponder(profileCacheManager),
[TransactionKind.CLAIM_HANDLE]: new CreateProfileResponder(apolloClient, profileCacheManager),
[TransactionKind.CLAIM_HANDLE]: new CreateProfileResponder(apolloClient),
[TransactionKind.CREATE_COMMENT]: new RefreshCurrentProfileResponder(profileCacheManager),
[TransactionKind.CREATE_POST]: new RefreshCurrentProfileResponder(profileCacheManager),
[TransactionKind.CREATE_PROFILE]: new CreateProfileResponder(apolloClient, profileCacheManager),
[TransactionKind.CREATE_PROFILE]: new CreateProfileResponder(apolloClient),
[TransactionKind.CREATE_QUOTE]: new RefreshCurrentProfileResponder(profileCacheManager),
[TransactionKind.FOLLOW_PROFILE]: new FollowProfileResponder(profileCacheManager),
[TransactionKind.LINK_HANDLE]: new LinkHandleResponder(apolloClient, profileCacheManager),
Expand Down
6 changes: 1 addition & 5 deletions packages/react/src/transactions/adapters/relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ export function handleRelayError(
switch (error.reason) {
case RelayErrorReasonType.AppNotAllowed:
case LensProfileManagerRelayErrorReasonType.AppNotAllowed:
return failure(
new BroadcastingError(BroadcastingErrorReason.APP_NOT_ALLOWED, {
details: 'See https://docs.lens.xyz/docs/gasless-and-signless#whitelisting-your-app',
}),
);
return failure(new BroadcastingError(BroadcastingErrorReason.APP_NOT_ALLOWED));

case RelayErrorReasonType.RateLimited:
case LensProfileManagerRelayErrorReasonType.RateLimited:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,12 @@ import {
import { AnyTransactionRequestModel } from '@lens-protocol/domain/entities';
import { ITransactionResponder } from '@lens-protocol/domain/use-cases/transactions';

import { IProfileCacheManager } from '../../../profile/adapters/IProfileCacheManager';

export class CreateProfileResponder implements ITransactionResponder<AnyTransactionRequestModel> {
constructor(
private readonly apolloClient: SafeApolloClient,
private readonly profileCacheManager: IProfileCacheManager,
) {}
constructor(private readonly apolloClient: SafeApolloClient) {}

async commit() {
await Promise.all([
this.profileCacheManager.refreshCurrentProfile(),
this.apolloClient.refetchQueries({
include: [OwnedHandlesDocument, ProfilesManagedDocument],
}),
]);
await this.apolloClient.refetchQueries({
include: [OwnedHandlesDocument, ProfilesManagedDocument],
});
}
}

0 comments on commit 9747e35

Please sign in to comment.