Approvable
, NContract
, HashIdentifiable
, java.lang.Cloneable
, net.sergeych.biserializer.BiSerializable
public class UnsContract extends NSmartContract
Modifier and Type | Class | Description |
---|---|---|
static class |
UnsContract.PayingAmountMissingException |
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 |
DESCRIPTIONS_LIST_FIELD_NAME |
|
static java.lang.String |
ENTRIES_FIELD_NAME |
|
static java.lang.String |
NAMES_LIST_FIELD_NAME |
|
static java.lang.String |
PREPAID_ND_FIELD_NAME |
|
static java.lang.String |
REDUCED_NAMES_LIST_FIELD_NAME |
|
static java.lang.String |
SUSPENDED_FIELD_NAME |
PAID_U_FIELD_NAME
JSAPI_SCRIPT_FIELD
Constructor | Description |
---|---|
UnsContract() |
|
UnsContract(byte[] sealed,
@NonNull TransactionPack pack) |
Extract contract from v2 or v3 sealed form, getting revoking and new items from the transaction pack supplied.
|
UnsContract(com.icodici.crypto.PrivateKey key) |
Create a default empty new contract using a provided key as issuer and owner and sealer.
|
UnsContract(com.icodici.crypto.PrivateKey key,
NSmartContract.SmartContractType unsType) |
|
UnsContract(net.sergeych.tools.Binder unpacked,
@NonNull TransactionPack pack) |
Modifier and Type | Method | Description |
---|---|---|
void |
addAddress(com.icodici.crypto.KeyAddress keyAddress) |
|
void |
addData(net.sergeych.tools.Binder data) |
|
void |
addKey(com.icodici.crypto.PublicKey publicKey) |
|
void |
addName(java.lang.String name,
java.lang.String reducedName,
java.lang.String description) |
Add name to be register by UNS1 contract
|
void |
addOrigin(Contract contract) |
Add origin to be registered by UNS1 contract
|
void |
addOrigin(HashId origin) |
Add origin to be registered by UNS1 contract
|
void |
addUnsSpecific() |
Initialize UnsContract internal data structure with specific UNS1 parameters.
|
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.
|
Contract |
copy() |
Make a valid deep copy of a contract
|
Parcel |
createRegistrationParcel(int payingAmount,
Contract uContract,
java.util.Collection<com.icodici.crypto.PrivateKey> uKeys,
java.util.Collection<com.icodici.crypto.PrivateKey> keysToSignUnsWith) |
Create
Parcel to be registered that includes given amount paid |
Parcel |
createRegistrationParcel(Contract uContract,
java.util.Collection<com.icodici.crypto.PrivateKey> uKeys) |
Create
Parcel to be registered that includes additional payment of size expected by UNS1 contract: getPayingAmount()
Using this method allows to create paying parcel for UNS1 contract without dropping its signatures. |
Parcel |
createRegistrationParcel(java.time.ZonedDateTime unsExpirationDate,
Contract uContract,
java.util.Collection<com.icodici.crypto.PrivateKey> uKeys,
java.util.Collection<com.icodici.crypto.PrivateKey> keysToSignUnsWith) |
Create
Parcel to be registered that ensures expiration date of current UNS1 is not less than desired one |
void |
deserialize(net.sergeych.tools.Binder data,
net.sergeych.biserializer.BiDeserializer deserializer) |
|
static UnsContract |
fromDslFile(java.lang.String fileName) |
Method creates
UnsContract contract from dsl file where contract is described. |
java.util.Set<com.icodici.crypto.KeyAddress> |
getAddresses() |
|
java.util.List<net.sergeych.tools.Binder> |
getAllData() |
|
java.time.ZonedDateTime |
getCurrentUnsExpiration() |
Get expiration date of names associated with UNS1 contract.
|
net.sergeych.tools.Binder |
getExtraResultForApprove() |
Creates
Binder that will be returned to client after smart contract have been approved. |
java.time.ZonedDateTime |
getMinUnsExpiration() |
Get expiration date of current UNS1 if being payed additionally by minimum amount possible.
|
UnsName |
getName(java.lang.String name) |
|
java.util.Set<java.lang.String> |
getNames() |
Get all names registered by UNS1 contract
|
java.util.Set<HashId> |
getOrigins() |
Get all origins registered by UNS1 contract
|
java.lang.Integer |
getPayingAmount() |
Get paying amount expected by this UNS1 contract.
|
int |
getPayingAmount(java.time.ZonedDateTime unsExpirationDate) |
Get amount of U to be payed additionally to achieve desired UNS1 expiration date
Note: UNS1 expiration date is related to names services expiration
only and has nothing with
Contract expiration. |
double |
getPrepaidNameDays() |
Deprecated.
|
java.math.BigDecimal |
getPrepaidNamesDays() |
|
java.time.ZonedDateTime |
getUnsExpiration(int payingAmount) |
Get expiration date of current UNS1 if being payed additionally by specified amount.
|
protected UnsContract |
initializeWithDsl(net.sergeych.tools.Binder root) |
Method calls from
NSmartContract.fromDslFile(String) and initialize contract from given binder. |
@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.
|
boolean |
removeAddress(com.icodici.crypto.KeyAddress keyAddress) |
|
boolean |
removeData(net.sergeych.tools.Binder data) |
|
boolean |
removeKey(com.icodici.crypto.PublicKey publicKey) |
|
boolean |
removeName(java.lang.String name) |
Remove name from the list of names registered by UNS1 contract
|
boolean |
removeOrigin(HashId origin) |
Remove origin from the list of origins registered by UNS1 contract
|
byte[] |
seal() |
Seal contract to binary.
|
java.time.ZonedDateTime |
setPayingAmount(int payingAmount) |
Sets an amount that is going to be paid for this UNS1
Note: UNS1 expiration date is related to names services expiration
only and has nothing with
Contract expiration. |
addError, attachToNetwork, canFollowContract, check, getAdditionalKeysAddressesToSignWith, getCallbackKeys, getExtendedType, getMinPayment, getNodeInfoProvider, getPaidU, getPaidU, getRate, getRate, getTrackingOrigins, onContractSubscriptionEvent, 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, 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 NAMES_LIST_FIELD_NAME
public static final java.lang.String REDUCED_NAMES_LIST_FIELD_NAME
public static final java.lang.String DESCRIPTIONS_LIST_FIELD_NAME
public static final java.lang.String ENTRIES_FIELD_NAME
public static final java.lang.String SUSPENDED_FIELD_NAME
public static final java.lang.String PREPAID_ND_FIELD_NAME
public UnsContract(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 UnsContract(net.sergeych.tools.Binder unpacked, @NonNull TransactionPack pack) throws java.io.IOException
java.io.IOException
public UnsContract()
public UnsContract(com.icodici.crypto.PrivateKey key) throws ClientError
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 contractClientError
public UnsContract(com.icodici.crypto.PrivateKey key, NSmartContract.SmartContractType unsType) throws ClientError
ClientError
public void addUnsSpecific()
@Deprecated public double getPrepaidNameDays()
public java.math.BigDecimal getPrepaidNamesDays()
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
protected UnsContract initializeWithDsl(net.sergeych.tools.Binder root) throws com.icodici.crypto.EncryptionError
NSmartContract
NSmartContract.fromDslFile(String)
and initialize contract from given binder.initializeWithDsl
in class NSmartContract
root
- id binder with initialized dataNSmartContract
contract.com.icodici.crypto.EncryptionError
- if something went wrongpublic static UnsContract fromDslFile(java.lang.String fileName) throws java.io.IOException
UnsContract
contract from dsl file where contract is described.fileName
- is path to dsl file with yaml structure of data for contract.java.io.IOException
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 java.time.ZonedDateTime getCurrentUnsExpiration()
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
public void addName(java.lang.String name, java.lang.String reducedName, java.lang.String description)
name
- name to registerreducedName
- reduced version of registered name (verified by name service)description
- descriptionpublic boolean removeName(java.lang.String name)
name
- public java.util.Set<java.lang.String> getNames()
public void addOrigin(Contract contract)
contract
- contract whose origin is registered. Contract is added to UNS1 referenced items.public void addOrigin(HashId origin)
origin
- to be registered. Corresponding contract must be added to referenced items of transaction manuallypublic java.util.Set<HashId> getOrigins()
public boolean removeOrigin(HashId origin)
origin
- to be removedpublic void addKey(com.icodici.crypto.PublicKey publicKey)
public void addAddress(com.icodici.crypto.KeyAddress keyAddress)
public java.util.Set<com.icodici.crypto.KeyAddress> getAddresses()
public boolean removeAddress(com.icodici.crypto.KeyAddress keyAddress)
public boolean removeKey(com.icodici.crypto.PublicKey publicKey)
public Contract copy()
Contract
public void addData(net.sergeych.tools.Binder data)
public java.util.List<net.sergeych.tools.Binder> getAllData()
public boolean removeData(net.sergeych.tools.Binder data)
public UnsName getName(java.lang.String name)
public int getPayingAmount(java.time.ZonedDateTime unsExpirationDate)
Contract
expiration. Contract
expiration
can be set by its owner freely. It is only automatically adjusted if it's less
than: names services expiration date + HOLD period (one month) + 10 daysunsExpirationDate
- desired expiration datapublic java.time.ZonedDateTime getUnsExpiration(int payingAmount)
Contract
expiration. Contract
expiration
can be set by its owner freely. It is only automatically adjusted if it's less
than: names services expiration date + HOLD period (one month) + 10 dayspayingAmount
- null
if amount passed is less than NSmartContract.getMinPayment()
public java.time.ZonedDateTime getMinUnsExpiration()
Contract
expiration. Contract
expiration
can be set by its owner freely. It is only automatically adjusted if it's less
than: names services expiration date + HOLD period (one month) + 10 dayspublic Parcel createRegistrationParcel(java.time.ZonedDateTime unsExpirationDate, Contract uContract, java.util.Collection<com.icodici.crypto.PrivateKey> uKeys, java.util.Collection<com.icodici.crypto.PrivateKey> keysToSignUnsWith)
Parcel
to be registered that ensures expiration date of current UNS1 is not less than desired oneunsExpirationDate
- desired expiration dateuContract
- contract to used as paymentuKeys
- keys that resolve owner of payment contractkeysToSignUnsWith
- keys to sign UNS1 contract with (existing signatures are dropped when adding payment)public Parcel createRegistrationParcel(int payingAmount, Contract uContract, java.util.Collection<com.icodici.crypto.PrivateKey> uKeys, java.util.Collection<com.icodici.crypto.PrivateKey> keysToSignUnsWith)
Parcel
to be registered that includes given amount paidpayingAmount
- amount to payuContract
- contract to used as paymentuKeys
- keys that resolve owner of payment contractkeysToSignUnsWith
- keys to sign UNS1 contract with (existing signatures are dropped when adding payment)public Parcel createRegistrationParcel(Contract uContract, java.util.Collection<com.icodici.crypto.PrivateKey> uKeys)
Parcel
to be registered that includes additional payment of size expected by UNS1 contract: getPayingAmount()
Using this method allows to create paying parcel for UNS1 contract without dropping its signatures.uContract
- contract to used as paymentuKeys
- keys that resolve owner of payment contractpublic java.time.ZonedDateTime setPayingAmount(int payingAmount)
Contract
expiration. Contract
expiration
can be set by its owner freely. It is only automatically adjusted if it's less
than: names services expiration date + HOLD period (one month) + 10 dayspayingAmount
- amount that is going to be paidpublic java.lang.Integer getPayingAmount()
setPayingAmount(int)
Providing exactly this amount as payment won't require any signatures to be reapplied to UNS1 createRegistrationParcel(Contract, Collection)