fix ns contract call bug

master
cyhhao 2 years ago
parent 453b37fcc8
commit 547746302e

@ -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`)
}

@ -137,7 +137,7 @@ program
program
.command("create")
.argument("<uri>", "ex: default@git3.w3q/repo_name")
.argument("<uri>", "ex: git3.w3q/repo_name")
.description("create a new repo")
.action(async (uri) => {
if (!uri.startsWith("git3://")) {

@ -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()

@ -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)
Loading…
Cancel
Save