aboutsummaryrefslogtreecommitdiffstats
path: root/docs/multi_vault_planning.md
blob: fdde2bc50d3e01e16bac5ae5dcc3d342afa17f8a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
https://hackmd.io/JwIwDMDGKQZgtAFgKZjEgbARhPAhgKxZbwAcA7LAWOQCaKEgFA==?edit

Subscribablez(initState)
 .subscribe()
 .emitUpdate(newState)
 //.getState()


var initState = fromDisk()
ReduxStore(reducer, initState)
.reduce(action) -> .emitUpdate()

ReduxStore.subscribe(toDisk)


### KeyChainManager / idStore 2.0 (maybe just in MetaMaskController)
    keychains: []
    getAllAccounts(cb)
    getAllKeychainViewStates(cb) -> returns [ KeyChainViewState]

#### Old idStore external methods, for feature parity:

- init(configManager)
- setStore(ethStore)
- getState()
- getSelectedAddres()
- setSelectedAddress()
- createNewVault()
- recoverFromSeed()
- submitPassword()
- approveTransaction()
- cancelTransaction()
- addUnconfirmedMessage(msgParams, cb)
- signMessage()
- cancelMessage()
- setLocked()
- clearSeedWordCache()
- exportAccount()
- revealAccount()
- saveAccountLabel()
- tryPassword()
- recoverSeed()
- getNetwork()

##### Of those methods

Where they should end up:

##### MetaMaskController

- getNetwork()

##### KeyChainManager

- init(configManager)
- setStore(ethStore)
- getState() // Deprecate for unidirectional flow
- on('update', cb)
- createNewVault(password)
- getSelectedAddres()
- setSelectedAddress()
- submitPassword()
- tryPassword()
- approveTransaction()
- cancelTransaction()
- signMessage()
- cancelMessage()
- setLocked()
- exportAccount()

##### Bip44 KeyChain

- getState() // Deprecate for unidirectional flow
- on('update', cb)

If we adopt a ReactStore style unidirectional action dispatching data flow, these methods will be unified under a `dispatch` method, and rather than having a cb will emit an update to the UI:

- createNewKeyChain(entropy)
- recoverFromSeed()
- approveTransaction()
- signMessage()
- clearSeedWordCache()
- exportAccount()
- revealAccount()
- saveAccountLabel()
- recoverSeed()

Additional methods, new to this:
- serialize()
  - Returns pojo with optional `secret` key whose contents will be encrypted with the users' password and salt when written to disk.
  - The isolation of secrets is to preserve performance when decrypting user data.
- deserialize(pojo)

### KeyChain (ReduxStore?)
    // attributes
    @name

    signTx(txParams, cb)
    signMsg(msg, cb)

    getAddressList(cb)

    getViewState(cb) -> returns KeyChainViewState

    serialize(cb) -> obj
    deserialize(obj)

  dispatch({ type: <str>, value: <pojo> })


### KeyChainViewState
    // The serialized, renderable keychain data
    accountList: [],
    typeName: 'uPort',
    iconAddress: 'uport.gif',
    internal: {} // Subclass-defined metadata

### KeyChainReactComponent
    // takes a KeyChainViewState

    // Subclasses of this:
    - KeyChainListItemComponent
    - KeyChainInitComponent - Maybe part of the List Item
    - KeyChainAccountHeaderComponent
    - KeyChainConfirmationComponent
    // Account list item, tx confirmation extra data (like a QR code),
    // Maybe an options screen, init screen,

    how to send actions?
    emitAction(keychains.<id>.didInit)


gimmeRemoteKeychain((err, remoteKeychain)=>

)





KeyChainReactComponent({
    keychain
})

Keychain:
    methods:{},
    cachedAccountList: [],
    name: '',


CoinbaseKeychain
    getAccountList


CoinbaseKeychainComponent
   isLoading = true
   keychain.getAccountList(()=>{
     isLoading=false
     accountList=accounts
   })





KeyChainViewState {
    attributes: {
        //mandatory:
        accountList: [],
        typeName: 'uPort',
        iconAddress: 'uport.gif',

        internal: {
            // keychain-specific metadata
            proxyAddresses: {
                0xReal: '0xProxy'
            }
        },
    },
    methods: {
        // arbitrary, internal
    }
}

## A note on the security of arbitrary action dispatchers

Since keychains will be dispatching actions that are then passed through the background process to be routed, we should not trust or require them to include their own keychain ID as a prefix to their action, but we should tack it on ourselves, so that no action dispatched by a KeyChainComponent ever reaches any KeyChain other than its own.