-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from soramitsu/develop
v0.10.0
- Loading branch information
Showing
40 changed files
with
2,356 additions
and
566 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Foundation | ||
|
||
public class AliasNode: Node { | ||
public let typeName: String | ||
public let underlyingTypeName: String | ||
|
||
public init(typeName: String, underlyingTypeName: String) { | ||
self.typeName = typeName | ||
self.underlyingTypeName = underlyingTypeName | ||
} | ||
|
||
public func accept(encoder: DynamicScaleEncoding, value: JSON) throws { | ||
try encoder.append(json: value, type: underlyingTypeName) | ||
} | ||
|
||
public func accept(decoder: DynamicScaleDecoding) throws -> JSON { | ||
try decoder.read(type: underlyingTypeName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
35 changes: 35 additions & 0 deletions
35
FearlessUtils/Classes/Runtime/Nodes/Items/KeyValueNode.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Foundation | ||
|
||
public class KeyValueNode: Node { | ||
public let typeName: String | ||
|
||
public init(typeName: String) { | ||
self.typeName = typeName | ||
} | ||
|
||
public func accept(encoder: DynamicScaleEncoding, value: JSON) throws { | ||
guard let mapping = value.dictValue else { | ||
throw DynamicScaleEncoderError.dictExpected(json: value) | ||
} | ||
|
||
let tuples: [ScaleTuple<String, String>] = try mapping.enumerated().map { (_, element) in | ||
guard let value = element.value.stringValue else { | ||
throw DynamicScaleEncoderError.stringExpected(json: element.value) | ||
} | ||
|
||
return ScaleTuple(first: element.key, second: value) | ||
} | ||
|
||
try encoder.append(encodable: tuples) | ||
} | ||
|
||
public func accept(decoder: DynamicScaleDecoding) throws -> JSON { | ||
let tuples: [ScaleTuple<String, String>] = try decoder.read() | ||
|
||
let mapping = tuples.reduce(into: [String: JSON]()) { (result, item) in | ||
result[item.first] = .stringValue(item.second) | ||
} | ||
|
||
return .dictionaryValue(mapping) | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
FearlessUtils/Classes/Runtime/Nodes/Items/MappingNode+Generic.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import Foundation | ||
|
||
public extension MappingNode { | ||
static var consensus: MappingNode { | ||
MappingNode( | ||
typeName: GenericType.consensus.rawValue, | ||
typeMapping: [ | ||
NamedType(name: "engineId", type: GenericType.consensusEngineId.name), | ||
NamedType(name: "data", type: GenericType.bytes.rawValue) | ||
]) | ||
} | ||
|
||
static var seal: MappingNode { | ||
MappingNode( | ||
typeName: GenericType.seal.rawValue, | ||
typeMapping: [ | ||
NamedType(name: "engineId", type: GenericType.consensusEngineId.name), | ||
NamedType(name: "data", type: GenericType.bytes.rawValue) | ||
]) | ||
} | ||
|
||
static var sealv0: MappingNode { | ||
MappingNode( | ||
typeName: GenericType.sealv0.rawValue, | ||
typeMapping: [ | ||
NamedType(name: "slot", type: PrimitiveType.u64.rawValue), | ||
NamedType(name: "signature", type: GenericType.signature.rawValue) | ||
]) | ||
} | ||
|
||
static var preRuntime: MappingNode { | ||
MappingNode( | ||
typeName: GenericType.preRuntime.rawValue, | ||
typeMapping: [ | ||
NamedType(name: "engineId", type: GenericType.consensusEngineId.name), | ||
NamedType(name: "data", type: GenericType.bytes.rawValue) | ||
]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,3 +97,5 @@ public struct NullCodable<T: Codable>: Codable { | |
} | ||
} | ||
} | ||
|
||
extension NullCodable: Equatable where T: Equatable {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.