Skip to content

Commit e64209f

Browse files
author
SimplyUb
committed
Correct issue for Opened Issue Creation
1 parent 22c0856 commit e64209f

File tree

3 files changed

+115
-100
lines changed

3 files changed

+115
-100
lines changed

src/multichain/command/IssueCommand.java

Lines changed: 89 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,19 @@ && verifyInstanceofList((ArrayList<Object>) objectBalanceAsset, BalanceAsset.cla
7272
*
7373
* Issue new asset
7474
*
75-
* Arguments:
76-
* 1. "address" (string, required) The address to send newly created asset to.
77-
* 2. "asset-name" (string, required) Asset name, if not "" should be unique.
78-
* or
79-
* 2. "asset-params" (object, required) A json object of with asset params { "name" : "asset-name" (string,
80-
* optional) Asset name "open" : true|false (boolean, optional, default false) True if follow-on issues are
81-
* allowed,... }
82-
* 3. "quantity" (numeric, required) The asset total amount in display units. eg. 1234.56
83-
* 4. "smallest-unit" (numeric, optional, default=1) Number of raw units in one displayed unit, eg 0.01 for cents
84-
* 5. "native-amount" (numeric, optional) native currency amount to send. eg 0.1, Default: minimum-per-output.
85-
* 6 "custom-fields" (object, optional) a json object with custom fields { "param-name": "param-value" (strings,
86-
* required) The key is the parameter name, the value is parameter value ,... }
75+
* Arguments: 1. "address" (string, required) The address to send newly
76+
* created asset to. 2. "asset-name" (string, required) Asset name, if not
77+
* "" should be unique. or 2. "asset-params" (object, required) A json
78+
* object of with asset params { "name" : "asset-name" (string, optional)
79+
* Asset name "open" : true|false (boolean, optional, default false) True if
80+
* follow-on issues are allowed,... } 3. "quantity" (numeric, required) The
81+
* asset total amount in display units. eg. 1234.56 4. "smallest-unit"
82+
* (numeric, optional, default=1) Number of raw units in one displayed unit,
83+
* eg 0.01 for cents 5. "native-amount" (numeric, optional) native currency
84+
* amount to send. eg 0.1, Default: minimum-per-output. 6 "custom-fields"
85+
* (object, optional) a json object with custom fields { "param-name":
86+
* "param-value" (strings, required) The key is the parameter name, the
87+
* value is parameter value ,... }
8788
*
8889
* Result: "transactionid" (string) The transaction id.
8990
*
@@ -111,18 +112,19 @@ public String issue(String address, String assetName, float quantity, float unit
111112
*
112113
* Issue new asset
113114
*
114-
* Arguments:
115-
* 1. "address" (string, required) The address to send newly created asset to.
116-
* 2. "asset-name" (string, required) Asset name, if not "" should be unique.
117-
* or
118-
* 2. "asset-params" (object, required) A json object of with asset params { "name" : "asset-name" (string,
119-
* optional) Asset name "open" : true|false (boolean, optional, default false) True if follow-on issues are
120-
* allowed,... }
121-
* 3. "quantity" (numeric, required) The asset total amount in display units. eg. 1234.56
122-
* 4. "smallest-unit" (numeric, optional, default=1) Number of raw units in one displayed unit, eg 0.01 for cents
123-
* 5. "native-amount" (numeric, optional) native currency amount to send. eg 0.1, Default: minimum-per-output.
124-
* 6 "custom-fields" (object, optional) a json object with custom fields { "param-name": "param-value" (strings,
125-
* required) The key is the parameter name, the value is parameter value ,... }
115+
* Arguments: 1. "address" (string, required) The address to send newly
116+
* created asset to. 2. "asset-name" (string, required) Asset name, if not
117+
* "" should be unique. or 2. "asset-params" (object, required) A json
118+
* object of with asset params { "name" : "asset-name" (string, optional)
119+
* Asset name "open" : true|false (boolean, optional, default false) True if
120+
* follow-on issues are allowed,... } 3. "quantity" (numeric, required) The
121+
* asset total amount in display units. eg. 1234.56 4. "smallest-unit"
122+
* (numeric, optional, default=1) Number of raw units in one displayed unit,
123+
* eg 0.01 for cents 5. "native-amount" (numeric, optional) native currency
124+
* amount to send. eg 0.1, Default: minimum-per-output. 6 "custom-fields"
125+
* (object, optional) a json object with custom fields { "param-name":
126+
* "param-value" (strings, required) The key is the parameter name, the
127+
* value is parameter value ,... }
126128
*
127129
* Result: "transactionid" (string) The transaction id.
128130
*
@@ -135,8 +137,7 @@ public String issue(String address, String assetName, float quantity, float unit
135137
* @return
136138
* @throws MultichainException
137139
*/
138-
public String issue(String address, List<AssetParams> assets, float quantity, float unit)
139-
throws MultichainException {
140+
public String issue(String address, AssetParams assets, float quantity, float unit) throws MultichainException {
140141
return issue(address, assets, quantity, unit, 0, null);
141142
}
142143

@@ -151,18 +152,19 @@ public String issue(String address, List<AssetParams> assets, float quantity, fl
151152
*
152153
* Issue new asset
153154
*
154-
* Arguments:
155-
* 1. "address" (string, required) The address to send newly created asset to.
156-
* 2. "asset-name" (string, required) Asset name, if not "" should be unique.
157-
* or
158-
* 2. "asset-params" (object, required) A json object of with asset params { "name" : "asset-name" (string,
159-
* optional) Asset name "open" : true|false (boolean, optional, default false) True if follow-on issues are
160-
* allowed,... }
161-
* 3. "quantity" (numeric, required) The asset total amount in display units. eg. 1234.56
162-
* 4. "smallest-unit" (numeric, optional, default=1) Number of raw units in one displayed unit, eg 0.01 for cents
163-
* 5. "native-amount" (numeric, optional) native currency amount to send. eg 0.1, Default: minimum-per-output.
164-
* 6 "custom-fields" (object, optional) a json object with custom fields { "param-name": "param-value" (strings,
165-
* required) The key is the parameter name, the value is parameter value ,... }
155+
* Arguments: 1. "address" (string, required) The address to send newly
156+
* created asset to. 2. "asset-name" (string, required) Asset name, if not
157+
* "" should be unique. or 2. "asset-params" (object, required) A json
158+
* object of with asset params { "name" : "asset-name" (string, optional)
159+
* Asset name "open" : true|false (boolean, optional, default false) True if
160+
* follow-on issues are allowed,... } 3. "quantity" (numeric, required) The
161+
* asset total amount in display units. eg. 1234.56 4. "smallest-unit"
162+
* (numeric, optional, default=1) Number of raw units in one displayed unit,
163+
* eg 0.01 for cents 5. "native-amount" (numeric, optional) native currency
164+
* amount to send. eg 0.1, Default: minimum-per-output. 6 "custom-fields"
165+
* (object, optional) a json object with custom fields { "param-name":
166+
* "param-value" (strings, required) The key is the parameter name, the
167+
* value is parameter value ,... }
166168
*
167169
* Result: "transactionid" (string) The transaction id.
168170
*
@@ -192,18 +194,19 @@ public String issue(String address, String assetName, float quantity, float unit
192194
*
193195
* Issue new asset
194196
*
195-
* Arguments:
196-
* 1. "address" (string, required) The address to send newly created asset to.
197-
* 2. "asset-name" (string, required) Asset name, if not "" should be unique.
198-
* or
199-
* 2. "asset-params" (object, required) A json object of with asset params { "name" : "asset-name" (string,
200-
* optional) Asset name "open" : true|false (boolean, optional, default false) True if follow-on issues are
201-
* allowed,... }
202-
* 3. "quantity" (numeric, required) The asset total amount in display units. eg. 1234.56
203-
* 4. "smallest-unit" (numeric, optional, default=1) Number of raw units in one displayed unit, eg 0.01 for cents
204-
* 5. "native-amount" (numeric, optional) native currency amount to send. eg 0.1, Default: minimum-per-output.
205-
* 6 "custom-fields" (object, optional) a json object with custom fields { "param-name": "param-value" (strings,
206-
* required) The key is the parameter name, the value is parameter value ,... }
197+
* Arguments: 1. "address" (string, required) The address to send newly
198+
* created asset to. 2. "asset-name" (string, required) Asset name, if not
199+
* "" should be unique. or 2. "asset-params" (object, required) A json
200+
* object of with asset params { "name" : "asset-name" (string, optional)
201+
* Asset name "open" : true|false (boolean, optional, default false) True if
202+
* follow-on issues are allowed,... } 3. "quantity" (numeric, required) The
203+
* asset total amount in display units. eg. 1234.56 4. "smallest-unit"
204+
* (numeric, optional, default=1) Number of raw units in one displayed unit,
205+
* eg 0.01 for cents 5. "native-amount" (numeric, optional) native currency
206+
* amount to send. eg 0.1, Default: minimum-per-output. 6 "custom-fields"
207+
* (object, optional) a json object with custom fields { "param-name":
208+
* "param-value" (strings, required) The key is the parameter name, the
209+
* value is parameter value ,... }
207210
*
208211
* Result: "transactionid" (string) The transaction id.
209212
*
@@ -217,7 +220,7 @@ public String issue(String address, String assetName, float quantity, float unit
217220
* @return
218221
* @throws MultichainException
219222
*/
220-
public String issue(String address, List<AssetParams> assets, float quantity, float unit, float amount)
223+
public String issue(String address, AssetParams assets, float quantity, float unit, float amount)
221224
throws MultichainException {
222225
return issue(address, assets, quantity, unit, amount, null);
223226
}
@@ -233,18 +236,19 @@ public String issue(String address, List<AssetParams> assets, float quantity, fl
233236
*
234237
* Issue new asset
235238
*
236-
* Arguments:
237-
* 1. "address" (string, required) The address to send newly created asset to.
238-
* 2. "asset-name" (string, required) Asset name, if not "" should be unique.
239-
* or
240-
* 2. "asset-params" (object, required) A json object of with asset params { "name" : "asset-name" (string,
241-
* optional) Asset name "open" : true|false (boolean, optional, default false) True if follow-on issues are
242-
* allowed,... }
243-
* 3. "quantity" (numeric, required) The asset total amount in display units. eg. 1234.56
244-
* 4. "smallest-unit" (numeric, optional, default=1) Number of raw units in one displayed unit, eg 0.01 for cents
245-
* 5. "native-amount" (numeric, optional) native currency amount to send. eg 0.1, Default: minimum-per-output.
246-
* 6 "custom-fields" (object, optional) a json object with custom fields { "param-name": "param-value" (strings,
247-
* required) The key is the parameter name, the value is parameter value ,... }
239+
* Arguments: 1. "address" (string, required) The address to send newly
240+
* created asset to. 2. "asset-name" (string, required) Asset name, if not
241+
* "" should be unique. or 2. "asset-params" (object, required) A json
242+
* object of with asset params { "name" : "asset-name" (string, optional)
243+
* Asset name "open" : true|false (boolean, optional, default false) True if
244+
* follow-on issues are allowed,... } 3. "quantity" (numeric, required) The
245+
* asset total amount in display units. eg. 1234.56 4. "smallest-unit"
246+
* (numeric, optional, default=1) Number of raw units in one displayed unit,
247+
* eg 0.01 for cents 5. "native-amount" (numeric, optional) native currency
248+
* amount to send. eg 0.1, Default: minimum-per-output. 6 "custom-fields"
249+
* (object, optional) a json object with custom fields { "param-name":
250+
* "param-value" (strings, required) The key is the parameter name, the
251+
* value is parameter value ,... }
248252
*
249253
* Result: "transactionid" (string) The transaction id.
250254
*
@@ -283,18 +287,19 @@ public String issue(String address, String assetName, float quantity, float unit
283287
*
284288
* Issue new asset
285289
*
286-
* Arguments:
287-
* 1. "address" (string, required) The address to send newly created asset to.
288-
* 2. "asset-name" (string, required) Asset name, if not "" should be unique.
289-
* or
290-
* 2. "asset-params" (object, required) A json object of with asset params { "name" : "asset-name" (string,
291-
* optional) Asset name "open" : true|false (boolean, optional, default false) True if follow-on issues are
292-
* allowed,... }
293-
* 3. "quantity" (numeric, required) The asset total amount in display units. eg. 1234.56
294-
* 4. "smallest-unit" (numeric, optional, default=1) Number of raw units in one displayed unit, eg 0.01 for cents
295-
* 5. "native-amount" (numeric, optional) native currency amount to send. eg 0.1, Default: minimum-per-output.
296-
* 6 "custom-fields" (object, optional) a json object with custom fields { "param-name": "param-value" (strings,
297-
* required) The key is the parameter name, the value is parameter value ,... }
290+
* Arguments: 1. "address" (string, required) The address to send newly
291+
* created asset to. 2. "asset-name" (string, required) Asset name, if not
292+
* "" should be unique. or 2. "asset-params" (object, required) A json
293+
* object of with asset params { "name" : "asset-name" (string, optional)
294+
* Asset name "open" : true|false (boolean, optional, default false) True if
295+
* follow-on issues are allowed,... } 3. "quantity" (numeric, required) The
296+
* asset total amount in display units. eg. 1234.56 4. "smallest-unit"
297+
* (numeric, optional, default=1) Number of raw units in one displayed unit,
298+
* eg 0.01 for cents 5. "native-amount" (numeric, optional) native currency
299+
* amount to send. eg 0.1, Default: minimum-per-output. 6 "custom-fields"
300+
* (object, optional) a json object with custom fields { "param-name":
301+
* "param-value" (strings, required) The key is the parameter name, the
302+
* value is parameter value ,... }
298303
*
299304
* Result: "transactionid" (string) The transaction id.
300305
*
@@ -309,7 +314,7 @@ public String issue(String address, String assetName, float quantity, float unit
309314
* @return
310315
* @throws MultichainException
311316
*/
312-
public String issue(String address, List<AssetParams> assets, float quantity, float unit, float amount,
317+
public String issue(String address, AssetParams assets, float quantity, float unit, float amount,
313318
List<CustomParamString> customFields) throws MultichainException {
314319
String issue = "";
315320

@@ -497,11 +502,10 @@ public String issueMoreFrom(String fromAddress, String toAddress, String assetNa
497502

498503
/**
499504
*
500-
* listassets ("asset-identifier" verbose)
501-
* 1. "asset-identifier" (string, optional) Asset identifier - one of the following: issue txid, asset reference,
502-
* asset name.
503-
* 2. verbose (boolean, optional, default=false) If true, returns list of all issue transactions, including
504-
* follow-ons
505+
* listassets ("asset-identifier" verbose) 1. "asset-identifier" (string,
506+
* optional) Asset identifier - one of the following: issue txid, asset
507+
* reference, asset name. 2. verbose (boolean, optional, default=false) If
508+
* true, returns list of all issue transactions, including follow-ons
505509
*
506510
* Returns list of defined assets
507511
*
@@ -526,11 +530,10 @@ && verifyInstanceofList((ArrayList<Object>) objectBalances, BalanceAsset.class))
526530

527531
/**
528532
*
529-
* listassets ("asset-identifier" verbose)
530-
* 1. "asset-identifier" (string, optional) Asset identifier - one of the following: issue txid, asset reference,
531-
* asset name.
532-
* 2. verbose (boolean, optional, default=false) If true, returns list of all issue transactions, including
533-
* follow-ons
533+
* listassets ("asset-identifier" verbose) 1. "asset-identifier" (string,
534+
* optional) Asset identifier - one of the following: issue txid, asset
535+
* reference, asset name. 2. verbose (boolean, optional, default=false) If
536+
* true, returns list of all issue transactions, including follow-ons
534537
*
535538
* Returns list of defined assets
536539
*

src/multichain/command/builders/QueryBuilderIssue.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,14 @@ protected Object executeIssue(String address, String assetName, float quantity,
141141
* @return
142142
* @throws MultichainException
143143
*/
144-
protected Object executeIssue(String address, List<AssetParams> assets, float quantity, float unit, float amount,
144+
protected Object executeIssue(String address, AssetParams assets, float quantity, float unit, float amount,
145145
List<CustomParamString> customFields) throws MultichainException {
146146
MultichainTestParameter.isNotNullOrEmpty("address", address);
147147

148-
if (assets == null || assets.isEmpty()) {
148+
if (assets == null) {
149149
throw new MultichainException("assets", "assets needed to be sent");
150150
}
151-
for (AssetParams asset : assets) {
152-
asset.isFilled();
153-
}
151+
assets.isFilled();
154152

155153
MultichainTestParameter.valueIsPositive("quantity", quantity);
156154
MultichainTestParameter.valueIsPositive("unit", unit);
@@ -159,9 +157,9 @@ protected Object executeIssue(String address, List<AssetParams> assets, float qu
159157
Map<String, String> customParams = CustomParamFormatter.formatCustomParamString(customFields);
160158

161159
if (customParams == null || customParams.size() == 0) {
162-
return execute(CommandEnum.ISSUE, address, formatJson(assets), quantity, unit, amount);
160+
return execute(CommandEnum.ISSUE, address, assets, quantity, unit, amount);
163161
} else {
164-
return execute(CommandEnum.ISSUE, address, formatJson(assets), quantity, unit, amount, customParams);
162+
return execute(CommandEnum.ISSUE, address, assets, quantity, unit, amount, customParams);
165163
}
166164
}
167165

src/multichain/test/command/IssueCommandTest.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import multichain.command.MultiChainCommand;
1616
import multichain.command.MultichainException;
1717
import multichain.object.BalanceAsset;
18+
import multichain.object.queryobjects.AssetParams;
1819
import multichain.object.queryobjects.CustomParamString;
1920

2021
/**
@@ -34,7 +35,8 @@ public IssueCommandTest() {
3435
}
3536

3637
private static void testissue() {
37-
String result = "";
38+
String resultClosed = "";
39+
String resultOpened = "";
3840
try {
3941
List<String> addresses = multiChainCommand.getAddressCommand().getAddresses();
4042
if (addresses != null && addresses.size() > 0) {
@@ -44,25 +46,37 @@ private static void testissue() {
4446
customFields.add(new CustomParamString("name1", "value1"));
4547
customFields.add(new CustomParamString("name2", "value2"));
4648
customFields.add(new CustomParamString("name3", "value3"));
47-
result = multiChainCommand.getIssueCommand().issue(address, assetName, 100, 1, 0, customFields);
49+
50+
// Closed Asset
51+
System.out.println("Creation of the asset : " + assetName + "Closed");
52+
resultClosed = multiChainCommand.getIssueCommand().issue(address, assetName + "Closed", 100, 1, 0,
53+
customFields);
54+
55+
// Opened Asset
56+
AssetParams params = new AssetParams(assetName + "Opened", true);
57+
System.out.println("Creation of the asset : " + assetName + "Opened");
58+
resultOpened = multiChainCommand.getIssueCommand().issue(address, params, 100, 1, 0, customFields);
59+
4860
}
4961
} catch (MultichainException e) {
5062
// TODO Auto-generated catch block
5163
e.printStackTrace();
5264
}
53-
if (result == null || "".equals(result)) {
54-
System.err.println("testissue - result is empty");
65+
if (resultClosed == null || "".equals(resultClosed) || resultOpened == null || "".equals(resultOpened)) {
66+
System.err.println("testissue - resultClosed or resultOpened is empty");
5567
} else {
5668
System.out.println("testissue");
57-
System.out.println("Result :");
58-
System.out.println(result);
69+
System.out.println("Result for asset " + assetName + "Closed :");
70+
System.out.println(resultClosed);
71+
System.out.println("Result for asset " + assetName + "Opened :");
72+
System.out.println(resultOpened);
5973
}
6074
}
6175

6276
private static void testlistAssets() {
6377
List<BalanceAsset> result = null;
6478
try {
65-
result = multiChainCommand.getIssueCommand().listAssets(assetName);
79+
result = multiChainCommand.getIssueCommand().listAssets(assetName + "Closed");
6680
} catch (MultichainException e) {
6781
// TODO Auto-generated catch block
6882
e.printStackTrace();

0 commit comments

Comments
 (0)