@steemit/steem-js 1.0.18 → 1.0.19
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/dist/auth/account-update-chain.d.ts +38 -8
- package/dist/auth/index.d.ts +1 -1
- package/dist/browser.esm.js +60 -40
- package/dist/browser.esm.js.map +1 -1
- package/dist/index.cjs +60 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +60 -40
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +60 -40
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types.d.ts +4 -0
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -24987,11 +24987,25 @@
|
|
|
24987
24987
|
}
|
|
24988
24988
|
|
|
24989
24989
|
/**
|
|
24990
|
-
* Chain-safe JSON normalization for account_update operations.
|
|
24991
|
-
*
|
|
24992
|
-
*
|
|
24990
|
+
* Chain-safe JSON normalization for `account_update` operations.
|
|
24991
|
+
*
|
|
24992
|
+
* Protocol types (steem/libraries/protocol):
|
|
24993
|
+
* - `authority` — weight_threshold (uint32), account_auths / key_auths (fc::flat_map)
|
|
24994
|
+
* - `account_update_operation` — account, optional owner/active/posting, memo_key, json_metadata (string)
|
|
24995
|
+
*
|
|
24996
|
+
* JSON-RPC (`condenser_api.broadcast_transaction` → fc::from_variant):
|
|
24997
|
+
* - `authority` is a variant_object, not a bare key_auths array.
|
|
24998
|
+
* - `fc::flat_map` serializes as an array of [key, weight] pairs (see fc/container/flat.hpp),
|
|
24999
|
+
* not a JSON object `{ "key": weight }` — object maps cause bad_cast_exception.
|
|
25000
|
+
* - `json_metadata` must be a string (protocol `string`), not a parsed JSON object.
|
|
25001
|
+
*
|
|
25002
|
+
* Binary signing (transaction digest) uses the same logical fields; the serializer packs
|
|
25003
|
+
* flat_maps as sorted on-wire maps (see serializeAuthority in serializer/transaction.ts).
|
|
25004
|
+
*/
|
|
25005
|
+
/**
|
|
25006
|
+
* Coerce `json_metadata` to protocol `string` (FC string field).
|
|
25007
|
+
* Node rejects object/array variants with bad_cast when broadcasting.
|
|
24993
25008
|
*/
|
|
24994
|
-
/** Steem broadcast JSON requires json_metadata to be a string (not object/array). */
|
|
24995
25009
|
function normalizeChainJsonMetadata(value) {
|
|
24996
25010
|
if (typeof value === 'string')
|
|
24997
25011
|
return value;
|
|
@@ -25003,6 +25017,10 @@
|
|
|
25003
25017
|
return JSON.stringify(value);
|
|
25004
25018
|
return String(value);
|
|
25005
25019
|
}
|
|
25020
|
+
/**
|
|
25021
|
+
* Parse fc::flat_map JSON (pair array) or mistaken object-map input into pair arrays.
|
|
25022
|
+
* Broadcast output always uses pair arrays per fc::from_variant(flat_map).
|
|
25023
|
+
*/
|
|
25006
25024
|
function toAuthPairs(raw) {
|
|
25007
25025
|
if (Array.isArray(raw)) {
|
|
25008
25026
|
return raw
|
|
@@ -25031,7 +25049,7 @@
|
|
|
25031
25049
|
}
|
|
25032
25050
|
return [];
|
|
25033
25051
|
}
|
|
25034
|
-
/** Normalize API authority data (
|
|
25052
|
+
/** Normalize API authority data (get_accounts-style input; accepts pair arrays or object maps). */
|
|
25035
25053
|
function normalizeAuthoritySource(source) {
|
|
25036
25054
|
if (Array.isArray(source) || !source || typeof source !== 'object') {
|
|
25037
25055
|
return { weight_threshold: 1, account_auths: [], key_auths: [] };
|
|
@@ -25057,7 +25075,10 @@
|
|
|
25057
25075
|
}
|
|
25058
25076
|
return { weight_threshold, account_auths, key_auths };
|
|
25059
25077
|
}
|
|
25060
|
-
/**
|
|
25078
|
+
/**
|
|
25079
|
+
* Coerce account_update operation payload to protocol JSON shape for signing and broadcast.
|
|
25080
|
+
* Emits fc::flat_map fields as pair arrays, not object maps.
|
|
25081
|
+
*/
|
|
25061
25082
|
function sanitizeAccountUpdatePayload(payload) {
|
|
25062
25083
|
return {
|
|
25063
25084
|
account: String(payload.account || ''),
|
|
@@ -25469,8 +25490,9 @@
|
|
|
25469
25490
|
writeString(bb, String(dataObj.json_metadata || ''));
|
|
25470
25491
|
}
|
|
25471
25492
|
/**
|
|
25472
|
-
* Serialize
|
|
25473
|
-
*
|
|
25493
|
+
* Serialize account_update_operation (steem_operations.hpp).
|
|
25494
|
+
* JSON fields: account, owner/active/posting (authority objects), memo_key, json_metadata (string).
|
|
25495
|
+
* Optional authorities use a presence byte before serializeAuthority.
|
|
25474
25496
|
*/
|
|
25475
25497
|
function serializeAccountUpdate(bb, data) {
|
|
25476
25498
|
const dataObj = data;
|
|
@@ -26137,7 +26159,26 @@
|
|
|
26137
26159
|
writeString(bb, String(dataObj.json || '{}'));
|
|
26138
26160
|
}
|
|
26139
26161
|
/**
|
|
26140
|
-
*
|
|
26162
|
+
* Read authority map fields for binary packing (on-wire sorted flat_map).
|
|
26163
|
+
* JSON-RPC uses fc::flat_map → array of [key, weight] pairs; object maps are accepted
|
|
26164
|
+
* here only so callers that forgot to normalize still sign the intended keys.
|
|
26165
|
+
*/
|
|
26166
|
+
function authorityMapEntries(raw) {
|
|
26167
|
+
if (Array.isArray(raw)) {
|
|
26168
|
+
return raw
|
|
26169
|
+
.filter((entry) => Array.isArray(entry) && entry.length >= 2)
|
|
26170
|
+
.map(([key, weight]) => [String(key), Number(weight)])
|
|
26171
|
+
.filter(([, weight]) => Number.isFinite(weight));
|
|
26172
|
+
}
|
|
26173
|
+
if (raw && typeof raw === 'object') {
|
|
26174
|
+
return Object.entries(raw)
|
|
26175
|
+
.map(([key, weight]) => [String(key), Number(weight)])
|
|
26176
|
+
.filter(([, weight]) => Number.isFinite(weight));
|
|
26177
|
+
}
|
|
26178
|
+
return [];
|
|
26179
|
+
}
|
|
26180
|
+
/**
|
|
26181
|
+
* Serialize steem::protocol::authority (weight_threshold + sorted account/key flat_maps).
|
|
26141
26182
|
*/
|
|
26142
26183
|
function serializeAuthority(bb, auth) {
|
|
26143
26184
|
if (Array.isArray(auth)) {
|
|
@@ -26149,40 +26190,19 @@
|
|
|
26149
26190
|
const authObj = auth;
|
|
26150
26191
|
bb.writeUint32(authObj.weight_threshold || 1);
|
|
26151
26192
|
// Account auths (map<string, uint16>)
|
|
26152
|
-
const accountAuths = (
|
|
26153
|
-
// Maps in Steem serialization are sorted by key
|
|
26154
|
-
const accountAuthsArray = accountAuths;
|
|
26155
|
-
accountAuthsArray.sort((a, b) => {
|
|
26156
|
-
const aKey = Array.isArray(a) && a[0] ? String(a[0]) : '';
|
|
26157
|
-
const bKey = Array.isArray(b) && b[0] ? String(b[0]) : '';
|
|
26158
|
-
return aKey.localeCompare(bKey);
|
|
26159
|
-
});
|
|
26193
|
+
const accountAuths = authorityMapEntries(authObj.account_auths).sort((a, b) => a[0].localeCompare(b[0]));
|
|
26160
26194
|
bb.writeVarint32(accountAuths.length);
|
|
26161
|
-
for (const
|
|
26162
|
-
|
|
26163
|
-
|
|
26164
|
-
bb.writeUint16(authEntry[1]);
|
|
26165
|
-
}
|
|
26195
|
+
for (const [account, weight] of accountAuths) {
|
|
26196
|
+
writeString(bb, account);
|
|
26197
|
+
bb.writeUint16(weight);
|
|
26166
26198
|
}
|
|
26167
26199
|
// Key auths (map<public_key, uint16>)
|
|
26168
|
-
const keyAuths = (
|
|
26169
|
-
// Maps in Steem serialization are sorted by key (public key string)
|
|
26170
|
-
// But serialized as bytes. Usually sorting by string representation of public key works.
|
|
26171
|
-
const keyAuthsArray = keyAuths;
|
|
26172
|
-
keyAuthsArray.sort((a, b) => {
|
|
26173
|
-
const aKey = Array.isArray(a) && a[0] ? String(a[0]) : '';
|
|
26174
|
-
const bKey = Array.isArray(b) && b[0] ? String(b[0]) : '';
|
|
26175
|
-
return aKey.localeCompare(bKey);
|
|
26176
|
-
});
|
|
26200
|
+
const keyAuths = authorityMapEntries(authObj.key_auths).sort((a, b) => a[0].localeCompare(b[0]));
|
|
26177
26201
|
bb.writeVarint32(keyAuths.length);
|
|
26178
|
-
for (const
|
|
26179
|
-
|
|
26180
|
-
|
|
26181
|
-
|
|
26182
|
-
const pubKey = PublicKey.fromStringOrThrow(keyStr);
|
|
26183
|
-
bb.append(pubKey.toBuffer());
|
|
26184
|
-
bb.writeUint16(weight);
|
|
26185
|
-
}
|
|
26202
|
+
for (const [keyStr, weight] of keyAuths) {
|
|
26203
|
+
const pubKey = PublicKey.fromStringOrThrow(keyStr);
|
|
26204
|
+
bb.append(pubKey.toBuffer());
|
|
26205
|
+
bb.writeUint16(weight);
|
|
26186
26206
|
}
|
|
26187
26207
|
}
|
|
26188
26208
|
/**
|
|
@@ -29399,7 +29419,7 @@
|
|
|
29399
29419
|
operations,
|
|
29400
29420
|
utils: utils$n,
|
|
29401
29421
|
...crypto$1,
|
|
29402
|
-
version: '1.0.
|
|
29422
|
+
version: '1.0.19',
|
|
29403
29423
|
config: {
|
|
29404
29424
|
set: (options) => {
|
|
29405
29425
|
// If nodes is provided, extract the first node as url for API
|