Skip to content

Commit

Permalink
ts: Remove deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
acheroncrypto committed Dec 27, 2023
1 parent 52fbe55 commit 76bcd4f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 40 deletions.
24 changes: 0 additions & 24 deletions ts/packages/anchor/src/program/namespace/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { Idl, IdlAccountDef } from "../../idl.js";
import { Coder, BorshCoder } from "../../coder/index.js";
import { Subscription, Address, translateAddress } from "../common.js";
import { AllAccountsMap, IdlAccounts } from "./types.js";
import * as pubkeyUtil from "../../utils/pubkey.js";
import * as rpcUtil from "../../utils/rpc.js";

export default class AccountFactory {
Expand Down Expand Up @@ -372,29 +371,6 @@ export class AccountClient<
});
}

/**
* @deprecated since version 14.0.
*
* Function returning the associated account. Args are keys to associate.
* Order matters.
*/
async associated(...args: Array<PublicKey | Buffer>): Promise<T> {
const addr = await this.associatedAddress(...args);
return await this.fetch(addr);
}

/**
* @deprecated since version 14.0.
*
* Function returning the associated address. Args are keys to associate.
* Order matters.
*/
async associatedAddress(
...args: Array<PublicKey | Buffer>
): Promise<PublicKey> {
return await pubkeyUtil.associated(this._programId, ...args);
}

async getAccountInfo(
address: Address,
commitment?: Commitment
Expand Down
16 changes: 0 additions & 16 deletions ts/packages/anchor/src/utils/pubkey.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Buffer } from "buffer";
import { PublicKey } from "@solana/web3.js";
import { Address, translateAddress } from "../program/common.js";
import { sha256 } from "@noble/hashes/sha256";

// Sync version of web3.PublicKey.createWithSeed.
Expand All @@ -16,18 +15,3 @@ export function createWithSeedSync(
]);
return new PublicKey(sha256(buffer));
}

export function associated(
programId: Address,
...args: Array<Address | Buffer>
): PublicKey {
let seeds = [Buffer.from([97, 110, 99, 104, 111, 114])]; // b"anchor".
args.forEach((arg) => {
seeds.push(arg instanceof Buffer ? arg : translateAddress(arg).toBuffer());
});
const [assoc] = PublicKey.findProgramAddressSync(
seeds,
translateAddress(programId)
);
return assoc;
}

0 comments on commit 76bcd4f

Please sign in to comment.