From 6abc64c99c4d4dcc655375d4ca6d1d5c1b85246a Mon Sep 17 00:00:00 2001 From: crypto-shen Date: Mon, 22 Nov 2021 19:24:47 +0800 Subject: [PATCH 01/23] feat: add CryptoartAI plugins --- packages/dashboard/src/locales/en-US.json | 2 + packages/dashboard/src/locales/ko-KR.json | 2 + packages/dashboard/src/locales/zh-CN.json | 2 + .../dashboard/src/pages/Labs/constants.ts | 1 + packages/dashboard/src/pages/Labs/index.tsx | 9 + packages/mask/src/locales/en-US.json | 20 + packages/mask/src/locales/ja-JP.json | 20 + packages/mask/src/locales/ko-KR.json | 20 + packages/mask/src/locales/zh-CN.json | 20 + packages/mask/src/locales/zh-TW.json | 20 + packages/mask/src/plugin-infra/register.ts | 1 + .../CryptoartAI/SNSAdaptor/Account.tsx | 14 + .../CryptoartAI/SNSAdaptor/ActionBar.tsx | 87 + .../CryptoartAI/SNSAdaptor/ArticleTab.tsx | 61 + .../CryptoartAI/SNSAdaptor/CheckoutDialog.tsx | 163 ++ .../CryptoartAI/SNSAdaptor/Collectible.tsx | 274 +++ .../SNSAdaptor/CollectibleCard.tsx | 14 + .../CryptoartAI/SNSAdaptor/CollectibleTab.tsx | 27 + .../CryptoartAI/SNSAdaptor/HistoryTab/Row.tsx | 90 + .../SNSAdaptor/HistoryTab/index.tsx | 85 + .../CryptoartAI/SNSAdaptor/LoadingTable.tsx | 33 + .../SNSAdaptor/MakeOfferDialog.tsx | 204 ++ .../CryptoartAI/SNSAdaptor/OfferTab.tsx | 131 ++ .../CryptoartAI/SNSAdaptor/OrderRow.tsx | 100 + .../CryptoartAI/SNSAdaptor/PluginSkeleton.tsx | 33 + .../CryptoartAI/SNSAdaptor/PostInspector.tsx | 26 + .../CryptoartAI/SNSAdaptor/TokenTab.tsx | 146 ++ .../plugins/CryptoartAI/SNSAdaptor/index.tsx | 37 + .../src/plugins/CryptoartAI/Worker/index.ts | 8 + .../src/plugins/CryptoartAI/apis/index.ts | 118 + packages/mask/src/plugins/CryptoartAI/base.ts | 15 + .../mask/src/plugins/CryptoartAI/constants.ts | 36 + .../mask/src/plugins/CryptoartAI/helpers.ts | 21 + .../src/plugins/CryptoartAI/hooks/useAsset.ts | 70 + .../CryptoartAI/hooks/useCollectibleState.ts | 26 + .../hooks/useCryptoArtAI_Contract.ts | 27 + .../plugins/CryptoartAI/hooks/useEvents.ts | 37 + .../plugins/CryptoartAI/hooks/useOrders.ts | 18 + .../CryptoartAI/hooks/usePlaceBidCallback.ts | 141 ++ .../CryptoartAI/hooks/usePurchaseCallback.ts | 89 + .../mask/src/plugins/CryptoartAI/index.ts | 16 + .../src/plugins/CryptoartAI/pipes/index.ts | 36 + .../src/plugins/CryptoartAI/types/index.ts | 22 + .../mask/src/plugins/CryptoartAI/utils.ts | 62 + packages/web3-constants/evm/cryptoartai.json | 44 + .../CryptoArtAIArtistAcceptingBidsV2.json | 1035 +++++++++ .../abis/CryptoArtAICANFTMarket.json | 371 ++++ .../CryptoArtAIKnownOriginDigitalAssetV2.json | 1955 +++++++++++++++++ .../CryptoArtAIArtistAcceptingBidsV2.d.ts | 330 +++ .../types/CryptoArtAICANFTMarket.d.ts | 319 +++ .../CryptoArtAIKnownOriginDigitalAssetV2.d.ts | 492 +++++ packages/web3-shared/evm/constants/index.ts | 4 + 52 files changed, 6934 insertions(+) create mode 100644 packages/mask/src/plugins/CryptoartAI/SNSAdaptor/Account.tsx create mode 100644 packages/mask/src/plugins/CryptoartAI/SNSAdaptor/ActionBar.tsx create mode 100644 packages/mask/src/plugins/CryptoartAI/SNSAdaptor/ArticleTab.tsx create mode 100644 packages/mask/src/plugins/CryptoartAI/SNSAdaptor/CheckoutDialog.tsx create mode 100644 packages/mask/src/plugins/CryptoartAI/SNSAdaptor/Collectible.tsx create mode 100644 packages/mask/src/plugins/CryptoartAI/SNSAdaptor/CollectibleCard.tsx create mode 100644 packages/mask/src/plugins/CryptoartAI/SNSAdaptor/CollectibleTab.tsx create mode 100644 packages/mask/src/plugins/CryptoartAI/SNSAdaptor/HistoryTab/Row.tsx create mode 100644 packages/mask/src/plugins/CryptoartAI/SNSAdaptor/HistoryTab/index.tsx create mode 100644 packages/mask/src/plugins/CryptoartAI/SNSAdaptor/LoadingTable.tsx create mode 100644 packages/mask/src/plugins/CryptoartAI/SNSAdaptor/MakeOfferDialog.tsx create mode 100644 packages/mask/src/plugins/CryptoartAI/SNSAdaptor/OfferTab.tsx create mode 100644 packages/mask/src/plugins/CryptoartAI/SNSAdaptor/OrderRow.tsx create mode 100644 packages/mask/src/plugins/CryptoartAI/SNSAdaptor/PluginSkeleton.tsx create mode 100644 packages/mask/src/plugins/CryptoartAI/SNSAdaptor/PostInspector.tsx create mode 100644 packages/mask/src/plugins/CryptoartAI/SNSAdaptor/TokenTab.tsx create mode 100644 packages/mask/src/plugins/CryptoartAI/SNSAdaptor/index.tsx create mode 100644 packages/mask/src/plugins/CryptoartAI/Worker/index.ts create mode 100644 packages/mask/src/plugins/CryptoartAI/apis/index.ts create mode 100644 packages/mask/src/plugins/CryptoartAI/base.ts create mode 100644 packages/mask/src/plugins/CryptoartAI/constants.ts create mode 100644 packages/mask/src/plugins/CryptoartAI/helpers.ts create mode 100644 packages/mask/src/plugins/CryptoartAI/hooks/useAsset.ts create mode 100644 packages/mask/src/plugins/CryptoartAI/hooks/useCollectibleState.ts create mode 100644 packages/mask/src/plugins/CryptoartAI/hooks/useCryptoArtAI_Contract.ts create mode 100644 packages/mask/src/plugins/CryptoartAI/hooks/useEvents.ts create mode 100644 packages/mask/src/plugins/CryptoartAI/hooks/useOrders.ts create mode 100644 packages/mask/src/plugins/CryptoartAI/hooks/usePlaceBidCallback.ts create mode 100644 packages/mask/src/plugins/CryptoartAI/hooks/usePurchaseCallback.ts create mode 100644 packages/mask/src/plugins/CryptoartAI/index.ts create mode 100644 packages/mask/src/plugins/CryptoartAI/pipes/index.ts create mode 100644 packages/mask/src/plugins/CryptoartAI/types/index.ts create mode 100644 packages/mask/src/plugins/CryptoartAI/utils.ts create mode 100644 packages/web3-constants/evm/cryptoartai.json create mode 100644 packages/web3-contracts/abis/CryptoArtAIArtistAcceptingBidsV2.json create mode 100644 packages/web3-contracts/abis/CryptoArtAICANFTMarket.json create mode 100644 packages/web3-contracts/abis/CryptoArtAIKnownOriginDigitalAssetV2.json create mode 100644 packages/web3-contracts/types/CryptoArtAIArtistAcceptingBidsV2.d.ts create mode 100644 packages/web3-contracts/types/CryptoArtAICANFTMarket.d.ts create mode 100644 packages/web3-contracts/types/CryptoArtAIKnownOriginDigitalAssetV2.d.ts diff --git a/packages/dashboard/src/locales/en-US.json b/packages/dashboard/src/locales/en-US.json index 36132bcb8fc2..dfdcaf00302b 100644 --- a/packages/dashboard/src/locales/en-US.json +++ b/packages/dashboard/src/locales/en-US.json @@ -326,6 +326,8 @@ "labs_settings_swap_network": "{{network}} Network Default Trading Source", "labs_pets": "NFT revolution", "labs_pets_desc": "Explore the endless possibilities of NFTs. Link and display your NFTs on social media in a revolutionized way.", + "labs_cryptoartai": "CRYPTOART.AI", + "labs_cryptoartai_desc": "Connect CryptoArt Digital Artworks. The Internationale is a classic anthem that has been a shared memory for generations.", "dashboard_mobile_test": "Join Tests for Mobile", "dashboard_source_code": "Source Code", "privacy_policy": "Privacy Policy", diff --git a/packages/dashboard/src/locales/ko-KR.json b/packages/dashboard/src/locales/ko-KR.json index 60c77a9bc266..0a0dfa74c36f 100644 --- a/packages/dashboard/src/locales/ko-KR.json +++ b/packages/dashboard/src/locales/ko-KR.json @@ -312,6 +312,8 @@ "labs_settings_market_trend_source": "디폴트 추세 소스", "labs_settings_swap": "스왑 설정", "labs_settings_swap_network": "{{network}} 네트워크 디폴트 추세 소스", + "labs_cryptoartai": "CRYPTOART.AI", + "labs_cryptoartai_desc": "Connect CryptoArt Digital Artworks. The Internationale is a classic anthem that has been a shared memory for generations.", "dashboard_mobile_test": "모바일 테스트 참여", "dashboard_source_code": "소스 코드", "privacy_policy": "개인정보처리방침", diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.json index acafb984585c..5085e005e770 100644 --- a/packages/dashboard/src/locales/zh-CN.json +++ b/packages/dashboard/src/locales/zh-CN.json @@ -324,6 +324,8 @@ "labs_settings_market_trend_source": "默认趋势来源", "labs_settings_swap": "交易所设置", "labs_settings_swap_network": "{{network}} 网络默认交易所", + "labs_cryptoartai": "CRYPTOART.AI", + "labs_cryptoartai_desc": "Connect CryptoArt Digital Artworks. The Internationale is a classic anthem that has been a shared memory for generations.", "dashboard_mobile_test": "参加移动端测试", "dashboard_source_code": "源代码", "privacy_policy": "隐私政策", diff --git a/packages/dashboard/src/pages/Labs/constants.ts b/packages/dashboard/src/pages/Labs/constants.ts index ade24e8f7193..9508a4ed4faf 100644 --- a/packages/dashboard/src/pages/Labs/constants.ts +++ b/packages/dashboard/src/pages/Labs/constants.ts @@ -12,4 +12,5 @@ export const PLUGIN_IDS = { MARKET_TREND: 'com.maskbook.trader', POLL: 'com.maskbook.poll', PETS: 'com.maskbook.pets', + CRYPTOARTAI: 'com.maskbook.cryptoartai', } diff --git a/packages/dashboard/src/pages/Labs/index.tsx b/packages/dashboard/src/pages/Labs/index.tsx index e086430e2b18..6ec3520e8d94 100644 --- a/packages/dashboard/src/pages/Labs/index.tsx +++ b/packages/dashboard/src/pages/Labs/index.tsx @@ -62,6 +62,7 @@ export default function Plugins() { [PLUGIN_IDS.MARKETS]: true, [PLUGIN_IDS.VALUABLES]: true, [PLUGIN_IDS.MARKET_TREND]: true, + [PLUGIN_IDS.CRYPTOARTAI]: true, }) const account = useAccount() @@ -218,6 +219,14 @@ export default function Plugins() { enabled={pluginStatus[PLUGIN_IDS.COLLECTIBLES]} onSwitch={onSwitch} /> + } + enabled={pluginStatus[PLUGIN_IDS.CRYPTOARTAI]} + onSwitch={onSwitch} + /> {{price}} {{symbol}}.", "plugin_collectible_article": "Article", + "plugin_collectible_overview": "Overview", "plugin_collectible_details": "Details", "plugin_collectible_offers": "Offers", "plugin_collectible_listing": "Listing", @@ -513,6 +514,7 @@ "plugin_collectible_block_chain": "BlockChain", "plugin_collectible_create_by": "Created by", "plugin_collectible_owned_by": "Owned by", + "plugin_collectible_view_on": "View on", "plugin_collectible_no_history": "No History", "plugin_collectible_ensure_unreviewed_item": "Please ensure unreviewed item", "plugin_collectible_check_tos_document": "Please check ToS document", @@ -563,6 +565,24 @@ "plugin_collectible_make_an_offer": "Make an Offer", "plugin_collectible_approved_by_open_sea": "By checking this box, I acknowledge that this item has not been reviewed or approved by OpenSea.", "plugin_collectible_legal_text": "By checking this box, I agree to OpenSea's Terms of Service.", + "plugin_cryptoartai_operator": "Operator", + "plugin_cryptoartai_activitytype": "Type", + "plugin_cryptoartai_status": "Status", + "plugin_cryptoartai_time": "Time", + "plugin_cryptoartai_price": "Price", + "plugin_cryptoartai_tx": "Tx", + "plugin_cryptoartai_latestbid": "Latest Bid", + "plugin_cryptoartai_description": "Current Bid is {{bidprice}}{{symbol}}, price is {{price}}{{symbol}}. Edition {{soldNum}} of {{totalAvailable}} #{{editionNumber}}.", + "plugin_cryptoartai_buy": "Buy", + "plugin_cryptoartai_buynow": "Buy now", + "plugin_cryptoartai_title": "Title", + "plugin_cryptoartai_currentbalance": "Current balance", + "plugin_cryptoartai_current_highestoffer": "Current highest offer is ", + "plugin_cryptoartai_bidleast": "Your must bid at least ", + "plugin_cryptoartai_escrowed": "Your offer will be escrowed in the smart contract until it is accepted or you withdraw it", + "plugin_cryptoartai_currentbalance_is": "Current balance is ", + "plugin_cryptoartai_auctionend": "Auction has ended", + "plugin_cryptoartai_auctionendtime": "Auction end time ", "plugin_snapshot_info_title": "Information", "plugin_snapshot_info_strategy": "Strategie(s)", "plugin_snapshot_info_author": "Author", diff --git a/packages/mask/src/locales/ja-JP.json b/packages/mask/src/locales/ja-JP.json index e7698f437571..3ae95b43bd15 100644 --- a/packages/mask/src/locales/ja-JP.json +++ b/packages/mask/src/locales/ja-JP.json @@ -355,6 +355,7 @@ "plugin_collectible_post_listing": "投稿リスト", "plugin_collectible_description": "現在の価格は {{price}} {{symbol}} です。", "plugin_collectible_article": "品目", + "plugin_collectible_overview": "概要", "plugin_collectible_details": "詳細", "plugin_collectible_offers": "オファー", "plugin_collectible_listing": "リスティング", @@ -376,6 +377,7 @@ "plugin_collectible_block_chain": "ブロックチェーン", "plugin_collectible_create_by": "作成者", "plugin_collectible_owned_by": "所持者", + "plugin_collectible_view_on": "查看", "plugin_collectible_no_history": "履歴がありません", "plugin_collectible_ensure_unreviewed_item": "未レビューのアイテムを確認してください", "plugin_collectible_check_tos_document": "ToS ドキュメントを確認してください", @@ -425,6 +427,24 @@ "plugin_collectible_make_an_offer": "オファーする", "plugin_collectible_approved_by_open_sea": "このボックスをチェックすることで、このアイテムが OpenSea によってレビューまたは承認されていないことを認めます。", "plugin_collectible_legal_text": "このボックスをチェックすることで、OpenSea の利用規約に同意します。", + "plugin_cryptoartai_operator": "オペレーター", + "plugin_cryptoartai_activitytype": "タイプ", + "plugin_cryptoartai_status": "状態", + "plugin_cryptoartai_time": "時間", + "plugin_cryptoartai_price": "価格", + "plugin_cryptoartai_tx": "Tx", + "plugin_cryptoartai_latestbid": "最新の入札", + "plugin_cryptoartai_description": "最新の入札は {{bidprice}}{{symbol}},価格 {{price}}{{symbol}}。バージョン {{soldNum}} / {{totalAvailable}} #{{editionNumber}}。", + "plugin_cryptoartai_buy": "購入", + "plugin_cryptoartai_buynow": "今すぐ購入", + "plugin_cryptoartai_title": "タイトル", + "plugin_cryptoartai_currentbalance": "現在の残高", + "plugin_cryptoartai_current_highestoffer": "現在の最高のオファーは ", + "plugin_cryptoartai_bidleast": "少なくとも入札する必要があります ", + "plugin_cryptoartai_escrowed": "あなたのオファーは、それが受け入れられるか、あなたがそれを撤回するまで、スマートコントラクトでエスクローされます", + "plugin_cryptoartai_currentbalance_is": "現在の残高は ", + "plugin_cryptoartai_auctionend": "オークション終了しました", + "plugin_cryptoartai_auctionendtime": "オークション終了時間 ", "plugin_snapshot_info_title": "情報", "plugin_snapshot_info_strategy": "戦略家", "plugin_snapshot_info_author": "著者", diff --git a/packages/mask/src/locales/ko-KR.json b/packages/mask/src/locales/ko-KR.json index 09d9c6237d6f..71b1d6be6d17 100644 --- a/packages/mask/src/locales/ko-KR.json +++ b/packages/mask/src/locales/ko-KR.json @@ -483,6 +483,7 @@ "plugin_collectible_post_listing": "포스트 리스팅", "plugin_collectible_description": "현재의 가격은 {{price}} {{symbol}}.", "plugin_collectible_article": "글", + "plugin_collectible_overview": "개요", "plugin_collectible_details": "디테일", "plugin_collectible_offers": "오퍼", "plugin_collectible_listing": "리스팅", @@ -506,6 +507,7 @@ "plugin_collectible_block_chain": "불록체인", "plugin_collectible_create_by": "만든사람:", "plugin_collectible_owned_by": "소유자:", + "plugin_collectible_view_on": "보기:", "plugin_collectible_no_history": "기록없음", "plugin_collectible_ensure_unreviewed_item": "리뷰되지 않는 아이템을 확인하세요", "plugin_collectible_check_tos_document": "ToS 파일을 확인하세요", @@ -556,6 +558,24 @@ "plugin_collectible_make_an_offer": "오퍼하기", "plugin_collectible_approved_by_open_sea": "이 백스를 체크하면 OpenSea에서 이 항목을 리뷰받거나 승인받지 않았다는 것을 알 수 있습니다.", "plugin_collectible_legal_text": "이 박스를 체크하면 OpenSea의 항목과 서비스 동의합니다.", + "plugin_cryptoartai_operator": "운영자", + "plugin_cryptoartai_activitytype": "유형", + "plugin_cryptoartai_status": "상태", + "plugin_cryptoartai_time": "시간", + "plugin_cryptoartai_price": "가격", + "plugin_cryptoartai_tx": "Tx", + "plugin_cryptoartai_latestbid": "최근 입찰", + "plugin_cryptoartai_description": "최근 입찰 {{bidprice}}{{symbol}},가격 {{price}}{{symbol}}。버전 {{soldNum}} / {{totalAvailable}} #{{editionNumber}}。", + "plugin_cryptoartai_buy": "구매", + "plugin_cryptoartai_buynow": "지금 구매", + "plugin_cryptoartai_title": "제목", + "plugin_cryptoartai_currentbalance": "현재 잔액", + "plugin_cryptoartai_current_highestoffer": "현재 가장 높은 제안은 ", + "plugin_cryptoartai_bidleast": "최소한 입찰해야 합니다 ", + "plugin_cryptoartai_escrowed": "귀하의 제안은 수락되거나 철회할 때까지 스마트 계약에 에스크로됩니다", + "plugin_cryptoartai_currentbalance_is": "현재 잔액은 ", + "plugin_cryptoartai_auctionend": "경매가 종료되었습니다", + "plugin_cryptoartai_auctionendtime": "경매 종료 시간 ", "plugin_snapshot_info_title": "정보", "plugin_snapshot_info_strategy": "전략", "plugin_snapshot_info_author": "저자", diff --git a/packages/mask/src/locales/zh-CN.json b/packages/mask/src/locales/zh-CN.json index b4ebf2a0e634..f12a70dd18fb 100644 --- a/packages/mask/src/locales/zh-CN.json +++ b/packages/mask/src/locales/zh-CN.json @@ -461,6 +461,7 @@ "plugin_collectible_post_listing": "上架", "plugin_collectible_description": "当前价格是 {{price}} {{symbol}}", "plugin_collectible_article": "文章", + "plugin_collectible_overview": "概述", "plugin_collectible_details": "详情", "plugin_collectible_offers": "报价", "plugin_collectible_listing": "上架列表", @@ -484,6 +485,7 @@ "plugin_collectible_block_chain": "区块链", "plugin_collectible_create_by": "创建者", "plugin_collectible_owned_by": "持有者", + "plugin_collectible_view_on": "浏览", "plugin_collectible_no_history": "无历史记录", "plugin_collectible_ensure_unreviewed_item": "请确保未经审核的收藏品", "plugin_collectible_check_tos_document": "请查阅 ToS 文档", @@ -534,6 +536,24 @@ "plugin_collectible_make_an_offer": "发出报价", "plugin_collectible_approved_by_open_sea": "通过勾选此框,我确认此收藏品尚未被 OpenSea 审核或批准。", "plugin_collectible_legal_text": "通过勾选此框,我同意OpenSea的 服务条款。", + "plugin_cryptoartai_operator": "操作者", + "plugin_cryptoartai_activitytype": "类型", + "plugin_cryptoartai_status": "状态", + "plugin_cryptoartai_time": "时间", + "plugin_cryptoartai_price": "价格", + "plugin_cryptoartai_tx": "Tx", + "plugin_cryptoartai_latestbid": "最新出价", + "plugin_cryptoartai_description": "最新出价 {{bidprice}} {{symbol}},价格 {{price}} {{symbol}}。版本 {{soldNum}} / {{totalAvailable}} #{{editionNumber}}。", + "plugin_cryptoartai_buy": "购买", + "plugin_cryptoartai_buynow": "立即购买", + "plugin_cryptoartai_title": "名称", + "plugin_cryptoartai_currentbalance": "当前余额", + "plugin_cryptoartai_current_highestoffer": "当前最高报价为 ", + "plugin_cryptoartai_bidleast": "你必须至少出价 ", + "plugin_cryptoartai_escrowed": "您的报价将被托管在智能合约中,直到被接受或您撤回为止", + "plugin_cryptoartai_currentbalance_is": "当前余额为 ", + "plugin_cryptoartai_auctionend": "拍卖已结束", + "plugin_cryptoartai_auctionendtime": "拍卖结束时间 ", "plugin_snapshot_info_title": "相关信息", "plugin_snapshot_info_strategy": "策略", "plugin_snapshot_info_author": "作者", diff --git a/packages/mask/src/locales/zh-TW.json b/packages/mask/src/locales/zh-TW.json index 27eca1035215..29b0b642c88a 100644 --- a/packages/mask/src/locales/zh-TW.json +++ b/packages/mask/src/locales/zh-TW.json @@ -382,6 +382,7 @@ "plugin_collectible_post_listing": "上架", "plugin_collectible_description": "目前的價格是 {{price}} {{symbol}}。", "plugin_collectible_article": "文章", + "plugin_collectible_overview": "概述", "plugin_collectible_details": "詳細資訊", "plugin_collectible_offers": "報價", "plugin_collectible_listing": "上架的物品", @@ -405,6 +406,7 @@ "plugin_collectible_block_chain": "區塊練", "plugin_collectible_create_by": "建立者", "plugin_collectible_owned_by": "擁有者", + "plugin_collectible_view_on": "瀏覽", "plugin_collectible_no_history": "沒有歷史資運", "plugin_collectible_ensure_unreviewed_item": "請確保未審核的物品", "plugin_collectible_check_tos_document": "請查閱 ToS 文件", @@ -454,6 +456,24 @@ "plugin_collectible_make_an_offer": "商議價格", "plugin_collectible_approved_by_open_sea": "通過勾選此框,我確認此收藏品未經 OpenSea 審查。", "plugin_collectible_legal_text": "通過勾選此框,我同意 OpenSea 的 使用者條約。", + "plugin_cryptoartai_operator": "操作員", + "plugin_cryptoartai_activitytype": "類型", + "plugin_cryptoartai_status": "狀態", + "plugin_cryptoartai_time": "時間", + "plugin_cryptoartai_price": "價錢", + "plugin_cryptoartai_tx": "Tx", + "plugin_cryptoartai_latestbid": "最新出价", + "plugin_cryptoartai_description": "最新出价 {{bidprice}} {{symbol}},价格 {{price}} {{symbol}}。版本 {{soldNum}} / {{totalAvailable}} #{{editionNumber}}。", + "plugin_cryptoartai_buy": "購買", + "plugin_cryptoartai_buynow": "立即購買", + "plugin_cryptoartai_title": "名稱", + "plugin_cryptoartai_currentbalance": "當前餘額", + "plugin_cryptoartai_current_highestoffer": "當前最高報價為 ", + "plugin_cryptoartai_bidleast": "你必須至少出價 ", + "plugin_cryptoartai_escrowed": "您的報價將被託管在智能合約中,直到被接受或您撤回為止", + "plugin_cryptoartai_currentbalance_is": "當前餘額為 ", + "plugin_cryptoartai_auctionend": "拍賣已結束", + "plugin_cryptoartai_auctionendtime": "拍賣結束時間 ", "plugin_snapshot_info_title": "資訊", "plugin_snapshot_info_strategy": "策略", "plugin_snapshot_info_author": "作者", diff --git a/packages/mask/src/plugin-infra/register.ts b/packages/mask/src/plugin-infra/register.ts index 600fce9843b2..5c5d11d74a57 100644 --- a/packages/mask/src/plugin-infra/register.ts +++ b/packages/mask/src/plugin-infra/register.ts @@ -26,5 +26,6 @@ import '../plugins/MaskBox' import '../plugins/Profile' import '../plugins/Pets' import '../plugins/EVM' +import '../plugins/CryptoartAI' // import '../plugins/NFT' // import '../plugins/Airdrop' diff --git a/packages/mask/src/plugins/CryptoartAI/SNSAdaptor/Account.tsx b/packages/mask/src/plugins/CryptoartAI/SNSAdaptor/Account.tsx new file mode 100644 index 000000000000..2abe8ecd5ecb --- /dev/null +++ b/packages/mask/src/plugins/CryptoartAI/SNSAdaptor/Account.tsx @@ -0,0 +1,14 @@ +import { useI18N } from '../../../utils' +import { useAccount, isSameAddress } from '@masknet/web3-shared-evm' + +export interface AccountProps { + address?: string + username?: string +} + +export function Account({ address, username }: AccountProps) { + const account = useAccount() + const { t } = useI18N() + + return <>{isSameAddress(account, address ?? '') ? t('plugin_collectible_you') : username || address?.slice(2, 8)} +} diff --git a/packages/mask/src/plugins/CryptoartAI/SNSAdaptor/ActionBar.tsx b/packages/mask/src/plugins/CryptoartAI/SNSAdaptor/ActionBar.tsx new file mode 100644 index 000000000000..feefaab02599 --- /dev/null +++ b/packages/mask/src/plugins/CryptoartAI/SNSAdaptor/ActionBar.tsx @@ -0,0 +1,87 @@ +import { Box } from '@mui/material' +import { makeStyles } from '@masknet/theme' +import { useI18N } from '../../../utils' +import { CollectibleState } from '../hooks/useCollectibleState' +import ActionButton from '../../../extension/options-page/DashboardComponents/ActionButton' +import { useControlledDialog } from '../../../utils/hooks/useControlledDialog' +import { MakeOfferDialog } from './MakeOfferDialog' +import { CheckoutDialog } from './CheckoutDialog' + +const useStyles = makeStyles()((theme) => { + return { + root: { + marginLeft: theme.spacing(-0.5), + marginRight: theme.spacing(-0.5), + }, + button: { + flex: 1, + margin: `0 ${theme.spacing(0.5)}`, + }, + } +}) + +export interface ActionBarProps {} + +export function ActionBar(props: ActionBarProps) { + const { t } = useI18N() + const { classes } = useStyles() + const { asset } = CollectibleState.useContainer() + + const { + open: openCheckoutDialog, + onOpen: onOpenCheckoutDialog, + onClose: onCloseCheckoutDialog, + } = useControlledDialog() + const { open: openOfferDialog, onOpen: onOpenOfferDialog, onClose: onCloseOfferDialog } = useControlledDialog() + + if (!asset.value) return null + + return ( + + {!asset.value.isSoldOut && + !asset.value.is_owner && + asset.value.is24Auction && + new Date(asset.value.latestBidVo?.auctionEndTime).getTime() - Date.now() > 0 ? ( + { + onOpenOfferDialog() + }}> + {t('plugin_collectible_place_bid')} + + ) : null} + {!asset.value.isSoldOut && + !asset.value.is_owner && + !asset.value.is24Auction && + asset.value.trade?.isCanAuction ? ( + { + onOpenOfferDialog() + }}> + {t('plugin_collectible_make_offer')} + + ) : null} + {!asset.value.isSoldOut && + asset.value.totalSurplus > 0 && + !asset.value.is24Auction && + asset.value.priceInEth < 100000 && + asset.value.trade?.isCanBuy ? ( + + {t('plugin_collectible_buy_now')} + + ) : null} + + + + ) +} diff --git a/packages/mask/src/plugins/CryptoartAI/SNSAdaptor/ArticleTab.tsx b/packages/mask/src/plugins/CryptoartAI/SNSAdaptor/ArticleTab.tsx new file mode 100644 index 000000000000..e73e47d0400f --- /dev/null +++ b/packages/mask/src/plugins/CryptoartAI/SNSAdaptor/ArticleTab.tsx @@ -0,0 +1,61 @@ +import type { FC } from 'react' +import { Link } from '@mui/material' +import { makeStyles } from '@masknet/theme' +import { Video } from '../../../components/shared/Video' +import { CollectibleTab } from './CollectibleTab' +import { CollectibleState } from '../hooks/useCollectibleState' + +const useStyles = makeStyles()({ + body: { + display: 'flex', + justifyContent: 'center', + height: '300px', + }, + player: { + maxWidth: '100%', + maxHeight: '100%', + border: 'none', + }, +}) + +interface AssetPlayerProps { + src?: string + alt: string +} + +// opensea supports: JPG, PNG, GIF, SVG, MP4, WEBM, MP3, WAV, OGG, GLB, GLTF. +const AssetPlayer: FC = ({ src, alt }) => { + const { classes } = useStyles() + if (!src) { + return null + } + const isVideo = src.match(/\.(mp4|webm)$/i) + if (isVideo) { + return