Skip to content

Commit

Permalink
Merge pull request #409 from Adamant-im/stage
Browse files Browse the repository at this point in the history
v2.10.0
  • Loading branch information
adamant-al authored Mar 11, 2021
2 parents b6d7602 + ba65ea3 commit e52815b
Show file tree
Hide file tree
Showing 60 changed files with 1,364 additions and 136 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ This application deployed at [msg.adamant.im](https://msg.adamant.im). Feel free
yarn install
```

Note: some dependencies may ask for specific Node.js version, you can ignore this with `yarn install --ignore-engines`.

### Compiles and hot-reloads for development

```
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adamant-im",
"version": "2.9.0",
"version": "2.10.0",
"author": "ADAMANT Foundation <[email protected]>",
"license": "GPLv3",
"description": "Decentralized Messenger",
Expand All @@ -18,6 +18,8 @@
"postinstall": "electron-builder install-app-deps"
},
"dependencies": {
"@liskhq/lisk-cryptography": "2.3.0",
"@liskhq/lisk-transactions": "2.3.1",
"@mdi/font": "^5.9.55",
"@stablelib/utf8": "^1.0.0",
"@zxing/library": "0.18.3",
Expand Down Expand Up @@ -45,6 +47,7 @@
"lodash": "^4.17.20",
"marked": "^1.2.7",
"notifyjs": "^3.0.0",
"pbkdf2": "^3.1.1",
"promise-queue": "^2.2.5",
"qrcode": "^1.4.4",
"qs": "^6.9.6",
Expand Down
6 changes: 4 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<!-- Disables pull-to-refresh but allows overscroll glow effects.
overscroll-behavior-y: contain; -->
<html lang="en" style="overscroll-behavior-y: contain;">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand Down Expand Up @@ -38,7 +40,6 @@
<!-- Add to home screen for Android and modern mobile browsers -->
<link rel="manifest" href="<%= htmlWebpackPlugin.files.publicPath %>manifest.json">


<!-- Add to home screen for Safari on iOS -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="#4A4A4A">
Expand All @@ -48,6 +49,7 @@

<%= htmlWebpackPlugin.options.basePath %>
</head>

<body style="background: repeating-linear-gradient(140deg, #191919, #191919 0.7px, #212121 0, #212121 5px);">
<noscript>
<strong>We're sorry but adamant-im doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
Expand Down
42 changes: 21 additions & 21 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protocol.registerStandardSchemes(['app'], { secure: true })

function createWindow () {
// Create the browser window.
win = new BrowserWindow({ width: 800, height: 800, "max-width": 800, icon: path.join(__dirname, '/icon.png') })
win = new BrowserWindow({ width: 800, height: 800, 'max-width': 800, icon: path.join(__dirname, '/icon.png') })
if (process.env.WEBPACK_DEV_SERVER_URL) {
// Load the url of the dev server if in development mode
win.loadURL(process.env.WEBPACK_DEV_SERVER_URL)
Expand All @@ -33,42 +33,42 @@ function createWindow () {
win = null
})
var template = [{
label: "ADAMANT Messenger",
label: 'ADAMANT Messenger',
submenu: [
{ label: "About", selector: "orderFrontStandardAboutPanel:" },
{ type: "separator" },
{ label: "Quit", accelerator: "Command+Q", click: function() { app.quit(); }}
]}, {
label: "Edit",
{ label: 'About', selector: 'orderFrontStandardAboutPanel:' },
{ type: 'separator' },
{ label: 'Quit', accelerator: 'Command+Q', click: function () { app.quit() } }
] }, {
label: 'Edit',
submenu: [
{ label: "Undo", accelerator: "CmdOrCtrl+Z", selector: "undo:" },
{ label: "Redo", accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:" },
{ type: "separator" },
{ label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:" },
{ label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" },
{ label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:" },
{ label: "Select All", accelerator: "CmdOrCtrl+A", selector: "selectAll:" }
]}
];
{ label: 'Undo', accelerator: 'CmdOrCtrl+Z', selector: 'undo:' },
{ label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z', selector: 'redo:' },
{ type: 'separator' },
{ label: 'Cut', accelerator: 'CmdOrCtrl+X', selector: 'cut:' },
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:' },
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:' },
{ label: 'Select All', accelerator: 'CmdOrCtrl+A', selector: 'selectAll:' }
] }
]
if (process.platform === 'darwin') {
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
var darkMode = true;
Menu.setApplicationMenu(Menu.buildFromTemplate(template))
var darkMode = true
// if (systemPreferences.isDarkMode()) {
// darkMode = true;
// }
win.webContents.executeJavaScript("window.ep.$store.commit('options/updateOption', { key: 'darkTheme',value: "+darkMode+" })");
win.webContents.executeJavaScript("window.ep.$store.commit('options/updateOption', { key: 'darkTheme',value: " + darkMode + ' })')
systemPreferences.subscribeNotification(
'AppleInterfaceThemeChangedNotification',
function theThemeHasChanged () {
win.webContents.executeJavaScript("window.ep.$store.commit('options/updateOption', { key: 'darkTheme',value: "+systemPreferences.isDarkMode()+" })");
win.webContents.executeJavaScript("window.ep.$store.commit('options/updateOption', { key: 'darkTheme',value: " + systemPreferences.isDarkMode() + ' })')
}
)
}
}

// Quit when all windows are closed.
app.on('window-all-closed', () => {
app.quit()
app.quit()
})

app.on('activate', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/components/AChat/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Not used file

## Adamant chat

A chat built with Vuetify.
Expand Down
4 changes: 4 additions & 0 deletions src/components/AChat/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
Not used file
*/

export type Message = {
id: number,
hash?: string, // transactionId for third-party cryptos
Expand Down
16 changes: 15 additions & 1 deletion src/components/ExportKeysForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
import { validateMnemonic } from 'bip39'
import { getAccountFromPassphrase as getEthAccount } from '@/lib/eth-utils'
import { getAccount as getBtcAccount } from '@/lib/bitcoin/btc-base-api'
import { getAccount as getLskAccount } from '@/lib/lisk/lisk-api'
import { Cryptos, CryptosNames } from '@/lib/constants'
import { copyToClipboard } from '@/lib/textHelpers'
Expand All @@ -109,6 +110,17 @@ function getBtcKey (crypto, passphrase, asWif) {
}
}
function getLskKey (crypto, passphrase) {
const keyPair = getLskAccount(crypto, passphrase).keyPair
const key = keyPair.secretKey.toString('hex')
return {
crypto: crypto,
cryptoName: CryptosNames[crypto],
key
}
}
export default {
components: {
QrcodeCapture,
Expand Down Expand Up @@ -165,7 +177,9 @@ export default {
const dash = getBtcKey(Cryptos.DASH, this.passphrase, false)
const doge = getBtcKey(Cryptos.DOGE, this.passphrase, true)
this.keys = [bitcoin, eth, doge, dash]
const lsk = getLskKey(Cryptos.LSK, this.passphrase)
this.keys = [bitcoin, eth, doge, dash, lsk]
}, 0)
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/SendFundsForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ import { INCREASE_FEE_MULTIPLIER } from '../lib/constants'
import { parseURI } from '@/lib/uri'
import { sendMessage } from '@/lib/adamant-api'
import { Cryptos, CryptoAmountPrecision, CryptoNaturalUnits, TransactionStatus as TS, isErc20, isFeeEstimate, isEthBased, getMinAmount } from '@/lib/constants'
import { Cryptos, CryptoAmountPrecision, CryptoNaturalUnits, TransactionStatus as TS, isErc20, isFeeEstimate, isEthBased, getMinAmount, isSelfTxAllowed } from '@/lib/constants'
import validateAddress from '@/lib/validateAddress'
import { formatNumber, isNumeric } from '@/lib/numericHelpers'
import partnerName from '@/mixins/partnerName'
Expand Down Expand Up @@ -364,7 +364,7 @@ export default {
return {
cryptoAddress: [
v => validateAddress(this.currency, v) || this.$t('transfer.error_incorrect_address', { crypto: this.currency }),
v => v !== this.ownAddress || this.$t('transfer.error_same_recipient')
v => (v !== this.ownAddress || isSelfTxAllowed(this.currency)) || this.$t('transfer.error_same_recipient')
],
amount: [
v => v > 0 || this.$t('transfer.error_incorrect_amount'),
Expand Down
148 changes: 148 additions & 0 deletions src/components/transactions/LskTransaction.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<template>
<transaction-template
:amount="transaction.amount | currency(crypto)"
:timestamp="transaction.timestamp || NaN"
:id="transaction.hash || '' "
:fee="transaction.fee | currency('LSK')"
:confirmations="confirmations || NaN"
:sender="sender || '' "
:recipient="recipient || '' "
:explorerLink="explorerLink"
:partner="partner || '' "
:status="transaction.status || '' "
:admTx="admTx"
/>
</template>

<script>
import TransactionTemplate from './TransactionTemplate.vue'
import getExplorerUrl from '../../lib/getExplorerUrl'
import { Cryptos } from '../../lib/constants'
import partnerName from '@/mixins/partnerName'
export default {
mixins: [partnerName],
name: 'lsk-transaction',
props: {
crypto: {
required: true,
type: String
},
id: {
required: true,
type: String
}
},
components: {
TransactionTemplate
},
data () {
return { }
},
computed: {
cryptoKey () {
return this.crypto.toLowerCase()
},
transaction () {
return this.$store.getters[`${this.cryptoKey}/transaction`](this.id) || { }
},
sender () {
return this.transaction.senderId ? this.formatAddress(this.transaction.senderId) : ''
},
recipient () {
return this.transaction.recipientId ? this.formatAddress(this.transaction.recipientId) : ''
},
partner () {
if (this.transaction.partner) return this.transaction.partner
const id = this.transaction.senderId !== this.$store.state.lsk.address
? this.transaction.senderId : this.transaction.recipientId
return this.getAdmAddress(id)
},
explorerLink () {
return getExplorerUrl(Cryptos.LSK, this.id)
},
confirmations () {
const { height, confirmations } = this.transaction
let result = confirmations
if (height) {
// Calculate actual confirmations count based on the tx block height and the last block height.
const c = this.$store.getters[`${this.cryptoKey}/height`] - height
if (isFinite(c) && c > result) {
result = c
}
}
return result
},
admTx () {
let admTx = {}
// Bad news, everyone: we'll have to scan the messages
Object.values(this.$store.state.chat.chats).some(chat => {
Object.values(chat.messages).some(msg => {
if (msg.hash && msg.hash === this.id) {
Object.assign(admTx, msg)
}
return !!admTx.id
})
return !!admTx.id
})
return admTx
}
},
methods: {
getAdmAddress (address) {
let admAddress = ''
// First, check the known partners
const partners = this.$store.state.partners.list
Object.keys(partners).some(uid => {
const partner = partners[uid]
if (partner[Cryptos.LSK] === address) {
admAddress = uid
}
return !!admAddress
})
if (!admAddress) {
// Bad news, everyone: we'll have to scan the messages
Object.values(this.$store.state.chat.chats).some(chat => {
Object.values(chat.messages).some(msg => {
if (msg.hash && msg.hash === this.id) {
admAddress = msg.senderId === this.$store.state.address ? msg.recipientId : msg.senderId
}
return !!admAddress
})
return !!admAddress
})
}
return admAddress
},
formatAddress (address) {
let admAddress = this.getAdmAddress(address)
let name = ''
if (address === this.$store.state.lsk.address) {
name = this.$t('transaction.me')
} else {
name = this.getPartnerName(admAddress)
}
let result = ''
if (name !== '' && name !== undefined) {
result = name + ' (' + (address) + ')'
} else {
result = address
if (admAddress) {
result += ' (' + (admAddress) + ')'
}
}
return result
}
}
}
</script>
4 changes: 4 additions & 0 deletions src/config/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
],
"btc": [
{ "url": "https://btcnode2.adamant.im" }
],
"lsk": [
{ "url": "https://lisknode1.adamant.im" },
{ "url": "https://lisknode2.adamant.im" }
]
},
"env": "development"
Expand Down
4 changes: 4 additions & 0 deletions src/config/production.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
],
"btc": [
{ "url": "https://btcnode2.adamant.im" }
],
"lsk": [
{ "url": "https://lisknode1.adamant.im" },
{ "url": "https://lisknode2.adamant.im" }
]
},
"env": "production"
Expand Down
4 changes: 4 additions & 0 deletions src/config/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
],
"btc": [
{ "url": "https://btcnode2.adamant.im" }
],
"lsk": [
{ "url": "https://lisknode1.adamant.im" },
{ "url": "https://lisknode2.adamant.im" }
]
},
"env": "test"
Expand Down
6 changes: 5 additions & 1 deletion src/config/tor.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"minApiVersion": "0.3.1",
"minApiVersion": "0.5.2",
"server": {
"adm": [
{
Expand All @@ -26,6 +26,10 @@
],
"btc": [
{ "url": "http://mgplh7en3d6ywsec5h6q3tc6mirsleb5cmlyn6nmp25qrb6gy35nypad.onion" }
],
"lsk": [
{ "url": "http://4ktlltbfgr2ujaazdplhsuypcbjvd6dqkgoo6tujd2vrgizyfrymuaid.onion" },
{ "url": "http://lekfdkoo54l2vhmwnttlktxfomyxr3ihparn46kzxmrvh3dekfgy3gyd.onion" }
]
},
"env": "production"
Expand Down
Loading

0 comments on commit e52815b

Please sign in to comment.