api library

Properties

baseApiUrl String
getter/setter pair

Functions

filterResponses(Set<Response?> responsesArray) → Response?
Checks a list of responses from one same POST request to different coordinators If all responses are errors, throw the error If at least 1 was successful, return it @param {Array} responsesArray - An array of responses, including errors @returns response @throws Axios Error
getAccount(String accountIndex) Future<Account>
GET request to the /accounts/:accountIndex endpoint. Returns a specific token account for an accountIndex @param {string} accountIndex - Account index in the format hez:DAI:4444 @returns {object} Response data with the token account
getAccounts(String? address, List<int?> tokenIds, {int fromItem = 0, PaginationOrder order = PaginationOrder.ASC, int limit = DEFAULT_PAGE_SIZE}) Future<AccountsResponse>
GET request to the /accounts endpoint. Returns a list of token accounts associated to a Hermez address @param {string} address - The account's address. It can be a Hermez Ethereum address or a Hermez BabyJubJub address @param {int[]} tokenIds - Array of token IDs as registered in the network @param {int} fromItem - Item from where to start the request @returns {object} Response data with filtered token accounts and pagination data
getBaseApiUrl() String
Returns current coordinator API URL @returns {String} The currently set Coordinator
getBatch(int batchNum) Future<String>
GET request to the /batches/:batchNum endpoint. Returns a specific batch @param {int} batchNum - Number of a specific batch @returns {Object} Response data with a specific batch
getBatches(String forgerAddr, int slotNum, int fromItem) Future<String>
GET request to the /batches endpoint. Returns a filtered list of batches @param {String} forgerAddr - Filter by forger address @param {int} slotNum - A specific slot number @param {int} fromItem - Item from where to start the request @returns {Object} Response data with a paginated list of batches
getBids(int slotNum, String bidderAddr, int fromItem) Future<String>
GET request to the /bids endpoint. Returns a list of bids @param {int} slotNum - Filter by slot @param {String} bidderAddr - Filter by coordinator @param {int} fromItem - Item from where to start the request @returns {Object} Response data with the list of slots
getCoordinators(String forgerAddr, String bidderAddr, {int fromItem = 0, PaginationOrder order = PaginationOrder.ASC, int limit = DEFAULT_PAGE_SIZE}) Future<List<Coordinator>?>
GET request to the /coordinators/:bidderAddr endpoint. Returns a specific coordinator information @param {String} forgerAddr - A coordinator forger address @param {String} bidderAddr - A coordinator bidder address @returns {Object} Response data with a specific coordinator
getCreateAccountAuthorization(String hezEthereumAddress) Future<CreateAccountAuthorization?>
getExit(int batchNum, String accountIndex) Future<Exit>
GET request to the /exits/:batchNum/:accountIndex endpoint. Returns a specific exit @param {int} batchNum - Filter by an exit in a specific batch number @param {string} accountIndex - Filter by an exit associated to an account index @returns {object} Response data with the specific exit
getExits(String? address, bool onlyPendingWithdraws, int tokenId) Future<ExitsResponse>
GET request to the /exits endpoint. Returns a list of exits based on certain filters @param {string} address - Filter by the address associated to the exits. It can be a Hermez Ethereum address or a Hermez BabyJubJub address @param {boolean} onlyPendingWithdraws - Filter by exits that still haven't been withdrawn @returns {object} Response data with the list of exits
getForgerUrls(Set<String> nextForgerUrls) Set<String>
Makes sure a list of next forgers includes the base API URL @param {Array} nextForgerUrls - Array of forger URLs that may or may not include the base API URL @returns nextForgerUrls - Array of next forgers that definitely includes the base API URL
getHistoryTransaction(String transactionId) Future<ForgedTransaction?>
GET request to the /transactions-history/:transactionId endpoint. Returns a specific forged transaction @param {string} transactionId - The ID for the specific transaction @returns {object} Response data with the transaction
getNextForgerUrls() Future<Set<String>>
Fetches the URLs of the next forgers from the /state API @returns {Array} An array of URLs of the next forgers
getPageData(int fromItem, PaginationOrder order, int limit) Map<String, String>
Sets the query parameters related to pagination @param {int} fromItem - Item from where to start the request @returns {object} Includes the values fromItem and limit @private
getPoolTransaction(String transactionId) Future<PoolTransaction>
GET request to the /transactions-pool/:transactionId endpoint. Returns a specific unforged transaction @param {string} transactionId - The ID for the specific transaction @returns {object} Response data with the transaction
getSlot(int slotNum) Future<String>
GET request to the /slots/:slotNum endpoint. Returns the information for a specific slot @param {int} slotNum - The nunmber of a slot @returns {Object} Response data with a specific slot
getState() Future<StateResponse>
GET request to the /state endpoint. @returns {object} Response data with the current state of the coordinator
getToken(int tokenId) Future<Token>
GET request to the /tokens/:tokenId endpoint. Returns a specific token @param {int} tokenId - A token ID @returns {object} Response data with a specific token
getTokens({List<int>? tokenIds, int fromItem = 0, dynamic order = PaginationOrder.ASC, dynamic limit = DEFAULT_PAGE_SIZE}) Future<TokensResponse>
GET request to the /tokens endpoint. Returns a list of token data @param {int[]} tokenIds - An array of token IDs @returns {object} Response data with the list of tokens
getTransactions({String? address, List<int>? tokenIds, int? batchNum, String? accountIndex, int fromItem = 0, PaginationOrder order = PaginationOrder.ASC, int limit = DEFAULT_PAGE_SIZE}) Future<ForgedTransactionsResponse>
GET request to the /transactions-histroy endpoint. Returns a list of forged transaction based on certain filters @param {string} address - Filter by the address that sent or received the transactions. It can be a Hermez Ethereum address or a Hermez BabyJubJub address @param {int[]} tokenIds - Array of token IDs as registered in the network @param {int} batchNum - Filter by batch number @param {String} accountIndex - Filter by an account index that sent or received the transactions @param {int} fromItem - Item from where to start the request @returns {object} Response data with filtered transactions and pagination data
postCreateAccountAuthorization(String? hezEthereumAddress, String? bjj, String signature) Future<Response?>
POST request to the /account-creation-authorization endpoint. Sends an authorization to the coordinator to register token accounts on their behalf @param {String} hezEthereumAddress - The Hermez Ethereum address of the account that makes the authorization @param {String} bjj - BabyJubJub address of the account that makes the authorization @param {String} signature - The signature of the request @returns {Object} Response data
postPoolTransaction(Map<String, dynamic> transaction) Future<Response?>
POST request to the /transaction-pool endpoint. Sends an L2 transaction to the network @param {object} transaction - Transaction data returned by TxUtils.generateL2Transaction @returns {string} Transaction id
setBaseApiUrl(String url) → void
Sets the current coordinator API URL @param {String} url - The currently forging Coordinator