Skip to content

Commit

Permalink
allow offcurve
Browse files Browse the repository at this point in the history
  • Loading branch information
bryzettler committed Oct 19, 2023
1 parent 1cf14ca commit 6517087
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/utils/solanaUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,11 @@ export const createTransferTxn = async (
let instructions: TransactionInstruction[] = []
payments.forEach((p) => {
const amount = p.balanceAmount
const ata = getAssociatedTokenAddressSync(mint, new PublicKey(p.payee))
const ata = getAssociatedTokenAddressSync(
mint,
new PublicKey(p.payee),
true,
)

instructions = [
...instructions,
Expand Down Expand Up @@ -373,23 +377,16 @@ export const getTxn = async (
})
}

export const getAssocTokenAddress = (
walletAddress: string,
mintAddress: string,
) => {
const account = new PublicKey(walletAddress)
const mint = new PublicKey(mintAddress)
return getAssociatedTokenAddress(mint, account)
}

export const getTransactions = async (
anchorProvider: AnchorProvider,
walletAddress: string,
mintAddress: string,
options?: SignaturesForAddressOptions,
) => {
try {
const ata = await getAssocTokenAddress(walletAddress, mintAddress)
const account = new PublicKey(walletAddress)
const mint = new PublicKey(mintAddress)
const ata = await getAssociatedTokenAddress(account, mint)
const transactionList =
await anchorProvider.connection.getSignaturesForAddress(ata, options)
const sigs = transactionList.map(({ signature }) => signature)
Expand Down Expand Up @@ -478,6 +475,7 @@ export const createTransferCollectableMessage = async (
const recipientATA = await getAssociatedTokenAddress(
mintPubkey,
recipientPubKey,
true,
)

instructions.push(
Expand Down Expand Up @@ -546,6 +544,7 @@ export const transferCollectable = async (
const recipientATA = await getAssociatedTokenAddress(
mintPubkey,
recipientPubKey,
true,
)

instructions.push(
Expand Down Expand Up @@ -1433,7 +1432,7 @@ export async function createTreasurySwapTxn(
])
.accounts({
treasuryManagement,
to: getAssociatedTokenAddressSync(HNT_MINT, recipient),
to: getAssociatedTokenAddressSync(HNT_MINT, recipient, true),
})
.transaction()

Expand Down Expand Up @@ -1477,7 +1476,7 @@ export async function createTreasurySwapMessage(
])
.accounts({
treasuryManagement,
to: getAssociatedTokenAddressSync(HNT_MINT, recipient),
to: getAssociatedTokenAddressSync(HNT_MINT, recipient, true),
})
.transaction()

Expand Down Expand Up @@ -1614,7 +1613,7 @@ export const calcCreateAssociatedTokenAccountAccountFee = async (
}

const payeePubKey = new PublicKey(payee)
const ata = await getAssociatedTokenAddress(mint, payeePubKey)
const ata = await getAssociatedTokenAddress(mint, payeePubKey, true)
if (ata) {
return new BN(0)
}
Expand Down

0 comments on commit 6517087

Please sign in to comment.