Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update doge indexer healthcheck endpoint #681

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
521d1d3
chore: change commit activity from master to dev
aineo Aug 9, 2024
f9c3e84
Merge pull request #660 from Adamant-im/chore/commit-activity-from-ma…
bludnic Sep 6, 2024
19725ca
fix: broken links are shown as undefined
aineo Sep 25, 2024
c5abb4c
chore(ServiceWorker): remove hash from MDI font files
bludnic Sep 28, 2024
7108352
chore(ServiceWorker): cache WASM files (used by tiny-secp256k1 package)
bludnic Sep 28, 2024
ccf5eda
All-nodes-disabled-dialog bottom padding
Oct 21, 2024
e07d5a6
Support kly qr code
Oct 22, 2024
c7b2823
Fix: all-nodes-disabled-dialog css according to existed class name
Oct 23, 2024
841f010
Unified parseURI function
Oct 23, 2024
9d3f04a
Small fixes
Oct 23, 2024
4b9dec0
Fix: parseURIasAIP() get returned default uri parameter
Oct 23, 2024
7bac48c
fix: protocol name in parseKlyURI(); description parameters
Oct 23, 2024
c7cd65c
fix: small code fixes after review; klayr optional message
Oct 24, 2024
1eebbd5
fix: protocol: Cryptos.KLY.toLowerCase()
Oct 24, 2024
5c37665
fix: textData model assignment; small code syntactical sugar changes
Oct 24, 2024
12e0fd1
fix: more simplified ternary assignment
Oct 24, 2024
d378d52
fix: padding in styles
Oct 25, 2024
42d5b80
fix: padding in styles for headers; padding s for the content are vue…
Oct 25, 2024
2d1ee57
fix: padding in styles for the card's header with BEM rules
Oct 25, 2024
a3c2d71
fix(NodesOfflineDialog): add padding-right
bludnic Oct 25, 2024
3883d6e
feat(NodesOfflineDialog): less bottom padding for card content
bludnic Oct 25, 2024
4479bbf
feat(NodesOfflineDialog): remove disclaimer margin
bludnic Oct 25, 2024
7ea4e1d
Merge pull request #674 from Adamant-im/feat/support_kly_qrcode
bludnic Oct 25, 2024
f986b0d
Merge pull request #668 from Adamant-im/fix/broken-links-shown-undefined
bludnic Oct 28, 2024
bc08da3
update doge indexer healthcheck-endpoint
Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/adamant-im/adamant-im/dev.yml)](https://github.com/Adamant-im/adamant-im/actions/workflows/dev.yml) [![GitHub commit activity (branch)](https://img.shields.io/github/commit-activity/m/Adamant-im/adamant-im?color=24bd13)](https://github.com/Adamant-im/adamant-im/graphs/commit-activity) [![GitHub release (with filter)](https://img.shields.io/github/v/release/adamant-im/adamant-im?color=24bd13)](https://github.com/Adamant-im/adamant-im/releases) [![Static Badge](https://img.shields.io/badge/Slack-brightgreen?logo=slack&logoColor=white&labelColor=fa8f02&color=grey&link=https%3A%2F%2Fjoin.slack.com%2Ft%2Fadamant-im%2Fshared_invite%2Fzt-3n32uqh3-TmTM4qPAKcp3PzrPMtKETQ)](https://join.slack.com/t/adamant-im/shared_invite/zt-3n32uqh3-TmTM4qPAKcp3PzrPMtKETQ) [![Static Badge](https://img.shields.io/badge/Twitter-brightgreen?logo=x&logoColor=white&labelColor=blue&color=grey&link=https%3A%2F%2Ftwitter.com%2Fadamant_im)](https://twitter.com/adamant_im)
[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/adamant-im/adamant-im/dev.yml)](https://github.com/Adamant-im/adamant-im/actions/workflows/dev.yml) [![GitHub commit activity (branch)](https://img.shields.io/github/commit-activity/m/Adamant-im/adamant-im/dev?color=24bd13)](https://github.com/Adamant-im/adamant-im/graphs/commit-activity) [![GitHub release (with filter)](https://img.shields.io/github/v/release/adamant-im/adamant-im?color=24bd13)](https://github.com/Adamant-im/adamant-im/releases) [![Static Badge](https://img.shields.io/badge/Slack-brightgreen?logo=slack&logoColor=white&labelColor=fa8f02&color=grey&link=https%3A%2F%2Fjoin.slack.com%2Ft%2Fadamant-im%2Fshared_invite%2Fzt-3n32uqh3-TmTM4qPAKcp3PzrPMtKETQ)](https://join.slack.com/t/adamant-im/shared_invite/zt-3n32uqh3-TmTM4qPAKcp3PzrPMtKETQ) [![Static Badge](https://img.shields.io/badge/Twitter-brightgreen?logo=x&logoColor=white&labelColor=blue&color=grey&link=https%3A%2F%2Ftwitter.com%2Fadamant_im)](https://twitter.com/adamant_im)

# ADAMANT Messenger Progressive Web Application (PWA)

Expand Down
17 changes: 9 additions & 8 deletions src/components/NodesOfflineDialog.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<v-dialog v-model="showDialog" width="500" :class="className">
<v-card>
<v-card-title class="a-text-header">
<v-card-title :class="`${className}__card-title a-text-header`">
{{ t('chats.nodes_offline_dialog.title', { coin: nodeType.toUpperCase() }) }}
</v-card-title>

Expand Down Expand Up @@ -76,12 +76,13 @@ export default {
@import 'vuetify/_settings.scss';
@import '@/assets/styles/settings/_colors.scss';

.nodes-offline-dialog {
&__card-text {
padding: 16px !important;
.all-nodes-disabled-dialog {
&__card-title {
padding-left: 24px !important;
padding-right: 24px !important;
}
&__disclaimer {
margin-top: 10px;
&__card-text {
padding-bottom: 16px !important;
}
&__btn {
margin-top: 15px;
Expand All @@ -91,13 +92,13 @@ export default {
margin-right: 8px;
}
&__btn-block {
padding: 16px 0 32px 0;
padding: 16px 0 16px 0;
text-align: center;
}
}

.v-theme--dark {
.nodes-offline-dialog {
.all-nodes-disabled-dialog {
&__disclaimer {
color: map-get($shades, 'white');
}
Expand Down
25 changes: 14 additions & 11 deletions src/components/SendFundsForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ import {
Fees
} from '@/lib/constants'

import { parseURIasAIP } from '@/lib/uri'
import { parseURI } from '@/lib/uri'
import { sendMessage } from '@/lib/adamant-api'
import { replyMessageAsset } from '@/lib/adamant-api/asset'

Expand Down Expand Up @@ -310,6 +310,7 @@ export default {
increaseFee: false,
showWarningOnPartnerAddressDialog: false,
warningOnPartnerInfo: {},
klayrOptionalMessage: '',

// Account exists check
// Currently works only with KLY
Expand Down Expand Up @@ -671,7 +672,7 @@ export default {
*/
onPasteURIAddress(e) {
const data = e.clipboardData.getData('text')
const address = parseURIasAIP(data).address
const address = parseURI(data).address

if (validateAddress(this.currency, address)) {
e.preventDefault()
Expand All @@ -687,7 +688,7 @@ export default {
*/
onPasteURIComment(e) {
nextTick(() => {
const params = parseURIasAIP(e.target.value).params
const params = parseURI(e.target.value).params

if (params.message) {
this.comment = params.message
Expand All @@ -700,18 +701,20 @@ export default {
* @param {string} uri URI
*/
onScanQrcode(uri) {
const recipient = parseURIasAIP(uri)

this.cryptoAddress = ''
if (validateAddress(this.currency, recipient.address)) {
this.cryptoAddress = recipient.address
if (recipient.params.amount) {
const amount = formatNumber(this.exponent)(recipient.params.amount)

const recipient = parseURI(uri)
const { params, address, crypto } = recipient
const isValidAddress = validateAddress(this.currency, address)
if (isValidAddress) {
this.cryptoAddress = address
if (params.amount && !this.amountString) {
const amount = formatNumber(this.exponent)(params.amount)
if (Number(amount) <= this.maxToTransfer) {
this.amountString = amount
}
}
if (crypto === Cryptos.KLY) {
this.textData = params.reference ? params.reference : ''
}
} else {
this.$emit('error', this.$t('transfer.error_incorrect_address', { crypto: this.currency }))
}
Expand Down
14 changes: 8 additions & 6 deletions src/lib/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ marked.setOptions({

const renderer = new marked.Renderer()

renderer.image = function (_href, _title, _text) {
renderer.image = function ({ _href, _title, _text }) {
return ''
}

renderer.link = function (href, title, text) {
renderer.link = function ({ href, _title, text }) {
const linkPattern = /^(eth|bch|bitcoin|https?|s?ftp|magnet|tor|onion|tg):(.*)$/i
const emailPattern = /^(mailto):[^@]+@[^@]+\.[^@]+$/i

Expand All @@ -27,10 +27,12 @@ renderer.link = function (href, title, text) {
return text
}

renderer.heading = function (text) {
renderer.heading = function ({ text }) {
return `<p>${text}</p>`
}

marked.use({ renderer })

/**
* Sanitizes text to show HTML
* @param {string} text text to sanitize
Expand All @@ -46,7 +48,7 @@ export function sanitizeHTML(text = '') {
* @returns {string} resulting sanitized HTML
*/
export function renderMarkdown(text = '') {
return marked(DOMPurify.sanitize(text), { renderer })
return marked.parse(sanitizeHTML(text))
}

/**
Expand All @@ -58,15 +60,15 @@ export function renderMarkdown(text = '') {
export function removeFormats(text = '') {
const node = document.createElement('div')
const textWithSymbol = text.replace(/\n/g, '↵ ')
node.innerHTML = marked(DOMPurify.sanitize(textWithSymbol), { renderer })
node.innerHTML = marked.parse(sanitizeHTML(textWithSymbol))

return node.textContent || node.innerText || ''
}

export function formatMessage(text = '') {
const node = document.createElement('div')
const textWithSymbol = text.replace(/\n/g, '↵ ')
node.innerHTML = marked(DOMPurify.sanitize(textWithSymbol), { renderer })
node.innerHTML = marked.parse(sanitizeHTML(textWithSymbol))

const textWithoutHtml = node.textContent || node.innerText || ''
const styledText = textWithoutHtml.replace(//g, '<span class="arrow-return">↵</span>')
Expand Down
4 changes: 2 additions & 2 deletions src/lib/nodes/doge-indexer/DogeIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export class DogeIndexer extends Node<AxiosInstance> {
protected async checkHealth() {
const time = Date.now()
const height = await this.client
.get('/api/blocks?limit=0')
.then((res) => res.data.blocks[0].height)
.get('/api/status')
.then((res) => res.data.info.blocks)

return {
height,
Expand Down
77 changes: 62 additions & 15 deletions src/lib/uri.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { isAddress as isEthAddress, isHexStrict } from 'web3-utils'
import { validateBase32Address as isKlyAddress } from '@klayr/cryptography'
import { Cryptos, CryptosInfo } from './constants'

const KLAYR_WALLET = 'klayr://wallet'

/**
* Get an ADAMANT URI from the address bar or argv[]
* Complies with AIP-2, AIP-8, AIP-9
Expand All @@ -18,11 +20,68 @@ export function getAddressBarURI() {
return aip2 || document.URL
}

const formQueryParamsObject = (query) => {
return query.split('&').reduce((accum, param) => {
const [key, value = ''] = param.split('=')
return key && value
? {
...accum,
[key]: window.decodeURIComponent(
value.includes('+') ? value.replace(/\+/g, ' ') : value
)
}
: accum
}, {})
}

/**
* Parse info from an URI
* @param {string} uri URI. Default is address bar or argv[].
* @returns {
* {
* address: string,
* crypto: string,
* params: Object<string, string>,
* protocol: string
* }
* }
*/
export function parseURI(uri = getAddressBarURI()) {
const [origin, query = ''] = uri.split('?')
if (origin === KLAYR_WALLET) return parseKlyURI(query)
return parseURIasAIP(uri)
}

/**
* Parse info from an URI of the Klayr wallet
* Ex.: klayr://wallet?modal=send&recipient=klyap2bbanxn4agw286ofz85zf3y2brdzjdyoby8r&amount=123&token=0000000000000000&recipientChain=00000000
* @param {string} URI's query parameters
* @returns {
* {
* address: string,
* crypto: string,
* params: Object<string, string>,
* protocol: string
* }
* }
*/
function parseKlyURI(query) {
let address = ''
let params = {}

if (query) {
params = formQueryParamsObject(query)
address = params.recipient || ''
}

return { address, crypto: Cryptos.KLY, params, protocol: Cryptos.KLY.toLowerCase() }
}

/**
* Parse info from an URI containing a cryptocurrency address
* Complies with AIP-2, AIP-8, AIP-9
* Sample: https://msg.adamant.im?address=U9821606738809290000&label=John+Doe&amount=1.12&message=Buy+a+beer
* @param {string} uri URI. Default is address bar or argv[].
* @param {string} URI
* @returns {
* {
* address: string,
Expand All @@ -39,22 +98,10 @@ export function parseURIasAIP(uri = getAddressBarURI()) {
let params = Object.create(null)
let protocol = ''

if (query) {
params = query.split('&').reduce((accum, param) => {
const [key, value = ''] = param.split('=')
return key && value
? {
...accum,
[key]: window.decodeURIComponent(
value.includes('+') ? value.replace(/\+/g, ' ') : value
)
}
: accum
}, Object.create(null))
}
if (query) params = formQueryParamsObject(query)

if (origin.includes(':')) {
;[protocol, address] = origin.split(':')
[protocol, address] = origin.split(':')
if (protocol === 'ethereum') {
crypto = Cryptos.ETH
} else if (/^https?$/.test(protocol) || /^app$/.test(protocol)) {
Expand Down
11 changes: 10 additions & 1 deletion vite-base.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,16 @@ export default defineConfig({
include: []
},
rollupOptions: {
external: [...excludeBip39Wordlists()]
external: [...excludeBip39Wordlists()],
output: {
assetFileNames: (assetInfo) => {
if (assetInfo.name.startsWith('materialdesignicons-webfont')) {
return 'assets/[name][extname]'
}

return 'assets/[name]-[hash][extname]'
}
}
}
}
})
1 change: 1 addition & 0 deletions vite-pwa.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default mergeConfig(
manifest: manifest,
manifestFilename: 'manifest.json',
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg,wasm}'],
maximumFileSizeToCacheInBytes: 5000000 // 5 MiB
}
})
Expand Down
Loading