New TS-SDK Requires Buffer, which hinders frontend dev

The latest version of the TS SDK (0.94.0) uses decompressBytecode function in the factory, which requires the node builtin Buffer, which isn’t available in most Frontend Envs and causes issues especially with Vite.

This would require polyfill Buffer on the frontend which would ideally be avoided altogether.

Is this necessary or could there be an alternative path?

For example you could use something that doesn’t rely on node builtins like pako:

import pako from "pako";

const decompressBytecode = (bytecode: string): Uint8Array => {
  const binaryString = atob(bytecode);
  return pako.inflate(Uint8Array.from(binaryString, (c) => c.charCodeAt(0)));
};

Hey @xpluscal, thanks for reporting this. Team is looking into it

Awesome @Nazeeh21 , I just tested my solution as posted above and that works way better without relying on Buffer.

Hey @xpluscal,

Thanks for raising this, we’ve got an issue to track this. Will update here once we have a fix.

1 Like

Hey @xpluscal,

We have a PR to address this issue. If you’re blocked by this, then you can use the published NPM versions pr-2985.

Let me know if you have any issues :slight_smile:

1 Like

@xpluscal This should have been fixed in 0.94.1: