fix: obligation token mint

This commit is contained in:
Justin Starry 2020-11-21 15:07:58 +08:00
parent 4231fedeef
commit c9a87b3771
2 changed files with 25 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import { AccountLayout, Token } from "@solana/spl-token";
import { AccountLayout, MintLayout, Token } from "@solana/spl-token";
import {
Account,
PublicKey,
@ -75,6 +75,28 @@ export function createTempMemoryAccount(
return account.publicKey;
}
export function createUninitializedMint(
instructions: TransactionInstruction[],
payer: PublicKey,
amount: number,
signers: Account[]
) {
const account = new Account();
instructions.push(
SystemProgram.createAccount({
fromPubkey: payer,
newAccountPubkey: account.publicKey,
lamports: amount,
space: MintLayout.span,
programId: TOKEN_PROGRAM_ID,
})
);
signers.push(account);
return account.publicKey;
}
export function createUninitializedAccount(
instructions: TransactionInstruction[],
payer: PublicKey,

View File

@ -12,6 +12,7 @@ import { LENDING_PROGRAM_ID, TOKEN_PROGRAM_ID } from "../constants/ids";
import {
createTempMemoryAccount,
createUninitializedAccount,
createUninitializedMint,
ensureSplAccount,
findOrCreateAccountByMint,
} from "./account";
@ -60,7 +61,7 @@ export const borrow = async (
signers
);
const obligationMint = createUninitializedAccount(
const obligationMint = createUninitializedMint(
instructions,
wallet.publicKey,
await connection.getMinimumBalanceForRentExemption(MintLayout.span),