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

Upgrade Lisk #567

Merged
merged 30 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8361583
refactor(lisk): rewrite `lisk-utils` to TypeScript
bludnic Nov 27, 2023
15be6ba
refactor(lisk): move `getAccount()` to `lisk-utils`
bludnic Nov 27, 2023
91fff37
fix(`jest`): fix config name in testing environment
bludnic Nov 27, 2023
c29a220
fix(`jest`): update old structured `test.json` config
bludnic Nov 27, 2023
35cb37c
test(): add unit tests for `lisk-utils`
bludnic Nov 27, 2023
022fd7c
Merge branch 'dev' into feat/upgrade-lisk
bludnic Nov 28, 2023
e11a6ce
fix(`lisk-utils`): Lisk API changed
bludnic Nov 28, 2023
a1613ac
Draft
bludnic Nov 29, 2023
40d004e
Draft2
bludnic Nov 29, 2023
58434f7
Refactor
bludnic Nov 29, 2023
91a0395
feat: migrate Lisk Node API to v4
bludnic Dec 9, 2023
990ea0a
chore(package.json): add missing types
bludnic Dec 9, 2023
ad46845
feat(SendFundsForm): add `dryRun` checkbox for debugging
bludnic Dec 9, 2023
3a898c2
feat: migrate lisk service from v2 to v3
bludnic Dec 12, 2023
c6fd58b
chore: update package-lock.json
bludnic Dec 12, 2023
5ab5383
chore(`sodium-browserify-tweetnacl`): add missing types
bludnic Dec 12, 2023
d9e2bed
fix(lsk): fix tx id
bludnic Dec 12, 2023
2780f1d
fix(LskClient): `getBalance()` must return a number
bludnic Dec 13, 2023
ab1bee9
feat(lisk-utils): add `estimateFee()` for LSK
bludnic Dec 13, 2023
4544330
feat(tests, lisk-api): remove unused imports
bludnic Dec 13, 2023
f006da4
refactor(`lisk-account`): remove redundant types
bludnic Dec 14, 2023
a4593ac
refactor: remove `lisk-api` (use `lisk-account` instead)
bludnic Dec 14, 2023
be180da
Merge pull request #58 from Adamant-im/dev
bludnic Dec 19, 2023
fc335a8
feat(SendsFunds): include `amount` and `data` in LSK fee calculation
bludnic Dec 19, 2023
7f2f898
feat(LSK): apply additional fee of 0.05 LSK if account doesn't exist
bludnic Dec 19, 2023
1f9ce35
test(lisk-utils): fix BigInt
bludnic Dec 19, 2023
ce85102
fix(SendFundsForm, LSK): change then/catch order
bludnic Dec 19, 2023
f7804e2
refactor(LSK): refactor todos
bludnic Dec 22, 2023
84dd30a
refactor(LSK): use min fee from adamant-wallets & rename LSK_COMMAND_FEE
bludnic Dec 22, 2023
a113209
fix(Transactions): fix infinite scroll
bludnic Dec 22, 2023
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
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