From 547746302e11499e075889da1624d40da6872a1d Mon Sep 17 00:00:00 2001 From: cyhhao Date: Fri, 24 Feb 2023 18:32:24 +0800 Subject: [PATCH] fix ns contract call bug --- src/common/git3-protocol.ts | 4 ++-- src/git3/index.ts | 2 +- src/storage/testit.ts | 26 -------------------------- src/storage/testnft.ts | 23 ----------------------- 4 files changed, 3 insertions(+), 52 deletions(-) delete mode 100644 src/storage/testit.ts delete mode 100644 src/storage/testnft.ts diff --git a/src/common/git3-protocol.ts b/src/common/git3-protocol.ts index 4a45914..54f31a5 100644 --- a/src/common/git3-protocol.ts +++ b/src/common/git3-protocol.ts @@ -48,7 +48,7 @@ export async function parseGit3URI( } else { ;[nsName, nsDomain] = url.hostname.split(".") ns = nameServices[nsDomain] - if (!ns) throw new Error("invalid name service") + if (!ns) throw new Error(`invalid name service ${nsDomain}`) chainId = chainId || ns.chainId // Todo: temporary resolve name service @@ -58,7 +58,7 @@ export async function parseGit3URI( resolverAddress, abis.NameService ) - hubAddress = await nsContract.NameHub([nsName, nsDomain].join(".")) + hubAddress = await nsContract.nameHub([nsName, nsDomain].join(".")) if (hubAddress == "0x0000000000000000000000000000000000000000") throw new Error(`${nsName} not found`) } diff --git a/src/git3/index.ts b/src/git3/index.ts index e1def78..9ced383 100644 --- a/src/git3/index.ts +++ b/src/git3/index.ts @@ -137,7 +137,7 @@ program program .command("create") - .argument("", "ex: default@git3.w3q/repo_name") + .argument("", "ex: git3.w3q/repo_name") .description("create a new repo") .action(async (uri) => { if (!uri.startsWith("git3://")) { diff --git a/src/storage/testit.ts b/src/storage/testit.ts deleted file mode 100644 index 2426f21..0000000 --- a/src/storage/testit.ts +++ /dev/null @@ -1,26 +0,0 @@ -import axios from "axios" -import FormData from "form-data" - -async function main() { - let auth = - "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJkaWQ6ZXRocjoweGFEQTdCOWFlQTdGNTc2ZDI5NzM0ZWUxY0Q2ODVFMzc2OWNCM2QwRDEiLCJpc3MiOiJuZnQtc3RvcmFnZSIsImlhdCI6MTY3NTQ5NDYwMDkzMiwibmFtZSI6ImZ2bS1oYWNrc29uIn0.YBqfsj_LTZSJPKc0OH586avnQNqove_Htzl5rrToXTk" - - let data = new FormData() - data.append("file", Buffer.from("hello world1"), { - filename: "hello.txt", - }) - - data.append("file", Buffer.from("hello world2"), { - filename: "hello.txt", - }) - - let response = await axios.post("https://api.nft.storage/upload", data, { - headers: { - "Content-Type": "multipart/form-data", - Authorization: auth, - }, - }) - console.log(response.status, JSON.stringify(response.data)) -} - -main() diff --git a/src/storage/testnft.ts b/src/storage/testnft.ts deleted file mode 100644 index 259d527..0000000 --- a/src/storage/testnft.ts +++ /dev/null @@ -1,23 +0,0 @@ -import axios from "axios" -import Form from "form-data" -let form = new Form() - -form.append("file", Buffer.from("hello world"), { - filename: "", - contentType: "image/*", -}) -const response = await axios.post( - "https://api.nft.storage/upload", - Buffer.from("hello world"), - { - headers: { - "Content-Type": "application/octet-stream", - Authorization: - "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJkaWQ6ZXRocjoweGFEQTdCOWFlQTdGNTc2ZDI5NzM0ZWUxY0Q2ODVFMzc2OWNCM2QwRDEiLCJpc3MiOiJuZnQtc3RvcmFnZSIsImlhdCI6MTY3NTQ5NDYwMDkzMiwibmFtZSI6ImZ2bS1oYWNrc29uIn0.YBqfsj_LTZSJPKc0OH586avnQNqove_Htzl5rrToXTk", - }, - } -) - -console.log(response.status) -console.log(response.headers) -console.log(response.data)