Hive-js & Hive-tx migration to Hive - Breaking changes for browsers!

avatar


hivejshivetx.jpg

Hive-js

Hive-js is the official javascript library for Hive. All the apps previously using Steem-js should use Hive-js instead.

Installation:

npm install @hiveio/hive-js --save

Browser usage:

<script src="https://cdn.jsdelivr.net/npm/@hiveio/hive-js/dist/hive.min.js"></script>

New config option:

hive.config.set('alternative_api_endpoints', ['https://api.hive.blog', 'https://anyx.io']);

Breaking changes (Only on browsers):
The only breaking change is the variable name on the browsers. You must use hive instead of steem in the browsers to access Hive-js library.

Example usage:

hive.api.getAccounts(['mahdiyari', 'hiveio'], function(err, result) {
    console.log(err, result);
});

Deprecated method:
hive.formatter.vestToSteem() is deprecated and will be removed in the future releases. Use hive.formatter.vestToHive() instead.

var hivePower = hive.formatter.vestToHive(vestingShares, totalVestingShares, totalVestingFundHive);

Source code and full documentation: https://gitlab.syncad.com/hive/hive-js
Npm package: https://www.npmjs.com/package/@hiveio/hive-js


Hive-tx

Lightweight and complete JavaScript library for using Hive blockchain in Javascript environments such as Web or NodeJS.

Previously introduced as Steem-tx and now fully migrated to Hive.

Source code and full documentation: https://github.com/mahdiyari/hive-tx-js
Npm package: https://www.npmjs.com/package/hive-tx


Contribution is more than welcome in all repositories on https://gitlab.syncad.com/hive
Development is in the hands of the community.



0
0
0.000
30 comments
avatar

Thanks for doing this important work.

0
0
0.000
avatar

I like the new alternative_api_endpoints, does it failover to the next endpoint when one errors?

0
0
0.000
avatar

Yes. The expected behavior is a failover to the next endpoint.

0
0
0.000
avatar

Nice! I don't have to re-invent the wheel swapping nodes in my code anymore.

0
0
0.000
avatar

Thanks for developing and sharing this "toy", @mahdiyari!
Bookmarked and reblogged!
!tip & hugs! 🤗
@tipu curate

0
0
0.000
avatar

How much time do we have to make the transition?

0
0
0.000
avatar

Hive-js is the official library (for now) and will get updated regularly. You can use whatever works for you.
I think after next hf, steem libraries will not work on Hive.

0
0
0.000
avatar

ok, great... I still have some time then...
Thx for the quick reply! 👍

0
0
0.000
avatar

Are there types for typescript with hive-js?

0
0
0.000
avatar
(Edited)

I might not understand what's your mean. But hive-js should work with typescript too.

import * as hive from 'hive-js'
0
0
0.000
avatar
(Edited)

kools, I started off on dsteem and it worked with typescript. For clarity I was tryina ensure that hive-js had types to work with typescript. Do you know if dsteem will be ported over and which is the recommend lib for deving for hive?

0
0
0.000
avatar

A few people worked on dhive and I think you can try it: https://gitlab.syncad.com/hive/dhive

Hive-js is not ideal for broadcasting massive transactions and is slow in signing but is more userfriendly and has more methods. On the other hand, dhive is faster in signing transactions.

If you want something light without any extra method, hive-tx might be your choice. And is fast enough.

0
0
0.000
avatar

Note the typo:

I20200506-13:22:30.477(2)? Alternate endpoitns:  [ 'https://api.hive.blog', 'https://anyx.io' ]
I20200506-13:22:30.524(2)? Error Failover Threshold:  3

'endpoitns' should be replaced by 'endpoints' :)

0
0
0.000
avatar

Anyone else having issues with old data being pulled? Seems hive.api.getAccounts is pulling old hive information, not the most recent update. I've tried multiple browsers and even a second computer to verify, example page is the console.log history on https://profile.blokz.io/?hive=sn0n

0
0
0.000
avatar

https://hiveblocks.com/@sn0n I'm noticing has 2 different versions of json metadata, the text in red is incorrect, but I see a posting json metadata on top that is showing updated information.... Assistance is more then welcomed.

0
0
0.000
avatar

https://github.com/steemit/steem/issues/3274 has more information, apparently it's a artifact from pre-hf21... Could this be updated to use posting_json_metadata with a json_metadata fallback? Or something?

0
0
0.000
avatar

posting_json_metadata requires only posting key to update but json_metadata requires active key.

0
0
0.000
avatar

What about to view it? My project site I'd like to display posting, but not sure what to call

0
0
0.000
avatar
(Edited)

https://developers.hive.io/apidefinitions/#database_api.find_accounts

database_api.find_accounts returns posting_json_metadata

hive.api.callAsync('database_api.find_accounts', { accounts: ['mahdiyari'] })
  .then((res) => console.log(res))

or

hive.api.call('database_api.find_accounts', { accounts: ['mahdiyari'] }, (err, res) => {
  console.log(err, res)
})
0
0
0.000
avatar

Beautiful, going to try that shortly. Appreciate the help.

0
0
0.000
avatar

Worked great, thank you again.

0
0
0.000