You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2 KiB
TypeScript

2 years ago
import hre from "hardhat";
2 years ago
const { ethers } = hre;
2 years ago
import fs from "fs";
2 years ago
async function main() {
2 years ago
const accounts = await ethers.getSigners();
console.log(accounts[0].address);
const Git3 = await hre.ethers.getContractAt(
2 years ago
"Git3Hub",
2 years ago
"0x608860940b8f3D3247E1B301Cf2fA5690e6504DD"
2 years ago
);
2 years ago
let file = fs.readFileSync("scripts/git3.png");
let rept
2 years ago
let buffer = Array.from(file).slice(0, 24 * 1024 - 300);
2 years ago
let fileSize = buffer.length;
console.log("buffer", buffer.length);
let cost = 0;
2 years ago
// if (fileSize > 24 * 1024 - 326) {
// cost = Math.floor((fileSize + 326) / 1024 / 24);
// }
let repoName = Buffer.from("test123")
// rept = await"test123" Git3.createRepo(repoName)
2 years ago
2 years ago
let key = ethers.utils.toUtf8Bytes("aaa");
2 years ago
// rept = await Git3.upload(repoName, key, buffer, {
// value: ethers.utils.parseEther(cost.toString()),
2 years ago
// gasLimit: 6000000
2 years ago
// });
2 years ago
rept = await Git3.transferOwnership(repoName, "0x1eD9c2F6814eA5225Bb78f2F2CA802Ded120077A")
2 years ago
console.log(await Git3.download(repoName, key));
2 years ago
// rept = await Git3.remove(repoName, key)
2 years ago
2 years ago
console.log("rept", "https://explorer.galileo.web3q.io/tx/" + rept.hash);
2 years ago
}
main().catch((error) => {
2 years ago
console.error(error);
process.exit(1);
});