graphenej/graphenej/src/main/java/cy/agorise/graphenej/BaseOperation.java

36 lines
928 B
Java
Raw Normal View History

2017-10-02 19:34:50 +00:00
package cy.agorise.graphenej;
2016-11-21 17:50:30 +00:00
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
2017-10-02 19:34:50 +00:00
import cy.agorise.graphenej.interfaces.ByteSerializable;
import cy.agorise.graphenej.interfaces.JsonSerializable;
2016-11-21 17:50:30 +00:00
/**
* Created by nelson on 11/5/16.
*/
2016-12-11 02:43:01 +00:00
public abstract class BaseOperation implements ByteSerializable, JsonSerializable {
2016-11-21 17:50:30 +00:00
public static final String KEY_FEE = "fee";
public static final String KEY_EXTENSIONS = "extensions";
2016-11-21 17:50:30 +00:00
protected OperationType type;
protected Extensions extensions;
2016-11-21 17:50:30 +00:00
public BaseOperation(OperationType type){
this.type = type;
this.extensions = new Extensions();
2016-11-21 17:50:30 +00:00
}
public byte getId() {
return (byte) this.type.ordinal();
}
2016-11-21 17:50:30 +00:00
public abstract void setFee(AssetAmount assetAmount);
public JsonElement toJsonObject(){
JsonArray array = new JsonArray();
array.add(this.getId());
return array;
}
2016-11-21 17:50:30 +00:00
}