Skip to content

Commit 3d9eb45

Browse files
committed
Add sample for readGhostKey
1 parent cfb068a commit 3d9eb45

File tree

4 files changed

+35
-10
lines changed

4 files changed

+35
-10
lines changed

library/src/main/kotlin/one/mixin/bot/api/call/UserCallService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ interface UserCallService {
5050
@POST("outputs")
5151
fun readGhostKeysCall(
5252
@Body ghostKeyRequest: GhostKeyRequest
53-
): Call<MixinResponse<List<GhostKey>>>
53+
): Call<MixinResponse<GhostKey>>
5454

5555
@POST("external/proxy")
5656
fun mixinMainnetRPCCall(

library/src/main/kotlin/one/mixin/bot/api/coroutine/UserCoroutineService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ interface UserCoroutineService {
4141
suspend fun unlockMultisigs(@Path("id") id: String, @Body pinRequest: PinRequest): MixinResponse<Void>
4242

4343
@POST("outputs")
44-
suspend fun readGhostKeys(@Body ghostKeyRequest: GhostKeyRequest): MixinResponse<List<GhostKey>>
44+
suspend fun readGhostKeys(@Body ghostKeyRequest: GhostKeyRequest): MixinResponse<GhostKey>
4545

4646
@POST("external/proxy")
4747
suspend fun mixinMainnetRPC(

samples/src/main/java/jvmMain/java/Sample.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ public static void main(String[] args) {
9393

9494
networkSnapshot(client, "c8e73a02-b543-4100-bd7a-879ed4accdfc");
9595
networkSnapshots(client, CNB_assetId);
96+
97+
readGhostKey(client);
9698
} catch (InterruptedException | IOException e) {
9799
System.out.println(e.getMessage());
98100
}
@@ -313,4 +315,19 @@ private static void networkSnapshots(HttpClient client, String assetId) throws I
313315
System.out.printf("Fail: %s", Objects.requireNonNull(snapshotResponse.getError()).getDescription());
314316
}
315317
}
318+
319+
private static void readGhostKey(HttpClient client) throws IOException {
320+
List<String> userList = new ArrayList<>();
321+
userList.add("639ec50a-d4f1-4135-8624-3c71189dcdcc");
322+
userList.add("d3bee23a-81d4-462e-902a-22dae9ef89ff");
323+
GhostKeyRequest request = new GhostKeyRequest(userList, 0, "");
324+
MixinResponse<GhostKey> response = client.getUserService().readGhostKeysCall(request).execute().body();
325+
assert response != null;
326+
327+
if (response.isSuccess()) {
328+
System.out.printf("ReadGhostKey success %s%n", response.getData());
329+
} else {
330+
System.out.println("ReadGhostKey failed");
331+
}
332+
}
316333
}

samples/src/main/java/jvmMain/kotlin/Sample.kt

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,7 @@ import one.mixin.bot.util.calculateAgreement
1414
import one.mixin.bot.util.decryASEKey
1515
import one.mixin.bot.util.generateEd25519KeyPair
1616
import one.mixin.bot.util.getEdDSAPrivateKeyFromString
17-
import one.mixin.bot.vo.AccountRequest
18-
import one.mixin.bot.vo.AddressRequest
19-
import one.mixin.bot.vo.PinRequest
20-
import one.mixin.bot.vo.TransactionRequest
21-
import one.mixin.bot.vo.TransferRequest
22-
import one.mixin.bot.vo.User
23-
import one.mixin.bot.vo.WithdrawalRequest
24-
import one.mixin.bot.vo.generateTextMessageRequest
17+
import one.mixin.bot.vo.*
2518
import java.util.Random
2619
import java.util.UUID
2720

@@ -102,6 +95,8 @@ fun main() = runBlocking {
10295

10396
networkSnapshots(client, CNB_ID)
10497
networkSnapshot(client, "c8e73a02-b543-4100-bd7a-879ed4accdfc")
98+
99+
readGhostKey(client)
105100
return@runBlocking
106101
}
107102

@@ -303,4 +298,17 @@ private suspend fun networkSnapshots(
303298
} else {
304299
println("Fail: ${snapshotResponse.error?.description}")
305300
}
301+
}
302+
303+
private suspend fun readGhostKey(client: HttpClient) {
304+
val request = GhostKeyRequest(listOf(
305+
"639ec50a-d4f1-4135-8624-3c71189dcdcc",
306+
"d3bee23a-81d4-462e-902a-22dae9ef89ff",
307+
), 0, "")
308+
val response = client.userService.readGhostKeys(request)
309+
if (response.isSuccess()) {
310+
println("ReadGhostKey success ${response.data}")
311+
} else {
312+
println("ReadGhostKey failed")
313+
}
306314
}

0 commit comments

Comments
 (0)