Skip to content

Commit 020475c

Browse files
committed
Updated Java, Python and NodeJS wrappers
Signed-off-by: artem.ivanov <[email protected]>
1 parent e2d276c commit 020475c

File tree

15 files changed

+325
-328
lines changed

15 files changed

+325
-328
lines changed

libindy/src/api/payments.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,6 @@ pub extern fn indy_list_payment_addresses(command_handle: i32,
470470
/// Format of inputs is specific for payment method. Usually it should reference payment transaction
471471
/// with at least one output that corresponds to payment address that user owns.
472472
///
473-
///
474473
/// Note this endpoint is EXPERIMENTAL. Function signature and behaviour may change
475474
/// in the future releases.
476475
///

libindy/tests/payments.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ static EMPTY_ARRAY: &str = "[]";
2727
static PAYMENT_METHOD_NAME: &str = "null";
2828
static WRONG_PAYMENT_METHOD_NAME: &str = "null_payment_handler";
2929
static CORRECT_INPUTS: &str = r#"["pay:null:1", "pay:null:2"]"#;
30-
static CORRECT_OUTPUTS: &str = r#"[{"paymentAddress": "pay:null:1", "amount":1, "extra":"1"}, {"paymentAddress": "pay:null:2", "amount":2, "extra":"2"}]"#;
30+
static CORRECT_OUTPUTS: &str = r#"[{"recipient": "pay:null:1", "amount":1, "extra":"1"}, {"recipient": "pay:null:2", "amount":2, "extra":"2"}]"#;
3131
static INPUTS_UNKNOWN_METHOD: &str = r#"["pay:unknown_payment_method:1"]"#;
32-
static OUTPUTS_UNKNOWN_METHOD: &str = r#"[{"paymentAddress": "pay:unknown_payment_method:1", "amount":1, "extra":"1"}]"#;
32+
static OUTPUTS_UNKNOWN_METHOD: &str = r#"[{"recipient": "pay:unknown_payment_method:1", "amount":1, "extra":"1"}]"#;
3333
static INPUTS_INVALID_FORMAT: &str = r#"pay:null:1"#;
3434
static OUTPUTS_INVALID_FORMAT: &str = r#"["pay:null:1",1]"#;
3535
static INCOMPATIBLE_INPUTS: &str = r#"["pay:PAYMENT_METHOD_1:1", "pay:PAYMENT_METHOD_2:1"]"#;
36-
static INCOMPATIBLE_OUTPUTS: &str = r#"[{"paymentAddress": "pay:PAYMENT_METHOD_1:1", "amount":1}, {"paymentAddress": "pay:PAYMENT_METHOD_2:1", "amount":1}]"#;
36+
static INCOMPATIBLE_OUTPUTS: &str = r#"[{"recipient": "pay:PAYMENT_METHOD_1:1", "amount":1}, {"recipient": "pay:PAYMENT_METHOD_2:1", "amount":1}]"#;
3737
static EQUAL_INPUTS: &str = r#"["pay:null1:1", "pay:null1:1", "pay:null1:2"]"#;
3838
static EQUAL_OUTPUTS: &str = r#"[{"paymentAddress": "pay:null:1", "amount":1, "extra":"1"}, {"paymentAddress": "pay:null:1", "amount":2, "extra":"2"}, {"paymentAddress": "pay:null:2", "amount":2, "extra":"2"}]"#;
3939
static CORRECT_FEES: &str = r#"{"txnType1":1, "txnType2":2}"#;
@@ -562,7 +562,7 @@ mod medium_cases {
562562
IDENTIFIER,
563563
EMPTY_OBJECT,
564564
r#"["pay:null1:1"]"#,
565-
r#"[{"paymentAddress": "pay:null2:1", "amount":1, "extra":"1"}]"#,
565+
r#"[{"recipient": "pay:null2:1", "amount":1, "extra":"1"}]"#,
566566
).unwrap_err();
567567

568568
assert_eq!(err, ErrorCode::PaymentIncompatibleMethodsError);
@@ -988,7 +988,7 @@ mod medium_cases {
988988
payments::mock_method::init();
989989
let wallet_handle = WalletUtils::create_and_open_default_wallet().unwrap();
990990
let inputs = r#"["pay:PAYMENT_METHOD_1:1"]"#;
991-
let outputs = r#"[{"paymentAddress": "pay:PAYMENT_METHOD_2:1", "amount": 1}]"#;
991+
let outputs = r#"[{"recipient": "pay:PAYMENT_METHOD_2:1", "amount": 1}]"#;
992992

993993
let res = payments::build_payment_req(wallet_handle,
994994
IDENTIFIER,
@@ -1215,7 +1215,7 @@ mod medium_cases {
12151215
TestUtils::cleanup_storage();
12161216
payments::mock_method::init();
12171217
let wallet_handle = WalletUtils::create_and_open_default_wallet().unwrap();
1218-
let outputs = r#"[{"paymentAddress": "pay:null", "amount":1, "extra":"1"}]"#;
1218+
let outputs = r#"[{"recipient": "pay:null", "amount":1, "extra":"1"}]"#;
12191219

12201220
let res = payments::build_mint_req(wallet_handle,
12211221
IDENTIFIER,

wrappers/java/src/main/java/org/hyperledger/indy/sdk/LibIndy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ public int indy_register_wallet_storage(int command_handle, String type, Callbac
159159
int indy_list_payment_addresses(int command_handle, int wallet_handle, Callback cb);
160160
int indy_add_request_fees(int command_handle, int wallet_handle, String submitter_did, String req_json, String inputs_json, String outputs_json, Callback cb);
161161
int indy_parse_response_with_fees(int command_handle, String payment_method, String resp_json, Callback cb);
162-
int indy_build_get_utxo_request(int command_handle, int wallet_handle, String submitter_did, String payment_method, Callback cb);
163-
int indy_parse_get_utxo_response(int command_handle, String payment_method, String resp_json, Callback cb);
162+
int indy_build_get_sources_request(int command_handle, int wallet_handle, String submitter_did, String payment_address, Callback cb);
163+
int indy_parse_get_sources_response(int command_handle, String payment_method, String resp_json, Callback cb);
164164
int indy_build_payment_req(int command_handle, int wallet_handle, String submitter_did, String inputs_json, String outputs_json, Callback cb);
165165
int indy_parse_payment_response(int command_handle, String payment_method, String resp_json, Callback cb);
166166
int indy_build_mint_req(int command_handle, int wallet_handle, String submitter_did, String outputs_json, Callback cb);

wrappers/java/src/main/java/org/hyperledger/indy/sdk/payments/Payments.java

Lines changed: 77 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ public void callback(int xcommandHandle, int err, String reqWithFeesJson, String
5050
};
5151

5252
/**
53-
* Callback used when buildGetUtxoRequest completes.
53+
* Callback used when buildGetSourcesRequest completes.
5454
*/
55-
private static Callback buildGetUtxoRequestCb = new Callback() {
55+
private static Callback buildGetSourcesRequestCb = new Callback() {
5656
@SuppressWarnings({"unused", "unchecked"})
57-
public void callback(int xcommandHandle, int err, String utxoJson, String paymentMethod) {
58-
CompletableFuture<BuildGetUtxoRequestResult> future = (CompletableFuture<BuildGetUtxoRequestResult>) removeFuture(xcommandHandle);
57+
public void callback(int xcommandHandle, int err, String sourcesJson, String paymentMethod) {
58+
CompletableFuture<BuildGetSourcesRequestResult> future = (CompletableFuture<BuildGetSourcesRequestResult>) removeFuture(xcommandHandle);
5959
if (!checkCallback(future, err)) return;
6060

61-
BuildGetUtxoRequestResult addRequestFeesResult = new BuildGetUtxoRequestResult(utxoJson, paymentMethod);
61+
BuildGetSourcesRequestResult addRequestFeesResult = new BuildGetSourcesRequestResult(sourcesJson, paymentMethod);
6262

6363
future.complete(addRequestFeesResult);
6464
}
@@ -175,11 +175,9 @@ public static CompletableFuture<String> listPaymentAddresses(
175175

176176
/**
177177
* Modifies Indy request by adding information how to pay fees for this transaction
178-
* according to selected payment method.
179-
*
180-
* Payment selection is performed by looking to o
178+
* according to this payment method.
181179
*
182-
* This method consumes set of UTXO inputs and outputs. The difference between inputs balance
180+
* This method consumes set of inputs and outputs. The difference between inputs balance
183181
* and outputs balance is the fee for this transaction.
184182
*
185183
* Not that this method also produces correct fee signatures.
@@ -189,20 +187,20 @@ public static CompletableFuture<String> listPaymentAddresses(
189187
*
190188
* Note this endpoint is EXPERIMENTAL. Function signature and behaviour may change
191189
* in the future releases.
190+
*
192191
* @param wallet The wallet.
193192
* @param submitterDid DID of request sender
194193
* @param reqJson initial transaction request as json
195-
* @param inputsJson The list of UTXO inputs as json array:
196-
* ["input1", ...]
197-
* Notes:
198-
* - each input should reference paymentAddress
199-
* - this param will be used to determine payment_method
200-
* @param outputsJson The list of UTXO outputs as json array:
201-
* [{
202-
* paymentAddress: <str>, // payment address used as output
203-
* amount: <int>, // amount of tokens to transfer to this payment address
204-
* extra: <str>, // optional data
205-
* }]
194+
* @param inputsJson The list of payment sources as json array:
195+
* ["source1", ...]
196+
* - each input should reference paymentAddress
197+
* - this param will be used to determine payment_method
198+
* @param outputsJson The list of outputs as json array:
199+
* [{
200+
* recipient: <str>, // payment address of recipient
201+
* amount: <int>, // amount
202+
* extra: <str>, // optional data
203+
* }]
206204
* @return modified Indy request with added fees info
207205
* @throws IndyException
208206
*/
@@ -244,12 +242,13 @@ public static CompletableFuture<AddRequestFeesResult> addRequestFees(
244242
* in the future releases.
245243
* @param paymentMethod
246244
* @param respJson response for Indy request with fees
247-
* @return parsed (payment method and node version agnostic) utxo info as json:
248-
* [{
249-
* input: <str>, // UTXO input
250-
* amount: <int>, // amount of tokens in this input
251-
* extra: <str>, // optional data from payment transaction
252-
* }]
245+
* @return receiptsJson - parsed (payment method and node version agnostic) receipts info as json:
246+
* [{
247+
* receipt: <str>, // receipt that can be used for payment referencing and verification
248+
* recipient: <str>, //payment address of recipient
249+
* amount: <int>, // amount
250+
* extra: <str>, // optional data from payment transaction
251+
* }]
253252
* @throws IndyException
254253
*/
255254
public static CompletableFuture<String> parseResponseWithFees(
@@ -260,89 +259,91 @@ public static CompletableFuture<String> parseResponseWithFees(
260259
}
261260

262261
/**
263-
* Builds Indy request for getting UTXO list for payment address
262+
* Builds Indy request for getting sources list for payment address
264263
* according to this payment method.
265264
*
266265
* Note this endpoint is EXPERIMENTAL. Function signature and behaviour may change
267266
* in the future releases.
267+
*
268268
* @param wallet The wallet.
269269
* @param submitterDid DID of request sender
270270
* @param paymentAddress target payment address
271-
* @return Indy request for getting UTXO list for payment address
271+
* @return Indy request for getting sources list for payment address
272272
* @throws IndyException
273273
*/
274-
public static CompletableFuture<BuildGetUtxoRequestResult> buildGetUtxoRequest(
274+
public static CompletableFuture<BuildGetSourcesRequestResult> buildGetSourcesRequest(
275275
Wallet wallet,
276276
String submitterDid,
277277
String paymentAddress
278278
) throws IndyException {
279279
ParamGuard.notNullOrWhiteSpace(submitterDid, "submitterDid");
280280
ParamGuard.notNullOrWhiteSpace(paymentAddress, "paymentAddress");
281281

282-
CompletableFuture<BuildGetUtxoRequestResult> future = new CompletableFuture<>();
282+
CompletableFuture<BuildGetSourcesRequestResult> future = new CompletableFuture<>();
283283
int commandHandle = addFuture(future);
284284

285285
int walletHandle = wallet.getWalletHandle();
286286

287-
int result = LibIndy.api.indy_build_get_utxo_request(
287+
int result = LibIndy.api.indy_build_get_sources_request(
288288
commandHandle,
289289
walletHandle,
290290
submitterDid,
291291
paymentAddress,
292-
buildGetUtxoRequestCb);
292+
buildGetSourcesRequestCb);
293293

294294
checkResult(result);
295295

296296
return future;
297297
}
298298

299299
/**
300-
* Parses response for Indy request for getting UTXO list.
300+
* Parses response for Indy request for getting sources list.
301301
*
302302
* Note this endpoint is EXPERIMENTAL. Function signature and behaviour may change
303303
* in the future releases.
304-
* @param paymentMethod
305-
* @param respJson response for Indy request for getting UTXO list
306-
* @return parsed (payment method and node version agnostic) utxo info as json:
307-
* [{
308-
* input: <str>, // UTXO input
309-
* amount: <int>, // amount of tokens in this input
310-
* extra: <str>, // optional data from payment transaction
311-
* }]
304+
*
305+
* @param paymentMethod payment method to use.
306+
* @param respJson response for Indy request for getting sources list
307+
* @return parsed (payment method and node version agnostic) sources info as json:
308+
* [{
309+
* source: <str>, // source input
310+
* paymentAddress: <str>, //payment address for this source
311+
* amount: <int>, // amount
312+
* extra: <str>, // optional data from payment transaction
313+
* }]
312314
* @throws IndyException
313315
*/
314-
public static CompletableFuture<String> parseGetUtxoResponse(
316+
public static CompletableFuture<String> parseGetSourcesResponse(
315317
String paymentMethod,
316318
String respJson
317319
) throws IndyException {
318-
return parseResponse(paymentMethod, respJson, LibIndy.api::indy_parse_get_utxo_response);
320+
return parseResponse(paymentMethod, respJson, LibIndy.api::indy_parse_get_sources_response);
319321
}
320322

321323
/**
322-
* Builds Indy request for doing tokens payment
324+
* Builds Indy request for doing payment
323325
* according to this payment method.
324326
*
325-
* This method consumes set of UTXO inputs and outputs.
327+
* This method consumes set of inputs and outputs.
326328
*
327329
* Format of inputs is specific for payment method. Usually it should reference payment transaction
328330
* with at least one output that corresponds to payment address that user owns.
329331
*
330332
* Note this endpoint is EXPERIMENTAL. Function signature and behaviour may change
331333
* in the future releases.
334+
*
332335
* @param wallet The wallet.
333336
* @param submitterDid DID of request sender
334-
* @param inputsJson The list of UTXO inputs as json array:
335-
* ["input1", ...]
336-
* Note that each input should reference paymentAddress
337-
* @param outputsJson The list of UTXO outputs as json array:
338-
* [{
339-
* paymentAddress: <str>, // payment address used as output
340-
* amount: <int>, // amount of tokens to transfer to this payment address
341-
* extra: <str>, // optional data
342-
* }]
343-
* @return
344-
* payment_req_json - Indy request for doing tokens payment
345-
* payment_method
337+
* @param inputsJson The list of payment sources as json array:
338+
* ["source1", ...]
339+
* Note that each source should reference payment address
340+
* @param outputsJson The list of outputs as json array:
341+
* [{
342+
* recipient: <str>, // payment address of recipient
343+
* amount: <int>, // amount
344+
* extra: <str>, // optional data
345+
* }]
346+
* @return Indy request for doing payment
346347
* @throws IndyException
347348
*/
348349
public static CompletableFuture<BuildPaymentReqResult> buildPaymentRequest(
@@ -378,14 +379,15 @@ public static CompletableFuture<BuildPaymentReqResult> buildPaymentRequest(
378379
*
379380
* Note this endpoint is EXPERIMENTAL. Function signature and behaviour may change
380381
* in the future releases.
381-
* @param paymentMethod
382+
* @param paymentMethod payment method to use
382383
* @param respJson response for Indy request for payment txn
383-
* @return parsed (payment method and node version agnostic) utxo info as json:
384-
* [{
385-
* input: <str>, // UTXO input
386-
* amount: <int>, // amount of tokens in this input
387-
* extra: <str>, // optional data from payment transaction
388-
* }]
384+
* @return parsed (payment method and node version agnostic) receipts info as json:
385+
* [{
386+
* receipt: <str>, // receipt that can be used for payment referencing and verification
387+
* recipient: <str>, // payment address of recipient
388+
* amount: <int>, // amount
389+
* extra: <str>, // optional data from payment transaction
390+
* }]
389391
* @throws IndyException
390392
*/
391393
public static CompletableFuture<String> parsePaymentResponse (
@@ -396,21 +398,21 @@ public static CompletableFuture<String> parsePaymentResponse (
396398
}
397399

398400
/**
399-
* Builds Indy request for doing tokens minting
401+
* Builds Indy request for doing minting
400402
* according to this payment method.
401403
*
402404
* Note this endpoint is EXPERIMENTAL. Function signature and behaviour may change
403405
* in the future releases.
404406
*
405407
* @param wallet The wallet.
406408
* @param submitterDid DID of request sender
407-
* @param outputsJson The list of UTXO outputs as json array:
408-
* [{
409-
* paymentAddress: <str>, // payment address used as output
410-
* amount: <int>, // amount of tokens to transfer to this payment address
411-
* extra: <str>, // optional data
412-
* }]
413-
* @return Indy request for doing tokens minting
409+
* @param outputsJson The list of outputs as json array:
410+
* [{
411+
* recipient: <str>, // payment address of recipient
412+
* amount: <int>, // amount
413+
* extra: <str>, // optional data
414+
* }]
415+
* @return Indy request for doing minting
414416
* @throws IndyException
415417
*/
416418
public static CompletableFuture<BuildMintReqResult> buildMintRequest(
@@ -445,7 +447,7 @@ public static CompletableFuture<BuildMintReqResult> buildMintRequest(
445447
* in the future releases.
446448
* @param wallet The wallet.
447449
* @param submitterDid DID of request sender
448-
* @param paymentMethod
450+
* @param paymentMethod payment method to use
449451
* @param feesJson {
450452
* txnType1: amount1,
451453
* txnType2: amount2,
@@ -490,7 +492,7 @@ public static CompletableFuture<String> buildSetTxnFeesRequest(
490492
* in the future releases.
491493
* @param wallet The wallet.
492494
* @param submitterDid DID of request sender
493-
* @param paymentMethod
495+
* @param paymentMethod payment method to use
494496
* @return Indy request for getting fees for transactions in the ledger
495497
* @throws IndyException
496498
*/
@@ -524,7 +526,7 @@ public static CompletableFuture<String> buildGetTxnFeesRequest(
524526
*
525527
* Note this endpoint is EXPERIMENTAL. Function signature and behaviour may change
526528
* in the future releases.
527-
* @param paymentMethod
529+
* @param paymentMethod payment method to use
528530
* @param respJson response for Indy request for getting fees
529531
* @return fees_json {
530532
* txnType1: amount1,

wrappers/java/src/main/java/org/hyperledger/indy/sdk/payments/PaymentsResults.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ public String getPaymentMethod() {
2424
}
2525

2626
/**
27-
* Result from calling buildGetUtxoRequest
27+
* Result from calling buildGetSourcesRequest
2828
*/
29-
public static class BuildGetUtxoRequestResult {
30-
private String getUtxoTxnJson;
29+
public static class BuildGetSourcesRequestResult {
30+
private String getSourcesTxnJson;
3131
private String paymentMethod;
3232

33-
public BuildGetUtxoRequestResult(String getUtxoTxnJson, String paymentMethod) {
34-
this.getUtxoTxnJson = getUtxoTxnJson;
33+
public BuildGetSourcesRequestResult(String getSourcesTxnJson, String paymentMethod) {
34+
this.getSourcesTxnJson = getSourcesTxnJson;
3535
this.paymentMethod = paymentMethod;
3636
}
3737

38-
public String getGetUtxoTxnJson() {
39-
return getUtxoTxnJson;
38+
public String getGetSourcesTxnJson() {
39+
return getSourcesTxnJson;
4040
}
4141

4242
public String getPaymentMethod() {

0 commit comments

Comments
 (0)