/** * Method calls from {@link FollowerContract#fromDslFile(String)} and initialize contract from given binder. * * @param root id binder with initialized data * @return created and ready {@link FollowerContract} contract. * @throws EncryptionError if something went wrong */ protected FollowerContract initializeWithDsl(Binder root) throws EncryptionError { super.initializeWithDsl(root); return this; }
/** * Method creates smart contract from dsl file where contract is described. * @param fileName is path to dsl file with yaml structure of data for contract. */ public static NSmartContract fromDslFile(String fileName) throws IOException { Yaml yaml = new Yaml(); try (FileReader r = new FileReader(fileName)) { Binder binder = Binder.from(DefaultBiMapper.deserialize((Map) yaml.load(r))); return new NSmartContract().initializeWithDsl(binder); } }
protected UnsContract initializeWithDsl(Binder root) throws EncryptionError { super.initializeWithDsl(root); ArrayList<?> arrayNames = root.getBinder("state").getBinder("data").getArray(NAMES_FIELD_NAME); for (Object name: arrayNames) { Binder binder; if (name.getClass().getName().endsWith("Binder")) binder = (Binder) name; else binder = new Binder((Map) name); UnsName unsName = new UnsName().initializeWithDsl(binder); storedNames.add(unsName); } return this; }
/** * Method calls from {@link SlotContract#fromDslFile(String)} and initialize contract from given binder. * @param root id binder with initialized data * @return created and ready {@link SlotContract} contract. * @throws EncryptionError if something went wrong */ protected SlotContract initializeWithDsl(Binder root) throws EncryptionError { super.initializeWithDsl(root); int numRevisions = root.getBinder("state").getBinder("data").getInt(KEEP_REVISIONS_FIELD_NAME, -1); if(numRevisions > 0) keepRevisions = numRevisions; return this; }