Skip to content

Commit cf263e6

Browse files
joriscaloudBertrandNOEL
authored andcommitted
add optional parameters to issuemorefrom method (hubert-marteau#41)
1 parent 403501b commit cf263e6

File tree

3 files changed

+97
-1
lines changed

3 files changed

+97
-1
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.multichainjavaapi</groupId>
55
<artifactId>MultiChainJavaAPI</artifactId>
6-
<version>0.5.01-SNAPSHOT</version>
6+
<version>0.5.02-SNAPSHOT</version>
77

88
<properties>
99
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

src/main/java/multichain/command/IssueCommand.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,53 @@ public String issueMoreFrom(String fromAddress,
619619
return issueMoreFrom;
620620
}
621621

622+
/**
623+
* Issues qty additional units of asset, sending them to address. The asset
624+
* can be specified using its name, ref or issuance txid
625+
*
626+
* issuemorefrom "from-address" "to-address" asset-identifier quantity (
627+
* native-amount custom-fields )
628+
*
629+
* Create more units for asset from specific address
630+
*
631+
* Arguments: 1. "from-address" (string, required) Address used for issuing.
632+
* 2. "to-address" (string, required) The address to send newly created
633+
* asset to. 3. "asset-identifier" (string, required) Asset identifier - one
634+
* of the following: issue txid. asset reference, asset name. 4. "quantity"
635+
* (numeric, required) The asset total amount in display units. eg. 1234.56
636+
* 5. "native-amount" (numeric, optional) native currency amount to send. eg
637+
* 0.1, Default: minimum-per-output. 6 "custom-fields" (object, optional) a
638+
* json object with custom fields { "param-name": "param-value" (strings,
639+
* required) The key is the parameter name, the value is parameter value
640+
* ,... }
641+
*
642+
* Result: "transactionid" (string) The transaction id.
643+
*
644+
* @param fromAddress
645+
* @param toAddress
646+
* @param assetName
647+
* @param quantity
648+
* @param customFields
649+
* @return
650+
* @throws MultichainException
651+
*/
652+
public String issueMoreFrom(String fromAddress,
653+
String toAddress,
654+
String assetName,
655+
float quantity,
656+
float nativeAmount,
657+
List<CustomParamString> customFields) throws MultichainException {
658+
String issueMoreFrom = "";
659+
660+
Object objectIssueMoreFrom = executeIssueMoreFrom(fromAddress, toAddress, assetName, quantity,
661+
nativeAmount, customFields);
662+
if (verifyInstance(objectIssueMoreFrom, String.class)) {
663+
issueMoreFrom = (String) objectIssueMoreFrom;
664+
}
665+
666+
return issueMoreFrom;
667+
}
668+
622669
/**
623670
*
624671
* listassets ("asset-identifier" verbose) 1. "asset-identifier" (string,

src/main/java/multichain/command/builders/QueryBuilderIssue.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,55 @@ protected Object executeIssueMoreFrom( String fromAddress,
366366
return execute(CommandEnum.ISSUEMOREFROM, fromAddress, toAddress, assetName, quantity);
367367
}
368368

369+
/**
370+
* Issues qty additional units of asset, sending them to address. The asset
371+
* can be specified using its name, ref or issuance txid
372+
*
373+
* issuemorefrom "from-address" "to-address" asset-identifier quantity (
374+
* native-amount custom-fields )
375+
*
376+
* Create more units for asset from specific address
377+
*
378+
* Arguments: 1. "from-address" (string, required) Address used for issuing.
379+
* 2. "to-address" (string, required) The address to send newly created
380+
* asset to. 3. "asset-identifier" (string, required) Asset identifier - one
381+
* of the following: issue txid. asset reference, asset name. 4. "quantity"
382+
* (numeric, required) The asset total amount in display units. eg. 1234.56
383+
* 5. "native-amount" (numeric, optional) native currency amount to send. eg
384+
* 0.1, Default: minimum-per-output. 6 "custom-fields" (object, optional) a
385+
* json object with custom fields { "param-name": "param-value" (strings,
386+
* required) The key is the parameter name, the value is parameter value
387+
* ,... }
388+
*
389+
* Result: "transactionid" (string) The transaction id.
390+
*
391+
* @param fromAddress
392+
* @param toAddress
393+
* @param assetName
394+
* @param quantity
395+
* @param customFields
396+
* @return
397+
* @throws MultichainException
398+
*/
399+
protected Object executeIssueMoreFrom(String fromAddress,
400+
String toAddress,
401+
String assetName,
402+
float quantity,
403+
float nativeAmount,
404+
List<CustomParamString> customFields) throws MultichainException {
405+
MultichainTestParameter.isNotNullOrEmpty("toAddress", toAddress);
406+
MultichainTestParameter.isNotNullOrEmpty("fromAddress", fromAddress);
407+
MultichainTestParameter.isNotNullOrEmpty("assetName", assetName);
408+
MultichainTestParameter.valueIsPositive("quantity", quantity);
409+
Map<String, String> customParams = CustomParamFormatter.formatCustomParamString(customFields);
410+
411+
if (nativeAmount < 0.f || customParams == null || customParams.size() == 0) {
412+
return execute(CommandEnum.ISSUEMOREFROM, fromAddress, toAddress, assetName, quantity);
413+
} else {
414+
return execute(CommandEnum.ISSUEMOREFROM, fromAddress, toAddress, assetName, quantity, nativeAmount, customParams);
415+
}
416+
}
417+
369418
/**
370419
*
371420
* listassets ("asset-identifier" verbose) 1. "asset-identifier" (string,

0 commit comments

Comments
 (0)