Skip to content

Commit

Permalink
update example transaction builder
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmanzanera committed Aug 30, 2024
1 parent 7874b1e commit 92a7a99
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions example/transactionBuilder/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ window.onChangeRecipient = async () => {

document.querySelector("#namedActionsContainer").style.display = "block";

Contract.extractActionsFromContract(contractCode).forEach((action) => {
const actions = await Contract.extractActionsFromContract(contractCode);
actions.forEach((action) => {
const option = document.createElement("option");
option.text = action.name;
option.value = action.name;
Expand All @@ -280,7 +281,16 @@ window.onChangeRecipient = async () => {
paramInput.setAttribute("class", "input");
paramInput.addEventListener("change", function (e) {
const value = e.target.value;
namedParams[index] = Contract.parseTypedArgument(value);
try {
const json = JSON.parse(value);
if (typeof json === "object") {
namedParams[index] = Contract.parseTypedArgument(json);
} else {
namedParams[index] = Contract.parseTypedArgument(value);
}
} catch (e) {
namedParams[index] = Contract.parseTypedArgument(value);
}
});

paramsContainer.appendChild(paramLabel);
Expand Down Expand Up @@ -309,7 +319,7 @@ window.onClickAddRecipient = () => {
if (recipientList.textContent != "") {
recipientList.textContent = recipientList.textContent + "\n";
}
recipientList.textContent += `${recipientAddress} - ${namedAction} - ${namedParams}`;
recipientList.textContent += `${recipientAddress} - ${namedAction} - ${JSON.stringify(namedParams)}`;

document.querySelector("#namedActionsContainer").style.display = "none";
document.querySelector("#namedActions").innerHTML = "<option></option>";
Expand Down

0 comments on commit 92a7a99

Please sign in to comment.