forked from bianjieai/avata-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NftTest.java
283 lines (265 loc) · 10.3 KB
/
NftTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
import ai.bianjie.avatasdk.AvataClient;
import ai.bianjie.avatasdk.model.PublicResponse;
import ai.bianjie.avatasdk.model.nft.*;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
public class NftTest {
AvataClient client = new AvataClient.Builder()
.setDomain("")
.setApiKey("")
.setApiSecret("")
.setHttpTimeout(10000)
.init();
String OperationID = String.valueOf(System.currentTimeMillis());
@Test
//请求创建 NFT 类别接口示例
void TestCreateClass() {
CreateNftClassReq req = new CreateNftClassReq();
req.setName("lmhnftclassname01");
req.setClassId("111bakvavoy");
req.setSymbol("123");
req.setDescription("123");
req.setUri("http://www.123.com");
req.setUriHash("123");
req.setData("123");
req.setOwner("iaa14c3dul0xdh4javrxec5vvfzvy7qk0qnfrruvvl");
req.setOperationId(OperationID);
try {
PublicResponse res = client.nftClient.createClass(req);
System.out.println(res.getData().getOperationId());
System.out.println("no ai.bianjie.avatasdk.exception");
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
}
@Test
//请求查询 NFT 类别列表接口示例
void TestQueryClasses() {
QueryNftClassesReq req = new QueryNftClassesReq();
req.setId("bakvavoy");
req.setOwner("iaa14c3dul0xdh4javrxec5vvfzvy7qk0qnfrruvvl");
QueryNftClassesRes res = client.nftClient.queryClasses(req);
System.out.println(res.getData());
}
@Test
//请求查询 NFT 类别详情接口示例
void TestQueryClass() {
QueryNftClassRes res = client.nftClient.queryClass("bakvavoy");
System.out.println(res.getData());
}
@Test
//请求转让 NFT 类别接口示例
void TestTransferClass() {
TransferNftClassReq req = new TransferNftClassReq();
req.setRecipient("iaa1jxf58dswgfqs84vw57wzucmttda3s3eu8dhcgr");
req.setOperationId(OperationID);
try {
PublicResponse res = client.nftClient.transferClass(req,
"bakvavoy",
"iaa14c3dul0xdh4javrxec5vvfzvy7qk0qnfrruvvl");
System.out.println(res.getData().getOperationId());
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
}
@Test
//请求发行 NFT 接口示例
void TestCreateNft() {
MintNftReq req = new MintNftReq();
req.setName("lmhnft023011");
req.setUri("http://www.456.com");
req.setUriHash("456");
req.setData("456");
req.setRecipient("iaa14c3dul0xdh4javrxec5vvfzvy7qk0qnfrruvvl");
req.setOperationId(OperationID);
try {
PublicResponse res = client.nftClient.createNft(req, "bakvavoy");
System.out.println(res.getData().getOperationId());
System.out.println("no ai.bianjie.avatasdk.exception");
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
}
@Test
//请求转让 NFT 接口示例
void TestTransferNft() {
TransferNftReq req = new TransferNftReq();
req.setRecipient("iaa1jxf58dswgfqs84vw57wzucmttda3s3eu8dhcgr");
req.setOperationId(OperationID);
try {
PublicResponse res = client.nftClient.transferNft(req,
"bakvavoy",
"iaa14c3dul0xdh4javrxec5vvfzvy7qk0qnfrruvvl",
"avatavgj7c3u5722k0oddsgyi3ps2ced");
System.out.println(res.getData().getOperationId());
System.out.println("no ai.bianjie.avatasdk.exception");
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
}
@Test
//请求编辑 NFT 接口示例
void TestEditNft() {
EditNftReq req = new EditNftReq();
req.setName("lmhtesteditnft0001");
req.setUri("http://www.789.com");
req.setData("789");
req.setOperationId(OperationID);
try {
PublicResponse res = client.nftClient.editNft(req,
"bakvavoy",
"iaa1jxf58dswgfqs84vw57wzucmttda3s3eu8dhcgr",
"avatavgj7c3u5722k0oddsgyi3ps2ced");
System.out.println(res.getData().getOperationId());
System.out.println("no ai.bianjie.avatasdk.exception");
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
}
@Test
//请求销毁 NFT 接口示例
void TestDeleteNft() {
BurnNftReq req = new BurnNftReq();
req.setOperationId(OperationID);
try {
PublicResponse res = client.nftClient.burnNft(req,
"bakvavoy",
"iaa1jxf58dswgfqs84vw57wzucmttda3s3eu8dhcgr",
"avatavgj7c3u5722k0oddsgyi3ps2ced");
System.out.println(res.getData().getOperationId());
System.out.println("no ai.bianjie.avatasdk.exception");
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
}
@Test
//请求批量发行 NFT 接口示例
void TestBatchCreateNft() {
BatchMintNftReq req = new BatchMintNftReq();
req.setName("lmhbatchnft111");
req.setUri("http://www.000.com");
req.setUriHash("000");
req.setData("000");
List<BatchMintNftReq.RecipientsDTO> list = new ArrayList<>();
BatchMintNftReq.RecipientsDTO dto1 = new BatchMintNftReq.RecipientsDTO();
dto1.setAmount(2);
dto1.setRecipient("iaa1jxf58dswgfqs84vw57wzucmttda3s3eu8dhcgr");
// BatchCreateNftReq.RecipientsDTO dto2 = new BatchCreateNftReq.RecipientsDTO();
// dto2.setAmount(2);
// dto2.setRecipient("iaa19lv0jz60plu6dd9kzycsp8l86ap4gmaynwxd9d");
list.add(dto1);
// list.add(dto2);
req.setRecipients(list);
req.setOperationId(OperationID);
try {
PublicResponse res = client.nftClient.batchCreateNft(req, "bakvavoy");
System.out.println(res.getData().getOperationId());
System.out.println("no ai.bianjie.avatasdk.exception");
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
}
@Test
//请求批量转让 NFT 接口示例
void TestBatchTransferNft() {
BatchTransferNftReq req = new BatchTransferNftReq();
List<BatchTransferNftReq.DataDTO> datalist = new ArrayList<>();
BatchTransferNftReq.DataDTO dataDTO = new BatchTransferNftReq.DataDTO();
List<BatchTransferNftReq.DataDTO.NftsDTO> nftlist = new ArrayList<>();
BatchTransferNftReq.DataDTO.NftsDTO nftsDTO = new BatchTransferNftReq.DataDTO.NftsDTO();
dataDTO.setNfts(nftlist);
dataDTO.setRecipient("iaa14c3dul0xdh4javrxec5vvfzvy7qk0qnfrruvvl");
nftsDTO.setClassId("bakvavoy");
nftsDTO.setNftId("avataaeqov8gmo0xetsexyi7k7cvxngn");
datalist.add(dataDTO);
nftlist.add(nftsDTO);
req.setData(datalist);
req.setOperationId(OperationID);
try {
PublicResponse res = client.nftClient.batchTransferNft(req, "iaa1jxf58dswgfqs84vw57wzucmttda3s3eu8dhcgr");
System.out.println(res.getData().getOperationId());
System.out.println("no ai.bianjie.avatasdk.exception");
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
}
@Test
//请求批量编辑 NFT 接口示例
void TestBatchEditNft() {
BatchEditNftReq req = new BatchEditNftReq();
List<BatchEditNftReq.NftsDTO> nftslist = new ArrayList<>();
BatchEditNftReq.NftsDTO nftsDTO = new BatchEditNftReq.NftsDTO();
nftsDTO.setClassId("bakvavoy");
nftsDTO.setNftId("avataaeqov8gmo0xetsexyi7k7cvxngn");
nftsDTO.setName("lmheditnftssss");
nftsDTO.setUri("http://www.hasbocai.com");
nftsDTO.setData("123");
nftslist.add(nftsDTO);
req.setNfts(nftslist);
req.setOperationId(OperationID);
try {
PublicResponse res = client.nftClient.batchEditNft(req, "iaa14c3dul0xdh4javrxec5vvfzvy7qk0qnfrruvvl");
System.out.println(res.getData().getOperationId());
System.out.println("no ai.bianjie.avatasdk.exception");
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
}
@Test
//请求批量销毁 NFT 接口示例
void TestBatchDeleteNft() {
BatchBurnNftReq req = new BatchBurnNftReq();
List<BatchBurnNftReq.NftsDTO> nftslist = new ArrayList<>();
BatchBurnNftReq.NftsDTO nftsDTO = new BatchBurnNftReq.NftsDTO();
nftsDTO.setClassId("bakvavoy");
nftsDTO.setNftId("avataaeqov8gmo0xetsexyi7k7cvxngn");
nftslist.add(nftsDTO);
req.setNfts(nftslist);
req.setOperationId(OperationID);
try {
PublicResponse res = client.nftClient.batchBurnNft(req, "iaa14c3dul0xdh4javrxec5vvfzvy7qk0qnfrruvvl");
System.out.println(res.getData().getOperationId());
System.out.println("no ai.bianjie.avatasdk.exception");
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
}
@Test
//请求查询 NFT 列表接口示例
void TestQueryNfts() {
QueryNftsReq req = new QueryNftsReq();
req.setLimit("2");
req.setStatus("burned");
QueryNftsRes res = client.nftClient.queryNfts(req);
System.out.println(res.getData());
}
@Test
//请求查询 NFT 详情接口示例
void TestQueryNft() {
QueryNftRes res = client.nftClient.queryNft(
"bakvavoy",
"avatabpyev9ewlg25bz4v8lpehap5xor");
System.out.println(res);
}
@Test
//请求查询 NFT 操作记录接口示例
void TestQueryNftHistory() {
QueryNftHistoryReq req = new QueryNftHistoryReq();
req.setLimit("2");
QueryNftHistoryRes res = client.nftClient.queryNftHistory(
"bakvavoy",
"avatabpyev9ewlg25bz4v8lpehap5xor",req);
System.out.println(res);
}
}