diff --git a/src/api/nft.ts b/src/api/nft.ts index 1730cfa..a9fae07 100644 --- a/src/api/nft.ts +++ b/src/api/nft.ts @@ -82,6 +82,25 @@ export async function mintToken( return transaction } +export async function onTokenMinted( + authToken: string, + postId: string, + transactionId: string, +): Promise { + const url = `${BACKEND_URL}/api/v1/statuses/${postId}/token_minted` + const response = await http(url, { + method: "POST", + json: { transaction_id: transactionId }, + authToken, + }) + const data = await response.json() + if (response.status !== 200) { + throw new Error(data.message) + } else { + return data + } +} + export async function getTokenMetadata(url: string): Promise { const response = await http(url, { method: "GET", diff --git a/src/components/Post.vue b/src/components/Post.vue index 38b997c..baeeefa 100644 --- a/src/components/Post.vue +++ b/src/components/Post.vue @@ -166,7 +166,7 @@ import { Options, Vue, setup } from "vue-class-component" import { Prop } from "vue-property-decorator" -import { makePermanent, getSignature, mintToken } from "@/api/nft" +import { makePermanent, getSignature, mintToken, onTokenMinted } from "@/api/nft" import { Post, getPost, favourite, unfavourite, createRepost, deleteRepost } from "@/api/posts" import Avatar from "@/components/Avatar.vue" import CryptoAddress from "@/components/CryptoAddress.vue" @@ -384,7 +384,7 @@ export default class PostComponent extends Vue { return } try { - await mintToken( + const transaction = await mintToken( instance.nft_contract_name, instance.nft_contract_address, currentUser.wallet_address, @@ -392,6 +392,7 @@ export default class PostComponent extends Vue { signature, signer, ) + await onTokenMinted(authToken, this.post.id, transaction.hash) } catch (error) { // User has rejected tx this.isWaitingForToken = false