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
10b788a1
Commit
10b788a1
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Add GetFactsFromContact functor
parent
cdeb2d24
No related branches found
No related tags found
2 merge requests
!102
Release 1.0.0
,
!18
Update Bindings
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Sources/ElixxirDAppsSDK/Fact.swift
+39
-0
39 additions, 0 deletions
Sources/ElixxirDAppsSDK/Fact.swift
Sources/ElixxirDAppsSDK/GetFactsFromContact.swift
+30
-0
30 additions, 0 deletions
Sources/ElixxirDAppsSDK/GetFactsFromContact.swift
with
69 additions
and
0 deletions
Sources/ElixxirDAppsSDK/
Legacy/
Fact.swift
→
Sources/ElixxirDAppsSDK/Fact.swift
+
39
−
0
View file @
10b788a1
import
Foundation
public
struct
Fact
:
Equatable
{
public
init
(
fact
:
String
,
...
...
@@ -16,4 +18,22 @@ extension Fact: Codable {
case
fact
=
"Fact"
case
type
=
"Type"
}
static
func
decode
(
_
data
:
Data
)
throws
->
Fact
{
try
JSONDecoder
()
.
decode
(
Self
.
self
,
from
:
data
)
}
func
encode
()
throws
->
Data
{
try
JSONEncoder
()
.
encode
(
self
)
}
}
extension
Array
where
Element
==
Fact
{
static
func
decode
(
_
data
:
Data
)
throws
->
[
Fact
]
{
try
JSONDecoder
()
.
decode
(
Self
.
self
,
from
:
data
)
}
func
encode
()
throws
->
Data
{
try
JSONEncoder
()
.
encode
(
self
)
}
}
This diff is collapsed.
Click to expand it.
Sources/ElixxirDAppsSDK/
Legacy/ContactFactsProvider
.swift
→
Sources/ElixxirDAppsSDK/
GetFactsFromContact
.swift
+
30
−
0
View file @
10b788a1
import
Bindings
import
XCTestDynamicOverlay
public
struct
ContactFactsProvider
{
public
var
get
:
(
Data
)
throws
->
[
Fact
]
public
struct
GetFactsFromContact
{
public
var
run
:
(
Data
)
throws
->
[
Fact
]
public
func
callAsFunction
(
contact
:
Data
)
throws
->
[
Fact
]
{
try
get
(
contact
)
try
run
(
contact
)
}
}
extension
ContactFactsProvider
{
public
static
let
live
=
ContactFactsProvider
{
contact
in
extension
GetFactsFromContact
{
public
static
let
live
=
GetFactsFromContact
{
contact
in
var
error
:
NSError
?
let
factsD
ata
=
BindingsGetFactsFromContact
(
contact
,
&
error
)
let
d
ata
=
BindingsGetFactsFromContact
(
contact
,
&
error
)
if
let
error
=
error
{
throw
error
}
guard
let
factsData
=
factsD
ata
else
{
guard
let
data
=
d
ata
else
{
fatalError
(
"BindingsGetFactsFromContact returned `nil` without providing error"
)
}
let
decoder
=
JSONDecoder
()
let
facts
=
try
decoder
.
decode
([
Fact
]
.
self
,
from
:
factsData
)
return
facts
return
try
[
Fact
]
.
decode
(
data
)
}
}
#if DEBUG
extension
ContactFactsProvider
{
public
static
let
failing
=
ContactFactsProvider
{
_
in
struct
NotImplemented
:
Error
{}
throw
NotImplemented
()
}
extension
GetFactsFromContact
{
public
static
let
unimplemented
=
GetFactsFromContact
(
run
:
XCTUnimplemented
(
"
\(
Self
.
self
)
"
)
)
}
#endif
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