(keyringId)
| 157 | * @return {KeyringBase} |
| 158 | */ |
| 159 | export async function createKeyring(keyringId) { |
| 160 | await keyringInitialized; |
| 161 | if (keyringAttr.has(keyringId)) { |
| 162 | throw new MvError(`Keyring for id ${keyringId} already exists.`, 'KEYRING_ALREADY_EXISTS'); |
| 163 | } |
| 164 | // persist keyring attributes |
| 165 | await keyringAttr.create(keyringId); |
| 166 | try { |
| 167 | // instantiate keyring |
| 168 | const keyRng = await buildKeyring(keyringId); |
| 169 | return keyRng; |
| 170 | } catch (e) { |
| 171 | // cleanup |
| 172 | await keyringAttr.delete(keyringId); |
| 173 | throw e; |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * Instantiate a new keyring object, keys are loaded from the keystore |
no test coverage detected