Skip to content
This repository has been archived by the owner on Oct 20, 2020. It is now read-only.

Commit

Permalink
Edit Client Function
Browse files Browse the repository at this point in the history
  • Loading branch information
asuleymanov committed Oct 5, 2017
1 parent 0197e17 commit ceb5659
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This is just a code snippet. Please check the `examples` directory
for more complete and ready to use examples.

```go
cls := client.NewApi()
cls := client.NewApi([]string{"wss://ws.golos.io"},"golos")
defer cls.Rpc.Close()

// Get config.
Expand Down
19 changes: 11 additions & 8 deletions apis/database/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,11 +472,11 @@ func (api *API) GetConversionRequests(accountName string) ([]*ConversionRequests
}

//get_account_history
func (api *API) GetAccountHistory(account string, from uint64, limit uint32) (*json.RawMessage, error) {
/*func (api *API) GetAccountHistory(account string, from uint64, limit uint32) (*json.RawMessage, error) {
return api.Raw("get_account_history", []interface{}{account, from, limit})
}
}*/

/*func (api *API) GetAccountHistory(account string, from uint64, limit uint32) ([]*AccountHistory, error) {
func (api *API) GetAccountHistory(account string, from uint64, limit uint32) ([]*types.OperationObject, error) {
raw, err := api.Raw("get_account_history", []interface{}{account, from, limit})
if err != nil {
return nil, err
Expand All @@ -485,17 +485,20 @@ func (api *API) GetAccountHistory(account string, from uint64, limit uint32) (*j
if err := json.Unmarshal([]byte(*raw), &tmp1); err != nil {
return nil, err
}
var resp []*AccountHistory
var resp []*types.OperationObject
for _, v := range tmp1 {
byteData, _ := json.Marshal(v[1])
var tmp AccountHistory
byteData, errm := json.Marshal(&v[1])
if errm != nil {
return nil, errm
}
var tmp *types.OperationObject
if err := json.Unmarshal(byteData, &tmp); err != nil {
return nil, err
}
resp = append(resp, &tmp)
resp = append(resp, tmp)
}
return resp, nil
}*/
}

//get_owner_history
func (api *API) GetOwnerHistory(accountName string) (*json.RawMessage, error) {
Expand Down
10 changes: 0 additions & 10 deletions apis/database/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,13 +493,3 @@ type Categories struct {
Discussions *types.Int `json:"discussions"`
LastUpdate string `json:"last_update"`
}

type AccountHistory struct {
TrxID string `json:"trx_id"`
Block int `json:"block"`
TrxInBlock int `json:"trx_in_block"`
OpInTrx int `json:"op_in_trx"`
VirtualOp int `json:"virtual_op"`
Timestamp string `json:"timestamp"`
Op []interface{} `json:"op"`
}
30 changes: 24 additions & 6 deletions client/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,15 @@ func (api *Client) Post_Options(author_name, title, body string, tags []string,
permlink := translit.EncodeTitle(title)
tag := translit.EncodeTags(tags)
ptag := translit.EncodeTag(tags[0])
MAP := "1000000.000 GBG"
PSD := percent
if percent == 0 {
MAP = "0.000 GBG"
} else if percent == 50 {
PSD = 10000
} else {
PSD = 0
}

json_meta := "{\"tags\":["
for k, v := range tag {
Expand All @@ -222,8 +231,8 @@ func (api *Client) Post_Options(author_name, title, body string, tags []string,
txo := &types.CommentOptionsOperation{
Author: author_name,
Permlink: permlink,
MaxAcceptedPayout: "1000000.000 GBG",
PercentSteemDollars: percent,
MaxAcceptedPayout: MAP,
PercentSteemDollars: PSD,
AllowVotes: votes,
AllowCurationRewards: curation,
Extensions: []interface{}{},
Expand All @@ -239,13 +248,22 @@ func (api *Client) Post_Options(author_name, title, body string, tags []string,
}
}

func (api *Client) Post_Options_Vote(author_name, title, body string, tags []string, percent uint16, weight_post int, votes, curation bool) error {
func (api *Client) Post_Options_Vote(author_name, title, body string, tags []string, weight_post int, percent uint16, votes, curation bool) error {
if weight_post > 10000 {
weight_post = 10000
}
permlink := translit.EncodeTitle(title)
tag := translit.EncodeTags(tags)
ptag := translit.EncodeTag(tags[0])
MAP := "1000000.000 GBG"
PSD := percent
if percent == 0 {
MAP = "0.000 GBG"
} else if percent == 50 {
PSD = 10000
} else {
PSD = 0
}

json_meta := "{\"tags\":["
for k, v := range tag {
Expand All @@ -271,11 +289,11 @@ func (api *Client) Post_Options_Vote(author_name, title, body string, tags []str
txo := &types.CommentOptionsOperation{
Author: author_name,
Permlink: permlink,
MaxAcceptedPayout: "1000000.000 GBG",
PercentSteemDollars: percent,
MaxAcceptedPayout: MAP,
PercentSteemDollars: PSD,
AllowVotes: votes,
AllowCurationRewards: curation,
//Extensions: "",
Extensions: []interface{}{},
}
trx = append(trx, txo)

Expand Down

0 comments on commit ceb5659

Please sign in to comment.