From 8f0b7ac2967a63f8be4c13053b46b05fa38c3fc2 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 14 Jun 2022 13:52:26 +0200 Subject: [PATCH 1/3] docs: keyring component diagram --- docs/architecture/keyring_component.puml | 104 +++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 docs/architecture/keyring_component.puml diff --git a/docs/architecture/keyring_component.puml b/docs/architecture/keyring_component.puml new file mode 100644 index 0000000000..944b2687bb --- /dev/null +++ b/docs/architecture/keyring_component.puml @@ -0,0 +1,104 @@ +@startuml +frame "Background Document" { + package common { + [KVStore] + } + + package background { + [KeyRingService] + [KeyRing] + [KeyRingService] -> [KeyRing] + } + + package extension as bg_extension { + [ExtensionRouter] ------> [KeyRingService] + } +} + +frame "Chrome" { + package browser { + component runtime { + } + + component tabs { + } + } +} + +frame "Popup Document" { + package stores { + [KeyRingStore] + [KeyRing] -> [KVStore] + } + + package crypto { + [KeyStore] + [KeyRingStore] --> [KeyStore] + } + + package extension as pop_extension { + component RootStore { +' portout UIConfigStore +' portout ChainStore + portout KeyRingStore as pKeyRingStore +' portout IBCChannelStore + portout InteractionStore + portout PermissionStore +' portout SignInteractionStore +' portout LedgerInitStore +' portout ChainSuggestStore +' portout QueriesStore +' portout AccountStore +' portout CoinGeckoPriceStore +' portout TokensStore +' portout AnalyticStore + + component IBCCurrencyRegistrar { + } + } + RootStore -> [KeyRingStore] + } + + package router-extension { + component InExtensionMessageRequester { + port Messages + portout Requests + +' component browser.runtime { +' portin Messages as brMessages +' } +' Messages -- brMessages + component browser.runtime { + } + Messages --> "Message" browser.runtime + } + pKeyRingStore -0)-> Messages : Message + Requests ..> [ExtensionRouter] + } +} + +node legend { + frame "execution context" { + package "package" { + component "component" { + } + skinparam componentStyle rectangle + component legend_text [ + "Direct use" imports related component. + + "Cross-context use" uses related component via + message passing request/response between isolated + javascript contexts. + ' TODO: explain "role" + ' + ' The relation label should + ' reference the (sub-)component or module responsible + ' for initiating the respective message passing request. + ] + [component] -> legend_text : direct use + [component] .> "role (to component)" legend_text : cross-context use + [component] -0)- legend_text : "role (to text node)" required interface + } + } +} +@enduml From 59592d0ec202ce58cfc098e099feac6bdbd58754 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 14 Jun 2022 13:53:02 +0200 Subject: [PATCH 2/3] docs: keyring class diagram --- docs/architecture/keyring_class.puml | 165 +++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 docs/architecture/keyring_class.puml diff --git a/docs/architecture/keyring_class.puml b/docs/architecture/keyring_class.puml new file mode 100644 index 0000000000..a84efe9952 --- /dev/null +++ b/docs/architecture/keyring_class.puml @@ -0,0 +1,165 @@ +@startuml + +package router { + interface MessageRequester { + sendMessage() + } + + abstract Router { + #msgRegistry + #registeredHandler + #guards + #port + +registerMessage() + +addHandler() + +addGuard() + +handleMessage() + + --- + Abstract members + -- + +listen() + +unlisten() + } + + class MessageRegistry { + -registeredMsgType + +registerMessage() + +parseMessage() + } + Router --o MessageRegistry +} +package common { + interface KVStore { + get() + set() + prefix() + } +} + +package store { + class KeyRingStore { + +status: KeyRingStatus + +multiKeyStoreInfo + #requester: MessageRequester + +createMnemonicKey() + +createPrivateKey() + +createLedgerKey() + +addMnemonicKey() + +addPrivateKey() + +addLedgerKey() + +changeKeyRing() + +lock() + +unlock() + +deleteKeyRing() + +updateNameKeyRing() + #restore() + } +} + +package router-extension { + class InExtensionMessageRequester { + +sendMessage() + } + InExtensionMessageRequester --|> MessageRequester + KeyRingStore --o InExtensionMessageRequester + + class ExtensionRouter { + +listen() + +unlisten() + #onMessage() + #onMessageHandler() + } + ExtensionRouter -|> Router +} + +package crypto { + interface KeyStore { + version: string + coinTypeForChain: CoinTypeForChain + type + bip44HDPath + meta + crypto + } + + interface "KeyStoreCrypto (embedded)" as KeyStoreCrypto { + cipher + ciphertext + kdf + mac + } + KeyStore --* KeyStoreCrypto +} + +package background { + class KeyRing { + -keystore + -multiKeyStore + } + KeyRing --o "\nkeyStore[]\n\n" KeyStore + KeyRing --o KVStore + + class KeyRingService { + -keyRing: KeyRing + + +restore() + +enable() + +deleteKeyRing() + +updateNameKeyRing() + +showKeyRing() + +createMnemonicKey() + +createPrivateKey() + +createLedgerKey() + +lock() + +unlock() + +getKey() + +getKeyStoreMeta() + +getKeyRingType() + +requestSignAmino() + +requestSignDirect() + +sign() + +addMnemonicKey() + +addPrivateKey() + +addLedgerKey() + +changeKeyStoreFromMultiKeyStore() + } + KeyRingService "keyRing" --o KeyRing + + interface MultiKeyStoreInfoElem { + version + coinTypeForChain + type + bip44HDPath + meta + } + MultiKeyStoreInfoElem --* KeyStore : "Pick\n(where K = members of\nMultiKeyStoreInfoElem)" + KeyRingStore -o "many" MultiKeyStoreInfoElem +} + +package extension { + class RootStore { + +keyRingStore + } + RootStore --o KeyRingStore +} + +node legend { + package "package" { + interface "interface" {} + abstract "abstract interface" {} + class "class" { + -private_attribute + #protected_attribute + +public_attribute + -private_method() + #protected_method() + +public_method() + + } + "class" -* "interface" : composition + "class" -o "arity" "interface" : aggregation + "class" -|> "interface" : interface realization + } +} +@enduml From 805d2b82b5ded7bd197c67ad5285014978dd36a4 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Fri, 17 Jun 2022 10:30:01 +0200 Subject: [PATCH 3/3] chore: add .puml files to eslintignore --- .eslintignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintignore b/.eslintignore index bf6ee7d465..6506af6fab 100644 --- a/.eslintignore +++ b/.eslintignore @@ -7,6 +7,7 @@ **/*.secret **/*.md **/*.py +**/*.puml .DS_Store node_modules