diff --git a/index.html b/index.html index 03558f0..c5f26e1 100644 --- a/index.html +++ b/index.html @@ -513,14 +513,17 @@ 0.00 - +
+ +
diff --git a/scripts/fn_ui.js b/scripts/fn_ui.js index 2a98f17..94c0b49 100644 --- a/scripts/fn_ui.js +++ b/scripts/fn_ui.js @@ -1393,4 +1393,28 @@ getRef('send_transaction').onclick = evt => { }).finally(_ => { buttonLoader('send_transaction', false) }) +} + +function convertAsset() { + buttonLoader('convert_asset_button', true) + const fromAsset = getRef('from_asset_selector').value; + const fromAmount = parseFloat(getRef('from_amount').value.trim()); + if (fromAsset === 'BTC') { + btc_api.getBalance(btc_api.convert.legacy2bech(myFloID)).then(btcBalance => { + if (btcBalance < fromAmount) { + notify('You do not have enough BTC to convert', 'error'); + buttonLoader('convert_asset_button', false) + return; + } + }) + } else { + floTokenAPI.getBalance(myFloID).then((balance = 0) => { + if(balance < fromAmount) { + notify('You do not have enough rupee tokens to convert', 'error'); + buttonLoader('convert_asset_button', false) + return; + } + }) + } + // use api to convert asset } \ No newline at end of file