@steemit/steem-js 0.7.10 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -3
- package/circle.yml +1 -1
- package/config.json +1 -1
- package/dist/steem-tests.min.js +4097 -23
- package/dist/steem.min.js +2089 -18
- package/docker-webpack.config.js +44 -0
- package/lib/api/index.js +305 -412
- package/lib/api/methods.js +16 -1
- package/lib/api/rpc-auth.js +135 -0
- package/lib/api/transports/base.js +25 -66
- package/lib/api/transports/http.js +114 -129
- package/lib/api/transports/index.js +8 -15
- package/lib/api/transports/ws.js +107 -207
- package/lib/auth/ecc/index.js +9 -9
- package/lib/auth/ecc/src/address.js +48 -78
- package/lib/auth/ecc/src/aes.js +93 -129
- package/lib/auth/ecc/src/brain_key.js +7 -7
- package/lib/auth/ecc/src/ecdsa.js +7 -33
- package/lib/auth/ecc/src/ecsignature.js +4 -30
- package/lib/auth/ecc/src/enforce_types.js +1 -8
- package/lib/auth/ecc/src/hash.js +16 -25
- package/lib/auth/ecc/src/key_private.js +146 -199
- package/lib/auth/ecc/src/key_public.js +130 -202
- package/lib/auth/ecc/src/key_utils.js +64 -106
- package/lib/auth/ecc/src/signature.js +125 -177
- package/lib/auth/index.js +84 -97
- package/lib/auth/memo.js +90 -118
- package/lib/auth/serializer/index.js +12 -18
- package/lib/auth/serializer/src/ChainTypes.js +0 -3
- package/lib/auth/serializer/src/convert.js +29 -32
- package/lib/auth/serializer/src/error_with_cause.js +22 -37
- package/lib/auth/serializer/src/fast_parser.js +54 -74
- package/lib/auth/serializer/src/number_utils.js +30 -54
- package/lib/auth/serializer/src/object_id.js +37 -62
- package/lib/auth/serializer/src/operations.js +597 -689
- package/lib/auth/serializer/src/precision.js +55 -73
- package/lib/auth/serializer/src/serializer.js +158 -204
- package/lib/auth/serializer/src/template.js +13 -8
- package/lib/auth/serializer/src/types.js +949 -1110
- package/lib/auth/serializer/src/validation.js +268 -328
- package/lib/broadcast/helpers.js +61 -98
- package/lib/broadcast/index.js +61 -82
- package/lib/browser.js +15 -19
- package/lib/config.js +16 -38
- package/lib/formatter.js +89 -115
- package/lib/index.js +19 -17
- package/lib/utils.js +4 -9
- package/node-18.dockerfile +28 -0
- package/package.json +62 -38
- package/test/Crypto.js +16 -16
- package/test/KeyFormats.js +1 -1
- package/test/api.test.js +37 -0
- package/test/broadcast.test.js +14 -8
- package/test/comment.test.js +17 -3
- package/test/operations_test.js +1 -1
- package/test/promise-broadcast.test.js +86 -0
- package/test/reputation.test.js +68 -0
- package/test/smt.test.js +11 -11
- package/test-github-workflow.bat +19 -0
- package/test-github-workflow.sh +15 -0
- package/webpack/makeConfig.js +25 -17
- package/.circleci/config.yml +0 -23
- package/dist/statistics.html +0 -208
- package/dist/steem-tests.min.js.gz +0 -0
- package/dist/steem-tests.min.js.map +0 -1
- package/dist/steem.min.js.gz +0 -0
- package/dist/steem.min.js.map +0 -1
- package/lib/auth/ecc/README.md +0 -20
- package/lib/auth/ecc/package.json +0 -36
- package/lib/auth/serializer/README.md +0 -13
- package/lib/auth/serializer/package.json +0 -32
- package/node-4.dockerfile +0 -6
- package/node-6.dockerfile +0 -6
- package/yarn.lock +0 -3336
package/lib/broadcast/helpers.js
CHANGED
|
@@ -1,40 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
username = _ref.username,
|
|
15
|
-
authorizedUsername = _ref.authorizedUsername,
|
|
16
|
-
_ref$role = _ref.role,
|
|
17
|
-
role = _ref$role === undefined ? 'posting' : _ref$role,
|
|
18
|
-
weight = _ref.weight;
|
|
19
|
-
|
|
20
|
-
_api2.default.getAccounts([username], function (err, _ref2) {
|
|
21
|
-
var _ref3 = _slicedToArray(_ref2, 1),
|
|
22
|
-
userAccount = _ref3[0];
|
|
23
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _api = _interopRequireDefault(require("../api"));
|
|
4
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
5
|
+
exports = module.exports = steemBroadcast => {
|
|
6
|
+
steemBroadcast.addAccountAuth = ({
|
|
7
|
+
signingKey,
|
|
8
|
+
username,
|
|
9
|
+
authorizedUsername,
|
|
10
|
+
role = 'posting',
|
|
11
|
+
weight
|
|
12
|
+
}, cb) => {
|
|
13
|
+
_api.default.getAccounts([username], (err, [userAccount]) => {
|
|
24
14
|
if (err) {
|
|
25
15
|
return cb(new Error(err), null);
|
|
26
16
|
}
|
|
27
17
|
if (!userAccount) {
|
|
28
18
|
return cb(new Error('Invalid account name'), null);
|
|
29
19
|
}
|
|
30
|
-
|
|
31
|
-
var updatedAuthority = userAccount[role];
|
|
20
|
+
const updatedAuthority = userAccount[role];
|
|
32
21
|
|
|
33
22
|
/** Release callback if the account already exist in the account_auths array */
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
37
|
-
var hasAuthority = authorizedAccounts.indexOf(authorizedUsername) !== -1;
|
|
23
|
+
const authorizedAccounts = updatedAuthority.account_auths.map(auth => auth[0]);
|
|
24
|
+
const hasAuthority = authorizedAccounts.indexOf(authorizedUsername) !== -1;
|
|
38
25
|
if (hasAuthority) {
|
|
39
26
|
return cb(null, null);
|
|
40
27
|
}
|
|
@@ -42,37 +29,31 @@ exports = module.exports = function (steemBroadcast) {
|
|
|
42
29
|
/** Use weight_thresold as default weight */
|
|
43
30
|
weight = weight || userAccount[role].weight_threshold;
|
|
44
31
|
updatedAuthority.account_auths.push([authorizedUsername, weight]);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
32
|
+
const owner = role === 'owner' ? updatedAuthority : undefined;
|
|
33
|
+
const active = role === 'active' ? updatedAuthority : undefined;
|
|
34
|
+
const posting = role === 'posting' ? updatedAuthority : undefined;
|
|
48
35
|
|
|
49
36
|
/** Add authority on user account */
|
|
50
37
|
steemBroadcast.accountUpdate(signingKey, userAccount.name, owner, active, posting, userAccount.memo_key, userAccount.json_metadata, cb);
|
|
51
38
|
});
|
|
52
39
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
_api2.default.getAccounts([username], function (err, _ref5) {
|
|
62
|
-
var _ref6 = _slicedToArray(_ref5, 1),
|
|
63
|
-
userAccount = _ref6[0];
|
|
64
|
-
|
|
40
|
+
steemBroadcast.removeAccountAuth = ({
|
|
41
|
+
signingKey,
|
|
42
|
+
username,
|
|
43
|
+
authorizedUsername,
|
|
44
|
+
role = 'posting'
|
|
45
|
+
}, cb) => {
|
|
46
|
+
_api.default.getAccounts([username], (err, [userAccount]) => {
|
|
65
47
|
if (err) {
|
|
66
48
|
return cb(new Error(err), null);
|
|
67
49
|
}
|
|
68
50
|
if (!userAccount) {
|
|
69
51
|
return cb(new Error('Invalid account name'), null);
|
|
70
52
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
var user = updatedAuthority.account_auths[i];
|
|
53
|
+
const updatedAuthority = userAccount[role];
|
|
54
|
+
const totalAuthorizedUser = updatedAuthority.account_auths.length;
|
|
55
|
+
for (let i = 0; i < totalAuthorizedUser; i++) {
|
|
56
|
+
const user = updatedAuthority.account_auths[i];
|
|
76
57
|
if (user[0] === authorizedUsername) {
|
|
77
58
|
updatedAuthority.account_auths.splice(i, 1);
|
|
78
59
|
break;
|
|
@@ -83,41 +64,31 @@ exports = module.exports = function (steemBroadcast) {
|
|
|
83
64
|
if (totalAuthorizedUser === updatedAuthority.account_auths.length) {
|
|
84
65
|
return cb(null, null);
|
|
85
66
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
var posting = role === 'posting' ? updatedAuthority : undefined;
|
|
90
|
-
|
|
67
|
+
const owner = role === 'owner' ? updatedAuthority : undefined;
|
|
68
|
+
const active = role === 'active' ? updatedAuthority : undefined;
|
|
69
|
+
const posting = role === 'posting' ? updatedAuthority : undefined;
|
|
91
70
|
steemBroadcast.accountUpdate(signingKey, userAccount.name, owner, active, posting, userAccount.memo_key, userAccount.json_metadata, cb);
|
|
92
71
|
});
|
|
93
72
|
};
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
_api2.default.getAccounts([username], function (err, _ref8) {
|
|
104
|
-
var _ref9 = _slicedToArray(_ref8, 1),
|
|
105
|
-
userAccount = _ref9[0];
|
|
106
|
-
|
|
73
|
+
steemBroadcast.addKeyAuth = ({
|
|
74
|
+
signingKey,
|
|
75
|
+
username,
|
|
76
|
+
authorizedKey,
|
|
77
|
+
role = 'posting',
|
|
78
|
+
weight
|
|
79
|
+
}, cb) => {
|
|
80
|
+
_api.default.getAccounts([username], (err, [userAccount]) => {
|
|
107
81
|
if (err) {
|
|
108
82
|
return cb(new Error(err), null);
|
|
109
83
|
}
|
|
110
84
|
if (!userAccount) {
|
|
111
85
|
return cb(new Error('Invalid account name'), null);
|
|
112
86
|
}
|
|
113
|
-
|
|
114
|
-
var updatedAuthority = userAccount[role];
|
|
87
|
+
const updatedAuthority = userAccount[role];
|
|
115
88
|
|
|
116
89
|
/** Release callback if the key already exist in the key_auths array */
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
});
|
|
120
|
-
var hasAuthority = authorizedKeys.indexOf(authorizedKey) !== -1;
|
|
90
|
+
const authorizedKeys = updatedAuthority.key_auths.map(auth => auth[0]);
|
|
91
|
+
const hasAuthority = authorizedKeys.indexOf(authorizedKey) !== -1;
|
|
121
92
|
if (hasAuthority) {
|
|
122
93
|
return cb(null, null);
|
|
123
94
|
}
|
|
@@ -125,37 +96,31 @@ exports = module.exports = function (steemBroadcast) {
|
|
|
125
96
|
/** Use weight_thresold as default weight */
|
|
126
97
|
weight = weight || userAccount[role].weight_threshold;
|
|
127
98
|
updatedAuthority.key_auths.push([authorizedKey, weight]);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
99
|
+
const owner = role === 'owner' ? updatedAuthority : undefined;
|
|
100
|
+
const active = role === 'active' ? updatedAuthority : undefined;
|
|
101
|
+
const posting = role === 'posting' ? updatedAuthority : undefined;
|
|
131
102
|
|
|
132
103
|
/** Add authority on user account */
|
|
133
104
|
steemBroadcast.accountUpdate(signingKey, userAccount.name, owner, active, posting, userAccount.memo_key, userAccount.json_metadata, cb);
|
|
134
105
|
});
|
|
135
106
|
};
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
_api2.default.getAccounts([username], function (err, _ref11) {
|
|
145
|
-
var _ref12 = _slicedToArray(_ref11, 1),
|
|
146
|
-
userAccount = _ref12[0];
|
|
147
|
-
|
|
107
|
+
steemBroadcast.removeKeyAuth = ({
|
|
108
|
+
signingKey,
|
|
109
|
+
username,
|
|
110
|
+
authorizedKey,
|
|
111
|
+
role = 'posting'
|
|
112
|
+
}, cb) => {
|
|
113
|
+
_api.default.getAccounts([username], (err, [userAccount]) => {
|
|
148
114
|
if (err) {
|
|
149
115
|
return cb(new Error(err), null);
|
|
150
116
|
}
|
|
151
117
|
if (!userAccount) {
|
|
152
118
|
return cb(new Error('Invalid account name'), null);
|
|
153
119
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
var user = updatedAuthority.key_auths[i];
|
|
120
|
+
const updatedAuthority = userAccount[role];
|
|
121
|
+
const totalAuthorizedKey = updatedAuthority.key_auths.length;
|
|
122
|
+
for (let i = 0; i < totalAuthorizedKey; i++) {
|
|
123
|
+
const user = updatedAuthority.key_auths[i];
|
|
159
124
|
if (user[0] === authorizedKey) {
|
|
160
125
|
updatedAuthority.key_auths.splice(i, 1);
|
|
161
126
|
break;
|
|
@@ -166,11 +131,9 @@ exports = module.exports = function (steemBroadcast) {
|
|
|
166
131
|
if (totalAuthorizedKey === updatedAuthority.key_auths.length) {
|
|
167
132
|
return cb(null, null);
|
|
168
133
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
var posting = role === 'posting' ? updatedAuthority : undefined;
|
|
173
|
-
|
|
134
|
+
const owner = role === 'owner' ? updatedAuthority : undefined;
|
|
135
|
+
const active = role === 'active' ? updatedAuthority : undefined;
|
|
136
|
+
const posting = role === 'posting' ? updatedAuthority : undefined;
|
|
174
137
|
steemBroadcast.accountUpdate(signingKey, userAccount.name, owner, active, posting, userAccount.memo_key, userAccount.json_metadata, cb);
|
|
175
138
|
});
|
|
176
139
|
};
|
package/lib/broadcast/index.js
CHANGED
|
@@ -1,76 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var _formatter = require('../formatter');
|
|
18
|
-
|
|
19
|
-
var _formatter2 = _interopRequireDefault(_formatter);
|
|
20
|
-
|
|
21
|
-
var _operations = require('./operations');
|
|
22
|
-
|
|
23
|
-
var _operations2 = _interopRequireDefault(_operations);
|
|
24
|
-
|
|
25
|
-
var _api = require('../api');
|
|
26
|
-
|
|
27
|
-
var _api2 = _interopRequireDefault(_api);
|
|
28
|
-
|
|
29
|
-
var _auth = require('../auth');
|
|
30
|
-
|
|
31
|
-
var _auth2 = _interopRequireDefault(_auth);
|
|
32
|
-
|
|
33
|
-
var _utils = require('../utils');
|
|
34
|
-
|
|
35
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
36
|
-
|
|
37
|
-
var debug = (0, _debug2.default)('steem:broadcast');
|
|
38
|
-
var noop = function noop() {};
|
|
39
|
-
var formatter = (0, _formatter2.default)(_api2.default);
|
|
40
|
-
|
|
41
|
-
var steemBroadcast = {};
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _bluebird = _interopRequireDefault(require("bluebird"));
|
|
4
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
5
|
+
var _helpers = _interopRequireDefault(require("./helpers"));
|
|
6
|
+
var _formatter = _interopRequireDefault(require("../formatter"));
|
|
7
|
+
var _operations = _interopRequireDefault(require("./operations"));
|
|
8
|
+
var _api = _interopRequireDefault(require("../api"));
|
|
9
|
+
var _auth = _interopRequireDefault(require("../auth"));
|
|
10
|
+
var _utils = require("../utils");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
const debug = (0, _debug.default)('steem:broadcast');
|
|
13
|
+
const noop = function () {};
|
|
14
|
+
const formatter = (0, _formatter.default)(_api.default);
|
|
15
|
+
const steemBroadcast = {};
|
|
42
16
|
|
|
43
17
|
// Base transaction logic -----------------------------------------------------
|
|
44
18
|
|
|
45
19
|
/**
|
|
46
20
|
* Sign and broadcast transactions on the steem network
|
|
21
|
+
* @param {Object} tx - Transaction object
|
|
22
|
+
* @param {Object|String} privKeys - Private keys or key string
|
|
23
|
+
* @param {Function} [callback] - Optional callback function
|
|
24
|
+
* @return {Promise} - Returns a promise if no callback is provided
|
|
47
25
|
*/
|
|
48
|
-
|
|
49
26
|
steemBroadcast.send = function steemBroadcast$send(tx, privKeys, callback) {
|
|
50
|
-
|
|
27
|
+
const resultP = steemBroadcast._prepareTransaction(tx).then(transaction => {
|
|
51
28
|
debug('Signing transaction (transaction, transaction.operations)', transaction, transaction.operations);
|
|
52
|
-
return
|
|
53
|
-
}).spread(
|
|
29
|
+
return _bluebird.default.join(transaction, _auth.default.signTransaction(transaction, privKeys));
|
|
30
|
+
}).spread((transaction, signedTransaction) => {
|
|
54
31
|
debug('Broadcasting transaction (transaction, transaction.operations)', transaction, transaction.operations);
|
|
55
|
-
return
|
|
32
|
+
return _api.default.broadcastTransactionSynchronousAsync(signedTransaction).then(result => {
|
|
56
33
|
return Object.assign({}, result, signedTransaction);
|
|
57
34
|
});
|
|
58
35
|
});
|
|
59
|
-
|
|
60
|
-
|
|
36
|
+
if (callback) {
|
|
37
|
+
resultP.nodeify(callback);
|
|
38
|
+
return undefined;
|
|
39
|
+
} else {
|
|
40
|
+
return resultP;
|
|
41
|
+
}
|
|
61
42
|
};
|
|
62
|
-
|
|
63
43
|
steemBroadcast._prepareTransaction = function steemBroadcast$_prepareTransaction(tx) {
|
|
64
|
-
|
|
65
|
-
return propertiesP.then(
|
|
44
|
+
const propertiesP = _api.default.getDynamicGlobalPropertiesAsync();
|
|
45
|
+
return propertiesP.then(properties => {
|
|
66
46
|
// Set defaults on the transaction
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return
|
|
70
|
-
|
|
47
|
+
const chainDate = new Date(properties.time + 'Z');
|
|
48
|
+
const refBlockNum = properties.last_irreversible_block_num - 1 & 0xFFFF;
|
|
49
|
+
return _api.default.getBlockHeaderAsync(properties.last_irreversible_block_num).then(block => {
|
|
50
|
+
const headBlockId = block ? block.previous : '0000000000000000000000000000000000000000';
|
|
71
51
|
return Object.assign({
|
|
72
52
|
ref_block_num: refBlockNum,
|
|
73
|
-
ref_block_prefix: new Buffer(headBlockId, 'hex').readUInt32LE(4),
|
|
53
|
+
ref_block_prefix: new Buffer.from(headBlockId, 'hex').readUInt32LE(4),
|
|
74
54
|
expiration: new Date(chainDate.getTime() + 600 * 1000)
|
|
75
55
|
}, tx);
|
|
76
56
|
});
|
|
@@ -80,15 +60,16 @@ steemBroadcast._prepareTransaction = function steemBroadcast$_prepareTransaction
|
|
|
80
60
|
// Generated wrapper ----------------------------------------------------------
|
|
81
61
|
|
|
82
62
|
// Generate operations from operations.json
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
63
|
+
_operations.default.forEach(operation => {
|
|
64
|
+
const operationName = (0, _utils.camelCase)(operation.operation);
|
|
65
|
+
const operationParams = operation.params || [];
|
|
66
|
+
const useCommentPermlink = operationParams.indexOf('parent_author') !== -1 && operationParams.indexOf('parent_permlink') !== -1;
|
|
67
|
+
steemBroadcast[`${operationName}With`] = function steemBroadcast$specializedSendWith(wif, options, callback) {
|
|
68
|
+
debug(`Sending operation "${operationName}" with`, {
|
|
69
|
+
options,
|
|
70
|
+
callback
|
|
71
|
+
});
|
|
72
|
+
const keys = {};
|
|
92
73
|
if (operation.roles && operation.roles.length) {
|
|
93
74
|
keys[operation.roles[0]] = wif; // TODO - Automatically pick a role? Send all?
|
|
94
75
|
}
|
|
@@ -101,27 +82,25 @@ _operations2.default.forEach(function (operation) {
|
|
|
101
82
|
} : {})]]
|
|
102
83
|
}, keys, callback);
|
|
103
84
|
};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
debug('Parsing operation "' + operationName + '" with', { args: args });
|
|
111
|
-
var options = operationParams.reduce(function (memo, param, i) {
|
|
85
|
+
steemBroadcast[operationName] = function steemBroadcast$specializedSend(wif, ...args) {
|
|
86
|
+
debug(`Parsing operation "${operationName}" with`, {
|
|
87
|
+
args
|
|
88
|
+
});
|
|
89
|
+
const options = operationParams.reduce((memo, param, i) => {
|
|
112
90
|
memo[param] = args[i]; // eslint-disable-line no-param-reassign
|
|
113
91
|
return memo;
|
|
114
92
|
}, {});
|
|
115
|
-
|
|
116
|
-
|
|
93
|
+
// Check if the last argument is a function (callback)
|
|
94
|
+
let callback = null;
|
|
95
|
+
if (args.length > operationParams.length && typeof args[operationParams.length] === 'function') {
|
|
96
|
+
callback = args[operationParams.length];
|
|
97
|
+
}
|
|
98
|
+
return steemBroadcast[`${operationName}With`](wif, options, callback);
|
|
117
99
|
};
|
|
118
100
|
});
|
|
101
|
+
const toString = obj => typeof obj === 'object' ? JSON.stringify(obj) : obj;
|
|
102
|
+
(0, _helpers.default)(steemBroadcast);
|
|
119
103
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
};
|
|
123
|
-
(0, _helpers2.default)(steemBroadcast);
|
|
124
|
-
|
|
125
|
-
_bluebird2.default.promisifyAll(steemBroadcast);
|
|
126
|
-
|
|
104
|
+
// For backwards compatibility, maintain the Async versions
|
|
105
|
+
_bluebird.default.promisifyAll(steemBroadcast);
|
|
127
106
|
exports = module.exports = steemBroadcast;
|
package/lib/browser.js
CHANGED
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
utils: utils
|
|
3
|
+
const api = require("./api");
|
|
4
|
+
const auth = require("./auth");
|
|
5
|
+
const memo = require("./auth/memo");
|
|
6
|
+
const broadcast = require("./broadcast");
|
|
7
|
+
const config = require("./config");
|
|
8
|
+
const formatter = require("./formatter")(api);
|
|
9
|
+
const utils = require("./utils");
|
|
10
|
+
const steem = {
|
|
11
|
+
api,
|
|
12
|
+
auth,
|
|
13
|
+
memo,
|
|
14
|
+
broadcast,
|
|
15
|
+
config,
|
|
16
|
+
formatter,
|
|
17
|
+
utils
|
|
19
18
|
};
|
|
20
|
-
|
|
21
19
|
if (typeof window !== "undefined") {
|
|
22
20
|
window.steem = steem;
|
|
23
21
|
}
|
|
24
|
-
|
|
25
22
|
if (typeof global !== "undefined") {
|
|
26
23
|
global.steem = steem;
|
|
27
24
|
}
|
|
28
|
-
|
|
29
25
|
exports = module.exports = steem;
|
package/lib/config.js
CHANGED
|
@@ -1,43 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
-
|
|
13
|
-
var defaultConfig = require('../config.json');
|
|
14
|
-
|
|
15
|
-
var Config = function () {
|
|
16
|
-
function Config(c) {
|
|
17
|
-
var _this = this;
|
|
18
|
-
|
|
19
|
-
_classCallCheck(this, Config);
|
|
20
|
-
|
|
21
|
-
(0, _each2.default)(c, function (value, key) {
|
|
22
|
-
_this[key] = value;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _each = _interopRequireDefault(require("lodash/each"));
|
|
4
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
5
|
+
const defaultConfig = require('../config.json');
|
|
6
|
+
class Config {
|
|
7
|
+
constructor(c) {
|
|
8
|
+
(0, _each.default)(c, (value, key) => {
|
|
9
|
+
this[key] = value;
|
|
23
10
|
});
|
|
24
11
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
key: 'set',
|
|
33
|
-
value: function set(k, v) {
|
|
34
|
-
this[k] = v;
|
|
35
|
-
}
|
|
36
|
-
}]);
|
|
37
|
-
|
|
38
|
-
return Config;
|
|
39
|
-
}();
|
|
40
|
-
|
|
12
|
+
get(k) {
|
|
13
|
+
return this[k];
|
|
14
|
+
}
|
|
15
|
+
set(k, v) {
|
|
16
|
+
this[k] = v;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
41
19
|
module.exports = new Config(defaultConfig);
|
|
42
20
|
if (typeof module.exports.Config !== 'undefined') {
|
|
43
21
|
throw new Error("default config.json file may not contain a property 'Config'");
|