Skip to content

Commit

Permalink
Add sample for readGhostKey
Browse files Browse the repository at this point in the history
  • Loading branch information
Tougee committed Aug 5, 2021
1 parent cfb068a commit 3d9eb45
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ interface UserCallService {
@POST("outputs")
fun readGhostKeysCall(
@Body ghostKeyRequest: GhostKeyRequest
): Call<MixinResponse<List<GhostKey>>>
): Call<MixinResponse<GhostKey>>

@POST("external/proxy")
fun mixinMainnetRPCCall(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface UserCoroutineService {
suspend fun unlockMultisigs(@Path("id") id: String, @Body pinRequest: PinRequest): MixinResponse<Void>

@POST("outputs")
suspend fun readGhostKeys(@Body ghostKeyRequest: GhostKeyRequest): MixinResponse<List<GhostKey>>
suspend fun readGhostKeys(@Body ghostKeyRequest: GhostKeyRequest): MixinResponse<GhostKey>

@POST("external/proxy")
suspend fun mixinMainnetRPC(
Expand Down
17 changes: 17 additions & 0 deletions samples/src/main/java/jvmMain/java/Sample.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public static void main(String[] args) {

networkSnapshot(client, "c8e73a02-b543-4100-bd7a-879ed4accdfc");
networkSnapshots(client, CNB_assetId);

readGhostKey(client);
} catch (InterruptedException | IOException e) {
System.out.println(e.getMessage());
}
Expand Down Expand Up @@ -313,4 +315,19 @@ private static void networkSnapshots(HttpClient client, String assetId) throws I
System.out.printf("Fail: %s", Objects.requireNonNull(snapshotResponse.getError()).getDescription());
}
}

private static void readGhostKey(HttpClient client) throws IOException {
List<String> userList = new ArrayList<>();
userList.add("639ec50a-d4f1-4135-8624-3c71189dcdcc");
userList.add("d3bee23a-81d4-462e-902a-22dae9ef89ff");
GhostKeyRequest request = new GhostKeyRequest(userList, 0, "");
MixinResponse<GhostKey> response = client.getUserService().readGhostKeysCall(request).execute().body();
assert response != null;

if (response.isSuccess()) {
System.out.printf("ReadGhostKey success %s%n", response.getData());
} else {
System.out.println("ReadGhostKey failed");
}
}
}
24 changes: 16 additions & 8 deletions samples/src/main/java/jvmMain/kotlin/Sample.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ import one.mixin.bot.util.calculateAgreement
import one.mixin.bot.util.decryASEKey
import one.mixin.bot.util.generateEd25519KeyPair
import one.mixin.bot.util.getEdDSAPrivateKeyFromString
import one.mixin.bot.vo.AccountRequest
import one.mixin.bot.vo.AddressRequest
import one.mixin.bot.vo.PinRequest
import one.mixin.bot.vo.TransactionRequest
import one.mixin.bot.vo.TransferRequest
import one.mixin.bot.vo.User
import one.mixin.bot.vo.WithdrawalRequest
import one.mixin.bot.vo.generateTextMessageRequest
import one.mixin.bot.vo.*
import java.util.Random
import java.util.UUID

Expand Down Expand Up @@ -102,6 +95,8 @@ fun main() = runBlocking {

networkSnapshots(client, CNB_ID)
networkSnapshot(client, "c8e73a02-b543-4100-bd7a-879ed4accdfc")

readGhostKey(client)
return@runBlocking
}

Expand Down Expand Up @@ -303,4 +298,17 @@ private suspend fun networkSnapshots(
} else {
println("Fail: ${snapshotResponse.error?.description}")
}
}

private suspend fun readGhostKey(client: HttpClient) {
val request = GhostKeyRequest(listOf(
"639ec50a-d4f1-4135-8624-3c71189dcdcc",
"d3bee23a-81d4-462e-902a-22dae9ef89ff",
), 0, "")
val response = client.userService.readGhostKeys(request)
if (response.isSuccess()) {
println("ReadGhostKey success ${response.data}")
} else {
println("ReadGhostKey failed")
}
}

0 comments on commit 3d9eb45

Please sign in to comment.