From 40f1663a56d3e5718a090e055df04e54d9e7d8b4 Mon Sep 17 00:00:00 2001 From: Alexandr Date: Mon, 24 Feb 2025 01:15:09 +0300 Subject: [PATCH] add comment as optional transfer param --- src/background/background.ts | 4 ++-- src/background/wallet.ts | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/background/background.ts b/src/background/background.ts index 7446e01..d33d745 100644 --- a/src/background/background.ts +++ b/src/background/background.ts @@ -427,7 +427,7 @@ async function processRequest(request: RequestType, sender: Sender, sendResponse request.destination, request.amount, request.decimalPoint, - request.comment + request.comment ?? undefined ) .then((data) => { sendResponse({ data }); @@ -526,7 +526,7 @@ async function processRequest(request: RequestType, sender: Sender, sendResponse destination, amount, asset?.decimal_point || 12, - comment + comment ?? undefined ); }, { diff --git a/src/background/wallet.ts b/src/background/wallet.ts index 0760925..04f4c67 100644 --- a/src/background/wallet.ts +++ b/src/background/wallet.ts @@ -318,7 +318,7 @@ export const transfer = async ( destination: any, amount: any, decimalPoint: any, - comment: string + comment?: string ) => { const destinations = [ { @@ -331,12 +331,15 @@ export const transfer = async ( }, ]; - const response = await fetchData("transfer", { + const options : {[key: string]: typeof destinations | number | string } = { destinations, fee: 10000000000, mixin: 10, - comment - }); + }; + + if (comment) options.comment = comment; + + const response = await fetchData("transfer", options); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`);