fix resolution of claims

This commit is contained in:
Niko Storni 2019-09-23 23:00:58 +02:00
parent 6ae0984edf
commit 39ea483f08
2 changed files with 33 additions and 5 deletions

View file

@ -257,7 +257,7 @@ const handleExamples = debounce(event => {
switch(data.action) { switch(data.action) {
case "choose claim": case "choose claim":
fetchMetadata(exampleNumber, data.claimId); fetchMetadata(exampleNumber, `${data.name}#${data.claimId}`);
if (document.querySelector(".playground-navigation__example:nth-child(3)").classList.contains("active")) if (document.querySelector(".playground-navigation__example:nth-child(3)").classList.contains("active"))
document.getElementById("fetch-claim-uri").value = event.dataset.name + "#" + event.dataset.claimId; document.getElementById("fetch-claim-uri").value = event.dataset.name + "#" + event.dataset.claimId;

View file

@ -13,6 +13,8 @@ import stringifyObject from "stringify-object";
import messageSlack from "./slack"; import messageSlack from "./slack";
import publishMeme from "./publish-meme"; import publishMeme from "./publish-meme";
import lbrytvAPI from "~helper/lbrytv-sdk";
import randomString from "./random-string"; import randomString from "./random-string";
import { send } from "~socket"; import { send } from "~socket";
import uploadImage from "./upload-image"; import uploadImage from "./upload-image";
@ -76,10 +78,10 @@ export default async(data, socket) => {
switch(true) { switch(resolveMethod) {
// T I P // T I P
// E X A M P L E // E X A M P L E
case resolveMethod === "support_create": case "support_create":
if (!approvedContentIdsForTipping.includes(claimAddress)) { if (!approvedContentIdsForTipping.includes(claimAddress)) {
return send(socket, { return send(socket, {
example: data.example, example: data.example,
@ -103,7 +105,7 @@ export default async(data, socket) => {
// P U B L I S H // P U B L I S H
// E X A M P L E // E X A M P L E
case resolveMethod === "publish": case "publish":
apiRequestMethod = "PUT"; apiRequestMethod = "PUT";
// Required for publishing // Required for publishing
@ -194,10 +196,36 @@ export default async(data, socket) => {
// R E S O L V E // R E S O L V E
// E X A M P L E // E X A M P L E
case resolveMethod === "resolve": case "resolve":
apiRequestMethod = "GET"; apiRequestMethod = "GET";
body.uri = claimAddress; body.uri = claimAddress;
try {
let resolveResponse = await lbrytvAPI.resolve([claimAddress]);
if (socket) {
const renderedCode = prism.highlight(
stringifyObject(resolveResponse, { indent: " ", singleQuotes: false }),
prism.languages.json,
"json"
);
return send(socket, {
example: data.example,
html: raw(`
<h3>Response</h3>
${explorerNotice}
<pre><code class="language-json">${renderedCode}</code></pre>
`),
message: "show result",
selector: `#example${data.example}-result`
});
}
} catch(error) {
messageSlack({
message: "```" + error + "```",
title: "DAEMON ERROR: resolve"
});
}
break; break;