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

➖ remove getSetting #5999

Merged
merged 11 commits into from
May 17, 2023
8 changes: 5 additions & 3 deletions composables/useApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import type { ApiPromise } from '@polkadot/api'
import { getChainEndpointByPrefix } from '@/utils/chain'

export default function () {
const { $store } = useNuxtApp()
const { urlPrefix } = usePrefix()

const apiUrl = computed(() => {
const endpoint = getChainEndpointByPrefix(urlPrefix.value)
return endpoint || $store.getters.getSettings['apiUrl']
const endpoint: string =
getChainEndpointByPrefix(urlPrefix.value) ||
getChainEndpointByPrefix('ksm') ||
''
roiLeo marked this conversation as resolved.
Show resolved Hide resolved
return endpoint
})

const apiInstance = computed<Promise<ApiPromise>>(() =>
Expand Down
3 changes: 0 additions & 3 deletions pages/_prefix/transfer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,6 @@ export default class Transfer extends mixins(
const availableNodesByPrefix: { value: string }[] =
this.$store.getters['availableNodesByPrefix']
const availableUrls = availableNodesByPrefix.map((node) => node.value)
if (usedNodeUrls.length === 0) {
usedNodeUrls.push(this.$store.getters.getSettings['apiUrl'])
}
if (usedNodeUrls.length < availableUrls.length) {
const nextTryUrls = availableUrls.filter(
(url) => !usedNodeUrls.includes(url)
Expand Down
15 changes: 1 addition & 14 deletions utils/WithKeyring.ts
vikiival marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { enableExtension } from '@/utils/extension'
import correctFormat from '@/utils/ss58Format'

import { isWeb3Injected, web3Accounts } from '@polkadot/extension-dapp'
import { getPrefixByStoreUrl } from '@/utils/chain'
import ChainMixin from './mixins/chainMixin'
import { useIdentityStore } from '@/stores/identity'

Expand Down Expand Up @@ -44,12 +43,8 @@ export default class WithKeyring extends ChainMixin {
ss58Format:
correctFormat(ss58Forever) >= 0
? correctFormat(ss58Forever)
: correctFormat(this.prefixByStore),
: correctFormat('0'),
roiLeo marked this conversation as resolved.
Show resolved Hide resolved
})

// if ((!this.accountId || ss58Changed) && this.importedAccounts?.length && process.env.VUE_APP_KEYRING) {
// this.$store.dispatch('setAuth', { address: this.importedAccounts[0]?.address });
// }
}

get identityStore() {
Expand All @@ -60,14 +55,6 @@ export default class WithKeyring extends ChainMixin {
return this.identityStore.getAuthAddress
}

get getSettings() {
return this.$store.getters.getSettings?.apiUrl
}

get prefixByStore() {
return correctFormat(getPrefixByStoreUrl(this.getSettings()))
}

public allAcctounts(): KeyringAccount[] {
return [...this.keyringAccounts, ...this.importedAccounts]
}
Expand Down
14 changes: 8 additions & 6 deletions utils/mixins/apiUrlMixin.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { Component, Vue } from 'nuxt-property-decorator'
import { Component, mixins } from 'nuxt-property-decorator'
import { getChainEndpointByPrefix } from '@/utils/chain'
import PrefixMixin from '@/utils/mixins/prefixMixin'

/*
* refer to https://stackoverflow.com/questions/51873087/unable-to-use-mixins-in-vue-with-typescript
* import { Component, Mixins } from 'nuxt-property-decorator';
* class ExtendedClass extends Mixins(ActualMixin) {
*/
@Component
export default class ApiUrlMixin extends Vue {
export default class ApiUrlMixin extends mixins(PrefixMixin) {
get apiUrl() {
const endpoint = getChainEndpointByPrefix(
this.$store.getters.currentUrlPrefix
)
return endpoint || this.$store.getters.getSettings['apiUrl']
const endpoint: string =
getChainEndpointByPrefix(this.urlPrefix) ||
vikiival marked this conversation as resolved.
Show resolved Hide resolved
getChainEndpointByPrefix('ksm') ||
''
roiLeo marked this conversation as resolved.
Show resolved Hide resolved
return endpoint
}
}