/** * Binder to hold any data client might want to keep per one transaction. * @return data {@link Binder} from transactional section */ public Binder getTransactionalData() { if (transactional == null) createTransactionalSection(); return transactional.getData(); }
/** * Checks if permission of given type exists and is allowed for given key record * @param permissionName type of permission to check for * @param keyRecord key record to check permission with * @return permission allowed for keyRecord is found * @throws Quantiser.QuantiserException if quantas limit was reached during check */ public boolean isPermitted(String permissionName, KeyRecord keyRecord) throws Quantiser.QuantiserException { return isPermitted(permissionName, keyRecord.getPublicKey()); }
/** * Pack the contract to the most modern .unicon format, same as {@link TransactionPack#pack()}. Uses bounded {@link * TransactionPack} instance to save together the contract, revoking and new items (if any). This is a binary format * using to submit for approval. Use {@link #fromPackedTransaction(byte[])} to read this format. * * @return packed binary form. */ public byte[] getPackedTransaction() { return getTransactionPack().pack(); }
protected Contract createCoin(String yamlFilePath) throws IOException { Contract c = Contract.fromDslFile(yamlFilePath); c.setOwnerKey(ownerKey2); return c; }
public int getRevision() { return this.currentContract.getState().getRevision(); }
@Test public void deserializeOldContract() throws Exception { TransactionPack tp = TransactionPack.unpack(c.sealAsV2()); checkSimplePack(tp); }
public Contract getPayloadContract() { if (payload != null) return payload.getContract(); return null; }
/** * Create new revision to be changed, signed sealed and then ready to approve. Created "revision" contract is a copy * of this contract, with all fields and references correctly set. After this call one need to change mutable * fields, add signing keys, seal it and then apss to Universa network for approval. * * @param keys initially added and signer keys. Role "creator" is set to these keys for new revision * @return new revision of this contract, identical to this one, to be modified. */ public synchronized Contract createRevision(Collection<PrivateKey> keys) { return createRevision(keys, null); }
/** * @see #createTokenContract(Set, Set, BigDecimal, BigDecimal, String, String, String) */ public synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue) { return createTokenContract(issuerKeys, ownerKeys, amount, minValue, "DT", "Default token name", "Default token description"); }
public void removeAllReferencedItems() { for (Contract c: getReferenced()) removeReferencedItem(c); } /**
@Override public Binder serialize(BiSerializer s) { Binder binder = Binder.of( "api_level", apiLevel, "definition", definition.serializeWith(s), "state", state.serializeWith(s) ); if(transactional != null) binder.set("transactional", transactional.serializeWith(s)); return binder; }
/** * Create new revision to be changed, signed sealed and then ready to approve. Created "revision" contract is a copy * of this contract, with all fields and references correctly set. After this call one need to change mutable * fields, add signing keys, seal it and then apss to Universa network for approval. * * @param keys initially added and signer keys. Role "creator" is set to anonymous ids of these keys * @return new revision of this contract, identical to this one, to be modified. */ public synchronized Contract createRevisionAnonymously(Collection<?> keys) { return createRevisionAnonymously(keys, null); }
/** * Check not pre-parsed condition of reference (old version) * @param condition condition to check for matching * @param ref contract to check for matching * @param contracts contract list to check for matching * @param iteration check inside references iteration number * @return true if match or false */ private boolean checkCondition(String condition, Contract ref, Collection<Contract> contracts, int iteration) { Binder parsed = parseCondition(condition); return checkCondition(parsed, ref, contracts, iteration); }
/** * Sign the data with a given key. * * @param key is {@link PrivateKey} to sign with * @param data to be sign with key * * @return binary signature */ static public byte[] sign(PrivateKey key, byte[] data) { return sign(key, data, true); }
/** * Create a transaction pack and add a contract to it. See {@link TransactionPack#TransactionPack()} and {@link * #setContract(Contract)} for more information. * * @param contract is {@link Contract} to be send with this {@link TransactionPack} */ public TransactionPack(Contract contract) { this(); setContract(contract); }
/** * Set "creator" role to given key records * @param records key records to set "creator" role to * @return creator role */ public Role setCreator(Collection<KeyRecord> records) { return setRole("creator", records); }
/** * Check if given item matching with current reference criteria * @param a item to check for matching * @param contracts contract list to check for matching * @return true if match or false */ public boolean isMatchingWith(Approvable a, Collection<Contract> contracts) { return isMatchingWith(a, contracts, 0); }
/** * Set the conditions from the reference * @return this reference */ public Reference setConditions(Binder conditions) { this.conditions = parseConditions(conditions); return this; }
/** * Create new transactional section for the contract * @return created transactional */ public Transactional createTransactionalSection() { transactional = new Transactional(); return transactional; }
protected static Contract createCoin(String yamlFilePath) throws IOException { Contract c = Contract.fromDslFile(yamlFilePath); c.setOwnerKey(ownerKey2); return c; }