mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-18 16:05:10 +00:00
Fixed state deserialize which is an uint enum in contract definition. (#467)
Signed-off-by: Luciano da Silva Ribas <luciano.ribas+git@gmail.com> Co-authored-by: Matthew B White <mbwhite@users.noreply.github.com>
This commit is contained in:
parent
42c456ffda
commit
bd559c81c8
2 changed files with 7 additions and 3 deletions
|
|
@ -18,6 +18,7 @@ public class CommercialPaper extends State {
|
|||
public final static String ISSUED = "ISSUED";
|
||||
public final static String TRADING = "TRADING";
|
||||
public final static String REDEEMED = "REDEEMED";
|
||||
public final static String[] STATES = new String[] {ISSUED, TRADING, REDEEMED};
|
||||
|
||||
@Property()
|
||||
private String state="";
|
||||
|
|
@ -161,8 +162,9 @@ public class CommercialPaper extends State {
|
|||
String maturityDateTime = json.getString("maturityDateTime");
|
||||
String owner = json.getString("owner");
|
||||
int faceValue = json.getInt("faceValue");
|
||||
String state = json.getString("state");
|
||||
return createInstance(issuer, paperNumber, issueDateTime, maturityDateTime, faceValue,owner,state);
|
||||
int currentState = json.getInt("currentState");
|
||||
String state = STATES[currentState-1];
|
||||
return createInstance(issuer, paperNumber, issueDateTime, maturityDateTime, faceValue, owner, state);
|
||||
}
|
||||
|
||||
public static byte[] serialize(CommercialPaper paper) {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ public class CommercialPaper extends State {
|
|||
public final static String ISSUED = "ISSUED";
|
||||
public final static String TRADING = "TRADING";
|
||||
public final static String REDEEMED = "REDEEMED";
|
||||
public final static String[] STATES = new String[] {ISSUED, TRADING, REDEEMED};
|
||||
|
||||
@Property()
|
||||
private String state="";
|
||||
|
|
@ -162,7 +163,8 @@ public class CommercialPaper extends State {
|
|||
String maturityDateTime = json.getString("maturityDateTime");
|
||||
String owner = json.getString("owner");
|
||||
int faceValue = json.getInt("faceValue");
|
||||
String state = json.getString("state");
|
||||
int currentState = json.getInt("currentState");
|
||||
String state = STATES[currentState-1];
|
||||
return createInstance(issuer, paperNumber, issueDateTime, maturityDateTime, faceValue, owner, state);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue