Always use first blockchain from "blockchains" property of instance info object
This commit is contained in:
parent
cf23d9b8d3
commit
8e601b3180
12 changed files with 32 additions and 22 deletions
|
@ -16,7 +16,7 @@ interface ChainMetadata {
|
||||||
explorer_url: string | null;
|
explorer_url: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface BlockchainInfo {
|
export interface BlockchainInfo {
|
||||||
chain_id: string;
|
chain_id: string;
|
||||||
chain_metadata: ChainMetadata | null;
|
chain_metadata: ChainMetadata | null;
|
||||||
contract_address: string | null;
|
contract_address: string | null;
|
||||||
|
|
|
@ -285,7 +285,7 @@ interface PaymentOption {
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { currentUser, ensureAuthToken } = $(useCurrentUser())
|
const { currentUser, ensureAuthToken } = $(useCurrentUser())
|
||||||
const { instance, getActorAddress } = $(useInstanceInfo())
|
const { getActorAddress, getBlockchainInfo, instance } = $(useInstanceInfo())
|
||||||
|
|
||||||
/* eslint-disable-next-line no-undef */
|
/* eslint-disable-next-line no-undef */
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
|
@ -307,7 +307,7 @@ let menuVisible = $ref(false)
|
||||||
let selectedPaymentAddress = $ref<string | null>(null)
|
let selectedPaymentAddress = $ref<string | null>(null)
|
||||||
let isWaitingForToken = $ref(false)
|
let isWaitingForToken = $ref(false)
|
||||||
|
|
||||||
const blockchain = $computed(() => instance?.blockchains[0])
|
const blockchain = $computed(() => getBlockchainInfo())
|
||||||
const author = $computed(() => new ProfileWrapper(props.post.account))
|
const author = $computed(() => new ProfileWrapper(props.post.account))
|
||||||
|
|
||||||
function openProfile(event: Event, profile: Mention | Profile) {
|
function openProfile(event: Event, profile: Mention | Profile) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ const {
|
||||||
endUserSession,
|
endUserSession,
|
||||||
ensureAuthToken,
|
ensureAuthToken,
|
||||||
} = $(useCurrentUser())
|
} = $(useCurrentUser())
|
||||||
const { instance } = $(useInstanceInfo())
|
const { getBlockchainInfo } = $(useInstanceInfo())
|
||||||
const { loadNotifications, getUnreadNotificationCount } = $(useNotifications())
|
const { loadNotifications, getUnreadNotificationCount } = $(useNotifications())
|
||||||
const { loadTheme } = useTheme()
|
const { loadTheme } = useTheme()
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ const unreadNotificationCount = $computed<number>(() => {
|
||||||
})
|
})
|
||||||
|
|
||||||
function canManageSubscriptions(): boolean {
|
function canManageSubscriptions(): boolean {
|
||||||
const blockchain = instance?.blockchains[0]
|
const blockchain = getBlockchainInfo()
|
||||||
const isSubscriptionsFeatureEnabled = Boolean(blockchain?.features.subscriptions)
|
const isSubscriptionsFeatureEnabled = Boolean(blockchain?.features.subscriptions)
|
||||||
return (
|
return (
|
||||||
isSubscriptionsFeatureEnabled &&
|
isSubscriptionsFeatureEnabled &&
|
||||||
|
|
|
@ -137,7 +137,7 @@ const props = defineProps<{
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { currentUser } = $(useCurrentUser())
|
const { currentUser } = $(useCurrentUser())
|
||||||
const { instance } = $(useInstanceInfo())
|
const { getBlockchainInfo } = $(useInstanceInfo())
|
||||||
const { connectWallet: connectEthereumWallet } = useWallet()
|
const { connectWallet: connectEthereumWallet } = useWallet()
|
||||||
const recipient = new ProfileWrapper(props.profile)
|
const recipient = new ProfileWrapper(props.profile)
|
||||||
const recipientEthereumAddress = recipient.getVerifiedEthereumAddress()
|
const recipientEthereumAddress = recipient.getVerifiedEthereumAddress()
|
||||||
|
@ -159,7 +159,7 @@ onMounted(() => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const blockchain = $computed(() => instance?.blockchains[0])
|
const blockchain = $computed(() => getBlockchainInfo())
|
||||||
|
|
||||||
function canConnectWallet(): boolean {
|
function canConnectWallet(): boolean {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -110,7 +110,7 @@ import { ethereumAddressMatch } from "@/utils/ethereum"
|
||||||
|
|
||||||
const { ensureAuthToken, ensureCurrentUser, setCurrentUser } = $(useCurrentUser())
|
const { ensureAuthToken, ensureCurrentUser, setCurrentUser } = $(useCurrentUser())
|
||||||
const { verifyEthereumAddress } = useEthereumAddressVerification()
|
const { verifyEthereumAddress } = useEthereumAddressVerification()
|
||||||
const { instance } = $(useInstanceInfo())
|
const { getBlockchainInfo } = $(useInstanceInfo())
|
||||||
const { connectWallet: connectEthereumWallet, getSigner } = useWallet()
|
const { connectWallet: connectEthereumWallet, getSigner } = useWallet()
|
||||||
const subscriptionPrice = $ref<number>(1)
|
const subscriptionPrice = $ref<number>(1)
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ let subscriptionState = $ref<SubscriptionState | null>(null)
|
||||||
let subscriptions = $ref<Subscription[]>([])
|
let subscriptions = $ref<Subscription[]>([])
|
||||||
let subscriberAddress = $ref<string | null>(null)
|
let subscriberAddress = $ref<string | null>(null)
|
||||||
|
|
||||||
const blockchain = $computed(() => instance?.blockchains[0])
|
const blockchain = $computed(() => getBlockchainInfo())
|
||||||
const profile = $computed(() => new ProfileWrapper(ensureCurrentUser()))
|
const profile = $computed(() => new ProfileWrapper(ensureCurrentUser()))
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { ref } from "vue"
|
import { ref } from "vue"
|
||||||
|
|
||||||
import { InstanceInfo, getInstanceInfo } from "@/api/instance"
|
import { BlockchainInfo, InstanceInfo, getInstanceInfo } from "@/api/instance"
|
||||||
import { Mention } from "@/api/posts"
|
import { Mention } from "@/api/posts"
|
||||||
import { Profile } from "@/api/users"
|
import { Profile } from "@/api/users"
|
||||||
|
|
||||||
|
@ -23,9 +23,14 @@ export function useInstanceInfo() {
|
||||||
return `${profile.username}@${instance.value.uri}`
|
return `${profile.username}@${instance.value.uri}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getBlockchainInfo(): BlockchainInfo | null {
|
||||||
|
return instance.value?.blockchains[0] || null
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
instance,
|
instance,
|
||||||
loadInstanceInfo,
|
loadInstanceInfo,
|
||||||
getActorAddress,
|
getActorAddress,
|
||||||
|
getBlockchainInfo,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@ function disconnectWallet() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function connectWallet(): Promise<void> {
|
async function connectWallet(): Promise<void> {
|
||||||
const { instance } = useInstanceInfo()
|
const { getBlockchainInfo } = useInstanceInfo()
|
||||||
const blockchain = instance.value?.blockchains[0]
|
const blockchain = getBlockchainInfo()
|
||||||
if (!blockchain) {
|
if (!blockchain) {
|
||||||
throw new Error("blockchain integration disabled")
|
throw new Error("blockchain integration disabled")
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ import {
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { setCurrentUser, setAuthToken } = useCurrentUser()
|
const { setCurrentUser, setAuthToken } = useCurrentUser()
|
||||||
const { instance } = $(useInstanceInfo())
|
const { getBlockchainInfo, instance } = $(useInstanceInfo())
|
||||||
|
|
||||||
const isRegistered = $ref(true)
|
const isRegistered = $ref(true)
|
||||||
const username = $ref("")
|
const username = $ref("")
|
||||||
|
@ -135,7 +135,7 @@ function isWalletRequired(): boolean {
|
||||||
if (!instance) {
|
if (!instance) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
const blockchain = instance?.blockchains[0]
|
const blockchain = getBlockchainInfo()
|
||||||
return Boolean(blockchain?.features.gate)
|
return Boolean(blockchain?.features.gate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,11 @@ import { formatDate } from "@/utils/dates"
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { currentUser, authToken } = $(useCurrentUser())
|
const { currentUser, authToken } = $(useCurrentUser())
|
||||||
const { instance, getActorAddress } = $(useInstanceInfo())
|
const {
|
||||||
|
getActorAddress,
|
||||||
|
getBlockchainInfo,
|
||||||
|
instance,
|
||||||
|
} = $(useInstanceInfo())
|
||||||
|
|
||||||
let post = $ref<Post | null>(null)
|
let post = $ref<Post | null>(null)
|
||||||
let token = $ref<TokenMetadata | null>(null)
|
let token = $ref<TokenMetadata | null>(null)
|
||||||
|
@ -99,7 +103,8 @@ const actorAddress = $computed<string>(() => {
|
||||||
})
|
})
|
||||||
|
|
||||||
const transactionUrl = $computed<string | null>(() => {
|
const transactionUrl = $computed<string | null>(() => {
|
||||||
const explorerUrl = instance?.blockchains[0]?.chain_metadata?.explorer_url
|
const blockchain = getBlockchainInfo()
|
||||||
|
const explorerUrl = blockchain?.chain_metadata?.explorer_url
|
||||||
if (!explorerUrl || !post?.token_tx_id) {
|
if (!explorerUrl || !post?.token_tx_id) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
|
@ -306,7 +306,7 @@ const {
|
||||||
ensureAuthToken,
|
ensureAuthToken,
|
||||||
} = $(useCurrentUser())
|
} = $(useCurrentUser())
|
||||||
const { verifyEthereumAddress } = useEthereumAddressVerification()
|
const { verifyEthereumAddress } = useEthereumAddressVerification()
|
||||||
const { instance, getActorAddress } = $(useInstanceInfo())
|
const { getActorAddress, getBlockchainInfo } = $(useInstanceInfo())
|
||||||
|
|
||||||
let profile = $ref<ProfileWrapper | null>(null)
|
let profile = $ref<ProfileWrapper | null>(null)
|
||||||
let relationship = $ref<Relationship | null>(null)
|
let relationship = $ref<Relationship | null>(null)
|
||||||
|
@ -561,7 +561,7 @@ async function onSignActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSubscriptionsFeatureEnabled(): boolean {
|
function isSubscriptionsFeatureEnabled(): boolean {
|
||||||
const blockchain = instance?.blockchains[0]
|
const blockchain = getBlockchainInfo()
|
||||||
return Boolean(blockchain?.features.subscriptions)
|
return Boolean(blockchain?.features.subscriptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,10 @@ import { useCurrentUser } from "@/composables/user"
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const { authToken } = $(useCurrentUser())
|
const { authToken } = $(useCurrentUser())
|
||||||
const { instance } = $(useInstanceInfo())
|
const { getBlockchainInfo } = $(useInstanceInfo())
|
||||||
let profile = $ref<Profile | null>(null)
|
let profile = $ref<Profile | null>(null)
|
||||||
|
|
||||||
const blockchain = $computed(() => instance?.blockchains[0])
|
const blockchain = $computed(() => getBlockchainInfo())
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// Recipient
|
// Recipient
|
||||||
|
|
|
@ -16,9 +16,9 @@ import SubscriptionSettingsEthereum from "@/components/SubscriptionSettingsEther
|
||||||
import SubscriptionSettingsMonero from "@/components/SubscriptionSettingsMonero.vue"
|
import SubscriptionSettingsMonero from "@/components/SubscriptionSettingsMonero.vue"
|
||||||
import { useInstanceInfo } from "@/composables/instance"
|
import { useInstanceInfo } from "@/composables/instance"
|
||||||
|
|
||||||
const { instance } = $(useInstanceInfo())
|
const { getBlockchainInfo } = $(useInstanceInfo())
|
||||||
|
|
||||||
const blockchain = $computed(() => instance?.blockchains[0])
|
const blockchain = $computed(() => getBlockchainInfo())
|
||||||
|
|
||||||
function isEthereum(): boolean {
|
function isEthereum(): boolean {
|
||||||
if (!blockchain) {
|
if (!blockchain) {
|
||||||
|
|
Loading…
Reference in a new issue