Skip to content

Commit

Permalink
Merge branch 'release/v1.0.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
pasynkov committed Mar 22, 2022
2 parents 94320fa + 9f5eed8 commit e2aa2eb
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 218 deletions.
6 changes: 3 additions & 3 deletions packages/apps/.env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ DECIMALS=6
DISCORD_CHANNEL=https://discord.com/invite/8jghD8V9PU
FAVICON_PATH=favicons/marketplace
GRAPH_QL_ADMIN_SECRET=hepM3wfsATBoI-ix2uhsAodr1j99MThPF5LBZJI2YtHAax7W9BIP9F8IWuzcNUC4
GRAPH_QL_API=https://dev-api-explorer.unique.network/v1/graphql
IMAGE_SERVER_URL=https://dev-offchain-api.unique.network
GRAPH_QL_API=https://hasura.quartz.uniquenetwork.dev/v1/graphql
IMAGE_SERVER_URL=https://image-uploader.unique.network
IPFS_GATEWAY=https://dev-ipfs.unique.network/ipfs
MIN_PRICE=0.000001
UNIQUE_SUBSTRATE_API=wss://ws-opal.unique.network
UNIQUE_SUBSTRATE_API=wss://us-ws-quartz.unique.network/
UNQ_TELEGRAM=https://t.me/unique2faucet_opal_bot
UNQ_WALLET="https://wallet-opal.unique.network/#/myStuff/nft?collectionId="
WHITE_LABEL_URL=https://whitelabel.unique.network
23 changes: 4 additions & 19 deletions packages/apps/src/Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ import { useAccounts, useApi, useCall } from '@polkadot/react-hooks';
import { stringToU8a } from '@polkadot/util';
import { xxhashAsHex } from '@polkadot/util-crypto';

import { useTranslation } from './translate';

interface Props {
optionsAll?: KeyringOptions;
}

let prevEventHash: string;

function filterEvents (allAccounts: string[], t: <T = string> (key: string, opts?: Record<string, unknown>) => T, optionsAll?: KeyringOptions, events?: EventRecord[]): ActionStatus[] | null {
function filterEvents (allAccounts: string[], optionsAll?: KeyringOptions, events?: EventRecord[]): ActionStatus[] | null {
const eventHash = xxhashAsHex(stringToU8a(JSON.stringify(events)));

if (!optionsAll || !events || eventHash === prevEventHash) {
Expand All @@ -38,22 +36,10 @@ function filterEvents (allAccounts: string[], t: <T = string> (key: string, opts
return {
account,
action: `${section}.${method}`,
message: t<string>('transfer received'),
message: 'transfer received',
status: 'event'
};
}
} else if (section === 'democracy') {
const index = data[0].toString();

return {
action: `${section}.${method}`,
message: t<string>('update on #{{index}}', {
replace: {
index
}
}),
status: 'event'
};
}

return null;
Expand All @@ -65,14 +51,13 @@ function Status ({ optionsAll }: Props): React.ReactElement<Props> {
const { queueAction } = useContext(StatusContext);
const { api, isApiReady } = useApi();
const { allAccounts } = useAccounts();
const { t } = useTranslation();
const events = useCall<EventRecord[]>(isApiReady && api.query.system?.events);

useEffect((): void => {
const filtered = filterEvents(allAccounts, t, optionsAll, events);
const filtered = filterEvents(allAccounts, optionsAll, events);

filtered && queueAction(filtered);
}, [allAccounts, events, optionsAll, queueAction, t]);
}, [allAccounts, events, optionsAll, queueAction]);

return (
<StatusDisplay />
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/webpack.serve.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = merge(
proxy: {
'/v1/graphql/': {
changeOrigin: true,
target: 'https://dev-api-explorer.unique.network'
target: 'https://hasura.dev.uniquenetwork.dev/'
}
},
static: path.resolve(__dirname, 'build')
Expand Down
8 changes: 4 additions & 4 deletions packages/page-builder/src/Builder.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2021 @polkadot/apps , UseTech authors & contributors
// Copyright 2017-2022 @polkadot/apps , UseTech authors & contributors
// SPDX-License-Identifier: Apache-2.0

import './styles.scss';
Expand All @@ -19,16 +19,16 @@ const { graphQlAdminSecret, graphQlApi } = envConfig;
const graphQlUrl = process.env.NODE_ENV === 'production' ? graphQlApi : '/v1/graphql/';

const headers: {[k: string]: string} = {
'content-type': 'application/json',
}
'content-type': 'application/json'
};

if (graphQlAdminSecret) {
headers['x-hasura-admin-secret'] = graphQlAdminSecret;
}

const client = new ApolloClient({
headers,
cache: new InMemoryCache(),
headers,
uri: graphQlUrl
});

Expand Down
40 changes: 17 additions & 23 deletions packages/page-builder/src/components/MainInformation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import BN from 'bn.js';
import React, { memo, useCallback, useContext, useEffect, useState } from 'react';
import { useHistory } from 'react-router';

import { SubmittableResult } from '@polkadot/api';
import TransactionContext from '@polkadot/app-builder/TransactionContext/TransactionContext';
import { Input, TextArea, UnqButton } from '@polkadot/react-components';
import { useCollection } from '@polkadot/react-hooks';
Expand All @@ -27,7 +28,7 @@ const stepText = 'Creating collection and saving it to blockchain';

function MainInformation (props: MainInformationProps): React.ReactElement {
const { account, description, name, setDescription, setName, setTokenPrefix, tokenPrefix } = props;
const { calculateCreateCollectionFee, createCollection, getCreatedCollectionCount } = useCollection();
const { calculateCreateCollectionFee, createCollection } = useCollection();
const [createFees, setCreateFees] = useState<BN | null>(null);
const history = useHistory();
const { setTransactions } = useContext(TransactionContext);
Expand All @@ -40,40 +41,32 @@ function MainInformation (props: MainInformationProps): React.ReactElement {
}
}, [account, calculateCreateCollectionFee, description, name, tokenPrefix]);

// @todo - get latest index if account is owner
const goToNextStep = useCallback(async () => {
/*
export function getCreateCollectionResult(events: EventRecord[]): CreateCollectionResult {
let success = false;
const goToNextStep = useCallback((result: SubmittableResult) => {
const { events } = result;

let collectionId = 0;
events.forEach(({event: {data, method, section}}) => {
// console.log(` ${phase}: ${section}.${method}:: ${data}`);
if (method == 'ExtrinsicSuccess') {
success = true;
} else if ((section == 'common') && (method == 'CollectionCreated')) {
collectionId = parseInt(data[0].toString(), 10);
}

events.forEach(({ event: { data, method, section } }) => {
if ((section === 'common') && (method === 'CollectionCreated')) {
collectionId = parseInt(data[0].toString(), 10);
}
});
const result: CreateCollectionResult = {
success,
collectionId,
};
return result;
}
*/

setTransactions([
{
state: 'finished',
text: stepText
}
]);

setTimeout(() => {
setTransactions([]);
}, 3000);
const collectionCount = await getCreatedCollectionCount();

history.push(`/builder/collections/${collectionCount}/cover`);
}, [setTransactions, getCreatedCollectionCount, history]);
if (collectionId) {
history.push(`/builder/collections/${collectionId}/cover`);
}
}, [setTransactions, history]);

const onCreateCollection = useCallback(() => {
if (account && name && tokenPrefix) {
Expand All @@ -83,6 +76,7 @@ function MainInformation (props: MainInformationProps): React.ReactElement {
text: stepText
}
]);

createCollection(account, {
description,
modeprm: { nft: null },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2021 @polkadot/apps, UseTech authors & contributors
// Copyright 2017-2022 @polkadot/apps, UseTech authors & contributors
// SPDX-License-Identifier: Apache-2.0

import './styles.scss';
Expand Down
6 changes: 4 additions & 2 deletions packages/page-builder/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright 2017-2021 @polkadot/apps , UseTech authors & contributors
// Copyright 2017-2022 @polkadot/apps , UseTech authors & contributors
// SPDX-License-Identifier: Apache-2.0

import './styles.scss';

import React, { useCallback, useEffect, useState } from 'react';

import envConfig from '@polkadot/apps-config/envConfig';
import { AppProps as Props } from '@polkadot/react-components/types';

import Disclaimer from './components/Disclaimer';
import Builder from './Builder';
import Transactions from './TransactionContext';
import envConfig from '@polkadot/apps-config/envConfig';

function CollectionBuilder (props: Props): React.ReactElement {
// const { allAccounts } = useAccounts();
Expand All @@ -28,8 +28,10 @@ function CollectionBuilder (props: Props): React.ReactElement {
const checkDisclaimer = useCallback(() => {
if (!uniqueTelegram) {
toggleDisclaimer(false);

return;
}

const builderDisclaimer = localStorage.getItem('BUILDER_DISCLAIMER');

toggleDisclaimer(!account || builderDisclaimer !== 'accepted');
Expand Down
46 changes: 17 additions & 29 deletions packages/react-components/src/Status/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
// Copyright 2017-2021 @polkadot/react-components authors & contributors
// Copyright 2017-2022 @polkadot/react-components authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { IconName } from '@fortawesome/fontawesome-svg-core';
import type { QueueStatus, QueueTx, QueueTxStatus } from './types';

import React, { useCallback, useContext, useEffect, useState } from 'react';
import React, { useContext, useEffect, useState } from 'react';
import styled from 'styled-components';

import AddressMini from '../AddressMini';
import Button from '../Button';
import Icon from '../Icon';
import Spinner from '../Spinner';
import { useTranslation } from '../translate';
import { STATUS_COMPLETE } from './constants';
import StatusContext from './Context';

Expand Down Expand Up @@ -84,8 +82,8 @@ function renderStatus ({ account, action, id, message, removeItem, status }: Que
<div className='desc'>
<div className='header'>
{Array.isArray(action)
? action.map((action, index) => <div key={index}>{action}</div>)
: action}
? action.map((action, index) => <div key={index}>{action.replace('Custom. ', '')}</div>)
: action.replace('Custom. ', '')}
</div>
{account && (
<AddressMini value={account} />
Expand Down Expand Up @@ -113,6 +111,11 @@ function renderItem ({ error, extrinsic, id, removeItem, rpc, status }: QueueTx)
}

const icon = signerIconName(status) as 'ban' | 'spinner';
const errorMessage = error?.message.includes('Inability to pay some fees') ? 'Error. Balance too low' : '';

if (!errorMessage) {
return null;
}

return (
<div
Expand All @@ -138,7 +141,7 @@ function renderItem ({ error, extrinsic, id, removeItem, rpc, status }: QueueTx)
{section}.{method}
</div>
<div className='status'>
{error ? (error.message || error) : status}
{errorMessage}
</div>
</div>
</div>
Expand All @@ -161,7 +164,6 @@ function Status ({ className = '' }: Props): React.ReactElement<Props> | null {
const { stqueue, txqueue } = useContext(StatusContext);
const [allSt, setAllSt] = useState<QueueStatus[]>([]);
const [[allTx, completedTx], setAllTx] = useState<[QueueTx[], QueueTx[]]>([[], []]);
const { t } = useTranslation();

useEffect((): void => {
setAllSt(filterSt(stqueue));
Expand All @@ -171,33 +173,19 @@ function Status ({ className = '' }: Props): React.ReactElement<Props> | null {
setAllTx(filterTx(txqueue));
}, [txqueue]);

const _onDismiss = useCallback(
(): void => {
allSt.map((s) => s.removeItem());
completedTx.map((t) => t.removeItem());
},
[allSt, completedTx]
);
console.log('allTx', allTx, 'completedTx', completedTx, 'allSt', allSt);

if (!allSt.length && !allTx.length) {
const txWithFeeError = allTx.filter((txItem) => txItem.error?.message.includes('Inability to pay some fees'));
const customEvents = allSt.filter((eventItem) => eventItem.action.includes('Custom'));

if (!txWithFeeError.length && !customEvents.length) {
return null;
}

return (
<div className={`ui--Status ${className}`}>
{(allSt.length + completedTx.length) > 1 && (
<div className='dismiss'>
<Button
icon='times'
isBasic
isFull
label={t<string>('Dismiss all notifications')}
onClick={_onDismiss}
/>
</div>
)}
{allTx.map(renderItem)}
{allSt.map(renderStatus)}
{txWithFeeError.map(renderItem)}
{customEvents.map(renderStatus)}
</div>
);
}
Expand Down
Loading

0 comments on commit e2aa2eb

Please sign in to comment.