How to use the @polkadot/types.displayType function in @polkadot/types

To help you get started, we’ve selected a few @polkadot/types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github polkadot-js / apps / packages / react-params / src / Param / index.tsx View on Github external
function Param ({ className, defaultValue, isDisabled, isOptional, name, onChange, onEnter, onEscape, overrides, style, type }: Props): React.ReactElement | null {
  const compRef = useRef | null>(findComponent(type, overrides));

  if (!compRef.current) {
    return null;
  }

  const label = isUndefined(name)
    ? displayType(type)
    : `${name}: ${displayType(type)}`;

  return isOptional
    ? (
      
    )
    : (
github polkadot-js / apps / packages / react-components / src / MessageSignature.tsx View on Github external
{args.map(({ name, type }, index): React.ReactNode => {
        return (
          
            {name}:
            {' '}
            
              {params && params[index]
                ? (
                  <b>
                    {truncate(params[index].toString())}
                  </b>
                )
                : displayType(type)}
            
            {index &lt; args.length - 1 &amp;&amp; ', '}
          
        );
      })}
      )
github polkadot-js / apps / packages / react-components / src / MessageSignature.tsx View on Github external
{truncate(params[index].toString())}
                  
                )
                : displayType(type)}
            
            {index &lt; args.length - 1 &amp;&amp; ', '}
          
        );
      })}
      )
      {(!asConstructor &amp;&amp; returnType) &amp;&amp; (
        &lt;&gt;
          :
          {' '}
          
            {displayType(returnType)}
          
        
      )}
      {mutates &amp;&amp; (
        &lt;&gt;
          
          {withTooltip &amp;&amp; (
github polkadot-js / api / packages / api-contract / src / MetaRegistry.ts View on Github external
private typeDefForBuiltinVecFixed (id: MetaTypeIdVecFixed, typeIndex?: TypeIndex): Pick {
    const { 'array.type': vecTypeIndex, 'array.len': vecLength } = id;

    assert(!vecLength || vecLength &lt;= 256, 'MetaRegistry: Only support for [Type; ], where length &lt;= 256');
    assert(!typeIndex || vecTypeIndex !== typeIndex, `MetaRegistry: self-referencing registry type at index ${typeIndex}`);

    const type = displayType(this.typeDefFromMetaTypeAt(vecTypeIndex));
    assert(type &amp;&amp; type.length &gt; 0, `MetaRegistry: Invalid vector type found at index ${typeIndex}`);

    return {
      info: TypeDefInfo.VecFixed,
      ext: { length: vecLength, type },
      type: `[${type};${vecLength}]`,
      sub: this.typeDefFromMetaTypeAt(vecTypeIndex)
    };
  }
github polkadot-js / apps / packages / react-params / src / Param / index.tsx View on Github external
function Param ({ className, defaultValue, isDisabled, isOptional, name, onChange, onEnter, onEscape, overrides, style, type }: Props): React.ReactElement | null {
  const compRef = useRef | null&gt;(findComponent(type, overrides));

  if (!compRef.current) {
    return null;
  }

  const label = isUndefined(name)
    ? displayType(type)
    : `${name}: ${displayType(type)}`;

  return isOptional
    ? (
      
    )
    : (
github polkadot-js / api / packages / api-contract / src / MetaRegistry.ts View on Github external
private typeDefForBuiltinVec (id: MetaTypeIdVec, typeIndex?: TypeIndex): Pick {
    const { 'slice.type': vecTypeIndex } = id;

    assert(!typeIndex || vecTypeIndex !== typeIndex, `MetaRegistry: self-referencing registry type at index ${typeIndex}`);

    const type = displayType(this.typeDefFromMetaTypeAt(vecTypeIndex));
    assert(type &amp;&amp; type.length &gt; 0, `MetaRegistry: Invalid builtin Vec type found at index ${typeIndex}`);

    return {
      info: TypeDefInfo.Vec,
      type: `Vec&lt;${type}&gt;`,
      sub: this.typeDefFromMetaTypeAt(vecTypeIndex)
    };
  }