mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-05-05 09:17:51 +00:00
Added export arrr masterkey ( enabled when core update is out )
This commit is contained in:
parent
dbaa81ed40
commit
7aa298b6be
@ -1,6 +1,8 @@
|
|||||||
import {css, html, LitElement} from 'lit'
|
import {css, html, LitElement} from 'lit'
|
||||||
import {connect} from 'pwa-helpers'
|
import {connect} from 'pwa-helpers'
|
||||||
import {store} from '../../store.js'
|
import {store} from '../../store.js'
|
||||||
|
import { Epml } from '../../epml.js'
|
||||||
|
import { addTradeBotRoutes } from '../../tradebot/addTradeBotRoutes.js'
|
||||||
import {get, translate} from 'lit-translate'
|
import {get, translate} from 'lit-translate'
|
||||||
import snackbar from '../../functional-components/snackbar.js'
|
import snackbar from '../../functional-components/snackbar.js'
|
||||||
import FileSaver from 'file-saver'
|
import FileSaver from 'file-saver'
|
||||||
@ -9,6 +11,8 @@ import '@material/mwc-dialog'
|
|||||||
import '@material/mwc-button'
|
import '@material/mwc-button'
|
||||||
import '@material/mwc-icon'
|
import '@material/mwc-icon'
|
||||||
|
|
||||||
|
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
|
||||||
|
|
||||||
class ExportKeys extends connect(store)(LitElement) {
|
class ExportKeys extends connect(store)(LitElement) {
|
||||||
static get properties() {
|
static get properties() {
|
||||||
return {
|
return {
|
||||||
@ -19,21 +23,26 @@ class ExportKeys extends connect(store)(LitElement) {
|
|||||||
dogePMK: { type: String },
|
dogePMK: { type: String },
|
||||||
dgbPMK: { type: String },
|
dgbPMK: { type: String },
|
||||||
rvnPMK: { type: String },
|
rvnPMK: { type: String },
|
||||||
|
arrrPMK: { type: String },
|
||||||
btcWALLET: { type: String },
|
btcWALLET: { type: String },
|
||||||
ltcWALLET: { type: String },
|
ltcWALLET: { type: String },
|
||||||
dogeWALLET: { type: String },
|
dogeWALLET: { type: String },
|
||||||
dgbWALLET: { type: String },
|
dgbWALLET: { type: String },
|
||||||
rvnWALLET: { type: String },
|
rvnWALLET: { type: String },
|
||||||
|
arrrWALLET: { type: String },
|
||||||
btcName: { type: String },
|
btcName: { type: String },
|
||||||
ltcName: { type: String },
|
ltcName: { type: String },
|
||||||
dogeName: { type: String },
|
dogeName: { type: String },
|
||||||
dgbName: { type: String },
|
dgbName: { type: String },
|
||||||
rvnName: { type: String },
|
rvnName: { type: String },
|
||||||
|
arrrName: { type: String },
|
||||||
btcShort: { type: String },
|
btcShort: { type: String },
|
||||||
ltcShort: { type: String },
|
ltcShort: { type: String },
|
||||||
dogeShort: { type: String },
|
dogeShort: { type: String },
|
||||||
dgbShort: { type: String },
|
dgbShort: { type: String },
|
||||||
rvnShort: { type: String },
|
rvnShort: { type: String },
|
||||||
|
arrrShort: { type: String },
|
||||||
|
enableArrr: { type: Boolean },
|
||||||
dWalletAddress: { type: String },
|
dWalletAddress: { type: String },
|
||||||
dPrivateKey: { type: String },
|
dPrivateKey: { type: String },
|
||||||
dCoinName: { type: String },
|
dCoinName: { type: String },
|
||||||
@ -48,7 +57,7 @@ class ExportKeys extends connect(store)(LitElement) {
|
|||||||
--mdc-theme-surface: var(--white);
|
--mdc-theme-surface: var(--white);
|
||||||
--mdc-dialog-content-ink-color: var(--black);
|
--mdc-dialog-content-ink-color: var(--black);
|
||||||
--mdc-dialog-min-width: 500px;
|
--mdc-dialog-min-width: 500px;
|
||||||
--mdc-dialog-max-width: 500px;
|
--mdc-dialog-max-width: 1000px;
|
||||||
--lumo-primary-text-color: rgb(0, 167, 245);
|
--lumo-primary-text-color: rgb(0, 167, 245);
|
||||||
--lumo-primary-color-50pct: rgba(0, 167, 245, 0.5);
|
--lumo-primary-color-50pct: rgba(0, 167, 245, 0.5);
|
||||||
--lumo-primary-color-10pct: rgba(0, 167, 245, 0.1);
|
--lumo-primary-color-10pct: rgba(0, 167, 245, 0.1);
|
||||||
@ -60,9 +69,8 @@ class ExportKeys extends connect(store)(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.center-box {
|
.center-box {
|
||||||
position: absolute;
|
position: relative;
|
||||||
width: 100%;
|
top: 45%;
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%, 0%);
|
transform: translate(-50%, 0%);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -71,6 +79,7 @@ class ExportKeys extends connect(store)(LitElement) {
|
|||||||
.sub-main {
|
.sub-main {
|
||||||
position: relative;
|
position: relative;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
height: auto;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,9 +87,9 @@ class ExportKeys extends connect(store)(LitElement) {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
min-width: 400px;
|
min-width: 400px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.export-button {
|
.export-button {
|
||||||
@ -135,6 +144,11 @@ class ExportKeys extends connect(store)(LitElement) {
|
|||||||
this.rvnWALLET = store.getState().app.selectedAddress.rvnWallet.address
|
this.rvnWALLET = store.getState().app.selectedAddress.rvnWallet.address
|
||||||
this.rvnName = 'Ravencoin'
|
this.rvnName = 'Ravencoin'
|
||||||
this.rvnShort = 'rvn'
|
this.rvnShort = 'rvn'
|
||||||
|
this.arrrPMK = ''
|
||||||
|
this.arrrWALLET = ''
|
||||||
|
this.arrrName = 'Pirate Chain'
|
||||||
|
this.arrrShort = 'arrr'
|
||||||
|
this.enableArrr = false
|
||||||
this.dWalletAddress = ''
|
this.dWalletAddress = ''
|
||||||
this.dPrivateKey = ''
|
this.dPrivateKey = ''
|
||||||
this.dCoinName = ''
|
this.dCoinName = ''
|
||||||
@ -143,8 +157,8 @@ class ExportKeys extends connect(store)(LitElement) {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return html`
|
return html`
|
||||||
<div>
|
<div style="position: relative;">
|
||||||
<div>
|
<div class="center-box">
|
||||||
<p>
|
<p>
|
||||||
${translate("settings.exp4")}
|
${translate("settings.exp4")}
|
||||||
</p>
|
</p>
|
||||||
@ -181,6 +195,12 @@ class ExportKeys extends connect(store)(LitElement) {
|
|||||||
</div>
|
</div>
|
||||||
<div @click=${() => this.checkForPmkDownload(this.rvnWALLET, this.rvnPMK, this.rvnName, this.rvnShort)} class="export-button"> ${translate("settings.exp2")} </div>
|
<div @click=${() => this.checkForPmkDownload(this.rvnWALLET, this.rvnPMK, this.rvnName, this.rvnShort)} class="export-button"> ${translate("settings.exp2")} </div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="content-box" style="display:${this.enableArrr ? 'block' : 'none'}">
|
||||||
|
<div style="display: flex; align-items: center; justify-content: center;">
|
||||||
|
<img src="/img/arrr.png" style="width: 32px; height: 32px;"> ${this.arrrWALLET}<br>
|
||||||
|
</div>
|
||||||
|
<div @click=${() => this.checkForPmkDownload(this.arrrWALLET, this.arrrPMK, this.arrrName, this.arrrShort)} class="export-button"> ${translate("settings.exp2")} </div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<mwc-dialog id="savePkmDialog" scrimClickAction="" escapeKeyAction="">
|
<mwc-dialog id="savePkmDialog" scrimClickAction="" escapeKeyAction="">
|
||||||
@ -202,10 +222,94 @@ class ExportKeys extends connect(store)(LitElement) {
|
|||||||
${translate("settings.exp3")}
|
${translate("settings.exp3")}
|
||||||
</mwc-button>
|
</mwc-button>
|
||||||
</mwc-dialog>
|
</mwc-dialog>
|
||||||
|
<mwc-dialog id="arrrWalletNotSynced" scrimClickAction="" escapeKeyAction="">
|
||||||
|
<img src="/img/arrr.png" style="width: 32px; height: 32px;">
|
||||||
|
<h3>${translate("settings.arrr1")}</h3>
|
||||||
|
<hr>
|
||||||
|
<h4>${translate("settings.arrr2")}</h4>
|
||||||
|
<mwc-button
|
||||||
|
slot="primaryAction"
|
||||||
|
@click="${() => this.closeArrrWalletNotSynced()}"
|
||||||
|
class="red"
|
||||||
|
>
|
||||||
|
${translate("general.close")}
|
||||||
|
</mwc-button>
|
||||||
|
</mwc-dialog>
|
||||||
|
<mwc-dialog id="needCoreUpdate" scrimClickAction="" escapeKeyAction="">
|
||||||
|
<img src="/img/arrr.png" style="width: 32px; height: 32px;">
|
||||||
|
<h3>${translate("settings.arrr3")}</h3>
|
||||||
|
<hr>
|
||||||
|
<h4>${translate("settings.arrr4")}</h4>
|
||||||
|
<mwc-button
|
||||||
|
slot="primaryAction"
|
||||||
|
@click="${() => this.closeNeedCoreUpdate()}"
|
||||||
|
class="red"
|
||||||
|
>
|
||||||
|
${translate("general.close")}
|
||||||
|
</mwc-button>
|
||||||
|
</mwc-dialog>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async firstUpdated() {
|
||||||
|
addTradeBotRoutes(parentEpml)
|
||||||
|
parentEpml.imReady()
|
||||||
|
await this.fetchArrrWalletAddress()
|
||||||
|
this.fetchArrrWalletPrivateKey()
|
||||||
|
}
|
||||||
|
|
||||||
|
async fetchArrrWalletAddress() {
|
||||||
|
let resAD = await parentEpml.request('apiCall', {
|
||||||
|
url: `/crosschain/arrr/walletaddress?apiKey=${this.getApiKey()}`,
|
||||||
|
method: 'POST',
|
||||||
|
body: `${store.getState().app.selectedAddress.arrrWallet.seed58}`
|
||||||
|
})
|
||||||
|
|
||||||
|
if (resAD != null && resAD.error != 1201) {
|
||||||
|
this.arrrWALLET = ''
|
||||||
|
this.enableArrr = true
|
||||||
|
this.arrrWALLET = resAD
|
||||||
|
} else {
|
||||||
|
this.arrrWALLET = ''
|
||||||
|
this.enableArrr = false
|
||||||
|
this.shadowRoot.querySelector('#arrrWalletNotSynced').show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fetchArrrWalletPrivateKey() {
|
||||||
|
const myNode = store.getState().app.nodeConfig.knownNodes[store.getState().app.nodeConfig.node]
|
||||||
|
const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port
|
||||||
|
const privateKeyUrl = `${nodeUrl}/crosschain/arrr/walletprivatekey?apiKey=${this.getApiKey()}`
|
||||||
|
|
||||||
|
await fetch(privateKeyUrl, {
|
||||||
|
method: 'POST',
|
||||||
|
body: `${store.getState().app.selectedAddress.arrrWallet.seed58}`
|
||||||
|
}).then(res => {
|
||||||
|
if (res.status === 404) {
|
||||||
|
this.arrrPMK = ''
|
||||||
|
this.enableArrr = false
|
||||||
|
this.shadowRoot.querySelector('#needCoreUpdate').show()
|
||||||
|
} else if (res != null && res.error != 1201) {
|
||||||
|
this.arrrPMK = ''
|
||||||
|
this.enableArrr = true
|
||||||
|
this.arrrPMK = res
|
||||||
|
} else {
|
||||||
|
this.arrrPMK = ''
|
||||||
|
this.enableArrr = false
|
||||||
|
this.shadowRoot.querySelector('#arrrWalletNotSynced').show()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
closeArrrWalletNotSynced() {
|
||||||
|
this.shadowRoot.querySelector('#arrrWalletNotSynced').close()
|
||||||
|
}
|
||||||
|
|
||||||
|
closeNeedCoreUpdate() {
|
||||||
|
this.shadowRoot.querySelector('#needCoreUpdate').close()
|
||||||
|
}
|
||||||
|
|
||||||
closeSavePkmDialog() {
|
closeSavePkmDialog() {
|
||||||
this.shadowRoot.querySelector('#savePkmDialog').close()
|
this.shadowRoot.querySelector('#savePkmDialog').close()
|
||||||
}
|
}
|
||||||
@ -259,7 +363,10 @@ class ExportKeys extends connect(store)(LitElement) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stateChanged(state) {
|
getApiKey() {
|
||||||
|
const apiNode = store.getState().app.nodeConfig.knownNodes[store.getState().app.nodeConfig.node]
|
||||||
|
let apiKey = apiNode.apiKey
|
||||||
|
return apiKey
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user