Git Product home page Git Product logo

ditch's Introduction

Build Status

Wiki Documentation Site Telegram (ru) Telegram (en) Follow us (ru) Follow us (en)

Ditch

The essence of the library is to generate a transaction according to the required operations (vote, comment, etc.), sign the transaction and broadcast to the Graphene-based blockchain.

Supported chains:

  • Golos (v0.18.3) NuGet version
  • Steem (v0.19.10) NuGet version
  • EOS (v1.1.0) NuGet version
  • BitShares NuGet version

Additional features:

  • Transliteration (Cyrillic to Latin)
  • Base58 converter
  • Can connect by https or socket (wss)

Usage

//set global properties
public void SetUp()
{
    HttpClient = new HttpClient();
    HttpManager = new HttpManager(HttpClient);
    Api = new OperationManager(HttpManager);
    //Api = new OperationManager(new WebSocketManager());
    
    Api.ConnectTo("https://api.steemit.com", CancellationToken.None);        
    //Api.ConnectTo("wss://ws.golos.io", CancellationToken.None);
    
    YouPrivateKeys = new List<byte[]>
    {
        Base58.GetBytes("5**************************************************") \\WIF
    };
    YouLogin = "username";
}

//Create new post with some beneficiaries
var postOp = new PostOperation("parentPermlink", YouLogin, "Title", "Body", "jsonMetadata");
var benOp = new BeneficiariesOperation(YouLogin, postOp.Permlink, new Asset(1, Config.SteemAssetNumSbd), new Beneficiary("someBeneficiarName", 1000));
var responce = Api.BroadcastOperations(YouPrivateKeys, new[]{postOp, benOp},CancellationToken.None);

//UpVote
var voteOp = new UpVoteOperation(YouLogin, "someUserName", "somePermlink");
var responce = Api.BroadcastOberations(YouPrivateKeys, voteOp, CancellationToken.None);

//Follow
var followOp = new FollowOperation(YouLogin, "someUserName", FollowType.Blog, YouLogin);
var responce = Api.BroadcastOperations(YouPrivateKeys, followOp, CancellationToken.None);

ditch's People

Contributors

anch7 avatar korzunav avatar lexani avatar nikita-pobazhak avatar nikitkao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ditch's Issues

Ditch.Steem does not work with nodes other than api.steemit.com

It seems there are two a bit different formats for calling methods via Steem JsonRpc.

The first one is the one Ditch uses:
{"jsonrpc":"2.0","method":"database_api.get_dynamic_global_properties","id":14}

The second one is the one steemit.com website uses:
{"id":14,"jsonrpc":"2.0","method":"call","params":["database_api","get_dynamic_global_properties",[]]}

Main api.steemit.com node seems to support both formats, but alternative public nodes like "https://steemd.minnowsupportproject.org" and "https://rpc.buildteam.io" only support the second one, so they reject Ditch requests.

The way I see it this issue can be fixed by making minor changes to DitchSteem/JsonRpc/JsonRpcRequest.cs.
Also it might be a good idea to add some sort of setting to choose format needed.

STEEM API change creates 2 issues with Ditch.Steem.OperationManager class

It seems there was an API change on March 23:

There are 2 issue in class: Ditch.Steem.OperationManager.TryLoadChainId()

(1.) Naming change:

var scid = conf.STEEMIT_CHAIN_ID as JValue;
var smpsbd = conf.STEEMIT_MIN_PAYOUT_SBD as JValue;
var sbhv = conf.STEEMIT_BLOCKCHAIN_HARDFORK_VERSION as JValue;

STEEMIT has changed to STEEM:

var scid = conf.STEEM_CHAIN_ID as JValue;
var smpsbd = conf.STEEM_MIN_PAYOUT_SBD as JValue;
var sbhv = conf.STEEM_BLOCKCHAIN_HARDFORK_VERSION as JValue;

(2.) STEEM_MIN_PAYOUT_SBD seems to have a different result value than expected and creates an error:

var smpsbd = conf.STEEM_MIN_PAYOUT_SBD as JValue;

The new result is an array.


Because of the 2 issues the class TryLoadChainId() returns false. And because of that
var url = _operationManager.TryConnectTo() is now always string.empty.

Anyway it seems every other API call still seems to work as expected.

Thank you for your work I highly appreciate it.

Assert Exception:v.is_object(): Input data have to treated as object.

Hi, when I invoke mehod VoteTest() from Steemit Tests project, it fails with response: Ditch.Core.Errors.ResponseError. Code: '-32003'. Message: 'Assert Exception:v.is_object(): Input data have to treated as object.'

Do you have any idea why is that? PostTest() returns the same response. I suspect that sent operation has wrong structure but I am not sure how to correct it. Do you know how to fix it?

Error while getting account balance.

When i trying to check user balance i get Error with text: `"+ Error {Ditch.Core.Errors.ResponseError. Code: '1'. Message: '10 assert_exception: Assert Exception
itr != _by_name.end(): no method with name 'get_account_balances'
{"name":"get_account_balances","api":{"cancel_all_subscriptions":3,"get_account_bandwidth":48,"get_account_count":41,"get_account_history":43,"get_account_references":38,"get_account_votes":61,"get_accounts":37,"get_active_categories":25,"get_active_votes":60,"get_active_witnesses":71,"get_best_categories":24,"get_block":20,"get_block_header":19,"get_chain_properties":30,"get_config":27,"get_content":62,"get_content_replies":63,"get_conversion_requests":42,"get_current_median_history_price":32,"get_discussions_by_active":9,"get_discussions_by_author_before_date":64,"get_discussions_by_blog":16,"get_discussions_by_cashout":10,"get_discussions_by_children":13,"get_discussions_by_comments":17,"get_discussions_by_created":8,"get_discussions_by_feed":15,"get_discussions_by_hot":14,"get_discussions_by_payout":11,"get_discussions_by_promoted":18,"get_discussions_by_trending":6,"get_discussions_by_trending30":7,"get_discussions_by_votes":12,"get_dynamic_global_properties":29,"get_escrow":46,"get_feed_history":31,"get_free_memory":28,"get_hardfork_version":34,"get_key_references":36,"get_liquidity_queue":53,"get_miner_queue":72,"get_next_scheduled_hardfork":35,"get_open_orders":52,"get_ops_in_block":21,"get_order_book":51,"get_owner_history":44,"get_potential_signatures":57,"get_recent_categories":26,"get_recovery_request":45,"get_replies_by_last_update":65,"get_required_signatures":56,"get_savings_withdraw_from":49,"get_savings_withdraw_to":50,"get_state":22,"get_tags_used_by_author":5,"get_transaction":55,"get_transaction_hex":54,"get_trending_categories":23,"get_trending_tags":4,"get_withdraw_routes":47,"get_witness_by_account":67,"get_witness_count":70,"get_witness_schedule":33,"get_witnesses":66,"get_witnesses_by_vote":68,"lookup_account_names":39,"lookup_accounts":40,"lookup_witness_accounts":69,"set_block_applied_callback":2,"set_pending_transaction_callback":1,"set_subscribe_callback":0,"verify_account_authority":59,"verify_authority":58}}
th_a api_connection.hpp:109 call

{"call.method":"call","call.params":["database_api","get_account_balances",["hmmmk",["GOLOS"]]]}
th_a  websocket_api.cpp:124 on_message'}	Ditch.Core.Errors.ErrorInfo {Ditch.Core.Errors.ResponseError}

"`

Here is my code:
`JsonRpcResponse<Asset[]> response = _operationManager
.GetAccountBalances(userAdress, new String[] { "GOLOS" }, CancellationToken.None);
Asset[] assets = response.Result;

            MessageBox.Show("Balance of " + userAdress + " is " + assets[0].Value + " " + assets[0].Currency);`

Initialization has to happen before creation

In current code WebSocketManager gets initialized in constructor and it expects GlobalSettings to be already initialized. For example, you cannot write

_operationManager = new OperationManager();
GlobalSettings.Init(Name, PostingKey, KnownChains.Steem);

you always have to do it the other way around, otherwise you'll get NullReferenceException. This is quite inconvenient as it's natural to create objects in class constructor, i.e.:

public Robot(){
this.operationManager = new OperationManager();
}

and configure it later:

public void Configure(){
this.Account = ConfigurationManager.AppSettings["account"];
this.PostingKey = ConfigurationManager.AppSettings["postingKey"];
GlobalSettings.Init(Account, PostingKey, KnownChains.Golos);
}

This scenario is not possible in current setup. I suggest lazy initialization of WebSocketManager to address this with minimal impact. Please see my fork for details.

System.InvalidCastException: Unable to cast object of type 'Newtonsoft.Json.Linq.JObject' to type 'Newtonsoft.Json.Linq.JArray'

Hi,

I'm unable to run the following code:

var findAccountsArgs = new FindAccountsArgs()
{
    Accounts = new[] { "my_login" }
};
_operationManager.FindAccounts(findAccountsArgs, CancellationToken.None);

It gives the error:

System.InvalidCastException: Unable to cast object of type 'Newtonsoft.Json.Linq.JObject' to type 'Newtonsoft.Json.Linq.JArray'

The error happens in the method:

\Sources\Ditch.Steem\Models\Other\LegacyAsset.cs

public void ReadJson(JsonReader reader, JsonSerializer serializer)
{
->    var arr = serializer.Deserialize<JArray>(reader);
    Amount = arr[0].Value<long>();
    Symbol = new AssetSymbolType(arr[2].Value<string>(), arr[1].Value<byte>());
}

I'm trying to get a single (existing) account as seen here:
https://github.com/Chainers/Ditch/releases

Versions:

  • Ditch 3.1.3 / 3.2-alpha
  • Newtonsoft.Json 11.0.2

I'm not sure if I made a mistake or not.

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.