Skip to content

Commit

Permalink
feat: replace LSK with KLY
Browse files Browse the repository at this point in the history
  • Loading branch information
bludnic committed Jun 24, 2024
1 parent 36de0b7 commit eb19ad8
Show file tree
Hide file tree
Showing 75 changed files with 302 additions and 490 deletions.
130 changes: 0 additions & 130 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@
"@klayr/cryptography": "^4.0.2",
"@klayr/transactions": "^6.0.2",
"@klayr/validator": "^0.8.2",
"@liskhq/lisk-codec": "^0.5.0",
"@liskhq/lisk-cryptography": "4.1.0",
"@liskhq/lisk-transactions": "6.1.0",
"@liskhq/lisk-validator": "^0.9.0",
"@mdi/font": "^7.4.47",
"@stablelib/utf8": "^1.0.2",
"@zxing/browser": "^0.1.4",
Expand Down Expand Up @@ -208,7 +204,7 @@
"cryptocurrency",
"doge",
"dash",
"lisk",
"klayr",
"erc20",
"business",
"2fa"
Expand Down
10 changes: 5 additions & 5 deletions src/components/ExportKeysForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ import { validateMnemonic } from 'bip39'
import copyToClipboard from 'copy-to-clipboard'
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-utils'
import { getAccount as getKlyAccount } from '@/lib/klayr/klayr-utils'
import { Cryptos, CryptosInfo } from '@/lib/constants'
import QrcodeCapture from '@/components/QrcodeCapture.vue'
import QrcodeScannerDialog from '@/components/QrcodeScannerDialog.vue'
Expand All @@ -122,8 +122,8 @@ function getBtcKey(crypto, passphrase, asWif) {
}
}
function getLskKey(crypto, passphrase) {
const keyPair = getLskAccount(crypto, passphrase).keyPair
function getKlyKey(crypto, passphrase) {
const keyPair = getKlyAccount(crypto, passphrase).keyPair
const key = keyPair.secretKey.toString('hex')
return {
Expand Down Expand Up @@ -184,9 +184,9 @@ export default defineComponent({
const dash = getBtcKey(Cryptos.DASH, passphrase.value, false)
const doge = getBtcKey(Cryptos.DOGE, passphrase.value, true)
const lsk = getLskKey(Cryptos.LSK, passphrase.value)
const kly = getKlyKey(Cryptos.KLY, passphrase.value)
keys.value = [bitcoin, eth, doge, dash, lsk]
keys.value = [bitcoin, eth, doge, dash, kly]
}, 0)
}
const copyKey = (key) => {
Expand Down
8 changes: 4 additions & 4 deletions src/components/SendFundsForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@

<script>
import { adm } from '@/lib/nodes'
import lskIndexer from '@/lib/nodes/lsk-indexer'
import klyIndexer from '@/lib/nodes/kly-indexer'
import { AllNodesOfflineError } from '@/lib/nodes/utils/errors'
import { PendingTransactionError } from '@/lib/pending-transactions'
import axios from 'axios'
Expand Down Expand Up @@ -312,7 +312,7 @@ export default {
warningOnPartnerInfo: {},
// Account exists check
// Currently works only with LSK
// Currently works only with KLY
account: {
isNew: false,
abortController: new AbortController(),
Expand Down Expand Up @@ -608,9 +608,9 @@ export default {
this.account.abortController = new AbortController()
switch (this.currency) {
case Cryptos.LSK:
case Cryptos.KLY:
this.account.loading = true
lskIndexer
klyIndexer
.checkAccountExists(cryptoAddress, {
signal: this.account.abortController.signal
})
Expand Down
10 changes: 0 additions & 10 deletions src/components/icons/cryptos/LskIcon.vue

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:id="transaction.hash || ''"
:amount="currency(transaction.amount, crypto)"
:timestamp="transaction.timestamp || NaN"
:fee="currency(transaction.fee, 'LSK')"
:fee="currency(transaction.fee, 'KLY')"
:confirmations="confirmations || NaN"
:sender="sender || ''"
:recipient="recipient || ''"
Expand All @@ -29,7 +29,7 @@ import transaction from '@/mixins/transaction'
import currency from '@/filters/currencyAmountWithSymbol'
export default {
name: 'LskTransaction',
name: 'KlyTransaction',
components: {
TransactionTemplate
},
Expand Down Expand Up @@ -71,13 +71,13 @@ export default {
partner() {
if (this.transaction.partner) return this.transaction.partner
const id = !isStringEqualCI(this.transaction.senderId, this.$store.state.lsk.address)
const id = !isStringEqualCI(this.transaction.senderId, this.$store.state.kly.address)
? this.transaction.senderId
: this.transaction.recipientId
return this.getAdmAddress(id)
},
explorerLink() {
return getExplorerTxUrl(Cryptos.LSK, this.id)
return getExplorerTxUrl(Cryptos.KLY, this.id)
},
confirmations() {
const { height } = this.transaction
Expand Down Expand Up @@ -112,7 +112,7 @@ export default {
const partners = this.$store.state.partners.list
Object.keys(partners).some((uid) => {
const partner = partners[uid]
if (isStringEqualCI(partner[Cryptos.LSK], address)) {
if (isStringEqualCI(partner[Cryptos.KLY], address)) {
admAddress = uid
}
return !!admAddress
Expand Down Expand Up @@ -140,7 +140,7 @@ export default {
const admAddress = this.getAdmAddress(address)
let name = ''
if (isStringEqualCI(address, this.$store.state.lsk.address)) {
if (isStringEqualCI(address, this.$store.state.kly.address)) {
name = this.$t('transaction.me')
} else {
name = this.getPartnerName(admAddress)
Expand Down
2 changes: 1 addition & 1 deletion src/config/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
},
"services": {
"list": {
"lskService": [
"klyService": [
{
"url": "https://testnet-service.klayr.xyz"
}
Expand Down
2 changes: 1 addition & 1 deletion src/config/production.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
},
"services": {
"list": {
"lskService": [
"klyService": [
{
"url": "https://testnet-service.klayr.xyz"
}
Expand Down
2 changes: 1 addition & 1 deletion src/config/tor.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
},
"services": {
"list": {
"lskService": [
"klyService": [
{
"url": "https://testnet-service.klayr.xyz"
}
Expand Down
8 changes: 4 additions & 4 deletions src/lib/__tests__/lisk/__snapshots__/lisk-utils.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`lisk-utils > getAccount > should generate account from passphrase 1`] = `
exports[`klayr-utils > getAccount > should generate account from passphrase 1`] = `
{
"address": "lskkjurzk3xb47scma49ukyqupn8vrg2ggyuehk5j",
"address": "klykjurzk3xb47scma49ukyqupn8vrg2ggyuehk5j",
"addressHex": "a721205101325db197296c291ac08778a5fc7ff1",
"addressHexBinary": {
"data": [
Expand Down Expand Up @@ -139,9 +139,9 @@ exports[`lisk-utils > getAccount > should generate account from passphrase 1`] =
},
},
"network": {
"name": "Lisk",
"name": "Klayr",
"port": 8000,
"unit": "LSK",
"unit": "KLY",
"wsPort": 8001,
},
}
Expand Down
12 changes: 6 additions & 6 deletions src/lib/__tests__/lisk/lisk-utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
// @vitest-environment node
// Some crypto libs throw errors when using `jsdom` environment

import { LSK_MIN_FEE_PER_BYTE } from '@/lib/lisk'
import { convertBeddowsToLSK } from '@liskhq/lisk-transactions'
import { KLY_MIN_FEE_PER_BYTE } from '@/lib/klayr'
import { convertBeddowsToKLY } from '@klayr/transactions'
import { describe, it, expect } from 'vitest'
import { Cryptos } from '@/lib/constants'
import { estimateFee, getAccount } from '@/lib/lisk/lisk-utils'
import { estimateFee, getAccount } from '@/lib/klayr/klayr-utils'

const passphrase = 'joy mouse injury soft decade bid rough about alarm wreck season sting'

describe('lisk-utils', () => {
describe('getAccount', () => {
it('should generate account from passphrase', () => {
expect(getAccount(Cryptos.LSK, passphrase)).toMatchSnapshot()
expect(getAccount(Cryptos.KLY, passphrase)).toMatchSnapshot()
})
})

describe('estimateFee', () => {
it('should calculate fee including `data`', () => {
const data = 'hello'
const minimalFee = BigInt(165000)
const messageFee = BigInt(data.length) * BigInt(LSK_MIN_FEE_PER_BYTE)
const messageFee = BigInt(data.length) * BigInt(KLY_MIN_FEE_PER_BYTE)
const expectedFee = minimalFee + messageFee

expect(estimateFee({ data })).toBe(convertBeddowsToLSK(expectedFee.toString()))
expect(estimateFee({ data })).toBe(convertBeddowsToKLY(expectedFee.toString()))
})
})
})
2 changes: 1 addition & 1 deletion src/lib/chat/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ export const KnownCryptos = Object.keys(Cryptos).reduce((map, crypto) => {

/** Cryptos, supported by other clients, but not PWA */
export const UnsupportedCryptos = {
lsk_transaction: 'LSK'
kly_transaction: 'KLY'
}
Loading

0 comments on commit eb19ad8

Please sign in to comment.