Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Elixxir dApps SDK Swift
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile
iOS
Elixxir dApps SDK Swift
Commits
b2ccecfa
"git@git.xx.network:elixxir/integration.git" did not exist on "47305d22872ad225550561c58c9a3087abf2f824"
Commit
b2ccecfa
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Add CMixManagerRestore functor
parent
b5ae112e
No related branches found
No related tags found
1 merge request
!102
Release 1.0.0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Sources/ElixxirDAppsSDK/CmixManager/CMixManager.swift
+13
-1
13 additions, 1 deletion
Sources/ElixxirDAppsSDK/CmixManager/CMixManager.swift
Sources/ElixxirDAppsSDK/CmixManager/Functors/CMixManagerRestore.swift
+46
-0
46 additions, 0 deletions
...xirDAppsSDK/CmixManager/Functors/CMixManagerRestore.swift
with
59 additions
and
1 deletion
Sources/ElixxirDAppsSDK/CmixManager/CMixManager.swift
+
13
−
1
View file @
b2ccecfa
...
...
@@ -3,6 +3,7 @@ import Bindings
public
struct
CMixManager
{
public
var
hasStorage
:
CMixManagerHasStorage
public
var
create
:
CMixManagerCreate
public
var
restore
:
CMixManagerRestore
public
var
load
:
CMixManagerLoad
public
var
remove
:
CMixManagerRemove
}
...
...
@@ -21,7 +22,8 @@ extension CMixManager {
passwordStorage
:
PasswordStorage
,
newCMix
:
NewCMix
=
.
live
,
getCMixParams
:
GetCMixParams
=
.
liveDefault
,
loadCMix
:
LoadCMix
=
.
live
loadCMix
:
LoadCMix
=
.
live
,
newCMixFromBackup
:
NewCMixFromBackup
=
.
live
)
->
CMixManager
{
CMixManager
(
hasStorage
:
.
live
(
...
...
@@ -39,6 +41,15 @@ extension CMixManager {
getCMixParams
:
getCMixParams
,
loadCMix
:
loadCMix
),
restore
:
.
live
(
environment
:
environment
,
downloadNDF
:
downloadNDF
,
generateSecret
:
generateSecret
,
passwordStorage
:
passwordStorage
,
directoryPath
:
directoryPath
,
fileManager
:
fileManager
,
newCMixFromBackup
:
newCMixFromBackup
),
load
:
.
live
(
directoryPath
:
directoryPath
,
passwordStorage
:
passwordStorage
,
...
...
@@ -57,6 +68,7 @@ extension CMixManager {
public
static
let
unimplemented
=
CMixManager
(
hasStorage
:
.
unimplemented
,
create
:
.
unimplemented
,
restore
:
.
unimplemented
,
load
:
.
unimplemented
,
remove
:
.
unimplemented
)
...
...
This diff is collapsed.
Click to expand it.
Sources/ElixxirDAppsSDK/CmixManager/Functors/CMixManagerRestore.swift
0 → 100644
+
46
−
0
View file @
b2ccecfa
import
Foundation
import
XCTestDynamicOverlay
public
struct
CMixManagerRestore
{
public
var
run
:
(
Data
,
String
)
throws
->
BackupReport
public
func
callAsFunction
(
backup
:
Data
,
passphrase
:
String
)
throws
->
BackupReport
{
try
run
(
backup
,
passphrase
)
}
}
extension
CMixManagerRestore
{
public
static
func
live
(
environment
:
Environment
,
downloadNDF
:
DownloadAndVerifySignedNdf
,
generateSecret
:
GenerateSecret
,
passwordStorage
:
PasswordStorage
,
directoryPath
:
String
,
fileManager
:
FileManager
,
newCMixFromBackup
:
NewCMixFromBackup
)
->
CMixManagerRestore
{
CMixManagerRestore
{
backup
,
passphrase
in
let
ndfData
=
try
downloadNDF
(
environment
)
let
password
=
generateSecret
()
try
passwordStorage
.
save
(
password
)
try
?
fileManager
.
removeItem
(
atPath
:
directoryPath
)
try
?
fileManager
.
createDirectory
(
atPath
:
directoryPath
,
withIntermediateDirectories
:
true
)
return
try
newCMixFromBackup
(
ndfJSON
:
String
(
data
:
ndfData
,
encoding
:
.
utf8
)
!
,
storageDir
:
directoryPath
,
backupPassphrase
:
passphrase
,
sessionPassword
:
password
,
backupFileContents
:
backup
)
}
}
}
extension
CMixManagerRestore
{
public
static
let
unimplemented
=
CMixManagerRestore
(
run
:
XCTUnimplemented
(
"
\(
Self
.
self
)
"
)
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment