Commit 94a4e2f8 authored by Mahdi Yari's avatar Mahdi Yari

Merge branch 'fix-browserbuild-readme-1' into 'master'

Fix browserbuild and readme

See merge request !4
parents 3ebac6da c21cbf88
...@@ -11,7 +11,7 @@ build/Release ...@@ -11,7 +11,7 @@ build/Release
node_modules node_modules
.tern-port .tern-port
dist/steem-tests.min.js* dist/hive-tests.min.js*
# node-dist # node-dist
.tern-port .tern-port
.envrc .envrc
......
MIT License MIT License
Copyright (c) 2017 Steem.js Copyright (c) 2017 Hive.js
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
......
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/steemit/steem-js/blob/master/LICENSE) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitlab.syncad.com/hive/hive-js/blob/master/LICENSE)
[![Steem.js channel on steemit.chat](https://img.shields.io/badge/chat-steemit.chat-1c56a4.svg)](https://steemit.chat/channel/steemjs)
# Steem.js # Hive.js
Steem.js the JavaScript API for Steem blockchain Hive.js the Official JavaScript API for Hive blockchain
# Documentation # Documentation
- [Install](https://github.com/steemit/steem-js/tree/master/doc#install) - [Install](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#install)
- [Browser](https://github.com/steemit/steem-js/tree/master/doc#browser) - [Browser](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#browser)
- [Config](https://github.com/steemit/steem-js/tree/master/doc#config) - [Config](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#config)
- [Database API](https://github.com/steemit/steem-js/tree/master/doc#api) - [Database API](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#api)
- [Subscriptions](https://github.com/steemit/steem-js/tree/master/doc#subscriptions) - [Subscriptions](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#subscriptions)
- [Tags](https://github.com/steemit/steem-js/tree/master/doc#tags) - [Tags](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#tags)
- [Blocks and transactions](https://github.com/steemit/steem-js/tree/master/doc#blocks-and-transactions) - [Blocks and transactions](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#blocks-and-transactions)
- [Globals](https://github.com/steemit/steem-js/tree/master/doc#globals) - [Globals](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#globals)
- [Keys](https://github.com/steemit/steem-js/tree/master/doc#keys) - [Keys](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#keys)
- [Accounts](https://github.com/steemit/steem-js/tree/master/doc#accounts) - [Accounts](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#accounts)
- [Market](https://github.com/steemit/steem-js/tree/master/doc#market) - [Market](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#market)
- [Authority / validation](https://github.com/steemit/steem-js/tree/master/doc#authority--validation) - [Authority / validation](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#authority--validation)
- [Votes](https://github.com/steemit/steem-js/tree/master/doc#votes) - [Votes](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#votes)
- [Content](https://github.com/steemit/steem-js/tree/master/doc#content) - [Content](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#content)
- [Witnesses](https://github.com/steemit/steem-js/tree/master/doc#witnesses) - [Witnesses](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#witnesses)
- [Login API](https://github.com/steemit/steem-js/tree/master/doc#login) - [Login API](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#login)
- [Follow API](https://github.com/steemit/steem-js/tree/master/doc#follow-api) - [Follow API](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#follow-api)
- [Broadcast API](https://github.com/steemit/steem-js/tree/master/doc#broadcast-api) - [Broadcast API](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#broadcast-api)
- [Broadcast](https://github.com/steemit/steem-js/tree/master/doc#broadcast) - [Broadcast](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#broadcast)
- [Auth](https://github.com/steemit/steem-js/tree/master/doc#auth) - [Auth](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#auth)
Here is full documentation: Here is full documentation:
https://github.com/steemit/steem-js/tree/master/doc https://gitlab.syncad.com/hive/hive-js/tree/master/doc
## Browser ## Browser
```html ```html
<script src="./steem.min.js"></script> <script src="./hive.min.js"></script>
<script> <script>
steem.api.getAccounts(['ned', 'dan'], function(err, response){ hive.api.getAccounts(['mahdiyari', 'hiveio'], function(err, response){
console.log(err, response); console.log(err, response);
}); });
</script> </script>
``` ```
## CDN ## CDN
https://cdn.jsdelivr.net/npm/steem/dist/steem.min.js<br/> https://cdn.jsdelivr.net/npm/@hiveio/hive-js/dist/hive.min.js<br/>
```html ```html
<script src="https://cdn.jsdelivr.net/npm/steem/dist/steem.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/@hiveio/hive-js/dist/hive.min.js"></script>
``` ```
## Webpack ## Webpack
[Please have a look at the webpack usage example.](https://github.com/steemit/steem-js/blob/master/examples/webpack-example) [Please have a look at the webpack usage example.](https://gitlab.syncad.com/hive/hive-js/blob/master/examples/webpack-example)
## Server ## Server
## Install ## Install
``` ```
$ npm install steem --save $ npm install @hiveio/hive-js --save
``` ```
## RPC Servers ## RPC Servers
https://api.steemit.com By Default<br/> https://api.hive.blog By Default<br/>
https://node.steem.ws<br/> https://anyx.io<br/>
https://this.piston.rocks<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 ## Examples
### Broadcast Vote ### Broadcast Vote
```js ```js
var steem = require('steem'); var hive = require('@hiveio/hive-js');
var wif = steem.auth.toWif(username, password, 'posting'); var wif = hive.auth.toWif(username, password, 'posting');
steem.broadcast.vote(wif, voter, author, permlink, weight, function(err, result) { hive.broadcast.vote(wif, voter, author, permlink, weight, function(err, result) {
console.log(err, result); console.log(err, result);
}); });
``` ```
### Get Accounts ### Get Accounts
```js ```js
steem.api.getAccounts(['ned', 'dan'], function(err, result) { hive.api.getAccounts(['mahdiyari', 'hiveio'], function(err, result) {
console.log(err, result); console.log(err, result);
}); });
``` ```
### Get State ### Get State
```js ```js
steem.api.getState('/trends/funny', function(err, result) { hive.api.getState('/trends/funny', function(err, result) {
console.log(err, result); console.log(err, result);
}); });
``` ```
### Reputation Formatter ### Reputation Formatter
```js ```js
var reputation = steem.formatter.reputation(user.reputation); var reputation = hive.formatter.reputation(user.reputation);
console.log(reputation); console.log(reputation);
``` ```
### Steem Testnet ### Hive Testnet
Steem-js requires some configuration to work on the public Steem testnet. Hive-js requires some configuration to work on the public Hive testnet.
You need to set two Steem API options, `address_prefix` and `chain_id`. You need to set two Hive API options, `address_prefix` and `chain_id`.
```js ```js
steem.api.setOptions({ hive.api.setOptions({
address_prefix: 'TST', address_prefix: 'TST',
chain_id: '46d82ab7d8db682eb1959aed0ada039a6d49afa1602491f93dde9cac3e8e6c32', chain_id: '46d82ab7d8db682eb1959aed0ada039a6d49afa1602491f93dde9cac3e8e6c32',
useTestNet: true, useTestNet: true,
...@@ -107,7 +112,7 @@ steem.api.setOptions({ ...@@ -107,7 +112,7 @@ steem.api.setOptions({
The Chain ID could change. If it does, it may not be reflected here, but will be documented on any testnet launch announcements. The Chain ID could change. If it does, it may not be reflected here, but will be documented on any testnet launch announcements.
## Contributions ## 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. If you would like to contribute, but don't know what to work on, check the issues list or on Steemit Chat channel #steemjs https://steemit.chat/channel/steemjs. 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 ## Issues
When you find issues, please report them! When you find issues, please report them!
......
This diff is collapsed.
const steem = require('../lib'); const hive = require('../lib');
/* Generate private active WIF */ /* Generate private active WIF */
const username = process.env.STEEM_USERNAME; const username = process.env.HIVE_USERNAME;
const password = process.env.STEEM_PASSWORD; const password = process.env.HIVE_PASSWORD;
const privActiveWif = steem.auth.toWif(username, password, 'active'); const privActiveWif = hive.auth.toWif(username, password, 'active');
/** Add posting key auth */ /** Add posting key auth */
steem.broadcast.addKeyAuth({ hive.broadcast.addKeyAuth({
signingKey: privActiveWif, signingKey: privActiveWif,
username, username,
authorizedKey: 'STM88CPfhCmeEzCnvC1Cjc3DNd1DTjkMcmihih8SSxmm4LBqRq5Y9', authorizedKey: 'STM88CPfhCmeEzCnvC1Cjc3DNd1DTjkMcmihih8SSxmm4LBqRq5Y9',
......
...@@ -2,22 +2,22 @@ ...@@ -2,22 +2,22 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Steem.js Broadcast</title> <title>Hive.js Broadcast</title>
</head> </head>
<body> <body>
<script src="../dist/steem.min.js"></script> <script src="../dist/hive.min.js"></script>
<script> <script>
/** Configure your account */ /** Configure your account */
var username = 'guest123'; var username = 'guest123';
var postingWif = '5JRaypasxMx1L97ZUX7YuC5Psb5EAbF821kkAGtBj7xCJFQcbLg'; var postingWif = '5JRaypasxMx1L97ZUX7YuC5Psb5EAbF821kkAGtBj7xCJFQcbLg';
/** Broadcast a vote */ /** Broadcast a vote */
steem.broadcast.vote( hive.broadcast.vote(
postingWif, postingWif,
username, // Voter username, // Voter
'firepower', // Author 'hiveio', // Author
'steemit-veni-vidi-vici-steemfest-2016-together-we-made-it-happen-thank-you-steemians', // Permlink 'announcing-the-launch-of-hive-blockchain', // Permlink
10000, // Weight (10000 = 100%) 10000, // Weight (10000 = 100%)
function(err, result) { function(err, result) {
console.log(err, result); console.log(err, result);
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
/** Broadcast a comment */ /** Broadcast a comment */
var permlink = new Date().toISOString().replace(/[^a-zA-Z0-9]+/g, '').toLowerCase(); var permlink = new Date().toISOString().replace(/[^a-zA-Z0-9]+/g, '').toLowerCase();
steem.broadcast.comment( hive.broadcast.comment(
postingWif, postingWif,
'siol', // Parent Author 'siol', // Parent Author
'test', // Parent Permlink 'test', // Parent Permlink
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
permlink, // Permlink permlink, // Permlink
'', // Title '', // Title
'This is a test!', // Body 'This is a test!', // Body
{ tags: ['test'], app: 'steemjs/examples' }, // Json Metadata { tags: ['test'], app: 'hivejs/examples' }, // Json Metadata
function(err, result) { function(err, result) {
console.log(err, result); console.log(err, result);
} }
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
/** Broadcast a post */ /** Broadcast a post */
var permlink = new Date().toISOString().replace(/[^a-zA-Z0-9]+/g, '').toLowerCase(); var permlink = new Date().toISOString().replace(/[^a-zA-Z0-9]+/g, '').toLowerCase();
steem.broadcast.comment( hive.broadcast.comment(
postingWif, postingWif,
'', // Leave parent author empty '', // Leave parent author empty
'photography', // Main tag 'photography', // Main tag
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
permlink + '-post', // Permlink permlink + '-post', // Permlink
'This is just a test!', // Title 'This is just a test!', // Title
'Nothing to see here', // Body 'Nothing to see here', // Body
{ tags: ['test'], app: 'steemjs/examples' }, // Json Metadata { tags: ['test'], app: 'hivejs/examples' }, // Json Metadata
function(err, result) { function(err, result) {
console.log(err, result); console.log(err, result);
} }
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
/** Follow an user */ /** Follow an user */
var follower = username; // Your username var follower = username; // Your username
var following = 'steemjs'; // User to follow var following = 'hiveio'; // User to follow
var json = JSON.stringify( var json = JSON.stringify(
['follow', { ['follow', {
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
}] }]
); );
steem.broadcast.customJson( hive.broadcast.customJson(
postingWif, postingWif,
[], // Required_auths [], // Required_auths
[follower], // Required Posting Auths [follower], // Required Posting Auths
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
}] }]
); );
steem.broadcast.customJson( hive.broadcast.customJson(
postingWif, postingWif,
[], // Required_auths [], // Required_auths
[follower], // Required Posting Auths [follower], // Required Posting Auths
...@@ -103,4 +103,4 @@ ...@@ -103,4 +103,4 @@
</script> </script>
</body> </body>
</html> </html>
\ No newline at end of file
const steem = require('../lib'); const hive = require('../lib');
const resultP = steem.api.getContentAsync('yamadapc', 'test-1-2-3-4-5-6-7-9'); const resultP = hive.api.getContentAsync('hiveio', 'announcing-the-launch-of-hive-blockchain');
resultP.then(result => console.log(result)); resultP.then(result => console.log(result));
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Steem.js</title> <title>Hive.js</title>
</head> </head>
<body> <body>
<script src="../dist/steem.min.js"></script> <script src="../dist/hive.min.js"></script>
<script> <script>
steem.api.getConfig(function(err, response){ hive.api.getConfig(function(err, response){
console.log(err, response); console.log(err, response);
}); });
steem.api.getAccounts(['ned', 'dan'], function(err, response){ hive.api.getAccounts(['hiveio', 'mahdiyari'], function(err, response){
console.log(err, response); console.log(err, response);
}); });
steem.api.getAccountCount(function(err, response){ hive.api.getAccountCount(function(err, response){
console.log(err, response); console.log(err, response);
}); });
</script> </script>
......
const steem = require('../lib'); const hive = require('../lib');
const privWif1 = '5K2LA2ucS8b1GuFvVgZK6itKNE6fFMbDMX4GDtNHiczJESLGRd8'; const privWif1 = '5K2LA2ucS8b1GuFvVgZK6itKNE6fFMbDMX4GDtNHiczJESLGRd8';
const privWif2 = '5JRaypasxMx1L97ZUX7YuC5Psb5EAbF821kkAGtBj7xCJFQcbLg'; const privWif2 = '5JRaypasxMx1L97ZUX7YuC5Psb5EAbF821kkAGtBj7xCJFQcbLg';
steem.broadcast.send({ hive.broadcast.send({
extensions: [], extensions: [],
operations: [ operations: [
['vote', { ['vote', {
......
var steem = require('../lib'); var hive = require('../lib');
steem.api.getAccountCount(function(err, result) { hive.api.getAccountCount(function(err, result) {
console.log(err, result); console.log(err, result);
}); });
steem.api.getAccounts(['dan'], function(err, result) { hive.api.getAccounts(['hiveio'], function(err, result) {
console.log(err, result); console.log(err, result);
var reputation = steem.formatter.reputation(result[0].reputation); var reputation = hive.formatter.reputation(result[0].reputation);
console.log(reputation); console.log(reputation);
}); });
steem.api.getState('trending/steemit', function(err, result) { hive.api.getState('trending/hive', function(err, result) {
console.log(err, result); console.log(err, result);
}); });
steem.api.getFollowing('ned', 0, 'blog', 10, function(err, result) { hive.api.getFollowing('hiveio', 0, 'blog', 10, function(err, result) {
console.log(err, result); console.log(err, result);
}); });
steem.api.getFollowers('dan', 0, 'blog', 10, function(err, result) { hive.api.getFollowers('hiveio', 0, 'blog', 10, function(err, result) {
console.log(err, result); console.log(err, result);
}); });
steem.api.streamOperations(function(err, result) { hive.api.streamOperations(function(err, result) {
console.log(err, result); console.log(err, result);
}); });
steem.api.getDiscussionsByActive({ hive.api.getDiscussionsByActive({
limit: 10, limit: 10,
start_author: 'thecastle', start_author: 'thecastle',
start_permlink: 'this-week-in-level-design-1-22-2017' start_permlink: 'this-week-in-level-design-1-22-2017'
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Steem.js Stream</title> <title>Hive.js Stream</title>
</head> </head>
<body> <body>
<script src="../dist/steem.min.js"></script> <script src="../dist/hive.min.js"></script>
<script> <script>
steem.api.streamOperations(function (err, operations) { hive.api.streamOperations(function (err, operations) {
operations.forEach(function (operation) { operations.forEach(function (operation) {
console.log(operation); console.log(operation);
}); });
......
const steem = require('../lib'); const hive = require('../lib');
const username = 'guest123'; const username = 'guest123';
const wif = '5JRaypasxMx1L97ZUX7YuC5Psb5EAbF821kkAGtBj7xCJFQcbLg'; const wif = '5JRaypasxMx1L97ZUX7YuC5Psb5EAbF821kkAGtBj7xCJFQcbLg';
steem hive
.broadcast .broadcast
.vote( .vote(
wif, wif,
......
# `steem-js` webpack configuration example # `hive-js` webpack configuration example
This is a demo of `steem-js` and webpack usage targetting both the Web and This is a demo of `hive-js` and webpack usage targetting both the Web and
Node.js platforms. Node.js platforms.
## Compiling the example ## Compiling the example
......
{ {
"name": "steem-js-webpack-example", "name": "hive-js-webpack-example",
"scripts": { "scripts": {
"build": "npm run build-web && npm run build-node", "build": "npm run build-web && npm run build-node",
"build-web": "webpack", "build-web": "webpack",
...@@ -10,6 +10,6 @@ ...@@ -10,6 +10,6 @@
"webpack": "^3.0.0" "webpack": "^3.0.0"
}, },
"dependencies": { "dependencies": {
"steem": "^0.5.20" "hive": "^0.0.5"
} }
} }
const steem = require('steem/lib/browser'); const hive = require('hive/lib/browser');
console.log('Getting post content...'); console.log('Getting post content...');
const resultP = steem.api.getContentAsync('yamadapc', 'test-1-2-3-4-5-6-7-9'); const resultP = hive.api.getContentAsync('yamadapc', 'test-1-2-3-4-5-6-7-9');
resultP.then(result => console.log(result)); resultP.then(result => console.log(result));
{ {
"name": "@hiveio/hive-js", "name": "@hiveio/hive-js",
"version": "0.0.5", "version": "0.1.0",
"description": "Hive.js the JavaScript API for Hive blockchain", "description": "Hive.js the JavaScript API for Hi