Remove rent projection (#6185)
This commit is contained in:
parent
9d5aeee15b
commit
7320d08c10
@ -4,18 +4,17 @@
|
||||
import type { ContractCallOutcome } from '@polkadot/api-contract/types';
|
||||
import type { ActionStatus } from '@polkadot/react-components/Status/types';
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { BlockNumber, ContractInfo } from '@polkadot/types/interfaces';
|
||||
import type { ContractInfo } from '@polkadot/types/interfaces';
|
||||
import type { ContractLink } from './types';
|
||||
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import React, { useCallback } from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { ContractPromise } from '@polkadot/api-contract';
|
||||
import { AddressInfo, AddressMini, Button, Forget } from '@polkadot/react-components';
|
||||
import { useApi, useBestNumber, useCall, useToggle } from '@polkadot/react-hooks';
|
||||
import { BlockToTime } from '@polkadot/react-query';
|
||||
import { useApi, useCall, useToggle } from '@polkadot/react-hooks';
|
||||
import { keyring } from '@polkadot/ui-keyring';
|
||||
import { formatNumber, isFunction, isUndefined } from '@polkadot/util';
|
||||
import { isUndefined } from '@polkadot/util';
|
||||
|
||||
import Messages from '../shared/Messages';
|
||||
import { useTranslation } from '../translate';
|
||||
@ -35,20 +34,9 @@ function transformInfo (optInfo: Option<ContractInfo>): ContractInfo | null {
|
||||
function Contract ({ className, contract, index, links, onCall }: Props): React.ReactElement<Props> | null {
|
||||
const { t } = useTranslation();
|
||||
const { api } = useApi();
|
||||
const bestNumber = useBestNumber();
|
||||
const info = useCall<ContractInfo | null>(api.query.contracts.contractInfoOf, [contract.address], { transform: transformInfo });
|
||||
const [evictAt, setEvictAt] = useState<BlockNumber | null>(null);
|
||||
const [isForgetOpen, toggleIsForgetOpen] = useToggle();
|
||||
|
||||
useEffect((): void => {
|
||||
if (info && isFunction(api.rpc.contracts?.rentProjection)) {
|
||||
api.rpc.contracts
|
||||
.rentProjection(contract.address)
|
||||
.then((value) => setEvictAt(value.unwrapOr(null)))
|
||||
.catch(() => undefined);
|
||||
}
|
||||
}, [api, contract, info]);
|
||||
|
||||
const _onCall = useCallback(
|
||||
(messageIndex: number, resultCb: (messageIndex: number, result?: ContractCallOutcome) => void) =>
|
||||
onCall(index, messageIndex, resultCb),
|
||||
@ -122,18 +110,6 @@ function Contract ({ className, contract, index, links, onCall }: Props): React.
|
||||
: t<string>('Not on-chain')
|
||||
)}
|
||||
</td>
|
||||
<td className='number together media--1100'>
|
||||
{bestNumber && (
|
||||
evictAt
|
||||
? (
|
||||
<>
|
||||
<BlockToTime value={evictAt.sub(bestNumber)} />
|
||||
#{formatNumber(evictAt)}
|
||||
</>
|
||||
)
|
||||
: t<string>('None')
|
||||
)}
|
||||
</td>
|
||||
<td className='button'>
|
||||
<Button
|
||||
icon='trash'
|
||||
|
||||
@ -47,7 +47,6 @@ function ContractsTable ({ contracts: keyringContracts }: Props): React.ReactEle
|
||||
[t('contracts'), 'start'],
|
||||
[undefined, undefined, 3],
|
||||
[t('status'), 'start'],
|
||||
[t('projection'), 'media--1100'],
|
||||
[]
|
||||
]);
|
||||
|
||||
|
||||
@ -12,11 +12,11 @@ import { useToggle } from '@polkadot/react-hooks';
|
||||
import Codes from '../Codes';
|
||||
import CodeAdd from '../Codes/Add';
|
||||
import CodeUpload from '../Codes/Upload';
|
||||
import ContractAdd from '../Contracts/Add';
|
||||
import ContractsTable from '../Contracts/ContractsTable';
|
||||
import { useTranslation } from '../translate';
|
||||
import { useCodes } from '../useCodes';
|
||||
import { useContracts } from '../useContracts';
|
||||
import ContractAdd from './Add';
|
||||
import ContractsTable from './ContractsTable';
|
||||
import Deploy from './Deploy';
|
||||
import Summary from './Summary';
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user