From fc3766b88975b4ba98e5a57ba94ee1a055e86121 Mon Sep 17 00:00:00 2001 From: Peter <53189696+PeterYinusa@users.noreply.github.com> Date: Wed, 1 Mar 2023 11:10:58 +0000 Subject: [PATCH] Set approval for all erc1155 (#215) * setApprovalForAll UI buttons * approval methods --- src/index.html | 20 ++++++++++++++++++++ src/index.js | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/src/index.html b/src/index.html index d6a6e9ad..b5e54198 100644 --- a/src/index.html +++ b/src/index.html @@ -486,6 +486,26 @@

+
+ +
+ +
+ +
+

ERC 1155:

diff --git a/src/index.js b/src/index.js index ab77345b..4204dd30 100644 --- a/src/index.js +++ b/src/index.js @@ -105,6 +105,10 @@ const batchTransferTokenAmounts = document.getElementById( const batchTransferFromButton = document.getElementById( 'batchTransferFromButton', ); +const setApprovalForAllERC1155Button = document.getElementById( + 'setApprovalForAllERC1155Button', +); +const revokeERC1155Button = document.getElementById('revokeERC1155Button'); const erc1155Status = document.getElementById('erc1155Status'); // Send Eth Section @@ -289,6 +293,8 @@ const initialize = async () => { batchTransferTokenIds, batchTransferTokenAmounts, batchTransferFromButton, + setApprovalForAllERC1155Button, + revokeERC1155Button, deployFailingButton, sendFailingButton, deployMultisigButton, @@ -429,6 +435,8 @@ const initialize = async () => { batchTransferTokenIds.disabled = false; batchTransferTokenAmounts.disabled = false; batchTransferFromButton.disabled = false; + setApprovalForAllERC1155Button.disabled = false; + revokeERC1155Button.disabled = false; // ERC20 Token - Send Tokens tokenAddress.innerHTML = hstContract.address; watchAsset.disabled = false; @@ -750,6 +758,8 @@ const initialize = async () => { batchTransferTokenAmounts.disabled = false; batchMintButton.disabled = false; batchTransferFromButton.disabled = false; + setApprovalForAllERC1155Button.disabled = false; + revokeERC1155Button.disabled = false; }; batchMintButton.onclick = async () => { @@ -798,6 +808,34 @@ const initialize = async () => { erc1155Status.innerHTML = 'Batch Transfer From completed'; }; + setApprovalForAllERC1155Button.onclick = async () => { + erc1155Status.innerHTML = 'Set Approval For All initiated'; + let result = await erc1155Contract.setApprovalForAll( + '0x9bc5baF874d2DA8D216aE9f137804184EE5AfEF4', + true, + { + from: accounts[0], + }, + ); + result = await result.wait(); + console.log(result); + erc1155Status.innerHTML = 'Set Approval For All completed'; + }; + + revokeERC1155Button.onclick = async () => { + erc1155Status.innerHTML = 'Revoke initiated'; + let result = await erc1155Contract.setApprovalForAll( + '0x9bc5baF874d2DA8D216aE9f137804184EE5AfEF4', + false, + { + from: accounts[0], + }, + ); + result = await result.wait(); + console.log(result); + erc1155Status.innerHTML = 'Revoke completed'; + }; + /** * Sending ETH */