From e47dbc12909a1b43f30a013c62a75e27bbd6ce84 Mon Sep 17 00:00:00 2001 From: aowheel Date: Tue, 1 Oct 2024 11:52:55 +0900 Subject: [PATCH 1/5] =?UTF-8?q?hats=20protocol=E3=81=AEmetadata=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E3=81=AE=E6=A9=9F=E8=83=BD=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/cli/package.json | 4 +++- pkgs/cli/src/commands/hats.ts | 18 ++++++++++++++++++ yarn.lock | 18 ++++++++++++++++-- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/pkgs/cli/package.json b/pkgs/cli/package.json index 4bfc65f..589382e 100644 --- a/pkgs/cli/package.json +++ b/pkgs/cli/package.json @@ -12,13 +12,15 @@ "hat:sample": "npx ts-node ./scripts/hat.ts" }, "dependencies": { + "@hatsprotocol/details-sdk": "^0.0.1", "@hatsprotocol/sdk-v1-core": "^0.10.0", "@hatsprotocol/sdk-v1-subgraph": "^1.0.0", "commander": "^12.1.0", "dotenv": "^16.4.5", "ts-node": "^10.9.2", "typescript": "^5.6.2", - "viem": "^2.21.15" + "viem": "^2.21.15", + "zod": "^3.23.8" }, "devDependencies": { "@types/commander": "^2.12.2", diff --git a/pkgs/cli/src/commands/hats.ts b/pkgs/cli/src/commands/hats.ts index 46b3c41..8505f93 100644 --- a/pkgs/cli/src/commands/hats.ts +++ b/pkgs/cli/src/commands/hats.ts @@ -4,6 +4,7 @@ import { getWearerInfo, getWearersInfo, } from "../modules/hatsProtocol"; +import { HatsDetailsClient } from "@hatsprotocol/details-sdk"; export const hatsCommands = new Command(); @@ -61,3 +62,20 @@ hatsCommands console.log(wearer); }); + +/** + * Hatのメタデータをipfs上にアップロードするコマンド + */ +hatsCommands + .command("upload") + .description("Upload the hat metadata on ipfs.") + .option("--metadata ", "Hat Metadata") + .action(({ metadata }) => { + const hatsDetailsClient = new HatsDetailsClient({ + provider: "pinata", + pinata: { + pinningKey: process.env.PINATA_JWT as string + } + }); + console.log(hatsDetailsClient); + }) \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 125585a..345926b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -451,6 +451,15 @@ resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.2.0.tgz#5f3d96ec6b2354ad6d8a28bf216a1d97b5426861" integrity sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ== +"@hatsprotocol/details-sdk@^0.0.1": + version "0.0.1" + resolved "https://registry.yarnpkg.com/@hatsprotocol/details-sdk/-/details-sdk-0.0.1.tgz#fb62c74945f9345527284daf83d3fbe54f4d52e2" + integrity sha512-1vluiU7QTCSV7VTpBg/M1RkcQ2+S3q0rKvApOwuyCp+q0Ts5tBXSTUuhhObGlzpBNs75iSc19B8FO0iJF4BJ7g== + dependencies: + axios "^1.7.3" + url-join "^5.0.0" + zod "^3.21.4" + "@hatsprotocol/sdk-v1-core@^0.10.0": version "0.10.0" resolved "https://registry.yarnpkg.com/@hatsprotocol/sdk-v1-core/-/sdk-v1-core-0.10.0.tgz#64a906e680b851852756f11d64dca9af60949297" @@ -1616,7 +1625,7 @@ axe-core@^4.10.0: resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.10.0.tgz#d9e56ab0147278272739a000880196cdfe113b59" integrity sha512-Mr2ZakwQ7XUAjp7pAwQWRhhK8mQQ6JAaNWSjmjxil0R8BPioMtQsTLOolGYkji1rcL++3dCqZA3zWqpT+9Ew6g== -axios@^1.5.1: +axios@^1.5.1, axios@^1.7.3: version "1.7.7" resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.7.tgz#2f554296f9892a72ac8d8e4c5b79c14a91d0a47f" integrity sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q== @@ -5817,6 +5826,11 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" +url-join@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/url-join/-/url-join-5.0.0.tgz#c2f1e5cbd95fa91082a93b58a1f42fecb4bdbcf1" + integrity sha512-n2huDr9h9yzd6exQVnH/jU5mr+Pfx08LRXXZhkLLetAMESRj+anQsTAh940iMrIetKAmry9coFuZQ2jY8/p3WA== + utf8@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/utf8/-/utf8-3.0.0.tgz#f052eed1364d696e769ef058b183df88c87f69d1" @@ -6063,7 +6077,7 @@ yocto-queue@^0.1.0: resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== -zod@^3.22.4: +zod@^3.21.4, zod@^3.22.4, zod@^3.23.8: version "3.23.8" resolved "https://registry.yarnpkg.com/zod/-/zod-3.23.8.tgz#e37b957b5d52079769fb8097099b592f0ef4067d" integrity sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g== From 8b23938852174d58952acff367917c64436f5004 Mon Sep 17 00:00:00 2001 From: aowheel Date: Thu, 3 Oct 2024 15:31:29 +0900 Subject: [PATCH 2/5] =?UTF-8?q?cli=E3=81=8B=E3=82=89hats=20protocol?= =?UTF-8?q?=E3=81=AB=E6=B2=BF=E3=81=A3=E3=81=9Fmetadata=E3=82=92=E4=BD=9C?= =?UTF-8?q?=E6=88=90=E3=81=97=E3=80=81pinata=E3=81=AEsdk=E3=81=A7ipfs?= =?UTF-8?q?=E3=81=AB=E3=82=A2=E3=83=83=E3=83=97=E3=83=AD=E3=83=BC=E3=83=89?= =?UTF-8?q?=E3=81=97=E3=81=A6cid=E3=82=92=E8=BF=94=E3=81=99=E6=A9=9F?= =?UTF-8?q?=E8=83=BD=E3=82=92=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/cli/package.json | 2 +- pkgs/cli/src/commands/hats.ts | 81 +++++++++++-- yarn.lock | 219 +++++++++++++++++++++++++++++++--- 3 files changed, 276 insertions(+), 26 deletions(-) diff --git a/pkgs/cli/package.json b/pkgs/cli/package.json index 589382e..e318d47 100644 --- a/pkgs/cli/package.json +++ b/pkgs/cli/package.json @@ -12,11 +12,11 @@ "hat:sample": "npx ts-node ./scripts/hat.ts" }, "dependencies": { - "@hatsprotocol/details-sdk": "^0.0.1", "@hatsprotocol/sdk-v1-core": "^0.10.0", "@hatsprotocol/sdk-v1-subgraph": "^1.0.0", "commander": "^12.1.0", "dotenv": "^16.4.5", + "pinata-web3": "^0.5.0", "ts-node": "^10.9.2", "typescript": "^5.6.2", "viem": "^2.21.15", diff --git a/pkgs/cli/src/commands/hats.ts b/pkgs/cli/src/commands/hats.ts index 8505f93..1066d87 100644 --- a/pkgs/cli/src/commands/hats.ts +++ b/pkgs/cli/src/commands/hats.ts @@ -4,7 +4,10 @@ import { getWearerInfo, getWearersInfo, } from "../modules/hatsProtocol"; -import { HatsDetailsClient } from "@hatsprotocol/details-sdk"; +import { PinataSDK } from "pinata-web3"; +import { config } from "dotenv"; + +config(); export const hatsCommands = new Command(); @@ -66,16 +69,76 @@ hatsCommands /** * Hatのメタデータをipfs上にアップロードするコマンド */ +interface Responsibility { + label: string; + description?: string; + link?: string; +} +interface Eligibility { + manual: boolean; + criteria: string[]; +} +interface Toggle { + manual: boolean; + criteria: string[]; +} hatsCommands .command("upload") .description("Upload the hat metadata on ipfs.") - .option("--metadata ", "Hat Metadata") - .action(({ metadata }) => { - const hatsDetailsClient = new HatsDetailsClient({ - provider: "pinata", - pinata: { - pinningKey: process.env.PINATA_JWT as string + .requiredOption("-n, --name ", "Hat Name") + .option("-d, --description ", "Hat Details") + .option( + "-r, --responsibility