status-lib/status/types/account.nim

58 lines
1.6 KiB
Nim
Raw Normal View History

2021-09-08 18:05:39 +00:00
{.used.}
import json_serialization, json
2021-09-08 18:05:39 +00:00
import ../../eventemitter
import ./identity_image
import ./profile
2021-09-08 18:05:39 +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
account*: Account
proc toProfile*(account: Account): Profile =
result = Profile(
id: "",
username: account.name,
identicon: account.identicon,
alias: account.name,
ensName: "",
ensVerified: false,
appearance: 0
)