metaplex-foundation / umi

A Solana Framework for JS Clients.
https://umi.typedoc.metaplex.com
MIT License
168 stars 51 forks source link

@metaplex-foundation/umi-uploader-irys seems not to work anymore since removal of Deprecated RPC Methods #144

Open BenoistP opened 3 months ago

BenoistP commented 3 months ago

Hello,

@metaplex-foundation/umi-uploader-irys depends on an old solana/web3.js version which calls getRecentBlockhash that has been deprecated since a while and seems now completely discarded

https://github.com/metaplex-foundation/umi/blob/main/packages/umi-uploader-irys/package.json "@solana/web3.js": "^1.72.0",

image

https://solana-labs.github.io/solana-web3.js/classes/Connection.html#getRecentBlockhash

File upload does not work anymore whatever the rpc used.

https://solanacompass.com/learn/Changelog/solana-changelog-jul-3-rpc-deprecations-actions-and-blinks#removal-of-deprecated-rpc-methods-in-version-20

Probably the same issue should affect bundler https://github.com/metaplex-foundation/umi/blob/main/packages/umi-uploader-bundlr/package.json

blockiosaurus commented 3 months ago

Thanks! The bundlr package is deprecated but it looks like the Irys uploader is dependent on an old version. I'll update it.

VintageWander commented 2 months ago

I have the same issue as well, currently you have to monkey patch the code for now, add this somewhere in your code \ Reference to the same issue: https://github.com/metaplex-foundation/umi/issues/143

// Monkey patch the Connection prototype
Connection.prototype.getRecentBlockhash = async function (commitment) {
  try {
    const { blockhash, lastValidBlockHeight } = await this.getLatestBlockhash(
      commitment
    );
    const recentPrioritizationFees = await this.getRecentPrioritizationFees();
    const averageFee =
      recentPrioritizationFees.length > 0
        ? recentPrioritizationFees.reduce(
            (sum, fee) => sum + fee.prioritizationFee,
            0
          ) / recentPrioritizationFees.length
        : 5000;

    return {
      blockhash,
      feeCalculator: {
        lamportsPerSignature: averageFee,
      },
    };
  } catch (e) {
    throw new Error("failed to get recent blockhash: " + e);
  }
};
blockiosaurus commented 2 months ago

This should be patched in the newest beta release. A full release will go out this week. https://www.npmjs.com/package/@metaplex-foundation/umi-uploader-irys/v/0.10.0-beta.0

BenoistP commented 2 months ago

Thanks you all guys, awesome support !