Skip to content

Commit d28b8b7

Browse files
committed
Remove Never usage
this is a try to fix the chaos `Never` introduced inside this library, there is a high chance change below is the final source. swiftlang/swift#64899 At least unit test passes after it removed.
1 parent cc014e4 commit d28b8b7

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

Sources/EOSIO/ABICodable.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,18 +164,6 @@ public struct BinaryExtension<Value: ABICodable>: ABICodable {
164164
extension BinaryExtension: Equatable where Value: Equatable {}
165165
extension BinaryExtension: Hashable where Value: Hashable {}
166166

167-
extension Never: ABICodable {
168-
public init(from decoder: Decoder) throws {
169-
let ctx = DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Attempted to decode Never")
170-
throw DecodingError.dataCorrupted(ctx)
171-
}
172-
173-
public func encode(to encoder: Encoder) throws {
174-
let ctx = EncodingError.Context(codingPath: encoder.codingPath, debugDescription: "Attempted to encode Never")
175-
throw EncodingError.invalidValue(self, ctx)
176-
}
177-
}
178-
179167
// MARK: Dynamic ABI Coding
180168

181169
public extension CodingUserInfoKey {

Sources/EOSIO/Chain/ABI.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,11 @@ public extension ABI {
307307
let errorCode: UInt64
308308
let errorMsg: String
309309
}
310+
311+
private struct ExtensionsEntry: ABICodable, Equatable, Hashable {
312+
let errorCode: UInt16
313+
let errorMsg: Data
314+
}
310315
}
311316

312317
// MARK: ABI Coding
@@ -345,7 +350,7 @@ extension ABI: ABICodable {
345350
self.tables = try decoder.decode([ABI.Table].self)
346351
self.ricardianClauses = try decoder.decode([ABI.Clause].self)
347352
_ = try decoder.decode([ABI.ErrorMessage].self) // ignore error messages, used only by abi compiler
348-
_ = try decoder.decode([Never].self) // abi extensions not used
353+
_ = try decoder.decode([ABI.ExtensionsEntry].self) // abi extensions not used
349354
// decode variant typedefs (Y U NO USE EXTENSIONS?!)
350355
do {
351356
self.variants = try decoder.decode([ABI.Variant].self)
@@ -362,8 +367,8 @@ extension ABI: ABICodable {
362367
try container.encode(self.actions, forKey: .actions)
363368
try container.encode(self.tables, forKey: .tables)
364369
try container.encode(self.ricardianClauses, forKey: .ricardianClauses)
365-
try container.encode([] as [Never], forKey: .errorMessages)
366-
try container.encode([] as [Never], forKey: .abiExtensions)
370+
try container.encode([] as [ABI.ErrorMessage], forKey: .errorMessages)
371+
try container.encode([] as [ABI.ExtensionsEntry], forKey: .abiExtensions)
367372
try container.encode(self.variants, forKey: .variants)
368373
}
369374
}

0 commit comments

Comments
 (0)