-
Notifications
You must be signed in to change notification settings - Fork 15
Getting Cannot construct unknown type Result
error on deployment
#52
Comments
I debugged the error. The contract is sending a return message and then the UI does a lookup in the registry to dynamically infer the message type from it. The message is carrying a Changing the function formatData(registry: Registry, data: AnyJson, type: TypeDef | undefined): Codec {
return createTypeUnsafe(type?.displayName || registry, type?.type || "Raw", [data]);
} to function formatData(registry: Registry, data: AnyJson, type: TypeDef | undefined): Codec {
return createTypeUnsafe( registry, type?.type || type?.displayName || "Raw", [data]);
} leads to a correct execution of the call. However, I'm wondering if it makes any sense at all to infer the |
@achimcc I tool your suggested changes to The issue is due to The issue / fix is outlined below, with incorrect logic commented out and subsequent line showing the correct logic. // if (type.info === TypeDefInfo.Option && value instanceof Option) { <-- INCORRECT
if (type.info === TypeDefInfo.Option && codec instanceof Option) {
//const isSome = value.isSome;
const isSome = codec.isSome;
const subType = type.sub as TypeDef;
if (asJson) {
// return `${isSome ? 'Some' : 'None'}${isSome ? `(${value.toString()})` : ''}`; <-- INCORRECT
return `${isSome ? 'Some' : 'None'}${isSome ? `(${codec.unwrap().toString()})` : ''}`;
}
return (
<div className='enum'>
{isSome ? 'Some' : 'None'}
{isSome && (
<>
{'('}
<div className='inner'>
<Data
registry={registry}
type={subType}
//value={value.toString()} <-- INCORRECT
value={codec.unwrap().toString()}
/>
</div>
{')'}
</>
)}
</div>
);
} I'm happy to open a PR containing both your fix to |
One more note regarding decoding The second thing that's done in if (isNull(value) || (Array.isArray(value) && value.length === 0)) {
return '()';
} An Would it be safe to remove the check for |
When deploying this contract via the UI, the UI just displays this:
Uncaught error. Something went wrong with the query and rendering of this component. createType(Result):: Cannot construct unknown type Result
The console shows:
I think the reason is that the specific contract has this ink! message:
The text was updated successfully, but these errors were encountered: