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