Dr.Crypto! avatar

My contribution to dhive! ( Node wrapper for hive rpc api )

tngflx

Published: 06 May 2020 › Updated: 06 May 2020My contribution to dhive! ( Node wrapper for hive rpc api )

My contribution to dhive! ( Node wrapper for hive rpc api )

My merge request : https://gitlab.syncad.com/hive/dhive/-/merge_requests/7/diffs

Dsteem was an amazing library written by almost-digitalHive account@almost-digital, it provided a robust tool for us javascript developer to better interact with steem blockchain. In comparison with steemjs official library, it proved to be a faster and simpler syntax to work with. Developing dapp with dsteem is more pleasant, not to mention the intellisense that comes with typescript. Lessen the hours needed to read and search through documentations.

Other than that, typescript also provided a better bug control with its typed feature, further saved us developers from hidden variables error that took most of the time to catch and trace.

Due to this, I wish to further learn more about typescript and helped in developing on this rebranded library of dhive. Dhive still pertains all of its feature from dsteem. However there's still lots of feature need to be added in comparison with hivejs.

So these are the features related to hivemine that I've developed and hope to bring more in future! Do correct me if there's flaw and error!

Added Hivemind API query

import "mocha";
import * as assert from "assert";

import { Client, Asset, Transaction, PrivateKey } from "./../src";
import { getTestnetAccounts, randomString, agent, TEST_NODE } from "./common";

describe("HivemindAPI", function () {
    this.slow(500);
    this.timeout(20 * 1000);

    const client = Client.testnet({ agent });
    const liveClient = new Client(TEST_NODE, { agent });

    let acc: { username: string; password: string };

    it('getRankedPosts', async () => {
        const r = await liveClient.hivemind.getRankedPosts({ limit: 1, sort: 'trending', tag: '', observer: "" })
        console.log('rankedposts', r)
        assert.equal(r.length, 1)
    })

    it('getCommunity', async () => {
        const r = await liveClient.hivemind.getCommunity({ name: 'hive-148441', observer: '' })
        console.log('community', r)
        //assert.equal(r.length, 1)
    })

    it('getAccountNotifications', async () => {
        const r = await liveClient.hivemind.getAccountNotifications({ account: 'acidyo', limit: 2 })
        console.log('notifies', r)
        //assert.equal(r.length, 1)
    })

    it('listCommunities', async () => {
        const r = await liveClient.hivemind.listCommunities({ limit: 2 })
        console.log('communities', r)
    })

    it('listAllSubscriptions', async () => {
        const r = await liveClient.hivemind.listAllSubscriptions({ account: 'acidyo' })
        console.log('subscriptions', r)
        //assert.equal(r.length, 1)
    })
});

This is the full test code by mocha which proved to be successful in retrieving data. This also signifies all the api calls to hivemind you can make using dhive!

Tips for the day : Do you know notifications is actually handled by hivemind? You can use dhive to query it too!

image.png

The great thing about typescript is that the queries you placed as parameters of dhive functions is checked in realtime. Suggestion will show as what options are available. That's a much more pleasant programming experience.

Future plan :

  1. To add encode memo function
  2. Further improve documentations

Your support is my motivation!

Leave My contribution to dhive! ( Node wrapper for hive rpc api ) to:

Written by

Stay tune for more crypto news, medical publications, electronic hobbyist, passion for travelling!!

Read more #hivedevs posts


Best Posts From Dr.Crypto!

We have not curated any of tngflx's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Dr.Crypto!