From 735267aa0310a5febe66b26023f4041c741a891a Mon Sep 17 00:00:00 2001 From: Kendall Weihe Date: Thu, 1 Aug 2024 10:12:50 -0400 Subject: [PATCH] Rename getExchanges() to getExchangeIds() (#101) --- .../tbdex_uniffi/src/http_client/exchanges.rs | 4 +-- bindings/tbdex_uniffi/src/lib.rs | 2 +- bindings/tbdex_uniffi/src/tbdex.udl | 2 +- .../kotlin/tbdex/sdk/httpclient/Exchanges.kt | 6 ++-- .../src/main/kotlin/tbdex/sdk/rust/UniFFI.kt | 10 +++---- crates/tbdex/src/http_client/exchanges.rs | 2 +- docs/API_DESIGN.md | 8 +++--- .../hosted-wallet-kt/pfi/build.gradle.kts | 28 ++++++++++--------- .../hosted-wallet-kt/wallet/build.gradle.kts | 28 ++++++++++--------- .../wallet/src/main/kotlin/Main.kt | 2 +- 10 files changed, 48 insertions(+), 44 deletions(-) diff --git a/bindings/tbdex_uniffi/src/http_client/exchanges.rs b/bindings/tbdex_uniffi/src/http_client/exchanges.rs index 967fc05d..7b529100 100644 --- a/bindings/tbdex_uniffi/src/http_client/exchanges.rs +++ b/bindings/tbdex_uniffi/src/http_client/exchanges.rs @@ -76,8 +76,8 @@ pub fn get_exchange( Ok(Exchange::from_inner(inner_exchange)) } -pub fn get_exchanges(pfi_did_uri: String, bearer_did: Arc) -> Result> { +pub fn get_exchange_ids(pfi_did_uri: String, bearer_did: Arc) -> Result> { let exchange_ids = - tbdex::http_client::exchanges::get_exchanges(&pfi_did_uri, &bearer_did.0.clone())?; + tbdex::http_client::exchanges::get_exchange_ids(&pfi_did_uri, &bearer_did.0.clone())?; Ok(exchange_ids) } diff --git a/bindings/tbdex_uniffi/src/lib.rs b/bindings/tbdex_uniffi/src/lib.rs index 0ffe1a38..9bbf8783 100644 --- a/bindings/tbdex_uniffi/src/lib.rs +++ b/bindings/tbdex_uniffi/src/lib.rs @@ -21,7 +21,7 @@ use crate::{ http_client::{ balances::get_balances, exchanges::{ - create_exchange, get_exchange, get_exchanges, submit_cancel, submit_order, + create_exchange, get_exchange, get_exchange_ids, submit_cancel, submit_order, Exchange as ExchangeData, }, offerings::get_offerings, diff --git a/bindings/tbdex_uniffi/src/tbdex.udl b/bindings/tbdex_uniffi/src/tbdex.udl index 54b32912..643e6e3c 100644 --- a/bindings/tbdex_uniffi/src/tbdex.udl +++ b/bindings/tbdex_uniffi/src/tbdex.udl @@ -12,7 +12,7 @@ namespace tbdex { [Throws=TbdexSdkError] ExchangeData get_exchange(string pfi_did_uri, BearerDid bearer_did, string exchange_id); [Throws=TbdexSdkError] - sequence get_exchanges(string pfi_did_uri, BearerDid bearer_did); + sequence get_exchange_ids(string pfi_did_uri, BearerDid bearer_did); }; [Error] diff --git a/bound/kt/src/main/kotlin/tbdex/sdk/httpclient/Exchanges.kt b/bound/kt/src/main/kotlin/tbdex/sdk/httpclient/Exchanges.kt index e028db4f..1ffa0e5b 100644 --- a/bound/kt/src/main/kotlin/tbdex/sdk/httpclient/Exchanges.kt +++ b/bound/kt/src/main/kotlin/tbdex/sdk/httpclient/Exchanges.kt @@ -7,7 +7,7 @@ import tbdex.sdk.rust.createExchange as rustCoreCreateExchange import tbdex.sdk.rust.submitOrder as rustCoreSubmitOrder import tbdex.sdk.rust.submitCancel as rustCoreSubmitCancel import tbdex.sdk.rust.getExchange as rustCoreGetExchange -import tbdex.sdk.rust.getExchanges as rustCoreGetExchanges +import tbdex.sdk.rust.getExchangeIds as rustCoreGetExchangeIds import web5.sdk.dids.BearerDid data class Exchange( @@ -63,10 +63,10 @@ fun getExchange(pfiDidUri: String, bearerDid: BearerDid, exchangeId: String): Ex return Exchange.fromRustCore(rustCoreExchange) } -fun getExchanges(pfiDidUri: String, bearerDid: BearerDid): List { +fun getExchangeIds(pfiDidUri: String, bearerDid: BearerDid): List { SystemArchitecture.set() // ensure the sys arch is set for first-time loading - return rustCoreGetExchanges(pfiDidUri, bearerDid.rustCoreBearerDid) + return rustCoreGetExchangeIds(pfiDidUri, bearerDid.rustCoreBearerDid) } diff --git a/bound/kt/src/main/kotlin/tbdex/sdk/rust/UniFFI.kt b/bound/kt/src/main/kotlin/tbdex/sdk/rust/UniFFI.kt index 71985127..325ac35a 100644 --- a/bound/kt/src/main/kotlin/tbdex/sdk/rust/UniFFI.kt +++ b/bound/kt/src/main/kotlin/tbdex/sdk/rust/UniFFI.kt @@ -1330,7 +1330,7 @@ internal interface UniffiLib : Library { ): RustBuffer.ByValue fun uniffi_tbdex_uniffi_fn_func_get_exchange(`pfiDidUri`: RustBuffer.ByValue,`bearerDid`: Pointer,`exchangeId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue - fun uniffi_tbdex_uniffi_fn_func_get_exchanges(`pfiDidUri`: RustBuffer.ByValue,`bearerDid`: Pointer,uniffi_out_err: UniffiRustCallStatus, + fun uniffi_tbdex_uniffi_fn_func_get_exchange_ids(`pfiDidUri`: RustBuffer.ByValue,`bearerDid`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue fun uniffi_tbdex_uniffi_fn_func_get_offerings(`pfiDidUri`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue @@ -1456,7 +1456,7 @@ internal interface UniffiLib : Library { ): Short fun uniffi_tbdex_uniffi_checksum_func_get_exchange( ): Short - fun uniffi_tbdex_uniffi_checksum_func_get_exchanges( + fun uniffi_tbdex_uniffi_checksum_func_get_exchange_ids( ): Short fun uniffi_tbdex_uniffi_checksum_func_get_offerings( ): Short @@ -1698,7 +1698,7 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) { if (lib.uniffi_tbdex_uniffi_checksum_func_get_exchange() != 35978.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_tbdex_uniffi_checksum_func_get_exchanges() != 31534.toShort()) { + if (lib.uniffi_tbdex_uniffi_checksum_func_get_exchange_ids() != 44594.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_tbdex_uniffi_checksum_func_get_offerings() != 28498.toShort()) { @@ -10878,10 +10878,10 @@ public object FfiConverterMapStringString: FfiConverterRustBuffer { + @Throws(TbdexSdkException::class) fun `getExchangeIds`(`pfiDidUri`: kotlin.String, `bearerDid`: BearerDid): List { return FfiConverterSequenceString.lift( uniffiRustCallWithError(TbdexSdkException) { _status -> - UniffiLib.INSTANCE.uniffi_tbdex_uniffi_fn_func_get_exchanges( + UniffiLib.INSTANCE.uniffi_tbdex_uniffi_fn_func_get_exchange_ids( FfiConverterString.lower(`pfiDidUri`),FfiConverterTypeBearerDid.lower(`bearerDid`),_status) } ) diff --git a/crates/tbdex/src/http_client/exchanges.rs b/crates/tbdex/src/http_client/exchanges.rs index 66c6a300..cfe8c023 100644 --- a/crates/tbdex/src/http_client/exchanges.rs +++ b/crates/tbdex/src/http_client/exchanges.rs @@ -151,7 +151,7 @@ pub fn get_exchange( Ok(exchange) } -pub fn get_exchanges(pfi_did: &str, requestor_did: &BearerDid) -> Result> { +pub fn get_exchange_ids(pfi_did: &str, requestor_did: &BearerDid) -> Result> { let service_endpoint = get_service_endpoint(pfi_did)?; let get_exchanges_endpoint = format!("{}/exchanges", service_endpoint); diff --git a/docs/API_DESIGN.md b/docs/API_DESIGN.md index 24552e82..345c6272 100644 --- a/docs/API_DESIGN.md +++ b/docs/API_DESIGN.md @@ -37,7 +37,7 @@ - [`QuoteDetails`](#quotedetails) - [`Order`](#order) - [`OrderInstructions`](#orderinstructions) - - [`OrderInstructionsData](#orderinstructionsdata) + - [`OrderInstructionsData`](#orderinstructionsdata) - [`PaymentInstruction`](#paymentinstruction) - [`Cancel`](#cancel) - [`CancelData`](#canceldata) @@ -63,7 +63,7 @@ - [`submit_close()`](#submit_close) - [`get_exchange()`](#get_exchange) - [`Exchange`](#exchange) - - [`get_exchanges()`](#get_exchanges) + - [`get_exchange_ids()`](#get_exchange_ids) > [!WARNING] > @@ -625,8 +625,8 @@ CLASS Exchange PUBLIC DATA close: Close ``` -## `get_exchanges()` +## `get_exchange_ids()` ```pseudocode! -FUNCTION get_exchanges(pfi_did_uri: string, bearer_did: BearerDid): []string +FUNCTION get_exchange_ids(pfi_did_uri: string, bearer_did: BearerDid): []string ``` diff --git a/examples/hosted-wallet-kt/pfi/build.gradle.kts b/examples/hosted-wallet-kt/pfi/build.gradle.kts index 44403388..e1dbe0f6 100644 --- a/examples/hosted-wallet-kt/pfi/build.gradle.kts +++ b/examples/hosted-wallet-kt/pfi/build.gradle.kts @@ -7,8 +7,20 @@ repositories { mavenCentral() mavenLocal() - // Optional: Add JitPack repository if using dependencies hosted on JitPack - maven { url = uri("https://jitpack.io") } + maven { + name = "tbd-oss-thirdparty" + url = uri("https://blockxyz.jfrog.io/artifactory/tbd-oss-thirdparty-maven2/") + mavenContent { + releasesOnly() + } + } + maven { + name = "tbd-oss-snapshots" + url = uri("https://blockxyz.jfrog.io/artifactory/tbd-oss-snapshots-maven2/") + mavenContent { + snapshotsOnly() + } + } } dependencies { @@ -16,17 +28,7 @@ dependencies { implementation("com.sparkjava:spark-core:2.9.4") implementation("com.squareup.okhttp3:okhttp:4.12.0") - // For local development dependency. - // Install the dependency locally by running `mvn install` in the `bound/kt` directory - // implementation("tbdex.sdk.core:tbdex-core-kt:1.0-SNAPSHOT") - - // GitHub dependency - // Reference: https://github.com/TBD54566975/tbdex-rs/packages/2210202 - // implementation("tbdex.sdk.core:tbdex-core-kt:0.0.1") - - // JitPack dependency - // Reference: https://jitpack.io/#TBD54566975/tbdex-rs/ - implementation("com.github.TBD54566975:tbdex-rs:v1.0.25") + implementation("xyz.block:tbdex:commit-d6edc85-SNAPSHOT") } java { diff --git a/examples/hosted-wallet-kt/wallet/build.gradle.kts b/examples/hosted-wallet-kt/wallet/build.gradle.kts index c2a10aae..6dd361cd 100644 --- a/examples/hosted-wallet-kt/wallet/build.gradle.kts +++ b/examples/hosted-wallet-kt/wallet/build.gradle.kts @@ -7,25 +7,27 @@ repositories { mavenCentral() mavenLocal() - // Optional: Add JitPack repository if using dependencies hosted on JitPack - maven { url = uri("https://jitpack.io") } + maven { + name = "tbd-oss-thirdparty" + url = uri("https://blockxyz.jfrog.io/artifactory/tbd-oss-thirdparty-maven2/") + mavenContent { + releasesOnly() + } + } + maven { + name = "tbd-oss-snapshots" + url = uri("https://blockxyz.jfrog.io/artifactory/tbd-oss-snapshots-maven2/") + mavenContent { + snapshotsOnly() + } + } } dependencies { implementation(kotlin("stdlib")) implementation("com.sparkjava:spark-core:2.9.4") - // For local development dependency. - // Install the dependency locally by running `mvn install` in the `bound/kt` directory - // implementation("tbdex.sdk.core:tbdex-core-kt:1.0-SNAPSHOT") - - // GitHub dependency - // Reference: https://github.com/TBD54566975/tbdex-rs/packages/2210202 - // implementation("tbdex.sdk.core:tbdex-core-kt:0.0.1") - - // JitPack dependency - // Reference: https://jitpack.io/#TBD54566975/tbdex-rs/ - implementation("com.github.TBD54566975:tbdex-rs:v1.0.25") + implementation("xyz.block:tbdex:commit-d6edc85-SNAPSHOT") } java { diff --git a/examples/hosted-wallet-kt/wallet/src/main/kotlin/Main.kt b/examples/hosted-wallet-kt/wallet/src/main/kotlin/Main.kt index 8d998ac7..10f42597 100644 --- a/examples/hosted-wallet-kt/wallet/src/main/kotlin/Main.kt +++ b/examples/hosted-wallet-kt/wallet/src/main/kotlin/Main.kt @@ -43,7 +43,7 @@ fun main() { runCancelFlow(pfiDidUri, verifiableCredential, bearerDid, replyToUrl) runErrorFlow(pfiDidUri, verifiableCredential, bearerDid) - val allExchanges = tbdex.sdk.httpclient.getExchanges(pfiDidUri, bearerDid) + val allExchanges = tbdex.sdk.httpclient.getExchangeIds(pfiDidUri, bearerDid) println("All Exchanges Completed: $allExchanges") } }