From 4b4922e40b2bf28dbe5c0fb3eacded2b697ef844 Mon Sep 17 00:00:00 2001 From: Moon Date: Mon, 30 Jan 2023 12:47:43 -0500 Subject: [PATCH] updated scripts for everything almost --- scripts/balance.js | 21 ++++++++++++++++++ scripts/batch-unwrap.js | 46 ++++++++++++++++++++++++++++++++++++++++ scripts/batch-wrap.js | 46 ++++++++++++++++++++++++++++++++++++++++ scripts/contract-info.js | 15 +++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 scripts/balance.js create mode 100644 scripts/batch-unwrap.js create mode 100644 scripts/batch-wrap.js create mode 100644 scripts/contract-info.js diff --git a/scripts/balance.js b/scripts/balance.js new file mode 100644 index 0000000..52e0772 --- /dev/null +++ b/scripts/balance.js @@ -0,0 +1,21 @@ +const Wrapper = artifacts.require("CurioERC1155Wrapper"); +const IMastersFedi = artifacts.require("IMastersFedi"); + +module.exports = async (callback) => { + const nftId1 = parseInt(process.argv[6]); + + const wrapper = await Wrapper.deployed(); + const tokenContractAddress1 = await wrapper.contracts(nftId1); + const tokenContract1 = await IMastersFedi.at(tokenContractAddress1); + const tokenName1 = await tokenContract1.name(); + console.log(`Token name: "${tokenName1}"`); + + const [account,] = await web3.eth.getAccounts(); + + const wrappedBalance1 = await wrapper.balanceOf(account, nftId1); + const tokenBalance1 = await tokenContract1.balanceOf(account); + console.log(`Wrapped: ${wrappedBalance1}`); + console.log(`Unwrapped: ${tokenBalance1}`); + + callback(); +} diff --git a/scripts/batch-unwrap.js b/scripts/batch-unwrap.js new file mode 100644 index 0000000..fb58164 --- /dev/null +++ b/scripts/batch-unwrap.js @@ -0,0 +1,46 @@ +const Wrapper = artifacts.require("CurioERC1155Wrapper"); +const IMastersFedi = artifacts.require("IMastersFedi"); + +module.exports = async (callback) => { + const nftId1 = parseInt(process.argv[6]); + const quantity1 = parseInt(process.argv[7]); + const nftId2 = parseInt(process.argv[8]); + const quantity2 = parseInt(process.argv[9]); + + const wrapper = await Wrapper.deployed(); + const tokenContractAddress1 = await wrapper.contracts(nftId1); + const tokenContractAddress2 = await wrapper.contracts(nftId2); + const tokenContract1 = await IMastersFedi.at(tokenContractAddress1); + const tokenContract2 = await IMastersFedi.at(tokenContractAddress2); + const tokenName1 = await tokenContract1.name(); + const tokenName2 = await tokenContract2.name(); + console.log(`Token names: "${tokenName1}", "${tokenName2}"`); + + const [account,] = await web3.eth.getAccounts(); + + try { + console.log("Batch unwrapping..."); + const finalResult = await wrapper.unwrapBatch( + [nftId1, nftId2], + [quantity1, quantity2], + { from: account } + ); + + console.log(`Tx: ${finalResult.tx}`); + + const wrappedBalance1 = await wrapper.balanceOf(account, nftId1); + const wrappedBalance2 = await wrapper.balanceOf(account, nftId2); + + console.log(`New wrapped balances: ${wrappedBalance1}, ${wrappedBalance2}`); + + const tokenBalance1 = await tokenContract1.balanceOf(account); + const tokenBalance2 = await tokenContract2.balanceOf(account); + console.log(`New unwrapped balances: ${tokenBalance1}, ${tokenBalance2}`); + } + catch (e) { + console.error(`FAILED: ${e}`); + } + + console.log("Done."); + callback(); +} diff --git a/scripts/batch-wrap.js b/scripts/batch-wrap.js new file mode 100644 index 0000000..06c77fa --- /dev/null +++ b/scripts/batch-wrap.js @@ -0,0 +1,46 @@ +const Wrapper = artifacts.require("CurioERC1155Wrapper"); +const IMastersFedi = artifacts.require("IMastersFedi"); + +module.exports = async (callback) => { + const nftId1 = parseInt(process.argv[6]); + const quantity1 = parseInt(process.argv[7]); + const nftId2 = parseInt(process.argv[8]); + const quantity2 = parseInt(process.argv[9]); + + const wrapper = await Wrapper.deployed(); + const tokenContractAddress1 = await wrapper.contracts(nftId1); + const tokenContractAddress2 = await wrapper.contracts(nftId2); + const tokenContract1 = await IMastersFedi.at(tokenContractAddress1); + const tokenContract2 = await IMastersFedi.at(tokenContractAddress2); + const tokenName1 = await tokenContract1.name(); + const tokenName2 = await tokenContract2.name(); + console.log(`Token names: "${tokenName1}", "${tokenName2}"`); + + const [account,] = await web3.eth.getAccounts(); + const tokenBalance1 = await tokenContract1.balanceOf(account); + const tokenBalance2 = await tokenContract2.balanceOf(account); + console.log(`Unwrapped balances: ${tokenBalance1}, ${tokenBalance2}`); + + + try { + console.log(`Approving token 1...`); + const result1 = await tokenContract1.approve(wrapper.address, quantity1, { from: account }); + console.log(`Approving token 2...`); + const result2 = await tokenContract2.approve(wrapper.address, quantity2, { from: account }); + + console.log("Batch wrapping..."); + const finalResult = await wrapper.wrapBatch( + [nftId1, nftId2], + [quantity1, quantity2], + { from: account } + ); + + console.log(`Tx: ${finalResult.tx}`); + } + catch (e) { + console.error(`FAILED: ${e}`); + } + + console.log("Done."); + callback(); +} diff --git a/scripts/contract-info.js b/scripts/contract-info.js new file mode 100644 index 0000000..c16356f --- /dev/null +++ b/scripts/contract-info.js @@ -0,0 +1,15 @@ +const Wrapper = artifacts.require("CurioERC1155Wrapper"); + +module.exports = async (callback) => { + const wrapper = await Wrapper.deployed(); + + const name = await wrapper.name(); + const symbol = await wrapper.symbol(); + + console.log(`Name: "${name}", symbol: "${symbol}"`); + + const royaltyInfo = await wrapper.royaltyInfo(1, "10000000000"); + console.log(JSON.stringify(royaltyInfo, null, 4)); + + callback(); +}