16
16
package org .hyperledger .fabric .shim ;
17
17
18
18
import static java .nio .charset .StandardCharsets .UTF_8 ;
19
+ import static java .util .stream .Collectors .toList ;
19
20
20
- import java .nio .charset .StandardCharsets ;
21
21
import java .util .Arrays ;
22
22
import java .util .List ;
23
- import java .util .stream .Collectors ;
24
23
25
24
import org .hyperledger .fabric .protos .peer .ChaincodeEventPackage .ChaincodeEvent ;
26
25
import org .hyperledger .fabric .protos .peer .ProposalResponsePackage .Response ;
@@ -41,9 +40,31 @@ public interface ChaincodeStub {
41
40
* {@link Chaincode#init(ChaincodeStub)} or
42
41
* {@link Chaincode#invoke(ChaincodeStub)}.
43
42
*
44
- * @return a list of arguments cast to a UTF-8 string
43
+ * @return a list of arguments cast to UTF-8 strings
45
44
*/
46
- List <String > getArgsAsStrings ();
45
+ List <String > getStringArgs ();
46
+
47
+ /**
48
+ * A convenience method that returns the first argument of the chaincode
49
+ * invocation for use as a function name.
50
+ *
51
+ * The bytes of the first argument are decoded as a UTF-8 string.
52
+ *
53
+ * @return the function name
54
+ */
55
+ String getFunction ();
56
+
57
+ /**
58
+ * A convenience method that returns all except the first argument of the
59
+ * chaincode invocation for use as the parameters to the function returned
60
+ * by #{@link ChaincodeStub#getFunction()}.
61
+ *
62
+ * The bytes of the arguments are decoded as a UTF-8 strings and returned as
63
+ * a list of string parameters..
64
+ *
65
+ * @return a list of parameters
66
+ */
67
+ List <String > getParameters ();
47
68
48
69
/**
49
70
* Returns the transaction id
@@ -134,7 +155,7 @@ default Response invokeChaincode(String chaincodeName, List<byte[]> args) {
134
155
* @return
135
156
*/
136
157
default Response invokeChaincodeWithStringArgs (String chaincodeName , List <String > args , String channel ) {
137
- return invokeChaincode (chaincodeName , args .stream ().map (x ->x .getBytes (StandardCharsets . UTF_8 )).collect (Collectors . toList ()), channel );
158
+ return invokeChaincode (chaincodeName , args .stream ().map (x ->x .getBytes (UTF_8 )).collect (toList ()), channel );
138
159
}
139
160
140
161
/**
0 commit comments