|
@@ -278,9 +278,7 @@ class BankClient {
|
|
|
}
|
|
}
|
|
|
getContentItemByHash(hash) {
|
|
getContentItemByHash(hash) {
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
- if (hash.startsWith('/ipfs/')) {
|
|
|
|
|
- hash = hash.split('/').pop();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ hash = this.parseItemHash(hash).hash;
|
|
|
const contentParams = (yield this.webClient.requestJSON({
|
|
const contentParams = (yield this.webClient.requestJSON({
|
|
|
method: 'get',
|
|
method: 'get',
|
|
|
url: this.ipfsUrlBase + '/ipfs/' + hash + '/content.json'
|
|
url: this.ipfsUrlBase + '/ipfs/' + hash + '/content.json'
|
|
@@ -292,9 +290,10 @@ class BankClient {
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
const itemHashes = commaList.split(',').filter(x => x.trim() !== '');
|
|
const itemHashes = commaList.split(',').filter(x => x.trim() !== '');
|
|
|
const items = yield Promise.all(itemHashes.map(itemId => {
|
|
const items = yield Promise.all(itemHashes.map(itemId => {
|
|
|
|
|
+ const itemHash = this.parseItemHash(itemId).hash;
|
|
|
return this.webClient.requestJSON({
|
|
return this.webClient.requestJSON({
|
|
|
method: 'get',
|
|
method: 'get',
|
|
|
- url: this.ipfsUrlBase + '/ipfs/' + itemId,
|
|
|
|
|
|
|
+ url: this.ipfsUrlBase + '/ipfs/' + itemHash,
|
|
|
});
|
|
});
|
|
|
}));
|
|
}));
|
|
|
for (const item of items) {
|
|
for (const item of items) {
|
|
@@ -303,6 +302,27 @@ class BankClient {
|
|
|
return items;
|
|
return items;
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+ parseItemHash(itemHash) {
|
|
|
|
|
+ let type = null;
|
|
|
|
|
+ let timestamp = null;
|
|
|
|
|
+ let hash = null;
|
|
|
|
|
+ if (itemHash.startsWith('/ipfs/')) {
|
|
|
|
|
+ itemHash = itemHash.substring(6);
|
|
|
|
|
+ }
|
|
|
|
|
+ const matched = itemHash.match(/^([0-9]*)_(..)_(.*)$/);
|
|
|
|
|
+ if (matched) {
|
|
|
|
|
+ timestamp = matched[1];
|
|
|
|
|
+ type = matched[2];
|
|
|
|
|
+ hash = matched[3];
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!type) {
|
|
|
|
|
+ type = 'CO';
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!hash) {
|
|
|
|
|
+ hash = itemHash;
|
|
|
|
|
+ }
|
|
|
|
|
+ return { type, timestamp, hash };
|
|
|
|
|
+ }
|
|
|
connectWebsocket(peerAddr, topic, connectCallback, messageCallback) {
|
|
connectWebsocket(peerAddr, topic, connectCallback, messageCallback) {
|
|
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
|
const nonce = yield this.getNonce();
|
|
const nonce = yield this.getNonce();
|