mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-07-29 07:25:39 +00:00
971df8edba
- Remove all 3rd party parachain configurations from endpoints: - productionRelayPolkadot.ts: Keep only system parachains - productionRelayDicle.ts: Keep only system parachains - testingRelayZagros.ts: Keep only system parachains - testingRelayTeyrChain.ts: Keep only system parachains - Update domain references: - polkadot.js.org → pezkuwichain.app - wiki.polkadot.network → wiki.pezkuwichain.io - dotapps.io → pezkuwichain.app - statement.polkadot.network → docs.pezkuwichain.io/statement - support.polkadot.network → docs.pezkuwichain.io - Update repository references: - github.com/pezkuwi-js/apps → github.com/pezkuwichain/pwap - Rename system parachains to Pezkuwi ecosystem: - PolkadotAssetHub → PezkuwiAssetHub - polkadotBridgeHub → pezkuwiBridgeHub - polkadotCollectives → pezkuwiCollectives - polkadotCoretime → pezkuwiCoretime - polkadotPeople → pezkuwiPeople - Update network name in claims utility: - Polkadot → Pezkuwi
117 lines
2.5 KiB
TypeScript
117 lines
2.5 KiB
TypeScript
// Copyright 2017-2026 @pezkuwi/app-js authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { Log } from './types.js';
|
|
|
|
import React from 'react';
|
|
|
|
import { styled } from '@pezkuwi/react-components';
|
|
import { isError, isNull, isUndefined } from '@pezkuwi/util';
|
|
|
|
interface Props {
|
|
children?: React.ReactNode;
|
|
className?: string;
|
|
logs: Log[];
|
|
}
|
|
|
|
const format = (value: unknown): string => {
|
|
if (isError(value)) {
|
|
return value.stack
|
|
? value.stack
|
|
: value.toString();
|
|
} else if (isUndefined(value)) {
|
|
return 'undefined';
|
|
} else if (isNull(value)) {
|
|
return 'null';
|
|
} else if (Array.isArray(value)) {
|
|
return `[${value.map(format).join(', ')}]`;
|
|
} else if (value instanceof Map) {
|
|
return `{${[...value.entries()]
|
|
.map(([k, v]) => `${(k as string).toString()}: ${format(v)}`)
|
|
.join(', ')}}`;
|
|
}
|
|
|
|
// This _could_ fail as well, hence the catch below
|
|
return (value as string).toString();
|
|
};
|
|
|
|
const renderEntry = ({ args, type }: Log, index: number): React.ReactNode => {
|
|
try {
|
|
return (
|
|
<div
|
|
className={`js--Log ${type}`}
|
|
key={index}
|
|
>
|
|
{args.map(format).join(' ')}
|
|
</div>
|
|
);
|
|
} catch (error) {
|
|
// e.g. this would hit here -
|
|
// console.log(api.createType('ProxyType').__proto__)
|
|
return (
|
|
<div
|
|
className={`js--Log ${type} error`}
|
|
key={index}
|
|
>
|
|
Internal error: {(error as Error).stack || (error as Error).message}
|
|
</div>
|
|
);
|
|
}
|
|
};
|
|
|
|
function Output ({ children, className = '', logs }: Props): React.ReactElement<Props> {
|
|
return (
|
|
<StyledArticle className={`${className} container`}>
|
|
<div className='logs-wrapper'>
|
|
<div className='logs-container'>
|
|
<pre className='logs-content'>
|
|
{logs.map(renderEntry)}
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
{children}
|
|
</StyledArticle>
|
|
);
|
|
}
|
|
|
|
const StyledArticle = styled.article`
|
|
background-color: #4e4e4e;
|
|
color: #ffffff;
|
|
display: flex;
|
|
flex-direction: column;
|
|
flex-grow: 1;
|
|
font: var(--font-mono);
|
|
font-variant-ligatures: common-ligatures;
|
|
line-height: 18px;
|
|
padding: 50px 10px 10px;
|
|
position: relative;
|
|
width: 40%;
|
|
|
|
.logs-wrapper {
|
|
display: flex;
|
|
flex: 1;
|
|
min-height: 0;
|
|
}
|
|
|
|
.logs-container {
|
|
flex: 1;
|
|
overflow: auto;
|
|
}
|
|
|
|
.logs-content {
|
|
height: auto;
|
|
}
|
|
|
|
.js--Log {
|
|
animation: fadein 0.2s;
|
|
margin: 0 0 5px 0;
|
|
word-break: break-all;
|
|
|
|
&.error {
|
|
color: #f88;
|
|
}
|
|
}
|
|
`;
|
|
|
|
export default React.memo(Output);
|