Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added ts-sdk/bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions ts-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
"license": "MIT",
"dependencies": {
"@coral-xyz/anchor": "^0.29.0",
"@solana/spl-token": "0.1.8",
"@solana/spl-token": "^0.4.9",
"@solana/web3.js": "~1.87.6",
"prettier": "^3.2.5",
"ts-node": "^10.9.2"
},
"devDependencies": {
"@tsconfig/recommended": "^1.0.1",
"typescript": "^4.7.2"
"typescript": "^5.0.0"
},
"directories": {
"test": "tests"
Expand Down
23 changes: 7 additions & 16 deletions ts-sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { AnchorProvider, BN, Program, Wallet } from '@coral-xyz/anchor';
import { ASSOCIATED_TOKEN_PROGRAM_ID, Token, TOKEN_PROGRAM_ID } from '@solana/spl-token';
import {
createAssociatedTokenAccountInstruction,
getAssociatedTokenAddress,
TOKEN_PROGRAM_ID,
} from '@solana/spl-token';
import { Connection, PublicKey, SystemProgram, TransactionInstruction } from '@solana/web3.js';
import { MerkleDistributor, IDL } from '../../target/types/merkle_distributor';

Expand Down Expand Up @@ -69,23 +73,10 @@ export const getOrCreateATAInstruction = async (
): Promise<[PublicKey, TransactionInstruction?]> => {
let toAccount;
try {
toAccount = await Token.getAssociatedTokenAddress(
ASSOCIATED_TOKEN_PROGRAM_ID,
TOKEN_PROGRAM_ID,
tokenMint,
owner,
allowOwnerOffCurve,
);
toAccount = await getAssociatedTokenAddress(tokenMint, owner, allowOwnerOffCurve);
const account = await connection.getAccountInfo(toAccount);
if (!account) {
const ix = Token.createAssociatedTokenAccountInstruction(
ASSOCIATED_TOKEN_PROGRAM_ID,
TOKEN_PROGRAM_ID,
tokenMint,
toAccount,
owner,
payer,
);
const ix = createAssociatedTokenAccountInstruction(payer, toAccount, owner, tokenMint);
return [toAccount, ix];
}
return [toAccount, undefined];
Expand Down