Codota Logo
Contract.setOwnerKeys
Code IndexAdd Codota to your IDE (free)

How to use
setOwnerKeys
method
in
com.icodici.universa.contract.Contract

Best Java code snippets using com.icodici.universa.contract.Contract.setOwnerKeys (Showing top 20 results out of 315)

  • Common ways to obtain Contract
private void myMethod () {
Contract c =
  • Codota Iconnew Contract()
  • Codota IconString fileName;Contract.fromDslFile(fileName)
  • Codota IconParcel parcel;parcel.getPaymentContract()
  • Smart code suggestions by Codota
}
origin: UniversaBlockchain/universa

/**
 * Set "owner" role to given keys
 * @param keys keys to set "owner" role to
 * @return owner role
 */
@NonNull
public Role setOwnerKeys(Object... keys) {
  return setOwnerKeys(asList(keys));
}
origin: UniversaBlockchain/universa

public void setOwner(List<String> addresses) throws KeyAddress.IllegalAddressException {
  List<KeyAddress> addressesList = new ArrayList<>();
  for (String s : addresses)
    addressesList.add(new KeyAddress(s));
  this.currentContract.setOwnerKeys(addressesList);
}
origin: UniversaBlockchain/universa

/**
 * Transfers payment contract to new owner on the result of escrow.
 * Use payment contract that was added to external escrow contract by
 * {@link ContractsService#addPaymentToEscrowContract(Contract, Contract, Collection, Collection, Collection)} or
 * was modified by {@link ContractsService#modifyPaymentForEscrowContract(Contract, Contract, Collection, Collection, Collection)}.
 * Executor can take the payment contract, if internal escrow contract are completed.
 * Customer can take the payment contract, if internal escrow contract are canceled.
 * For registration payment contract (returned by this method) need to add result internal escrow contract by
 * {@link TransactionPack#addReferencedItem(Contract)}.
 *
 * @param newOwnerKeys are private keys of new owner of payment
 * @param payment contract to take by new owner. Must be registered for creation new revision
 *
 * @return new revision of payment contract with new owner
 */
public static Contract takeEscrowPayment(Collection<PrivateKey> newOwnerKeys, Contract payment) {
  Contract revisionPayment = payment.createRevision(newOwnerKeys);
  // set new owner
  revisionPayment.setOwnerKeys(newOwnerKeys);
  // remove escrow references from Contract.references (from transactional section references removed automatically)
  revisionPayment.getReferences().remove("return_payment_to_customer");
  revisionPayment.getReferences().remove("send_payment_to_executor");
  revisionPayment.seal();
  return revisionPayment;
}
origin: UniversaBlockchain/universa

PrivateKey goodKey = c.getKeysToSignWith().iterator().next();
c.setOwnerKeys(goodKey);
c.seal();
String contractFileName = basePath + "with_role_for_revoke.unicon";
origin: UniversaBlockchain/universa

PrivateKey goodKey = c.getKeysToSignWith().iterator().next();
c.setOwnerKeys(goodKey);
c.seal();
origin: UniversaBlockchain/universa

twoSignContract.getTransactional().addReference(reference);
twoSignContract.setOwnerKeys(toKeys);
twoSignContract.seal();
origin: UniversaBlockchain/universa

  @Test
  public void goodRevoke() throws Exception {
    Contract c = Contract.fromDslFile(rootPath + "simple_root_contract.yml");
    c.addSignerKeyFromFile(rootPath+"_xer0yfe2nn1xthc.private.unikey");
    PrivateKey goodKey = c.getKeysToSignWith().iterator().next();
    c.setOwnerKeys(new KeyRecord(goodKey.getPublicKey()));
    c.seal();

    Contract revokeContract = c.createRevocation(goodKey);

    revokeContract.check();
    assertTrue(revokeContract.isOk());
//        tc.traceErrors();
  }

origin: UniversaBlockchain/universa

jobCertificate.setOwnerKeys(stepaPublicKeys);
jobCertificate.getDefinition().getData().set("issuer", "Roga & Kopita");
jobCertificate.getDefinition().getData().set("type", "chief accountant assignment");
origin: UniversaBlockchain/universa

jobCertificate.setOwnerKeys(stepaPublicKeys);
jobCertificate.getDefinition().getData().set("issuer", "Roga & Kopita");
jobCertificate.getDefinition().getData().set("type", "chief accountant assignment");
llcProperty2.setOwnerKeys(thirdPartyPublicKeys);
llcProperty2.seal();
llcProperty2.check();
origin: UniversaBlockchain/universa

jobCertificate.setOwnerKeys(stepaPublicKeys);
jobCertificate.getDefinition().getData().set("issuer", "Roga & Kopita");
jobCertificate.getDefinition().getData().set("type", "chief accountant assignment");
origin: UniversaBlockchain/universa

anonSignedContract.setOwnerKeys(martyPublicKeys);
anonSignedContract.setCreatorKeys(stepaAddress);
anonSignedContract.addSignerKey(stepaPrivateKeys.iterator().next());
origin: UniversaBlockchain/universa

jobCertificate.setOwnerKeys(stepaPublicKeys);
jobCertificate.getDefinition().getData().set("issuer", "Roga & Kopita");
jobCertificate.getDefinition().getData().set("type", "chief accountant assignment");
origin: UniversaBlockchain/universa

anonSignedContract.setOwnerKeys(martyPublicKeys);
anonSignedContract.seal();
anonSignedContract.check();
origin: UniversaBlockchain/universa

anonSignedContract.setOwnerKeys(martyPublicKeys);
anonSignedContract.setCreatorKeys(stepaAnonId);
anonSignedContract.addSignerKey(stepaPrivateKeys.iterator().next());
origin: UniversaBlockchain/universa

anonSignedContract.setOwnerKeys(martyPublicKeys);
anonSignedContract.seal();
anonSignedContract.check();
origin: UniversaBlockchain/universa

@Test
public void goodRevokeAnother() throws Exception {
  Contract c1 = new Contract(ownerKey1);
  RoleLink rl = new RoleLink("@revoke", "owner");
  rl.setContract(c1);
  c1.addPermission(new RevokePermission(rl));
  c1.seal();
  Contract c2 = new Contract(ownerKey2);
  c2.seal();
  Assert.assertTrue(c2.check());
  Contract c3 = c2.createRevision(ownerKey2);
  //to prevent "state is identical"
  c3.setOwnerKeys(ownerKey3);
  c3.addSignerKey(ownerKey1);
  c3.addRevokingItems(c1);
  c3.seal();
  assertTrue(c3.check());
}
origin: UniversaBlockchain/universa

@Test
public void jsInStateAndDefinition() throws Exception {
  Contract contract = new Contract(TestKeys.privateKey(0));
  contract.setOwnerKeys(TestKeys.publicKey(1), TestKeys.publicKey(2), TestKeys.publicKey(3));
  contract.setCreatorKeys(TestKeys.publicKey(4), TestKeys.publicKey(5).getLongAddress());
  String jsDefinitionA = "print('hello world from definition A'); result = 'dA';";
  String jsDefinitionB = "print('hello world from definition B'); result = 'dB';";
  String jsStateA = "print('hello world from state A'); result = 'sA';";
  String jsStateB = "print('hello world from state B'); result = 'sB';";
  contract.getDefinition().setJS(jsDefinitionA.getBytes(), "script1.js", new JSApiScriptParameters(), true);
  contract.getDefinition().setJS(jsDefinitionB.getBytes(), "script2.js", new JSApiScriptParameters(), true);
  contract.getState().setJS(jsStateA.getBytes(), "script3.js", new JSApiScriptParameters(), true);
  contract.getState().setJS(jsStateB.getBytes(), "script4.js", new JSApiScriptParameters(), true);
  contract.seal();
  String res1 = (String)contract.execJSByName("script1.js");
  String res2 = (String)contract.execJSByName("script2.js");
  String res3 = (String)contract.execJSByName("script3.js");
  String res4 = (String)contract.execJSByName("script4.js");
  assertEquals("dA", res1);
  assertEquals("dB", res2);
  assertEquals("sA", res3);
  assertEquals("sB", res4);
}
origin: UniversaBlockchain/universa

@Test
public void jsInContract() throws Exception {
  Contract contract = new Contract(TestKeys.privateKey(0));
  contract.setOwnerKeys(TestKeys.publicKey(1), TestKeys.publicKey(2), TestKeys.publicKey(3));
  contract.setCreatorKeys(TestKeys.publicKey(4), TestKeys.publicKey(5).getLongAddress());
  System.out.println("testKey[10].getShortAddress: " + TestKeys.publicKey(10).getShortAddress().toString());
  System.out.println("testKey[11].getShortAddress: " + TestKeys.publicKey(11).getShortAddress().toString());
  contract.getStateData().set("some_value", HashId.createRandom().toBase64String());
  contract.getStateData().set("some_hash_id", HashId.createRandom());
  String js = "";
  js += "print('hello world');";
  js += "var currentContract = jsApi.getCurrentContract();";
  js += "print('currentContract.getId(): ' + currentContract.getId());";
  js += "print('currentContract.getRevision(): ' + currentContract.getRevision());";
  js += "print('currentContract.getCreatedAt(): ' + currentContract.getCreatedAt());";
  js += "print('currentContract.getOrigin(): ' + currentContract.getOrigin());";
  js += "print('currentContract.getParent(): ' + currentContract.getParent());";
  js += "print('currentContract.getStateDataField(some_value): ' + currentContract.getStateDataField('some_value'));";
  js += "print('currentContract.getStateDataField(some_hash_id): ' + currentContract.getStateDataField('some_hash_id'));";
  js += "print('currentContract.getDefinitionDataField(scripts): ' + currentContract.getDefinitionDataField('scripts'));";
  js += "print('currentContract.getIssuer(): ' + currentContract.getIssuer());";
  js += "print('currentContract.getOwner(): ' + currentContract.getOwner());";
  js += "print('currentContract.getCreator(): ' + currentContract.getCreator());";
  js += "print('call currentContract.setOwner()...');";
  js += "currentContract.setOwner(['ZastWpWNPMqvVJAMocsMUTJg45i8LoC5Msmr7Lt9EaJJRwV2xV', 'a1sxhjdtGhNeji8SWJNPkwV5m6dgWfrQBnhiAxbQwZT6Y5FsXD']);";
  js += "print('currentContract.getOwner(): ' + currentContract.getOwner());";
  contract.getDefinition().setJS(js.getBytes(), "client script.js", new JSApiScriptParameters());
  contract.seal();
  contract.execJS(js.getBytes());
}
origin: UniversaBlockchain/universa

c3.addSignerKey(ownerKey1);
c3.setOwnerKeys(ownerKey2);
c2.seal();
c3.seal();
c4.setOwnerKeys(ownerKey3);
c4.addSignerKey(ownerKey1);
origin: UniversaBlockchain/universa

@Test
public void badRevokeAnother() throws Exception {
  Contract c1 = new Contract(ownerKey1);
  RoleLink rl = new RoleLink("@revoke", "owner");
  rl.setContract(c1);
  c1.addPermission(new RevokePermission(rl));
  c1.seal();
  Contract c2 = new Contract(ownerKey2);
  c2.seal();
  Assert.assertTrue(c2.check());
  Contract c3 = c2.createRevision(ownerKey2);
  //to prevent "state is identical"
  c3.setOwnerKeys(ownerKey3);
  c3.addRevokingItems(c1);
  c3.seal();
  assertFalse(c3.check());
}
com.icodici.universa.contractContractsetOwnerKeys

Javadoc

Set "owner" role to given keys

Popular methods of Contract

  • <init>
    Extract old, deprecated v2 self-contained binary partially unpacked by the TransactionPack, and fill
  • addNewItems
    Add one or more siblings to the contract. Note that those must be sealed before calling #seal() or #
  • addSignerKey
    Add private key to keys contract binary to be signed with when sealed next time. It is called before
  • getExpiresAt
    Get contract expiration time
  • getId
    Get the id sealing self if need
  • getPackedTransaction
    Pack the contract to the most modern .unicon format, same as TransactionPack#pack(). Uses bounded Tr
  • registerRole
    Register new role. Name must be unique otherwise existing role will be overwritten
  • seal
    Seal contract to binary. This call adds signatures from #getKeysToSignWith()
  • addSignatureToSeal
    Add signature to sealed (before) contract. Do not deserializing or changing contract bytes, but will
  • check
  • createRevision
    Create new revision to be changed, signed sealed and then ready to approve. Created "revision" contr
  • fromDslFile
    Create contract importing its parameters with passed .yaml file. No signatures are added automatical
  • createRevision,
  • fromDslFile,
  • fromPackedTransaction,
  • getCreatedAt,
  • getDefinition,
  • getErrors,
  • getKeysToSignWith,
  • getLastSealedBinary,
  • getNew,
  • getNewItems

Popular in Java

  • Start an intent from android
  • onCreateOptionsMenu (Activity)
  • getExternalFilesDir (Context)
  • startActivity (Activity)
  • FileInputStream (java.io)
    A FileInputStream obtains input bytes from a file in a file system. What files are available depends
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • List (java.util)
    A List is a collection which maintains an ordering for its elements. Every element in the List has a
  • Timer (java.util)
    A facility for threads to schedule tasks for future execution in a background thread. Tasks may be s
  • Join (org.hibernate.mapping)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now