Skip to content

Commit

Permalink
Bump API (#2224)
Browse files Browse the repository at this point in the history
* Bump API

* Type adjustments

* Update zero const
  • Loading branch information
jacogr authored Feb 2, 2020
1 parent 8469978 commit efd0e72
Show file tree
Hide file tree
Showing 20 changed files with 90 additions and 86 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"packages/*"
],
"resolutions": {
"@polkadot/api": "^1.1.0-beta.6",
"@polkadot/api-contract": "^1.1.0-beta.6",
"@polkadot/api": "^1.1.0-beta.8",
"@polkadot/api-contract": "^1.1.0-beta.8",
"@polkadot/keyring": "^2.0.1",
"@polkadot/types": "^1.1.0-beta.6",
"@polkadot/types": "^1.1.0-beta.8",
"@polkadot/util": "^2.0.1",
"@polkadot/util-crypto": "^2.0.1",
"babel-core": "^7.0.0-bridge.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/app-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.8.3",
"@polkadot/api-contract": "^1.1.0-beta.6"
"@polkadot/api-contract": "^1.1.0-beta.8"
}
}
4 changes: 2 additions & 2 deletions packages/app-council/src/Overview/VoteValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import { DerivedBalances } from '@polkadot/api-derive/types';
import { DerivedBalancesAll } from '@polkadot/api-derive/types';

import BN from 'bn.js';
import React, { useEffect, useState } from 'react';
Expand All @@ -26,7 +26,7 @@ interface ValueState {
export default function VoteValue ({ accountId, onChange }: Props): React.ReactElement<Props> | null {
const { t } = useTranslation();
const { api } = useApi();
const allBalances = useCall<DerivedBalances>(api.derive.balances.all as any, [accountId]);
const allBalances = useCall<DerivedBalancesAll>(api.derive.balances.all as any, [accountId]);
const [{ selectedId, value }, setValue] = useState<ValueState>({});

// TODO This may be useful elsewhere, so figure out a way to make this a utility
Expand Down
4 changes: 2 additions & 2 deletions packages/app-extrinsics/src/Balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { BareProps } from '@polkadot/react-api/types';

import React from 'react';
import { DerivedBalances } from '@polkadot/api-derive/types';
import { DerivedBalancesAll } from '@polkadot/api-derive/types';
import { InputBalance } from '@polkadot/react-components';
import { useApi, useCall } from '@polkadot/react-hooks';

Expand All @@ -16,7 +16,7 @@ interface Props extends BareProps {

export default function BalanceDisplay ({ className, label, params, style }: Props): React.ReactElement<Props> {
const { api } = useApi();
const allBalances = useCall<DerivedBalances>(api.derive.balances.all as any, [params]);
const allBalances = useCall<DerivedBalancesAll>(api.derive.balances.all as any, [params]);

return (
<InputBalance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import { DerivedBalances } from '@polkadot/api-derive/types';
import { DerivedBalancesAll } from '@polkadot/api-derive/types';
import { I18nProps } from '@polkadot/react-components/types';

import BN from 'bn.js';
Expand All @@ -20,7 +20,7 @@ interface Props extends I18nProps {

function ValidateAmount ({ accountId, onError, value, t }: Props): React.ReactElement<Props> | null {
const { api } = useApi();
const allBalances = useCall<DerivedBalances>(api.derive.balances.all as any, [accountId]);
const allBalances = useCall<DerivedBalancesAll>(api.derive.balances.all as any, [accountId]);
const [error, setError] = useState<string | null>(null);

useEffect((): void => {
Expand Down
4 changes: 2 additions & 2 deletions packages/app-staking/src/Actions/Account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import { DerivedBalances, DerivedStakingAccount, DerivedStakingOverview, DerivedHeartbeats } from '@polkadot/api-derive/types';
import { DerivedBalancesAll, DerivedStakingAccount, DerivedStakingOverview, DerivedHeartbeats } from '@polkadot/api-derive/types';
import { AccountId, Exposure, StakingLedger, ValidatorPrefs } from '@polkadot/types/interfaces';
import { Codec, ITuple } from '@polkadot/types/types';

Expand Down Expand Up @@ -92,7 +92,7 @@ function Account ({ allStashes, className, isOwnStash, next, onUpdateType, staki
const { api } = useApi();
const { allAccounts } = useAccounts();
const validateInfo = useCall<ValidatorInfo>(api.query.staking.validators, [stashId]);
const balancesAll = useCall<DerivedBalances>(api.derive.balances.all as any, [stashId]);
const balancesAll = useCall<DerivedBalancesAll>(api.derive.balances.all as any, [stashId]);
const stakingAccount = useCall<DerivedStakingAccount>(api.derive.staking.account as any, [stashId]);
const [{ controllerId, destination, hexSessionIdQueue, hexSessionIdNext, isLoading, isOwnController, isStashNominating, isStashValidating, nominees, sessionIds, validatorPrefs }, setStakeState] = useState<StakeState>({ controllerId: null, destination: 0, hexSessionIdNext: null, hexSessionIdQueue: null, isLoading: true, isOwnController: false, isStashNominating: false, isStashValidating: false, sessionIds: [] });
const [activeNoms, setActiveNoms] = useState<string[]>([]);
Expand Down
4 changes: 2 additions & 2 deletions packages/app-staking/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import { DerivedFees, DerivedBalances } from '@polkadot/api-derive/types';
import { DerivedFees, DerivedBalancesAll } from '@polkadot/api-derive/types';
import { AccountId, Balance, BlockNumber, Hash, SessionIndex } from '@polkadot/types/interfaces';

export type Nominators = Record<string, string[]>;

export interface CalculateBalanceProps {
balances_fees?: DerivedFees;
balances_all?: DerivedBalances;
balances_all?: DerivedBalancesAll;
}

export type AccountFilter = 'all' | 'controller' | 'session' | 'stash' | 'unbonded';
Expand Down
12 changes: 7 additions & 5 deletions packages/app-treasury/src/Overview/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import BN from 'bn.js';
import { DerivedBalancesAccount } from '@polkadot/api-derive/types';
import { Balance } from '@polkadot/types/interfaces';

import React from 'react';
import { SummaryBox, CardSummary } from '@polkadot/react-components';
import { useApi, useCall } from '@polkadot/react-hooks';
Expand All @@ -21,12 +23,12 @@ interface Props {
export default function Summary ({ approvalCount, proposalCount }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const { api } = useApi();
const bestNumber = useCall<BN>(api.derive.chain.bestNumber as any, []);
const bestNumber = useCall<Balance>(api.derive.chain.bestNumber as any, []);
const spendPeriod = api.consts.treasury.spendPeriod;
const treasuryBalance = useCall<BN>(api.query.balances.freeBalance, [TREASURY_ACCOUNT]);
const treasuryBalance = useCall<DerivedBalancesAccount>(api.derive.balances.account as any, [TREASURY_ACCOUNT]);

const value = treasuryBalance?.gtn(0)
? treasuryBalance.toString()
const value = treasuryBalance?.freeBalance.gtn(0)
? treasuryBalance.freeBalance.toString()
: null;

return (
Expand Down
2 changes: 1 addition & 1 deletion packages/react-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"homepage": "https://github.com/polkadot-js/ui/tree/master/packages/ui-reactive#readme",
"dependencies": {
"@babel/runtime": "^7.8.3",
"@polkadot/api": "^1.1.0-beta.6",
"@polkadot/api": "^1.1.0-beta.8",
"@polkadot/extension-dapp": "^0.21.0-beta.1",
"edgeware-node-types": "^1.1.0",
"rxjs-compat": "^6.5.3"
Expand Down
4 changes: 2 additions & 2 deletions packages/react-components/src/AddressInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import { DerivedBalances, DerivedStakingAccount } from '@polkadot/api-derive/types';
import { DerivedBalancesAll, DerivedStakingAccount } from '@polkadot/api-derive/types';
import { ValidatorPrefsTo145 } from '@polkadot/types/interfaces';
import { BareProps } from './types';

Expand Down Expand Up @@ -46,7 +46,7 @@ const PERBILL = new BN(1000000000);

interface Props extends BareProps {
address: string;
balancesAll?: DerivedBalances;
balancesAll?: DerivedBalancesAll;
children?: React.ReactNode;
extraInfo?: [string, string][];
stakingInfo?: DerivedStakingAccount;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-components/src/InputBalanceBonded.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.

import { BareProps, BitLength } from './types';
import { DerivedFees, DerivedBalances } from '@polkadot/api-derive/types';
import { DerivedFees, DerivedBalancesAll } from '@polkadot/api-derive/types';

import BN from 'bn.js';
import React from 'react';
Expand All @@ -20,7 +20,7 @@ import { bnMax } from '@polkadot/util';
interface Props extends BareProps, ApiProps {
autoFocus?: boolean;
balances_fees?: DerivedFees;
balances_all?: DerivedBalances;
balances_all?: DerivedBalancesAll;
controllerId: string;
defaultValue?: BN | string;
destination?: number;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-query/src/Available.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.

import { BareProps } from '@polkadot/react-api/types';
import { DerivedBalances } from '@polkadot/api-derive/types';
import { DerivedBalancesAll } from '@polkadot/api-derive/types';
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';

import React from 'react';
Expand All @@ -19,7 +19,7 @@ interface Props extends BareProps {

export default function AvailableDisplay ({ children, className, label, params }: Props): React.ReactElement<Props> {
const { api } = useApi();
const allBalances = useCall<DerivedBalances>(api.derive.balances.all as any, [params]);
const allBalances = useCall<DerivedBalancesAll>(api.derive.balances.all as any, [params]);

return (
<FormatBalance
Expand Down
4 changes: 2 additions & 2 deletions packages/react-query/src/Balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.

import { BareProps } from '@polkadot/react-api/types';
import { DerivedBalances } from '@polkadot/api-derive/types';
import { DerivedBalancesAll } from '@polkadot/api-derive/types';
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';

import React from 'react';
Expand All @@ -19,7 +19,7 @@ interface Props extends BareProps {

export default function BalanceDisplay ({ children, className, label, params }: Props): React.ReactElement<Props> {
const { api } = useApi();
const allBalances = useCall<DerivedBalances>(api.derive.balances.all as any, [params]);
const allBalances = useCall<DerivedBalancesAll>(api.derive.balances.all as any, [params]);

return (
<FormatBalance
Expand Down
4 changes: 2 additions & 2 deletions packages/react-query/src/BalanceFree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.

import { BareProps } from '@polkadot/react-api/types';
import { DerivedBalances } from '@polkadot/api-derive/types';
import { DerivedBalancesAll } from '@polkadot/api-derive/types';
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';

import React from 'react';
Expand All @@ -19,7 +19,7 @@ interface Props extends BareProps {

export default function BalanceFree ({ children, className, label, params }: Props): React.ReactElement<Props> {
const { api } = useApi();
const allBalances = useCall<DerivedBalances>(api.derive.balances.all as any, [params]);
const allBalances = useCall<DerivedBalancesAll>(api.derive.balances.all as any, [params]);

return (
<FormatBalance
Expand Down
4 changes: 2 additions & 2 deletions packages/react-query/src/BalanceVoting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.

import { BareProps } from '@polkadot/react-api/types';
import { DerivedBalances } from '@polkadot/api-derive/types';
import { DerivedBalancesAll } from '@polkadot/api-derive/types';
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';

import React from 'react';
Expand All @@ -19,7 +19,7 @@ interface Props extends BareProps {

export default function BalanceVoting ({ children, className, label, params }: Props): React.ReactElement<Props> {
const { api } = useApi();
const allBalances = useCall<DerivedBalances>(api.derive.balances.all as any, [params]);
const allBalances = useCall<DerivedBalancesAll>(api.derive.balances.all as any, [params]);

return (
<FormatBalance
Expand Down
4 changes: 2 additions & 2 deletions packages/react-query/src/Nonce.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import { DerivedBalances } from '@polkadot/api-derive/types';
import { DerivedBalancesAll } from '@polkadot/api-derive/types';
import { BareProps } from '@polkadot/react-api/types';

import BN from 'bn.js';
Expand All @@ -19,7 +19,7 @@ interface Props extends BareProps {

export default function Nonce ({ children, className, label, params }: Props): React.ReactElement<Props> {
const { api } = useApi();
const allBalances = useCall<DerivedBalances>(api.derive.balances.all as any, [params]);
const allBalances = useCall<DerivedBalancesAll>(api.derive.balances.all as any, [params]);

return (
<div className={className}>
Expand Down
4 changes: 2 additions & 2 deletions packages/react-signer/src/Checks/Transfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import { DerivedBalances, DerivedFees } from '@polkadot/api-derive/types';
import { DerivedBalancesAll, DerivedFees } from '@polkadot/api-derive/types';
import { AccountId } from '@polkadot/types/interfaces';
import { ExtraFees } from './types';

Expand Down Expand Up @@ -30,7 +30,7 @@ interface State extends ExtraFees {
export default function Transfer ({ amount, fees, onChange, recipientId }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const { api } = useApi();
const allBalances = useCall<DerivedBalances>(api.derive.balances.all as any, [recipientId]);
const allBalances = useCall<DerivedBalancesAll>(api.derive.balances.all as any, [recipientId]);
const [{ isCreation, isNoEffect }, setState] = useState<State>({
extraFees: new BN(0),
extraAmount: new BN(0),
Expand Down
6 changes: 4 additions & 2 deletions packages/react-signer/src/Checks/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import { DerivedFees, DerivedBalances, DerivedContractFees } from '@polkadot/api-derive/types';
import { DerivedFees, DerivedBalancesAll, DerivedContractFees } from '@polkadot/api-derive/types';

import BN from 'bn.js';
import { registry } from '@polkadot/react-api';
import { createType } from '@polkadot/types';

const ZERO_BALANCE: DerivedBalances = {
const ZERO_BALANCE: DerivedBalancesAll = {
accountId: createType(registry, 'AccountId'),
accountNonce: createType(registry, 'Index'),
availableBalance: createType(registry, 'Balance'),
freeBalance: createType(registry, 'Balance'),
frozenFee: createType(registry, 'Balance'),
frozenMisc: createType(registry, 'Balance'),
isVesting: false,
lockedBalance: createType(registry, 'Balance'),
lockedBreakdown: [],
Expand Down
4 changes: 2 additions & 2 deletions packages/react-signer/src/Checks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.

import { SubmittableExtrinsic } from '@polkadot/api/promise/types';
import { DerivedFees, DerivedBalances, DerivedContractFees } from '@polkadot/api-derive/types';
import { DerivedFees, DerivedBalancesAll, DerivedContractFees } from '@polkadot/api-derive/types';
import { AccountId, RuntimeDispatchInfo } from '@polkadot/types/interfaces';
import { IExtrinsic } from '@polkadot/types/types';
import { ExtraFees } from './types';
Expand Down Expand Up @@ -37,7 +37,7 @@ interface State {

interface Props {
balances_fees?: DerivedFees;
balances_all?: DerivedBalances;
balances_all?: DerivedBalancesAll;
contract_fees?: DerivedContractFees;
accountId?: string | null;
className?: string;
Expand Down
Loading

0 comments on commit efd0e72

Please sign in to comment.