Skip to content

Commit

Permalink
Merge pull request #567 from Adamant-im/feat/upgrade-lisk
Browse files Browse the repository at this point in the history
Upgrade Lisk
  • Loading branch information
bludnic authored Dec 22, 2023
2 parents 7469103 + a113209 commit 0d935bb
Show file tree
Hide file tree
Showing 46 changed files with 2,166 additions and 954 deletions.
143 changes: 103 additions & 40 deletions package-lock.json

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

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
},
"dependencies": {
"@emoji-mart/data": "^1.1.2",
"@liskhq/lisk-cryptography": "3.2.1",
"@liskhq/lisk-transactions": "5.2.2",
"@liskhq/lisk-codec": "^0.4.0",
"@liskhq/lisk-cryptography": "4.0.0",
"@liskhq/lisk-transactions": "6.0.0",
"@liskhq/lisk-validator": "^0.8.0",
"@mdi/font": "^7.3.67",
"@stablelib/utf8": "^1.0.1",
"@zxing/browser": "^0.1.4",
Expand Down Expand Up @@ -108,6 +110,8 @@
"@types/emoji-mart": "^3.0.12",
"@types/eslint": "^8.44.7",
"@types/marked": "^5.0.2",
"@types/pbkdf2": "^3.1.2",
"@types/uuid": "^9.0.7",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"@vitejs/plugin-vue": "^4.5.0",
Expand Down
2 changes: 1 addition & 1 deletion 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-api'
import { getAccount as getLskAccount } from '@/lib/lisk/lisk-utils'
import { Cryptos, CryptosInfo } from '@/lib/constants'
import QrcodeCapture from '@/components/QrcodeCapture.vue'
import QrcodeScannerDialog from '@/components/QrcodeScannerDialog.vue'
Expand Down
3 changes: 2 additions & 1 deletion src/components/LoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export default defineComponent({
.then(() => {
emit('login')
})
.catch(() => {
.catch((err) => {
console.log(err)
emit('error', 'login.invalid_passphrase')
})
.finally(() => {
Expand Down
64 changes: 61 additions & 3 deletions src/components/SendFundsForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
:label="$t('transfer.increase_fee')"
color="grey darken-1"
/>
<v-checkbox v-if="debug" v-model="dryRun" label="Dry run" color="grey darken-1" />

<div class="text-center">
<v-btn :class="`${className}__button`" class="a-btn-primary" @click="confirm">
Expand Down Expand Up @@ -185,6 +186,8 @@
</template>

<script>
import lskIndexer from '@/lib/nodes/lsk-indexer'
import axios from 'axios'
import { nextTick } from 'vue'
import QrcodeCapture from '@/components/QrcodeCapture.vue'
Expand Down Expand Up @@ -301,7 +304,19 @@ export default {
fetchAddress: null, // fn throttle
increaseFee: false,
showWarningOnPartnerAddressDialog: false,
warningOnPartnerInfo: {}
warningOnPartnerInfo: {},
// Account exists check
// Currently works only with LSK
account: {
isNew: false,
abortController: new AbortController(),
loading: false
},
// Debugging section
dryRun: false,
debug: !!localStorage.getItem('DEBUG')
}),
computed: {
className: () => 'send-funds-form',
Expand Down Expand Up @@ -529,6 +544,9 @@ export default {
} else {
this.amount = 0
}
},
cryptoAddress(cryptoAddress) {
this.checkIsNewAccount(cryptoAddress)
}
},
created() {
Expand All @@ -545,6 +563,44 @@ export default {
this.fetchUserCryptoAddress()
},
methods: {
checkIsNewAccount(cryptoAddress) {
this.account.isNew = false
if (!validateAddress(this.currency, cryptoAddress)) {
return
}
// Cancel the previous fetch request
this.account.abortController.abort()
// Create a new AbortController for the current request
this.account.abortController = new AbortController()
switch (this.currency) {
case Cryptos.LSK:
this.account.loading = true
lskIndexer
.checkAccountExists(cryptoAddress, {
signal: this.account.abortController.signal
})
.then((exists) => {
this.account.isNew = !exists
})
.catch((err) => {
if (axios.isCancel(err)) {
// Request canceled
return
}
throw err
})
.finally(() => {
this.account.loading = false
})
break
}
},
confirm() {
const abstract = validateForm.call(this)
Expand Down Expand Up @@ -711,7 +767,8 @@ export default {
fee: this.transferFee,
increaseFee: this.increaseFee,
textData: this.textData,
replyToId: this.replyToId
replyToId: this.replyToId,
dryRun: this.dryRun
})
}
},
Expand Down Expand Up @@ -790,7 +847,8 @@ export default {
this.$store.getters[`${this.currency.toLowerCase()}/fee`](
amount || this.balance,
this.cryptoAddress,
this.textData
this.textData,
this.account.isNew
)
)
}
Expand Down
Loading

0 comments on commit 0d935bb

Please sign in to comment.