stellar / js-stellar-base

The lowest-level stellar helper library. It consists of classes to read, write, hash, and sign Stellar xdr
https://stellar.github.io/js-stellar-base/
Apache License 2.0
106 stars 138 forks source link

Expose certain functions from `@stellar/js-xdr` so downstream don't need to mix dependencies. #744

Closed Shaptic closed 4 months ago

github-actions[bot] commented 4 months ago

Size Change: +3.07 kB (+0.1%)

Total Size: 3.22 MB

Filename Size Change
dist/stellar-base.js 2.36 MB +2.28 kB (+0.1%)
dist/stellar-base.min.js 856 kB +788 B (+0.09%)

compressed-size-action

BlaineHeffron commented 4 months ago

When I use the cereal namespace instead of just importing directly from js-xdr this code gets a TypeError:

export function processSpecEntryStream(buffer: Buffer) {
  const reader = new cereal.XdrReader(buffer);
  const res: xdr.ScSpecEntry[] = [];
  while (!reader.eof){
    res.push(xdr.ScSpecEntry.read(reader));
  }
  return res;
}
Argument of type 'XdrReader' is not assignable to parameter of type 'Buffer'.
  Type 'XdrReader' is missing the following properties from type 'Buffer': write, toJSON, equals, compare, and 91 more.

93     res.push(xdr.ScSpecEntry.read(reader));

Edit: it still works when I just ts-ignore it, but not sure why it complains when I use the cereal namespace vs importing it directly. Anyway, I don't think its really a problem.