java.lang.Object
tech.deplant.java4ever.binding.Net

public class Net extends Object
net Contains methods of "net" module. Network access.
  • Constructor Details

    • Net

      public Net()
  • Method Details

    • query

      public static Net.ResultOfQuery query(Context ctx, String query, Map<String,Object> variables) throws EverSdkException
      net.query Performs DAppServer GraphQL query.
      Parameters:
      query - GraphQL query text.
      variables - Variables used in query. Must be a map with named values that can be used in query.
      Returns:
      Net.ResultOfQuery
      Throws:
      EverSdkException
    • batchQuery

      public static Net.ResultOfBatchQuery batchQuery(Context ctx, Net.ParamsOfQueryOperation[] operations) throws EverSdkException
      net.batch_query Performs multiple queries per single fetch.
      Parameters:
      operations - List of query operations that must be performed per single fetch.
      Returns:
      Net.ResultOfBatchQuery
      Throws:
      EverSdkException
    • queryCollection

      public static Net.ResultOfQueryCollection queryCollection(Context ctx, String collection, Map<String,Object> filter, String result, Net.OrderBy[] order, Number limit) throws EverSdkException
      net.query_collection Queries collection data Queries data that satisfies the `filter` conditions,limits the number of returned records and orders them.The projection fields are limited to `result` fields
      Parameters:
      collection - Collection name (accounts, blocks, transactions, messages, block_signatures)
      filter - Collection filter
      result - Projection (result) string
      order - Sorting order
      limit - Number of documents to return
      Returns:
      Net.ResultOfQueryCollection
      Throws:
      EverSdkException
    • aggregateCollection

      public static Net.ResultOfAggregateCollection aggregateCollection(Context ctx, String collection, Map<String,Object> filter, Net.FieldAggregation[] fields) throws EverSdkException
      net.aggregate_collection Aggregates collection data. Aggregates values from the specified `fields` for recordsthat satisfies the `filter` conditions,
      Parameters:
      collection - Collection name (accounts, blocks, transactions, messages, block_signatures)
      filter - Collection filter
      fields - Projection (result) string
      Returns:
      Net.ResultOfAggregateCollection
      Throws:
      EverSdkException
    • waitForCollection

      public static Net.ResultOfWaitForCollection waitForCollection(Context ctx, String collection, Map<String,Object> filter, String result, Number timeout) throws EverSdkException
      net.wait_for_collection Returns an object that fulfills the conditions or waits for its appearance Triggers only once.If object that satisfies the `filter` conditionsalready exists - returns it immediately.If not - waits for insert/update of data within the specified `timeout`,and returns it.The projection fields are limited to `result` fields
      Parameters:
      collection - Collection name (accounts, blocks, transactions, messages, block_signatures)
      filter - Collection filter
      result - Projection (result) string
      timeout - Query timeout
      Returns:
      Net.ResultOfWaitForCollection
      Throws:
      EverSdkException
    • unsubscribe

      public static void unsubscribe(Context ctx, Number handle) throws EverSdkException
      net.unsubscribe Cancels a subscription Cancels a subscription specified by its handle.
      Parameters:
      handle - Subscription handle. Must be closed with `unsubscribe`
      Throws:
      EverSdkException
    • subscribeCollection

      public static Net.ResultOfSubscribeCollection subscribeCollection(Context ctx, String collection, Map<String,Object> filter, String result, Consumer<SubscribeCollectionEvent> consumer) throws EverSdkException
      net.subscribe_collection Creates a collection subscription Triggers for each insert/update of data that satisfiesthe `filter` conditions.The projection fields are limited to `result` fields.

      The subscription is a persistent communication channel betweenclient and Free TON Network.All changes in the blockchain will be reflected in realtime.Changes means inserts and updates of the blockchain entities.

      ### Important Notes on Subscriptions

      Unfortunately sometimes the connection with the network brakes down.In this situation the library attempts to reconnect to the network.This reconnection sequence can take significant time.All of this time the client is disconnected from the network.

      Bad news is that all blockchain changes that happened whilethe client was disconnected are lost.

      Good news is that the client report errors to the callback whenit loses and resumes connection.

      So, if the lost changes are important to the application thenthe application must handle these error reports.

      Library reports errors with `responseType` == 101and the error object passed via `params`.

      When the library has successfully reconnectedthe application receives callback with`responseType` == 101 and `params.code` == 614 (NetworkModuleResumed).

      Application can use several ways to handle this situation:- If application monitors changes for the single blockchainobject (for example specific account): applicationcan perform a query for this object and handle actual data as aregular data from the subscription.- If application monitors sequence of some blockchain objects(for example transactions of the specific account): application mustrefresh all cached (or visible to user) lists where this sequences presents.

      Parameters:
      collection - Collection name (accounts, blocks, transactions, messages, block_signatures)
      filter - Collection filter
      result - Projection (result) string
      Returns:
      Net.ResultOfSubscribeCollection
      Throws:
      EverSdkException
    • subscribe

      public static Net.ResultOfSubscribeCollection subscribe(Context ctx, String subscription, Map<String,Object> variables, Consumer<SubscribeEvent> consumer) throws EverSdkException
      net.subscribe Creates a subscription The subscription is a persistent communication channel betweenclient and Everscale Network.

      ### Important Notes on Subscriptions

      Unfortunately sometimes the connection with the network brakes down.In this situation the library attempts to reconnect to the network.This reconnection sequence can take significant time.All of this time the client is disconnected from the network.

      Bad news is that all changes that happened whilethe client was disconnected are lost.

      Good news is that the client report errors to the callback whenit loses and resumes connection.

      So, if the lost changes are important to the application thenthe application must handle these error reports.

      Library reports errors with `responseType` == 101and the error object passed via `params`.

      When the library has successfully reconnectedthe application receives callback with`responseType` == 101 and `params.code` == 614 (NetworkModuleResumed).

      Application can use several ways to handle this situation:- If application monitors changes for the singleobject (for example specific account): applicationcan perform a query for this object and handle actual data as aregular data from the subscription.- If application monitors sequence of some objects(for example transactions of the specific account): application mustrefresh all cached (or visible to user) lists where this sequences presents.

      Parameters:
      subscription - GraphQL subscription text.
      variables - Variables used in subscription. Must be a map with named values that can be used in query.
      Returns:
      Net.ResultOfSubscribeCollection
      Throws:
      EverSdkException
    • suspend

      public static void suspend(Context ctx) throws EverSdkException
      net.suspend Suspends network module to stop any network activity
      Throws:
      EverSdkException
    • resume

      public static void resume(Context ctx) throws EverSdkException
      net.resume Resumes network module to enable network activity
      Throws:
      EverSdkException
    • findLastShardBlock

      public static Net.ResultOfFindLastShardBlock findLastShardBlock(Context ctx, String address) throws EverSdkException
      net.find_last_shard_block Returns ID of the last block in a specified account shard
      Parameters:
      address - Account address
      Returns:
      Net.ResultOfFindLastShardBlock
      Throws:
      EverSdkException
    • fetchEndpoints

      public static Net.EndpointsSet fetchEndpoints(Context ctx) throws EverSdkException
      net.fetch_endpoints Requests the list of alternative endpoints from server
      Returns:
      Net.EndpointsSet
      Throws:
      EverSdkException
    • setEndpoints

      public static void setEndpoints(Context ctx, String[] endpoints) throws EverSdkException
      net.set_endpoints Sets the list of endpoints to use on reinit
      Parameters:
      endpoints - List of endpoints provided by server
      Throws:
      EverSdkException
    • getEndpoints

      public static Net.ResultOfGetEndpoints getEndpoints(Context ctx) throws EverSdkException
      net.get_endpoints Requests the list of alternative endpoints from server
      Returns:
      Net.ResultOfGetEndpoints
      Throws:
      EverSdkException
    • queryCounterparties

      public static Net.ResultOfQueryCollection queryCounterparties(Context ctx, String account, String result, Number first, String after) throws EverSdkException
      net.query_counterparties Allows to query and paginate through the list of accounts that the specified account has interacted with, sorted by the time of the last internal message between accounts *Attention* this query retrieves data from 'Counterparties' service which is not supported inthe opensource version of DApp Server (and will not be supported) as well as in Evernode SE (will be supported in SE in future),but is always accessible via EVER OS Clouds
      Parameters:
      account - Account address
      result - Projection (result) string
      first - Number of counterparties to return
      after - `cursor` field of the last received result
      Returns:
      Net.ResultOfQueryCollection
      Throws:
      EverSdkException
    • queryTransactionTree

      public static Net.ResultOfQueryTransactionTree queryTransactionTree(Context ctx, String inMsg, Abi.ABI[] abiRegistry, Number timeout) throws EverSdkException
      net.query_transaction_tree Returns a tree of transactions triggered by a specific message. Performs recursive retrieval of a transactions tree produced by a specific message:in_msg -> dst_transaction -> out_messages -> dst_transaction -> ...If the chain of transactions execution is in progress while the function is running,it will wait for the next transactions to appear until the full tree or more than 50 transactionsare received.

      All the retrieved messages and transactions are includedinto `result.messages` and `result.transactions` respectively.

      Function reads transactions layer by layer, by pages of 20 transactions.

      The retrieval prosess goes like this:Let's assume we have an infinite chain of transactions and each transaction generates 5 messages.1. Retrieve 1st message (input parameter) and corresponding transaction - put it into result.It is the first level of the tree of transactions - its root.Retrieve 5 out message ids from the transaction for next steps.2. Retrieve 5 messages and corresponding transactions on the 2nd layer. Put them into result.Retrieve 5*5 out message ids from these transactions for next steps3. Retrieve 20 (size of the page) messages and transactions (3rd layer) and 20*5=100 message ids (4th layer).4. Retrieve the last 5 messages and 5 transactions on the 3rd layer + 15 messages and transactions (of 100) from the 4th layer+ 25 message ids of the 4th layer + 75 message ids of the 5th layer.5. Retrieve 20 more messages and 20 more transactions of the 4th layer + 100 more message ids of the 5th layer.6. Now we have 1+5+20+20+20 = 66 transactions, which is more than 50. Function exits with the tree of1m->1t->5m->5t->25m->25t->35m->35t. If we see any message ids in the last transactions out_msgs, which don't havecorresponding messages in the function result, it means that the full tree was not received and we need to continue iteration.

      To summarize, it is guaranteed that each message in `result.messages` has the corresponding transactionin the `result.transactions`.But there is no guarantee that all messages from transactions `out_msgs` arepresented in `result.messages`.So the application has to continue retrieval for missing messages if it requires.

      Parameters:
      inMsg - Input message id.
      abiRegistry - List of contract ABIs that will be used to decode message bodies. Library will try to decode each returned message body using any ABI from the registry.
      timeout - Timeout used to limit waiting time for the missing messages and transaction. If some of the following messages and transactions are missing yetThe maximum waiting time is regulated by this option.

      Default value is 60000 (1 min).

      Returns:
      Net.ResultOfQueryTransactionTree
      Throws:
      EverSdkException
    • createBlockIterator

      public static Net.RegisteredIterator createBlockIterator(Context ctx, Number startTime, Number endTime, String[] shardFilter, String result) throws EverSdkException
      net.create_block_iterator Creates block iterator. Block iterator uses robust iteration methods that guaranties that everyblock in the specified range isn't missed or iterated twice.

      Iterated range can be reduced with some filters:- `start_time` – the bottom time range. Only blocks with `gen_utime`more or equal to this value is iterated. If this parameter is omitted then there isno bottom time edge, so all blocks since zero state is iterated.- `end_time` – the upper time range. Only blocks with `gen_utime`less then this value is iterated. If this parameter is omitted then there isno upper time edge, so iterator never finishes.- `shard_filter` – workchains and shard prefixes that reduce the set of interestingblocks. Block conforms to the shard filter if it belongs to the filter workchainand the first bits of block's `shard` fields matches to the shard prefix.Only blocks with suitable shard are iterated.

      Items iterated is a JSON objects with block data. The minimal set of returnedfields is:```textidgen_utimeworkchain_idshardafter_splitafter_mergeprev_ref { root_hash}prev_alt_ref { root_hash}```Application can request additional fields in the `result` parameter.

      Application should call the `remove_iterator` when iterator is no longer required.

      Parameters:
      startTime - Starting time to iterate from. If the application specifies this parameter then the iterationincludes blocks with `gen_utime` >= `start_time`.Otherwise the iteration starts from zero state.

      Must be specified in seconds.

      endTime - Optional end time to iterate for. If the application specifies this parameter then the iterationincludes blocks with `gen_utime` < `end_time`.Otherwise the iteration never stops.

      Must be specified in seconds.

      shardFilter - Shard prefix filter. If the application specifies this parameter and it is not the empty arraythen the iteration will include items related to accounts that belongs tothe specified shard prefixes.Shard prefix must be represented as a string "workchain:prefix".Where `workchain` is a signed integer and the `prefix` if a hexadecimalrepresentation if the 64-bit unsigned integer with tagged shard prefix.For example: "0:3800000000000000".
      result - Projection (result) string. List of the fields that must be returned for iterated items.This field is the same as the `result` parameter ofthe `query_collection` function.Note that iterated items can contains additional fields that arenot requested in the `result`.
      Returns:
      Net.RegisteredIterator
      Throws:
      EverSdkException
    • resumeBlockIterator

      public static Net.RegisteredIterator resumeBlockIterator(Context ctx, Map<String,Object> resumeState) throws EverSdkException
      net.resume_block_iterator Resumes block iterator. The iterator stays exactly at the same position where the `resume_state` was catched.

      Application should call the `remove_iterator` when iterator is no longer required.

      Parameters:
      resumeState - Iterator state from which to resume. Same as value returned from `iterator_next`.
      Returns:
      Net.RegisteredIterator
      Throws:
      EverSdkException
    • createTransactionIterator

      public static Net.RegisteredIterator createTransactionIterator(Context ctx, Number startTime, Number endTime, String[] shardFilter, String[] accountsFilter, String result, Boolean includeTransfers) throws EverSdkException
      net.create_transaction_iterator Creates transaction iterator. Transaction iterator uses robust iteration methods that guaranty that everytransaction in the specified range isn't missed or iterated twice.

      Iterated range can be reduced with some filters:- `start_time` – the bottom time range. Only transactions with `now`more or equal to this value are iterated. If this parameter is omitted then there isno bottom time edge, so all the transactions since zero state are iterated.- `end_time` – the upper time range. Only transactions with `now`less then this value are iterated. If this parameter is omitted then there isno upper time edge, so iterator never finishes.- `shard_filter` – workchains and shard prefixes that reduce the set of interestingaccounts. Account address conforms to the shard filter ifit belongs to the filter workchain and the first bits of address match tothe shard prefix. Only transactions with suitable account addresses are iterated.- `accounts_filter` – set of account addresses whose transactions must be iterated.Note that accounts filter can conflict with shard filter so application must combinethese filters carefully.

      Iterated item is a JSON objects with transaction data. The minimal set of returnedfields is:```textidaccount_addrnowbalance_delta(format:DEC)bounce { bounce_type }in_message { id value(format:DEC) msg_type src}out_messages { id value(format:DEC) msg_type dst}```Application can request an additional fields in the `result` parameter.

      Another parameter that affects on the returned fields is the `include_transfers`.When this parameter is `true` the iterator computes and adds `transfer` field containinglist of the useful `TransactionTransfer` objects.Each transfer is calculated from the particular message related to the transactionand has the following structure:- message – source message identifier.- isBounced – indicates that the transaction is bounced, which means the value will be returned back to the sender.- isDeposit – indicates that this transfer is the deposit (true) or withdraw (false).- counterparty – account address of the transfer source or destination depending on `isDeposit`.- value – amount of nano tokens transferred. The value is represented as a decimal stringbecause the actual value can be more precise than the JSON number can represent. Applicationmust use this string carefully – conversion to number can follow to loose of precision.

      Application should call the `remove_iterator` when iterator is no longer required.

      Parameters:
      startTime - Starting time to iterate from. If the application specifies this parameter then the iterationincludes blocks with `gen_utime` >= `start_time`.Otherwise the iteration starts from zero state.

      Must be specified in seconds.

      endTime - Optional end time to iterate for. If the application specifies this parameter then the iterationincludes blocks with `gen_utime` < `end_time`.Otherwise the iteration never stops.

      Must be specified in seconds.

      shardFilter - Shard prefix filters. If the application specifies this parameter and it is not an empty arraythen the iteration will include items related to accounts that belongs tothe specified shard prefixes.Shard prefix must be represented as a string "workchain:prefix".Where `workchain` is a signed integer and the `prefix` if a hexadecimalrepresentation if the 64-bit unsigned integer with tagged shard prefix.For example: "0:3800000000000000".Account address conforms to the shard filter ifit belongs to the filter workchain and the first bits of address match tothe shard prefix. Only transactions with suitable account addresses are iterated.
      accountsFilter - Account address filter. Application can specify the list of accounts for whichit wants to iterate transactions.

      If this parameter is missing or an empty list then the library iteratestransactions for all accounts that pass the shard filter.

      Note that the library doesn't detect conflicts between the account filter and the shard filterif both are specified.So it is an application responsibility to specify the correct filter combination.

      result - Projection (result) string. List of the fields that must be returned for iterated items.This field is the same as the `result` parameter ofthe `query_collection` function.Note that iterated items can contain additional fields that arenot requested in the `result`.
      includeTransfers - Include `transfers` field in iterated transactions. If this parameter is `true` then each transaction contains field`transfers` with list of transfer. See more about this structure in function description.
      Returns:
      Net.RegisteredIterator
      Throws:
      EverSdkException
    • resumeTransactionIterator

      public static Net.RegisteredIterator resumeTransactionIterator(Context ctx, Map<String,Object> resumeState, String[] accountsFilter) throws EverSdkException
      net.resume_transaction_iterator Resumes transaction iterator. The iterator stays exactly at the same position where the `resume_state` was caught.Note that `resume_state` doesn't store the account filter. If the application requiresto use the same account filter as it was when the iterator was created then the applicationmust pass the account filter again in `accounts_filter` parameter.

      Application should call the `remove_iterator` when iterator is no longer required.

      Parameters:
      resumeState - Iterator state from which to resume. Same as value returned from `iterator_next`.
      accountsFilter - Account address filter. Application can specify the list of accounts for whichit wants to iterate transactions.

      If this parameter is missing or an empty list then the library iteratestransactions for all accounts that passes the shard filter.

      Note that the library doesn't detect conflicts between the account filter and the shard filterif both are specified.So it is the application's responsibility to specify the correct filter combination.

      Returns:
      Net.RegisteredIterator
      Throws:
      EverSdkException
    • iteratorNext

      public static Net.ResultOfIteratorNext iteratorNext(Context ctx, Number iterator, Number limit, Boolean returnResumeState) throws EverSdkException
      net.iterator_next Returns next available items. In addition to available items this function returns the `has_more` flagindicating that the iterator isn't reach the end of the iterated range yet.

      This function can return the empty list of available items butindicates that there are more items is available.This situation appears when the iterator doesn't reach iterated rangebut database doesn't contains available items yet.

      If application requests resume state in `return_resume_state` parameterthen this function returns `resume_state` that can be used later toresume the iteration from the position after returned items.

      The structure of the items returned depends on the iterator used.See the description to the appropriated iterator creation function.

      Parameters:
      iterator - Iterator handle
      limit - Maximum count of the returned items. If value is missing or is less than 1 the library uses 1.
      returnResumeState - Indicates that function must return the iterator state that can be used for resuming iteration.
      Returns:
      Net.ResultOfIteratorNext
      Throws:
      EverSdkException
    • removeIterator

      public static void removeIterator(Context ctx, Number handle) throws EverSdkException
      net.remove_iterator Removes an iterator Frees all resources allocated in library to serve iterator.

      Application always should call the `remove_iterator` when iteratoris no longer required.

      Parameters:
      handle - Iterator handle. Must be removed using `remove_iterator`when it is no more needed for the application.
      Throws:
      EverSdkException