2021-09-08 18:05:39 +00:00
|
|
|
{.used.}
|
|
|
|
|
2021-10-01 16:53:38 +00:00
|
|
|
import json_serialization, json
|
2021-09-08 18:05:39 +00:00
|
|
|
|
|
|
|
import ../../eventemitter
|
2021-10-01 16:53:38 +00:00
|
|
|
import ./identity_image
|
|
|
|
import ./profile
|
2021-09-08 18:05:39 +00:00
|
|
|
|
2021-10-01 16:53:38 +00:00
|
|
|
include ./multi_accounts
|
2021-09-08 18:05:39 +00:00
|
|
|
export identity_image
|
|
|
|
|
|
|
|
type
|
|
|
|
Account* = ref object of RootObj
|
|
|
|
name*: string
|
|
|
|
keyUid* {.serializedFieldName("key-uid").}: string
|
|
|
|
identityImage*: IdentityImage
|
|
|
|
identicon*: string
|
|
|
|
|
|
|
|
type
|
|
|
|
NodeAccount* = ref object of Account
|
|
|
|
timestamp*: int
|
|
|
|
keycardPairing* {.serializedFieldName("keycard-pairing").}: string
|
|
|
|
|
|
|
|
type
|
|
|
|
GeneratedAccount* = ref object
|
|
|
|
publicKey*: string
|
|
|
|
address*: string
|
|
|
|
id*: string
|
|
|
|
mnemonic*: string
|
|
|
|
derived*: MultiAccounts
|
|
|
|
# FIXME: should inherit from Account but multiAccountGenerateAndDeriveAddresses
|
|
|
|
# response has a camel-cased properties like "publicKey" and "keyUid", so the
|
|
|
|
# serializedFieldName pragma would need to be different
|
|
|
|
name*: string
|
|
|
|
keyUid*: string
|
|
|
|
identicon*: string
|
|
|
|
identityImage*: IdentityImage
|
|
|
|
|
|
|
|
proc toAccount*(account: GeneratedAccount): Account =
|
|
|
|
result = Account(name: account.name, identityImage: account.identityImage, identicon: account.identicon, keyUid: account.keyUid)
|
|
|
|
|
|
|
|
proc toAccount*(account: NodeAccount): Account =
|
|
|
|
result = Account(name: account.name, identityImage: account.identityImage, identicon: account.identicon, keyUid: account.keyUid)
|
|
|
|
|
|
|
|
type AccountArgs* = ref object of Args
|
2021-10-01 16:53:38 +00:00
|
|
|
account*: Account
|
|
|
|
|
|
|
|
proc toProfile*(account: Account): Profile =
|
|
|
|
result = Profile(
|
|
|
|
id: "",
|
|
|
|
username: account.name,
|
|
|
|
identicon: account.identicon,
|
|
|
|
alias: account.name,
|
|
|
|
ensName: "",
|
|
|
|
ensVerified: false,
|
2021-10-05 20:10:45 +00:00
|
|
|
appearance: 0
|
2021-10-01 16:53:38 +00:00
|
|
|
)
|