Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
Rename getExchanges() to getExchangeIds() (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
KendallWeihe authored Aug 1, 2024
1 parent aa3e465 commit 735267a
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 44 deletions.
4 changes: 2 additions & 2 deletions bindings/tbdex_uniffi/src/http_client/exchanges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<BearerDid>) -> Result<Vec<String>> {
pub fn get_exchange_ids(pfi_did_uri: String, bearer_did: Arc<BearerDid>) -> Result<Vec<String>> {
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)
}
2 changes: 1 addition & 1 deletion bindings/tbdex_uniffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion bindings/tbdex_uniffi/src/tbdex.udl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace tbdex {
[Throws=TbdexSdkError]
ExchangeData get_exchange(string pfi_did_uri, BearerDid bearer_did, string exchange_id);
[Throws=TbdexSdkError]
sequence<string> get_exchanges(string pfi_did_uri, BearerDid bearer_did);
sequence<string> get_exchange_ids(string pfi_did_uri, BearerDid bearer_did);
};

[Error]
Expand Down
6 changes: 3 additions & 3 deletions bound/kt/src/main/kotlin/tbdex/sdk/httpclient/Exchanges.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -63,10 +63,10 @@ fun getExchange(pfiDidUri: String, bearerDid: BearerDid, exchangeId: String): Ex
return Exchange.fromRustCore(rustCoreExchange)
}

fun getExchanges(pfiDidUri: String, bearerDid: BearerDid): List<String> {
fun getExchangeIds(pfiDidUri: String, bearerDid: BearerDid): List<String> {
SystemArchitecture.set() // ensure the sys arch is set for first-time loading

return rustCoreGetExchanges(pfiDidUri, bearerDid.rustCoreBearerDid)
return rustCoreGetExchangeIds(pfiDidUri, bearerDid.rustCoreBearerDid)
}


Expand Down
10 changes: 5 additions & 5 deletions bound/kt/src/main/kotlin/tbdex/sdk/rust/UniFFI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -10878,10 +10878,10 @@ public object FfiConverterMapStringString: FfiConverterRustBuffer<Map<kotlin.Str
}


@Throws(TbdexSdkException::class) fun `getExchanges`(`pfiDidUri`: kotlin.String, `bearerDid`: BearerDid): List<kotlin.String> {
@Throws(TbdexSdkException::class) fun `getExchangeIds`(`pfiDidUri`: kotlin.String, `bearerDid`: BearerDid): List<kotlin.String> {
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)
}
)
Expand Down
2 changes: 1 addition & 1 deletion crates/tbdex/src/http_client/exchanges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ pub fn get_exchange(
Ok(exchange)
}

pub fn get_exchanges(pfi_did: &str, requestor_did: &BearerDid) -> Result<Vec<String>> {
pub fn get_exchange_ids(pfi_did: &str, requestor_did: &BearerDid) -> Result<Vec<String>> {
let service_endpoint = get_service_endpoint(pfi_did)?;
let get_exchanges_endpoint = format!("{}/exchanges", service_endpoint);

Expand Down
8 changes: 4 additions & 4 deletions docs/API_DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
- [`QuoteDetails`](#quotedetails)
- [`Order`](#order)
- [`OrderInstructions`](#orderinstructions)
- [`OrderInstructionsData](#orderinstructionsdata)
- [`OrderInstructionsData`](#orderinstructionsdata)
- [`PaymentInstruction`](#paymentinstruction)
- [`Cancel`](#cancel)
- [`CancelData`](#canceldata)
Expand All @@ -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]
>
Expand Down Expand Up @@ -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
```
28 changes: 15 additions & 13 deletions examples/hosted-wallet-kt/pfi/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,28 @@ 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")
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 {
Expand Down
28 changes: 15 additions & 13 deletions examples/hosted-wallet-kt/wallet/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion examples/hosted-wallet-kt/wallet/src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down

0 comments on commit 735267a

Please sign in to comment.