Skip to content

Commit

Permalink
Set approval for all erc1155 (#215)
Browse files Browse the repository at this point in the history
* setApprovalForAll UI buttons

* approval methods
  • Loading branch information
PeterYinusa authored Mar 1, 2023
1 parent 3e08cc4 commit fc3766b
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,26 @@ <h4 class="card-title">
</button>
</div>

<div class="form-group">
<button
class="btn btn-primary btn-lg btn-block mb-3"
id="setApprovalForAllERC1155Button"
disabled
>
Set Approval For All
</button>
</div>

<div class="form-group">
<button
class="btn btn-primary btn-lg btn-block mb-3"
id="revokeERC1155Button"
disabled
>
Revoke
</button>
</div>

<p class="info-text alert alert-secondary">
ERC 1155: <span id="erc1155Status"></span>
</p>
Expand Down
38 changes: 38 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -289,6 +293,8 @@ const initialize = async () => {
batchTransferTokenIds,
batchTransferTokenAmounts,
batchTransferFromButton,
setApprovalForAllERC1155Button,
revokeERC1155Button,
deployFailingButton,
sendFailingButton,
deployMultisigButton,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit fc3766b

Please sign in to comment.