Metaplex Compressed NFTをgetAssetWithProofすると「context.rpc.getAsset is not a function」エラー

現象

実行すると以下のエラーが出る。

TypeError: context.rpc.getAsset is not a function
    at getAssetWithProof (metaplex/bubblegum_CompressedNFT/node_modules/@metaplex-foundation/mpl-bubblegum/src/getAssetWithProof.ts:37:17)
    at createCollection (metaplex/bubblegum_CompressedNFT/src/verifyCreator.ts:50:49)
    at Object.<anonymous> (metaplex/bubblegum_CompressedNFT/src/verifyCreator.ts:73:1)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module.m._compile (/usr/local/lib/node_modules/ts-node/src/index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Object.require.extensions.<computed> [as .ts] (/usr/local/lib/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)

ソース

// Lib
import * as dotenv from 'dotenv';

// Metaplex
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import {
  createSignerFromKeypair,
  keypairIdentity,
  generateSigner,
  percentAmount,
  publicKey,
} from '@metaplex-foundation/umi';
import {
  mplTokenMetadata,
  createNft,
} from '@metaplex-foundation/mpl-token-metadata';
import {
  getAssetWithProof,
} from '@metaplex-foundation/mpl-bubblegum';

const assetWithProof = async () => {
  // ----------------------------------------------------
  //  Setup
  // ----------------------------------------------------
  dotenv.config();

  // Public RPC unavailbale DAS on Devnet. Use following RPC:
  //  https://developers.metaplex.com/bubblegum/rpcs
  const endpoint =
    'https://devnet.helius-rpc.com/?api-key=<HELIUS_API>';
  const umi = createUmi(endpoint).use(mplTokenMetadata());

  // Set Payer
  const payerSecretKey = process.env.PAYER_SECRET_KEY;
  if (!payerSecretKey) throw new Error('payerSecretKey not found.');

  const secretKeyUInt8Array = new Uint8Array(JSON.parse(payerSecretKey));
  const payerKeypair =
    umi.eddsa.createKeypairFromSecretKey(secretKeyUInt8Array);

  umi.use(keypairIdentity(payerKeypair));

  // -------------------------------------
  //  Create a Collection NFT
  // -------------------------------------
  const assetId = publicKey('CjBKALu6F1CERdXmyJVfKRXviBQWAcgYGPejyuQpgGb8');

  const assetWithProof = await getAssetWithProof(umi, assetId);

  console.log('payer =>', umi.identity.publicKey.toString());
  console.log('assetId =>', assetId);
  console.log('assetWithProof =>', assetWithProof);
};

assetWithProof();

原因

getAssetWithProof を呼び出すための関数が見つからない。
つまり、Umiで使うプラグインの宣言不足。

具体的には、以下のプラグインが誤っている。

 const umi = createUmi(endpoint).use(mplTokenMetadata());

対応

assetWithProofに必要なプラグインを宣言する。

~~~

import {
  mplBubblegum, // ← 追加
  getAssetWithProof,
} from '@metaplex-foundation/mpl-bubblegum';

~~~

  const umi = createUmi(endpoint).use(mplBubblegum()); // ← プラグインmplBubblegumを宣言

~~~