Skip to content

[Squadron Builder 7] - issues with IdentityMarshaler #33

@AlexDochioiu

Description

@AlexDochioiu

Starting with version 7, I have issues using Identity Marshaler for VM.

import "marshaler.vm.dart" //
    if (dart.library.js) "marshaler.web.dart"
    if (dart.library.js_interop) "marshaler.web.dart"
    if (dart.library.html) "marshaler.web.dart";

For VM I have:

<redacted>
const dataSignatureMarshaler = IdentityMarshaler<DataSignature>();
const utxoListMarshaler = IdentityMarshaler<List<Utxo>>();
<redacted>

for WEB I Have:

<redacted>
const dataSignatureMarshaler = _DataSignatureMarshaler();

class _DataSignatureMarshaler implements SquadronMarshaler<DataSignature, Uint8List> {
  const _DataSignatureMarshaler();

  @override
  Uint8List marshal(DataSignature data, [MarshalingContext? context]) => data.marshal();

  @override
  DataSignature unmarshal(Uint8List data, [MarshalingContext? context]) => DataSignature.unmarshal(data);
}
<redacted>

and the output Deser in worker is:

final class _$Deser extends MarshalingContext {
  _$Deser({super.contextAware});
  late final $0 = value<String>();
  late final $1 = list<String>($0);
  late final $2 = value<int>();
  late final $3 = value<Uint8List>();
  late final $4 = value<T>();
  late final $5 = (($) => hdWalletMarshaler.unmarshal($4($), this));
  late final $6 = (($) => networkIdMarshaler.unmarshal($4($), this));
  <redacted>
}

Problem is that all the values get wrapped with $4 which is causing problems (cannot compile to web because of it). I believe the issue is caused by IdentityMarshaler.

Trying to change the imports to always use web instead of conditional imports leads to correct worker being generated (without that value wrapper).

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions