Tabnine Logo
Contract.getNewItems
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: UniversaBlockchain/universa

/**
 * Get contracts current contract creates upon registration
 * @return contracts to be created
 */
public List<? extends Contract> getNew() {
  return new ArrayList<Contract>((Collection) getNewItems());
}
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

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

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

protected synchronized void destroyFromAllNodesExistingNew(Contract c50_1) {
  StateRecord orCreate;
  for (Approvable c : c50_1.getNewItems()) {
    for (Node nodeS : nodesMap.values()) {
      orCreate = nodeS.getLedger().getRecord(c.getId());
      if (orCreate != null)
        orCreate.destroy();
    }
  }
}
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

});
tp.getContract().getNewItems().forEach(a -> {
  resultsNew.put(a.getId(),new HashMap<>());
});
origin: UniversaBlockchain/universa

@Ignore
@Test
public void registerFromFile() throws Exception {
  TestSpace testSpace = prepareTestSpace(TestKeys.privateKey(0));
  testSpace.nodes.forEach(m -> m.config.setIsFreeRegistrationsAllowedFromYaml(true));
  Path path = Paths.get("/tmp/not3.unicon");
  byte[] testTransactionPackBytes = Files.readAllBytes(path);
  Contract contract = Contract.fromPackedTransaction(testTransactionPackBytes);
  System.out.println("======================");
  System.out.println("check(): " + contract.check());
  System.out.println("------- errors -------");
  contract.traceErrors();
  int i = 0;
  for (Approvable a : contract.getNewItems()) {
    Contract nc = (Contract) a;
    System.out.println("------- errors n"+i+" ----");
    System.out.println("  check: " + nc.check());
    nc.traceErrors();
    ++i;
  }
  System.out.println("======================");
  System.out.println("hashId: " + contract.getId().toBase64String());
  testSpace.node.setVerboseLevel(DatagramAdapter.VerboseLevel.BASE);
  ItemResult itemResult = testSpace.client.register(testTransactionPackBytes, 5000);
  ItemResult itemResult2 = testSpace.client.getState(contract.getId());
  System.out.println("itemResult: " + itemResult);
  System.out.println("itemResult2: " + itemResult2);
  testSpace.nodes.forEach(m -> m.shutdown());
}
origin: UniversaBlockchain/universa

List<Approvable> n1 = new ArrayList<>(c.getNewItems());
List<Approvable> n2 = new ArrayList<>(c1.getNewItems());
origin: UniversaBlockchain/universa

System.out.println("Transaction contract for swapping is valid: " + swapContract.isOk() + " num new contracts: " + swapContract.getNewItems().size());
origin: UniversaBlockchain/universa

System.out.println("Transaction contract for swapping is valid: " + swapContract.isOk() + " num new contracts: " + swapContract.getNewItems().size());
registerAndCheckApproved(swapContract);
for(Approvable a : swapContract.getNewItems()) {
  assertEquals(ItemState.APPROVED, node.waitItem(a.getId(), 5000).state);
  System.out.println("new is " + node.waitItem(a.getId(), 5000).state);
origin: UniversaBlockchain/universa

@Test
public void dupesWrongTest() throws Exception {
  PrivateKey key = new PrivateKey(Do.read(rootPath + "_xer0yfe2nn1xthc.private.unikey"));
  Set<PrivateKey> keys = new HashSet<>();
  keys.add(key);
  Contract c_1 = Contract.fromDslFile(rootPath + "coin100.yml");
  c_1.addSignerKey(key);
  c_1.seal();
  assertTrue(c_1.check());
  c_1.traceErrors();
  Contract c_2_1 = ContractsService.createSplit(c_1, new BigDecimal("20"), "amount", keys);
  Contract c_2_2 = c_2_1.getNew().get(0);
  if(c_2_2 != null) {
    Contract c_2_3 = c_2_2.copy();
    c_2_3.addSignerKey(key);
    c_2_3.seal();
    c_2_1.addNewItems(c_2_3);
  }
  assertEquals(2, c_2_1.getNewItems().size());
  c_2_1.check();
  c_2_1.traceErrors();
  assertFalse(c_2_1.isOk());
  // should be BAD_VALUE duplicated revision id
  assertEquals(2, c_2_1.getErrors().size());
}
origin: UniversaBlockchain/universa

assertTrue(c3.isOk());
c2.getNewItems().clear();
c2.addNewItems(c3);
assertEquals(1, c2.getNewItems().size());
origin: UniversaBlockchain/universa

swapContract.getNewItems().clear();
swapContract.addNewItems(martyCoinsSplit, stepaCoinsSplit);
swapContract.seal();
origin: UniversaBlockchain/universa

ContractsService.finishSwap(swapContract, martyPrivateKeys);
swapContract.getNewItems().clear();
swapContract.addNewItems(martyCoinsSplit, stepaCoinsSplit);
swapContract.seal();
origin: UniversaBlockchain/universa

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

swapContract.getNewItems().clear();
swapContract.addNewItems(user1CoinsSplit, user2CoinsSplit);
swapContract.seal();
origin: UniversaBlockchain/universa

for (Contract c: baseContract.getNew())
  if (!c.equals(slotContract)) {
    baseContract.getNewItems().remove(c);
    slotContract.addNewItems(c);
    slotContract.seal();
origin: UniversaBlockchain/universa

for (Contract c : baseContract.getNew())
  if (!c.equals(followerContract)) {
    baseContract.getNewItems().remove(c);
    followerContract.addNewItems(c);
    followerContract.seal();
origin: UniversaBlockchain/universa

for (Contract c : baseContract.getNew())
  if (!c.equals(followerContract)) {
    baseContract.getNewItems().remove(c);
    followerContract.addNewItems(c);
    followerContract.seal();
for (Contract c : baseContract2.getNew())
  if (!c.equals(refilledFollowerContract)) {
    baseContract2.getNewItems().remove(c);
    refilledFollowerContract.addNewItems(c);
    refilledFollowerContract.seal();
com.icodici.universa.contractContractgetNewItems

Javadoc

Get contracts to be registered within current contract registration.

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

Popular in Java

  • Updating database using SQL prepared statement
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • addToBackStack (FragmentTransaction)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • ImageIO (javax.imageio)
  • JFileChooser (javax.swing)
  • CodeWhisperer alternatives
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