@Override public boolean isU(Set<KeyAddress> issuerKeys, String issuerName) { Role issuer = getIssuer(); if(!(issuer instanceof SimpleRole)) return false; Set<KeyAddress> thisIssuerAddresses = new HashSet<>(((SimpleRole)issuer).getSimpleKeyAddresses()); for (PublicKey publicKey : ((SimpleRole)issuer).getSimpleKeys()) thisIssuerAddresses.add(publicKey.getShortAddress()); if (Collections.disjoint(issuerKeys, thisIssuerAddresses)) return false; if ( !issuerName.equals(getDefinition().getData().get("issuerName"))) return false; return true; }
/** * Just print contracts info to console. * * @param contracts */ private static void printContracts(HashMap<String, Contract> contracts) { reporter.verbose(""); reporter.verbose("found contracts list: "); reporter.verbose(""); for (String key : contracts.keySet()) { try { String description; try { description = contracts.get(key).getDefinition().getData().getString("description"); } catch (Exception e) { description = ""; } reporter.verbose(key + ": " + "contract created at " + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(contracts.get(key).getCreatedAt()) + ": " + description ); } catch (Exception e) { e.printStackTrace(); } } }
private void initEndpoints() throws Exception { endpoints = new ConcurrentHashMap<>(); ConcurrentLinkedQueue<Exception> exceptions = new ConcurrentLinkedQueue<>(); routes.forEach((endpoint, route) -> { try { JSApiEnvironment apiEnvironment = JSApiEnvironment.execJSByName( route.contract.getDefinition().getData().getBinder(Contract.JSAPI_SCRIPT_FIELD, null), route.contract.getState().getData().getBinder(Contract.JSAPI_SCRIPT_FIELD, null), execOptions, route.scriptName, route.contract, route.jsParams == null ? new String[0] : route.jsParams ); apiEnvironment.setHandlerMethodName(route.handlerMethodName); apiEnvironment.setSlotId(route.slotId); endpoints.put(endpoint, apiEnvironment); } catch (Exception e) { exceptions.add(e); } }); if (!exceptions.isEmpty()) { throw exceptions.iterator().next(); } }
escrowPack.getDefinition().getData().set("EscrowOrigin", internalEscrow.getOrigin().toBase64String());
/** * Cancels escrow contract. All linked payments are made available to the customer. * For registration canceled escrow contract require quorum of 2 of 3 roles: customer, executor and arbitrator. * * @param escrow contract (external or internal) to cancel. Must be registered for creation new revision * * @return canceled internal escrow contract or null if error occurred */ public static Contract cancelEscrowContract(Contract escrow) { Contract escrowInside = escrow; if (!escrow.getStateData().getString("status", "null").equals("opened")) { // external escrow contract (escrow pack) // Find internal escrow contract in external escrow contract (escrow pack) String escrowOrigin = escrow.getDefinition().getData().getString("EscrowOrigin", null); if (escrowOrigin == null) return null; escrowInside = null; for (Contract c : escrow.getNew()) if (c.getOrigin().toBase64String().equals(escrowOrigin) && c.getStateData().getString("status", "null").equals("opened")) escrowInside = c; if (escrowInside == null) return null; } Contract revisionEscrow = escrowInside.createRevision(); revisionEscrow.getStateData().set("status", "canceled"); revisionEscrow.seal(); return revisionEscrow; }
/** * Completes escrow contract. All linked payments are made available to the executor. * For registration completed escrow contract require quorum of 2 of 3 roles: customer, executor and arbitrator. * * @param escrow contract (external or internal) to complete. Must be registered for creation new revision * * @return completed internal escrow contract or null if error occurred */ public static Contract completeEscrowContract(Contract escrow) { Contract escrowInside = escrow; if (!escrow.getStateData().getString("status", "null").equals("opened")) { // external escrow contract (escrow pack) // Find internal escrow contract in external escrow contract (escrow pack) String escrowOrigin = escrow.getDefinition().getData().getString("EscrowOrigin", null); if (escrowOrigin == null) return null; escrowInside = null; for (Contract c : escrow.getNew()) if (c.getOrigin().toBase64String().equals(escrowOrigin) && c.getStateData().getString("status", "null").equals("opened")) escrowInside = c; if (escrowInside == null) return null; } Contract revisionEscrow = escrowInside.createRevision(); revisionEscrow.getStateData().set("status", "completed"); revisionEscrow.seal(); return revisionEscrow; }
private void checkCreateParcelFotTestNet(String contract_file_payload, String contract_file_payment) throws Exception { final String ROOT_PATH = "./src/test_contracts/contractService/"; PrivateKey privateKey = TestKeys.privateKey(3); Set<PrivateKey> privateKeys = new HashSet<>(); privateKeys.add(privateKey); Set<PublicKey> publicKeys = new HashSet<>(); publicKeys.add(privateKey.getPublicKey()); Contract payload = Contract.fromDslFile(ROOT_PATH + contract_file_payload); payload.addSignerKey(privateKey); payload.seal(); Contract payment = InnerContractsService.createFreshU(100, publicKeys, true); Parcel parcel = ContractsService.createParcel(payload, payment, 20, privateKeys, true); assertEquals(parcel.getPayloadContract().getState().getBranchId(), payload.getState().getBranchId()); assertEquals(parcel.getPaymentContract().getState().getBranchId(), payment.getState().getBranchId()); assertEquals(parcel.getPayloadContract().getStateData(), payload.getStateData()); assertEquals(parcel.getPaymentContract().getDefinition().getData(), payment.getDefinition().getData()); assertEquals(100, parcel.getPaymentContract().getStateData().getIntOrThrow("transaction_units")); assertEquals(10000 - 20, parcel.getPaymentContract().getStateData().getIntOrThrow("test_transaction_units")); System.out.println("OK"); }
/** * Executes javascript, that previously should be saved in contract's definition * with {@link Definition#setJS(byte[], String, JSApiScriptParameters)} or {@link State#setJS(byte[], String, JSApiScriptParameters)}. * Provides instance of {@link JSApi} to this script, as 'jsApi' global var. * @param params list of strings, will be passed to javascript * @return Object, got it from 'result' global var of javascript. * @throws ScriptException if javascript throws some errors * @throws IllegalArgumentException if javascript is not defined in contract's definition */ public Object execJS(JSApiExecOptions execOptions, byte[] jsFileContent, String... params) throws Exception { JSApiEnvironment env = JSApiEnvironment.execJS( getDefinition().getData().getBinder(JSAPI_SCRIPT_FIELD, null), getState().getData().getBinder(JSAPI_SCRIPT_FIELD, null), execOptions, jsFileContent, this, params ); env.callEvent("main", true); return env.getResult(); }
private void checkCreateParcel(String contract_file_payload, String contract_file_payment) throws Exception { final String ROOT_PATH = "./src/test_contracts/contractService/"; PrivateKey privateKey = TestKeys.privateKey(3); Contract payload = Contract.fromDslFile(ROOT_PATH + contract_file_payload); payload.addSignerKey(privateKey); payload.seal(); Contract payment = Contract.fromDslFile(ROOT_PATH + contract_file_payment); payment.addSignerKey(privateKey); payment.seal(); Set<PrivateKey> PrivateKeys = new HashSet<>(); PrivateKeys.add(privateKey); Parcel parcel = ContractsService.createParcel(payload, payment, 20, PrivateKeys); assertEquals(parcel.getPayloadContract().getState().getBranchId(), payload.getState().getBranchId()); assertEquals(parcel.getPaymentContract().getState().getBranchId(), payment.getState().getBranchId()); assertEquals(parcel.getPayloadContract().getStateData(), payload.getStateData()); assertEquals(parcel.getPaymentContract().getDefinition().getData(), payment.getDefinition().getData()); System.out.println("OK"); }
@Test public void jsFileContentInContract_byFilename() throws Exception { String fileName = "somescript.zip"; String scriptDump = "UEsDBBQAAgAIAEGVA02XbF8YbAEAAPoEAAANAAAAc29tZXNjcmlwdC5qc62UXU+DMBSG7038D9yVRUOckTk1XkzmzMiY+xJ0y7JU6KATKLYF9vNlyj6cUtR42/O+z3vSntOI4pDLwEO+T6SUUN8BlavDgwRSyY4pRSHXSMgptLl0LS1YI8KKi7j2uSSvLNEHac+1UrcduXIpAelIKiiK7QOUYIZJKIBsJWKURhHkyGlwAWtHI4bdU+xiUVdrgRjTg6sTAWYtEGOGPOu6CTlsYeQ7MiMBmiXQj1ExeM8Cth7whzAPMm+GnV/G5a6ywCaa4xDz7Il3Um2KI86KA78zgdxVFthmLEZUNLe5oGRG0lBIyes/mFpCy2aW7IGg73/Rsk2koijvm16omIAxZNyKrG7PeE1MvWEQmxkPI909U3G9QzTVYAE97/CLW6jrg9Q8XZrgWAKwypbewuF3XhctcH1o6d3eS2qqQc1xrTnt34Qebiyf++l4VHtSW+yxCab/dokUsdjffFXZ5sCATU6mmW/3oDrNpG9QSwECFAAUAAIACABBlQNNl2xfGGwBAAD6BAAADQAAAAAAAAAAACAAAAAAAAAAc29tZXNjcmlwdC5qc1BLBQYAAAAAAQABADsAAACXAQAAAAA="; Contract contract = new Contract(TestKeys.privateKey(0)); contract.getStateData().set("some_value", HashId.createRandom().toBase64String()); contract.getStateData().set("some_hash_id", HashId.createRandom()); JSApiScriptParameters scriptParameters = new JSApiScriptParameters(); scriptParameters.isCompressed = true; contract.getDefinition().setJS(Base64.decodeLines(scriptDump), fileName, scriptParameters, true); contract.seal(); String res = (String)contract.execJSByName("somescript.zip", "3", "6"); System.out.println("res: " + res); assertEquals("36", res); String compression = contract.getDefinition().getData().getOrThrow("scripts", JSApiHelpers.fileName2fileKey(fileName), "compression"); System.out.println("compression: " + compression); assertEquals(JSApiCompressionEnum.ZIP, JSApiCompressionEnum.valueOf(compression)); }
@Test public void compressedJavaScript() throws Exception { String fileName = "somescript.zip"; String scriptDump = "UEsDBBQAAgAIAEGVA02XbF8YbAEAAPoEAAANAAAAc29tZXNjcmlwdC5qc62UXU+DMBSG7038D9yVRUOckTk1XkzmzMiY+xJ0y7JU6KATKLYF9vNlyj6cUtR42/O+z3vSntOI4pDLwEO+T6SUUN8BlavDgwRSyY4pRSHXSMgptLl0LS1YI8KKi7j2uSSvLNEHac+1UrcduXIpAelIKiiK7QOUYIZJKIBsJWKURhHkyGlwAWtHI4bdU+xiUVdrgRjTg6sTAWYtEGOGPOu6CTlsYeQ7MiMBmiXQj1ExeM8Cth7whzAPMm+GnV/G5a6ywCaa4xDz7Il3Um2KI86KA78zgdxVFthmLEZUNLe5oGRG0lBIyes/mFpCy2aW7IGg73/Rsk2koijvm16omIAxZNyKrG7PeE1MvWEQmxkPI909U3G9QzTVYAE97/CLW6jrg9Q8XZrgWAKwypbewuF3XhctcH1o6d3eS2qqQc1xrTnt34Qebiyf++l4VHtSW+yxCab/dokUsdjffFXZ5sCATU6mmW/3oDrNpG9QSwECFAAUAAIACABBlQNNl2xfGGwBAAD6BAAADQAAAAAAAAAAACAAAAAAAAAAc29tZXNjcmlwdC5qc1BLBQYAAAAAAQABADsAAACXAQAAAAA="; Contract contract = new Contract(TestKeys.privateKey(0)); contract.getStateData().set("some_value", HashId.createRandom().toBase64String()); contract.getStateData().set("some_hash_id", HashId.createRandom()); JSApiScriptParameters scriptParameters = new JSApiScriptParameters(); scriptParameters.isCompressed = true; contract.getDefinition().setJS(Base64.decodeLines(scriptDump), fileName, scriptParameters); contract.seal(); String res = (String)contract.execJS(Base64.decodeLines(scriptDump), "3", "6"); System.out.println("res: " + res); assertEquals("36", res); String compression = contract.getDefinition().getData().getOrThrow("scripts", JSApiHelpers.fileName2fileKey(fileName), "compression"); System.out.println("compression: " + compression); assertEquals(JSApiCompressionEnum.ZIP, JSApiCompressionEnum.valueOf(compression)); }
@Test public void jsFileContentInContract() throws Exception { String fileName = "somescript.js"; String scriptDump = "cHJpbnQoJ2hlbGxvIHdvcmxkJyk7DQp2YXIgY3VycmVudENvbnRyYWN0ID0ganNBcGkuZ2V0Q3VycmVudENvbnRyYWN0KCk7DQpwcmludCgnY3VycmVudENvbnRyYWN0LmdldElkKCk6ICcgKyBjdXJyZW50Q29udHJhY3QuZ2V0SWQoKSk7DQpwcmludCgnY3VycmVudENvbnRyYWN0LmdldFJldmlzaW9uKCk6ICcgKyBjdXJyZW50Q29udHJhY3QuZ2V0UmV2aXNpb24oKSk7DQpwcmludCgnY3VycmVudENvbnRyYWN0LmdldENyZWF0ZWRBdCgpOiAnICsgY3VycmVudENvbnRyYWN0LmdldENyZWF0ZWRBdCgpKTsNCnByaW50KCdjdXJyZW50Q29udHJhY3QuZ2V0T3JpZ2luKCk6ICcgKyBjdXJyZW50Q29udHJhY3QuZ2V0T3JpZ2luKCkpOw0KcHJpbnQoJ2N1cnJlbnRDb250cmFjdC5nZXRQYXJlbnQoKTogJyArIGN1cnJlbnRDb250cmFjdC5nZXRQYXJlbnQoKSk7DQpwcmludCgnY3VycmVudENvbnRyYWN0LmdldFN0YXRlRGF0YUZpZWxkKHNvbWVfdmFsdWUpOiAnICsgY3VycmVudENvbnRyYWN0LmdldFN0YXRlRGF0YUZpZWxkKCdzb21lX3ZhbHVlJykpOw0KcHJpbnQoJ2N1cnJlbnRDb250cmFjdC5nZXRTdGF0ZURhdGFGaWVsZChzb21lX2hhc2hfaWQpOiAnICsgY3VycmVudENvbnRyYWN0LmdldFN0YXRlRGF0YUZpZWxkKCdzb21lX2hhc2hfaWQnKSk7DQpwcmludCgnY3VycmVudENvbnRyYWN0LmdldERlZmluaXRpb25EYXRhRmllbGQoc2NyaXB0cyk6ICcgKyBjdXJyZW50Q29udHJhY3QuZ2V0RGVmaW5pdGlvbkRhdGFGaWVsZCgnc2NyaXB0cycpKTsNCnByaW50KCdjdXJyZW50Q29udHJhY3QuZ2V0SXNzdWVyKCk6ICcgKyBjdXJyZW50Q29udHJhY3QuZ2V0SXNzdWVyKCkpOw0KcHJpbnQoJ2N1cnJlbnRDb250cmFjdC5nZXRPd25lcigpOiAnICsgY3VycmVudENvbnRyYWN0LmdldE93bmVyKCkpOw0KcHJpbnQoJ2N1cnJlbnRDb250cmFjdC5nZXRDcmVhdG9yKCk6ICcgKyBjdXJyZW50Q29udHJhY3QuZ2V0Q3JlYXRvcigpKTsNCnByaW50KCdjYWxsIGN1cnJlbnRDb250cmFjdC5zZXRPd25lcigpLi4uJyk7DQpjdXJyZW50Q29udHJhY3Quc2V0T3duZXIoWydaYXN0V3BXTlBNcXZWSkFNb2NzTVVUSmc0NWk4TG9DNU1zbXI3THQ5RWFKSlJ3VjJ4VicsICdhMXN4aGpkdEdoTmVqaThTV0pOUGt3VjVtNmRnV2ZyUUJuaGlBeGJRd1pUNlk1RnNYRCddKTsNCnByaW50KCdjdXJyZW50Q29udHJhY3QuZ2V0T3duZXIoKTogJyArIGN1cnJlbnRDb250cmFjdC5nZXRPd25lcigpKTsNCnJlc3VsdCA9IGpzQXBpUGFyYW1zWzBdICsganNBcGlQYXJhbXNbMV07DQo="; Contract contract = new Contract(TestKeys.privateKey(0)); contract.getStateData().set("some_value", HashId.createRandom().toBase64String()); contract.getStateData().set("some_hash_id", HashId.createRandom()); contract.getDefinition().setJS(Base64.decodeLines(scriptDump), fileName, new JSApiScriptParameters(), true); contract.seal(); HashId scriptHash = HashId.of(Base64.decodeLines(scriptDump)); String res = (String)contract.execJSByScriptHash(scriptHash, "3", "6"); System.out.println("res: " + res); assertEquals("36", res); String compression = contract.getDefinition().getData().getOrThrow("scripts", JSApiHelpers.fileName2fileKey(fileName), "compression"); System.out.println("compression: " + compression); assertEquals(JSApiCompressionEnum.RAW, JSApiCompressionEnum.valueOf(compression)); }
/** * Executes javascript, like {@link Contract#execJS(JSApiExecOptions, byte[], String...)}, * but searches script body in contract. It should be saved previously with {@link Definition#setJS(byte[], String, JSApiScriptParameters, boolean)} * or {@link State#setJS(byte[], String, JSApiScriptParameters, boolean)} with putContentIntoContract == true. * @param scriptHash is {@link HashId} from js-file content. */ public Object execJSByScriptHash(JSApiExecOptions execOptions, HashId scriptHash, String... params) throws Exception { JSApiEnvironment env = JSApiEnvironment.execJSByScriptHash( getDefinition().getData().getBinder(JSAPI_SCRIPT_FIELD, null), getState().getData().getBinder(JSAPI_SCRIPT_FIELD, null), execOptions, scriptHash, this, params ); return env.callEvent("main", true); }
@Test public void rawJavaScript() throws Exception { String fileName = "somescript.js"; String scriptDump = "cHJpbnQoJ2hlbGxvIHdvcmxkJyk7DQp2YXIgY3VycmVudENvbnRyYWN0ID0ganNBcGkuZ2V0Q3VycmVudENvbnRyYWN0KCk7DQpwcmludCgnY3VycmVudENvbnRyYWN0LmdldElkKCk6ICcgKyBjdXJyZW50Q29udHJhY3QuZ2V0SWQoKSk7DQpwcmludCgnY3VycmVudENvbnRyYWN0LmdldFJldmlzaW9uKCk6ICcgKyBjdXJyZW50Q29udHJhY3QuZ2V0UmV2aXNpb24oKSk7DQpwcmludCgnY3VycmVudENvbnRyYWN0LmdldENyZWF0ZWRBdCgpOiAnICsgY3VycmVudENvbnRyYWN0LmdldENyZWF0ZWRBdCgpKTsNCnByaW50KCdjdXJyZW50Q29udHJhY3QuZ2V0T3JpZ2luKCk6ICcgKyBjdXJyZW50Q29udHJhY3QuZ2V0T3JpZ2luKCkpOw0KcHJpbnQoJ2N1cnJlbnRDb250cmFjdC5nZXRQYXJlbnQoKTogJyArIGN1cnJlbnRDb250cmFjdC5nZXRQYXJlbnQoKSk7DQpwcmludCgnY3VycmVudENvbnRyYWN0LmdldFN0YXRlRGF0YUZpZWxkKHNvbWVfdmFsdWUpOiAnICsgY3VycmVudENvbnRyYWN0LmdldFN0YXRlRGF0YUZpZWxkKCdzb21lX3ZhbHVlJykpOw0KcHJpbnQoJ2N1cnJlbnRDb250cmFjdC5nZXRTdGF0ZURhdGFGaWVsZChzb21lX2hhc2hfaWQpOiAnICsgY3VycmVudENvbnRyYWN0LmdldFN0YXRlRGF0YUZpZWxkKCdzb21lX2hhc2hfaWQnKSk7DQpwcmludCgnY3VycmVudENvbnRyYWN0LmdldERlZmluaXRpb25EYXRhRmllbGQoc2NyaXB0cyk6ICcgKyBjdXJyZW50Q29udHJhY3QuZ2V0RGVmaW5pdGlvbkRhdGFGaWVsZCgnc2NyaXB0cycpKTsNCnByaW50KCdjdXJyZW50Q29udHJhY3QuZ2V0SXNzdWVyKCk6ICcgKyBjdXJyZW50Q29udHJhY3QuZ2V0SXNzdWVyKCkpOw0KcHJpbnQoJ2N1cnJlbnRDb250cmFjdC5nZXRPd25lcigpOiAnICsgY3VycmVudENvbnRyYWN0LmdldE93bmVyKCkpOw0KcHJpbnQoJ2N1cnJlbnRDb250cmFjdC5nZXRDcmVhdG9yKCk6ICcgKyBjdXJyZW50Q29udHJhY3QuZ2V0Q3JlYXRvcigpKTsNCnByaW50KCdjYWxsIGN1cnJlbnRDb250cmFjdC5zZXRPd25lcigpLi4uJyk7DQpjdXJyZW50Q29udHJhY3Quc2V0T3duZXIoWydaYXN0V3BXTlBNcXZWSkFNb2NzTVVUSmc0NWk4TG9DNU1zbXI3THQ5RWFKSlJ3VjJ4VicsICdhMXN4aGpkdEdoTmVqaThTV0pOUGt3VjVtNmRnV2ZyUUJuaGlBeGJRd1pUNlk1RnNYRCddKTsNCnByaW50KCdjdXJyZW50Q29udHJhY3QuZ2V0T3duZXIoKTogJyArIGN1cnJlbnRDb250cmFjdC5nZXRPd25lcigpKTsNCnJlc3VsdCA9IGpzQXBpUGFyYW1zWzBdICsganNBcGlQYXJhbXNbMV07DQo="; Contract contract = new Contract(TestKeys.privateKey(0)); contract.getStateData().set("some_value", HashId.createRandom().toBase64String()); contract.getStateData().set("some_hash_id", HashId.createRandom()); contract.getDefinition().setJS(Base64.decodeLines(scriptDump), fileName, new JSApiScriptParameters()); contract.seal(); String res = (String)contract.execJS(Base64.decodeLines(scriptDump), "3", "6"); System.out.println("res: " + res); assertEquals("36", res); String compression = contract.getDefinition().getData().getOrThrow("scripts", JSApiHelpers.fileName2fileKey(fileName), "compression"); System.out.println("compression: " + compression); assertEquals(JSApiCompressionEnum.RAW, JSApiCompressionEnum.valueOf(compression)); }
public String getDefinitionDataField(String fieldPath) { return this.currentContract.getDefinition().getData().getStringOrThrow(fieldPath); }
/** * Executes attached javascript if only one js is attached. Also, it should be attached with putContentIntoContract == true. */ public Object execJSByName(JSApiExecOptions execOptions, String jsFileName, String... params) throws Exception { JSApiEnvironment env = JSApiEnvironment.execJSByName( getDefinition().getData().getBinder(JSAPI_SCRIPT_FIELD, null), getState().getData().getBinder(JSAPI_SCRIPT_FIELD, null), execOptions, jsFileName, this, params ); return env.callEvent("main", true); }
public void updateThisEnvironmentByName(Contract newContract, JSApiExecOptions execOptions) throws Exception { JSApiEnvironment env = execJSByName( newContract.getDefinition().getData().getBinder(Contract.JSAPI_SCRIPT_FIELD, null), newContract.getState().getData().getBinder(Contract.JSAPI_SCRIPT_FIELD, null), execOptions, jsFileName, newContract, stringParams ); this.jsApi = env.jsApi; this.scriptEngine = env.scriptEngine; this.currentContract = env.currentContract; this.result = env.result; }
@Test public void createContractWithJS() throws Exception { ScriptEngine jse = new NashornScriptEngineFactory().getScriptEngine(new ClassFilter_allowSomething()); jse.eval("var contract = new com.icodici.universa.contract.Contract();"); jse.eval("contract.getDefinition().getData().put('someKey', 'someValue');"); jse.eval("contract.seal()"); Contract contract = (Contract)jse.get("contract"); System.out.println("contract id: " + contract.getId()); System.out.println("contract someKey: " + contract.getDefinition().getData().getString("someKey")); assertEquals("someValue", contract.getDefinition().getData().getString("someKey")); }
/** * Saves client's javascript in contract's definition. It can be executed with {@link Contract#execJS(JSApiExecOptions, byte[], String...)} * @param putContentIntoContract pass here true to save js body in contract, in this case it's not necessary to store attached * js-files separately, needs only {@link HashId} of its. */ public void setJS(byte[] jsFileContent, String jsFileName, JSApiScriptParameters scriptParameters, boolean putContentIntoContract) { String fileNameKey = JSApiHelpers.fileName2fileKey(jsFileName); Binder scriptBinder = JSApiHelpers.createScriptBinder(jsFileContent, jsFileName, scriptParameters, putContentIntoContract); Binder scripts = getData().getBinder(JSAPI_SCRIPT_FIELD, new Binder()); scripts.set(fileNameKey, scriptBinder); getData().put(JSAPI_SCRIPT_FIELD, scripts); }
public List<String> extractJSNames() { List<String> res = new ArrayList<>(); Binder scriptBinder = getDefinition().getData().getBinder(JSAPI_SCRIPT_FIELD, null); if (scriptBinder == null) scriptBinder = getState().getData().getBinder(JSAPI_SCRIPT_FIELD, null); if (scriptBinder != null) res.addAll(JSApiHelpers.getFileNamesFromScriptBinder(scriptBinder)); return res; }