Skip to content

Commit 9c0dced

Browse files
Adds transferFromTokens error to token addresses text box (#304)
* Adds transferFromTokens error to token addresses text box * Introduce token methods output box
1 parent a3a2ea8 commit 9c0dced

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

src/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,10 @@ <h4 class="card-title">
417417
>
418418
Approve Tokens Without Gas
419419
</button>
420+
421+
<p class="info-text alert alert-secondary">
422+
Token methods result: <span id="tokenMethodsResult"></span>
423+
</p>
420424
</div>
421425
</div>
422426
</div>

src/index.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ const approveTokensWithoutGas = document.getElementById(
174174
'approveTokensWithoutGas',
175175
);
176176

177+
const tokenMethodsResult = document.getElementById('tokenMethodsResult');
178+
177179
// Encrypt / Decrypt Section
178180
const getEncryptionKeyButton = document.getElementById(
179181
'getEncryptionKeyButton',
@@ -920,6 +922,7 @@ const clearDisplayElements = () => {
920922
cleartextDisplay.innerText = '';
921923
batchTransferTokenIds.value = '';
922924
batchTransferTokenAmounts.value = '';
925+
tokenMethodsResult.value = '';
923926
};
924927

925928
const updateOnboardElements = () => {
@@ -1767,15 +1770,20 @@ const initializeFormElements = () => {
17671770
};
17681771

17691772
transferFromTokens.onclick = async () => {
1770-
const result = await hstContract.transferFrom(
1771-
transferFromSenderInput.value,
1772-
transferFromRecipientInput.value,
1773-
decimalUnitsInput.value === '0'
1774-
? 1
1775-
: `${1.5 * 10 ** decimalUnitsInput.value}`,
1776-
{ from: accounts[0] },
1777-
);
1778-
console.log('result', result);
1773+
try {
1774+
const result = await hstContract.transferFrom(
1775+
transferFromSenderInput.value,
1776+
transferFromRecipientInput.value,
1777+
decimalUnitsInput.value === '0'
1778+
? 1
1779+
: `${1.5 * 10 ** decimalUnitsInput.value}`,
1780+
{ from: accounts[0] },
1781+
);
1782+
console.log('result', result);
1783+
tokenMethodsResult.innerHTML = result;
1784+
} catch (error) {
1785+
tokenMethodsResult.innerHTML = error.message;
1786+
}
17791787
};
17801788

17811789
transferTokensWithoutGas.onclick = async () => {

0 commit comments

Comments
 (0)