Browse Source

ts: Remove deprecated `associated` methods (#2749)

acheron 1 year ago
parent
commit
de9901b5fd

+ 1 - 0
CHANGELOG.md

@@ -41,6 +41,7 @@ The minor version will be incremented upon a breaking change and the patch versi
 - lang: Remove `CLOSED_ACCOUNT_DISCRIMINATOR` ([#2726](https://github.com/coral-xyz/anchor/pull/2726)).
 - lang: Remove `CLOSED_ACCOUNT_DISCRIMINATOR` ([#2726](https://github.com/coral-xyz/anchor/pull/2726)).
 - lang: Make bumps of optional accounts `Option<u8>` rather than `u8` ([#2730](https://github.com/coral-xyz/anchor/pull/2730)).
 - lang: Make bumps of optional accounts `Option<u8>` rather than `u8` ([#2730](https://github.com/coral-xyz/anchor/pull/2730)).
 - spl: Remove `shared-memory` program ([#2747](https://github.com/coral-xyz/anchor/pull/2747)).
 - spl: Remove `shared-memory` program ([#2747](https://github.com/coral-xyz/anchor/pull/2747)).
+- ts: Remove `associated`, `account.associated` and `account.associatedAddress` methods ([#2749](https://github.com/coral-xyz/anchor/pull/2749)).
 
 
 ## [0.29.0] - 2023-10-16
 ## [0.29.0] - 2023-10-16
 
 

+ 0 - 24
ts/packages/anchor/src/program/namespace/account.ts

@@ -16,7 +16,6 @@ import { Idl, IdlAccountDef } from "../../idl.js";
 import { Coder, BorshCoder } from "../../coder/index.js";
 import { Coder, BorshCoder } from "../../coder/index.js";
 import { Subscription, Address, translateAddress } from "../common.js";
 import { Subscription, Address, translateAddress } from "../common.js";
 import { AllAccountsMap, IdlAccounts } from "./types.js";
 import { AllAccountsMap, IdlAccounts } from "./types.js";
-import * as pubkeyUtil from "../../utils/pubkey.js";
 import * as rpcUtil from "../../utils/rpc.js";
 import * as rpcUtil from "../../utils/rpc.js";
 
 
 export default class AccountFactory {
 export default class AccountFactory {
@@ -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(
   async getAccountInfo(
     address: Address,
     address: Address,
     commitment?: Commitment
     commitment?: Commitment

+ 0 - 16
ts/packages/anchor/src/utils/pubkey.ts

@@ -1,6 +1,5 @@
 import { Buffer } from "buffer";
 import { Buffer } from "buffer";
 import { PublicKey } from "@solana/web3.js";
 import { PublicKey } from "@solana/web3.js";
-import { Address, translateAddress } from "../program/common.js";
 import { sha256 } from "@noble/hashes/sha256";
 import { sha256 } from "@noble/hashes/sha256";
 
 
 // Sync version of web3.PublicKey.createWithSeed.
 // Sync version of web3.PublicKey.createWithSeed.
@@ -16,18 +15,3 @@ export function createWithSeedSync(
   ]);
   ]);
   return new PublicKey(sha256(buffer));
   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;
-}