Send transaction ID to server after minting token
This commit is contained in:
parent
d8c0ed4737
commit
b574f9f390
2 changed files with 22 additions and 2 deletions
|
@ -82,6 +82,25 @@ export async function mintToken(
|
||||||
return transaction
|
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> {
|
export async function getTokenMetadata(url: string): Promise<TokenMetadata> {
|
||||||
const response = await http(url, {
|
const response = await http(url, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
|
|
|
@ -166,7 +166,7 @@
|
||||||
import { Options, Vue, setup } from "vue-class-component"
|
import { Options, Vue, setup } from "vue-class-component"
|
||||||
import { Prop } from "vue-property-decorator"
|
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 { Post, getPost, favourite, unfavourite, createRepost, deleteRepost } from "@/api/posts"
|
||||||
import Avatar from "@/components/Avatar.vue"
|
import Avatar from "@/components/Avatar.vue"
|
||||||
import CryptoAddress from "@/components/CryptoAddress.vue"
|
import CryptoAddress from "@/components/CryptoAddress.vue"
|
||||||
|
@ -384,7 +384,7 @@ export default class PostComponent extends Vue {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await mintToken(
|
const transaction = await mintToken(
|
||||||
instance.nft_contract_name,
|
instance.nft_contract_name,
|
||||||
instance.nft_contract_address,
|
instance.nft_contract_address,
|
||||||
currentUser.wallet_address,
|
currentUser.wallet_address,
|
||||||
|
@ -392,6 +392,7 @@ export default class PostComponent extends Vue {
|
||||||
signature,
|
signature,
|
||||||
signer,
|
signer,
|
||||||
)
|
)
|
||||||
|
await onTokenMinted(authToken, this.post.id, transaction.hash)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// User has rejected tx
|
// User has rejected tx
|
||||||
this.isWaitingForToken = false
|
this.isWaitingForToken = false
|
||||||
|
|
Loading…
Reference in a new issue