-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ABW-3230] Update Wallet Interaction models (#162)
* wip * wip * wip * wip * change WalletInteractionId from UUID to String * Revert "wip" This reverts commit 3ea7600. * wip * wip * wip * fix kotlin tests * wip * wip * wip * wip * revert sample values * fix * address comments * address comments * address comments * address comments * Bump to 1.0.11 * export new_wallet_interaction_version_current
- Loading branch information
1 parent
b1fb6d6
commit 4152cd3
Showing
49 changed files
with
827 additions
and
129 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "sargon" | ||
version = "1.0.10" | ||
version = "1.0.11" | ||
edition = "2021" | ||
build = "build.rs" | ||
|
||
|
12 changes: 12 additions & 0 deletions
12
...ds/RadixConnect/WalletInteraction/DappToWalletInteractionUnvalidated+Wrap+Functions.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,12 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension DappToWalletInteractionUnvalidated { | ||
public func toJSONString(prettyPrinted: Bool = false) -> String { | ||
dappToWalletInteractionUnvalidatedToJsonString(interactionUnvalidated: self, prettyPrinted: prettyPrinted) | ||
} | ||
|
||
public init(jsonString: String) throws { | ||
self = try newDappToWalletInteractionUnvalidatedFromJsonString(jsonStr: jsonString) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...ethods/RadixConnect/WalletInteraction/UnvalidatedTransactionManifest+Wrap+Functions.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,15 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension UnvalidatedTransactionManifest { | ||
public init(manifest: TransactionManifest) { | ||
self = newUnvalidatedTransactionManifestFromTransactionManifest(transactionManifest: manifest) | ||
} | ||
|
||
public func transactionManifest(onNetwork networkID: NetworkID) throws -> TransactionManifest { | ||
try newTransactionManifestFromUnvalidatedTransactionManifest( | ||
unvalidatedTransactionManifest: self, | ||
networkId: networkID | ||
) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...thods/RadixConnect/WalletInteraction/WalletToDappInteractionResponse+Wrap+Functions.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,12 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension WalletToDappInteractionResponse { | ||
public init(jsonData: some DataProtocol) throws { | ||
self = try newWalletToDappInteractionResponseFromJsonBytes(jsonBytes: Data(jsonData)) | ||
} | ||
|
||
public func jsonData() -> Data { | ||
walletToDappInteractionResponseToJsonBytes(walletToDappInteractionResponse: self) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...rces/Sargon/Extensions/Methods/RadixConnect/WalletInteractionVersion+Wrap+Functions.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,6 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension WalletInteractionVersion { | ||
public static let current: Self = newWalletInteractionVersionCurrent() | ||
} |
12 changes: 12 additions & 0 deletions
12
...argon/Extensions/Methods/RadixConnect/WalletInteractionWalletAccount+Wrap+Functions.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,12 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension WalletInteractionWalletAccount { | ||
public init(jsonData: some DataProtocol) throws { | ||
self = try newWalletInteractionWalletAccountFromJsonBytes(jsonBytes: Data(jsonData)) | ||
} | ||
|
||
public func jsonData() -> Data { | ||
walletInteractionWalletAccountToJsonBytes(walletInteractionWalletAccount: self) | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...lues/RadixConnect/WalletInteraction/DappToWalletInteractionUnvalidated+SampleValues.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,9 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
#if DEBUG | ||
extension DappToWalletInteractionUnvalidated { | ||
public static let sample: Self = newDappToWalletInteractionUnvalidatedSample() | ||
public static let sampleOther: Self = newDappToWalletInteractionUnvalidatedSampleOther() | ||
} | ||
#endif // DEBUG |
9 changes: 9 additions & 0 deletions
9
...leValues/RadixConnect/WalletInteraction/UnvalidatedTransactionManifest+SampleValues.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,9 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
#if DEBUG | ||
extension UnvalidatedTransactionManifest { | ||
public static let sample: Self = newUnvalidatedTransactionManifestSample() | ||
public static let sampleOther: Self = newUnvalidatedTransactionManifestSampleOther() | ||
} | ||
#endif // DEBUG |
9 changes: 9 additions & 0 deletions
9
...eValues/RadixConnect/WalletInteraction/WalletToDappInteractionResponse+SampleValues.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,9 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
#if DEBUG | ||
extension WalletToDappInteractionResponse { | ||
public static let sample: Self = newWalletToDappInteractionResponseSample() | ||
public static let sampleOther: Self = newWalletToDappInteractionResponseSampleOther() | ||
} | ||
#endif // DEBUG |
9 changes: 9 additions & 0 deletions
9
...on/Extensions/SampleValues/RadixConnect/WalletInteractionWalletAccount+SampleValues.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,9 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
#if DEBUG | ||
extension WalletInteractionWalletAccount { | ||
public static let sample: Self = newWalletInteractionWalletAccountSample() | ||
public static let sampleOther: Self = newWalletInteractionWalletAccountSampleOther() | ||
} | ||
#endif // DEBUG |
4 changes: 4 additions & 0 deletions
4
...tified/RadixConnect/WalletInteraction/DappToWalletInteractionUnvalidated+Swiftified.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,4 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension DappToWalletInteractionUnvalidated: SargonModel {} |
4 changes: 4 additions & 0 deletions
4
...Swiftified/RadixConnect/WalletInteraction/UnvalidatedTransactionManifest+Swiftified.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,4 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension UnvalidatedTransactionManifest: SargonModel {} |
5 changes: 5 additions & 0 deletions
5
...wiftified/RadixConnect/WalletInteraction/WalletToDappInteractionResponse+Swiftified.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,5 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension WalletToDappInteractionResponse: SargonModel {} | ||
extension WalletToDappInteractionResponse: SargonObjectCodable {} |
5 changes: 5 additions & 0 deletions
5
...Sargon/Extensions/Swiftified/RadixConnect/WalletInteractionWalletAccount+Swiftified.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,5 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension WalletInteractionWalletAccount: SargonModel {} | ||
extension WalletInteractionWalletAccount: SargonObjectCodable {} |
21 changes: 21 additions & 0 deletions
21
...ts/TestCases/RadixConnect/WalletInteraction/DappToWalletInteractionUnvalidatedTests.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,21 @@ | ||
import CustomDump | ||
import Foundation | ||
import Sargon | ||
import SargonUniFFI | ||
import XCTest | ||
|
||
final class DappToWalletInteractionUnvalidatedTests: Test<DappToWalletInteractionUnvalidated> { | ||
func test_json_roundtrip() throws { | ||
func doTest(sut: SUT, json: String) throws { | ||
let encoded = sut.toJSONString(prettyPrinted: false) | ||
XCTAssertEqual(encoded, json) | ||
let decoded = try SUT(jsonString: json) | ||
XCTAssertEqual(decoded, sut) | ||
} | ||
|
||
try SUT.sampleValues.forEach { sample in | ||
let json = sample.toJSONString(prettyPrinted: false) | ||
try doTest(sut: sample, json: json) | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
.../Tests/TestCases/RadixConnect/WalletInteraction/UnvalidatedTransactionManifestTests.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,13 @@ | ||
import CustomDump | ||
import Foundation | ||
import Sargon | ||
import SargonUniFFI | ||
import XCTest | ||
|
||
final class UnvalidatedTransactionManifestTests: Test<UnvalidatedTransactionManifest> { | ||
func testTransactionManifestOnNetwork() throws { | ||
let instance = SUT(manifest: .sample) | ||
let result = try instance.transactionManifest(onNetwork: .sample) | ||
XCTAssertEqual(result, TransactionManifest.sample) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...Tests/TestCases/RadixConnect/WalletInteraction/WalletToDappInteractionResponseTests.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,21 @@ | ||
import CustomDump | ||
import Foundation | ||
import Sargon | ||
import SargonUniFFI | ||
import XCTest | ||
|
||
final class WalletToDappInteractionResponseTests: Test<WalletToDappInteractionResponse> { | ||
func test_codable() throws { | ||
let json = try openFile(subPath: "vector", "wallet_interactions_wallet_to_dapp", extension: "json") | ||
let sut = try JSONDecoder().decode([SUT].self, from: json) | ||
let encoded = try JSONEncoder().encode(sut) | ||
try XCTAssertEqual(JSONDecoder().decode([SUT].self, from: encoded), sut) | ||
} | ||
|
||
/// Cyon: We might be able remove this function once we have converted to `swift-testing` which has much more | ||
/// powerful discovery than XCTest, and maybe `eachSampleCodableRoundtripTest` will be picked up as | ||
/// a test directly. | ||
func testJSONRoundtripAllSamples() throws { | ||
try eachSampleCodableRoundtripTest() | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
apple/Tests/TestCases/RadixConnect/WalletInteractionWalletAccountTests.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,32 @@ | ||
import CustomDump | ||
import Foundation | ||
import Sargon | ||
import SargonUniFFI | ||
import XCTest | ||
|
||
final class WalletInteractionWalletAccountTests: Test<WalletInteractionWalletAccount> { | ||
func test_codable() throws { | ||
let raw = """ | ||
{ | ||
"address" : "account_rdx128y6j78mt0aqv6372evz28hrxp8mn06ccddkr7xppc88hyvynvjdwr", | ||
"label" : "Spending Account", | ||
"appearanceId" : 0 | ||
} | ||
""".data(using: .utf8)! | ||
|
||
// test decoding | ||
let sut = try JSONDecoder().decode(SUT.self, from: raw) | ||
XCTAssertEqual(sut, SUT.sample) | ||
|
||
// test encoding | ||
let encoded = try JSONEncoder().encode(sut) | ||
try XCTAssertEqual(JSONDecoder().decode(SUT.self, from: encoded), sut) | ||
} | ||
|
||
/// Cyon: We might be able remove this function once we have converted to `swift-testing` which has much more | ||
/// powerful discovery than XCTest, and maybe `eachSampleCodableRoundtripTest` will be picked up as | ||
/// a test directly. | ||
func testJSONRoundtripAllSamples() throws { | ||
try eachSampleCodableRoundtripTest() | ||
} | ||
} |
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 @@ | ||
use crate::prelude::*; | ||
|
||
#[uniffi::export] | ||
pub fn new_wallet_interaction_version_current() -> WalletInteractionVersion { | ||
WalletInteractionVersion::current() | ||
} | ||
|
||
#[cfg(test)] | ||
mod uniffi_tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn current() { | ||
assert_eq!( | ||
new_wallet_interaction_version_current(), | ||
WalletInteractionVersion::current() | ||
) | ||
} | ||
} |
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.