congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Contract.setCreatorKeys
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: UniversaBlockchain/universa

/**
 * 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
 * @param transactional is {@link Transactional} section to create new revision with
 * @return new revision of this contract, identical to this one, to be modified.
 */
public synchronized Contract createRevisionAnonymously(Collection<?> keys, Transactional transactional) {
  Contract newRevision = createRevision(transactional);
  Set<AnonymousId> aids = new HashSet<>();
  AtomicBoolean returnNull = new AtomicBoolean(false);
  keys.forEach(k -> {
    if (k instanceof AbstractKey)
      aids.add(AnonymousId.fromBytes(((AbstractKey) k).createAnonymousId()));
    else if (k instanceof AnonymousId)
      aids.add((AnonymousId)k);
    else
      returnNull.set(true);
  });
  newRevision.setCreatorKeys(aids);
  if (returnNull.get())
    return null;
  return newRevision;
}
origin: UniversaBlockchain/universa

/**
 * 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 addresses of these keys
 * @param transactional is {@link Transactional} section to create new revision with
 * @return new revision of this contract, identical to this one, to be modified.
 */
public synchronized Contract createRevisionWithAddress(Collection<?> keys, Transactional transactional) {
  Contract newRevision = createRevision(transactional);
  Set<KeyAddress> aids = new HashSet<>();
  AtomicBoolean returnNull = new AtomicBoolean(false);
  keys.forEach(k -> {
    if (k instanceof AbstractKey)
      aids.add(((AbstractKey) k).getPublicKey().getShortAddress());
    else if (k instanceof KeyAddress)
      aids.add((KeyAddress)k);
    else
      returnNull.set(true);
  });
  newRevision.setCreatorKeys(aids);
  if (returnNull.get())
    return null;
  return newRevision;
}
origin: UniversaBlockchain/universa

      SimpleRole role = new SimpleRole("owner", asList(new KeyAddress((String) owners.get(i))));
      partContracts[i].registerRole(role);
      partContracts[i].setCreatorKeys(keysMap().values());
    } catch (KeyAddress.IllegalAddressException e) {
      System.out.println("Not a valid address: " + owners.get(i));
contract.setCreatorKeys(keysMap().values());
origin: UniversaBlockchain/universa

public void asd() throws Exception {
  PrivateKey key = new PrivateKey(Do.read("/Users/romanu/Downloads/ru/roman.uskov.privateKey.unikey"));
  Set<PrivateKey> issuers = new HashSet<>();
  issuers.add(key);
  Set<PublicKey> owners = new HashSet<>();
  owners.add(key.getPublicKey());
  TestSpace testSpace = prepareTestSpace();
  testSpace.nodes.forEach(n->n.config.setIsFreeRegistrationsAllowedFromYaml(true));
  for(int i = 109; i < 110; i++) {
    Contract c = ContractsService.createTokenContract(issuers, owners, new BigDecimal("100000.9"), new BigDecimal("0.01"));
    c.setIssuerKeys(key.getPublicKey().getShortAddress());
    c.setCreatorKeys(key.getPublicKey().getShortAddress());
    c.setExpiresAt(ZonedDateTime.now().plusDays(10));
    c.seal();
    new FileOutputStream("/Users/romanu/Downloads/ru/token"+i+".unicon").write(c.getPackedTransaction());
    assertEquals(testSpace.client.register(Contract.fromPackedTransaction(Do.read("/Users/romanu/Downloads/ru/token"+i+".unicon")).getPackedTransaction(),10000).state,ItemState.APPROVED);
  }
}
origin: UniversaBlockchain/universa

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

anonSignedContract.setCreatorKeys(stepaAnonId);
anonSignedContract.addSignerKey(stepaPrivateKeys.iterator().next());
anonSignedContract.seal();
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

@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 issuerTest() throws Exception {
  KeyAddress keyAddress1 = TestKeys.privateKey(0).getPublicKey().getShortAddress();
  KeyAddress keyAddress2 = TestKeys.privateKey(1).getPublicKey().getShortAddress();
  Contract contract = new Contract(TestKeys.privateKey(2));
  contract.setCreatorKeys(keyAddress1);
  contract.setIssuerKeys(keyAddress2);
  contract.addSignerKey(TestKeys.privateKey(0));
  contract.seal();
  assertFalse(contract.check());
  contract.setIssuerKeys(keyAddress1);
  contract.getErrors().clear();
  contract.seal();
  assertTrue(contract.check());
}
origin: UniversaBlockchain/universa

badReferencedContract.setCreatorKeys(TestKeys.privateKey(1));
badReferencedContract.seal();
com.icodici.universa.contractContractsetCreatorKeys

Javadoc

Set "creator" 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

  • Reactive rest calls using spring rest template
  • scheduleAtFixedRate (Timer)
  • getSharedPreferences (Context)
  • getResourceAsStream (ClassLoader)
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now