diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 7859ecb23c..bff8161c22 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -18,6 +18,7 @@ import { OffsetToLineColumnConverter, CompilerMetadata, CompilerArtefacts, Fetch import Registry from './app/state/registry' import { ConfigPlugin } from './app/plugins/config' +import { StoragePlugin } from './app/plugins/storage' import { Layout } from './app/panels/layout' import { NotificationPlugin } from './app/plugins/notification' import { Blockchain } from './blockchain/blockchain.js' @@ -142,6 +143,9 @@ class AppComponent { // ----------------- dGit provider --------------------------------- const dGitProvider = new DGitProvider() + // ----------------- Storage plugin --------------------------------- + const storagePlugin = new StoragePlugin() + // ----------------- import content service ------------------------ const contentImport = new CompilerImports() @@ -214,6 +218,7 @@ class AppComponent { web3Provider, fetchAndCompile, dGitProvider, + storagePlugin, hardhatProvider, self.walkthroughService ]) @@ -327,7 +332,7 @@ class AppComponent { await self.appManager.activatePlugin(['settings', 'config']) await self.appManager.activatePlugin(['hiddenPanel', 'pluginManager', 'contextualListener', 'terminal', 'blockchain', 'fetchAndCompile', 'contentImport', 'gistHandler']) await self.appManager.activatePlugin(['settings']) - await self.appManager.activatePlugin(['walkthrough']) + await self.appManager.activatePlugin(['walkthrough','storage']) self.appManager.on( 'filePanel', diff --git a/apps/remix-ide/src/app/plugins/storage.ts b/apps/remix-ide/src/app/plugins/storage.ts new file mode 100644 index 0000000000..f50a98ca1c --- /dev/null +++ b/apps/remix-ide/src/app/plugins/storage.ts @@ -0,0 +1,24 @@ +import { Plugin } from '@remixproject/engine'; + +const profile = { + name: 'storage', + displayName: 'Storage', + description: 'Storage', + methods: ['getStorage'] +}; + +export class StoragePlugin extends Plugin { + constructor() { + console.log('storage plugin') + super(profile); + } + + async getStorage() { + console.log('getStorage') + if ('storage' in navigator && 'estimate' in navigator.storage) { + return navigator.storage.estimate() + } else { + throw new Error("Can't get storage quota"); + } + } +} diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js index 7967336579..60543c9e2b 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -8,7 +8,7 @@ const _paq = window._paq = window._paq || [] const requiredModules = [ // services + layout views + system views 'manager', 'config', 'compilerArtefacts', 'compilerMetadata', 'contextualListener', 'editor', 'offsetToLineColumnConverter', 'network', 'theme', 'fileManager', 'contentImport', 'blockchain', 'web3Provider', 'scriptRunner', 'fetchAndCompile', 'mainPanel', 'hiddenPanel', 'sidePanel', 'menuicons', - 'filePanel', 'terminal', 'settings', 'pluginManager', 'tabs', 'udapp', 'dGitProvider', 'solidity-logic', 'gistHandler', 'layout', 'notification', 'permissionhandler', 'walkthrough'] + 'filePanel', 'terminal', 'settings', 'pluginManager', 'tabs', 'udapp', 'dGitProvider', 'solidity-logic', 'gistHandler', 'layout', 'notification', 'permissionhandler', 'walkthrough', 'storage'] const dependentModules = ['git', 'hardhat', 'slither'] // module which shouldn't be manually activated (e.g git is activated by remixd)