Skip to content

Commit

Permalink
fix mint instructions (solana-labs#1492)
Browse files Browse the repository at this point in the history
  • Loading branch information
abrzezinski94 authored Mar 22, 2023
1 parent a3ec2ef commit 615cfcf
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion components/Members/AddMemberForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions hooks/useDestination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions utils/instructionTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
Expand Down
8 changes: 3 additions & 5 deletions utils/tokens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions utils/validations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand All @@ -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({
Expand Down

0 comments on commit 615cfcf

Please sign in to comment.