override transfer from

This commit is contained in:
Moon Man 2023-01-30 15:33:49 -05:00
parent a5f9d9f139
commit 791ca05333
1 changed files with 9 additions and 2 deletions

View File

@ -10,13 +10,20 @@ module.exports = async (callback) => {
const [account,] = await web3.eth.getAccounts(); const [account,] = await web3.eth.getAccounts();
const currentBalance = BigInt(await wrapper.balanceOf(account, nftId1)); const from = process.argv[9] ? process.argv[9] : account;
if (from !== account) {
console.log(`Overrode from address`);
const approved = await wrapper.isApprovedForAll(from, account);
console.log(`Approved? ${approved ? "yes" : "no"}`);
}
const currentBalance = BigInt(await wrapper.balanceOf(from, nftId1));
console.log(`Current balance: ${currentBalance}`); console.log(`Current balance: ${currentBalance}`);
if (currentBalance >= quantity1) { if (currentBalance >= quantity1) {
console.log("Executing transfer transaction..."); console.log("Executing transfer transaction...");
try { try {
const result = await wrapper.safeTransferFrom(account, to, nftId1, quantity1.toString(), []); const result = await wrapper.safeTransferFrom(from, to, nftId1, quantity1.toString(), []);
console.log(`Transaction: ${result.tx}`); console.log(`Transaction: ${result.tx}`);
} }
catch (e) { catch (e) {