From 615cfcf24cc067f4847b05af6f1774e8f40e4bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Brzezi=C5=84ski?= Date: Wed, 22 Mar 2023 02:46:29 +0100 Subject: [PATCH] fix mint instructions (#1492) --- components/Members/AddMemberForm.tsx | 2 +- hooks/useDestination.ts | 2 -- utils/instructionTools.ts | 7 ++++--- utils/tokens.tsx | 8 +++----- utils/validations.tsx | 6 ++---- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/components/Members/AddMemberForm.tsx b/components/Members/AddMemberForm.tsx index 958b745b93..1f83cf7229 100644 --- a/components/Members/AddMemberForm.tsx +++ b/components/Members/AddMemberForm.tsx @@ -153,7 +153,7 @@ const AddMemberForm: FC<{ close: () => void; mintAccount: AssetAccount }> = ({ tokenMint, tokenMint, new PublicKey(form.destinationAccount), - mintAccount.governance.pubkey, + mintAccount.extensions.mint!.account.mintAuthority!, new PublicKey(form.destinationAccount), getMintNaturalAmountFromDecimalAsBN( form.amount ?? 1, diff --git a/hooks/useDestination.ts b/hooks/useDestination.ts index 3fa1d7b562..32a173953b 100644 --- a/hooks/useDestination.ts +++ b/hooks/useDestination.ts @@ -34,9 +34,7 @@ export const useDestination = (connection: Connection, address: string) => { useEffect(() => { if (address) { debounce.debounceFcn(async () => { - console.log('useDestination -> debounce', address) const { pubKey, account } = await getDestination(connection, address) - console.log({ pubKey: pubKey?.toBase58(), account }) if (pubKey) { setDestinationAddress(pubKey) diff --git a/utils/instructionTools.ts b/utils/instructionTools.ts index 618555daa2..89b8f33df4 100644 --- a/utils/instructionTools.ts +++ b/utils/instructionTools.ts @@ -371,7 +371,8 @@ export async function getMintInstruction({ if (isValid && programId && form.mintAccount?.governance?.pubkey) { //this is the original owner const destinationAccount = new PublicKey(form.destinationAccount) - const mintPK = form.mintAccount.governance.account.governedAccount + + const mintPK = form.mintAccount.extensions.mint!.publicKey const mintAmount = parseMintNaturalAmountFromDecimal( form.amount!, form.mintAccount.extensions.mint.account?.decimals @@ -400,9 +401,9 @@ export async function getMintInstruction({ } const transferIx = Token.createMintToInstruction( TOKEN_PROGRAM_ID, - form.mintAccount.governance.account.governedAccount, + mintPK, receiverAddress, - form.mintAccount.governance!.pubkey, + form.mintAccount.extensions.mint!.account.mintAuthority!, [], mintAmount ) diff --git a/utils/tokens.tsx b/utils/tokens.tsx index db94a0ff11..40db371663 100644 --- a/utils/tokens.tsx +++ b/utils/tokens.tsx @@ -473,13 +473,11 @@ export function getMintAccountLabelInfo(acc: AssetAccount | undefined) { let amount = '' let imgUrl = '' if (acc?.extensions.mint && acc.governance) { - const info = tokenPriceService.getTokenInfo( - acc.governance.account.governedAccount.toBase58() - ) + const info = tokenPriceService.getTokenInfo(acc.pubkey.toBase58()) imgUrl = info?.logoURI ? info.logoURI : '' - account = acc.governance?.account.governedAccount.toBase58() + account = acc.pubkey.toBase58() tokenName = info?.name ? info.name : '' - mintAccountName = getAccountName(acc.governance.account.governedAccount) + mintAccountName = getAccountName(acc.pubkey) amount = formatMintNaturalAmountAsDecimal( acc.extensions.mint.account, acc?.extensions.mint.account.supply diff --git a/utils/validations.tsx b/utils/validations.tsx index 2eb308df36..2ef330f414 100644 --- a/utils/validations.tsx +++ b/utils/validations.tsx @@ -833,9 +833,7 @@ export const getMintSchema = ({ form, connection }) => { val, form.mintAccount?.extensions.mint.account.decimals ) - return !!( - form.mintAccount.governance?.account.governedAccount && mintValue - ) + return !!(form.mintAccount.extensions.mint.publicKey && mintValue) } return this.createError({ message: `Amount is required`, @@ -853,7 +851,7 @@ export const getMintSchema = ({ form, connection }) => { await validateDestinationAccAddressWithMint( connection, val, - form.mintAccount.governance.account.governedAccount + form.mintAccount.extensions.mint.publicKey ) } else { return this.createError({