@typemove/sui 2.0.5 → 2.0.6-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/move-coder.ts CHANGED
@@ -61,6 +61,18 @@ export class MoveCoder extends AbstractMoveCoder<ModuleWithAddress, SuiEventInpu
61
61
  }
62
62
  return super.decode(data, type)
63
63
  }
64
+ // gRPC's unified Object.json also flattens 0x1::type_name::TypeName to its
65
+ // inner string (e.g. "<addr>::coin::COIN") — re-wrap to `{ name: '...' }` so
66
+ // downstream `.name` accessors keep working. Without this the string falls
67
+ // into the generic struct walk and decodes to `{ name: undefined }`. The
68
+ // BCS-shaped path (`{ name: { bytes: ... } }`) is delegated to super.decode,
69
+ // whose field walk hits the ascii::String case.
70
+ if (type.qname === '0x1::type_name::TypeName') {
71
+ if (typeof data === 'string') {
72
+ return { name: data } as any
73
+ }
74
+ return super.decode(data, type)
75
+ }
64
76
  switch (type.qname) {
65
77
  case '0x1::ascii::Char':
66
78
  if (data !== undefined && typeof data !== 'string') {