Skip to content

Commit

Permalink
chore: improve eligiblity check
Browse files Browse the repository at this point in the history
  • Loading branch information
d-reader-luka committed Apr 29, 2024
1 parent fc1bd53 commit dda34de
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 31 deletions.
17 changes: 13 additions & 4 deletions lib/features/nft/presentation/providers/nft_providers.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'dart:async' show Timer;
import 'dart:async' show TimeoutException, Timer;

import 'package:d_reader_flutter/config/config.dart';
import 'package:d_reader_flutter/features/nft/domain/models/nft.dart';
Expand Down Expand Up @@ -74,9 +74,18 @@ final transactionChainStatusProvider = StateProvider.family<void, String>(
isLoading: false,
newMessage: TransactionStatusMessage.success.getString(),
);
}).onError((error, stackTrace) {
Sentry.captureException(error,
stackTrace: 'Signature status provider $signature');
}).onError((exception, stackTrace) {
if (exception is TimeoutException || exception is RpcTimeoutException) {
ref.read(globalNotifierProvider.notifier).update(
isLoading: false,
newMessage: TransactionStatusMessage.timeout.getString(),
);
return;
}
Sentry.captureException(
exception,
stackTrace: 'Signature status provider $signature',
);
ref.read(globalNotifierProvider.notifier).update(
isLoading: false,
newMessage: TransactionStatusMessage.fail.getString(),
Expand Down
4 changes: 2 additions & 2 deletions lib/features/nft/presentation/screens/nft_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class NftDetails extends ConsumerWidget {
),
Text(
'royalty',
style: textTheme.bodyMedium,
style: textTheme.bodySmall,
),
],
),
Expand Down Expand Up @@ -394,7 +394,7 @@ class NftDetails extends ConsumerWidget {
height: 16,
),
const Text(
'NFT Address',
'Token Address',
style: sectionHeadingStyle,
),
const SizedBox(
Expand Down
15 changes: 2 additions & 13 deletions lib/features/settings/presentation/widgets/referrals/body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ReferralBody extends ConsumerWidget {
height: 12,
),
Text(
user.hasBetaAccess ? 'Invite your friends' : 'Join the beta',
user.hasBetaAccess ? 'Invite your friends' : 'Claim referral',
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 32,
Expand All @@ -46,7 +46,7 @@ class ReferralBody extends ConsumerWidget {
),
if (!user.hasBetaAccess) ...[
const Text(
'Type in the username or the wallet address from your referrer to claim beta access',
'Onboarding people to the platform will make you eligible for rewards in the future',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
Expand Down Expand Up @@ -85,17 +85,6 @@ class ReferralBody extends ConsumerWidget {
const SizedBox(
height: 16,
),
const Text(
'Fully onboarding 2 people to the platform will make you eligible for a free comic mint! \'Fully\' means that the users have verified their email and connected a wallet.',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
const SizedBox(
height: 16,
),
GestureDetector(
onTap: () {
Clipboard.setData(
Expand Down
20 changes: 11 additions & 9 deletions lib/shared/domain/providers/solana/solana_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,17 @@ class SolanaNotifier extends _$SolanaNotifier {
shouldSignMessage: isConnectOnly,
);

// Invalidate candy machine to refetch eligibility
if (ref.read(selectedCandyMachineGroup) != null) {
final signerAddress = ref.read(environmentProvider).publicKey?.toBase58();
final currentCMAddress = ref.read(candyMachineStateProvider)?.address;
ref.invalidate(candyMachineProvider);
await ref.read(candyMachineProvider(
query:
'candyMachineAddress=$currentCMAddress${'&walletAddress=$signerAddress'}')
.future);
}

if (result != successResult) {
await session.close();
return Left(
Expand Down Expand Up @@ -325,15 +336,6 @@ class SolanaNotifier extends _$SolanaNotifier {
}, (message) async {
ref.invalidate(registerWalletToSocketEvents);
ref.read(registerWalletToSocketEvents);
if (ref.read(selectedCandyMachineGroup) != null) {
final currentCMAddress = ref.read(candyMachineStateProvider)?.address;
ref.invalidate(candyMachineProvider);
await ref.read(candyMachineProvider(
query:
'candyMachineAddress=$currentCMAddress${'&walletAddress=${signer.toBase58()}'}')
.future);
}

return message;
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,13 @@ class SolanaTransactionNotifier extends _$SolanaTransactionNotifier {
);
if (!hasEligibility) {
await session.close();
final isUser = ref.read(selectedCandyMachineGroup)?.user != null;
return Left(
AppException(
identifier: 'SolanaTransactionNotifier.mint',
message:
'Wallet address ${Formatter.formatAddress(walletAddress, 3)} is not eligible for minting',
message: isUser
? 'User ${ref.read(environmentProvider).user?.email} is not eligible for minting'
: 'Wallet address ${Formatter.formatAddress(walletAddress, 3)} is not eligible for minting',
statusCode: 403,
),
);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: dReader Flutter app.

publish_to: 'none'

version: 1.3.1+44 # dappStore: 1.3.1+44 (next release: 1.3.2+45) google play: 1.3.1+70 (next release: 1.3.2+71)
version: 1.3.2+71 # dappStore: 1.3.1+44 (next release: 1.3.2+45) google play: 1.3.1+70 (next release: 1.3.2+71)

environment:
sdk: '>=3.0.0 <4.0.0'
Expand Down

0 comments on commit dda34de

Please sign in to comment.