Browse Source

Add explicit from address for wallet transaction requests

main
def 6 days ago
parent
commit
3ba7b07d1e
  1. 19
      templates/portal_invoice_detail.html

19
templates/portal_invoice_detail.html

@ -537,19 +537,32 @@ Reference: ${invoiceRef}`;
const decimals = Number(walletButton.dataset.decimals || "18");
const tokenContract = walletButton.dataset.tokenContract || "";
await window.ethereum.request({ method: "eth_requestAccounts" });
const accounts = await window.ethereum.request({ method: "eth_requestAccounts" });
const from = Array.isArray(accounts) && accounts.length ? accounts[0] : "";
if (!from) {
throw new Error("Wallet did not return an account address.");
}
await switchChain(chainId);
let txHash;
if (assetType === "native") {
txHash = await window.ethereum.request({
method: "eth_sendTransaction",
params: [{ to: to, value: toHexBigIntFromDecimal(amount, decimals) }]
params: [{
from: from,
to: to,
value: toHexBigIntFromDecimal(amount, decimals)
}]
});
} else {
txHash = await window.ethereum.request({
method: "eth_sendTransaction",
params: [{ to: tokenContract, data: erc20TransferData(to, amount, decimals) }]
params: [{
from: from,
to: tokenContract,
data: erc20TransferData(to, amount, decimals)
}]
});
}

Loading…
Cancel
Save