Preimage availability (#7941)
* Preimage availability * Primage submission * Display decoded proposal * Renames * yarn.lock
This commit is contained in:
parent
290431ad5d
commit
5108a7590d
@ -7,7 +7,7 @@ import type { EventRecord } from '@polkadot/types/interfaces';
|
||||
|
||||
import { createNamedHook, useApi, useEventChanges, useMapKeys } from '@polkadot/react-hooks';
|
||||
|
||||
const keyOptions = {
|
||||
const OPT_KEY = {
|
||||
transform: (keys: StorageKey<[u32]>[]): u32[] =>
|
||||
keys.map(({ args: [id] }) => id)
|
||||
};
|
||||
@ -27,9 +27,9 @@ function filter (records: EventRecord[]): Changes<u32> {
|
||||
return { added, removed };
|
||||
}
|
||||
|
||||
function useAssetIdsImpl (): u32[] {
|
||||
function useAssetIdsImpl (): u32[] | undefined {
|
||||
const { api } = useApi();
|
||||
const startValue = useMapKeys(api.query.assets.asset, keyOptions);
|
||||
const startValue = useMapKeys(api.query.assets.asset, OPT_KEY);
|
||||
|
||||
return useEventChanges([
|
||||
api.events.assets.Created,
|
||||
|
||||
@ -29,7 +29,7 @@ function filter (records: EventRecord[]): Changes<u32> {
|
||||
return { added, removed };
|
||||
}
|
||||
|
||||
function useCollectionIdsImpl (): u32[] {
|
||||
function useCollectionIdsImpl (): u32[] | undefined {
|
||||
const { api } = useApi();
|
||||
const startValue = useMapKeys(api.query.uniques.class, OPT_KEYS);
|
||||
|
||||
|
||||
127
packages/page-preimages/src/Add.tsx
Normal file
127
packages/page-preimages/src/Add.tsx
Normal file
@ -0,0 +1,127 @@
|
||||
// Copyright 2017-2022 @polkadot/app-preimages authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/types';
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
import { Button, Extrinsic, Input, InputAddress, InputBalance, Modal, TxButton } from '@polkadot/react-components';
|
||||
import { useApi, useToggle } from '@polkadot/react-hooks';
|
||||
import { Available } from '@polkadot/react-query';
|
||||
import { BN, BN_ZERO } from '@polkadot/util';
|
||||
import { blake2AsHex } from '@polkadot/util-crypto';
|
||||
|
||||
import { useTranslation } from './translate';
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
imageHash?: string;
|
||||
}
|
||||
|
||||
interface HashState {
|
||||
encodedHash: string;
|
||||
encodedProposal: string;
|
||||
storageFee: BN;
|
||||
}
|
||||
|
||||
const ZERO_HASH = blake2AsHex('');
|
||||
|
||||
function Add ({ className, imageHash }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const { api, apiDefaultTxSudo } = useApi();
|
||||
const [isAddOpen, toggleAdd] = useToggle();
|
||||
const [accountId, setAccountId] = useState<string | null>(null);
|
||||
const [{ encodedHash, encodedProposal, storageFee }, setHash] = useState<HashState>({ encodedHash: ZERO_HASH, encodedProposal: '', storageFee: BN_ZERO });
|
||||
const [proposal, setProposal] = useState<SubmittableExtrinsic<'promise'>>();
|
||||
|
||||
useEffect((): void => {
|
||||
const encodedProposal = (proposal as SubmittableExtrinsic<'promise'>)?.method.toHex() || '';
|
||||
const storageFee = api.consts.democracy.preimageByteDeposit.mul(
|
||||
encodedProposal
|
||||
? new BN((encodedProposal.length - 2) / 2)
|
||||
: BN_ZERO
|
||||
);
|
||||
|
||||
setHash({ encodedHash: blake2AsHex(encodedProposal), encodedProposal, storageFee });
|
||||
}, [api, proposal]);
|
||||
|
||||
const isMatched = imageHash
|
||||
? imageHash === encodedHash
|
||||
: true;
|
||||
|
||||
return (
|
||||
<>
|
||||
{isAddOpen && (
|
||||
<Modal
|
||||
className={className}
|
||||
header={t<string>('Submit preimage')}
|
||||
onClose={toggleAdd}
|
||||
size='large'
|
||||
>
|
||||
<Modal.Content>
|
||||
<Modal.Columns hint={t<string>('This account will pay the fees for the preimage, based on the size thereof.')}>
|
||||
<InputAddress
|
||||
help={t<string>('The account you want to register the preimage from')}
|
||||
label={t<string>('send from account')}
|
||||
labelExtra={
|
||||
<Available
|
||||
label={<span className='label'>{t<string>('transferrable')}</span>}
|
||||
params={accountId}
|
||||
/>
|
||||
}
|
||||
onChange={setAccountId}
|
||||
type='account'
|
||||
/>
|
||||
</Modal.Columns>
|
||||
<Modal.Columns hint={
|
||||
<>
|
||||
<p>{t<string>('The image (proposal) will be stored on-chain against the hash of the contents.')}</p>
|
||||
<p>{t<string>('When submitting a proposal the hash needs to be known. Proposals can be submitted with hash-only, but upon dispatch the preimage needs to be available.')}</p>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<Extrinsic
|
||||
defaultValue={apiDefaultTxSudo}
|
||||
label={t<string>('propose')}
|
||||
onChange={setProposal}
|
||||
/>
|
||||
<Input
|
||||
className='disabledLook'
|
||||
help={t<string>('The hash of the selected proposal, use it for submitting the proposal')}
|
||||
isDisabledError={!isMatched}
|
||||
label={t<string>('preimage hash')}
|
||||
value={encodedHash}
|
||||
/>
|
||||
</Modal.Columns>
|
||||
<Modal.Columns hint={t<string>('The calculated storage costs based on the size and the per-bytes fee.')}>
|
||||
<InputBalance
|
||||
defaultValue={storageFee}
|
||||
help={t<string>('The amount reserved to store this image')}
|
||||
isDisabled
|
||||
label={t<string>('calculated storage fee')}
|
||||
/>
|
||||
</Modal.Columns>
|
||||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
<TxButton
|
||||
accountId={accountId}
|
||||
icon='plus'
|
||||
isDisabled={!proposal || !accountId || !isMatched || !encodedProposal}
|
||||
label={t<string>('Submit preimage')}
|
||||
onStart={toggleAdd}
|
||||
params={[encodedProposal]}
|
||||
tx={api.tx.preimage.notePreimage}
|
||||
/>
|
||||
</Modal.Actions>
|
||||
</Modal>
|
||||
)}
|
||||
<Button
|
||||
icon='plus'
|
||||
label={t<string>('Add preimage')}
|
||||
onClick={toggleAdd}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(Add);
|
||||
65
packages/page-preimages/src/Hash.tsx
Normal file
65
packages/page-preimages/src/Hash.tsx
Normal file
@ -0,0 +1,65 @@
|
||||
// Copyright 2017-2022 @polkadot/app-preimages authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiPromise } from '@polkadot/api';
|
||||
import type { Bytes } from '@polkadot/types';
|
||||
import type { Call } from '@polkadot/types/interfaces';
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
|
||||
import { CallExpander } from '@polkadot/react-components';
|
||||
import { useApi } from '@polkadot/react-hooks';
|
||||
import { formatNumber } from '@polkadot/util';
|
||||
|
||||
import { useTranslation } from './translate';
|
||||
import useHashInfo from './useHashInfo';
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
value: HexString;
|
||||
}
|
||||
|
||||
function decodeBytes (api: ApiPromise, bytes: Bytes): Call | null {
|
||||
try {
|
||||
return api.registry.createType('Call', bytes.toU8a(true));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function Hash ({ className, value }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const { api } = useApi();
|
||||
const info = useHashInfo(value);
|
||||
const decoded = useMemo(
|
||||
() => info && info.bytes && decodeBytes(api, info.bytes),
|
||||
[api, info]
|
||||
);
|
||||
|
||||
return (
|
||||
<tr className={ className }>
|
||||
<td>
|
||||
{value}
|
||||
</td>
|
||||
<td className='all'>
|
||||
{decoded && (
|
||||
<CallExpander
|
||||
labelHash={t<string>('proposal')}
|
||||
value={decoded}
|
||||
/>
|
||||
)}
|
||||
</td>
|
||||
<td className='number'>
|
||||
{info && info.bytes && formatNumber(info.bytes.length)}
|
||||
</td>
|
||||
<td className='number'>
|
||||
{info && info.status && info.status.type}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(Hash);
|
||||
52
packages/page-preimages/src/Hashes.tsx
Normal file
52
packages/page-preimages/src/Hashes.tsx
Normal file
@ -0,0 +1,52 @@
|
||||
// Copyright 2017-2022 @polkadot/app-preimages authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { SubmittableExtrinsicFunction } from '@polkadot/api/types';
|
||||
|
||||
import React, { useRef } from 'react';
|
||||
|
||||
import { Button, Table } from '@polkadot/react-components';
|
||||
|
||||
import Add from './Add';
|
||||
import Hash from './Hash';
|
||||
import { useTranslation } from './translate';
|
||||
import useHashes from './useHashes';
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
defaultPropose?: SubmittableExtrinsicFunction<'promise'>;
|
||||
filter?: (section: string, method?: string) => boolean;
|
||||
}
|
||||
|
||||
function Hashes ({ className }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const hashes = useHashes();
|
||||
|
||||
const headerRef = useRef([
|
||||
[t('preimages'), 'start', 2],
|
||||
[t('size')],
|
||||
[t('status')]
|
||||
]);
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<Button.Group>
|
||||
<Add />
|
||||
</Button.Group>
|
||||
<Table
|
||||
className={className}
|
||||
empty={hashes && t<string>('No hashes found')}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{hashes && hashes.map((h) => (
|
||||
<Hash
|
||||
key={h}
|
||||
value={h}
|
||||
/>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(Hashes);
|
||||
@ -1,16 +1,37 @@
|
||||
// Copyright 2017-2022 @polkadot/app-preimages authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import React from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
|
||||
import { Tabs } from '@polkadot/react-components';
|
||||
|
||||
import Hashes from './Hashes';
|
||||
import { useTranslation } from './translate';
|
||||
|
||||
interface Props {
|
||||
basePath: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
function App ({ className }: Props): React.ReactElement<Props> {
|
||||
function App ({ basePath, className }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const tabsRef = useRef([
|
||||
{
|
||||
isRoot: true,
|
||||
name: 'overview',
|
||||
text: t<string>('Overview')
|
||||
}
|
||||
]);
|
||||
|
||||
return (
|
||||
<div className={className} />
|
||||
<main className={className}>
|
||||
<Tabs
|
||||
basePath={basePath}
|
||||
items={tabsRef.current}
|
||||
/>
|
||||
<Hashes />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
35
packages/page-preimages/src/useHashInfo.ts
Normal file
35
packages/page-preimages/src/useHashInfo.ts
Normal file
@ -0,0 +1,35 @@
|
||||
// Copyright 2017-2022 @polkadot/app-preimages authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Bytes, Option } from '@polkadot/types';
|
||||
import type { PalletPreimageRequestStatus } from '@polkadot/types/lookup';
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { createNamedHook, useApi, useCall } from '@polkadot/react-hooks';
|
||||
|
||||
interface Result {
|
||||
bytes: Bytes | null;
|
||||
status: PalletPreimageRequestStatus | null;
|
||||
}
|
||||
|
||||
function createResult (preimage: Option<Bytes>, status: Option<PalletPreimageRequestStatus>): Result {
|
||||
return {
|
||||
bytes: preimage.unwrapOr(null),
|
||||
status: status.unwrapOr(null)
|
||||
};
|
||||
}
|
||||
|
||||
function useHashInfoImpl (hash: HexString): Result | undefined {
|
||||
const { api } = useApi();
|
||||
const preimage = useCall<Option<Bytes>>(api.query.preimage.preimageFor, [hash]);
|
||||
const status = useCall<Option<PalletPreimageRequestStatus>>(api.query.preimage.statusFor, [hash]);
|
||||
|
||||
return useMemo(
|
||||
() => preimage && status && createResult(preimage, status),
|
||||
[preimage, status]
|
||||
);
|
||||
}
|
||||
|
||||
export default createNamedHook('useHashInfo', useHashInfoImpl);
|
||||
47
packages/page-preimages/src/useHashes.ts
Normal file
47
packages/page-preimages/src/useHashes.ts
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright 2017-2022 @polkadot/app-preimages authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Changes } from '@polkadot/react-hooks/useEventChanges';
|
||||
import type { StorageKey } from '@polkadot/types';
|
||||
import type { EventRecord, Hash } from '@polkadot/types/interfaces';
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { createNamedHook, useApi, useEventChanges, useMapKeys } from '@polkadot/react-hooks';
|
||||
|
||||
const OPT_HASH = {
|
||||
transform: (keys: StorageKey<[Hash]>[]): Hash[] =>
|
||||
keys.map(({ args: [hash] }) => hash)
|
||||
};
|
||||
|
||||
function filter (records: EventRecord[]): Changes<Hash> {
|
||||
const added: Hash[] = [];
|
||||
const removed: Hash[] = [];
|
||||
|
||||
records.forEach(({ event: { data: [hash], method } }): void => {
|
||||
if (method === 'Noted') {
|
||||
added.push(hash as Hash);
|
||||
} else {
|
||||
removed.push(hash as Hash);
|
||||
}
|
||||
});
|
||||
|
||||
return { added, removed };
|
||||
}
|
||||
|
||||
function useHashesImpl (): HexString[] | undefined {
|
||||
const { api } = useApi();
|
||||
const startValue = useMapKeys(api.query.preimage.statusFor, OPT_HASH);
|
||||
const hashes = useEventChanges([
|
||||
api.events.preimage.Cleared,
|
||||
api.events.preimage.Noted
|
||||
], filter, startValue);
|
||||
|
||||
return useMemo(
|
||||
() => hashes && hashes.map((h) => h.toHex()),
|
||||
[hashes]
|
||||
);
|
||||
}
|
||||
|
||||
export default createNamedHook('useHashes', useHashesImpl);
|
||||
1
packages/page-referenda/README.md
Normal file
1
packages/page-referenda/README.md
Normal file
@ -0,0 +1 @@
|
||||
# @polkadot/app-referenda
|
||||
@ -1,11 +1,11 @@
|
||||
{
|
||||
"bugs": "https://github.com/polkadot-js/apps/issues",
|
||||
"homepage": "https://github.com/polkadot-js/apps/tree/master/packages/page-referendums#readme",
|
||||
"homepage": "https://github.com/polkadot-js/apps/tree/master/packages/page-referenda#readme",
|
||||
"license": "Apache-2.0",
|
||||
"name": "@polkadot/app-referendums",
|
||||
"name": "@polkadot/app-referenda",
|
||||
"private": true,
|
||||
"repository": {
|
||||
"directory": "packages/page-referendums",
|
||||
"directory": "packages/page-referenda",
|
||||
"type": "git",
|
||||
"url": "https://github.com/polkadot-js/apps.git"
|
||||
},
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2022 @polkadot/app-referendums authors & contributors
|
||||
// Copyright 2017-2022 @polkadot/app-referenda authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import React from 'react';
|
||||
@ -1,10 +1,10 @@
|
||||
// Copyright 2017-2022 @polkadot/app-referendums authors & contributors
|
||||
// Copyright 2017-2022 @polkadot/app-referenda authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { UseTranslationResponse } from 'react-i18next';
|
||||
|
||||
import { useTranslation as useTranslationBase } from 'react-i18next';
|
||||
|
||||
export function useTranslation (): UseTranslationResponse<'app-referendums', undefined> {
|
||||
return useTranslationBase('app-referendums');
|
||||
export function useTranslation (): UseTranslationResponse<'app-referenda', undefined> {
|
||||
return useTranslationBase('app-referenda');
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
# @polkadot/app-referendums
|
||||
@ -90,7 +90,7 @@ function useMembersImpl (): MembersMap | undefined {
|
||||
const ids = useEventChanges([
|
||||
api.events.nominationPools.Bonded
|
||||
], filterEvents, EMPTY_START);
|
||||
const additions = useCall(ids.length !== 0 && api.query.nominationPools.poolMembers.multi, [ids], OPT_MULTI);
|
||||
const additions = useCall(ids && ids.length !== 0 && api.query.nominationPools.poolMembers.multi, [ids], OPT_MULTI);
|
||||
|
||||
// initial entries
|
||||
useEffect((): void => {
|
||||
|
||||
0
packages/page-whitelist/.skip-build
Normal file
0
packages/page-whitelist/.skip-build
Normal file
0
packages/page-whitelist/.skip-npm
Normal file
0
packages/page-whitelist/.skip-npm
Normal file
201
packages/page-whitelist/LICENSE
Normal file
201
packages/page-whitelist/LICENSE
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
1
packages/page-whitelist/README.md
Normal file
1
packages/page-whitelist/README.md
Normal file
@ -0,0 +1 @@
|
||||
# @polkadot/app-whitelist
|
||||
18
packages/page-whitelist/package.json
Normal file
18
packages/page-whitelist/package.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"bugs": "https://github.com/polkadot-js/apps/issues",
|
||||
"homepage": "https://github.com/polkadot-js/apps/tree/master/packages/page-whitelist#readme",
|
||||
"license": "Apache-2.0",
|
||||
"name": "@polkadot/app-whitelist",
|
||||
"private": true,
|
||||
"repository": {
|
||||
"directory": "packages/page-whitelist",
|
||||
"type": "git",
|
||||
"url": "https://github.com/polkadot-js/apps.git"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "0.119.2-0-x",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.9"
|
||||
}
|
||||
}
|
||||
17
packages/page-whitelist/src/index.tsx
Normal file
17
packages/page-whitelist/src/index.tsx
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2017-2022 @polkadot/app-whitelist authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import React from 'react';
|
||||
|
||||
interface Props {
|
||||
basePath: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
function App ({ className }: Props): React.ReactElement<Props> {
|
||||
return (
|
||||
<div className={className} />
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(App);
|
||||
10
packages/page-whitelist/src/translate.ts
Normal file
10
packages/page-whitelist/src/translate.ts
Normal file
@ -0,0 +1,10 @@
|
||||
// Copyright 2017-2022 @polkadot/app-whitelist authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { UseTranslationResponse } from 'react-i18next';
|
||||
|
||||
import { useTranslation as useTranslationBase } from 'react-i18next';
|
||||
|
||||
export function useTranslation (): UseTranslationResponse<'app-whitelist', undefined> {
|
||||
return useTranslationBase('app-whitelist');
|
||||
}
|
||||
9
packages/page-whitelist/tsconfig.build.json
Normal file
9
packages/page-whitelist/tsconfig.build.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": "..",
|
||||
"outDir": "./build",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"references": []
|
||||
}
|
||||
@ -17,7 +17,7 @@ export interface Changes<T extends Codec> {
|
||||
removed?: T[];
|
||||
}
|
||||
|
||||
function interleave <T extends Codec> (existing: T[], { added = [], removed = [] }: Changes<T>): T[] {
|
||||
function interleave <T extends Codec> (existing: T[] = [], { added = [], removed = [] }: Changes<T>): T[] {
|
||||
if (!added.length && !removed.length) {
|
||||
return existing;
|
||||
}
|
||||
@ -45,8 +45,8 @@ function interleave <T extends Codec> (existing: T[], { added = [], removed = []
|
||||
.map(([, v]) => v);
|
||||
}
|
||||
|
||||
export function useEventChanges <T extends Codec> (checks: EventCheck[], filter: (records: EventRecord[]) => Changes<T>, startValue?: T[]): T[] {
|
||||
const [state, setState] = useState<T[]>([]);
|
||||
export function useEventChanges <T extends Codec> (checks: EventCheck[], filter: (records: EventRecord[]) => Changes<T>, startValue?: T[]): T[] | undefined {
|
||||
const [state, setState] = useState<T[] | undefined>();
|
||||
const { blockHash, events } = useEventTrigger(checks);
|
||||
|
||||
// when startValue changes, we do a full refresh
|
||||
|
||||
@ -56,8 +56,8 @@
|
||||
"@polkadot/app-preimages/*": ["page-preimages/src/*"],
|
||||
"@polkadot/app-ranked-collective": ["page-ranked-collective/src"],
|
||||
"@polkadot/app-ranked-collective/*": ["page-ranked-collective/src/*"],
|
||||
"@polkadot/app-referendums": ["page-referendums/src"],
|
||||
"@polkadot/app-referendums/*": ["page-referendums/src/*"],
|
||||
"@polkadot/app-referenda": ["page-referenda/src"],
|
||||
"@polkadot/app-referenda/*": ["page-referenda/src/*"],
|
||||
"@polkadot/app-rpc": ["page-rpc/src"],
|
||||
"@polkadot/app-rpc/*": ["page-rpc/src/*"],
|
||||
"@polkadot/app-runtime": ["page-runtime/src"],
|
||||
@ -80,6 +80,8 @@
|
||||
"@polkadot/app-treasury/*": ["page-treasury/src/*"],
|
||||
"@polkadot/app-utilities": ["page-utilities/src"],
|
||||
"@polkadot/app-utilities/*": ["page-utilities/src/*"],
|
||||
"@polkadot/app-whitelist": ["page-whitelist/src"],
|
||||
"@polkadot/app-whitelist/*": ["page-whitelist/src/*"],
|
||||
"@polkadot/react-api": ["react-api/src"],
|
||||
"@polkadot/react-api/*": ["react-api/src/*"],
|
||||
"@polkadot/react-components": ["react-components/src"],
|
||||
|
||||
12
yarn.lock
12
yarn.lock
@ -2945,9 +2945,9 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/app-referendums@workspace:packages/page-referendums":
|
||||
"@polkadot/app-referenda@workspace:packages/page-referenda":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/app-referendums@workspace:packages/page-referendums"
|
||||
resolution: "@polkadot/app-referenda@workspace:packages/page-referenda"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.18.9
|
||||
languageName: unknown
|
||||
@ -3060,6 +3060,14 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/app-whitelist@workspace:packages/page-whitelist":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/app-whitelist@workspace:packages/page-whitelist"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.18.9
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/apps-config@^0.119.2-0-x, @polkadot/apps-config@workspace:packages/apps-config":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@polkadot/apps-config@workspace:packages/apps-config"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user