From 74871a81ef8f0ef75de987f6da07e664af2b0190 Mon Sep 17 00:00:00 2001 From: QuickMythril Date: Sun, 29 Oct 2023 15:35:23 -0400 Subject: [PATCH 1/2] Add qortalRequest for altcoin wallets --- core/language/us.json | 3 +- .../core/components/qdn-action-types.js | 3 + .../plugins/core/qdn/browser/browser.src.js | 64 +++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/core/language/us.json b/core/language/us.json index c4b49e0b..c3d8cccb 100644 --- a/core/language/us.json +++ b/core/language/us.json @@ -729,7 +729,8 @@ "bchange45": "Encrypt", "bchange46": "Do you give this application permission to save the following file", "bchange47": "Instant publish - requires", - "bchange48": "Do you give this application permission to send you notifications" + "bchange48": "Do you give this application permission to send you notifications", + "bchange49": "Do you give this application permission to get your wallet information?" }, "datapage": { "dchange1": "Data Management", diff --git a/plugins/plugins/core/components/qdn-action-types.js b/plugins/plugins/core/components/qdn-action-types.js index dd354da0..271bb05c 100644 --- a/plugins/plugins/core/components/qdn-action-types.js +++ b/plugins/plugins/core/components/qdn-action-types.js @@ -19,6 +19,9 @@ export const JOIN_GROUP = 'JOIN_GROUP'; // DEPLOY_AT action export const DEPLOY_AT = 'DEPLOY_AT'; +// GET_USER_WALLET action +export const GET_USER_WALLET = 'GET_USER_WALLET'; + // GET_WALLET_BALANCE action export const GET_WALLET_BALANCE = 'GET_WALLET_BALANCE'; diff --git a/plugins/plugins/core/qdn/browser/browser.src.js b/plugins/plugins/core/qdn/browser/browser.src.js index 50da5978..d2aa7260 100644 --- a/plugins/plugins/core/qdn/browser/browser.src.js +++ b/plugins/plugins/core/qdn/browser/browser.src.js @@ -2059,6 +2059,70 @@ class WebBrowser extends LitElement { break } + case actions.GET_USER_WALLET: { + const requiredFields = ['coin']; + const missingFields = []; + + requiredFields.forEach((field) => { + if (!data[field]) { + missingFields.push(field); + } + }); + + if (missingFields.length > 0) { + const missingFieldsString = missingFields.join(', '); + const errorMsg = `Missing fields: ${missingFieldsString}` + let data = {}; + data['error'] = errorMsg; + response = JSON.stringify(data); + break + } + const res3 = await showModalAndWait( + actions.GET_USER_WALLET + ); + + if (res3.action === 'accept') { + let coin = data.coin; + let userWallet = {}; + + switch (coin) { + case 'QORT': + userWallet['address'] = window.parent.reduxStore.getState().app.selectedAddress.address + userWallet['publickey'] = window.parent.reduxStore.getState().app.selectedAddress.base58PublicKey + break + case 'BTC': + userWallet['address'] = window.parent.reduxStore.getState().app.selectedAddress.btcWallet.address + userWallet['publickey'] = window.parent.reduxStore.getState().app.selectedAddress.btcWallet.derivedMasterPublicKey + break + case 'LTC': + userWallet['address'] = window.parent.reduxStore.getState().app.selectedAddress.ltcWallet.address + userWallet['publickey'] = window.parent.reduxStore.getState().app.selectedAddress.ltcWallet.derivedMasterPublicKey + break + case 'DOGE': + userWallet['address'] = window.parent.reduxStore.getState().app.selectedAddress.dogeWallet.address + userWallet['publickey'] = window.parent.reduxStore.getState().app.selectedAddress.dogeWallet.derivedMasterPublicKey + break + case 'DGB': + userWallet['address'] = window.parent.reduxStore.getState().app.selectedAddress.dgbWallet.address + userWallet['publickey'] = window.parent.reduxStore.getState().app.selectedAddress.dgbWallet.derivedMasterPublicKey + break + case 'RVN': + userWallet['address'] = window.parent.reduxStore.getState().app.selectedAddress.rvnWallet.address + userWallet['publickey'] = window.parent.reduxStore.getState().app.selectedAddress.rvnWallet.derivedMasterPublicKey + break + case 'ARRR': + break + default: + break + } + response = JSON.stringify(userWallet); + break; + } else if (res3.action === 'reject') { + response = '{"error": "User declined request"}'; + } + break; + } + case actions.GET_WALLET_BALANCE: { const requiredFields = ['coin'] const missingFields = [] From 11781d93fd2548eeb6656de658f29042105f3b57 Mon Sep 17 00:00:00 2001 From: QuickMythril Date: Sun, 29 Oct 2023 15:56:46 -0400 Subject: [PATCH 2/2] Add modal for GET_USER_WALLET --- plugins/plugins/core/qdn/browser/browser.src.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/plugins/core/qdn/browser/browser.src.js b/plugins/plugins/core/qdn/browser/browser.src.js index d2aa7260..9a9dce18 100644 --- a/plugins/plugins/core/qdn/browser/browser.src.js +++ b/plugins/plugins/core/qdn/browser/browser.src.js @@ -3554,6 +3554,11 @@ async function showModalAndWait(type, data) { ` : ''} + ${type === actions.GET_USER_WALLET ? ` + + ` : ''} ${type === actions.GET_WALLET_BALANCE ? `