Skip to content

Commit

Permalink
Update xdr
Browse files Browse the repository at this point in the history
  • Loading branch information
Volendi committed Mar 4, 2020
1 parent ea7c33f commit c5515ff
Show file tree
Hide file tree
Showing 342 changed files with 9,315 additions and 1,518 deletions.
17 changes: 17 additions & 0 deletions Example/Tests/XDREncodingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,23 @@ class XDREncodingTests: XCTestCase {

return xdr
}

init(xdrData: inout Data) throws {
let discriminant = try Int32(xdrData: &xdrData)

switch discriminant {
case 0:
let data = try Int64(xdrData: &xdrData)
self = .a(data)
case 1:
let data = try Int32(xdrData: &xdrData)
self = .b(data)
case 2:
self = .c
default:
throw XDRErrors.unknownEnumCase
}
}
}

XCTAssertEqual(TestDescriminatedUnion.a(1).toXDR().base64, "AAAAAAAAAAAAAAAB")
Expand Down
4 changes: 4 additions & 0 deletions Example/Tests/XDRTypesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class XDRTypesTests: XCTestCase {
let op = Operation(sourceAccount: nil, body: Operation.OperationBody.manageBalance(manageBalanceOp))

XCTAssertEqual(op.toXDR().base64, "AAAAAAAAAAkAAAAAAAAAAHteR0/xHy/UY52BNKpS2XhbRQ9sVCsVfrSwiwW7X7B9AAAAA09MRwAAAAAA")
// Decoding
XCTAssertEqual(try! Operation(xdrBase64: "AAAAAAAAAAkAAAAAAAAAAHteR0/xHy/UY52BNKpS2XhbRQ9sVCsVfrSwiwW7X7B9AAAAA09MRwAAAAAA").toXdrBase64String(), "AAAAAAAAAAkAAAAAAAAAAHteR0/xHy/UY52BNKpS2XhbRQ9sVCsVfrSwiwW7X7B9AAAAA09MRwAAAAAA")
}

func testDeleteBalanceOp() {
Expand All @@ -37,6 +39,8 @@ class XDRTypesTests: XCTestCase {
let op = Operation(sourceAccount: nil, body: Operation.OperationBody.manageBalance(manageBalanceOp))

XCTAssertEqual(op.toXDR().base64, "AAAAAAAAAAkAAAABAAAAAHteR0/xHy/UY52BNKpS2XhbRQ9sVCsVfrSwiwW7X7B9AAAAA09MRwAAAAAA")
// Decoding
XCTAssertEqual(try! Operation(xdrBase64: "AAAAAAAAAAkAAAABAAAAAHteR0/xHy/UY52BNKpS2XhbRQ9sVCsVfrSwiwW7X7B9AAAAA09MRwAAAAAA").toXdrBase64String(), "AAAAAAAAAAkAAAABAAAAAHteR0/xHy/UY52BNKpS2XhbRQ9sVCsVfrSwiwW7X7B9AAAAA09MRwAAAAAA")
}
}

Expand Down
17 changes: 16 additions & 1 deletion Sources/TokenDWallet/Xdr/AMLAlertDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Foundation
// };

// ===========================================================================
public struct AMLAlertDetails: XDREncodable {
public struct AMLAlertDetails: XDRCodable {
public var comment: String
public var ext: AMLAlertDetailsExt

Expand All @@ -40,6 +40,11 @@ public struct AMLAlertDetails: XDREncodable {
return xdr
}

public init(xdrData: inout Data) throws {
self.comment = try String(xdrData: &xdrData)
self.ext = try AMLAlertDetailsExt(xdrData: &xdrData)
}

public enum AMLAlertDetailsExt: XDRDiscriminatedUnion {
case emptyVersion()

Expand All @@ -61,5 +66,15 @@ public struct AMLAlertDetails: XDREncodable {
return xdr
}

public init(xdrData: inout Data) throws {
let discriminant = try Int32(xdrData: &xdrData)

switch discriminant {
case LedgerVersion.emptyVersion.rawValue: self = .emptyVersion()
default:
throw XDRErrors.unknownEnumCase
}
}

}
}
19 changes: 18 additions & 1 deletion Sources/TokenDWallet/Xdr/AMLAlertRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Foundation
// };

// ===========================================================================
public struct AMLAlertRequest: XDREncodable {
public struct AMLAlertRequest: XDRCodable {
public var balanceID: BalanceID
public var amount: Uint64
public var creatorDetails: Longstring
Expand Down Expand Up @@ -55,6 +55,13 @@ public struct AMLAlertRequest: XDREncodable {
return xdr
}

public init(xdrData: inout Data) throws {
self.balanceID = try BalanceID(xdrData: &xdrData)
self.amount = try Uint64(xdrData: &xdrData)
self.creatorDetails = try Longstring(xdrData: &xdrData)
self.ext = try AMLAlertRequestExt(xdrData: &xdrData)
}

public enum AMLAlertRequestExt: XDRDiscriminatedUnion {
case emptyVersion()

Expand All @@ -76,5 +83,15 @@ public struct AMLAlertRequest: XDREncodable {
return xdr
}

public init(xdrData: inout Data) throws {
let discriminant = try Int32(xdrData: &xdrData)

switch discriminant {
case LedgerVersion.emptyVersion.rawValue: self = .emptyVersion()
default:
throw XDRErrors.unknownEnumCase
}
}

}
}
80 changes: 0 additions & 80 deletions Sources/TokenDWallet/Xdr/ASwapBidCreationRequest.swift

This file was deleted.

69 changes: 0 additions & 69 deletions Sources/TokenDWallet/Xdr/ASwapBidQuoteAsset.swift

This file was deleted.

120 changes: 0 additions & 120 deletions Sources/TokenDWallet/Xdr/ASwapExtended.swift

This file was deleted.

Loading

0 comments on commit c5515ff

Please sign in to comment.