From 37c2510d2c0cdd2da3638afa3380586f9b1e89fd Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Mon, 6 Dec 2021 00:01:33 +0800 Subject: [PATCH] refactor: move application entrance definition to app-plugin --- packages/mask/src/plugins/EVM/base.ts | 3 --- packages/mask/src/plugins/EVM/constants.ts | 7 ------ packages/plugin-infra/src/types.ts | 27 ++++++++++++++++++++-- packages/plugin-infra/src/web3-types.ts | 18 --------------- packages/plugins/Flow/src/base.ts | 1 - 5 files changed, 25 insertions(+), 31 deletions(-) diff --git a/packages/mask/src/plugins/EVM/base.ts b/packages/mask/src/plugins/EVM/base.ts index f49400e3e205..d892984bd9c2 100644 --- a/packages/mask/src/plugins/EVM/base.ts +++ b/packages/mask/src/plugins/EVM/base.ts @@ -6,7 +6,6 @@ import { PLUGIN_DESCRIPTION, PLUGIN_PROVIDERS, PLUGIN_NETWORKS, - PLUGIN_APPLICATIONS, PLUGIN_APPLICATION_CATEGORIES, } from './constants' @@ -21,9 +20,7 @@ export const base: Plugin.Shared.Definition = { networks: { type: 'opt-out', networks: {} }, target: 'stable', }, - declareApplications: PLUGIN_APPLICATIONS, declareApplicationCategories: PLUGIN_APPLICATION_CATEGORIES, declareWeb3Networks: PLUGIN_NETWORKS, declareWeb3Providers: PLUGIN_PROVIDERS, } -;('') diff --git a/packages/mask/src/plugins/EVM/constants.ts b/packages/mask/src/plugins/EVM/constants.ts index 63ce7681d039..6f9c671fca6e 100644 --- a/packages/mask/src/plugins/EVM/constants.ts +++ b/packages/mask/src/plugins/EVM/constants.ts @@ -179,13 +179,6 @@ export const PLUGIN_PROVIDERS: Web3Plugin.ProviderDescriptor[] = [ icon: new URL('./assets/fortmatic.png', import.meta.url), }, ] -export const PLUGIN_APPLICATIONS: Web3Plugin.ApplicationDescriptor[] = [ - { - ID: `${PLUGIN_ID}_application_redpacket`, - name: 'Lucky Drop', - icon: new URL('./assets/lucky_drop.png', import.meta.url), - }, -] export const PLUGIN_APPLICATION_CATEGORIES: Web3Plugin.ApplicationCategoryDescriptor[] = [ { ID: `${PLUGIN_ID}_category_nfts`, diff --git a/packages/plugin-infra/src/types.ts b/packages/plugin-infra/src/types.ts index f0b387ebca49..3a63e94375b8 100644 --- a/packages/plugin-infra/src/types.ts +++ b/packages/plugin-infra/src/types.ts @@ -106,8 +106,6 @@ export namespace Plugin.Shared { declareWeb3Networks?: Web3Plugin.NetworkDescriptor[] /** Introduce wallet providers information. */ declareWeb3Providers?: Web3Plugin.ProviderDescriptor[] - /** Introduce application information. */ - declareApplications?: Web3Plugin.ApplicationDescriptor[] /** Introduce application category information. */ declareApplicationCategories?: Web3Plugin.ApplicationCategoryDescriptor[] } @@ -203,6 +201,8 @@ export namespace Plugin.SNSAdaptor { CompositionDialogMetadataBadgeRender?: CompositionMetadataBadgeRender /** This UI will be rendered as an entry in the toolbar (if the SNS has a Toolbar support) */ ToolbarEntry?: ToolbarEntry + /** This UI will be rendered as an entry in the wallet status dialog */ + ApplicationEntry?: ApplicationEntry } //#region Composition entry /** @@ -279,6 +279,29 @@ export namespace Plugin.SNSAdaptor { onClick: 'openCompositionEntry' } //#endregion + + export interface ApplicationEntry { + /** + * The icon image URL + */ + icon: URL + /** + * The name of the application + */ + label: I18NStringField | string + /** + * Also an entrance in a sub-folder + */ + categoryID?: string + /** + * Used to order the applications on the board + */ + priority: number + /** + * What to do if the application icon is clicked. + */ + onClick(): void + } } /** This part runs in the dashboard */ diff --git a/packages/plugin-infra/src/web3-types.ts b/packages/plugin-infra/src/web3-types.ts index 43dd1bbac68b..9f3529992c15 100644 --- a/packages/plugin-infra/src/web3-types.ts +++ b/packages/plugin-infra/src/web3-types.ts @@ -75,17 +75,6 @@ export declare namespace Web3Plugin { name: string } - export interface ApplicationDescriptor { - /** An unique ID for each application */ - ID: string - /** A sub-category defined by each network plugin */ - categoryID?: string - /** The application icon */ - icon: URL - /** The application name */ - name: string - } - export interface CryptoPrice { [token: string]: { [key in CurrencyType]?: number @@ -331,11 +320,6 @@ export declare namespace Web3Plugin { onClick?: (network: NetworkDescriptor, provider: ProviderDescriptor) => void onSubmit?: (network: NetworkDescriptor, provider: ProviderDescriptor) => void } - export interface ApplicationIconClickBaitProps { - application: ApplicationDescriptor - category?: ApplicationCategoryDescriptor - } - export interface ApplicationCategoryIconClickBaitProps { category: ApplicationCategoryDescriptor } @@ -355,8 +339,6 @@ export declare namespace Web3Plugin { ProviderIconClickBait?: Plugin.InjectUIReact } WalletStatusDialog?: { - /** This UI will receive application icon as children component, and the plugin may hook click handle on it. */ - ApplicationIconClickBait?: Plugin.InjectUIReact /** This UI will receive application category icon as children component, and the plugin may hook click handle on it. */ ApplicationCategoryIconClickBait?: Plugin.InjectUIReact } diff --git a/packages/plugins/Flow/src/base.ts b/packages/plugins/Flow/src/base.ts index 3c40d4d347cf..816e55ae7143 100644 --- a/packages/plugins/Flow/src/base.ts +++ b/packages/plugins/Flow/src/base.ts @@ -14,7 +14,6 @@ export const base: Plugin.Shared.Definition = { target: 'beta', }, i18n: languages, - declareApplications: [], declareApplicationCategories: [], declareWeb3Networks: PLUGIN_NETWORKS, declareWeb3Providers: PLUGIN_PROVIDERS,