Irys-xyz / arweave-js-sdk

JS SDK for Irys on Arweave
111 stars 96 forks source link

WebBundlr issues with latest viem and wagmi version #93

Closed cmwhited closed 1 year ago

cmwhited commented 1 year ago

Description

The WebBundlr docs recommend using the useProvider and useSigner hooks from the wagmi library. These hooks have been deprecated for usePublicClient and useWalletClient.

When initializing with viem as recommended here:

const client: any = createWalletClient({
  chain,
  transport: custom((window as any).ethereum),
});
client.getSigner = () => client;
client.getAddress = async () => client.getAddresses();

// initialize bundlr instance
const bundlr = new WebBundlr('https://node1.bundlr.network', 'matic', client);
await bundlr.ready();

The bundlr.ready() no longer opens the injected signer (my MetaMask extension, for instance) to sign for bundlr, and when I call to create the transaction with my bundlr instance:

const fileData = await fileToDataUrl(uploadData.file);
const tx = ctx.bundlr.createTransaction(fileData);
 // sign and upload the tx
await tx.sign();
const result = await tx.uploadWithReceipt();

It throws an error:

Error: Owner must be 42 bytes, but was incorrectly 1 at Module.createData

Example Stackblitz

JesseTheRobot commented 1 year ago

Thanks for the issue, I'll be looking into fixing this ASAP

JesseTheRobot commented 1 year ago

Hey @cmwhited I'm unable to reproduce your issue - that sackblitz app prompts me to connect properly (but I can't upload for some reason that button force refreshes the page, and there's some hydration errors from react which I suspect are related)

JesseTheRobot commented 1 year ago

Closing as stale