@eluvio/elv-client-js 4.0.81 → 4.0.82
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/ElvClient-min.js +2 -2
- package/dist/ElvClient-node-min.js +2 -2
- package/dist/ElvFrameClient-min.js +5 -5
- package/dist/ElvWalletClient-min.js +9 -9
- package/dist/ElvWalletClient-node-min.js +2 -2
- package/dist/src/client/ContentAccess.js +819 -755
- package/dist/src/client/ContentManagement.js +34 -2
- package/package.json +1 -1
- package/src/client/ContentAccess.js +37 -1
- package/src/client/ContentManagement.js +16 -1
|
@@ -1711,7 +1711,7 @@ exports.FinalizeContentObject = /*#__PURE__*/function () {
|
|
|
1711
1711
|
*/
|
|
1712
1712
|
exports.PublishContentVersion = /*#__PURE__*/function () {
|
|
1713
1713
|
var _ref38 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref37) {
|
|
1714
|
-
var objectId, versionHash, _ref37$awaitCommitCon, awaitCommitConfirmation, commit, abi, fromBlock, objectHash, pendingHash, pollingInterval, events, confirmEvent;
|
|
1714
|
+
var objectId, versionHash, _ref37$awaitCommitCon, awaitCommitConfirmation, commit, abi, fromBlock, objectHash, pendingHash, pollingInterval, events, confirmEvent, _pollingInterval, tries, h;
|
|
1715
1715
|
return _regeneratorRuntime.wrap(function _callee21$(_context21) {
|
|
1716
1716
|
while (1) switch (_context21.prev = _context21.next) {
|
|
1717
1717
|
case 0:
|
|
@@ -1793,12 +1793,44 @@ exports.PublishContentVersion = /*#__PURE__*/function () {
|
|
|
1793
1793
|
break;
|
|
1794
1794
|
}
|
|
1795
1795
|
// Found confirmation
|
|
1796
|
-
this.Log("Commit confirmed: ".concat(objectHash));
|
|
1796
|
+
this.Log("Commit confirmed on chain: ".concat(objectHash));
|
|
1797
1797
|
return _context21.abrupt("break", 34);
|
|
1798
1798
|
case 32:
|
|
1799
1799
|
_context21.next = 22;
|
|
1800
1800
|
break;
|
|
1801
1801
|
case 34:
|
|
1802
|
+
if (!awaitCommitConfirmation) {
|
|
1803
|
+
_context21.next = 48;
|
|
1804
|
+
break;
|
|
1805
|
+
}
|
|
1806
|
+
_pollingInterval = 500; // ms
|
|
1807
|
+
tries = 20;
|
|
1808
|
+
case 37:
|
|
1809
|
+
if (!(tries > 0)) {
|
|
1810
|
+
_context21.next = 48;
|
|
1811
|
+
break;
|
|
1812
|
+
}
|
|
1813
|
+
_context21.next = 40;
|
|
1814
|
+
return this.LatestVersionHashV2({
|
|
1815
|
+
objectId: objectId
|
|
1816
|
+
});
|
|
1817
|
+
case 40:
|
|
1818
|
+
h = _context21.sent;
|
|
1819
|
+
if (!(h == versionHash)) {
|
|
1820
|
+
_context21.next = 44;
|
|
1821
|
+
break;
|
|
1822
|
+
}
|
|
1823
|
+
this.Log("Commit confirmed on fabric node: ".concat(versionHash));
|
|
1824
|
+
return _context21.abrupt("break", 48);
|
|
1825
|
+
case 44:
|
|
1826
|
+
_context21.next = 46;
|
|
1827
|
+
return new Promise(function (resolve) {
|
|
1828
|
+
return setTimeout(resolve, _pollingInterval);
|
|
1829
|
+
});
|
|
1830
|
+
case 46:
|
|
1831
|
+
_context21.next = 37;
|
|
1832
|
+
break;
|
|
1833
|
+
case 48:
|
|
1802
1834
|
case "end":
|
|
1803
1835
|
return _context21.stop();
|
|
1804
1836
|
}
|
package/package.json
CHANGED
|
@@ -1075,7 +1075,7 @@ exports.ContentObjectVersions = async function({libraryId, objectId}) {
|
|
|
1075
1075
|
};
|
|
1076
1076
|
|
|
1077
1077
|
/**
|
|
1078
|
-
* Retrieve the version hash of the latest version of the specified object
|
|
1078
|
+
* Retrieve the version hash of the latest version of the specified object from chain
|
|
1079
1079
|
*
|
|
1080
1080
|
* @methodGroup Content Objects
|
|
1081
1081
|
* @namedParams
|
|
@@ -1122,6 +1122,42 @@ exports.LatestVersionHash = async function({objectId, versionHash}) {
|
|
|
1122
1122
|
return latestHash;
|
|
1123
1123
|
};
|
|
1124
1124
|
|
|
1125
|
+
/**
|
|
1126
|
+
* Retrieve the version hash of the latest version of the specified object via fabric API.
|
|
1127
|
+
* Requires authorization.
|
|
1128
|
+
*
|
|
1129
|
+
* @methodGroup Content Objects
|
|
1130
|
+
* @namedParams
|
|
1131
|
+
* @param {string=} objectId - ID of the object
|
|
1132
|
+
* @param {string=} versionHash - Version hash of the object
|
|
1133
|
+
*
|
|
1134
|
+
* @returns {Promise<string>} - The latest version hash of the object
|
|
1135
|
+
*/
|
|
1136
|
+
exports.LatestVersionHashV2 = async function({objectId, versionHash}) {
|
|
1137
|
+
if(versionHash) { objectId = this.utils.DecodeVersionHash(versionHash).objectId; }
|
|
1138
|
+
|
|
1139
|
+
ValidateObject(objectId);
|
|
1140
|
+
|
|
1141
|
+
let latestHash;
|
|
1142
|
+
try {
|
|
1143
|
+
let path = UrlJoin("q", objectId);
|
|
1144
|
+
|
|
1145
|
+
let q = await this.utils.ResponseToJson(
|
|
1146
|
+
this.HttpClient.Request({
|
|
1147
|
+
headers: await this.authClient.AuthorizationHeader({objectId}),
|
|
1148
|
+
method: "GET",
|
|
1149
|
+
path: path
|
|
1150
|
+
})
|
|
1151
|
+
);
|
|
1152
|
+
latestHash = q.hash;
|
|
1153
|
+
|
|
1154
|
+
} catch(error) {
|
|
1155
|
+
console.log("ERROR", error);
|
|
1156
|
+
throw Error(`Unable to determine latest version hash for ${versionHash || objectId}`);
|
|
1157
|
+
}
|
|
1158
|
+
return latestHash;
|
|
1159
|
+
};
|
|
1160
|
+
|
|
1125
1161
|
/* URL Methods */
|
|
1126
1162
|
|
|
1127
1163
|
/**
|
|
@@ -1044,11 +1044,26 @@ exports.PublishContentVersion = async function({objectId, versionHash, awaitComm
|
|
|
1044
1044
|
|
|
1045
1045
|
if(confirmEvent) {
|
|
1046
1046
|
// Found confirmation
|
|
1047
|
-
this.Log(`Commit confirmed: ${objectHash}`);
|
|
1047
|
+
this.Log(`Commit confirmed on chain: ${objectHash}`);
|
|
1048
1048
|
break;
|
|
1049
1049
|
}
|
|
1050
1050
|
}
|
|
1051
1051
|
}
|
|
1052
|
+
|
|
1053
|
+
// APIv2 ensure the fabric API returns the correct hash
|
|
1054
|
+
if(awaitCommitConfirmation) {
|
|
1055
|
+
const pollingInterval = 500; // ms
|
|
1056
|
+
let tries = 20;
|
|
1057
|
+
while (tries > 0) {
|
|
1058
|
+
const h = await this.LatestVersionHashV2({objectId});
|
|
1059
|
+
if (h == versionHash) {
|
|
1060
|
+
this.Log(`Commit confirmed on fabric node: ${versionHash}`);
|
|
1061
|
+
break;
|
|
1062
|
+
}
|
|
1063
|
+
await new Promise(resolve => setTimeout(resolve, pollingInterval));
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1052
1067
|
};
|
|
1053
1068
|
|
|
1054
1069
|
/**
|