From 827455114684b9f54861fb602b130bb881082d36 Mon Sep 17 00:00:00 2001 From: phuoc Date: Tue, 24 Oct 2023 13:52:47 +0700 Subject: [PATCH 01/27] merchandise support Signed-off-by: phuoc --- .../postcard_detail_page.dart | 41 +++++++++++++-- lib/screen/irl_screen/webview_irl_screen.dart | 51 +++++++++++++++++++ lib/service/configuration_service.dart | 35 +++++++++++++ lib/util/constants.dart | 20 ++++++-- 4 files changed, 139 insertions(+), 8 deletions(-) diff --git a/lib/screen/interactive_postcard/postcard_detail_page.dart b/lib/screen/interactive_postcard/postcard_detail_page.dart index 8e2612877..e3da5a48c 100644 --- a/lib/screen/interactive_postcard/postcard_detail_page.dart +++ b/lib/screen/interactive_postcard/postcard_detail_page.dart @@ -30,7 +30,9 @@ import 'package:autonomy_flutter/screen/interactive_postcard/postcard_view_widge import 'package:autonomy_flutter/screen/interactive_postcard/travel_info/postcard_travel_info.dart'; import 'package:autonomy_flutter/screen/interactive_postcard/travel_info/travel_info_bloc.dart'; import 'package:autonomy_flutter/screen/interactive_postcard/travel_info/travel_info_state.dart'; +import 'package:autonomy_flutter/screen/irl_screen/webview_irl_screen.dart'; import 'package:autonomy_flutter/screen/settings/help_us/inapp_webview.dart'; +import 'package:autonomy_flutter/service/auth_service.dart'; import 'package:autonomy_flutter/service/chat_service.dart'; import 'package:autonomy_flutter/service/configuration_service.dart'; import 'package:autonomy_flutter/service/metric_client_service.dart'; @@ -540,9 +542,7 @@ class ClaimedPostcardDetailPageState extends State ), if (!isViewOnly) ...[ _postcardAction(context, state), - const SizedBox( - height: 20, - ), + const SizedBox(height: 20), ], _postcardInfo(context, state), const SizedBox( @@ -597,8 +597,10 @@ class ClaimedPostcardDetailPageState extends State Widget _postcardAction(BuildContext context, PostcardDetailState state) { final asset = state.assetToken!; final theme = Theme.of(context); - if (asset.isCompleted || - !state.isLastOwner || + if (asset.isCompleted && !isViewOnly) { + return _postcardPhysical(context, state); + } + if (!state.isLastOwner || !state.postcardValueLoaded || isViewOnly != false) { return const SizedBox(); @@ -670,6 +672,35 @@ class ClaimedPostcardDetailPageState extends State } } + Widget _postcardPhysical(BuildContext context, PostcardDetailState state) { + return Column( + children: [ + PostcardButton( + text: "unlock_physical_objects".tr(), + color: POSTCARD_PINK_BUTTON_COLOR, + onTap: () async { + final indexId = state.assetToken!.id; + final jwtToken = + (await injector().getAuthToken()).jwtToken; + final hasCustomerSupport = + _configurationService.hasMerchandiseSupport(indexId); + log.info("?indexId=$indexId&hasCS=$hasCustomerSupport"); + if (!context.mounted) return; + final url = + "$AUTONOMY_MERCHANDISE_BASE_URL/?indexId=$indexId&hasCS=${hasCustomerSupport.toString()}&token=$jwtToken"; + Navigator.of(context).pushNamed(AppRouter.irlWebView, + arguments: IRLWebScreenPayload(url, isPlainUI: true)); + }, + ), + const SizedBox(height: 15), + Text( + "unlock_physical_objects_desc".tr(), + style: Theme.of(context).textTheme.moMASans400Black12, + ), + ], + ); + } + Future _sharePostcard( BuildContext context, AssetToken asset) async { try { diff --git a/lib/screen/irl_screen/webview_irl_screen.dart b/lib/screen/irl_screen/webview_irl_screen.dart index 8ef84c881..902d27a55 100644 --- a/lib/screen/irl_screen/webview_irl_screen.dart +++ b/lib/screen/irl_screen/webview_irl_screen.dart @@ -1,5 +1,8 @@ +import 'dart:convert'; + import 'package:autonomy_flutter/common/injector.dart'; import 'package:autonomy_flutter/database/cloud_database.dart'; +import 'package:autonomy_flutter/database/entity/draft_customer_support.dart'; import 'package:autonomy_flutter/model/connection_request_args.dart'; import 'package:autonomy_flutter/model/wc2_request.dart'; import 'package:autonomy_flutter/model/wc_ethereum_transaction.dart'; @@ -9,6 +12,8 @@ import 'package:autonomy_flutter/screen/settings/help_us/inapp_webview.dart'; import 'package:autonomy_flutter/screen/tezos_beacon/tb_send_transaction_page.dart'; import 'package:autonomy_flutter/screen/wallet_connect/send/wc_send_transaction_page.dart'; import 'package:autonomy_flutter/service/account_service.dart'; +import 'package:autonomy_flutter/service/configuration_service.dart'; +import 'package:autonomy_flutter/service/customer_support_service.dart'; import 'package:autonomy_flutter/service/metric_client_service.dart'; import 'package:autonomy_flutter/service/navigation_service.dart'; import 'package:autonomy_flutter/util/constants.dart'; @@ -24,6 +29,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:tezart/tezart.dart'; +import 'package:uuid/uuid.dart'; class IRLWebScreen extends StatefulWidget { final IRLWebScreenPayload payload; @@ -131,6 +137,46 @@ class _IRLWebScreenState extends State { } } + Future _receiveData(List args) async { + final argument = args.firstOrNull; + log.info('[IRLWebScreen] passData: $argument'); + if (argument == null) { + return; + } + final type = argument['type']; + switch (type) { + case "customer_support": + final customerSupportService = injector(); + final messageType = CSMessageType.CreateIssue.rawValue; + final issueID = "TEMP-${const Uuid().v4()}"; + final data = argument['data'] as Map; + final title = data['title']; + final text = data['text']; + final orderId = data['orderId']; + final indexId = data['indexId']; + final draft = DraftCustomerSupport( + uuid: const Uuid().v4(), + issueID: issueID, + type: messageType, + data: json.encode(DraftCustomerSupportData(text: text, title: title)), + createdAt: DateTime.now(), + reportIssueType: ReportIssueType.MerchandiseIssue, + mutedMessages: [orderId, indexId].join("[SEPARATOR]"), + ); + + await customerSupportService.draftMessage(draft); + await injector() + .setHasMerchandiseSupport(data['indexId']); + return; + case "open_customer_support": + if (!mounted) return; + Navigator.of(context).pushNamed(AppRouter.supportListPage); + return; + default: + return; + } + } + Future _signMessage(List args) async { try { log.info('[IRLWebScreen] signMessage: $args'); @@ -317,6 +363,11 @@ class _IRLWebScreenState extends State { callback: _getAddress, ); + _controller?.addJavaScriptHandler( + handlerName: 'passData', + callback: _receiveData, + ); + _controller?.addJavaScriptHandler( handlerName: 'signMessage', callback: _signMessage, diff --git a/lib/service/configuration_service.dart b/lib/service/configuration_service.dart index 501f679db..9848c97b6 100644 --- a/lib/service/configuration_service.dart +++ b/lib/service/configuration_service.dart @@ -27,6 +27,11 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:uuid/uuid.dart'; abstract class ConfigurationService { + Future setHasMerchandiseSupport(String indexId, + {bool value = true, bool isOverride = false}); + + bool hasMerchandiseSupport(String indexId); + Future setPostcardChatConfig(PostcardChatConfig config); PostcardChatConfig getPostcardChatConfig( @@ -267,6 +272,8 @@ abstract class ConfigurationService { } class ConfigurationServiceImpl implements ConfigurationService { + static const String KEY_HAS_MERCHANDISE_SUPPORT_INDEX_ID = + "has_merchandise_support"; static const String KEY_POSTCARD_CHAT_CONFIG = "postcard_chat_config"; static const String KEY_DID_MIGRATE_ADDRESS = "did_migrate_address"; static const String KEY_HIDDEN_FEEDS = "hidden_feeds"; @@ -1197,4 +1204,32 @@ class ConfigurationServiceImpl implements ConfigurationService { .toSet() .toList()); } + + @override + bool hasMerchandiseSupport(String indexId) { + final merchandiseSupportIndexIds = + _preferences.getStringList(KEY_HAS_MERCHANDISE_SUPPORT_INDEX_ID) ?? []; + return merchandiseSupportIndexIds.contains(indexId); + } + + @override + Future setHasMerchandiseSupport(String indexId, + {bool value = true, bool isOverride = false}) async { + if (isOverride) { + await _preferences + .setStringList(KEY_HAS_MERCHANDISE_SUPPORT_INDEX_ID, [indexId]); + } else { + final merchandiseSupportIndexIds = + _preferences.getStringList(KEY_HAS_MERCHANDISE_SUPPORT_INDEX_ID) ?? + []; + if (value) { + merchandiseSupportIndexIds.add(indexId); + merchandiseSupportIndexIds.toSet().toList(); + } else { + merchandiseSupportIndexIds.remove(indexId); + } + await _preferences.setStringList( + KEY_HAS_MERCHANDISE_SUPPORT_INDEX_ID, merchandiseSupportIndexIds); + } + } } diff --git a/lib/util/constants.dart b/lib/util/constants.dart index aafa71782..a6570ae02 100644 --- a/lib/util/constants.dart +++ b/lib/util/constants.dart @@ -48,6 +48,8 @@ const DEEP_LINKS = [ const FF_ARTIST_COLLECTOR = 'https://feralfile.com/docs/artist-collector-rights'; const WEB3_PRIMER_URL = 'https://autonomy.io/catalog/primer/'; +const AUTONOMY_MERCHANDISE_BASE_URL = + "http://192.168.31.162:3000"; //'https://autonomy.io/merchandise/'; const POSTCARD_RIGHTS_DOCS = "https://raw.githubusercontent.com/bitmark-inc/autonomy-apps/main/docs/postcard_collector_rights.md"; @@ -120,6 +122,7 @@ const Duration SENT_ARTWORK_HIDE_TIME = Duration(minutes: 2); const Duration STAMPING_POSTCARD_LIMIT_TIME = Duration(minutes: 60); const Color POSTCARD_BACKGROUND_COLOR = Color.fromRGBO(242, 242, 242, 1); +const Color POSTCARD_PINK_BUTTON_COLOR = Color.fromRGBO(231, 75, 168, 1); const POSTCARD_ABOUT_THE_PROJECT = "https://www.moma.org/calendar/exhibitions/5618?preview=true"; @@ -265,9 +268,18 @@ class ReportIssueType { static const Exception = 'exception'; static const ReportNFTIssue = 'report nft issue'; static const Announcement = 'announcement'; - - static List get getList => - [Feature, Bug, Feedback, Other, Exception, ReportNFTIssue, Announcement]; + static const MerchandiseIssue = 'merchandise issue'; + + static List get getList => [ + Feature, + Bug, + Feedback, + Other, + Exception, + ReportNFTIssue, + Announcement, + MerchandiseIssue + ]; static List get getSuggestList => [Feature, Bug, Feedback, Other]; @@ -285,6 +297,8 @@ class ReportIssueType { return 'Report NFT issue'; case Announcement: return "Announcement"; + case MerchandiseIssue: + return "Merchandise issue"; default: return 'Something else?'; } From bfe1aa7913f331842c0efaf6ce914fc688391749 Mon Sep 17 00:00:00 2001 From: phuoc Date: Tue, 24 Oct 2023 14:33:13 +0700 Subject: [PATCH 02/27] use env Signed-off-by: phuoc --- .github/workflows/android-release-appcenter.yaml | 1 + .github/workflows/bmvn_build_appcenter_android.yaml | 1 + .github/workflows/bmvn_build_appcenter_ios.yaml | 1 + .github/workflows/ios-release-appstore.yaml | 1 + lib/common/environment.dart | 3 +++ lib/screen/interactive_postcard/postcard_detail_page.dart | 3 ++- lib/util/constants.dart | 2 -- 7 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/android-release-appcenter.yaml b/.github/workflows/android-release-appcenter.yaml index 7a8175007..8f6f27c96 100644 --- a/.github/workflows/android-release-appcenter.yaml +++ b/.github/workflows/android-release-appcenter.yaml @@ -76,6 +76,7 @@ jobs: echo TZKT_TESTNET_URL=${{ secrets.TZKT_TESTNET_URL }} >> .env echo TZKT_MAINNET_URL=${{ secrets.TZKT_MAINNET_URL }} >> .env ${{ github.event.inputs.testnet == 'true' }} && echo POSTCARD_CONTRACT_ADDRESS=${{ secrets.POSTCARD_CONTRACT_ADDRESS_TESTNET }} >> .env || echo POSTCARD_CONTRACT_ADDRESS=${{ secrets.POSTCARD_CONTRACT_ADDRESS_MAINNET }} >> .env + ${{ github.event.inputs.testnet == 'true' }} && echo AUTONOMY_MERCHANDISE_BASE_URL=${{ secrets.AUTONOMY_MERCHANDISE_BASE_URL_TESTNET }} >> .env || echo AUTONOMY_MERCHANDISE_BASE_URL=${{ secrets.AUTONOMY_MERCHANDISE_BASE_URL_MAINNET }} >> .env echo FERAL_FILE_AUTHORIZATION_PREFIX=${{ secrets.FERAL_FILE_AUTHORIZATION_PREFIX }} >> .env echo SENTRY_DSN=${{ secrets.SENTRY_DSN }} >> .env diff --git a/.github/workflows/bmvn_build_appcenter_android.yaml b/.github/workflows/bmvn_build_appcenter_android.yaml index ccde4ab5c..336523ffe 100644 --- a/.github/workflows/bmvn_build_appcenter_android.yaml +++ b/.github/workflows/bmvn_build_appcenter_android.yaml @@ -95,6 +95,7 @@ jobs: echo TZKT_TESTNET_URL=${{ secrets.TZKT_TESTNET_URL }} >> .env echo TZKT_MAINNET_URL=${{ secrets.TZKT_MAINNET_URL }} >> .env ${{ inputs.testnet == true }} && echo POSTCARD_CONTRACT_ADDRESS=${{ secrets.POSTCARD_CONTRACT_ADDRESS_TESTNET }} >> .env || echo POSTCARD_CONTRACT_ADDRESS=${{ secrets.POSTCARD_CONTRACT_ADDRESS_MAINNET }} >> .env + ${{ inputs.testnet == true }} && echo AUTONOMY_MERCHANDISE_BASE_URL=${{ secrets.AUTONOMY_MERCHANDISE_BASE_URL_TESTNET }} >> .env || echo AUTONOMY_MERCHANDISE_BASE_URL=${{ secrets.AUTONOMY_MERCHANDISE_BASE_URL_MAINNET }} >> .env echo FERAL_FILE_AUTHORIZATION_PREFIX=${{ secrets.FERAL_FILE_AUTHORIZATION_PREFIX }} >> .env echo SENTRY_DSN=${{ secrets.SENTRY_DSN }} >> .env diff --git a/.github/workflows/bmvn_build_appcenter_ios.yaml b/.github/workflows/bmvn_build_appcenter_ios.yaml index e96770e1e..873cf55ed 100644 --- a/.github/workflows/bmvn_build_appcenter_ios.yaml +++ b/.github/workflows/bmvn_build_appcenter_ios.yaml @@ -102,6 +102,7 @@ jobs: echo TZKT_TESTNET_URL=${{ secrets.TZKT_TESTNET_URL }} >> .env echo TZKT_MAINNET_URL=${{ secrets.TZKT_MAINNET_URL }} >> .env ${{ inputs.testnet == true }} && echo POSTCARD_CONTRACT_ADDRESS=${{ secrets.POSTCARD_CONTRACT_ADDRESS_TESTNET }} >> .env || echo POSTCARD_CONTRACT_ADDRESS=${{ secrets.POSTCARD_CONTRACT_ADDRESS_MAINNET }} >> .env + ${{ inputs.testnet == true }} && echo AUTONOMY_MERCHANDISE_BASE_URL=${{ secrets.AUTONOMY_MERCHANDISE_BASE_URL_TESTNET }} >> .env || echo AUTONOMY_MERCHANDISE_BASE_URL=${{ secrets.AUTONOMY_MERCHANDISE_BASE_URL_MAINNET }} >> .env echo FERAL_FILE_AUTHORIZATION_PREFIX=${{ secrets.FERAL_FILE_AUTHORIZATION_PREFIX }} >> .env echo SENTRY_DSN=${{ secrets.SENTRY_DSN }} >> .env diff --git a/.github/workflows/ios-release-appstore.yaml b/.github/workflows/ios-release-appstore.yaml index 95a721cf5..27089473a 100644 --- a/.github/workflows/ios-release-appstore.yaml +++ b/.github/workflows/ios-release-appstore.yaml @@ -87,6 +87,7 @@ jobs: echo TZKT_TESTNET_URL=${{ secrets.TZKT_TESTNET_URL }} >> .env echo TZKT_MAINNET_URL=${{ secrets.TZKT_MAINNET_URL }} >> .env ${{ github.event.inputs.testnet == 'true' }} && echo POSTCARD_CONTRACT_ADDRESS=${{ secrets.POSTCARD_CONTRACT_ADDRESS_TESTNET }} >> .env || echo POSTCARD_CONTRACT_ADDRESS=${{ secrets.POSTCARD_CONTRACT_ADDRESS_MAINNET }} >> .env + ${{ github.event.inputs.testnet == 'true' }} && echo AUTONOMY_MERCHANDISE_BASE_URL=${{ secrets.AUTONOMY_MERCHANDISE_BASE_URL_TESTNET }} >> .env || echo AUTONOMY_MERCHANDISE_BASE_URL=${{ secrets.AUTONOMY_MERCHANDISE_BASE_URL_MAINNET }} >> .env echo FERAL_FILE_AUTHORIZATION_PREFIX=${{ secrets.FERAL_FILE_AUTHORIZATION_PREFIX }} >> .env echo SENTRY_DSN=${{ secrets.SENTRY_DSN }} >> .env diff --git a/lib/common/environment.dart b/lib/common/environment.dart index 11708559d..93dfa57be 100644 --- a/lib/common/environment.dart +++ b/lib/common/environment.dart @@ -157,6 +157,9 @@ class Environment { static String get postcardContractAddress => dotenv.env['POSTCARD_CONTRACT_ADDRESS'] ?? ''; + static String get merchandiseBaseUrl => + dotenv.env['AUTONOMY_MERCHANDISE_BASE_URL'] ?? ''; + static String get chatServerHmacKey => dotenv.env['CHAT_SERVER_HMAC_KEY'] ?? ''; diff --git a/lib/screen/interactive_postcard/postcard_detail_page.dart b/lib/screen/interactive_postcard/postcard_detail_page.dart index e3da5a48c..ea7035c54 100644 --- a/lib/screen/interactive_postcard/postcard_detail_page.dart +++ b/lib/screen/interactive_postcard/postcard_detail_page.dart @@ -10,6 +10,7 @@ import 'dart:collection'; import 'dart:convert'; import 'package:after_layout/after_layout.dart'; +import 'package:autonomy_flutter/common/environment.dart'; import 'package:autonomy_flutter/common/injector.dart'; import 'package:autonomy_flutter/model/pair.dart'; import 'package:autonomy_flutter/model/play_control_model.dart'; @@ -687,7 +688,7 @@ class ClaimedPostcardDetailPageState extends State log.info("?indexId=$indexId&hasCS=$hasCustomerSupport"); if (!context.mounted) return; final url = - "$AUTONOMY_MERCHANDISE_BASE_URL/?indexId=$indexId&hasCS=${hasCustomerSupport.toString()}&token=$jwtToken"; + "${Environment.merchandiseBaseUrl}?indexId=$indexId&hasCS=$hasCustomerSupport&token=$jwtToken"; Navigator.of(context).pushNamed(AppRouter.irlWebView, arguments: IRLWebScreenPayload(url, isPlainUI: true)); }, diff --git a/lib/util/constants.dart b/lib/util/constants.dart index a6570ae02..7d1016e57 100644 --- a/lib/util/constants.dart +++ b/lib/util/constants.dart @@ -48,8 +48,6 @@ const DEEP_LINKS = [ const FF_ARTIST_COLLECTOR = 'https://feralfile.com/docs/artist-collector-rights'; const WEB3_PRIMER_URL = 'https://autonomy.io/catalog/primer/'; -const AUTONOMY_MERCHANDISE_BASE_URL = - "http://192.168.31.162:3000"; //'https://autonomy.io/merchandise/'; const POSTCARD_RIGHTS_DOCS = "https://raw.githubusercontent.com/bitmark-inc/autonomy-apps/main/docs/postcard_collector_rights.md"; From 39e89e297f3513016deaf753fbc7c076d08af6d5 Mon Sep 17 00:00:00 2001 From: phuoc Date: Wed, 25 Oct 2023 14:25:05 +0700 Subject: [PATCH 03/27] close web view Signed-off-by: phuoc --- lib/screen/irl_screen/webview_irl_screen.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/screen/irl_screen/webview_irl_screen.dart b/lib/screen/irl_screen/webview_irl_screen.dart index 902d27a55..27132ffc3 100644 --- a/lib/screen/irl_screen/webview_irl_screen.dart +++ b/lib/screen/irl_screen/webview_irl_screen.dart @@ -380,7 +380,7 @@ class _IRLWebScreenState extends State { _controller?.addJavaScriptHandler( handlerName: 'closeWebview', callback: (args) async { - injector.get().popUntilHomeOrSettings(); + injector.get().goBack(); _metricClient.addEvent(MixpanelEvent.callIrlFunction, data: { 'function': IrlWebviewFunction.closeWebview, 'url': widget.payload.url, From e573e577114a450335ac84d5cf629696bc0592f3 Mon Sep 17 00:00:00 2001 From: phuoc Date: Wed, 25 Oct 2023 17:00:02 +0700 Subject: [PATCH 04/27] set localStorage Signed-off-by: phuoc --- .../interactive_postcard/postcard_detail_page.dart | 5 +++-- lib/screen/irl_screen/webview_irl_screen.dart | 13 ++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/screen/interactive_postcard/postcard_detail_page.dart b/lib/screen/interactive_postcard/postcard_detail_page.dart index ea7035c54..006f0dc5e 100644 --- a/lib/screen/interactive_postcard/postcard_detail_page.dart +++ b/lib/screen/interactive_postcard/postcard_detail_page.dart @@ -688,9 +688,10 @@ class ClaimedPostcardDetailPageState extends State log.info("?indexId=$indexId&hasCS=$hasCustomerSupport"); if (!context.mounted) return; final url = - "${Environment.merchandiseBaseUrl}?indexId=$indexId&hasCS=$hasCustomerSupport&token=$jwtToken"; + "${Environment.merchandiseBaseUrl}?indexId=$indexId&hasCS=$hasCustomerSupport"; Navigator.of(context).pushNamed(AppRouter.irlWebView, - arguments: IRLWebScreenPayload(url, isPlainUI: true)); + arguments: IRLWebScreenPayload(url, + isPlainUI: true, localStorageItems: {'token': jwtToken})); }, ), const SizedBox(height: 15), diff --git a/lib/screen/irl_screen/webview_irl_screen.dart b/lib/screen/irl_screen/webview_irl_screen.dart index 27132ffc3..a31fd7c7e 100644 --- a/lib/screen/irl_screen/webview_irl_screen.dart +++ b/lib/screen/irl_screen/webview_irl_screen.dart @@ -389,6 +389,12 @@ class _IRLWebScreenState extends State { ); } + void _addLocalStorageItems(Map items) { + items.forEach((key, value) { + _controller?.webStorage.localStorage.setItem(key: key, value: value); + }); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -414,6 +420,9 @@ class _IRLWebScreenState extends State { onWebViewCreated: (controller) { _controller = controller; _addJavaScriptHandler(); + if (widget.payload.localStorageItems != null) { + _addLocalStorageItems(widget.payload.localStorageItems!); + } }), ), ) @@ -476,6 +485,8 @@ class JSResult { class IRLWebScreenPayload { final String url; final bool isPlainUI; + final Map? localStorageItems; - IRLWebScreenPayload(this.url, {this.isPlainUI = false}); + IRLWebScreenPayload(this.url, + {this.isPlainUI = false, this.localStorageItems}); } From 4e0f8223c12a5483e9d426829d48b0a57ef98f17 Mon Sep 17 00:00:00 2001 From: phuoc Date: Thu, 26 Oct 2023 10:59:37 +0700 Subject: [PATCH 05/27] change type name Signed-off-by: phuoc --- lib/util/constants.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util/constants.dart b/lib/util/constants.dart index 7d1016e57..6a30d43e5 100644 --- a/lib/util/constants.dart +++ b/lib/util/constants.dart @@ -266,7 +266,7 @@ class ReportIssueType { static const Exception = 'exception'; static const ReportNFTIssue = 'report nft issue'; static const Announcement = 'announcement'; - static const MerchandiseIssue = 'merchandise issue'; + static const MerchandiseIssue = 'merchandise postcard'; static List get getList => [ Feature, From 120ce835cd9c31cdd941eb98919145b434e47216 Mon Sep 17 00:00:00 2001 From: phuoc Date: Thu, 26 Oct 2023 13:28:17 +0700 Subject: [PATCH 06/27] support ios, pass jwt token via param Signed-off-by: phuoc --- lib/screen/interactive_postcard/postcard_detail_page.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/screen/interactive_postcard/postcard_detail_page.dart b/lib/screen/interactive_postcard/postcard_detail_page.dart index 006f0dc5e..ea33c695d 100644 --- a/lib/screen/interactive_postcard/postcard_detail_page.dart +++ b/lib/screen/interactive_postcard/postcard_detail_page.dart @@ -688,7 +688,7 @@ class ClaimedPostcardDetailPageState extends State log.info("?indexId=$indexId&hasCS=$hasCustomerSupport"); if (!context.mounted) return; final url = - "${Environment.merchandiseBaseUrl}?indexId=$indexId&hasCS=$hasCustomerSupport"; + "${Environment.merchandiseBaseUrl}?indexId=$indexId&hasCS=$hasCustomerSupport&token=$jwtToken"; Navigator.of(context).pushNamed(AppRouter.irlWebView, arguments: IRLWebScreenPayload(url, isPlainUI: true, localStorageItems: {'token': jwtToken})); From e280de24e07e6316765cbb3f4f44b1a50b5ecf49 Mon Sep 17 00:00:00 2001 From: phuoc Date: Mon, 30 Oct 2023 16:17:55 +0700 Subject: [PATCH 07/27] fix ui text Signed-off-by: phuoc --- assets | 2 +- .../postcard_detail_page.dart | 25 +++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/assets b/assets index acd766672..bb36fb527 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit acd7666721e3bb1f3737192af91937041126510d +Subproject commit bb36fb527ba039d572c1af3698e45c7b706c0734 diff --git a/lib/screen/interactive_postcard/postcard_detail_page.dart b/lib/screen/interactive_postcard/postcard_detail_page.dart index ea33c695d..7113527d6 100644 --- a/lib/screen/interactive_postcard/postcard_detail_page.dart +++ b/lib/screen/interactive_postcard/postcard_detail_page.dart @@ -598,13 +598,18 @@ class ClaimedPostcardDetailPageState extends State Widget _postcardAction(BuildContext context, PostcardDetailState state) { final asset = state.assetToken!; final theme = Theme.of(context); - if (asset.isCompleted && !isViewOnly) { + final place15StampsText = Text( + "place_15_stamps".tr(), + style: theme.textTheme.moMASans400Black12, + ); + if (isViewOnly) { + return const SizedBox(); + } + if (asset.isCompleted) { return _postcardPhysical(context, state); } - if (!state.isLastOwner || - !state.postcardValueLoaded || - isViewOnly != false) { - return const SizedBox(); + if (!state.isLastOwner || !state.postcardValueLoaded) { + return place15StampsText; } if (!(asset.isStamping || asset.isStamped)) { final button = PostcardAsyncButton( @@ -627,6 +632,7 @@ class ClaimedPostcardDetailPageState extends State }, ); } + final sendPostcardExplain = [ const SizedBox( height: 20, @@ -638,6 +644,10 @@ class ClaimedPostcardDetailPageState extends State style: theme.textTheme.moMASans400Black12, ), ), + Padding( + padding: const EdgeInsets.only(left: 16, right: 15, top: 10), + child: place15StampsText, + ), ]; if (!isSending) { timer?.cancel(); @@ -694,11 +704,6 @@ class ClaimedPostcardDetailPageState extends State isPlainUI: true, localStorageItems: {'token': jwtToken})); }, ), - const SizedBox(height: 15), - Text( - "unlock_physical_objects_desc".tr(), - style: Theme.of(context).textTheme.moMASans400Black12, - ), ], ); } From 8974bec7b6f499416e159d31ced684a2bfd3ab25 Mon Sep 17 00:00:00 2001 From: phuoc Date: Tue, 31 Oct 2023 14:35:52 +0700 Subject: [PATCH 08/27] allow view-only Signed-off-by: phuoc --- .../interactive_postcard/postcard_detail_page.dart | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/screen/interactive_postcard/postcard_detail_page.dart b/lib/screen/interactive_postcard/postcard_detail_page.dart index 7113527d6..d67deeb15 100644 --- a/lib/screen/interactive_postcard/postcard_detail_page.dart +++ b/lib/screen/interactive_postcard/postcard_detail_page.dart @@ -541,10 +541,8 @@ class ClaimedPostcardDetailPageState extends State const SizedBox( height: 20, ), - if (!isViewOnly) ...[ - _postcardAction(context, state), - const SizedBox(height: 20), - ], + _postcardAction(context, state), + const SizedBox(height: 20), _postcardInfo(context, state), const SizedBox( height: 20, @@ -602,12 +600,12 @@ class ClaimedPostcardDetailPageState extends State "place_15_stamps".tr(), style: theme.textTheme.moMASans400Black12, ); - if (isViewOnly) { - return const SizedBox(); - } if (asset.isCompleted) { return _postcardPhysical(context, state); } + if (isViewOnly) { + return const SizedBox(); + } if (!state.isLastOwner || !state.postcardValueLoaded) { return place15StampsText; } From 0290fb3401a10fb5d961564b4d3f6bf9e2e8aa25 Mon Sep 17 00:00:00 2001 From: phuoc Date: Fri, 27 Oct 2023 13:35:52 +0700 Subject: [PATCH 09/27] pay to mint Signed-off-by: phuoc --- lib/model/postcard_claim.dart | 45 ++++++++++-- lib/screen/app_router.dart | 11 +++ .../pay_to_mint_postcard_screen.dart | 71 +++++++++++++++++++ .../hand_signature_page.dart | 14 +--- .../postcard_explain.dart | 4 +- lib/screen/irl_screen/webview_irl_screen.dart | 13 +++- lib/service/deeplink_service.dart | 43 ++++++++++- lib/service/navigation_service.dart | 15 ++++ lib/util/constants.dart | 1 + lib/view/select_address.dart | 6 +- 10 files changed, 202 insertions(+), 21 deletions(-) create mode 100644 lib/screen/interactive_postcard/claim_empty_postcard/pay_to_mint_postcard_screen.dart diff --git a/lib/model/postcard_claim.dart b/lib/model/postcard_claim.dart index 86dee0662..a241e4a24 100644 --- a/lib/model/postcard_claim.dart +++ b/lib/model/postcard_claim.dart @@ -171,10 +171,7 @@ class RequestPostcardRequest { final String id; final String? otp; - RequestPostcardRequest({ - required this.id, - this.otp - }); + RequestPostcardRequest({required this.id, this.otp}); // fromJson method factory RequestPostcardRequest.fromJson(Map json) { @@ -223,3 +220,43 @@ class RequestPostcardResponse { }; } } + +class PayToMintRequest extends RequestPostcardResponse { + final String address; + final String tokenId; + + //constructor + PayToMintRequest({ + required this.address, + required this.tokenId, + required String claimID, + required String name, + required String previewURL, + }) : super( + claimID: claimID, + name: name, + previewURL: previewURL, + ); + + @override + Map toJson() { + return { + 'claimID': claimID, + 'name': name, + 'previewURL': previewURL, + 'address': address, + 'tokenId': tokenId, + }; + } + + // fromJson method + factory PayToMintRequest.fromJson(Map json) { + return PayToMintRequest( + claimID: json['claimID'] as String, + name: json['name'] as String, + previewURL: json['previewURL'] as String, + address: json['address'] as String, + tokenId: json['tokenId'] as String, + ); + } +} diff --git a/lib/screen/app_router.dart b/lib/screen/app_router.dart index 735bf29cf..f5a10123b 100644 --- a/lib/screen/app_router.dart +++ b/lib/screen/app_router.dart @@ -67,6 +67,7 @@ import 'package:autonomy_flutter/screen/global_receive/receive_page.dart'; import 'package:autonomy_flutter/screen/home/home_bloc.dart'; import 'package:autonomy_flutter/screen/home/home_navigation_page.dart'; import 'package:autonomy_flutter/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_screen.dart'; +import 'package:autonomy_flutter/screen/interactive_postcard/claim_empty_postcard/pay_to_mint_postcard_screen.dart'; import 'package:autonomy_flutter/screen/interactive_postcard/design_stamp.dart'; import 'package:autonomy_flutter/screen/interactive_postcard/hand_signature_page.dart'; import 'package:autonomy_flutter/screen/interactive_postcard/leaderboard/postcard_leaderboard.dart'; @@ -198,6 +199,7 @@ class AppRouter { static const handSignaturePage = "hand_signature_page"; static const stampPreview = "stamp_preview"; static const claimEmptyPostCard = "claim_empty_postcard"; + static const payToMintPostcard = "pay_to_mint_postcard"; static const selectAddressScreen = "select_address_screen"; static const receivePostcardPage = 'receive_postcard_page'; static const receivePostcardSelectAccountPage = @@ -1042,6 +1044,15 @@ class AppRouter { }, ); + case payToMintPostcard: + final claimRequest = settings.arguments as PayToMintRequest; + return CupertinoPageRoute( + settings: settings, + builder: (context) { + return PayToMintPostcardScreen(claimRequest: claimRequest); + }, + ); + case selectAddressScreen: final arguments = settings.arguments as Map; final blockchain = arguments['blockchain'] as String; diff --git a/lib/screen/interactive_postcard/claim_empty_postcard/pay_to_mint_postcard_screen.dart b/lib/screen/interactive_postcard/claim_empty_postcard/pay_to_mint_postcard_screen.dart new file mode 100644 index 000000000..ac25c03a7 --- /dev/null +++ b/lib/screen/interactive_postcard/claim_empty_postcard/pay_to_mint_postcard_screen.dart @@ -0,0 +1,71 @@ +import 'package:autonomy_flutter/common/injector.dart'; +import 'package:autonomy_flutter/model/postcard_claim.dart'; +import 'package:autonomy_flutter/screen/app_router.dart'; +import 'package:autonomy_flutter/screen/interactive_postcard/design_stamp.dart'; +import 'package:autonomy_flutter/screen/interactive_postcard/postcard_explain.dart'; +import 'package:autonomy_flutter/util/asset_token_ext.dart'; +import 'package:autonomy_flutter/view/postcard_button.dart'; +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import 'claim_empty_postcard_bloc.dart'; +import 'claim_empty_postcard_state.dart'; + +class PayToMintPostcardScreen extends StatefulWidget { + final PayToMintRequest claimRequest; + + const PayToMintPostcardScreen({super.key, required this.claimRequest}); + + @override + State createState() => + _PayToMintPostcardScreenState(); +} + +class _PayToMintPostcardScreenState extends State { + final bloc = injector.get(); + + @override + void initState() { + super.initState(); + bloc.add(GetTokenEvent(widget.claimRequest)); + } + + @override + Widget build(BuildContext context) { + return BlocConsumer( + listener: (context, state) { + if (state.error != null && state.error!.isNotEmpty) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(state.error!), + ), + ); + } + }, + bloc: bloc, + builder: (context, state) { + final artwork = state.assetToken; + if (artwork == null) return Container(); + return PostcardExplain( + payload: PostcardExplainPayload( + artwork, + PostcardButton( + text: "continue".tr(), + fontSize: 18, + enabled: state.isClaiming != true, + isProcessing: state.isClaiming == true, + onTap: () { + Navigator.of(context).popAndPushNamed(AppRouter.designStamp, + arguments: DesignStampPayload(state.assetToken!.copyWith( + owner: widget.claimRequest.address, + tokenId: widget.claimRequest.tokenId))); + }, + color: const Color.fromRGBO(79, 174, 79, 1), + ), + isPayToMint: true, + ), + ); + }); + } +} diff --git a/lib/screen/interactive_postcard/hand_signature_page.dart b/lib/screen/interactive_postcard/hand_signature_page.dart index 1e54288e9..85a963d56 100644 --- a/lib/screen/interactive_postcard/hand_signature_page.dart +++ b/lib/screen/interactive_postcard/hand_signature_page.dart @@ -17,7 +17,6 @@ import 'package:autonomy_flutter/util/log.dart'; import 'package:autonomy_flutter/view/back_appbar.dart'; import 'package:autonomy_flutter/view/postcard_button.dart'; import 'package:autonomy_theme/style/colors.dart'; -import 'package:collection/collection.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -224,23 +223,14 @@ class _HandSignaturePageState extends State { fontSize: 18, onTap: () async { final counter = asset.numberOwners; - GeoLocation? geoLocation; - if (counter <= 1) { - geoLocation = moMAGeoLocation; - } else { - geoLocation = await getGeoLocationWithPermission(); - } + GeoLocation? geoLocation = await getGeoLocationWithPermission(); if (geoLocation == null) return; final metadataFilename = '$contractAddress-$tokenId-$counter-metadata.json'; - final claimLocation = - asset.postcardMetadata.locationInformation.lastOrNull ?? - moMAGeoLocation.position; - final claimAddress = await claimLocation.getAddress(); final stampAddress = await geoLocation.position.getAddress(); final Map metadata = { "address": stampAddress, // stamp address - "claimAddress": claimAddress, + "claimAddress": stampAddress, "stampedAt": DateTime.now().toIso8601String() }; final metadataFile = await _writeMetadata( diff --git a/lib/screen/interactive_postcard/postcard_explain.dart b/lib/screen/interactive_postcard/postcard_explain.dart index 20933c4a8..ef9e406fb 100644 --- a/lib/screen/interactive_postcard/postcard_explain.dart +++ b/lib/screen/interactive_postcard/postcard_explain.dart @@ -446,7 +446,9 @@ class _PostcardExplainState extends State { class PostcardExplainPayload { final AssetToken asset; final Widget startButton; + final bool isPayToMint; final List? pages; - PostcardExplainPayload(this.asset, this.startButton, {this.pages}); + PostcardExplainPayload(this.asset, this.startButton, + {this.isPayToMint = false, this.pages}); } diff --git a/lib/screen/irl_screen/webview_irl_screen.dart b/lib/screen/irl_screen/webview_irl_screen.dart index a31fd7c7e..27275df3b 100644 --- a/lib/screen/irl_screen/webview_irl_screen.dart +++ b/lib/screen/irl_screen/webview_irl_screen.dart @@ -111,9 +111,10 @@ class _IRLWebScreenState extends State { address = addresses.first.address; } else { if (!mounted) return null; + final title = arguments['title'] ?? 'select_address_to_connect'.tr(); address = await UIHelper.showDialog( context, - "select_address_to_connect".tr(), + title, SelectAddressView( addresses: addresses, ), @@ -171,6 +172,16 @@ class _IRLWebScreenState extends State { case "open_customer_support": if (!mounted) return; Navigator.of(context).pushNamed(AppRouter.supportListPage); + return; + case "pay_to_mint_success": + final data = argument['data'] as Map; + Map response = { + 'result': true, + }; + response.addAll(data); + if (!mounted) return; + Navigator.of(context).pop(response); + return; default: return; diff --git a/lib/service/deeplink_service.dart b/lib/service/deeplink_service.dart index e4c0e41f9..2518a34a7 100644 --- a/lib/service/deeplink_service.dart +++ b/lib/service/deeplink_service.dart @@ -219,6 +219,10 @@ class DeeplinkServiceImpl extends DeeplinkService { "tezos://", "autonomy-tezos://", ]; + + final postcardPayToMintPrefixes = [ + "https://autonomy.io/apps/moma-postcards/purchase", + ]; if (!_configurationService.isDoneOnboarding()) { memoryValues.deepLink.value = link; await injector().restoreIfNeeded(); @@ -272,10 +276,47 @@ class DeeplinkServiceImpl extends DeeplinkService { } return true; } + + final callingPostcardPayToMintPrefix = postcardPayToMintPrefixes + .firstWhereOrNull((prefix) => link.startsWith(prefix)); + if (callingPostcardPayToMintPrefix != null) { + _addScanQREvent( + link: link, + linkType: LinkType.postcardPayToMint, + prefix: callingPostcardPayToMintPrefix); + await _handlePayToMint(link); + return true; + } memoryValues.deepLink.value = null; return false; } + Future _handlePayToMint(String link) async { + log.info("[DeeplinkService] _handlePayToMint"); + _deepLinkHandlingMap.remove(link); + final url = "${Environment.merchandiseBaseUrl}/payToMint"; + final response = + (await _navigationService.goToIRLWebview(url)) as Map; + + if (response['result'] == true) { + final previewURL = response['previewURL']; + final title = response['title']; + final address = response['address']; + final tokenId = response['tokenId']; + + _navigationService.navigateTo( + AppRouter.payToMintPostcard, + arguments: PayToMintRequest( + claimID: "", + previewURL: previewURL, + name: title, + address: address, + tokenId: tokenId, + ) + ); + } + } + Future _handleIRL(String link) async { log.info("[DeeplinkService] _handleIRL"); memoryValues.irlLink.value = link; @@ -295,7 +336,7 @@ class DeeplinkServiceImpl extends DeeplinkService { ); if (!validUrl) return false; } - await _navigationService.navigateTo(AppRouter.irlWebView, + _navigationService.navigateTo(AppRouter.irlWebView, arguments: IRLWebScreenPayload(urlDecode)); return true; } diff --git a/lib/service/navigation_service.dart b/lib/service/navigation_service.dart index d8043139b..847578d36 100644 --- a/lib/service/navigation_service.dart +++ b/lib/service/navigation_service.dart @@ -13,6 +13,7 @@ import 'package:autonomy_flutter/model/otp.dart'; import 'package:autonomy_flutter/screen/app_router.dart'; import 'package:autonomy_flutter/screen/claim/activation/claim_activation_page.dart'; import 'package:autonomy_flutter/screen/claim/claim_token_page.dart'; +import 'package:autonomy_flutter/screen/irl_screen/webview_irl_screen.dart'; import 'package:autonomy_flutter/screen/send_receive_postcard/receive_postcard_page.dart'; import 'package:autonomy_flutter/service/airdrop_service.dart'; import 'package:autonomy_flutter/service/metric_client_service.dart'; @@ -316,6 +317,20 @@ class NavigationService { } } + Future goToIRLWebview(String url) async { + + if (navigatorKey.currentState?.mounted == true && + navigatorKey.currentContext != null) { + return await navigatorKey.currentState?.pushNamed( + AppRouter.irlWebView, + arguments: IRLWebScreenPayload(url, + isPlainUI: true) + ); + } else { + return {'result': false}; + } + } + Future showAlreadyDeliveredPostcard() async { if (navigatorKey.currentContext != null && navigatorKey.currentState?.mounted == true) { diff --git a/lib/util/constants.dart b/lib/util/constants.dart index 6a30d43e5..fa802f751 100644 --- a/lib/util/constants.dart +++ b/lib/util/constants.dart @@ -563,6 +563,7 @@ class LinkType { static const beaconConnect = 'Beacon Connect'; static const feralFileToken = 'FeralFile Token'; static const walletConnect = 'Wallet Connect'; + static const postcardPayToMint = 'Postcard Pay To Mint'; } class SocialApp { diff --git a/lib/view/select_address.dart b/lib/view/select_address.dart index 027924d88..4b761642b 100644 --- a/lib/view/select_address.dart +++ b/lib/view/select_address.dart @@ -11,8 +11,10 @@ import 'package:flutter/material.dart'; class SelectAddressView extends StatefulWidget { final List addresses; + final String? selectButton; - const SelectAddressView({Key? key, required this.addresses}) + const SelectAddressView( + {Key? key, required this.addresses, this.selectButton}) : super(key: key); @override @@ -51,7 +53,7 @@ class _SelectAddressViewState extends State { child: Column( children: [ PrimaryButton( - text: "connect".tr(), + text: widget.selectButton ?? "connect".tr(), enabled: _selectedAddress != null, onTap: () { Navigator.pop(context, _selectedAddress); From c3278fcfda45c06a178dcb172c34c9c03b27db5e Mon Sep 17 00:00:00 2001 From: phuoc Date: Mon, 30 Oct 2023 17:50:20 +0700 Subject: [PATCH 10/27] must select Signed-off-by: phuoc --- lib/screen/irl_screen/webview_irl_screen.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/screen/irl_screen/webview_irl_screen.dart b/lib/screen/irl_screen/webview_irl_screen.dart index 27275df3b..c4793a5c2 100644 --- a/lib/screen/irl_screen/webview_irl_screen.dart +++ b/lib/screen/irl_screen/webview_irl_screen.dart @@ -112,12 +112,16 @@ class _IRLWebScreenState extends State { } else { if (!mounted) return null; final title = arguments['title'] ?? 'select_address_to_connect'.tr(); + final buttonText = arguments['buttonText'] ?? 'connect'.tr(); + final mustSelect = arguments['mustSelect'] ?? false; address = await UIHelper.showDialog( context, title, SelectAddressView( addresses: addresses, + selectButton: buttonText, ), + isDismissible: !mustSelect, ); } if (address != null) { From 43f32b35cbd04659a6845c41e0b2f078d1db09b9 Mon Sep 17 00:00:00 2001 From: phuoc Date: Tue, 31 Oct 2023 10:51:43 +0700 Subject: [PATCH 11/27] select address then open irl Signed-off-by: phuoc --- lib/screen/irl_screen/webview_irl_screen.dart | 14 +++---- lib/service/deeplink_service.dart | 37 ++++++++++++------- lib/service/navigation_service.dart | 10 ++--- 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/lib/screen/irl_screen/webview_irl_screen.dart b/lib/screen/irl_screen/webview_irl_screen.dart index c4793a5c2..852adb476 100644 --- a/lib/screen/irl_screen/webview_irl_screen.dart +++ b/lib/screen/irl_screen/webview_irl_screen.dart @@ -111,17 +111,12 @@ class _IRLWebScreenState extends State { address = addresses.first.address; } else { if (!mounted) return null; - final title = arguments['title'] ?? 'select_address_to_connect'.tr(); - final buttonText = arguments['buttonText'] ?? 'connect'.tr(); - final mustSelect = arguments['mustSelect'] ?? false; address = await UIHelper.showDialog( context, - title, + 'select_address_to_connect'.tr(), SelectAddressView( addresses: addresses, - selectButton: buttonText, ), - isDismissible: !mustSelect, ); } if (address != null) { @@ -414,8 +409,8 @@ class _IRLWebScreenState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - systemOverlayStyle: const SystemUiOverlayStyle( - statusBarColor: Colors.white, + systemOverlayStyle: SystemUiOverlayStyle( + statusBarColor: widget.payload.statusBarColor ?? Colors.white, statusBarIconBrightness: Brightness.dark, statusBarBrightness: Brightness.light, ), @@ -501,7 +496,8 @@ class IRLWebScreenPayload { final String url; final bool isPlainUI; final Map? localStorageItems; + final Color? statusBarColor; IRLWebScreenPayload(this.url, - {this.isPlainUI = false, this.localStorageItems}); + {this.isPlainUI = false, this.localStorageItems, this.statusBarColor}); } diff --git a/lib/service/deeplink_service.dart b/lib/service/deeplink_service.dart index 2518a34a7..c2582d8ef 100644 --- a/lib/service/deeplink_service.dart +++ b/lib/service/deeplink_service.dart @@ -294,9 +294,22 @@ class DeeplinkServiceImpl extends DeeplinkService { Future _handlePayToMint(String link) async { log.info("[DeeplinkService] _handlePayToMint"); _deepLinkHandlingMap.remove(link); - final url = "${Environment.merchandiseBaseUrl}/payToMint"; - final response = - (await _navigationService.goToIRLWebview(url)) as Map; + final address = await _navigationService.navigateTo( + AppRouter.selectAddressScreen, + arguments: { + 'blockchain': 'Tezos', + 'onConfirm': (String address) async { + _navigationService.goBack(result: address); + }, + 'withLinked': true, + }, + ); + if (address == null) return; + final url = "${Environment.merchandiseBaseUrl}/payToMint?address=$address"; + final response = (await _navigationService.goToIRLWebview( + IRLWebScreenPayload(url, + isPlainUI: true, statusBarColor: POSTCARD_BACKGROUND_COLOR))) + as Map; if (response['result'] == true) { final previewURL = response['previewURL']; @@ -304,16 +317,14 @@ class DeeplinkServiceImpl extends DeeplinkService { final address = response['address']; final tokenId = response['tokenId']; - _navigationService.navigateTo( - AppRouter.payToMintPostcard, - arguments: PayToMintRequest( - claimID: "", - previewURL: previewURL, - name: title, - address: address, - tokenId: tokenId, - ) - ); + _navigationService.navigateTo(AppRouter.payToMintPostcard, + arguments: PayToMintRequest( + claimID: "", + previewURL: previewURL, + name: title, + address: address, + tokenId: tokenId, + )); } } diff --git a/lib/service/navigation_service.dart b/lib/service/navigation_service.dart index 847578d36..2ea949a2b 100644 --- a/lib/service/navigation_service.dart +++ b/lib/service/navigation_service.dart @@ -317,15 +317,11 @@ class NavigationService { } } - Future goToIRLWebview(String url) async { - + Future goToIRLWebview(IRLWebScreenPayload payload) async { if (navigatorKey.currentState?.mounted == true && navigatorKey.currentContext != null) { - return await navigatorKey.currentState?.pushNamed( - AppRouter.irlWebView, - arguments: IRLWebScreenPayload(url, - isPlainUI: true) - ); + return await navigatorKey.currentState + ?.pushNamed(AppRouter.irlWebView, arguments: payload); } else { return {'result': false}; } From e88b6d5e6af9ba390cb01fa87f7c5e77da62e8e2 Mon Sep 17 00:00:00 2001 From: phuoc Date: Tue, 31 Oct 2023 11:21:01 +0700 Subject: [PATCH 12/27] first claim is moma Signed-off-by: phuoc --- lib/screen/interactive_postcard/hand_signature_page.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/screen/interactive_postcard/hand_signature_page.dart b/lib/screen/interactive_postcard/hand_signature_page.dart index 85a963d56..a44dda31a 100644 --- a/lib/screen/interactive_postcard/hand_signature_page.dart +++ b/lib/screen/interactive_postcard/hand_signature_page.dart @@ -223,7 +223,12 @@ class _HandSignaturePageState extends State { fontSize: 18, onTap: () async { final counter = asset.numberOwners; - GeoLocation? geoLocation = await getGeoLocationWithPermission(); + GeoLocation? geoLocation; + if (counter <= 1) { + geoLocation = moMAGeoLocation; + } else { + geoLocation = await getGeoLocationWithPermission(); + } if (geoLocation == null) return; final metadataFilename = '$contractAddress-$tokenId-$counter-metadata.json'; From c396c60d2203831f9ea33ff78e47cd8b3b1de055 Mon Sep 17 00:00:00 2001 From: phuoc Date: Tue, 31 Oct 2023 11:26:47 +0700 Subject: [PATCH 13/27] refactor constant color Signed-off-by: phuoc --- .../claim_empty_postcard_screen.dart | 3 +- .../pay_to_mint_postcard_screen.dart | 3 +- .../receive_postcard_page.dart | 2 +- lib/util/constants.dart | 45 +++++++++++-------- 4 files changed, 32 insertions(+), 21 deletions(-) diff --git a/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_screen.dart b/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_screen.dart index bbed7880a..c1976c6f7 100644 --- a/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_screen.dart +++ b/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_screen.dart @@ -3,6 +3,7 @@ import 'package:autonomy_flutter/model/postcard_claim.dart'; import 'package:autonomy_flutter/screen/app_router.dart'; import 'package:autonomy_flutter/screen/interactive_postcard/design_stamp.dart'; import 'package:autonomy_flutter/screen/interactive_postcard/postcard_explain.dart'; +import 'package:autonomy_flutter/util/constants.dart'; import 'package:autonomy_flutter/view/postcard_button.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; @@ -61,7 +62,7 @@ class _ClaimEmptyPostCardScreenState extends State { onTap: () { bloc.add(AcceptGiftEvent(widget.claimRequest)); }, - color: const Color.fromRGBO(79, 174, 79, 1), + color: POSTCARD_GREEN_BUTTON_COLOR, ), ), ); diff --git a/lib/screen/interactive_postcard/claim_empty_postcard/pay_to_mint_postcard_screen.dart b/lib/screen/interactive_postcard/claim_empty_postcard/pay_to_mint_postcard_screen.dart index ac25c03a7..c4da36050 100644 --- a/lib/screen/interactive_postcard/claim_empty_postcard/pay_to_mint_postcard_screen.dart +++ b/lib/screen/interactive_postcard/claim_empty_postcard/pay_to_mint_postcard_screen.dart @@ -4,6 +4,7 @@ import 'package:autonomy_flutter/screen/app_router.dart'; import 'package:autonomy_flutter/screen/interactive_postcard/design_stamp.dart'; import 'package:autonomy_flutter/screen/interactive_postcard/postcard_explain.dart'; import 'package:autonomy_flutter/util/asset_token_ext.dart'; +import 'package:autonomy_flutter/util/constants.dart'; import 'package:autonomy_flutter/view/postcard_button.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; @@ -61,7 +62,7 @@ class _PayToMintPostcardScreenState extends State { owner: widget.claimRequest.address, tokenId: widget.claimRequest.tokenId))); }, - color: const Color.fromRGBO(79, 174, 79, 1), + color: POSTCARD_GREEN_BUTTON_COLOR, ), isPayToMint: true, ), diff --git a/lib/screen/send_receive_postcard/receive_postcard_page.dart b/lib/screen/send_receive_postcard/receive_postcard_page.dart index 18bb9bb20..2985c4bfa 100644 --- a/lib/screen/send_receive_postcard/receive_postcard_page.dart +++ b/lib/screen/send_receive_postcard/receive_postcard_page.dart @@ -90,7 +90,7 @@ class _ReceivePostCardPageState extends State { }); await _receivePostcard(context, assetToken); }, - color: const Color.fromRGBO(79, 174, 79, 1), + color: POSTCARD_GREEN_BUTTON_COLOR, ), ), ); diff --git a/lib/util/constants.dart b/lib/util/constants.dart index fa802f751..b18a46561 100644 --- a/lib/util/constants.dart +++ b/lib/util/constants.dart @@ -106,9 +106,10 @@ const MOMA_MEMENTO_6_CLAIM_ID = "memento6"; const MEMENTO_6_SERIES_ID_MAINNET = "2b75da9b-c605-4842-bf59-8e2e1fe04be6"; const MEMENTO_6_SERIES_ID_TESTNET = "420f4f8e-f45f-4627-b36c-e9fa5bf6af43"; -String get memento6SeriesId => Environment.appTestnetConfig - ? MEMENTO_6_SERIES_ID_TESTNET - : MEMENTO_6_SERIES_ID_MAINNET; +String get memento6SeriesId => + Environment.appTestnetConfig + ? MEMENTO_6_SERIES_ID_TESTNET + : MEMENTO_6_SERIES_ID_MAINNET; const REMOVE_CUSTOMER_SUPPORT = "/bitmark-inc/autonomy-apps/main/customer_support/annoucement_os.md"; @@ -121,15 +122,16 @@ const Duration STAMPING_POSTCARD_LIMIT_TIME = Duration(minutes: 60); const Color POSTCARD_BACKGROUND_COLOR = Color.fromRGBO(242, 242, 242, 1); const Color POSTCARD_PINK_BUTTON_COLOR = Color.fromRGBO(231, 75, 168, 1); +const Color POSTCARD_GREEN_BUTTON_COLOR = Color.fromRGBO(79, 174, 79, 1); const POSTCARD_ABOUT_THE_PROJECT = "https://www.moma.org/calendar/exhibitions/5618?preview=true"; final moMAGeoLocation = - GeoLocation(position: Location(lat: 40.761, lon: -73.980), address: "MoMA"); +GeoLocation(position: Location(lat: 40.761, lon: -73.980), address: "MoMA"); final internetUserGeoLocation = - GeoLocation(position: Location(lat: null, lon: null), address: "Web"); +GeoLocation(position: Location(lat: null, lon: null), address: "Web"); const int MAX_STAMP_IN_POSTCARD = 15; @@ -149,9 +151,10 @@ const String POSTCARD_FINISH_GETNEWSTAMP_MESSAGE = "finish getNewStamp"; const double POSTCARD_ASPECT_RATIO_ANDROID = 368.0 / 268; const double POSTCARD_ASPECT_RATIO_IOS = 348.0 / 268; -double get postcardAspectRatio => Platform.isAndroid - ? POSTCARD_ASPECT_RATIO_ANDROID - : POSTCARD_ASPECT_RATIO_IOS; +double get postcardAspectRatio => + Platform.isAndroid + ? POSTCARD_ASPECT_RATIO_ANDROID + : POSTCARD_ASPECT_RATIO_IOS; const double STAMP_ASPECT_RATIO = 345.0 / 378; @@ -162,9 +165,10 @@ const USDC_CONTRACT_ADDRESS_GOERLI = const USDC_CONTRACT_ADDRESS = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; const DEFAULT_FEE_OPTION = FeeOption.MEDIUM; -String get usdcContractAddress => Environment.appTestnetConfig - ? USDC_CONTRACT_ADDRESS_GOERLI - : USDC_CONTRACT_ADDRESS; +String get usdcContractAddress => + Environment.appTestnetConfig + ? USDC_CONTRACT_ADDRESS_GOERLI + : USDC_CONTRACT_ADDRESS; const publicTezosNodes = [ "https://mainnet.api.tez.ie", @@ -255,7 +259,10 @@ class GallerySortProperty { } extension RawValue on WalletApp { - String get rawValue => toString().split('.').last; + String get rawValue => + toString() + .split('.') + .last; } class ReportIssueType { @@ -268,7 +275,8 @@ class ReportIssueType { static const Announcement = 'announcement'; static const MerchandiseIssue = 'merchandise postcard'; - static List get getList => [ + static List get getList => + [ Feature, Bug, Feedback, @@ -326,7 +334,10 @@ enum PremiumFeature { } extension PremiumFeatureExtension on PremiumFeature { - String get rawValue => toString().split('.').last; + String get rawValue => + toString() + .split('.') + .last; String get description { switch (rawValue) { @@ -351,10 +362,8 @@ class ContextedAddress { final CryptoType cryptoType; final String address; - ContextedAddress( - this.cryptoType, - this.address, - ); + ContextedAddress(this.cryptoType, + this.address,); } enum CryptoType { From 1995573e835296ba093c2b9479131207c91e10f2 Mon Sep 17 00:00:00 2001 From: phuoc Date: Tue, 31 Oct 2023 14:10:54 +0700 Subject: [PATCH 14/27] change domain Signed-off-by: phuoc --- .github/workflows/android-release-appcenter.yaml | 1 + .github/workflows/bmvn_build_appcenter_android.yaml | 1 + .github/workflows/bmvn_build_appcenter_ios.yaml | 1 + .github/workflows/ios-release-appstore.yaml | 1 + lib/common/environment.dart | 3 +++ lib/service/deeplink_service.dart | 3 ++- 6 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/android-release-appcenter.yaml b/.github/workflows/android-release-appcenter.yaml index 8f6f27c96..d8bf3c37c 100644 --- a/.github/workflows/android-release-appcenter.yaml +++ b/.github/workflows/android-release-appcenter.yaml @@ -77,6 +77,7 @@ jobs: echo TZKT_MAINNET_URL=${{ secrets.TZKT_MAINNET_URL }} >> .env ${{ github.event.inputs.testnet == 'true' }} && echo POSTCARD_CONTRACT_ADDRESS=${{ secrets.POSTCARD_CONTRACT_ADDRESS_TESTNET }} >> .env || echo POSTCARD_CONTRACT_ADDRESS=${{ secrets.POSTCARD_CONTRACT_ADDRESS_MAINNET }} >> .env ${{ github.event.inputs.testnet == 'true' }} && echo AUTONOMY_MERCHANDISE_BASE_URL=${{ secrets.AUTONOMY_MERCHANDISE_BASE_URL_TESTNET }} >> .env || echo AUTONOMY_MERCHANDISE_BASE_URL=${{ secrets.AUTONOMY_MERCHANDISE_BASE_URL_MAINNET }} >> .env + ${{ github.event.inputs.testnet == 'true' }} && echo PAY_TO_MINT_BASE_URL=${{ secrets.PAY_TO_MINT_BASE_URL_TESTNET }} >> .env || echo PAY_TO_MINT_BASE_URL=${{ secrets.PAY_TO_MINT_BASE_URL_MAINNET }} >> .env echo FERAL_FILE_AUTHORIZATION_PREFIX=${{ secrets.FERAL_FILE_AUTHORIZATION_PREFIX }} >> .env echo SENTRY_DSN=${{ secrets.SENTRY_DSN }} >> .env diff --git a/.github/workflows/bmvn_build_appcenter_android.yaml b/.github/workflows/bmvn_build_appcenter_android.yaml index 336523ffe..5971afb57 100644 --- a/.github/workflows/bmvn_build_appcenter_android.yaml +++ b/.github/workflows/bmvn_build_appcenter_android.yaml @@ -96,6 +96,7 @@ jobs: echo TZKT_MAINNET_URL=${{ secrets.TZKT_MAINNET_URL }} >> .env ${{ inputs.testnet == true }} && echo POSTCARD_CONTRACT_ADDRESS=${{ secrets.POSTCARD_CONTRACT_ADDRESS_TESTNET }} >> .env || echo POSTCARD_CONTRACT_ADDRESS=${{ secrets.POSTCARD_CONTRACT_ADDRESS_MAINNET }} >> .env ${{ inputs.testnet == true }} && echo AUTONOMY_MERCHANDISE_BASE_URL=${{ secrets.AUTONOMY_MERCHANDISE_BASE_URL_TESTNET }} >> .env || echo AUTONOMY_MERCHANDISE_BASE_URL=${{ secrets.AUTONOMY_MERCHANDISE_BASE_URL_MAINNET }} >> .env + ${{ inputs.testnet == true }} && echo PAY_TO_MINT_BASE_URL=${{ secrets.PAY_TO_MINT_BASE_URL_TESTNET }} >> .env || echo PAY_TO_MINT_BASE_URL=${{ secrets.PAY_TO_MINT_BASE_URL_MAINNET }} >> .env echo FERAL_FILE_AUTHORIZATION_PREFIX=${{ secrets.FERAL_FILE_AUTHORIZATION_PREFIX }} >> .env echo SENTRY_DSN=${{ secrets.SENTRY_DSN }} >> .env diff --git a/.github/workflows/bmvn_build_appcenter_ios.yaml b/.github/workflows/bmvn_build_appcenter_ios.yaml index 873cf55ed..1cfe8ea5b 100644 --- a/.github/workflows/bmvn_build_appcenter_ios.yaml +++ b/.github/workflows/bmvn_build_appcenter_ios.yaml @@ -103,6 +103,7 @@ jobs: echo TZKT_MAINNET_URL=${{ secrets.TZKT_MAINNET_URL }} >> .env ${{ inputs.testnet == true }} && echo POSTCARD_CONTRACT_ADDRESS=${{ secrets.POSTCARD_CONTRACT_ADDRESS_TESTNET }} >> .env || echo POSTCARD_CONTRACT_ADDRESS=${{ secrets.POSTCARD_CONTRACT_ADDRESS_MAINNET }} >> .env ${{ inputs.testnet == true }} && echo AUTONOMY_MERCHANDISE_BASE_URL=${{ secrets.AUTONOMY_MERCHANDISE_BASE_URL_TESTNET }} >> .env || echo AUTONOMY_MERCHANDISE_BASE_URL=${{ secrets.AUTONOMY_MERCHANDISE_BASE_URL_MAINNET }} >> .env + ${{ inputs.testnet == true }} && echo PAY_TO_MINT_BASE_URL=${{ secrets.PAY_TO_MINT_BASE_URL_TESTNET }} >> .env || echo PAY_TO_MINT_BASE_URL=${{ secrets.PAY_TO_MINT_BASE_URL_MAINNET }} >> .env echo FERAL_FILE_AUTHORIZATION_PREFIX=${{ secrets.FERAL_FILE_AUTHORIZATION_PREFIX }} >> .env echo SENTRY_DSN=${{ secrets.SENTRY_DSN }} >> .env diff --git a/.github/workflows/ios-release-appstore.yaml b/.github/workflows/ios-release-appstore.yaml index 27089473a..6f23f83fc 100644 --- a/.github/workflows/ios-release-appstore.yaml +++ b/.github/workflows/ios-release-appstore.yaml @@ -88,6 +88,7 @@ jobs: echo TZKT_MAINNET_URL=${{ secrets.TZKT_MAINNET_URL }} >> .env ${{ github.event.inputs.testnet == 'true' }} && echo POSTCARD_CONTRACT_ADDRESS=${{ secrets.POSTCARD_CONTRACT_ADDRESS_TESTNET }} >> .env || echo POSTCARD_CONTRACT_ADDRESS=${{ secrets.POSTCARD_CONTRACT_ADDRESS_MAINNET }} >> .env ${{ github.event.inputs.testnet == 'true' }} && echo AUTONOMY_MERCHANDISE_BASE_URL=${{ secrets.AUTONOMY_MERCHANDISE_BASE_URL_TESTNET }} >> .env || echo AUTONOMY_MERCHANDISE_BASE_URL=${{ secrets.AUTONOMY_MERCHANDISE_BASE_URL_MAINNET }} >> .env + ${{ github.event.inputs.testnet == 'true' }} && echo PAY_TO_MINT_BASE_URL=${{ secrets.PAY_TO_MINT_BASE_URL_TESTNET }} >> .env || echo PAY_TO_MINT_BASE_URL=${{ secrets.PAY_TO_MINT_BASE_URL_MAINNET }} >> .env echo FERAL_FILE_AUTHORIZATION_PREFIX=${{ secrets.FERAL_FILE_AUTHORIZATION_PREFIX }} >> .env echo SENTRY_DSN=${{ secrets.SENTRY_DSN }} >> .env diff --git a/lib/common/environment.dart b/lib/common/environment.dart index 93dfa57be..a1eb9fe7e 100644 --- a/lib/common/environment.dart +++ b/lib/common/environment.dart @@ -160,6 +160,9 @@ class Environment { static String get merchandiseBaseUrl => dotenv.env['AUTONOMY_MERCHANDISE_BASE_URL'] ?? ''; + static String get payToMintBaseUrl => + dotenv.env['PAY_TO_MINT_BASE_URL'] ?? ''; + static String get chatServerHmacKey => dotenv.env['CHAT_SERVER_HMAC_KEY'] ?? ''; diff --git a/lib/service/deeplink_service.dart b/lib/service/deeplink_service.dart index c2582d8ef..ba1ca6801 100644 --- a/lib/service/deeplink_service.dart +++ b/lib/service/deeplink_service.dart @@ -305,7 +305,8 @@ class DeeplinkServiceImpl extends DeeplinkService { }, ); if (address == null) return; - final url = "${Environment.merchandiseBaseUrl}/payToMint?address=$address"; + final url = + "${Environment.payToMintBaseUrl}/moma/postcard?address=$address"; final response = (await _navigationService.goToIRLWebview( IRLWebScreenPayload(url, isPlainUI: true, statusBarColor: POSTCARD_BACKGROUND_COLOR))) From 577b566f656c13bd7c41815dd2822034f14e0291 Mon Sep 17 00:00:00 2001 From: phuoc Date: Wed, 1 Nov 2023 13:42:51 +0700 Subject: [PATCH 15/27] fix navigate Signed-off-by: phuoc --- lib/screen/irl_screen/webview_irl_screen.dart | 1 + lib/screen/settings/help_us/inapp_webview.dart | 12 ++++++++---- lib/service/deeplink_service.dart | 3 +-- lib/service/navigation_service.dart | 7 ++++--- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/screen/irl_screen/webview_irl_screen.dart b/lib/screen/irl_screen/webview_irl_screen.dart index 852adb476..ad4c3293c 100644 --- a/lib/screen/irl_screen/webview_irl_screen.dart +++ b/lib/screen/irl_screen/webview_irl_screen.dart @@ -427,6 +427,7 @@ class _IRLWebScreenState extends State { child: InAppWebViewPage( payload: InAppWebViewPayload(widget.payload.url, isPlainUI: widget.payload.isPlainUI, + backgroundColor: widget.payload.statusBarColor, onWebViewCreated: (controller) { _controller = controller; _addJavaScriptHandler(); diff --git a/lib/screen/settings/help_us/inapp_webview.dart b/lib/screen/settings/help_us/inapp_webview.dart index 85b043e10..6ba6b5165 100644 --- a/lib/screen/settings/help_us/inapp_webview.dart +++ b/lib/screen/settings/help_us/inapp_webview.dart @@ -39,12 +39,12 @@ class _InAppWebViewPageState extends State { return Scaffold( appBar: AppBar( toolbarHeight: 0, - systemOverlayStyle: const SystemUiOverlayStyle( - statusBarColor: Colors.transparent, + systemOverlayStyle: SystemUiOverlayStyle( + statusBarColor: widget.payload.backgroundColor ?? Colors.transparent, systemNavigationBarDividerColor: Colors.transparent, ), ), - backgroundColor: theme.primaryColor, + backgroundColor: widget.payload.backgroundColor ?? theme.primaryColor, body: Column( children: [ if (!widget.payload.isPlainUI) ...[ @@ -220,10 +220,14 @@ class _InAppWebViewPageState extends State { class InAppWebViewPayload { final String url; final bool isPlainUI; + final Color? backgroundColor; Function(InAppWebViewController controler)? onWebViewCreated; Function(InAppWebViewController controler, ConsoleMessage consoleMessage)? onConsoleMessage; InAppWebViewPayload(this.url, - {this.isPlainUI = false, this.onWebViewCreated, this.onConsoleMessage}); + {this.isPlainUI = false, + this.onWebViewCreated, + this.onConsoleMessage, + this.backgroundColor}); } diff --git a/lib/service/deeplink_service.dart b/lib/service/deeplink_service.dart index ba1ca6801..d3526f22e 100644 --- a/lib/service/deeplink_service.dart +++ b/lib/service/deeplink_service.dart @@ -305,8 +305,7 @@ class DeeplinkServiceImpl extends DeeplinkService { }, ); if (address == null) return; - final url = - "${Environment.payToMintBaseUrl}/moma/postcard?address=$address"; + final url = "${Environment.payToMintBaseUrl}/payToMint?address=$address"; final response = (await _navigationService.goToIRLWebview( IRLWebScreenPayload(url, isPlainUI: true, statusBarColor: POSTCARD_BACKGROUND_COLOR))) diff --git a/lib/service/navigation_service.dart b/lib/service/navigation_service.dart index 2ea949a2b..a612f6007 100644 --- a/lib/service/navigation_service.dart +++ b/lib/service/navigation_service.dart @@ -27,7 +27,9 @@ import 'package:autonomy_flutter/util/ui_helper.dart'; import 'package:autonomy_theme/autonomy_theme.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:nft_collection/models/asset_token.dart'; // ignore: implementation_imports +import 'package:nft_collection/models/asset_token.dart'; + +// ignore: implementation_imports import 'package:overlay_support/src/overlay_state_finder.dart'; class NavigationService { @@ -320,8 +322,7 @@ class NavigationService { Future goToIRLWebview(IRLWebScreenPayload payload) async { if (navigatorKey.currentState?.mounted == true && navigatorKey.currentContext != null) { - return await navigatorKey.currentState - ?.pushNamed(AppRouter.irlWebView, arguments: payload); + return await navigateTo(AppRouter.irlWebView, arguments: payload); } else { return {'result': false}; } From 7fb3d10165c3d3b91dee7c3537caef832cec3661 Mon Sep 17 00:00:00 2001 From: phuoc Date: Wed, 1 Nov 2023 14:38:57 +0700 Subject: [PATCH 16/27] change path Signed-off-by: phuoc --- lib/service/deeplink_service.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/service/deeplink_service.dart b/lib/service/deeplink_service.dart index d3526f22e..c879ba440 100644 --- a/lib/service/deeplink_service.dart +++ b/lib/service/deeplink_service.dart @@ -305,7 +305,7 @@ class DeeplinkServiceImpl extends DeeplinkService { }, ); if (address == null) return; - final url = "${Environment.payToMintBaseUrl}/payToMint?address=$address"; + final url = "${Environment.payToMintBaseUrl}/moma-postcard?address=$address"; final response = (await _navigationService.goToIRLWebview( IRLWebScreenPayload(url, isPlainUI: true, statusBarColor: POSTCARD_BACKGROUND_COLOR))) From 16b0df18ff4af4aedbd2ae81c196a430c6fddfa4 Mon Sep 17 00:00:00 2001 From: phuoc Date: Fri, 3 Nov 2023 09:57:01 +0700 Subject: [PATCH 17/27] assets Signed-off-by: phuoc --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index bb36fb527..acd766672 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit bb36fb527ba039d572c1af3698e45c7b706c0734 +Subproject commit acd7666721e3bb1f3737192af91937041126510d From c0ecb6a580c8794bc0c35e6027e4a8ed90a1d455 Mon Sep 17 00:00:00 2001 From: phuoc Date: Fri, 3 Nov 2023 10:55:01 +0700 Subject: [PATCH 18/27] add artwork metadata in dummy asset Signed-off-by: phuoc --- .../claim_empty_postcard/claim_empty_postcard_bloc.dart | 9 +++++++++ .../claim_empty_postcard/claim_empty_postcard_state.dart | 3 ++- .../pay_to_mint_postcard_screen.dart | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart b/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart index b3279473c..a59645769 100644 --- a/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart +++ b/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart @@ -1,4 +1,7 @@ +import 'dart:convert'; + import 'package:autonomy_flutter/common/injector.dart'; +import 'package:autonomy_flutter/model/postcard_metadata.dart'; import 'package:autonomy_flutter/screen/app_router.dart'; import 'package:autonomy_flutter/service/account_service.dart'; import 'package:autonomy_flutter/service/configuration_service.dart'; @@ -21,6 +24,9 @@ class ClaimEmptyPostCardBloc ClaimEmptyPostCardBloc() : super(ClaimEmptyPostCardState()) { on((event, emit) async { + final postcardMetadata = PostcardMetadata( + locationInformation: [], + ); final token = AssetToken( asset: Asset.init( artistName: 'MoMa', @@ -29,6 +35,9 @@ class ClaimEmptyPostCardBloc title: event.claimRequest.name, medium: 'software', previewURL: event.claimRequest.previewURL, + artworkMetadata: event.createMetadata + ? jsonEncode(postcardMetadata.toJson()) + : null, ), blockchain: "tezos", fungible: true, diff --git a/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_state.dart b/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_state.dart index 77cafcd5a..4e170db0a 100644 --- a/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_state.dart +++ b/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_state.dart @@ -34,9 +34,10 @@ class ClaimEmptyPostCardState { class GetTokenEvent extends ClaimEmptyPostCardEvent { final RequestPostcardResponse claimRequest; + final bool createMetadata; // constructor - GetTokenEvent(this.claimRequest); + GetTokenEvent(this.claimRequest, {this.createMetadata = false}); } class AcceptGiftEvent extends ClaimEmptyPostCardEvent { diff --git a/lib/screen/interactive_postcard/claim_empty_postcard/pay_to_mint_postcard_screen.dart b/lib/screen/interactive_postcard/claim_empty_postcard/pay_to_mint_postcard_screen.dart index c4da36050..f55cea7cc 100644 --- a/lib/screen/interactive_postcard/claim_empty_postcard/pay_to_mint_postcard_screen.dart +++ b/lib/screen/interactive_postcard/claim_empty_postcard/pay_to_mint_postcard_screen.dart @@ -29,7 +29,7 @@ class _PayToMintPostcardScreenState extends State { @override void initState() { super.initState(); - bloc.add(GetTokenEvent(widget.claimRequest)); + bloc.add(GetTokenEvent(widget.claimRequest, createMetadata: true)); } @override From 090ace89e8f831e830bddbb54abb2886d272f734 Mon Sep 17 00:00:00 2001 From: phuoc Date: Fri, 3 Nov 2023 11:02:57 +0700 Subject: [PATCH 19/27] fix conflict Signed-off-by: phuoc --- .../postcard_detail_page.dart | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/lib/screen/interactive_postcard/postcard_detail_page.dart b/lib/screen/interactive_postcard/postcard_detail_page.dart index fd0632935..7fc69fb38 100644 --- a/lib/screen/interactive_postcard/postcard_detail_page.dart +++ b/lib/screen/interactive_postcard/postcard_detail_page.dart @@ -755,33 +755,6 @@ class ClaimedPostcardDetailPageState extends State ); } - Future _sharePostcard( - BuildContext context, AssetToken asset) async { - try { - final shareTime = DateTime.now(); - final sharePostcardResponse = await _postcardService.sharePostcard(asset); - if (sharePostcardResponse.deeplink?.isNotEmpty ?? false) { - final shareMessage = "postcard_share_message".tr(namedArgs: { - 'deeplink': sharePostcardResponse.deeplink!, - }); - final result = await Share.shareWithResult(shareMessage); - if (result.status == ShareResultStatus.success) { - await Future.delayed(const Duration(milliseconds: 100)); - await _configurationService.updateSharedPostcard( - [SharedPostcard(asset.id, asset.owner, shareTime)]); - } - return result; - } - } catch (e) { - if (e is DioException) { - if (mounted) { - UIHelper.showSharePostcardFailed(context, e); - } - } - } - return null; - } - Widget _postcardInfo(BuildContext context, PostcardDetailState state) { return PostcardContainer( child: _travelInfoWidget(state), From 79756899279090120877363a68b72034ad911a27 Mon Sep 17 00:00:00 2001 From: phuoc Date: Fri, 3 Nov 2023 11:19:27 +0700 Subject: [PATCH 20/27] dummy asset Signed-off-by: phuoc --- .../claim_empty_postcard/claim_empty_postcard_bloc.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart b/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart index a59645769..aa5f011d3 100644 --- a/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart +++ b/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:autonomy_flutter/common/environment.dart'; import 'package:autonomy_flutter/common/injector.dart'; import 'package:autonomy_flutter/model/postcard_metadata.dart'; import 'package:autonomy_flutter/screen/app_router.dart'; @@ -43,7 +44,7 @@ class ClaimEmptyPostCardBloc fungible: true, contractType: 'fa2', tokenId: '1', - contractAddress: '', + contractAddress: Environment.postcardContractAddress, edition: 0, editionName: "", id: "tez-", From 39651ee2b7b4ba077fd8860c35314b93a5bcf180 Mon Sep 17 00:00:00 2001 From: phuoc Date: Mon, 6 Nov 2023 10:20:32 +0700 Subject: [PATCH 21/27] fix conflict Signed-off-by: phuoc --- .../interactive_postcard/postcard_detail_page.dart | 10 ++++++---- .../interactive_postcard/postcard_detail_state.dart | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/screen/interactive_postcard/postcard_detail_page.dart b/lib/screen/interactive_postcard/postcard_detail_page.dart index 05a5f35f5..f73f70f5b 100644 --- a/lib/screen/interactive_postcard/postcard_detail_page.dart +++ b/lib/screen/interactive_postcard/postcard_detail_page.dart @@ -11,6 +11,7 @@ import 'dart:convert'; import 'dart:io'; import 'package:after_layout/after_layout.dart'; +import 'package:autonomy_flutter/common/environment.dart'; import 'package:autonomy_flutter/common/injector.dart'; import 'package:autonomy_flutter/model/pair.dart'; import 'package:autonomy_flutter/model/play_control_model.dart'; @@ -31,6 +32,7 @@ import 'package:autonomy_flutter/screen/interactive_postcard/travel_info/travel_ import 'package:autonomy_flutter/screen/interactive_postcard/travel_info/travel_info_state.dart'; import 'package:autonomy_flutter/screen/irl_screen/webview_irl_screen.dart'; import 'package:autonomy_flutter/screen/settings/help_us/inapp_webview.dart'; +import 'package:autonomy_flutter/service/auth_service.dart'; import 'package:autonomy_flutter/service/chat_service.dart'; import 'package:autonomy_flutter/service/configuration_service.dart'; import 'package:autonomy_flutter/service/metric_client_service.dart'; @@ -562,7 +564,7 @@ class ClaimedPostcardDetailPageState extends State style: theme.textTheme.moMASans400Black12, ); if (asset.isCompleted) { - return _postcardPhysical(context, state); + return _postcardPhysical(context, asset); } if (isViewOnly) { return const SizedBox(); @@ -573,7 +575,7 @@ class ClaimedPostcardDetailPageState extends State isProcessing: true, ); } - if (!state.isLastOwner || !state.postcardValueLoaded) { + if (!asset.isLastOwner) { return place15StampsText; } if (!(asset.isStamping || asset.isStamped)) { @@ -655,14 +657,14 @@ class ClaimedPostcardDetailPageState extends State } } - Widget _postcardPhysical(BuildContext context, PostcardDetailState state) { + Widget _postcardPhysical(BuildContext context, AssetToken assetToken) { return Column( children: [ PostcardButton( text: "unlock_physical_objects".tr(), color: POSTCARD_PINK_BUTTON_COLOR, onTap: () async { - final indexId = state.assetToken!.id; + final indexId = assetToken.id; final jwtToken = (await injector().getAuthToken()).jwtToken; final hasCustomerSupport = diff --git a/lib/screen/interactive_postcard/postcard_detail_state.dart b/lib/screen/interactive_postcard/postcard_detail_state.dart index 3f6ebc56e..6980df059 100644 --- a/lib/screen/interactive_postcard/postcard_detail_state.dart +++ b/lib/screen/interactive_postcard/postcard_detail_state.dart @@ -39,7 +39,6 @@ class PostcardDetailState { List? provenances, String? imagePath, String? metadataPath, - bool? postcardValueLoaded, PostcardLeaderboard? leaderboard, bool? isFetchingLeaderboard, }) { From 32f85f7b43960f11f4a7fd541c2fb5d9aa19ed48 Mon Sep 17 00:00:00 2001 From: phuoc Date: Mon, 6 Nov 2023 10:48:01 +0700 Subject: [PATCH 22/27] fix lint Signed-off-by: phuoc --- lib/common/environment.dart | 4 ++-- lib/model/postcard_claim.dart | 12 ++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/common/environment.dart b/lib/common/environment.dart index a1eb9fe7e..b972d5b8f 100644 --- a/lib/common/environment.dart +++ b/lib/common/environment.dart @@ -158,10 +158,10 @@ class Environment { dotenv.env['POSTCARD_CONTRACT_ADDRESS'] ?? ''; static String get merchandiseBaseUrl => - dotenv.env['AUTONOMY_MERCHANDISE_BASE_URL'] ?? ''; + dotenv.env["AUTONOMY_MERCHANDISE_BASE_URL"] ?? ""; static String get payToMintBaseUrl => - dotenv.env['PAY_TO_MINT_BASE_URL'] ?? ''; + dotenv.env["PAY_TO_MINT_BASE_URL"] ?? ""; static String get chatServerHmacKey => dotenv.env['CHAT_SERVER_HMAC_KEY'] ?? ''; diff --git a/lib/model/postcard_claim.dart b/lib/model/postcard_claim.dart index a241e4a24..7aff1bcb8 100644 --- a/lib/model/postcard_claim.dart +++ b/lib/model/postcard_claim.dart @@ -229,14 +229,10 @@ class PayToMintRequest extends RequestPostcardResponse { PayToMintRequest({ required this.address, required this.tokenId, - required String claimID, - required String name, - required String previewURL, - }) : super( - claimID: claimID, - name: name, - previewURL: previewURL, - ); + required super.claimID, + required super.name, + required super.previewURL, + }); @override Map toJson() { From 52f8b214741b6c7b8023351ac1850f761807e644 Mon Sep 17 00:00:00 2001 From: phuocbitmark <110799144+phuocbitmark@users.noreply.github.com> Date: Mon, 6 Nov 2023 10:51:16 +0700 Subject: [PATCH 23/27] Update lib/screen/irl_screen/webview_irl_screen.dart Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- lib/screen/irl_screen/webview_irl_screen.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/screen/irl_screen/webview_irl_screen.dart b/lib/screen/irl_screen/webview_irl_screen.dart index ad4c3293c..9deb5c27c 100644 --- a/lib/screen/irl_screen/webview_irl_screen.dart +++ b/lib/screen/irl_screen/webview_irl_screen.dart @@ -428,7 +428,7 @@ class _IRLWebScreenState extends State { payload: InAppWebViewPayload(widget.payload.url, isPlainUI: widget.payload.isPlainUI, backgroundColor: widget.payload.statusBarColor, - onWebViewCreated: (controller) { + onWebViewCreated: (final controller) { _controller = controller; _addJavaScriptHandler(); if (widget.payload.localStorageItems != null) { From 670e52552b17fb656fa32b99c3391bd2ebd66b1c Mon Sep 17 00:00:00 2001 From: phuoc Date: Mon, 6 Nov 2023 11:30:41 +0700 Subject: [PATCH 24/27] support branch link Signed-off-by: phuoc --- lib/service/deeplink_service.dart | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/service/deeplink_service.dart b/lib/service/deeplink_service.dart index c879ba440..ea8aeaaa1 100644 --- a/lib/service/deeplink_service.dart +++ b/lib/service/deeplink_service.dart @@ -284,16 +284,20 @@ class DeeplinkServiceImpl extends DeeplinkService { link: link, linkType: LinkType.postcardPayToMint, prefix: callingPostcardPayToMintPrefix); - await _handlePayToMint(link); + await _handlePayToMintDeepLink(link); return true; } memoryValues.deepLink.value = null; return false; } - Future _handlePayToMint(String link) async { + Future _handlePayToMintDeepLink(String link) async { log.info("[DeeplinkService] _handlePayToMint"); _deepLinkHandlingMap.remove(link); + await _handlePayToMint(); + } + + Future _handlePayToMint() async { final address = await _navigationService.navigateTo( AppRouter.selectAddressScreen, arguments: { @@ -305,7 +309,8 @@ class DeeplinkServiceImpl extends DeeplinkService { }, ); if (address == null) return; - final url = "${Environment.payToMintBaseUrl}/moma-postcard?address=$address"; + final url = + "${Environment.payToMintBaseUrl}/moma-postcard?address=$address"; final response = (await _navigationService.goToIRLWebview( IRLWebScreenPayload(url, isPlainUI: true, statusBarColor: POSTCARD_BACKGROUND_COLOR))) @@ -451,6 +456,10 @@ class DeeplinkServiceImpl extends DeeplinkService { memoryValues.irlLink.value = null; } break; + + case "moma_postcard_purchase": + await _handlePayToMint(); + break; case "autonomy_airdrop": final String? sharedCode = data["share_code"]; if (sharedCode != null) { From 6145253815c21fe5661ff84eebfdcaa31a476122 Mon Sep 17 00:00:00 2001 From: phuoc Date: Mon, 6 Nov 2023 17:10:16 +0700 Subject: [PATCH 25/27] pay to mint: token id, address Signed-off-by: phuoc --- .../claim_empty_postcard_bloc.dart | 102 ++++++++++++------ 1 file changed, 72 insertions(+), 30 deletions(-) diff --git a/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart b/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart index aa5f011d3..71fc05036 100644 --- a/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart +++ b/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:autonomy_flutter/common/environment.dart'; import 'package:autonomy_flutter/common/injector.dart'; +import "package:autonomy_flutter/model/postcard_claim.dart"; import 'package:autonomy_flutter/model/postcard_metadata.dart'; import 'package:autonomy_flutter/screen/app_router.dart'; import 'package:autonomy_flutter/service/account_service.dart'; @@ -28,36 +29,77 @@ class ClaimEmptyPostCardBloc final postcardMetadata = PostcardMetadata( locationInformation: [], ); - final token = AssetToken( - asset: Asset.init( - artistName: 'MoMa', - maxEdition: 1, - mimeType: 'image/png', - title: event.claimRequest.name, - medium: 'software', - previewURL: event.claimRequest.previewURL, - artworkMetadata: event.createMetadata - ? jsonEncode(postcardMetadata.toJson()) - : null, - ), - blockchain: "tezos", - fungible: true, - contractType: 'fa2', - tokenId: '1', - contractAddress: Environment.postcardContractAddress, - edition: 0, - editionName: "", - id: "tez-", - balance: 1, - owner: 'owner', - lastActivityTime: DateTime.now(), - lastRefreshedTime: DateTime(1), - pending: true, - originTokenInfo: [], - provenance: [], - owners: {}, - ); - emit(state.copyWith(assetToken: token)); + if (event.claimRequest is PayToMintRequest) { + final payToMintRequest = event.claimRequest as PayToMintRequest; + final indexId = payToMintRequest.tokenId; + final tokenId = 'tez-${Environment.postcardContractAddress}-$indexId'; + print("[Pay to mint] tokenId: $tokenId"); + print(tokenId); + final token = AssetToken( + asset: Asset.init( + indexID: tokenId, + artistName: 'MoMa', + maxEdition: 1, + mimeType: 'image/png', + title: event.claimRequest.name, + medium: 'software', + previewURL: event.claimRequest.previewURL, + artworkMetadata: event.createMetadata + ? jsonEncode(postcardMetadata.toJson()) + : null, + ), + blockchain: "tezos", + fungible: true, + contractType: 'fa2', + tokenId: indexId, + contractAddress: Environment.postcardContractAddress, + edition: 0, + editionName: "", + id: tokenId, + balance: 1, + owner: payToMintRequest.address, + lastActivityTime: DateTime.now(), + lastRefreshedTime: DateTime(1), + pending: true, + originTokenInfo: [], + provenance: [], + owners: { + payToMintRequest.address: 1, + }, + ); + emit(state.copyWith(assetToken: token)); + } else { + final token = AssetToken( + asset: Asset.init( + artistName: 'MoMa', + maxEdition: 1, + mimeType: 'image/png', + title: event.claimRequest.name, + medium: 'software', + previewURL: event.claimRequest.previewURL, + artworkMetadata: event.createMetadata + ? jsonEncode(postcardMetadata.toJson()) + : null, + ), + blockchain: "tezos", + fungible: true, + contractType: 'fa2', + tokenId: '1', + contractAddress: Environment.postcardContractAddress, + edition: 0, + editionName: "", + id: "tez-", + balance: 1, + owner: 'owner', + lastActivityTime: DateTime.now(), + lastRefreshedTime: DateTime(1), + pending: true, + originTokenInfo: [], + provenance: [], + owners: {}, + ); + emit(state.copyWith(assetToken: token)); + } }); on((event, emit) async { From 824ee21a6f787cf183b4bcfa54559ade3651c057 Mon Sep 17 00:00:00 2001 From: phuoc Date: Mon, 6 Nov 2023 17:11:38 +0700 Subject: [PATCH 26/27] logging Signed-off-by: phuoc --- .../claim_empty_postcard/claim_empty_postcard_bloc.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart b/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart index 71fc05036..c38ccb9cb 100644 --- a/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart +++ b/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart @@ -10,6 +10,7 @@ import 'package:autonomy_flutter/service/configuration_service.dart'; import 'package:autonomy_flutter/service/metric_client_service.dart'; import 'package:autonomy_flutter/service/navigation_service.dart'; import 'package:autonomy_flutter/service/postcard_service.dart'; +import 'package:autonomy_flutter/util/log.dart'; import 'package:autonomy_flutter/util/wallet_utils.dart'; import 'package:dio/dio.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -33,8 +34,7 @@ class ClaimEmptyPostCardBloc final payToMintRequest = event.claimRequest as PayToMintRequest; final indexId = payToMintRequest.tokenId; final tokenId = 'tez-${Environment.postcardContractAddress}-$indexId'; - print("[Pay to mint] tokenId: $tokenId"); - print(tokenId); + log.info('[Pay to mint] tokenId: $tokenId'); final token = AssetToken( asset: Asset.init( indexID: tokenId, From a533aa83c1ccd6019a4d281b3971b62f27097b61 Mon Sep 17 00:00:00 2001 From: phuoc Date: Mon, 6 Nov 2023 17:28:13 +0700 Subject: [PATCH 27/27] set token pending Signed-off-by: phuoc --- .../claim_empty_postcard/claim_empty_postcard_bloc.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart b/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart index c38ccb9cb..8d8cb9fc8 100644 --- a/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart +++ b/lib/screen/interactive_postcard/claim_empty_postcard/claim_empty_postcard_bloc.dart @@ -15,6 +15,8 @@ import 'package:autonomy_flutter/util/wallet_utils.dart'; import 'package:dio/dio.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:nft_collection/models/models.dart'; +import "package:nft_collection/nft_collection.dart"; +import 'package:nft_collection/services/tokens_service.dart'; import 'claim_empty_postcard_state.dart'; @@ -24,6 +26,7 @@ class ClaimEmptyPostCardBloc final configService = injector(); final accountService = injector(); final navigationService = injector.get(); + final _tokensService = injector.get(); ClaimEmptyPostCardBloc() : super(ClaimEmptyPostCardState()) { on((event, emit) async { @@ -67,6 +70,12 @@ class ClaimEmptyPostCardBloc payToMintRequest.address: 1, }, ); + await _tokensService.setCustomTokens([token]); + _tokensService.reindexAddresses([payToMintRequest.address]); + injector.get().setListPostcardMint([tokenId]); + NftCollectionBloc.eventController.add( + GetTokensByOwnerEvent(pageKey: PageKey.init()), + ); emit(state.copyWith(assetToken: token)); } else { final token = AssetToken(