Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/components/Configure/Configure.js
Show First 20 Lines • Show All 1,145 Lines • ▼ Show 20 Lines | const addSavedWalletToContact = walletInfo => { | ||||
// initialise saved wallet name and address to state for confirmation modal | // initialise saved wallet name and address to state for confirmation modal | ||||
setManualContactName(walletInfo.name); | setManualContactName(walletInfo.name); | ||||
setManualContactAddress( | setManualContactAddress( | ||||
convertToEcashPrefix(walletInfo.Path1899.cashAddress), | convertToEcashPrefix(walletInfo.Path1899.cashAddress), | ||||
); | ); | ||||
setSavedWalletContactModal(true); | setSavedWalletContactModal(true); | ||||
}; | }; | ||||
const exportWallet = savedWallets => { | |||||
let walletExport = { | |||||
wallets: [], | |||||
}; | |||||
// retireve only what's needed from saved wallet objects | |||||
for (let i = 0; i < savedWallets.length; i++) { | |||||
const walletSummary = { | |||||
// Store all wallet info except state and unused deriv paths | |||||
mnemonic: savedWallets[i].mnemonic, | |||||
name: savedWallets[i].name, | |||||
Path1899: savedWallets[i].Path1899, | |||||
}; | |||||
walletExport.wallets.push(walletSummary); | |||||
} | |||||
// add the activate wallet to export | |||||
walletExport.wallets.push({ | |||||
// Store all wallet info except state and unused deriv paths | |||||
mnemonic: wallet.mnemonic, | |||||
name: wallet.name, | |||||
Path1899: wallet.Path1899, | |||||
}); | |||||
// convert and export wallet summary array into json format | |||||
let walletDataStr = JSON.stringify(walletExport, null, 4); | |||||
let walletDataUri = | |||||
'data:application/json;charset=utf-8,' + | |||||
encodeURIComponent(walletDataStr); | |||||
let exportFileName = 'CashtabExport_' + new Date().toString() + '.json'; | |||||
let linkElement = document.createElement('a'); | |||||
linkElement.setAttribute('href', walletDataUri); | |||||
linkElement.setAttribute('download', exportFileName); | |||||
linkElement.click(); | |||||
}; | |||||
const handleManualAddContactModalOk = async () => { | const handleManualAddContactModalOk = async () => { | ||||
// if either inputs are invalid then go no further | // if either inputs are invalid then go no further | ||||
if (!manualContactNameIsValid || !manualContactAddressIsValid) { | if (!manualContactNameIsValid || !manualContactAddressIsValid) { | ||||
return; | return; | ||||
} | } | ||||
let duplicateContact = false; | let duplicateContact = false; | ||||
let tempContactListArray = contactListArray; | let tempContactListArray = contactListArray; | ||||
▲ Show 20 Lines • Show All 407 Lines • ▼ Show 20 Lines | return ( | ||||
Import | Import | ||||
</SmartButton> | </SmartButton> | ||||
</Form> | </Form> | ||||
</AntdFormWrapper> | </AntdFormWrapper> | ||||
</> | </> | ||||
)} | )} | ||||
</> | </> | ||||
)} | )} | ||||
<SecondaryButton onClick={() => exportWallet(savedWallets)}> | |||||
<ImportOutlined /> Export Cashtab Data | |||||
</SecondaryButton> | |||||
{savedWallets && savedWallets.length > 0 && ( | {savedWallets && savedWallets.length > 0 && ( | ||||
<> | <> | ||||
<StyledCollapse> | <StyledCollapse> | ||||
<Panel header="Saved wallets"> | <Panel header="Saved wallets"> | ||||
<AWRow> | <AWRow> | ||||
<Tooltip title={wallet.name}> | <Tooltip title={wallet.name}> | ||||
<h3 className="notranslate"> | <h3 className="notranslate"> | ||||
{wallet.name} | {wallet.name} | ||||
▲ Show 20 Lines • Show All 328 Lines • Show Last 20 Lines |