Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
bokkypoobah committed Dec 19, 2023
1 parent 2e6cd0b commit b179af0
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -709,35 +709,36 @@ <h5 class="mt-3">Troubleshooting</h5>
console.log(moment().format("HH:mm:ss") + " updateApproval: " + JSON.stringify(this.modalApproval));
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
if (this.modalApproval.item.type == 'erc20') {
const contract = new ethers.Contract(this.modalApproval.item.contract, ERC20ABI, provider);
const item = this.modalApproval.item;
if (item.type == 'erc20') {
const contract = new ethers.Contract(item.contract, ERC20ABI, provider);
const contractWithSigner = contract.connect(provider.getSigner());
try {
const tx = await contractWithSigner.approve(this.modalApproval.item.spender, ethers.utils.parseUnits(this.modalApproval.tokens, this.modalApproval.item.decimals));
const tx = await contractWithSigner.approve(item.spender, ethers.utils.parseUnits(this.modalApproval.tokens, item.decimals));
console.log("tx: " + JSON.stringify(tx));
} catch (e) {
console.log("updateApproval ERC-20.approve(...) error: " + JSON.stringify(e));
}
} else if (this.modalApproval.item.type == 'erc721' && this.modalApproval.item.approvalType == 'Approval') {
const contract = new ethers.Contract(this.modalApproval.item.contract, ERC721ABI, provider);
} else if (item.type == 'erc721' && item.approvalType == 'Approval') {
const contract = new ethers.Contract(item.contract, ERC721ABI, provider);
const contractWithSigner = contract.connect(provider.getSigner());
try {
const tx = await contractWithSigner.approve(this.modalApproval.spender, this.modalApproval.tokenId);
console.log("tx: " + JSON.stringify(tx));
} catch (e) {
console.log("updateApproval ERC-721 approve(...) error: " + JSON.stringify(e));
}
} else if (this.modalApproval.item.type == 'erc721' && this.modalApproval.item.approvalType == 'ApprovalForAll') {
const contract = new ethers.Contract(this.modalApproval.item.contract, ERC721ABI, provider);
} else if (item.type == 'erc721' && item.approvalType == 'ApprovalForAll') {
const contract = new ethers.Contract(item.contract, ERC721ABI, provider);
const contractWithSigner = contract.connect(provider.getSigner());
try {
const tx = await contractWithSigner.setApprovalForAll(this.modalApproval.item.spender, this.modalApproval.approved);
const tx = await contractWithSigner.setApprovalForAll(item.spender, this.modalApproval.approved);
console.log("tx: " + JSON.stringify(tx));
} catch (e) {
console.log("updateApproval ERC-721 setApprovalForAll(...) error: " + JSON.stringify(e));
}
} else if (this.modalApproval.item.type == 'erc1155' && this.modalApproval.item.approvalType == 'ApprovalForAll') {
const contract = new ethers.Contract(this.modalApproval.item.contract, ERC1155ABI, provider);
} else if (item.type == 'erc1155' && item.approvalType == 'ApprovalForAll') {
const contract = new ethers.Contract(item.contract, ERC1155ABI, provider);
const contractWithSigner = contract.connect(provider.getSigner());
try {
const tx = await contractWithSigner.setApprovalForAll(this.modalApproval.item.spender, this.modalApproval.approved);
Expand Down

0 comments on commit b179af0

Please sign in to comment.