report("load payment revision: " + u.getState().getRevision() + " id: " + u.getId()); report("save payment revision: " + newUContract.getState().getRevision() + " id: " + newUContract.getId());
JSApiScriptParameters scriptParameters1 = new JSApiScriptParameters(); scriptParameters1.timeLimitMillis = 3000; contract1.getState().setJS(js1.getBytes(), "script1.js", scriptParameters1, true); contract1.getState().setJS(js2.getBytes(), "script2.js", scriptParameters1, true); contract1.seal(); contract1 = Contract.fromPackedTransaction(contract1.getPackedTransaction()); JSApiScriptParameters scriptParameters2 = new JSApiScriptParameters(); scriptParameters2.timeLimitMillis = 3000; contract2.getState().setJS(js3.getBytes(), "script3.js", scriptParameters2, true); contract2.seal(); contract2 = Contract.fromPackedTransaction(contract2.getPackedTransaction()); scriptParameters.domainMasks.add("localhost:*"); scriptParameters.setPermission(JSApiScriptParameters.ScriptPermissions.PERM_HTTP_CLIENT, true); httpClientContract.getState().setJS(js.getBytes(), "client script.js", scriptParameters, true); httpClientContract.seal(); httpClientContract = Contract.fromPackedTransaction(httpClientContract.getPackedTransaction());
return (T) getParent(); case "branchId": return (T) state.getBranchId(); default: if (name.startsWith("data."))
case "origin": if (value.getOrThrow("data").getClass().equals(HashId.class)) state.setOrigin(value.getOrThrow("data")); else if (value.getOrThrow("data").getClass().equals(String.class)) state.setOrigin(new HashId(Base64u.decodeCompactString(value.getOrThrow("data")))); return; case "created_at": case "parent": if (value.getOrThrow("data").getClass().equals(HashId.class)) state.setParent(value.getOrThrow("data")); else if (value.getOrThrow("data").getClass().equals(String.class)) state.setParent(new HashId(Base64u.decodeCompactString(value.getOrThrow("data")))); return; case "revision": state.setRevision(value.getIntOrThrow("data")); return; case "branchRevision": state.setBranchNumber(value.getIntOrThrow("data")); default: if (subname.startsWith("data.")) case "origin": if (value.getOrThrow("data").getClass().equals(HashId.class)) state.setOrigin(value.getOrThrow("data")); else if (value.getOrThrow("data").getClass().equals(String.class)) state.setOrigin(new HashId(Base64u.decodeCompactString(value.getOrThrow("data")))); return; case "issuer":
" });" + "};"; contractServer.getState().setJS(js.getBytes(), "client script.js", new JSApiScriptParameters(), true); RoleLink issuerLink = new RoleLink("issuer_link", "issuer"); contractServer.registerRole(issuerLink); " });" + "};"; contractServer2.getState().setJS(js2.getBytes(), "client script.js", new JSApiScriptParameters(), true); contractServer2.seal(); contractServer2 = Contract.fromPackedTransaction(contractServer2.getPackedTransaction());
llcProperty3.getState().getReferences().remove(llcProperty3.getReferences().get("temp_certification_contract")); llcProperty3.getReferences().remove("temp_certification_contract");
newListConditions.add("inherits this.definition.references.bank_certificate"); llcProperty2.getState().getReferences().remove(llcProperty2.getReferences().get("account_in_bank_certificate")); llcProperty2.getReferences().remove("account_in_bank_certificate");
" });" + "};"; contractServer.getState().setJS(js.getBytes(), "client script.js", new JSApiScriptParameters(), true); RoleLink issuerLink = new RoleLink("issuer_link", "issuer"); contractServer.registerRole(issuerLink); " });" + "};"; contractServer2.getState().setJS(js2.getBytes(), "client script.js", new JSApiScriptParameters(), true); contractServer2.seal(); contractServer2 = Contract.fromPackedTransaction(contractServer2.getPackedTransaction());
assertTrue(remRefContract1.getState().getReferences().get(0).matchingItems.contains(contractCertificate)); assertFalse(remRefContract1.getState().getReferences().get(0).matchingItems.contains(contractCertificate)); assertTrue(remRefContract2.getState().getReferences().get(0).matchingItems.contains(contractCertificate)); assertFalse(remRefContract2.getState().getReferences().get(0).matchingItems.contains(contractCertificate));
JSApiScriptParameters scriptParameters = new JSApiScriptParameters(); scriptParameters.setPermission(JSApiScriptParameters.ScriptPermissions.PERM_REVISION_STORAGE, true); contract1.getState().setJS(js1.getBytes(), "client script.js", scriptParameters); contract1.seal(); System.out.println("contract1.getId: " + Bytes.toHex(contract1.getId().getDigest()).replaceAll(" ", "")); js2 += "fileParentReaded = bin2string(fileParentReaded);"; js2 += "var result = [file2Areaded, file2Breaded, fileParentReaded]"; contract2.getState().setJS(js2.getBytes(), "client script.js", scriptParameters); contract2.seal(); System.out.println("contract2.getId: " + Bytes.toHex(contract2.getId().getDigest()).replaceAll(" ", "")); js3 += "fileParentReaded = bin2string(fileParentReaded);"; js3 += "var result = [file3Areaded, file3Breaded, fileParentReaded]"; contract3.getState().setJS(js3.getBytes(), "client script.js", scriptParameters); contract3.seal(); System.out.println("contract3.getId: " + Bytes.toHex(contract3.getId().getDigest()).replaceAll(" ", ""));
if(uSource != null) { u = loadContract(uSource, true); report("load payment revision: " + u.getState().getRevision() + " id: " + u.getId()); report("save payment revision: " + newUContract.getState().getRevision() + " id: " + newUContract.getId());
report("load payment revision: " + u.getState().getRevision() + " id: " + u.getId()); report("save payment revision: " + newUContract.getState().getRevision() + " id: " + newUContract.getId());
assertEquals(originState.getRevision(), checkingState.getRevision()); assertEquals(originState.getBranchId(), checkingState.getBranchId()); assertEquals(originState.getBranchRevision(), checkingState.getBranchRevision());
contract1.getStateData().set("contract3_parent", contract3.getParent().toBase64String()); contract1.getState().setBranchNumber(25); System.out.println("branchId: " + contract1.getState().getBranchId()); contract1.seal();
JSApiScriptParameters scriptParameters1 = new JSApiScriptParameters(); scriptParameters1.timeLimitMillis = 3000; contract1.getState().setJS(js1.getBytes(), "script1.js", scriptParameters1, true); contract1.getState().setJS(js2.getBytes(), "script2.js", scriptParameters1, true); contract1.seal(); contract1 = Contract.fromPackedTransaction(contract1.getPackedTransaction()); JSApiScriptParameters scriptParameters2 = new JSApiScriptParameters(); scriptParameters2.timeLimitMillis = 3000; contract2.getState().setJS(js3.getBytes(), "script3.js", scriptParameters2, true); contract2.seal(); contract2 = Contract.fromPackedTransaction(contract2.getPackedTransaction());
JSApiScriptParameters scriptParameters = new JSApiScriptParameters(); scriptParameters.timeLimitMillis = 3000; contract.getState().setJS(js.getBytes(), "script.js", scriptParameters, true); contract.seal(); contract = Contract.fromPackedTransaction(contract.getPackedTransaction()); JSApiScriptParameters scriptParametersHost = new JSApiScriptParameters(); scriptParametersHost.timeLimitMillis = 3000; someFileHost.getState().setJS(jsHost.getBytes(), "fileHost.js", scriptParametersHost, true); someFileHost.seal(); someFileHost = Contract.fromPackedTransaction(someFileHost.getPackedTransaction());
JSApiScriptParameters scriptParameters = new JSApiScriptParameters(); scriptParameters.timeLimitMillis = 3000; contract.getState().setJS(js.getBytes(), "client script.js", scriptParameters, true); contract.seal(); contract = Contract.fromPackedTransaction(contract.getPackedTransaction());
cd.setExpiresAt(stepaCoins.getCreatedAt().minusDays(1)); Contract.State cs = stepaCoins.getState(); cs.setExpiresAt(stepaCoins.getCreatedAt().minusDays(1)); stepaCoins.seal(); stepaCoins.check();
assertEquals(1, state.getRevision()); assertEquals(c.getCreatedAt().truncatedTo(ChronoUnit.SECONDS), state.getCreatedAt().truncatedTo(ChronoUnit.SECONDS)); KeyRecord owner = c.testGetOwner(); assertNotNull(owner);
Contract parent = loadContract((String) parentItems.get(s)); if(parent != null) { contract.getState().setParent(parent.getId()); contract.getState().setOrigin(parent.getOrigin()); contract.getState().setRevision(parent.getRevision()+1); contract.getDefinition().setExpiresAt(parent.getDefinition().getExpiresAt()); contract.getDefinition().setCreatedAt(parent.getDefinition().getCreatedAt());