Approvable
, NContract
, HashIdentifiable
, java.lang.Cloneable
, net.sergeych.biserializer.BiSerializable
public class SlotContract extends NSmartContract
NSmartContract.NodeInfoProvider, NSmartContract.SmartContractType
Contract.Context, Contract.ContractDev, Contract.Definition, Contract.State, Contract.Transactional, Contract.UnicapsuleExpectedException
Modifier and Type | Field | Description |
---|---|---|
static java.lang.String |
KEEP_REVISIONS_FIELD_NAME |
|
static java.lang.String |
PREPAID_FROM_TIME_FIELD_NAME |
|
static java.lang.String |
PREPAID_KD_FIELD_NAME |
|
static java.lang.String |
SPENT_KD_FIELD_NAME |
|
static java.lang.String |
SPENT_KD_TIME_FIELD_NAME |
|
static java.lang.String |
STORED_BYTES_FIELD_NAME |
|
static java.lang.String |
TRACKING_CONTRACT_FIELD_NAME |
PAID_U_FIELD_NAME
JSAPI_SCRIPT_FIELD
Constructor | Description |
---|---|
SlotContract() |
Slot contract is one of several types of smarts contracts that can be run on the node.
|
SlotContract(byte[] sealed,
@NonNull TransactionPack pack) |
Slot contract is one of several types of smarts contracts that can be run on the node.
|
SlotContract(com.icodici.crypto.PrivateKey key) |
Slot contract is one of several types of smarts contracts that can be run on the node.
|
SlotContract(net.sergeych.tools.Binder unpacked,
@NonNull TransactionPack pack) |
Modifier and Type | Method | Description |
---|---|---|
void |
addSlotSpecific() |
Method adds slot's specific to contract:
definition.extended_type is sets to SLOT1
adds permission modify_data with needed fields
|
boolean |
beforeCreate(ImmutableEnvironment c) |
Check the smart contract could be created
|
boolean |
beforeRevoke(ImmutableEnvironment c) |
Check the smart contract could be revoked
|
boolean |
beforeUpdate(ImmutableEnvironment c) |
Check the smart contract could be updated (e.g.
|
void |
deserialize(net.sergeych.tools.Binder data,
net.sergeych.biserializer.BiDeserializer deserializer) |
|
static SlotContract |
fromDslFile(java.lang.String fileName) |
Method creates
SlotContract contract from dsl file where contract is described. |
net.sergeych.tools.Binder |
getExtraResultForApprove() |
Creates
Binder that will be returned to client after smart contract have been approved. |
int |
getKeepRevisions() |
|
byte[] |
getPackedTrackingContract() |
|
java.util.Queue<byte[]> |
getPackedTrackingContracts() |
|
java.math.BigDecimal |
getPrepaidKilobytesDays() |
|
double |
getPrepaidKilobytesForDays() |
Deprecated.
|
Contract |
getTrackingContract() |
|
java.util.Queue<Contract> |
getTrackingContracts() |
|
protected SlotContract |
initializeWithDsl(net.sergeych.tools.Binder root) |
Method calls from
fromDslFile(String) and initialize contract from given binder. |
boolean |
isContractTracking(HashId hashId) |
|
void |
onContractSubscriptionEvent(ContractSubscription.Event event) |
For the
ContractSubscription the instance will receive event notifications with this callback |
@Nullable net.sergeych.tools.Binder |
onCreated(MutableEnvironment me) |
Called after the new contract is approved by the network.
|
void |
onRevoked(ImmutableEnvironment ime) |
Called when the contract is just revoked by the network
|
net.sergeych.tools.Binder |
onUpdated(MutableEnvironment me) |
Called after the new contract revision is approved by the network.
|
void |
putTrackingContract(Contract c) |
Put contract to the tracking contract's revisions queue.
|
byte[] |
seal() |
Seal contract to binary.
|
void |
setKeepRevisions(int keepRevisions) |
Sets number of revisions of tracking contract to hold in the storage.
|
addError, attachToNetwork, canFollowContract, check, getAdditionalKeysAddressesToSignWith, getCallbackKeys, getExtendedType, getMinPayment, getNodeInfoProvider, getPaidU, getPaidU, getRate, getRate, getTrackingOrigins, query, setNodeInfoProvider, toBinder
addError, addError, addNewItems, addPermission, addReference, addRevokingItems, addRole, addRole, addSignatureToSeal, addSignatureToSeal, addSignatureToSeal, addSignatureToSeal, addSignerKey, addSignerKeyFromFile, addSignerKeys, anonymizeRole, canBeRevoked, check, checkApplicablePermissionQuantized, checkReferencedItems, checkSubItemQuantized, clone, copy, createRevision, createRevision, createRevision, createRevision, createRevision, createRevision, createRevisionAnonymously, createRevisionAnonymously, createRevisionWithAddress, createRevisionWithAddress, createRevocation, createRole, createRole, createTransactionalSection, decodeDslTime, execJS, execJS, execJSByName, execJSByName, execJSByScriptHash, execJSByScriptHash, extractJSNames, extractTheContract, findReferenceByName, findReferenceByName, findSignatureInSeal, fromDslStream, fromDslString, fromPackedTransaction, fromSealedBinary, fromSealedBinary, fromSealedFile, get, getAllContractInTree, getApiLevel, getContext, getContract, getContractBytes, getCreatedAt, getCreator, getCustomRoles, getDefinition, getEarliestCreationTime, getEffectiveKeys, getErrors, getErrorsString, getExpiresAt, getId, getId, getIssuedAt, getIssuer, getKeysToSignWith, getLastSealedBinary, getLastSealedBinary, getNew, getNewItems, getOrigin, getOwner, getPackedTransaction, getParent, getPermissions, getPredefinedRoles, getProcessedCost, getProcessedCostTU, getProcessedCostU, getQuantiser, getRawOrigin, getReferenceContextKeys, getReferenced, getReferencedItems, getReferences, getRevision, getRevisionId, getRevoking, getRevokingItem, getRevokingItems, getRole, getRoleAddresses, getRoles, getRootId, getSealedByKeys, getSiblings, getState, getStateData, getTestQuantaLimit, getTransactional, getTransactionalData, getTransactionPack, getValidRoleReferences, isInWhiteList, isLimitedForTestnet, isOk, isPermitted, isPermitted, isPermitted, isRoleReference, isSuitableForTestnet, isU, isUnlimitKeyContract, paymentCheck, prepareForReferenceMatching, registerRole, removeAllReferencedItems, removeAllSignatures, removeReference, removeReferencedItem, sealAsV2, serialize, set, setApiLevel, setCreator, setCreator, setCreatorKeys, setCreatorKeys, setExpiresAt, setIssuerKeys, setIssuerKeys, setKeysToSignWith, setLimitedForTestnet, setOwnerKey, setOwnerKeys, setOwnerKeys, setReferenceContextKeys, setRoleKeys, setRoleKeys, setShouldBeU, setTestQuantaLimit, setTransactionPack, setVotedByKeys, shouldBeU, split, splitValue, testGetOwner, traceErrors, verifySealedKeys, verifySignatureQuantized
public static final java.lang.String PREPAID_KD_FIELD_NAME
public static final java.lang.String PREPAID_FROM_TIME_FIELD_NAME
public static final java.lang.String STORED_BYTES_FIELD_NAME
public static final java.lang.String SPENT_KD_FIELD_NAME
public static final java.lang.String SPENT_KD_TIME_FIELD_NAME
public static final java.lang.String KEEP_REVISIONS_FIELD_NAME
public static final java.lang.String TRACKING_CONTRACT_FIELD_NAME
public SlotContract()
public SlotContract(com.icodici.crypto.PrivateKey key)
This constructor adds key as sealing signature so it is ready to seal()
just after construction, thought
it is necessary to put real data to it first. It is allowed to change owner, expiration and data fields after
creation (but before sealing).
key
- is PrivateKey
for creating roles "issuer", "owner", "creator" and sign contractpublic SlotContract(byte[] sealed, @NonNull TransactionPack pack) throws java.io.IOException
It is recommended to call NSmartContract.check()
after construction to see the errors.
sealed
- binary sealed contract.pack
- the transaction pack to resolve dependencies again.java.io.IOException
- on the various format errorspublic SlotContract(net.sergeych.tools.Binder unpacked, @NonNull TransactionPack pack) throws java.io.IOException
java.io.IOException
public java.util.Queue<byte[]> getPackedTrackingContracts()
public java.util.Queue<Contract> getTrackingContracts()
public void addSlotSpecific()
protected SlotContract initializeWithDsl(net.sergeych.tools.Binder root) throws com.icodici.crypto.EncryptionError
fromDslFile(String)
and initialize contract from given binder.initializeWithDsl
in class NSmartContract
root
- id binder with initialized dataSlotContract
contract.com.icodici.crypto.EncryptionError
- if something went wrongpublic static SlotContract fromDslFile(java.lang.String fileName) throws java.io.IOException
SlotContract
contract from dsl file where contract is described.fileName
- is path to dsl file with yaml structure of data for contract.SlotContract
contract.java.io.IOException
- if something went wrongpublic byte[] getPackedTrackingContract()
TransactionPack
.public Contract getTrackingContract()
public boolean isContractTracking(HashId hashId)
hashId
- contract's id to checkpublic void putTrackingContract(Contract c)
keepRevisions
revisions then last one will removed.c
- is revision of tracking Contract
.public void setKeepRevisions(int keepRevisions)
keepRevisions
- is number of revisions to keep.public int getKeepRevisions()
@Deprecated public double getPrepaidKilobytesForDays()
public java.math.BigDecimal getPrepaidKilobytesDays()
public void onContractSubscriptionEvent(ContractSubscription.Event event)
NContract
ContractSubscription
the instance will receive event notifications with this callbackonContractSubscriptionEvent
in interface NContract
onContractSubscriptionEvent
in class NSmartContract
public byte[] seal()
Contract
Contract.getKeysToSignWith()
public void deserialize(net.sergeych.tools.Binder data, net.sergeych.biserializer.BiDeserializer deserializer)
deserialize
in interface net.sergeych.biserializer.BiSerializable
deserialize
in class Contract
public boolean beforeCreate(ImmutableEnvironment c)
NContract
beforeCreate
in interface NContract
beforeCreate
in class NSmartContract
public boolean beforeUpdate(ImmutableEnvironment c)
NContract
beforeUpdate
in interface NContract
beforeUpdate
in class NSmartContract
public boolean beforeRevoke(ImmutableEnvironment c)
NContract
beforeRevoke
in interface NContract
beforeRevoke
in class NSmartContract
public @Nullable net.sergeych.tools.Binder onCreated(MutableEnvironment me)
NContract
onCreated
in interface NContract
onCreated
in class NSmartContract
public net.sergeych.tools.Binder onUpdated(MutableEnvironment me)
NContract
onUpdated
in interface NContract
onUpdated
in class NSmartContract
public void onRevoked(ImmutableEnvironment ime)
NContract
onRevoked
in interface NContract
onRevoked
in class NSmartContract
public net.sergeych.tools.Binder getExtraResultForApprove()
NSmartContract
Binder
that will be returned to client after smart contract have been approved.getExtraResultForApprove
in class NSmartContract