congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
Contract.getRevokingItems
Code IndexAdd Tabnine to your IDE (free)

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

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

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
List l =
  • Codota Iconnew ArrayList()
  • Codota Iconnew LinkedList()
  • Smart code suggestions by Tabnine
}
origin: UniversaBlockchain/universa

/**
 * Get contracts current contract revokes upon registration
 * @return contracts to be revoked
 */
public List<Contract> getRevoking() {
  return new ArrayList<Contract>((Collection) getRevokingItems());
}
origin: UniversaBlockchain/universa

private Contract joinAndRemoveFromContracts(List<Contract> selectedContracts) throws Exception {
  Contract result = selectedContracts.get(0).copy();
  result.getRevokingItems().addAll(selectedContracts);
  this.contracts.removeAll(selectedContracts);
  result.setKeysToSignWith(selectedContracts.get(0).getKeysToSignWith());
  return result;
}
origin: UniversaBlockchain/universa

/**
 * Trace the tree of contracts subItems on the stdout.
 */
public void trace() {
  System.out.println("Transaction pack");
  System.out.println("\tContract:");
  System.out.println("\t\t" + contract.getId());
  contract.getNewItems().forEach(x -> System.out.println("\t\t\tnew: " + x.getId()));
  contract.getRevokingItems().forEach(x -> System.out.println("\t\t\trevoke: " + x.getId()));
  System.out.println("\tSubItems:");
  subItems.forEach((hashId, contract) -> System.out.println("\t\t" + hashId + " -> " + contract.getId()));
}
origin: UniversaBlockchain/universa

private void checkMerge(Contract changed, MapDelta<String, Binder, Binder> dataChanges, Set<Contract> revokingItems, Collection<PublicKey> keys, Decimal newValue) {
  boolean isValid;
  // merge means there are mergeable contracts in the revoking items
  Decimal sum = Decimal.ZERO;
  Set<Contract> revokesToRemove = new HashSet<>();
  for (Approvable a : changed.getRevokingItems()) {
    if (a instanceof Contract) {
      Contract c = (Contract) a;
      if (!isMergeable(c) || !validateMergeFields(changed, c) || !hasSimilarPermission(c, keys,true))
        continue;
      revokesToRemove.add(c);
      sum = sum.add(new Decimal(getFieldName(c)));
    }
  }
  isValid = sum.compareTo(newValue) == 0;
  if (!isValid) {
    revokesToRemove.clear();
    isValid = checkSplitJoinCase(changed, revokesToRemove, keys);
  }
  if (isValid) {
    dataChanges.remove(fieldName);
    revokingItems.removeAll(revokesToRemove);
  }
}
origin: UniversaBlockchain/universa

private void checkStateChange() throws Quantiser.QuantiserException {
  stateChanges = stateDelta.getChanges();
  revokingItems = new HashSet(changed.getRevokingItems());
  stateChanges.remove("created_by");
origin: UniversaBlockchain/universa

private static void saveContractSubitems(String source, String suffix, Contract contract) throws IOException {
  try {
    report("unpack contract from " + source);
    int i = 1;
    if (contract.getNewItems() != null) {
      for (Approvable newItem : contract.getNewItems()) {
        String newItemFileName = new FilenameTool(source).addSuffixToBase(suffix+"_new_item_" + i).toString();
        report("save newItem to " + newItemFileName);
        //                            ((Contract) newItem).seal();
        saveContract((Contract) newItem, newItemFileName);
        i++;
      }
    }
    i = 1;
    if (contract.getRevokingItems() != null) {
      for (Approvable revokeItem : contract.getRevokingItems()) {
        String revokeItemFileName = new FilenameTool(source).addSuffixToBase(suffix+"_revoke_" + i).setExtension("unicon").toString();
        report("save revokeItem to " + revokeItemFileName);
        saveContract((Contract) revokeItem, revokeItemFileName);
        i++;
      }
    }
  } catch (Quantiser.QuantiserException e) {
    addError("QUANTIZER_COST_LIMIT", contract.toString(), e.getMessage());
  }
}
origin: UniversaBlockchain/universa

public void checkSimplePack(TransactionPack tp) {
  assertEquals(3, tp.getSubItems().size());
  assertEquals(c.getId(), tp.getContract().getId());
  Set<HashId> rids = c.getRevokingItems().stream().map(x->x.getId()).collect(Collectors.toSet());
  Set<HashId> nids = c.getNewItems().stream().map(x->x.getId()).collect(Collectors.toSet());
  assertTrue(rids.contains(r0.getId()));
  assertTrue(nids.contains(n0.getId()));
  assertTrue(nids.contains(n1.getId()));
}
origin: UniversaBlockchain/universa

@Test
public void packedContractNotContainsOtherItems() throws Exception {
  // if we seal and load a contract without a pack, it should have empty
  // containers for new and revoking items - these should be fill separately.
  Contract c2 = new Contract(c.seal());
  assertEquals(0, c2.getRevokingItems().size());
  assertEquals(0, c2.getNewItems().size());
}
origin: UniversaBlockchain/universa

tc.createRole("creator", issuerRole);
if (!tc.getRevokingItems().contains(c)) {
  Binder data = tc.getDefinition().getData();
  List<Binder> actions = data.getOrCreateList("actions");
  tc.getRevokingItems().add(c);
  actions.add(Binder.fromKeysValues("action", "remove", "id", c.getId()));
origin: UniversaBlockchain/universa

protected synchronized void addDetailsToAllLedgers(Contract contract) {
  HashId id;
  StateRecord orCreate;
  for (Approvable c : contract.getRevokingItems()) {
    id = c.getId();
    for (Node nodeS : nodesMap.values()) {
      orCreate = nodeS.getLedger().findOrCreate(id);
      orCreate.setState(ItemState.APPROVED).save();
    }
  }
  destroyFromAllNodesExistingNew(contract);
  destroyCurrentFromAllNodesIfExists(contract);
}
origin: UniversaBlockchain/universa

List<Approvable> r1 = new ArrayList<>(c.getRevokingItems());
List<Approvable> r2 = new ArrayList<>(c1.getRevokingItems());
origin: UniversaBlockchain/universa

private boolean checkSplitJoinCase(Contract changed, Set<Contract> revokesToRemove, Collection<PublicKey> keys) {
  Decimal splitJoinSum = Decimal.ZERO;
  for (Contract c : changed.getSiblings()) {
    if (!isMergeable(c) || !validateMergeFields(changed, c) || !hasSimilarPermission(c, keys,  false))
      continue;
    splitJoinSum = splitJoinSum.add(new Decimal(c.getStateData().getString(fieldName)));
  }
  Decimal rSum = Decimal.ZERO;
  for (Approvable r : changed.getRevokingItems()) {
    if (r instanceof Contract) {
      Contract c = (Contract) r;
      if (!isMergeable(c) || !validateMergeFields(changed, c) || !hasSimilarPermission(c, keys, true))
        continue;
      revokesToRemove.add(c);
      rSum = rSum.add(new Decimal(((Contract) r).getStateData().getString(fieldName)));
    }
  }
  return splitJoinSum.compareTo(rSum) == 0;
}
origin: UniversaBlockchain/universa

  @Test
  public void newRevision() throws Exception {
    Contract c = Contract.fromDslFile(ROOT_CONTRACT);
    c.addSignerKeyFromFile(PRIVATE_KEY_PATH);
    byte[] sealed = c.seal();
    assertTrue(c.check());

    Contract c2 = c.createRevision(TestKeys.privateKey(0), TestKeys.privateKey(3));
    assertEquals(1, c2.getRevokingItems().size());
    assertEquals(c, c2.getRevokingItems().iterator().next());
    assertEquals(2, c2.getKeysToSignWith().size());
    assertEquals(2, c2.getRevision());
    assertEquals(c.getId(), c2.getParent());
    assertEquals(c.getId(), c2.getRawOrigin());

    c2.seal();

    Contract c3 = c2.createRevision(TestKeys.privateKey(0), TestKeys.privateKey(3));
    assertEquals(1, c3.getRevokingItems().size());
    assertEquals(c2, c3.getRevokingItems().iterator().next());
    assertEquals(2, c3.getKeysToSignWith().size());
    assertEquals(3, c3.getRevision());
    assertEquals(c2.getId(), c3.getParent());
    assertEquals(c.getId(), c3.getRawOrigin());


//        c2.check();
//        c2.traceErrors();
  }

origin: UniversaBlockchain/universa

for (int i = 0; i < 6; i++) {
  if(i < 5) {
    forJoin.getRevokingItems().add(splittedList.get(i));
  } else {
    Contract splitting = splittedList.get(i).createRevision();
    splitting.addSignerKeyFromFile(privateKeyPath);
    sealCheckTrace(splitting, true);
    forJoin.getRevokingItems().add(splitting);
    forJoin.addNewItems(splittedChanges);
origin: UniversaBlockchain/universa

System.out.println("check after split (c1.origin): " + c1.getOrigin().toBase64String());
System.out.println("check after split (c2.origin): " + c2.getOrigin().toBase64String());
((Contract)c1.getRevokingItems().iterator().next()).getStateData().set("amount", 2000);
c1.addSignerKey(key);
c1.seal();
origin: UniversaBlockchain/universa

@Test
public void shouldNotJoinWithWrongParent() throws Exception {
  Contract c = createCoin();
  c.addSignerKeyFromFile(PRIVATE_KEY_PATH);
  Contract c1 = c.splitValue(FIELD_NAME, new Decimal(1));
  Contract.ContractDev dev = c1.new ContractDev(c1);
  //Check after split.
  sealCheckTrace(c, true);
  //Set wrong parent
  HashId parent = HashId.withDigest(Do.randomNegativeBytes(64));
  HashId origin = HashId.withDigest(Do.randomNegativeBytes(64));
  dev.setParent(parent);
  dev.setOrigin(origin);
  c.getRevokingItems().add(dev.getContract());
  sealCheckTrace(c, false);
}
origin: UniversaBlockchain/universa

for (Approvable ri : getRevokingItems()) {
  if (ri.getExpiresAt().isAfter(expirationLimit)) {
    isSuitableForTestnet = false;
origin: UniversaBlockchain/universa

@Test
public void testJoinSum() throws Exception {
  Contract c = createCoin();
  c.addSignerKeyFromFile(PRIVATE_KEY_PATH);
  Binder d = c.getStateData();
  int a = 1000000;
  assertEquals(a, d.getIntOrThrow(FIELD_NAME));
  c.seal();
  c.check();
  c.traceErrors();
  assertTrue(c.check());
  // bad split: no changes
  Contract c1 = c.createRevision(ownerKey2);
  sealCheckTrace(c1, false);
  // Good split
  Contract c2 = c1.splitValue(FIELD_NAME, new Decimal(500));
  assertEquals(a - 500, c1.getStateData().getIntOrThrow(FIELD_NAME));
  assertEquals(500, c2.getStateData().getIntOrThrow(FIELD_NAME));
  c1.getErrors().clear();
  sealCheckTrace(c1, true);
  Contract c3 = c1.createRevision(ownerKey2);
  c3.getRevokingItems().add(c2);
  c3.getStateData().set(FIELD_NAME, new Decimal(a));
  sealCheckTrace(c3, true);
}
origin: UniversaBlockchain/universa

@Test
public void shouldNotJoinWithWrongAmount() throws Exception {
  int amount = 1000000;
  int v = 1;
  Contract c = createCoin();
  c.addSignerKeyFromFile(PRIVATE_KEY_PATH);
  sealCheckTrace(c, true);
  // Split with 1
  Contract c2 = c.splitValue(FIELD_NAME, new Decimal(v));
  assertEquals(amount - v, c.getStateData().getIntOrThrow(FIELD_NAME));
  assertEquals(v, c2.getStateData().getIntOrThrow(FIELD_NAME));
  sealCheckTrace(c2, true);
  Contract c3 = c.createRevision(ownerKey2);
  c3.getRevokingItems().add(c2);
  //Trying to hack the join and get bigger amount
  c3.getStateData().set(FIELD_NAME, new Decimal(v + 1));
  assertEquals(amount - v, c.getStateData().getIntOrThrow(FIELD_NAME));
  assertEquals(v + 1, c3.getStateData().getIntOrThrow(FIELD_NAME));
  sealCheckTrace(c3, false);
}
origin: UniversaBlockchain/universa

for (Approvable c : finalC.getRevokingItems()) {
  id = c.getId();
  for (int i = 0; i < nodes.size(); i++) {
com.icodici.universa.contractContractgetRevokingItems

Javadoc

Get contracts to be revoked within current contract registration. Revoking items require to be either parent of current contract or have special RevokePermission that is allowed for keys contract is signed with

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

  • Parsing JSON documents to java classes using gson
  • getSupportFragmentManager (FragmentActivity)
  • findViewById (Activity)
  • startActivity (Activity)
  • Menu (java.awt)
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Top 12 Jupyter Notebook Extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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