Commit d0b551f1 authored by Jason Salyers's avatar Jason Salyers
Browse files

Merge branch 'jsalyers-upgrade-hive-js-and-get-account-history' into 'develop'

[JES] remove test library

See merge request !66
parents 711acfa3 f8b3a953
MIT License
Copyright (c) 2017 Hive.js
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitlab.syncad.com/hive/hive-js/blob/master/LICENSE)
# Hive.js
Hive.js the Official JavaScript API for Hive blockchain
# Documentation
- [Install](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#install)
- [Browser](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#browser)
- [Config](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#config)
- [Database API](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#api)
- [Subscriptions](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#subscriptions)
- [Tags](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#tags)
- [Blocks and transactions](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#blocks-and-transactions)
- [Globals](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#globals)
- [Keys](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#keys)
- [Accounts](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#accounts)
- [Market](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#market)
- [Authority / validation](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#authority--validation)
- [Votes](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#votes)
- [Content](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#content)
- [Witnesses](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#witnesses)
- [Login API](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#login)
- [Follow API](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#follow-api)
- [Broadcast API](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#broadcast-api)
- [Broadcast](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#broadcast)
- [Auth](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#auth)
- [Formatter](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#formatter)
- [Utils](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#utils)
- [Tutorials](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#tutorials)
Here is full documentation:
https://gitlab.syncad.com/hive/hive-js/tree/master/doc
## Browser
```html
<script src="./hive.min.js"></script>
<script>
hive.api.getAccounts(['mahdiyari', 'hiveio'], function(err, response){
console.log(err, response);
});
</script>
```
## CDN
https://cdn.jsdelivr.net/npm/@hiveio/hive-js/dist/hive.min.js<br/>
```html
<script src="https://cdn.jsdelivr.net/npm/@hiveio/hive-js/dist/hive.min.js"></script>
```
## Webpack
[Please have a look at the webpack usage example.](https://gitlab.syncad.com/hive/hive-js/blob/master/examples/webpack-example)
## Server
## Install
```
$ npm install @hiveio/hive-js --save
```
## RPC Servers
https://api.hive.blog By Default<br/>
https://anyx.io<br/>
https://api.openhive.network<br/>
https://api.hivekings.com<br/>
https://api.pharesim.me<br/>
https://hived.privex.io<br/>
https://rpc.ausbit.dev<br/>
https://rpc.esteem.app<br/>
<sub>[List of Hive nodes](https://hivekings.com/nodes)</sub><br/>
## Examples
### Broadcast Vote
```js
var hive = require('@hiveio/hive-js');
var wif = hive.auth.toWif(username, password, 'posting');
hive.broadcast.vote(wif, voter, author, permlink, weight, function(err, result) {
console.log(err, result);
});
```
### Get Accounts
```js
hive.api.getAccounts(['mahdiyari', 'hiveio'], function(err, result) {
console.log(err, result);
});
```
### Get State
```js
hive.api.getState('/trends/funny', function(err, result) {
console.log(err, result);
});
```
### Reputation Formatter
```js
var reputation = hive.formatter.reputation(user.reputation);
console.log(reputation);
```
### Hive Testnet
Hive-js requires some configuration to work on the public Hive testnet.
You need to set two Hive API options, `address_prefix` and `chain_id`.
```js
hive.api.setOptions({
address_prefix: 'TST',
chain_id: '46d82ab7d8db682eb1959aed0ada039a6d49afa1602491f93dde9cac3e8e6c32',
useTestNet: true,
});
```
The Chain ID could change. If it does, it may not be reflected here, but will be documented on any testnet launch announcements.
## Contributions
Patches are welcome! Contributors are listed in the package.json file. Please run the tests before opening a pull request and make sure that you are passing all of them.
## Issues
When you find issues, please report them!
## License
MIT
{
"transport": "http",
"websocket": "wss://api.hive.blog:8090",
"uri": "https://api.hive.blog",
"url": "https://api.hive.blog",
"dev_uri": "",
"stage_uri": "",
"address_prefix": "STM",
"chain_id": "beeab0de00000000000000000000000000000000000000000000000000000000",
"alternative_api_endpoints": ["https://api.hive.blog", "https://anyx.io"],
"failover_threshold": 3,
"rebranded_api": true
}
This diff is collapsed.
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true,
});
exports.default = [
{
api: 'database_api',
method: 'set_subscribe_callback',
params: ['callback', 'clearFilter'],
},
{
api: 'database_api',
method: 'set_pending_transaction_callback',
params: ['cb'],
},
{
api: 'database_api',
method: 'set_block_applied_callback',
params: ['cb'],
},
{
api: 'database_api',
method: 'cancel_all_subscriptions',
},
{
api: 'database_api',
method: 'get_trending_tags',
params: ['afterTag', 'limit'],
},
{
api: 'database_api',
method: 'get_tags_used_by_author',
params: ['author'],
},
{
api: 'database_api',
method: 'get_post_discussions_by_payout',
params: ['query'],
},
{
api: 'database_api',
method: 'get_comment_discussions_by_payout',
params: ['query'],
},
{
api: 'database_api',
method: 'get_discussions_by_trending',
params: ['query'],
},
{
api: 'database_api',
method: 'get_discussions_by_trending30',
params: ['query'],
},
{
api: 'database_api',
method: 'get_discussions_by_created',
params: ['query'],
},
{
api: 'database_api',
method: 'get_discussions_by_active',
params: ['query'],
},
{
api: 'database_api',
method: 'get_discussions_by_cashout',
params: ['query'],
},
{
api: 'database_api',
method: 'get_discussions_by_payout',
params: ['query'],
},
{
api: 'database_api',
method: 'get_discussions_by_votes',
params: ['query'],
},
{
api: 'database_api',
method: 'get_discussions_by_children',
params: ['query'],
},
{
api: 'database_api',
method: 'get_discussions_by_hot',
params: ['query'],
},
{
api: 'database_api',
method: 'get_discussions_by_feed',
params: ['query'],
},
{
api: 'database_api',
method: 'get_discussions_by_blog',
params: ['query'],
},
{
api: 'database_api',
method: 'get_discussions_by_comments',
params: ['query'],
},
{
api: 'database_api',
method: 'get_discussions_by_promoted',
params: ['query'],
},
{
api: 'database_api',
method: 'get_block_header',
params: ['blockNum'],
},
{
api: 'database_api',
method: 'get_block',
params: ['blockNum'],
},
{
api: 'database_api',
method: 'get_ops_in_block',
params: ['blockNum', 'onlyVirtual'],
},
{
api: 'database_api',
method: 'get_state',
params: ['path'],
},
{
api: 'database_api',
method: 'get_trending_categories',
params: ['after', 'limit'],
},
{
api: 'database_api',
method: 'get_best_categories',
params: ['after', 'limit'],
},
{
api: 'database_api',
method: 'get_active_categories',
params: ['after', 'limit'],
},
{
api: 'database_api',
method: 'get_recent_categories',
params: ['after', 'limit'],
},
{
api: 'database_api',
method: 'get_config',
},
{
api: 'database_api',
method: 'get_dynamic_global_properties',
},
{
api: 'database_api',
method: 'get_chain_properties',
},
{
api: 'database_api',
method: 'get_feed_history',
},
{
api: 'database_api',
method: 'get_current_median_history_price',
},
{
api: 'database_api',
method: 'get_witness_schedule',
},
{
api: 'database_api',
method: 'get_hardfork_version',
},
{
api: 'database_api',
method: 'get_next_scheduled_hardfork',
},
{
api: 'account_by_key_api',
method: 'get_key_references',
params: ['key'],
},
{
api: 'database_api',
method: 'get_accounts',
params: ['names'],
},
{
api: 'database_api',
method: 'get_account_references',
params: ['accountId'],
},
{
api: 'database_api',
method: 'lookup_account_names',
params: ['accountNames'],
},
{
api: 'database_api',
method: 'lookup_accounts',
params: ['lowerBoundName', 'limit'],
},
{
api: 'database_api',
method: 'get_account_count',
},
{
api: 'database_api',
method: 'get_conversion_requests',
params: ['accountName'],
},
{
api: 'database_api',
method: 'get_account_history',
params: ['account', 'from', 'limit'],
},
{
api: 'database_api',
method: 'get_account_history',
params: ['account', 'from', 'limit', 'operation_filter'],
},
{
api: 'database_api',
method: 'get_owner_history',
params: ['account'],
},
{
api: 'database_api',
method: 'get_recovery_request',
params: ['account'],
},
{
api: 'database_api',
method: 'get_escrow',
params: ['from', 'escrowId'],
},
{
api: 'database_api',
method: 'get_withdraw_routes',
params: ['account', 'withdrawRouteType'],
},
{
api: 'database_api',
method: 'get_account_bandwidth',
params: ['account', 'bandwidthType'],
},
{
api: 'database_api',
method: 'get_savings_withdraw_from',
params: ['account'],
},
{
api: 'database_api',
method: 'get_savings_withdraw_to',
params: ['account'],
},
{
api: 'database_api',
method: 'get_order_book',
params: ['limit'],
},
{
api: 'database_api',
method: 'get_open_orders',
params: ['owner'],
},
{
api: 'database_api',
method: 'get_liquidity_queue',
params: ['startAccount', 'limit'],
},
{
api: 'database_api',
method: 'get_transaction_hex',
params: ['trx'],
},
{
api: 'database_api',
method: 'get_transaction',
params: ['trxId'],
},
{
api: 'database_api',
method: 'get_required_signatures',
params: ['trx', 'availableKeys'],
},
{
api: 'database_api',
method: 'get_potential_signatures',
params: ['trx'],
},
{
api: 'database_api',
method: 'verify_authority',
params: ['trx'],
},
{
api: 'database_api',
method: 'verify_account_authority',
params: ['nameOrId', 'signers'],
},
{
api: 'database_api',
method: 'get_active_votes',
params: ['author', 'permlink'],
},
{
api: 'database_api',
method: 'get_account_votes',
params: ['voter'],
},
{
api: 'database_api',
method: 'get_content',
params: ['author', 'permlink'],
},
{
api: 'database_api',
method: 'get_content_replies',
params: ['author', 'permlink'],
},
{
api: 'database_api',
method: 'get_discussions_by_author_before_date',
params: ['author', 'startPermlink', 'beforeDate', 'limit'],
},
{
api: 'database_api',
method: 'get_replies_by_last_update',
params: ['startAuthor', 'startPermlink', 'limit'],
},
{
api: 'database_api',
method: 'get_witnesses',
params: ['witnessIds'],
},
{
api: 'database_api',
method: 'get_witness_by_account',
params: ['accountName'],
},
{
api: 'database_api',
method: 'get_witnesses_by_vote',
params: ['from', 'limit'],
},
{
api: 'database_api',
method: 'lookup_witness_accounts',
params: ['lowerBoundName', 'limit'],
},
{
api: 'database_api',
method: 'get_witness_count',
},
{
api: 'database_api',
method: 'get_active_witnesses',
},
{
api: 'database_api',
method: 'get_miner_queue',
},
{
api: 'database_api',
method: 'get_reward_fund',
params: ['name'],
},
{
api: 'database_api',
method: 'get_vesting_delegations',
params: ['account', 'from', 'limit'],
},
{
api: 'login_api',
method: 'login',
params: ['username', 'password'],
},
{
api: 'login_api',
method: 'get_api_by_name',
params: ['database_api'],
},
{
api: 'login_api',
method: 'get_version',
},
{
api: 'follow_api',
method: 'get_followers',
params: ['following', 'startFollower', 'followType', 'limit'],
},
{
api: 'follow_api',
method: 'get_following',
params: ['follower', 'startFollowing', 'followType', 'limit'],
},
{
api: 'follow_api',
method: 'get_follow_count',
params: ['account'],
},
{
api: 'follow_api',
method: 'get_feed_entries',
params: ['account', 'entryId', 'limit'],
},
{
api: 'follow_api',
method: 'get_feed',
params: ['account', 'entryId', 'limit'],
},
{
api: 'follow_api',
method: 'get_blog_entries',
params: ['account', 'entryId', 'limit'],
},
{
api: 'follow_api',
method: 'get_blog',
params: ['account', 'entryId', 'limit'],
},
{