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

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

Best Java code snippets using com.icodici.universa.contract.Contract.getCreatedAt (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

public long getCreatedAt() {
  return this.currentContract.getCreatedAt().toEpochSecond();
}
origin: UniversaBlockchain/universa

/**
 * Just print contracts info to console.
 *
 * @param contracts
 */
private static void printContracts(HashMap<String, Contract> contracts) {
  reporter.verbose("");
  reporter.verbose("found contracts list: ");
  reporter.verbose("");
  for (String key : contracts.keySet()) {
    try {
      String description;
      try {
        description = contracts.get(key).getDefinition().getData().getString("description");
      } catch (Exception e) {
        description = "";
      }
      reporter.verbose(key + ": " +
                   "contract created at " +
                   DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(contracts.get(key).getCreatedAt()) +
                   ": " +
                   description
      );
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
origin: UniversaBlockchain/universa

@Test
public void checkPaymentContract() throws Exception {
  // to register manually, execute from deploy project:
  // bin/sql_all pro "insert into ledger(hash,state,created_at, expires_at, locked_by_id) values(decode('9186C0A9E9471E4559E74B5DAC3DBBB8445807DF80CAE4CE06FDB6588FAEBA1CE004AD378BEF3C445DECF3375E3CA5FD16227DBE5831A21207BB1BD21C85F30D0CED014E152F77E62082E0442FBD9FD2458C20778F7501B5D425AF9984062E54','hex'),'4','1520977039','1552513039','0');"
  // to erase all ledgers, execute:
  // bin/sql_all pro "truncate table ledger"
  // (after erasing ledgers, items still stay in cache -> need to restart (or redeploy) nodes)
  Contract contract = paymentContract;
  contract.check();
  System.out.println("uno bin: " + Base64.encodeString(contract.getPackedTransaction()));
  System.out.println("uno hashId: " + Bytes.toHex(contract.getId().getDigest()).replace(" ", ""));
  System.out.println("approved ord: " + ItemState.APPROVED.ordinal());
  System.out.println("getCreatedAt: " + StateRecord.unixTime(contract.getCreatedAt()));
  System.out.println("getExpiresAt: " + StateRecord.unixTime(contract.getExpiresAt()));
  ItemResult itemResult = normalClient.getState(contract.getId());
  System.out.println("getState... done! itemResult: " + itemResult.state);
}
origin: UniversaBlockchain/universa

/**
 * Save specified parcel to file.
 *
 * @param parcel              - parcel to save.
 * @param fileName              - name of file to save to.
 *
 */
public static boolean saveParcel(Parcel parcel, String fileName) throws IOException {
  if (fileName == null) {
    fileName = "Universa_" + DateTimeFormatter.ofPattern("yyyy-MM-ddTHH:mm:ss").format(parcel.getPayloadContract().getCreatedAt()) + ".uniparcel";
  }
  byte[] data = parcel.pack();
  String newFileName = FileTool.writeFileContentsWithRenaming(fileName, data);
  report("Parcel is saved to: " + newFileName);
  report("Parcel size: " + data.length);
  try {
    if (parcel.getPaymentContract().check() && parcel.getPayloadContract().check()) {
      report("Parcel has no errors");
    } else {
      addErrors(parcel.getPaymentContract().getErrors());
      addErrors(parcel.getPayloadContract().getErrors());
    }
  } catch (Quantiser.QuantiserException e) {
    addError("QUANTIZER_COST_LIMIT", parcel.toString(), e.getMessage());
  }
  return (newFileName!=null);
}
origin: UniversaBlockchain/universa

cd.setExpiresAt(tc.getCreatedAt().plusDays(30));
origin: UniversaBlockchain/universa

@Test
public void checkContractExpiresAtDistantFutureTime() throws Exception{
  Contract futureContract = Contract.fromDslFile(rootPath + "simple_root_contract.yml");
  futureContract.addSignerKeyFromFile(rootPath+"_xer0yfe2nn1xthc.private.unikey");
  futureContract.getDefinition().setExpiresAt(futureContract.getCreatedAt().plusYears(50));
  futureContract.seal();
  assertTrue(futureContract.check());
  System.out.println("Contract is valid: " + futureContract.isOk());
}
origin: UniversaBlockchain/universa

@Test
public void checkContractExpiresAtResentFutureTime() throws Exception{
  Contract futureContract = Contract.fromDslFile(rootPath + "simple_root_contract.yml");
  futureContract.addSignerKeyFromFile(rootPath+"_xer0yfe2nn1xthc.private.unikey");
  futureContract.getDefinition().setExpiresAt(futureContract.getCreatedAt().plusMinutes(1));
  futureContract.seal();
  assertTrue(futureContract.check());
  System.out.println("Contract is valid: " + futureContract.isOk());
}
origin: UniversaBlockchain/universa

@Test
public void checkRegisterContractExpiresAtReсentFutureTime() throws Exception{
  Contract futureContract = Contract.fromDslFile(ROOT_PATH + "simple_root_contract.yml");
  futureContract.addSignerKeyFromFile(ROOT_PATH+"_xer0yfe2nn1xthc.private.unikey");
  futureContract.getDefinition().setExpiresAt(futureContract.getCreatedAt().plusMinutes(1));
  futureContract.seal();
  assertTrue(futureContract.check());
  System.out.println("Contract is valid: " + futureContract.isOk());
  registerAndCheckApproved(futureContract);
}
origin: UniversaBlockchain/universa

@Test
public void checkContractExpiresAtDistantFutureTime() throws Exception{
  Contract futureContract = Contract.fromDslFile(ROOT_PATH + "simple_root_contract.yml");
  futureContract.addSignerKeyFromFile(ROOT_PATH+"_xer0yfe2nn1xthc.private.unikey");
  futureContract.getDefinition().setExpiresAt(futureContract.getCreatedAt().plusYears(50));
  futureContract.seal();
  assertTrue(futureContract.check());
  System.out.println("Contract is valid: " + futureContract.isOk());
  registerAndCheckApproved(futureContract);
}
origin: UniversaBlockchain/universa

@Test
public void checkRegisterContractExpiresAtReсentPastTime() throws Exception{
  Contract oldContract = Contract.fromDslFile(ROOT_PATH + "simple_root_contract.yml");
  oldContract.addSignerKeyFromFile(ROOT_PATH+"_xer0yfe2nn1xthc.private.unikey");
  oldContract.getDefinition().setExpiresAt(oldContract.getCreatedAt().minusMinutes(1));
  oldContract.seal();
  oldContract.check();
  oldContract.traceErrors();
  System.out.println("Contract is valid: " + oldContract.isOk());
  assertFalse(oldContract.isOk());
}
origin: UniversaBlockchain/universa

@Test
public void checkContractExpiresAtResentPastTime() throws Exception{
  Contract oldContract = Contract.fromDslFile(rootPath + "simple_root_contract.yml");
  oldContract.addSignerKeyFromFile(rootPath+"_xer0yfe2nn1xthc.private.unikey");
  oldContract.getDefinition().setExpiresAt(oldContract.getCreatedAt().minusMinutes(1));
  oldContract.seal();
  oldContract.check();
  oldContract.traceErrors();
  System.out.println("Contract is valid: " + oldContract.isOk());
  assertFalse(oldContract.isOk());
}
origin: UniversaBlockchain/universa

assertTrue(notaryContract.getCreatedAt().isBefore(ZonedDateTime.now()));
origin: UniversaBlockchain/universa

@Test
public void goodNotary() throws Exception {
  Set<PrivateKey> martyPrivateKeys = new HashSet<>();
  Set<PrivateKey> stepaPrivateKeys = new HashSet<>();
  Set<PublicKey> martyPublicKeys = new HashSet<>();
  Set<PublicKey> stepaPublicKeys = new HashSet<>();
  martyPrivateKeys.add(new PrivateKey(Do.read(rootPath + "keys/marty_mcfly.private.unikey")));
  stepaPrivateKeys.add(new PrivateKey(Do.read(rootPath + "keys/stepan_mamontov.private.unikey")));
  for (PrivateKey pk : stepaPrivateKeys)
    stepaPublicKeys.add(pk.getPublicKey());
  for (PrivateKey pk : martyPrivateKeys)
    martyPublicKeys.add(pk.getPublicKey());
  Contract notaryContract = ContractsService.createNotaryContract(martyPrivateKeys, stepaPublicKeys);
  notaryContract.check();
  notaryContract.traceErrors();
  assertTrue(notaryContract.isOk());
  assertTrue(notaryContract.getOwner().isAllowedForKeys(stepaPublicKeys));
  assertTrue(notaryContract.getIssuer().isAllowedForKeys(martyPrivateKeys));
  assertTrue(notaryContract.getCreator().isAllowedForKeys(martyPrivateKeys));
  assertFalse(notaryContract.getOwner().isAllowedForKeys(martyPrivateKeys));
  assertFalse(notaryContract.getIssuer().isAllowedForKeys(stepaPublicKeys));
  assertFalse(notaryContract.getCreator().isAllowedForKeys(stepaPublicKeys));
  assertTrue(notaryContract.getExpiresAt().isAfter(ZonedDateTime.now().plusMonths(3)));
  assertTrue(notaryContract.getCreatedAt().isBefore(ZonedDateTime.now()));
  assertTrue(notaryContract.isPermitted("revoke", stepaPublicKeys));
  assertTrue(notaryContract.isPermitted("revoke", martyPublicKeys));
  assertTrue(notaryContract.isPermitted("change_owner", stepaPublicKeys));
  assertFalse(notaryContract.isPermitted("change_owner", martyPublicKeys));
}
origin: UniversaBlockchain/universa

ZonedDateTime t = c.getCreatedAt();
assertAlmostSame(ZonedDateTime.now(), c.getCreatedAt());
assertEquals("2022-08-05T17:25:37Z", c.getExpiresAt().withZoneSameInstant(ZoneOffset.UTC).toString());
assertEquals(c.getCreatedAt().truncatedTo(ChronoUnit.SECONDS),
       state.getCreatedAt().truncatedTo(ChronoUnit.SECONDS));
KeyRecord owner = c.testGetOwner();
origin: UniversaBlockchain/universa

assertTrue(tokenContract.getCreatedAt().isBefore(ZonedDateTime.now()));
origin: UniversaBlockchain/universa

assertTrue(shareContract.getCreatedAt().isBefore(ZonedDateTime.now()));
origin: UniversaBlockchain/universa

assertTrue(tokenContract.getCreatedAt().isBefore(ZonedDateTime.now()));
origin: UniversaBlockchain/universa

escrowPack.setApiLevel(3);
escrowPack.getDefinition().setExpiresAt(escrowPack.getCreatedAt().plusMonths(60));
origin: UniversaBlockchain/universa

@Ignore
@Test
public void checkRevisionExpiresAtReсentPastTime() throws Exception{
  Contract baseContract = Contract.fromDslFile(ROOT_PATH + "DeLoreanOwnership.yml");
  PrivateKey manufacturePrivateKey = new PrivateKey(Do.read(ROOT_PATH + "_xer0yfe2nn1xthc.private.unikey"));
  PrivateKey ownerPrivateKey = new PrivateKey(Do.read(ROOT_PATH + "keys/marty_mcfly.private.unikey"));
  baseContract.addSignerKey(manufacturePrivateKey);
  baseContract.seal();
  baseContract.check();
  baseContract.traceErrors();
  System.out.println("Base contract is valid: " + baseContract.isOk());
  registerAndCheckApproved(baseContract);
  Contract revContract  = baseContract.createRevision(ownerPrivateKey);
  revContract.setExpiresAt(revContract.getCreatedAt().minusMinutes(1));
  revContract.seal();
  revContract.check();
  revContract.traceErrors();
  assertTrue(revContract.isOk());
}
origin: UniversaBlockchain/universa

@Ignore
@Test
public void checkRevisionExpiresAtReсentFutureTime() throws Exception{
  Contract baseContract = Contract.fromDslFile(ROOT_PATH + "DeLoreanOwnership.yml");
  PrivateKey manufacturePrivateKey = new PrivateKey(Do.read(ROOT_PATH + "_xer0yfe2nn1xthc.private.unikey"));
  PrivateKey ownerPrivateKey = new PrivateKey(Do.read(ROOT_PATH + "keys/marty_mcfly.private.unikey"));
  baseContract.addSignerKey(manufacturePrivateKey);
  baseContract.seal();
  baseContract.check();
  baseContract.traceErrors();
  System.out.println("Base contract is valid: " + baseContract.isOk());
  registerAndCheckApproved(baseContract);
  Contract revContract  = baseContract.createRevision(ownerPrivateKey);
  revContract.setExpiresAt(revContract.getCreatedAt().plusMinutes(1));
  revContract.seal();
  revContract.check();
  revContract.traceErrors();
  assertTrue(revContract.isOk());
}
com.icodici.universa.contractContractgetCreatedAt

Javadoc

Get contract creation time

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,
  • getDefinition,
  • getErrors,
  • getKeysToSignWith,
  • getLastSealedBinary,
  • getNew,
  • getNewItems

Popular in Java

  • Running tasks concurrently on multiple threads
  • setRequestProperty (URLConnection)
  • findViewById (Activity)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • InetAddress (java.net)
    This class represents an Internet Protocol (IP) address. An IP address is either a 32-bit or 128-bit
  • KeyStore (java.security)
    This class represents an in-memory collection of keys and certificates. It manages two types of entr
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
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