Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed state deserialize which is an uint enum in contract definition. #467

Merged
merged 3 commits into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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="";
Expand Down Expand Up @@ -161,8 +162,9 @@ public static CommercialPaper deserialize(byte[] data) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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="";
Expand Down Expand Up @@ -162,7 +163,8 @@ public static CommercialPaper deserialize(byte[] data) {
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);
}

Expand Down