Skip to content

Commit a2dc6f4

Browse files
committed
Renamed from get-sources to get_payment_sources
Signed-off-by: artem.ivanov <[email protected]>
1 parent 6055018 commit a2dc6f4

File tree

35 files changed

+383
-383
lines changed

35 files changed

+383
-383
lines changed

cli/src/commands/ledger.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -851,12 +851,12 @@ pub mod custom_command {
851851
}
852852
}
853853

854-
pub mod get_sources_command {
854+
pub mod get_payment_sources_command {
855855
use super::*;
856856

857-
command!(CommandMetadata::build("get-sources", "Get sources list for payment address.")
857+
command!(CommandMetadata::build("get-payment-sources", "Get sources list for payment address.")
858858
.add_required_param("payment_address","Target payment address")
859-
.add_example("ledger get-sources payment_address=pay:sov:GjZWsBLgZCR18aL468JAT7w9CZRiBnpxUPPgyQxh4voa")
859+
.add_example("ledger get-payment-sources payment_address=pay:sov:GjZWsBLgZCR18aL468JAT7w9CZRiBnpxUPPgyQxh4voa")
860860
.finalize()
861861
);
862862

@@ -869,13 +869,13 @@ pub mod get_sources_command {
869869

870870
let payment_address = get_str_param("payment_address", params).map_err(error_err!())?;
871871

872-
let (request, payment_method) = Payment::build_get_sources_request(wallet_handle, &submitter_did, payment_address)
872+
let (request, payment_method) = Payment::build_get_payment_sources_request(wallet_handle, &submitter_did, payment_address)
873873
.map_err(|err| handle_payment_error(err, None))?;
874874

875875
let response = Ledger::submit_request(pool_handle, &request)
876876
.map_err(|err| handle_transaction_error(err, None, Some(&pool_name), Some(&wallet_name)))?;
877877

878-
let res = match Payment::parse_get_sources_response(&payment_method, &response) {
878+
let res = match Payment::parse_get_payment_sources_response(&payment_method, &response) {
879879
Ok(sources_json) => {
880880
let mut sources: Vec<serde_json::Value> = serde_json::from_str(&sources_json)
881881
.map_err(|_| println_err!("Wrong data has been received"))?;
@@ -2897,11 +2897,11 @@ pub mod tests {
28972897
}
28982898

28992899
#[cfg(feature = "nullpay_plugin")]
2900-
mod get_sources {
2900+
mod get_payment_sources {
29012901
use super::*;
29022902

29032903
#[test]
2904-
pub fn get_sources_works() {
2904+
pub fn get_payment_sources_works() {
29052905
TestUtils::cleanup_storage();
29062906
let ctx = CommandContext::new();
29072907

@@ -2912,7 +2912,7 @@ pub mod tests {
29122912
use_did(&ctx, DID_TRUSTEE);
29132913
let payment_address = create_address_and_mint_sources(&ctx);
29142914
{
2915-
let cmd = get_sources_command::new();
2915+
let cmd = get_payment_sources_command::new();
29162916
let mut params = CommandParams::new();
29172917
params.insert("payment_address", payment_address);
29182918
cmd.execute(&ctx, &params).unwrap();
@@ -2923,7 +2923,7 @@ pub mod tests {
29232923
}
29242924

29252925
#[test]
2926-
pub fn get_sources_works_for_no_sources() {
2926+
pub fn get_payment_sources_works_for_no_sources() {
29272927
TestUtils::cleanup_storage();
29282928
let ctx = CommandContext::new();
29292929

@@ -2933,7 +2933,7 @@ pub mod tests {
29332933
new_did(&ctx, SEED_TRUSTEE);
29342934
use_did(&ctx, DID_TRUSTEE);
29352935
{
2936-
let cmd = get_sources_command::new();
2936+
let cmd = get_payment_sources_command::new();
29372937
let mut params = CommandParams::new();
29382938
params.insert("payment_address", PAYMENT_ADDRESS.to_string());
29392939
cmd.execute(&ctx, &params).unwrap();
@@ -2944,7 +2944,7 @@ pub mod tests {
29442944
}
29452945

29462946
#[test]
2947-
pub fn get_sources_works_for_unknown_payment_method() {
2947+
pub fn get_payment_sources_works_for_unknown_payment_method() {
29482948
TestUtils::cleanup_storage();
29492949
let ctx = CommandContext::new();
29502950

@@ -2954,7 +2954,7 @@ pub mod tests {
29542954
new_did(&ctx, SEED_TRUSTEE);
29552955
use_did(&ctx, DID_TRUSTEE);
29562956
{
2957-
let cmd = get_sources_command::new();
2957+
let cmd = get_payment_sources_command::new();
29582958
let mut params = CommandParams::new();
29592959
params.insert("payment_address", format!("pay:{}:test", UNKNOWN_PAYMENT_METHOD));
29602960
cmd.execute(&ctx, &params).unwrap_err();
@@ -2965,7 +2965,7 @@ pub mod tests {
29652965
}
29662966

29672967
#[test]
2968-
pub fn get_sources_works_for_invalid_payment_address() {
2968+
pub fn get_payment_sources_works_for_invalid_payment_address() {
29692969
TestUtils::cleanup_storage();
29702970
let ctx = CommandContext::new();
29712971

@@ -2975,7 +2975,7 @@ pub mod tests {
29752975
new_did(&ctx, SEED_TRUSTEE);
29762976
use_did(&ctx, DID_TRUSTEE);
29772977
{
2978-
let cmd = get_sources_command::new();
2978+
let cmd = get_payment_sources_command::new();
29792979
let mut params = CommandParams::new();
29802980
params.insert("payment_address", INVALID_PAYMENT_ADDRESS.to_string());
29812981
cmd.execute(&ctx, &params).unwrap_err();
@@ -2986,14 +2986,14 @@ pub mod tests {
29862986
}
29872987

29882988
#[test]
2989-
pub fn get_sources_works_for_no_active_wallet() {
2989+
pub fn get_payment_sources_works_for_no_active_wallet() {
29902990
TestUtils::cleanup_storage();
29912991
let ctx = CommandContext::new();
29922992

29932993
create_and_connect_pool(&ctx);
29942994
load_null_payment_plugin(&ctx);
29952995
{
2996-
let cmd = get_sources_command::new();
2996+
let cmd = get_payment_sources_command::new();
29972997
let mut params = CommandParams::new();
29982998
params.insert("payment_address", INVALID_PAYMENT_ADDRESS.to_string());
29992999
cmd.execute(&ctx, &params).unwrap_err();
@@ -3003,15 +3003,15 @@ pub mod tests {
30033003
}
30043004

30053005
#[test]
3006-
pub fn get_sources_works_for_no_active_did() {
3006+
pub fn get_payment_sources_works_for_no_active_did() {
30073007
TestUtils::cleanup_storage();
30083008
let ctx = CommandContext::new();
30093009

30103010
create_and_connect_pool(&ctx);
30113011
create_and_open_wallet(&ctx);
30123012
load_null_payment_plugin(&ctx);
30133013
{
3014-
let cmd = get_sources_command::new();
3014+
let cmd = get_payment_sources_command::new();
30153015
let mut params = CommandParams::new();
30163016
params.insert("payment_address", PAYMENT_ADDRESS.to_string());
30173017
cmd.execute(&ctx, &params).unwrap_err();
@@ -3871,10 +3871,10 @@ pub mod tests {
38713871
let (wallet_handle, _) = get_opened_wallet(ctx).unwrap();
38723872
let submitter_did = ensure_active_did(&ctx).unwrap();
38733873

3874-
let (get_sources_txn_json, _) = Payment::build_get_sources_request(wallet_handle, &submitter_did, payment_address).unwrap();
3874+
let (get_sources_txn_json, _) = Payment::build_get_payment_sources_request(wallet_handle, &submitter_did, payment_address).unwrap();
38753875
let response = Ledger::submit_request(pool_handle, &get_sources_txn_json).unwrap();
38763876

3877-
let sources_json = Payment::parse_get_sources_response(NULL_PAYMENT_METHOD, &response).unwrap();
3877+
let sources_json = Payment::parse_get_payment_sources_response(NULL_PAYMENT_METHOD, &response).unwrap();
38783878

38793879
let sources = serde_json::from_str::<serde_json::Value>(&sources_json).unwrap();
38803880
let source: &serde_json::Value = &sources.as_array().unwrap()[0];

cli/src/libindy/payment.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,37 +56,37 @@ impl Payment {
5656
super::results::result_to_string_string(err, receiver)
5757
}
5858

59-
pub fn build_get_sources_request(wallet_handle: i32, submitter_did: &str, payment_address: &str) -> Result<(String, String), ErrorCode> {
59+
pub fn build_get_payment_sources_request(wallet_handle: i32, submitter_did: &str, payment_address: &str) -> Result<(String, String), ErrorCode> {
6060
let (receiver, command_handle, cb) =
6161
super::callbacks::_closure_to_cb_ec_string_string();
6262

6363
let submitter_did = CString::new(submitter_did).unwrap();
6464
let payment_address = CString::new(payment_address).unwrap();
6565

6666
let err = unsafe {
67-
indy_build_get_sources_request(command_handle,
68-
wallet_handle,
69-
submitter_did.as_ptr(),
70-
payment_address.as_ptr(),
71-
cb)
67+
indy_build_get_payment_sources_request(command_handle,
68+
wallet_handle,
69+
submitter_did.as_ptr(),
70+
payment_address.as_ptr(),
71+
cb)
7272
};
7373

7474
super::results::result_to_string_string(err, receiver)
7575
}
7676

7777

78-
pub fn parse_get_sources_response(payment_method: &str, resp_json: &str) -> Result<String, ErrorCode> {
78+
pub fn parse_get_payment_sources_response(payment_method: &str, resp_json: &str) -> Result<String, ErrorCode> {
7979
let (receiver, command_handle, cb) =
8080
super::callbacks::_closure_to_cb_ec_string();
8181

8282
let payment_method = CString::new(payment_method).unwrap();
8383
let resp_json = CString::new(resp_json).unwrap();
8484

8585
let err = unsafe {
86-
indy_parse_get_sources_response(command_handle,
87-
payment_method.as_ptr(),
88-
resp_json.as_ptr(),
89-
cb)
86+
indy_parse_get_payment_sources_response(command_handle,
87+
payment_method.as_ptr(),
88+
resp_json.as_ptr(),
89+
cb)
9090
};
9191

9292
super::results::result_to_string(err, receiver)
@@ -250,22 +250,22 @@ extern {
250250
payment_method: *const c_char)>) -> ErrorCode;
251251

252252
#[no_mangle]
253-
fn indy_build_get_sources_request(command_handle: i32,
254-
wallet_handle: i32,
255-
submitter_did: *const c_char,
256-
payment_address: *const c_char,
257-
cb: Option<extern fn(command_handle_: i32,
258-
err: ErrorCode,
259-
get_sources_txn_json: *const c_char,
260-
payment_method: *const c_char)>) -> ErrorCode;
253+
fn indy_build_get_payment_sources_request(command_handle: i32,
254+
wallet_handle: i32,
255+
submitter_did: *const c_char,
256+
payment_address: *const c_char,
257+
cb: Option<extern fn(command_handle_: i32,
258+
err: ErrorCode,
259+
get_sources_txn_json: *const c_char,
260+
payment_method: *const c_char)>) -> ErrorCode;
261261

262262
#[no_mangle]
263-
fn indy_parse_get_sources_response(command_handle: i32,
264-
payment_method: *const c_char,
265-
resp_json: *const c_char,
266-
cb: Option<extern fn(command_handle_: i32,
267-
err: ErrorCode,
268-
sources_json: *const c_char)>) -> ErrorCode;
263+
fn indy_parse_get_payment_sources_response(command_handle: i32,
264+
payment_method: *const c_char,
265+
resp_json: *const c_char,
266+
cb: Option<extern fn(command_handle_: i32,
267+
err: ErrorCode,
268+
sources_json: *const c_char)>) -> ErrorCode;
269269

270270
#[no_mangle]
271271
fn indy_build_payment_req(command_handle: i32,

cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ fn build_executor() -> CommandExecutor {
107107
.add_command(ledger::pool_restart_command::new())
108108
.add_command(ledger::pool_upgrade_command::new())
109109
.add_command(ledger::custom_command::new())
110-
.add_command(ledger::get_sources_command::new())
110+
.add_command(ledger::get_payment_sources_command::new())
111111
.add_command(ledger::payment_command::new())
112112
.add_command(ledger::get_fees_command::new())
113113
.add_command(ledger::mint_prepare_command::new())

doc/design/001-cli/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@ Send custom transaction with user defined json body and optional signature
315315
ledger custom [txn=]<txn-json-value> [sign=<true|false>]
316316
```
317317
318-
#### GET_SOURCES transaction
319-
Send GET_SOURCES transaction
318+
#### GET_PAYMENT_SOURCES transaction
319+
Send GET_PAYMENT_SOURCES transaction
320320
```
321321
ledger get-sources payment_address=<payment_address>
322322
```

doc/design/004-payment-interface/README.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ by calling ```indy_register_payment_method``` call:
5050
/// payment_method: The type of payment method also used as sub-prefix for fully resolvable payment address format ("sov" - for example)
5151
/// create_payment_address: "create_payment_address" operation handler
5252
/// add_request_fees: "add_request_fees" operation handler
53-
/// build_get_sources_request: "build_get_sources_request" operation handler
54-
/// parse_get_sources_response: "parse_get_sources_response" operation handler
53+
/// build_get_payment_sources_request: "build_get_payment_sources_request" operation handler
54+
/// parse_get_payment_sources_response: "parse_get_payment_sources_response" operation handler
5555
/// build_payment_req: "build_payment_req" operation handler
5656
/// build_mint_req: "build_mint_req" operation handler
5757
///
@@ -64,8 +64,8 @@ pub extern fn indy_register_payment_method(command_handle: i32,
6464
create_payment_address: Option<CreatePaymentAddressCB>,
6565
add_request_fees: Option<AddRequestFeesCB>,
6666
parse_response_with_fees: Option<ParseResponseWithFeesCB>,
67-
build_get_sources_request: Option<BuildGetSourcesRequestCB>,
68-
parse_get_sources_response: Option<ParseGetSourcesResponseCB>,
67+
build_get_payment_sources_request: Option<BuildGetPaymentSourcesRequestCB>,
68+
parse_get_payment_sources_response: Option<ParseGetPaymentSourcesResponseCB>,
6969
build_payment_req: Option<BuildPaymentReqCB>,
7070
parse_payment_response: Option<ParsePaymentResponseCB>,
7171
build_mint_req: Option<BuildMintReqCB>,
@@ -180,7 +180,7 @@ type ParseResponseWithFeesCB = extern fn(command_handle: i32,
180180
///
181181
/// #Returns
182182
/// get_sources_txn_json - Indy request for getting sources list for payment address
183-
type BuildGetSourcesRequestCB = extern fn(command_handle: i32,
183+
type BuildGetPaymentSourcesRequestCB = extern fn(command_handle: i32,
184184
wallet_handle: i32,
185185
submitter_did: *const c_char,
186186
payment_address: *const c_char,
@@ -203,7 +203,7 @@ type BuildGetSourcesRequestCB = extern fn(command_handle: i32,
203203
/// amount: <int>, // amount
204204
/// extra: <str>, // optional data from payment transaction
205205
/// }]
206-
type ParseGetSourcesResponseCB = extern fn(command_handle: i32,
206+
type ParseGetPaymentSourcesResponseCB = extern fn(command_handle: i32,
207207
resp_json: *const c_char,
208208
cb: Option<extern fn(command_handle_: i32,
209209
err: ErrorCode,
@@ -473,14 +473,14 @@ pub extern fn indy_parse_response_with_fees(command_handle: i32,
473473
/// #Returns
474474
/// get_sources_txn_json - Indy request for getting sources list for payment address
475475
/// payment_method - used payment method
476-
pub extern fn indy_build_get_sources_request(command_handle: i32,
477-
wallet_handle: i32,
478-
submitter_did: *const c_char,
479-
payment_address: *const c_char,
480-
cb: Option<extern fn(command_handle_: i32,
481-
err: ErrorCode,
482-
get_sources_txn_json: *const c_char,
483-
payment_method: *const c_char) -> ErrorCode>) -> ErrorCode {}
476+
pub extern fn indy_build_get_payment_sources_request(command_handle: i32,
477+
wallet_handle: i32,
478+
submitter_did: *const c_char,
479+
payment_address: *const c_char,
480+
cb: Option<extern fn(command_handle_: i32,
481+
err: ErrorCode,
482+
get_sources_txn_json: *const c_char,
483+
payment_method: *const c_char) -> ErrorCode>) -> ErrorCode {}
484484

485485
/// Parses response for Indy request for getting sources list.
486486
///
@@ -498,12 +498,12 @@ pub extern fn indy_build_get_sources_request(command_handle: i32,
498498
/// amount: <int>, // amount
499499
/// extra: <str>, // optional data from payment transaction
500500
/// }]
501-
pub extern fn indy_parse_get_sources_response(command_handle: i32,
502-
payment_method: *const c_char,
503-
resp_json: *const c_char,
504-
cb: Option<extern fn(command_handle_: i32,
505-
err: ErrorCode,
506-
sources_json: *const c_char) -> ErrorCode>) -> ErrorCode {}
501+
pub extern fn indy_parse_get_payment_sources_response(command_handle: i32,
502+
payment_method: *const c_char,
503+
resp_json: *const c_char,
504+
cb: Option<extern fn(command_handle_: i32,
505+
err: ErrorCode,
506+
sources_json: *const c_char) -> ErrorCode>) -> ErrorCode {}
507507

508508
/// Builds Indy request for doing payment
509509
/// according to this payment method.

doc/design/007-cli-payments/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ Returns:
4040

4141
* Table with columns: Payment Address, Payment Method
4242

43-
### Send GET_SOURCES request
43+
### Send GET_PAYMENT_SOURCES request
4444

4545
Send request to get list of sources for specified payment addresses
4646

4747
```indy-cli
48-
indy> ledger get-sources payment_address=<payment-address>
48+
indy> ledger get-payment-sources payment_address=<payment-address>
4949
```
5050

5151
Returns:

0 commit comments

Comments
 (0)