@polkadot/types#encodeTypeDef TypeScript Examples

The following examples show how to use @polkadot/types#encodeTypeDef. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueryResult.tsx    From contracts-ui with GNU General Public License v3.0 6 votes vote down vote up
QueryResult = ({ result: { time, data, message, error }, date }: Props) => {
  const { api } = useApi();

  const value =
    message.returnType && encodeTypeDef(api.registry, message.returnType) === 'u128' && isBn(data)
      ? fromSats(api, data).toString()
      : data?.toString();

  return (
    <div
      key={`${time}`}
      className={
        'text-xs dark:text-gray-400 text-gray-600 break-all p-4 border-b border-gray-200 dark:border-gray-700'
      }
      data-cy={message.method}
    >
      <div className="mb-2">{date}</div>
      <div>
        <div className="mb-2">
          <MessageSignature message={message} />
        </div>
        <div className="dark:bg-elevation-1 bg-gray-200 p-2 rounded-sm text-mono return-value">
          {value}
          <CopyButton className="float-right" value={value || ''} />
        </div>
      </div>
      {error && (
        <ReactMarkdown
          // eslint-disable-next-line react/no-children-prop
          children={error.docs.join('\r\n')}
          remarkPlugins={[remarkGfm]}
          className="markdown mt-4"
        />
      )}
    </div>
  );
}