This repository has been archived by the owner on Jan 25, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 57
Sequence Diagrams
Dan Finlay edited this page Oct 3, 2019
·
1 revision
Diagrams were made with https://bramp.github.io/js-sequence-diagrams - source code below.
Note over PluginUI: connect
Note over RPCProvider: <--RpcCap middleware
PluginUI-> RPCProvider: (1) wallet_requestPermissions \n [{[`wallet_plugin_${ORIGIN}`]: {}}]
RPCProvider -> PermissionsController: requestUserApproval\n(permissionsRequest)
PermissionsController -> MM_UI: openPopup
Note over MM_UI: *granted*
MM_UI -> PermissionsController: approvePermissionsRequest\n(approved)
PermissionsController -> RPCProvider: resolve(approved)
RPCProvider -> RPCProvider: set domain permissions
RPCProvider -> PluginUI : (1) return result/error
PermissionsController -> PluginsController: add(plugin)
PluginsController -> PluginsController: _add\n(pluginName, sourceUrl)
PluginsController -> RPCProvider: (2) wallet_requestPermissions \n [{[`eth_runPlugin_${ORIGIN}`]: {}, pluginPermissions}]
RPCProvider -> PermissionsController: requestUserApproval\n(permissionsRequest)
PermissionsController -> MM_UI: openPopup
Note over MM_UI: *granted*
MM_UI -> PermissionsController: approvePermissionsRequest\n(approved)
PermissionsController -> RPCProvider: resolve(approved)
RPCProvider -> RPCProvider: set domain permissions
RPCProvider -> PluginsController: (2) return (err, response)
Note over RPCProvider: RpcCap middleware-->
PluginsController -> PluginsController: store.updateState(plugins)
Note over RPCProvider: <--restrictedMethods middleware
PluginsController -> RPCProvider: (3) `eth_runPlugin_${ORIGIN}` \n [{pluginPermissions, sourceCode, RPCProvider}]
RPCProvider -> PluginsController: run(pluginName, initialPermissions, sourceCode, ethereumProvider)
PluginsController -> PluginsController: _generateApisToProvide \n(approvedPermissions, pluginName)
PluginsController -> SES: rootRealm.evaluate
Note over PluginsController,SES: Plugin \n wallet.registerRpcMessageHandler
PluginsController -> PluginsController: _setPluginToActive(pluginName) \n store.updateState
PluginsController -> RPCProvider: return true / error
RPCProvider -> PluginsController: (3) return (err, response)
Note over RPCProvider: restrictedMethods middleware-->
Client-> RPCProvider: (1) pluginOrigin \n [{method: 'methodName', params: []}]
Note over RPCProvider: restrictedMethods middleware
RPCProvider -> Permissions_restrictedMethods: wallet_plugin_*
Permissions_restrictedMethods -> PluginsController: rpcMessageHandlers.get(origin)
PluginsController -> Permissions_restrictedMethods: return RpcMessageHandler
Permissions_restrictedMethods -> Plugin: RpcMessageHandler
Plugin -> Permissions_restrictedMethods: return result
Permissions_restrictedMethods -> RPCProvider: end() promise \n result/error
RPCProvider -> Client: result/error