Send transaction ID to server after minting token

This commit is contained in:
silverpill 2021-12-03 18:42:27 +00:00
parent d8c0ed4737
commit b574f9f390
2 changed files with 22 additions and 2 deletions

View file

@ -82,6 +82,25 @@ export async function mintToken(
return transaction
}
export async function onTokenMinted(
authToken: string,
postId: string,
transactionId: string,
): Promise<Post> {
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<TokenMetadata> {
const response = await http(url, {
method: "GET",

View file

@ -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