Sale Djenic f1e3ae5b46 feat: sync and backup wallet accounts
Changes applied here introduce:
- improvements to sync wallet accounts among devices (including all account types)
- backing up wallet accounts to and fetch them from waku (an information about received
wallet accounts is sent via `waku.backedup.wallet-account` signal to a client)
2023-04-21 16:35:24 +02:00

38 lines
1.4 KiB
Go

package wakusync
import (
"encoding/json"
"github.com/status-im/status-go/multiaccounts/accounts"
"github.com/status-im/status-go/multiaccounts/keypairs"
"github.com/status-im/status-go/multiaccounts/settings"
"github.com/status-im/status-go/protocol/protobuf"
)
type WakuBackedUpDataResponse struct {
FetchingDataProgress map[string]protobuf.FetchingBackedUpDataDetails // key represents the data/section backup details refer to
Profile *BackedUpProfile
Setting *settings.SyncSettingField
Keycards []*keypairs.KeyPair
WalletAccount *accounts.Account
}
func (sfwr *WakuBackedUpDataResponse) MarshalJSON() ([]byte, error) {
responseItem := struct {
FetchingDataProgress map[string]FetchingBackupedDataDetails `json:"fetchingBackedUpDataProgress,omitempty"`
Profile *BackedUpProfile `json:"backedUpProfile,omitempty"`
Setting *settings.SyncSettingField `json:"backedUpSettings,omitempty"`
Keycards []*keypairs.KeyPair `json:"backedUpKeycards,omitempty"`
WalletAccount *accounts.Account `json:"backedUpWalletAccount,omitempty"`
}{
Profile: sfwr.Profile,
Setting: sfwr.Setting,
Keycards: sfwr.Keycards,
WalletAccount: sfwr.WalletAccount,
}
responseItem.FetchingDataProgress = sfwr.FetchingBackedUpDataDetails()
return json.Marshal(responseItem)
}