-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_comment.js
122 lines (85 loc) · 2.65 KB
/
test_comment.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
const moment = require("moment");
var steem = require('steem');
require('dotenv').config();
steem.api.setOptions({url: 'https://testnet.steemitdev.com/', useAppbaseApi : true, address_prefix : 'TST', 'chain_id' : "98b69bd7cbe4d27864e2f06d9f74ba50aed0b7f511436ef9c7b80f36f3ff5859"});
steem.config.set('address_prefix', 'TST')
steem.config.set('chain_id', '98b69bd7cbe4d27864e2f06d9f74ba50aed0b7f511436ef9c7b80f36f3ff5859');
const assert = require("assert");
var s_username_0 = process.env.STEEM_USERNAME_0;
var s_active_key_0 = process.env.STEEM_AK_0;
var s_posting_key_0 = process.env.STEEM_PK_0;
var s_username_1 = process.env.STEEM_USERNAME_1;
var s_active_key_1 = process.env.STEEM_AK_1;
var s_posting_key_1 = process.env.STEEM_PK_1;
var s_username_2 = process.env.STEEM_USERNAME_2;
var s_active_key_2 = process.env.STEEM_AK_2;
const TEST_NAI_ASSET = { nai: '@@103004864', precision: 3 }
function broadcast(tx, wif)
{
return new Promise(resolve => {
steem.broadcast.send(tx, {wif}, async function (err, result) {
if (err) {
return resolve({noError : false, err})
} else {
return resolve({noError : true , result})
}
});
});
}
async function test_comment_options() {
let tx = {
'operations': [
[
"comment_options",
{
"author": "domenico",
"permlink": "test1",
"max_accepted_payout": {
"amount": 10000,
"precision": 3,
"nai": "@@000000013"
},
"percent_steem_dollars": 5000,
"allow_votes": true,
"allow_curation_rewards": true,
"extensions": [
[
0,
{
"beneficiaries": [{"account": "charlie", "weight": 1000}]
}
]
]
}
]
]
};
let j = JSON.stringify(tx);
console.log(j);
let result = await broadcast(tx, s_posting_key_1);
console.log(result);
}
async function test_comment() {
let tx = {
'operations': [
[
'comment', {
"author": "domenico",
"title": "A post by Joe",
"body": "Look at my awesome post",
"parent_author": "",
"parent_permlink": "steem",
"permlink": "test1",
"json_metadata": "{\"tags\":[\"steemit\",\"example\",\"tags\"]}"
}
],
]
};
let j = JSON.stringify(tx);
console.log(j);
let result = await broadcast(tx, s_posting_key_1);
console.log(result);
}
console.log("Testing comment operation with account: " + s_username_1 + " ...");
//test_comment();
test_comment_options();