typegen: give getSimilarTypes the registry's name for tx arguments

The tx generator rebranded each argument's lookup name (SpWeightsWeightV2Weight
to PezspWeightsWeightV2Weight) before asking getSimilarTypes for its inputs.
The registry knows the type only by its metadata name, so for every lookup
type the class checks found nothing and the generated signature was the bare
type: multisig.asMulti took `maxWeight: PezspWeightsWeightV2Weight` with no
`{ refTime?: any; proofSize?: any }`, and a timepoint without
`{ height?: any; index?: any }`. Passing a plain object, as every caller
does, was a type error.

getSimilarTypes and formatType now get the metadata name, as the query
generator already does for storage keys, and return rebranded names
themselves; the rebranded name is what goes into the imports and the
used-type list. The augment is regenerated (yarn build:metadata, 1070
passed). Only tx.ts files change; enum variant names are untouched.
This commit is contained in:
Satoshi Qazi Muhammed authored and SatoshiQaziMuhammed committed 2026-10-08 23:25:36 +04:00
1 parent ca7f3bcc2f
commit d0c07ebba2
6 files changed
+506 -500

No files matched your search

+11 -5
View File
@@ -82,21 +82,27 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
rebrandTypeName(typeName.isSome
? typeName.toString()
: typeDef.type),
rebrandTypeName(typeDef.isFromSi
// The registry knows lookup types by their metadata name
// (SpWeightsWeightV2Weight). getSimilarTypes and formatType have
// to be given that name, and rebrand what they return; given the
// rebranded name, the registry cannot find the type and the
// struct, enum and vector inputs are lost.
typeDef.isFromSi
? typeDef.type
: typeDef.lookupName || typeDef.type)
: typeDef.lookupName || typeDef.type
];
});
const params = typesInfo
.map(([name,, typeStr]) => {
const similarTypes = getSimilarTypes(registry, allDefs, typeStr, imports);
const typeName = rebrandTypeName(typeStr);
setImports(allDefs, imports, [typeStr, ...similarTypes]);
setImports(allDefs, imports, [typeName, ...similarTypes]);
// Add the type to the list of used types
if (!(imports.primitiveTypes[typeStr])) {
usedTypes.add(typeStr);
if (!(imports.primitiveTypes[typeName])) {
usedTypes.add(typeName);
}
return `${name}: ${similarTypes.join(' | ')}`;