Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.seq.api;
import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;
import java.util.*;
import java.util.concurrent.TimeUnit;
import com.seq.exception.*;
import com.seq.http.*;
/**
* A transaction is an atomic update to the state of the ledger. Transactions
* can issue new flavor units, transfer flavor units from one account to
* another, and/or retire flavor units from an account.
*/
public class Transaction {
/**
* A unique ID.
*/
public String id;
/**
* Time of transaction.
*/
public Date timestamp;
/**
* Sequence number of the transaction.
*/
@SerializedName("sequence_number")
public long sequenceNumber;
/**
* User-specified key-value data embedded into the transaction.
*/
@SerializedName("reference_data")
public Map referenceData;
/**
* List of actions taken by the transaction.
*/
public List actions;
/**
* List of contracts created by the transaction.
*/
public List contracts;
/**
* A single page of transactions returned from a query.
*/
public static class Page extends BasePage {}
/**
* Iterable interface for consuming individual transactions from a query.
*/
public static class ItemIterable extends BaseItemIterable {
public ItemIterable(Client client, String path, Query nextQuery) {
super(client, path, nextQuery, Page.class);
}
}
/**
* Iterable interface for consuming pages of transactions from a query.
*/
public static class PageIterable extends BasePageIterable {
public PageIterable(Client client, String path, Query nextQuery) {
super(client, path, nextQuery, Page.class);
}
}
/**
* A builder class for querying transactions in the ledger.
*/
public static class QueryBuilder extends BaseQueryBuilder {
/**
* Executes the query, returning a page of transactions.
* @param client ledger API connection object
* @return a page of transactions
* @throws ChainException
*/
public Page getPage(Client client) throws ChainException {
return client.request("list-transactions", this.next, Page.class);
}
/**
* Executes the query, returning a page of transactions that match the query
* beginning with provided cursor.
* @param client ledger API connection object
* @param cursor string representing encoded query object
* @return a page of transactions
* @throws ChainException
*/
public Page getPage(Client client, String cursor) throws ChainException {
Query next = new Query();
next.cursor = cursor;
return client.request("list-transactions", next, Page.class);
}
/**
* Executes the query, returning an iterable over transactions that match
* the query.
* @param client ledger API connection object
* @return an iterable over transactions
* @throws ChainException
*/
public ItemIterable getIterable(Client client) throws ChainException {
return new ItemIterable(client, "list-transactions", this.next);
}
/**
* Executes a query on the ledger's transactions, returning an iterable over
* pages of transactoins that match the query.
* @param client ledger API connection object
* @return an iterable over pages of transactions
* @throws ChainException
*/
public PageIterable getPageIterable(Client client) throws ChainException {
return new PageIterable(client, "list-transactions", this.next);
}
/**
* Specifies the timestamp of the earliest transaction to include in the query results.
* @param time unixtime in milliseconds
* @return updated builder
* @deprecated use "timestamp >= $1" with {@link #setFilter} instead
*/
@Deprecated
public QueryBuilder setStartTime(long time) {
this.next.startTime = time;
return this;
}
/**
* Specifies the timestamp of the most recent transaction to include in the query results.
* @param time unixtime in milliseconds
* @deprecated use "timestamp <= $1" with {@link #setFilter} instead
* @return updated builder
*/
@Deprecated
public QueryBuilder setEndTime(long time) {
this.next.endTime = time;
return this;
}
}
/**
* An action taken by a transaction.
*/
public static class Action {
/**
* The type of the action. Possible values are "issue", "transfer" and "retire".
*/
public String type;
/**
* The id of the action's flavor.
*/
@SerializedName("flavor_id")
public String flavorId;
/**
* A copy of the associated tags (flavor, source account, destination
* account, action, and token) as they existed at the time of the
* transaction.
*/
@SerializedName("snapshot")
public Snapshot snapshot;
/**
* The id of the action's asset.
* @deprecated use {@link #flavorId} instead
*/
@Deprecated
@SerializedName("asset_id")
public String assetId;
/**
* The alias of the action's asset.
* @deprecated use {@link #flavorId} instead
*/
@Deprecated
@SerializedName("asset_alias")
public String assetAlias;
/**
* The tags of the action's asset.
* @deprecated use {@link #snapshot} instead
*/
@Deprecated
@SerializedName("asset_tags")
public Map assetTags;
/**
* The number of flavor units issued, transferred, or retired.
*/
public long amount;
/**
* The ID of the account serving as the source of flavor units. Null for
* issuances.
*/
@SerializedName("source_account_id")
public String sourceAccountId;
/**
* The alias of the account serving as the source of asset units. Null for issuances.
* @deprecated see {@link #sourceAccountId} instead
*/
@Deprecated
@SerializedName("source_account_alias")
public String sourceAccountAlias;
/**
* The tags of the account serving as the source of flavor units. Null for
* issuances.
* @deprecated use {@link #snapshot} instead
*/
@Deprecated
@SerializedName("source_account_tags")
public Map sourceAccountTags;
/**
* The ID of the account receiving the flavor units. Null for retirements.
*/
@SerializedName("destination_account_id")
public String destinationAccountId;
/**
* The alias of the account receiving the asset units. Null for retirements.
* @deprecated see {@link #destinationAccountId} instead
*/
@Deprecated
@SerializedName("destination_account_alias")
public String destinationAccountAlias;
/**
* The tags of the account receiving the flavor units. Null for retirements.
* @deprecated use {@link #snapshot} instead
*/
@Deprecated
@SerializedName("destination_account_tags")
public Map destinationAccountTags;
/**
* User-specified, key-value data embedded into the action.
*/
@SerializedName("tags")
public Map tags;
/**
* User-specified, key-value data embedded into the action.
*/
@Deprecated
@SerializedName("reference_data")
public Map referenceData;
public static class Snapshot {
/**
* A snapshot of the actions's tags at the time of action creation
*/
@SerializedName("action_tags")
public Map actionTags;
/**
* A snapshot of the flavor's tags at the time of action creation
*/
@SerializedName("flavor_tags")
public Map flavorTags;
/**
* A snapshot of the source account's tags at the time of action creation
*/
@SerializedName("source_account_tags")
public Map sourceAccountTags;
/**
* A snapshot of the destination account's tags at the time of action creation
*/
@SerializedName("destination_account_tags")
public Map destinationAccountTags;
/**
* A snapshot of the tokens's tags at the time of action creation
*/
@SerializedName("token_tags")
public Map tokenTags;
}
}
/**
* A configuration object for creating and submitting transactions.
*/
public static class Builder {
@SerializedName("reference_data")
protected Map referenceData;
protected List actions;
/**
* Builds, signs, and submits a tranasaction.
* @param client ledger API connection object
* @return the submitted transaction object
* @throws ChainException
*/
public Transaction transact(Client client) throws ChainException {
return client.request("transact", this, Transaction.class);
}
public Builder() {
this.actions = new ArrayList<>();
}
/**
* Specifies key-value data to be recorded in the transaction.
* @param referenceData arbitrary key-value data
* @return updated builder
*/
public Builder setReferenceData(Map referenceData) {
this.referenceData = referenceData;
return this;
}
/**
* Adds a key-value pair to the transaction's reference data.
* @param key key of the reference data field
* @param value value of reference data field
* @return updated builder
*/
public Builder addReferenceDataField(String key, Object value) {
if (this.referenceData == null) {
this.referenceData = new HashMap<>();
}
this.referenceData.put(key, value);
return this;
}
/**
* Adds an action to a transaction builder.
* @param action action to add
* @return updated builder
*/
public Builder addAction(Action action) {
this.actions.add(action);
return this;
}
/**
* Base class representing actions that can be taken within a transaction.
*/
public static class Action extends HashMap {
public Action() {}
protected void addKeyValueField(String mapKey, String fieldKey, Object value) {
Map keyValueData = (Map) get(mapKey);
if (keyValueData == null) {
keyValueData = new HashMap();
put(mapKey, keyValueData);
}
keyValueData.put(fieldKey, value);
}
protected void addListItem(String mapKey, Object param) {
List