Skip to content

Commit

Permalink
feat: add new env for usdt token id and some minor validation in form (
Browse files Browse the repository at this point in the history
…#598)

* feat: add new env for usdt token id

* feat: add validations on purchase link on service add and detail

Co-authored-by: ciniaeleonora <[email protected]>
  • Loading branch information
ciniiia and ciniaeleonora authored Dec 5, 2022
1 parent 5e42d37 commit e7b29cf
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
1 change: 1 addition & 0 deletions .env-template
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ VUE_APP_MIXPANEL_TOKEN=
VUE_APP_SENTRY_DSN=
VUE_APP_PINATA_GATEWAY=
VUE_APP_PINATA_JWT_KEY=
VUE_APP_DEBIO_USDT_TOKEN_ID=
VUE_APP_PINATA_REQUIRED_DOCUMENT=
VUE_APP_OCTOPUS_EXPLORER=
1 change: 1 addition & 0 deletions .maintain/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ JSON_STRING='window.configs = { \
"VUE_APP_SENTRY_DSN":"'"${VUE_APP_SENTRY_DSN}"'", \
"VUE_APP_PINATA_GATEWAY":"'"${VUE_APP_PINATA_GATEWAY}"'", \
"VUE_APP_PINATA_JWT_KEY":"'"${VUE_APP_PINATA_JWT_KEY}"'", \
"VUE_APP_DEBIO_USDT_TOKEN_ID":"'"${VUE_APP_DEBIO_USDT_TOKEN_ID}"'", \
"VUE_APP_PINATA_REQUIRED_DOCUMENT":"'"${VUE_APP_PINATA_REQUIRED_DOCUMENT}"'", \
"VUE_APP_OCTOPUS_EXPLORER":"'"${VUE_APP_OCTOPUS_EXPLORER}"'" \
}'
Expand Down
17 changes: 13 additions & 4 deletions src/components/HeaderWallet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import {mapState, mapMutations, mapActions} from "vuex"
import {queryBalance} from "@/lib/polkadotProvider/query/balance"
import localStorage from "@/lib/local-storage"
import getEnv from "@/utils/env"
import { queryGetAssetBalance, queryGetAllOctopusAssets } from "@/lib/polkadotProvider/query/octopus-assets"
export default {
Expand All @@ -81,7 +82,6 @@ export default {
polkadotBalance: 0,
polkadotWallets: [
{
id: 0,
name: "debio",
icon: "debio-logo",
currency: "DBIO",
Expand All @@ -101,6 +101,14 @@ export default {
octopusAsset: []
}),
created() {
this.polkadotWallets.forEach(wallet => {
if(wallet.name ==="usdt") {
wallet.tokenId = getEnv("VUE_APP_DEBIO_USDT_TOKEN_ID")
}
})
},
methods: {
...mapMutations({
setWalletBalance: "substrate/SET_WALLET_BALANCE",
Expand All @@ -127,10 +135,10 @@ export default {
async getOctopusAssets() {
const assets = await queryGetAllOctopusAssets(this.api)
for (let i = 0; i < assets.length; i++) {
const name = assets[i][0].toHuman()[0]
const tokenId = assets[i][0].toHuman()[0]
const id = assets[i][1].toHuman()
const data = await queryGetAssetBalance(this.api, id, this.wallet.address)
const assetData = {id, data, name: name.split(".")[0]}
const assetData = {id, data, name: tokenId.split(".")[0], tokenId}
this.octopusAsset.push(assetData)
}
},
Expand All @@ -140,7 +148,8 @@ export default {
if (wallet.name !== "debio") {
const data = this.octopusAsset.find(a => a.name === wallet.name)
if (!data) return
wallet.balance = this.web3.utils.fromWei(data.data.balance.replaceAll(",", ""), wallet.unit)
const octopusData = this.octopusAsset.find(asset => asset.tokenId === wallet.tokenId )
wallet.balance = this.web3.utils.fromWei(octopusData.data.balance.replaceAll(",", ""), wallet.unit)
wallet.id = data.id
if (wallet.name === "usdt") this.setUSDTBalance(wallet.balance)
}
Expand Down
7 changes: 7 additions & 0 deletions src/views/Dashboard/Lab/Services/Add.vue
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
<label v-if="document.linkKit === 'yes'" style="font-size: 12px;"> Link to Purchase Kit </label>
<v-text-field
v-if="document.linkKit === 'yes'"
:rules="document.linkKit === 'yes' ? [...fieldRequiredRule, ...linkRules] : ''"
dense
:disabled="isLoading"
placeholder="kithub.com/collection/genome-sequencing/"
Expand Down Expand Up @@ -358,6 +359,12 @@ export default {
]
},
linkRules() {
return [
val => /^[-a-zA-Z0-9@:%._~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_.~#?&/=]*)/.test(val) || "Link is invalid"
]
},
serviceNameRules() {
return [
val => (val && val.length <= 50) || "This field only allows 50 characters."
Expand Down
7 changes: 7 additions & 0 deletions src/views/Dashboard/Lab/Services/Detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
v-if="document.linkKit === 'yes'"
dense
:disabled="isLoading || isUploading"
:rules="document.linkKit === 'yes' ? [...fieldRequiredRule, ...linkRules] : ''"
placeholder="kithub.com/collection/genome-sequencing/"
prepend-icon="mdi-file-document"
outlined
Expand Down Expand Up @@ -330,6 +331,12 @@ export default {
]
},
linkRules() {
return [
val => /^[-a-zA-Z0-9@:%._~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_.~#?&/=]*)/.test(val) || "Link is invalid"
]
},
fieldEnglishRules() {
return [ englishAlphabet ]
},
Expand Down

0 comments on commit e7b29cf

Please sign in to comment.