* Bump API

* Updates

* u128 as balance

* update bounties test

* More bounties
This commit is contained in:
Jaco 2021-10-03 09:05:55 +03:00 committed by GitHub
parent f39acc0bb3
commit cc0fda5ab4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 694 additions and 1376 deletions

View File

@ -12,15 +12,15 @@
"packages/*" "packages/*"
], ],
"resolutions": { "resolutions": {
"@polkadot/api": "^6.0.5", "@polkadot/api": "^6.1.3-3",
"@polkadot/api-contract": "^6.0.5", "@polkadot/api-contract": "^6.1.3-3",
"@polkadot/hw-ledger": "^7.4.1", "@polkadot/hw-ledger": "^7.4.1",
"@polkadot/keyring": "^7.4.1", "@polkadot/keyring": "^7.4.1",
"@polkadot/networks": "^7.4.1", "@polkadot/networks": "^7.4.1",
"@polkadot/phishing": "^0.6.297", "@polkadot/phishing": "^0.6.321",
"@polkadot/types": "^6.0.5", "@polkadot/types": "^6.1.3-3",
"@polkadot/types-known": "^6.0.5", "@polkadot/types-known": "^6.1.3-3",
"@polkadot/types-support": "^6.0.5", "@polkadot/types-support": "^6.1.3-3",
"@polkadot/util": "^7.4.1", "@polkadot/util": "^7.4.1",
"@polkadot/util-crypto": "^7.4.1", "@polkadot/util-crypto": "^7.4.1",
"@polkadot/wasm-crypto": "^4.2.1", "@polkadot/wasm-crypto": "^4.2.1",
@ -73,7 +73,7 @@
"@babel/runtime": "^7.15.4", "@babel/runtime": "^7.15.4",
"@crustio/crust-pin": "^1.0.0", "@crustio/crust-pin": "^1.0.0",
"@pinata/sdk": "^1.1.23", "@pinata/sdk": "^1.1.23",
"@polkadot/dev": "^0.62.67", "@polkadot/dev": "^0.62.68",
"@polkadot/ts": "^0.4.8", "@polkadot/ts": "^0.4.8",
"@types/bn.js": "^4.11.6", "@types/bn.js": "^4.11.6",
"@types/chart.js": "^2.9.34", "@types/chart.js": "^2.9.34",

View File

@ -6,7 +6,7 @@
"dependencies": { "dependencies": {
"@babel/core": "^7.15.5", "@babel/core": "^7.15.5",
"@babel/polyfill": "^7.12.1", "@babel/polyfill": "^7.12.1",
"@polkadot/dev": "^0.62.67", "@polkadot/dev": "^0.62.68",
"@polkadot/react-components": "^0.96.2-36", "@polkadot/react-components": "^0.96.2-36",
"electron-log": "^4.3.5", "electron-log": "^4.3.5",
"electron-updater": "^4.3.10" "electron-updater": "^4.3.10"

View File

@ -11,7 +11,7 @@
"@babel/runtime": "^7.15.4", "@babel/runtime": "^7.15.4",
"@polkadot/apps-config": "^0.96.2-36", "@polkadot/apps-config": "^0.96.2-36",
"@polkadot/apps-routing": "^0.96.2-36", "@polkadot/apps-routing": "^0.96.2-36",
"@polkadot/dev": "^0.62.67", "@polkadot/dev": "^0.62.68",
"@polkadot/react-api": "^0.96.2-36", "@polkadot/react-api": "^0.96.2-36",
"@polkadot/react-components": "^0.96.2-36", "@polkadot/react-components": "^0.96.2-36",
"@polkadot/react-hooks": "^0.96.2-36", "@polkadot/react-hooks": "^0.96.2-36",

View File

@ -6,9 +6,9 @@
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.15.4", "@babel/runtime": "^7.15.4",
"@polkadot/phishing": "^0.6.297", "@polkadot/phishing": "^0.6.321",
"@polkadot/react-components": "^0.96.2-36", "@polkadot/react-components": "^0.96.2-36",
"@polkadot/vanitygen": "^0.46.2", "@polkadot/vanitygen": "^0.46.3-0",
"detect-browser": "^5.2.1", "detect-browser": "^5.2.1",
"file-saver": "^2.0.5" "file-saver": "^2.0.5"
}, },

View File

@ -3,7 +3,8 @@
import type { SubmittableExtrinsic } from '@polkadot/api/types'; import type { SubmittableExtrinsic } from '@polkadot/api/types';
import type { DeriveCollectiveProposal } from '@polkadot/api-derive/types'; import type { DeriveCollectiveProposal } from '@polkadot/api-derive/types';
import type { Bounty, BountyIndex, BountyStatus } from '@polkadot/types/interfaces'; import type { BountyIndex, BountyStatus } from '@polkadot/types/interfaces';
import type { PalletBountiesBounty } from '@polkadot/types/lookup';
import { fireEvent } from '@testing-library/react'; import { fireEvent } from '@testing-library/react';
import BN from 'bn.js'; import BN from 'bn.js';
@ -49,10 +50,10 @@ jest.mock('./hooks/useBounties', () => ({
let aProposal: (extrinsic: SubmittableExtrinsic<'promise'>, ayes?: string[], nays?: string[]) => DeriveCollectiveProposal; let aProposal: (extrinsic: SubmittableExtrinsic<'promise'>, ayes?: string[], nays?: string[]) => DeriveCollectiveProposal;
let augmentedApi: ApiPromise; let augmentedApi: ApiPromise;
let aBounty: ({ status, value }?: Partial<Bounty>) => Bounty; let aBounty: ({ status, value }?: Partial<PalletBountiesBounty>) => PalletBountiesBounty;
let aBountyIndex: (index?: number) => BountyIndex; let aBountyIndex: (index?: number) => BountyIndex;
let bountyStatusWith: ({ curator, status, updateDue }: { curator?: string, status?: string, updateDue?: number}) => BountyStatus; let bountyStatusWith: ({ curator, status, updateDue }: { curator?: string, status?: string, updateDue?: number}) => BountyStatus;
let bountyWith: ({ status, value }: { status?: string, value?: number }) => Bounty; let bountyWith: ({ status, value }: { status?: string, value?: number }) => PalletBountiesBounty;
describe('Bounties', () => { describe('Bounties', () => {
let bountiesPage: BountiesPage; let bountiesPage: BountiesPage;

View File

@ -1,6 +1,8 @@
// Copyright 2017-2021 @polkadot/app-bounties authors & contributors // Copyright 2017-2021 @polkadot/app-bounties authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { PalletBountiesBounty } from '@polkadot/types/lookup';
import { fireEvent, render, within } from '@testing-library/react'; import { fireEvent, render, within } from '@testing-library/react';
import React, { Suspense } from 'react'; import React, { Suspense } from 'react';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
@ -19,7 +21,7 @@ import { PartialQueueTxExtrinsic, QueueProps, QueueTxExtrinsicAdd } from '@polka
import { balanceOf } from '@polkadot/test-support/creation/balance'; import { balanceOf } from '@polkadot/test-support/creation/balance';
import { BountyFactory } from '@polkadot/test-support/creation/bounties/bountyFactory'; import { BountyFactory } from '@polkadot/test-support/creation/bounties/bountyFactory';
import { TypeRegistry } from '@polkadot/types/create'; import { TypeRegistry } from '@polkadot/types/create';
import { Bounty, BountyIndex, BountyStatus } from '@polkadot/types/interfaces'; import { BountyIndex, BountyStatus } from '@polkadot/types/interfaces';
import { mockBountyHooks } from '../hooks/defaults'; import { mockBountyHooks } from '../hooks/defaults';
import { clickButtonWithName } from '../utils/clickButtonWithName'; import { clickButtonWithName } from '../utils/clickButtonWithName';
@ -51,11 +53,11 @@ interface RenderedBountiesPage {
} }
export class BountiesPage { export class BountiesPage {
aBounty: ({ status, value }?: Partial<Bounty>) => Bounty; aBounty: ({ status, value }?: Partial<PalletBountiesBounty>) => PalletBountiesBounty;
aBountyIndex: (index?: number) => BountyIndex; aBountyIndex: (index?: number) => BountyIndex;
aBountyStatus: (status: string) => BountyStatus; aBountyStatus: (status: string) => BountyStatus;
bountyStatusWith: ({ curator, status }: { curator?: string, status?: string, }) => BountyStatus; bountyStatusWith: ({ curator, status }: { curator?: string, status?: string, }) => BountyStatus;
bountyWith: ({ status, value }: { status?: string, value?: number }) => Bounty; bountyWith: ({ status, value }: { status?: string, value?: number }) => PalletBountiesBounty;
findByRole?: FindOne; findByRole?: FindOne;
findByText?: FindOne; findByText?: FindOne;
@ -68,7 +70,7 @@ export class BountiesPage {
({ aBounty: this.aBounty, aBountyIndex: this.aBountyIndex, aBountyStatus: this.aBountyStatus, bountyStatusWith: this.bountyStatusWith, bountyWith: this.bountyWith } = new BountyFactory(api)); ({ aBounty: this.aBounty, aBountyIndex: this.aBountyIndex, aBountyStatus: this.aBountyStatus, bountyStatusWith: this.bountyStatusWith, bountyWith: this.bountyWith } = new BountyFactory(api));
} }
renderOne (bounty: Bounty, proposals: DeriveCollectiveProposal[] = [], description = '', index = this.aBountyIndex()): RenderedBountiesPage { renderOne (bounty: PalletBountiesBounty, proposals: DeriveCollectiveProposal[] = [], description = '', index = this.aBountyIndex()): RenderedBountiesPage {
return this.renderMany({ bounties: [{ bounty, description, index, proposals }] }); return this.renderMany({ bounties: [{ bounty, description, index, proposals }] });
} }

View File

@ -6,6 +6,6 @@
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.15.4", "@babel/runtime": "^7.15.4",
"@polkadot/api-contract": "^6.0.5" "@polkadot/api-contract": "^6.1.3-3"
} }
} }

View File

@ -155,7 +155,7 @@ function Fasttrack ({ imageHash, members, threshold }: Props): React.ReactElemen
)} )}
<Button <Button
icon='fast-forward' icon='fast-forward'
isDisabled={!threshold.isSimplemajority} isDisabled={!threshold.isSimpleMajority}
label={t<string>('Fast track')} label={t<string>('Fast track')}
onClick={toggleFasttrack} onClick={toggleFasttrack}
/> />

View File

@ -88,7 +88,7 @@ export function approxChanges (threshold: VoteThreshold, sqrtElectorate: BN, sta
const isPassing = calcPassing(threshold, sqrtElectorate, state); const isPassing = calcPassing(threshold, sqrtElectorate, state);
// simple case, we have an aye > nay to determine passing // simple case, we have an aye > nay to determine passing
if (threshold.isSimplemajority) { if (threshold.isSimpleMajority) {
const change = isPassing const change = isPassing
? state.votedAye.sub(state.votedNay) ? state.votedAye.sub(state.votedNay)
: state.votedNay.sub(state.votedAye); : state.votedNay.sub(state.votedAye);

View File

@ -6,9 +6,9 @@
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.15.4", "@babel/runtime": "^7.15.4",
"@polkadot/api": "^6.0.5", "@polkadot/api": "^6.1.3-3",
"@polkadot/extension-compat-metamask": "^0.40.3", "@polkadot/extension-compat-metamask": "^0.40.4-0",
"@polkadot/extension-dapp": "^0.40.3", "@polkadot/extension-dapp": "^0.40.4-0",
"@substrate/connect": "^0.3.18", "@substrate/connect": "^0.3.18",
"fflate": "^0.7.1", "fflate": "^0.7.1",
"rxjs": "^7.3.0" "rxjs": "^7.3.0"

View File

@ -9,7 +9,7 @@
"testcontainers": "^7.20.2" "testcontainers": "^7.20.2"
}, },
"devDependencies": { "devDependencies": {
"@polkadot/types-support": "^6.0.5", "@polkadot/types-support": "^6.1.3-3",
"@testing-library/jest-dom": "^5.14.1", "@testing-library/jest-dom": "^5.14.1",
"tsconfig-paths": "^3.11.0" "tsconfig-paths": "^3.11.0"
} }

View File

@ -1,12 +1,8 @@
// Copyright 2017-2021 @polkadot/test-supports authors & contributors // Copyright 2017-2021 @polkadot/test-supports authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { Balance } from '@polkadot/types/interfaces'; import { TypeRegistry, u128 as U128 } from '@polkadot/types';
import BN from 'bn.js'; export function balanceOf (number: number | string): U128 {
return new U128(new TypeRegistry(), number);
import { TypeRegistry } from '@polkadot/types/create';
export function balanceOf (number: number | string): Balance {
return new TypeRegistry().createType('Balance', new BN(number));
} }

View File

@ -3,7 +3,8 @@
import { ApiPromise } from '@polkadot/api'; import { ApiPromise } from '@polkadot/api';
import { balanceOf } from '@polkadot/test-support/creation/balance'; import { balanceOf } from '@polkadot/test-support/creation/balance';
import { Bounty, BountyIndex, BountyStatus } from '@polkadot/types/interfaces'; import { BountyIndex, BountyStatus } from '@polkadot/types/interfaces';
import { PalletBountiesBounty } from '@polkadot/types/lookup';
import { Registry } from '@polkadot/types/types'; import { Registry } from '@polkadot/types/types';
export class BountyFactory { export class BountyFactory {
@ -18,8 +19,8 @@ export class BountyFactory {
public aBountyIndex = (index = 0): BountyIndex => public aBountyIndex = (index = 0): BountyIndex =>
this.#registry.createType('BountyIndex', index); this.#registry.createType('BountyIndex', index);
public defaultBounty = (): Bounty => public defaultBounty = (): PalletBountiesBounty =>
this.#registry.createType('Bounty'); this.#registry.createType<PalletBountiesBounty>('Bounty');
public aBountyStatus = (status: string): BountyStatus => public aBountyStatus = (status: string): BountyStatus =>
this.#registry.createType('BountyStatus', status); this.#registry.createType('BountyStatus', status);
@ -36,9 +37,9 @@ export class BountyFactory {
throw new Error('Unsupported status'); throw new Error('Unsupported status');
}; };
public bountyWith = ({ status = 'Proposed', value = 1 } = {}): Bounty => public bountyWith = ({ status = 'Proposed', value = 1 } = {}): PalletBountiesBounty =>
this.aBounty({ status: this.aBountyStatus(status), value: balanceOf(value) }) this.aBounty({ status: this.aBountyStatus(status), value: balanceOf(value) })
public aBounty = ({ fee = balanceOf(10), status = this.aBountyStatus('Proposed'), value = balanceOf(500) }: Partial<Bounty> = {}): Bounty => public aBounty = ({ fee = balanceOf(10), status = this.aBountyStatus('Proposed'), value = balanceOf(500) }: Partial<PalletBountiesBounty> = {}): PalletBountiesBounty =>
this.#registry.createType('Bounty', { fee, status, value }); this.#registry.createType<PalletBountiesBounty>('Bounty', { fee, status, value });
} }

View File

@ -1,13 +1,13 @@
// Copyright 2017-2021 @polkadot/app-bounties authors & contributors // Copyright 2017-2021 @polkadot/app-bounties authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { StakingLedger } from '@polkadot/types/interfaces'; import type { PalletStakingStakingLedger } from '@polkadot/types/lookup';
import BN from 'bn.js'; import BN from 'bn.js';
import { TypeRegistry } from '@polkadot/types/create'; import { TypeRegistry } from '@polkadot/types/create';
export function makeStakingLedger (active: BN | number | string): StakingLedger { export function makeStakingLedger (active: BN | number | string): PalletStakingStakingLedger {
const reg = new TypeRegistry(); const reg = new TypeRegistry();
// Constructing the whole StakingLedger structure is hard, // Constructing the whole StakingLedger structure is hard,
@ -17,5 +17,5 @@ export function makeStakingLedger (active: BN | number | string): StakingLedger
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
return { return {
active: reg.createType('Compact<Balance>', reg.createType('Balance', new BN(active))) active: reg.createType('Compact<Balance>', reg.createType('Balance', new BN(active)))
} as StakingLedger; } as PalletStakingStakingLedger;
} }

1988
yarn.lock

File diff suppressed because it is too large Load Diff