Skip to content

Commit

Permalink
Merge pull request #52 from kleros/feat/only-positive-results
Browse files Browse the repository at this point in the history
feat: only display positive results
  • Loading branch information
greenlucid authored Sep 19, 2023
2 parents 877b6b6 + dc9c331 commit b1c38df
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 27 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kleros/scout",
"version": "1.1.0",
"version": "1.2.0",
"description": "",
"homepage": "https://contract-insight-snap.kleros.builders/",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kleros/scout-snap",
"version": "1.1.0",
"version": "1.2.0",
"description": "A Metamask Snap that retrieves contract metadata from the Kleros Curate registries",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"version": "1.1.0",
"version": "1.2.0",
"description": "A Snap that retrieves contract metadata from the Kleros Curate registries.",
"proposedName": "Kleros Scout",
"repository": {
"type": "git",
"url": "https://github.com/kleros/scout-snap.git"
},
"source": {
"shasum": "z/7MIS7rM2gG7vjtY54Sv3pnvzItMnhooR22Svk6QkI=",
"shasum": "GQiH7jqEvK8jElnpB2j65lKt9bKIWJoQAudcKfX0Hvs=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
59 changes: 36 additions & 23 deletions packages/snap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ const getInsights = async (
return ['**Error:** Could not connect to the server.'];
}

// If insight search has no result in a category, the result is omitted.
const insights: string[] = [];
if (result.addressTag) {
// key2 is projectName, which is optional. No project name === "", which is falsy.
Expand All @@ -184,38 +185,29 @@ const getInsights = async (
const contractTag = result.addressTag.publicName;
insights.push(`**Project:** ${projectNameLabel}`);
insights.push(`**Contract Tag:** ${contractTag}`);
} else {
// Contract was not tagged in Address Tags. Let the user know, and provide a link to tag it.
// Note: current @metamask/snaps-ui does not allow markdown links, so no links in this version.
// todo: when links are a feature, turn them into [Tag me](https://curate.kleros.io/...), deeplink:
// const uri = new URL('https://curate.kleros.io/tcr/100/0x66260c69d03837016d88c9877e61e08ef74c59f2');
// uri.searchParams.append('action', 'submit');
// uri.searchParams.append('Contract Address', caipAddress);
// uri.toString();
const addressNotFound = `**Contract Tag:** _Not Found_`;
insights.push(addressNotFound);
}

const domainLabel = result.contractDomain
? `**Domain:** _${domain}_ is **verified** for this contract`
: // todo: when links are a feature, deeplink:
// const uri = new URL('https://curate.kleros.io/tcr/100/0x957A53A994860BE4750810131d9c876b2f52d6E1');
// uri.searchParams.append('action', 'submit');
// uri.searchParams.append('Contract Address', caipAddress);
// uri.searchParams.append('Domain Name', domain);
// uri.toString();
`**Domain:** _${domain}_ is **NOT verified** for this contract
`;
insights.push(domainLabel);

// Token information is only shown if confirmed to be a token.
if (result.contractDomain) {
const domainLabel = `**Domain:** _${domain}_ is **verified** for this contract`;
insights.push(domainLabel);
}

if (result.token) {
insights.push(
// etherscan-like token syntax
`**Token:** ${result.token.name} (${result.token.symbol})`,
);
}

if (insights.length === 0) {
insights.push(
'No insights available for this contract. Interact at your own risk.',
);
insights.push(
'Do you know this contract? Submit insights on curate.kleros.io in Gnosis Chain and earn rewards!',
);
}

return insights;
};

Expand Down Expand Up @@ -245,3 +237,24 @@ export const onTransaction: OnTransactionHandler = async ({
]),
};
};

/*
Note: current @metamask/snaps-ui does not allow markdown links, so no links in this version.
todo: when links are a feature, create links to direct user towards submitting.
or, to direct user towards seeing the submissions in case they believe they're wrong?
add contract tags link:
const uri = new URL('https://curate.kleros.io/tcr/100/0x66260c69d03837016d88c9877e61e08ef74c59f2');
uri.searchParams.append('action', 'submit');
uri.searchParams.append('Contract Address', caipAddress);
uri.toString();
add contract domain link:
const uri = new URL('https://curate.kleros.io/tcr/100/0x957A53A994860BE4750810131d9c876b2f52d6E1');
uri.searchParams.append('action', 'submit');
uri.searchParams.append('Contract Address', caipAddress);
uri.searchParams.append('Domain Name', domain);
uri.toString();
*/

0 comments on commit b1c38df

Please sign in to comment.