bunch more scripts

This commit is contained in:
Moon Man 2023-01-30 19:35:49 -05:00
parent cb9898a4bd
commit f3e292bec2
3 changed files with 114 additions and 0 deletions

31
scripts/approve-set.js Normal file
View File

@ -0,0 +1,31 @@
const Wrapper = artifacts.require("CurioERC1155Wrapper");
const IMastersFedi = artifacts.require("IMastersFedi");
const quantity = parseInt(process.argv[6]);
module.exports = async (callback) => {
if (quantity > 0) {
const wrapper = await Wrapper.deployed();
let approveSuccess = false;
console.log("Approving all contracts for transfer");
try {
for (let id = 2; id <= 9; ++id) {
const tokenContractAddress = await wrapper.contracts(id);
const tokenContract = await IMastersFedi.at(tokenContractAddress);
console.log(`Approving ID ${id}...`);
await tokenContract.approve(wrapper.address, quantity);
}
approveSuccess = true;
}
catch (e) {
console.error(`FAILED: ${e}`);
}
}
else {
console.error("Invalid quantity");
}
callback();
}

25
scripts/transfer1.js Normal file
View File

@ -0,0 +1,25 @@
const IMastersFedi = artifacts.require("IMastersFedi");
module.exports = async (callback) => {
const [account,] = await web3.eth.getAccounts();
const quantity = parseInt(process.argv[6]);
const to = process.argv[7];
const tokenContract = await IMastersFedi.at("0x2f873FCc3F4B84E9A62AFf28E9a897ce1BC8814B");
const currentBalance = await tokenContract.balanceOf(account);
console.log(`Current balance: ${currentBalance}`);
console.log("Executing transfer transaction...");
try {
const result = await tokenContract.transfer(to, quantity);
console.log(`Transaction: ${result.tx}`);
const newBalance = await tokenContract.balanceOf(account);
console.log(`New balance: ${newBalance}`);
}
catch (e) {
console.error(`FAILED: ${e}`);
}
callback();
}

View File

@ -0,0 +1,58 @@
const Wrapper = artifacts.require("CurioERC1155Wrapper");
const IMastersFedi = artifacts.require("IMastersFedi");
const seq = n => n < 1 ? [] : [...seq(n - 1), n];
const to = process.argv[6];
const quantity = parseInt(process.argv[7]);
module.exports = async (callback) => {
if (/0x[0-9a-fA-F]{40}/.test(to) && quantity > 0) {
const wrapper = await Wrapper.deployed();
const [account,] = await web3.eth.getAccounts();
const ids = seq(9);
const quantities = Array(9).fill(quantity);
let approveSuccess = false;
console.log("Approving all contracts for transfer");
try {
for (let id = 1; id <= 9; ++id) {
const tokenContractAddress = await wrapper.contracts(id);
const tokenContract = await IMastersFedi.at(tokenContractAddress);
console.log(`Approving ID ${id}...`);
await tokenContract.approve(wrapper.address, quantity);
}
approveSuccess = true;
}
catch (e) {
console.error(`FAILED: ${e}`);
}
if (approveSuccess) {
console.log("Executing wrap transaction...");
let wrapResult;
try {
wrapResult = await wrapper.wrapBatch(
ids,
quantities
);
console.log(`Wrap transaction: ${wrapResult.tx}`);
}
catch (e) {
console.error(`FAILED: ${e}`);
}
if (wrapResult) {
console.log("Executing batch transfer...");
const transferResult = await wrapper.safeBatchTransferFrom(account, to, ids, quantities, []);
console.log(`Transfer transaction: ${transferResult.tx}`);
}
}
}
else {
console.error("Invalid to address or quantity");
}
callback();
}