Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,26 @@ <h4 class="card-title">
</button>
</div>

<div class="form-group">
<label>Watch ERC1155 Token ID</label>
<input
class="form-control"
type="text"
value="1"
id="watchAssetInput"
/>
</div>

<div class="form-group">
<button
class="btn btn-primary btn-lg btn-block mb-3"
id="watchAssetButton"
disabled
>
Watch ERC1155 Asset
</button>
</div>

<p class="info-text alert alert-secondary">
ERC 1155: <span id="erc1155Status"></span>
</p>
Expand Down
26 changes: 26 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ const setApprovalForAllERC1155Button = document.getElementById(
'setApprovalForAllERC1155Button',
);
const revokeERC1155Button = document.getElementById('revokeERC1155Button');
const watchAssetInput = document.getElementById('watchAssetInput');
const watchAssetButton = document.getElementById('watchAssetButton');
const erc1155Status = document.getElementById('erc1155Status');

// ERC 747 Section
Expand Down Expand Up @@ -272,6 +274,8 @@ const allConnectedButtons = [
batchTransferFromButton,
setApprovalForAllERC1155Button,
revokeERC1155Button,
watchAssetInput,
watchAssetButton,
deployFailingButton,
sendFailingButton,
deployMultisigButton,
Expand Down Expand Up @@ -814,6 +818,8 @@ const updateContractElements = () => {
batchTransferFromButton.disabled = false;
setApprovalForAllERC1155Button.disabled = false;
revokeERC1155Button.disabled = false;
watchAssetInput.disabled = false;
watchAssetButton.disabled = false;
// ERC20 Token - Send Tokens
tokenAddresses.innerHTML = hstContract ? hstContract.address : '';
watchAssets.disabled = false;
Expand Down Expand Up @@ -1158,6 +1164,8 @@ const initializeFormElements = () => {
batchTransferFromButton.disabled = false;
setApprovalForAllERC1155Button.disabled = false;
revokeERC1155Button.disabled = false;
watchAssetInput.disabled = false;
watchAssetButton.disabled = false;
};

batchMintButton.onclick = async () => {
Expand Down Expand Up @@ -1234,6 +1242,24 @@ const initializeFormElements = () => {
erc1155Status.innerHTML = 'Revoke completed';
};

watchAssetButton.onclick = async () => {
try {
const watchAssetResult = await ethereum.request({
method: 'wallet_watchAsset',
params: {
type: 'ERC1155',
options: {
address: erc1155Contract.address,
tokenId: watchAssetInput.value,
},
},
});
console.log(watchAssetResult);
} catch (error) {
console.error(error);
}
};

/**
* EIP 747
*/
Expand Down