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

fix: waiting times for mint #11088

Merged
merged 4 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 9 additions & 6 deletions composables/autoTeleport/useAutoTeleportTransitionDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ export default function (
)

const needsSourceChainBalances = computed(
() => !hasEnoughInCurrentChain.value,
() => !hasEnoughInCurrentChain.value && !hasSourceChainBalances.value,
)

const actionAutoFees = computed(() =>
fees.actionAutoFees
? fees.forceActionAutoFees || needsSourceChainBalances.value
? fees.forceActionAutoFees || !hasEnoughInCurrentChain.value
: false,
)

const sourceChainsBalances = computed<{ [key: Chain]: string }>(() =>
const sourceChainsBalances = computed<Record<Chain, string>>(() =>
allowedSourceChains.value.reduce(
(reducer, chainPrefix) => ({
...reducer,
Expand All @@ -114,11 +114,14 @@ export default function (
),
)

const hasSourceChainBalances = computed(
() => Object.values(sourceChainsBalances.value).every(Boolean),
)

const hasBalances = computed(
() =>
(Boolean(currentChainBalance.value)
&& Object.values(sourceChainsBalances.value).every(Boolean))
|| hasFetched.balances,
(Boolean(currentChainBalance.value) && hasSourceChainBalances.value)
|| hasFetched.balances,
)

const richestChain = computed<Chain | undefined>(
Expand Down
10 changes: 2 additions & 8 deletions composables/useMultipleBalance.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { ApiPromise, WsProvider } from '@polkadot/api'
import { decodeAddress, encodeAddress } from '@polkadot/util-crypto'
import { storeToRefs } from 'pinia'
import {
CHAINS,
ENDPOINT_MAP,
type ChainProperties,
type Prefix,
} from '@kodadot1/static'
Expand Down Expand Up @@ -59,6 +57,7 @@ export default function (refetchPeriodically: boolean = false) {
const fiatStore = useFiatStore()
const { existentialDeposit } = useChain()
const { getEvmBalance: fetchEvmBalance } = useBalance()
const { apiInstanceByPrefix } = useApi()

const {
multiBalances,
Expand Down Expand Up @@ -113,20 +112,15 @@ export default function (refetchPeriodically: boolean = false) {
}) {
const publicKey = decodeAddress(address)
const prefixAddress = encodeAddress(publicKey, chain.ss58Format)
const wsProvider = new WsProvider(ENDPOINT_MAP[prefix])

const api = await ApiPromise.create({
provider: wsProvider,
})
const api = await apiInstanceByPrefix(prefix)

const balance = await getNativeBalance({
address: prefixAddress,
api: api,
tokenId,
})

await wsProvider.disconnect()

return { balance: balance.toString(), prefixAddress }
}

Expand Down
Loading