refactor/extract generateMultiAccounts method
This commit is contained in:
parent
6c03369ca2
commit
61b5d6e311
|
@ -63,14 +63,9 @@ proc generateRandomAccountAndLogin*(self: AccountModel) =
|
||||||
proc storeAccountAndLogin*(self: AccountModel, selectedAccountIndex: int, password: string): string =
|
proc storeAccountAndLogin*(self: AccountModel, selectedAccountIndex: int, password: string): string =
|
||||||
let account: GeneratedAccount = self.generatedAddresses[selectedAccountIndex]
|
let account: GeneratedAccount = self.generatedAddresses[selectedAccountIndex]
|
||||||
let password = "0x" & $keccak_256.digest(password)
|
let password = "0x" & $keccak_256.digest(password)
|
||||||
let multiAccount = %* {
|
|
||||||
"accountID": account.id,
|
let multiAccounts = status_accounts.generateMultiAccounts(%account, password)
|
||||||
"paths": [constants.PATH_WALLET_ROOT, constants.PATH_EIP_1581, constants.PATH_WHISPER,
|
|
||||||
constants.PATH_DEFAULT_WALLET],
|
|
||||||
"password": password
|
|
||||||
}
|
|
||||||
let storeResult = $libstatus.multiAccountStoreDerivedAccounts($multiAccount);
|
|
||||||
let multiAccounts = storeResult.parseJson
|
|
||||||
let whisperPubKey = account.derived[constants.PATH_WHISPER]["publicKey"].getStr
|
let whisperPubKey = account.derived[constants.PATH_WHISPER]["publicKey"].getStr
|
||||||
let alias = $libstatus.generateAlias(whisperPubKey.toGoString)
|
let alias = $libstatus.generateAlias(whisperPubKey.toGoString)
|
||||||
let identicon = $libstatus.identicon(whisperPubKey.toGoString)
|
let identicon = $libstatus.identicon(whisperPubKey.toGoString)
|
||||||
|
|
|
@ -84,30 +84,23 @@ proc saveAccountAndLogin*(multiAccounts: JsonNode, alias: string, identicon: str
|
||||||
echo "Account saved succesfully"
|
echo "Account saved succesfully"
|
||||||
subaccountData
|
subaccountData
|
||||||
|
|
||||||
proc setupRandomTestAccount*(): string =
|
proc generateMultiAccounts*(account: JsonNode, password: string): JsonNode =
|
||||||
var result: string
|
|
||||||
# 3
|
|
||||||
let multiAccountConfig = %* {
|
|
||||||
"n": 5,
|
|
||||||
"mnemonicPhraseLength": 12,
|
|
||||||
"bip39Passphrase": "",
|
|
||||||
"paths": ["m/43'/60'/1581'/0'/0", "m/44'/60'/0'/0/0"]
|
|
||||||
}
|
|
||||||
result = $libstatus.multiAccountGenerateAndDeriveAddresses(
|
|
||||||
$multiAccountConfig);
|
|
||||||
let generatedAddresses = result.parseJson
|
|
||||||
let account0 = generatedAddresses[0]
|
|
||||||
|
|
||||||
# 4
|
|
||||||
let password = "0x2cd9bf92c5e20b1b410f5ace94d963a96e89156fbe65b70365e8596b37f1f165" #qwerty
|
|
||||||
let multiAccount = %* {
|
let multiAccount = %* {
|
||||||
"accountID": account0["id"].getStr,
|
"accountID": account["id"].getStr,
|
||||||
"paths": ["m/44'/60'/0'/0", "m/43'/60'/1581'", "m/43'/60'/1581'/0'/0",
|
"paths": ["m/44'/60'/0'/0", "m/43'/60'/1581'", "m/43'/60'/1581'/0'/0", "m/44'/60'/0'/0/0"],
|
||||||
"m/44'/60'/0'/0/0"],
|
|
||||||
"password": password
|
"password": password
|
||||||
}
|
}
|
||||||
result = $libstatus.multiAccountStoreDerivedAccounts($multiAccount);
|
var response = $libstatus.multiAccountStoreDerivedAccounts($multiAccount);
|
||||||
let multiAccounts = result.parseJson
|
result = response.parseJson
|
||||||
|
|
||||||
|
proc setupRandomTestAccount*(): string =
|
||||||
|
var result: string
|
||||||
|
|
||||||
|
let generatedAddresses = generateAddresses().parseJson
|
||||||
|
|
||||||
|
let account0 = generatedAddresses[0]
|
||||||
|
let password = "0x2cd9bf92c5e20b1b410f5ace94d963a96e89156fbe65b70365e8596b37f1f165" #qwertyh
|
||||||
|
let multiAccounts = generateMultiAccounts(account0, password)
|
||||||
|
|
||||||
# 5
|
# 5
|
||||||
let accountData = %* {
|
let accountData = %* {
|
||||||
|
@ -315,6 +308,8 @@ proc setupRandomTestAccount*(): string =
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# let alias = $libstatus.generateAlias(whisperPubKey.toGoString)
|
||||||
|
# let identicon = $libstatus.identicon(whisperPubKey.toGoString)
|
||||||
var alias = "Delectable Overjoyed Nauplius"
|
var alias = "Delectable Overjoyed Nauplius"
|
||||||
var identicon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAmElEQVR4nOzX4QmAIBBA4Yp2aY52aox2ao6mqf+SoajwON73M0J4HBy6TEEYQmMIjSE0htCECVlbDziv+/n6fuzb3OP/UmEmYgiNITRNm+LPqO2UE2YihtAYQlN818ptoZzau1btOakwEzGExhCa5hdi7d2p1zZLhZmIITSG0PhCpDGExhANEmYihtAYQmMIjSE0bwAAAP//kHQdRIWYzToAAAAASUVORK5CYII="
|
var identicon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAmElEQVR4nOzX4QmAIBBA4Yp2aY52aox2ao6mqf+SoajwON73M0J4HBy6TEEYQmMIjSE0htCECVlbDziv+/n6fuzb3OP/UmEmYgiNITRNm+LPqO2UE2YihtAYQlN818ptoZzau1btOakwEzGExhCa5hdi7d2p1zZLhZmIITSG0PhCpDGExhANEmYihtAYQmMIjSE0bwAAAP//kHQdRIWYzToAAAAASUVORK5CYII="
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue