Stop using wallet_address property of User object
This commit is contained in:
parent
4902f089e6
commit
b455645173
3 changed files with 26 additions and 28 deletions
|
@ -31,18 +31,8 @@ export interface Profile {
|
||||||
subscription_page_url: string | null;
|
subscription_page_url: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getVerifiedEthereumAddress(profile: Profile): string | null {
|
|
||||||
for (const field of profile.identity_proofs) {
|
|
||||||
if (field.name === "$ETH") {
|
|
||||||
return field.value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface User extends Profile {
|
export interface User extends Profile {
|
||||||
source: Source;
|
source: Source;
|
||||||
wallet_address: string | null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProfileWrapper extends Profile {}
|
export interface ProfileWrapper extends Profile {}
|
||||||
|
@ -57,7 +47,12 @@ export class ProfileWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
getVerifiedEthereumAddress(): string | null {
|
getVerifiedEthereumAddress(): string | null {
|
||||||
return getVerifiedEthereumAddress(this)
|
for (const field of this.identity_proofs) {
|
||||||
|
if (field.name === "$ETH") {
|
||||||
|
return field.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
<router-link
|
<router-link
|
||||||
class="display-name"
|
class="display-name"
|
||||||
:to="{ name: 'profile', params: { profileId: post.account.id }}"
|
:to="{ name: 'profile', params: { profileId: post.account.id }}"
|
||||||
:title="getAuthorName()"
|
:title="author.getDisplayName()"
|
||||||
>
|
>
|
||||||
{{ getAuthorName() }}
|
{{ author.getDisplayName() }}
|
||||||
</router-link>
|
</router-link>
|
||||||
<div class="actor-address" :title="'@' + getActorAddress(post.account)">
|
<div class="actor-address" :title="'@' + getActorAddress(post.account)">
|
||||||
@{{ getActorAddress(post.account) }}
|
@{{ getActorAddress(post.account) }}
|
||||||
|
@ -203,7 +203,7 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
/* eslint-disable vue/no-mutating-props */
|
/* eslint-disable vue/no-mutating-props */
|
||||||
import { onMounted } from "vue"
|
import { onMounted } from "vue"
|
||||||
import { $, $ref } from "vue/macros"
|
import { $, $computed, $ref } from "vue/macros"
|
||||||
import { useRouter } from "vue-router"
|
import { useRouter } from "vue-router"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -223,6 +223,7 @@ import {
|
||||||
createRepost,
|
createRepost,
|
||||||
deleteRepost,
|
deleteRepost,
|
||||||
} from "@/api/posts"
|
} from "@/api/posts"
|
||||||
|
import { ProfileWrapper } from "@/api/users"
|
||||||
import Avatar from "@/components/Avatar.vue"
|
import Avatar from "@/components/Avatar.vue"
|
||||||
import CryptoAddress from "@/components/CryptoAddress.vue"
|
import CryptoAddress from "@/components/CryptoAddress.vue"
|
||||||
import PostEditor from "@/components/PostEditor.vue"
|
import PostEditor from "@/components/PostEditor.vue"
|
||||||
|
@ -266,6 +267,8 @@ 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 author = $computed(() => new ProfileWrapper(props.post.account))
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (postContentRef === null) {
|
if (postContentRef === null) {
|
||||||
return
|
return
|
||||||
|
@ -283,10 +286,6 @@ onMounted(() => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function getAuthorName(): string {
|
|
||||||
return props.post.account.display_name || props.post.account.username
|
|
||||||
}
|
|
||||||
|
|
||||||
function highlight(postId: string | null) {
|
function highlight(postId: string | null) {
|
||||||
emit("highlight", postId)
|
emit("highlight", postId)
|
||||||
}
|
}
|
||||||
|
@ -455,7 +454,7 @@ function canMintToken(): boolean {
|
||||||
Boolean(instance?.blockchain_features?.minter) &&
|
Boolean(instance?.blockchain_features?.minter) &&
|
||||||
props.post.account.id === currentUser?.id &&
|
props.post.account.id === currentUser?.id &&
|
||||||
props.post.visibility === "public" &&
|
props.post.visibility === "public" &&
|
||||||
Boolean(currentUser?.wallet_address) &&
|
author.getVerifiedEthereumAddress() !== null &&
|
||||||
!isTokenized() &&
|
!isTokenized() &&
|
||||||
!isWaitingForToken
|
!isWaitingForToken
|
||||||
)
|
)
|
||||||
|
@ -463,8 +462,6 @@ function canMintToken(): boolean {
|
||||||
|
|
||||||
async function onMintToken() {
|
async function onMintToken() {
|
||||||
if (
|
if (
|
||||||
!currentUser ||
|
|
||||||
!currentUser.wallet_address ||
|
|
||||||
!instance ||
|
!instance ||
|
||||||
!instance.blockchain_contract_address
|
!instance.blockchain_contract_address
|
||||||
) {
|
) {
|
||||||
|
@ -473,6 +470,10 @@ async function onMintToken() {
|
||||||
if (isTokenized() || isWaitingForToken) {
|
if (isTokenized() || isWaitingForToken) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const authorAddress = author.getVerifiedEthereumAddress()
|
||||||
|
if (!authorAddress) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const authToken = ensureAuthToken()
|
const authToken = ensureAuthToken()
|
||||||
isWaitingForToken = true
|
isWaitingForToken = true
|
||||||
if (props.post.ipfs_cid === null) {
|
if (props.post.ipfs_cid === null) {
|
||||||
|
@ -498,7 +499,7 @@ async function onMintToken() {
|
||||||
const transaction = await mintToken(
|
const transaction = await mintToken(
|
||||||
instance.blockchain_contract_address,
|
instance.blockchain_contract_address,
|
||||||
signer,
|
signer,
|
||||||
currentUser.wallet_address,
|
authorAddress,
|
||||||
tokenUri,
|
tokenUri,
|
||||||
signature,
|
signature,
|
||||||
)
|
)
|
||||||
|
|
|
@ -74,7 +74,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="name-buttons-group">
|
<div class="name-buttons-group">
|
||||||
<div class="name-group">
|
<div class="name-group">
|
||||||
<div class="display-name">{{ profile.display_name || profile.username }}</div>
|
<div class="display-name">{{ profile.getDisplayName() }}</div>
|
||||||
<div class="actor-address">@{{ actorAddress }}</div>
|
<div class="actor-address">@{{ actorAddress }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
|
@ -211,9 +211,9 @@ import {
|
||||||
createIdentityProof,
|
createIdentityProof,
|
||||||
getIdentityClaim,
|
getIdentityClaim,
|
||||||
getProfile,
|
getProfile,
|
||||||
getVerifiedEthereumAddress,
|
|
||||||
Profile,
|
Profile,
|
||||||
ProfileField,
|
ProfileField,
|
||||||
|
ProfileWrapper,
|
||||||
} from "@/api/users"
|
} from "@/api/users"
|
||||||
import Avatar from "@/components/Avatar.vue"
|
import Avatar from "@/components/Avatar.vue"
|
||||||
import PostList from "@/components/PostList.vue"
|
import PostList from "@/components/PostList.vue"
|
||||||
|
@ -233,7 +233,7 @@ const {
|
||||||
} = $(useCurrentUser())
|
} = $(useCurrentUser())
|
||||||
const { instance, getActorAddress } = $(useInstanceInfo())
|
const { instance, getActorAddress } = $(useInstanceInfo())
|
||||||
|
|
||||||
let profile = $ref<Profile | null>(null)
|
let profile = $ref<ProfileWrapper | null>(null)
|
||||||
let relationship = $ref<Relationship | null>(null)
|
let relationship = $ref<Relationship | null>(null)
|
||||||
|
|
||||||
let profileMenuVisible = $ref(false)
|
let profileMenuVisible = $ref(false)
|
||||||
|
@ -244,10 +244,11 @@ let followList = $ref<Profile[]>([])
|
||||||
let followListNextPageUrl = $ref<string | null>(null)
|
let followListNextPageUrl = $ref<string | null>(null)
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
profile = await getProfile(
|
const _profile = await getProfile(
|
||||||
authToken,
|
authToken,
|
||||||
route.params.profileId as string,
|
route.params.profileId as string,
|
||||||
)
|
)
|
||||||
|
profile = new ProfileWrapper(_profile)
|
||||||
if (currentUser && !isCurrentUser()) {
|
if (currentUser && !isCurrentUser()) {
|
||||||
relationship = await getRelationship(
|
relationship = await getRelationship(
|
||||||
ensureAuthToken(),
|
ensureAuthToken(),
|
||||||
|
@ -443,7 +444,8 @@ function canManageSubscriptions(): boolean {
|
||||||
return (
|
return (
|
||||||
Boolean(instance?.blockchain_contract_address) &&
|
Boolean(instance?.blockchain_contract_address) &&
|
||||||
Boolean(instance?.blockchain_features?.subscription) &&
|
Boolean(instance?.blockchain_features?.subscription) &&
|
||||||
Boolean(currentUser?.wallet_address) &&
|
profile !== null &&
|
||||||
|
profile.getVerifiedEthereumAddress() !== null &&
|
||||||
isCurrentUser()
|
isCurrentUser()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -453,7 +455,7 @@ function canSubscribe(): boolean {
|
||||||
Boolean(instance?.blockchain_contract_address) &&
|
Boolean(instance?.blockchain_contract_address) &&
|
||||||
Boolean(instance?.blockchain_features?.subscription) &&
|
Boolean(instance?.blockchain_features?.subscription) &&
|
||||||
profile !== null &&
|
profile !== null &&
|
||||||
getVerifiedEthereumAddress(profile) !== null &&
|
profile.getVerifiedEthereumAddress() !== null &&
|
||||||
profile.subscription_page_url !== null &&
|
profile.subscription_page_url !== null &&
|
||||||
!isCurrentUser()
|
!isCurrentUser()
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue