Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polkadot API (PAPI) Integration PR #2335

Open
wants to merge 95 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
eb72b16
init papi ws / sm, get chainSpec
rossbulat Nov 14, 2024
d0d13ed
Merge branch 'main' into rb-papi-init-again
rossbulat Nov 14, 2024
65bf7ad
expose untyped api
rossbulat Nov 14, 2024
e3f2cbc
destroy on disconnect
rossbulat Nov 14, 2024
9fa4408
Merge branch 'main' into rb-papi-init-again
rossbulat Nov 15, 2024
2eb6454
consts to papi
rossbulat Nov 15, 2024
f64fb6c
activeEra to papi
rossbulat Nov 15, 2024
6e2e58f
NetworkMeta fetch to pApi
rossbulat Nov 15, 2024
cd39730
activeEra to `Subscription`
rossbulat Nov 15, 2024
b6d019e
renames & fix
rossbulat Nov 15, 2024
8f4984e
`BlockNumber` to pApi, polish
rossbulat Nov 15, 2024
3bd6ee3
mx rxjs to deps
rossbulat Nov 15, 2024
2448c99
network metrics to rxjs
rossbulat Nov 15, 2024
99bf80d
`PoolsConfig` to rxjs
rossbulat Nov 15, 2024
9f8ba80
`StakingMetrics` to rxjs
rossbulat Nov 15, 2024
197ecf0
version info to chainSpecs
rossbulat Nov 15, 2024
a4eeb55
rename
rossbulat Nov 15, 2024
286d2f5
`ValidatorEntries` to query class
rossbulat Nov 15, 2024
6dedac2
fix, api to constructor
rossbulat Nov 15, 2024
3617108
`ErasStakersOverview` to Query class
rossbulat Nov 15, 2024
659776b
`ErasStakersPaged` to Query class
rossbulat Nov 15, 2024
1107839
Merge branch 'main' into rb-papi-init-again
rossbulat Nov 16, 2024
da70698
add `BondedPoolsEntries` Query class
rossbulat Nov 16, 2024
b809001
entries to own directory
rossbulat Nov 16, 2024
40fd03e
paged result fix
rossbulat Nov 16, 2024
c16369a
`Bonded` to subscription
rossbulat Nov 16, 2024
b1be4e3
use `substrate-bindings` for pool address generation
rossbulat Nov 17, 2024
f998850
Merge branch 'main' into rb-papi-init-again
rossbulat Nov 17, 2024
9533928
add `FastUnstakeConfig` subscription
rossbulat Nov 18, 2024
40d9dbe
fix
rossbulat Nov 18, 2024
cc3663e
add type
rossbulat Nov 18, 2024
71cd4e5
rename
rossbulat Nov 18, 2024
c11b18f
polish
rossbulat Nov 18, 2024
f65b7c7
add `FastUnstakeQueue` subscription, rm from context
rossbulat Nov 18, 2024
969409c
rm log
rossbulat Nov 18, 2024
2af9b14
Abstract balances to `AccountBalances` subscription
rossbulat Nov 18, 2024
9af050a
fetch one `BondedPool`
rossbulat Nov 18, 2024
8a85908
stop fetching pool member entries
rossbulat Nov 18, 2024
b4805db
discontinue `queryPoolMember`
rossbulat Nov 18, 2024
2dbca34
fix
rossbulat Nov 18, 2024
2af98fb
remove discontinued list
rossbulat Nov 18, 2024
0b83be3
migrate Pool multi queries to classes
rossbulat Nov 18, 2024
61c0fe6
account proxies to `AccountProxies` subscription class
rossbulat Nov 18, 2024
9f1d0a1
migrate proxy query to `ProxiesQuery`
rossbulat Nov 18, 2024
6cb0cd8
add `IdentityOfMulti` class
rossbulat Nov 18, 2024
c8bc325
use `bestOrFinalized` = `best`
rossbulat Nov 18, 2024
c24eb3e
prepare `ActivePoolAccount` class
rossbulat Nov 18, 2024
9a5632f
remove "all roles" from Pool UI
rossbulat Nov 18, 2024
8e73d75
rm locales
rossbulat Nov 18, 2024
2952786
init `ActivePoolAccount` subscription & remove multi role logic
rossbulat Nov 18, 2024
2480764
migrate `IdentitiesController` to `pApi`
rossbulat Nov 18, 2024
e6446ff
migrate validator entries queries
rossbulat Nov 18, 2024
69e34a0
add `ParaSessionAccounts` query
rossbulat Nov 18, 2024
747e8ee
add `PoolMemberBatchEvent` and migrate pool member batches
rossbulat Nov 19, 2024
6209042
migrate `ValidatorEntries` multi queries
rossbulat Nov 19, 2024
116be10
migrate `ClaimedRewards`, `BondedMulti` queries
rossbulat Nov 19, 2024
acab254
migrate `Payouts` queries
rossbulat Nov 19, 2024
d60e784
fixes
rossbulat Nov 19, 2024
4f1f896
Merge branch 'main' into rb-papi-init-again
rossbulat Nov 19, 2024
c420245
Merge branch 'main' into rb-papi-init-again
rossbulat Nov 19, 2024
ae8772e
fix
rossbulat Nov 20, 2024
3bbc829
fix
rossbulat Nov 20, 2024
77fe892
prepare tx hooks
rossbulat Nov 20, 2024
b7e12a1
tx submission via papi
rossbulat Nov 21, 2024
bbdec4b
migrate remaining tx, stop exposing pjs api
rossbulat Nov 21, 2024
88d0119
fixes
rossbulat Nov 21, 2024
50d9f08
stop exposing `peopleApi`, combine ready events
rossbulat Nov 21, 2024
c1f2f58
stop connecting to pjs
rossbulat Nov 21, 2024
7968cd8
uninstall pjs
rossbulat Nov 21, 2024
ae651b7
refactor BalanceTest
rossbulat Nov 21, 2024
0537bd5
Ledger signer working
rossbulat Nov 21, 2024
d604440
queries, apis at best
rossbulat Nov 21, 2024
853e5b9
some vault boilerplate
rossbulat Nov 21, 2024
0c86a59
vault prompt behaviour working
rossbulat Nov 22, 2024
9c62543
vault signer working
rossbulat Nov 22, 2024
f768b6c
simplify wc sign button
rossbulat Nov 22, 2024
f59cffc
update types
rossbulat Nov 22, 2024
a2c3ffa
almost working
rossbulat Nov 22, 2024
bbc2853
fix block hash & number
rossbulat Nov 22, 2024
2c6f3bb
some tidy up
rossbulat Nov 22, 2024
40d7004
mv file
rossbulat Nov 22, 2024
7a5369b
amendments
rossbulat Nov 22, 2024
7c410a6
use fromHex
rossbulat Nov 22, 2024
2d25a6a
use `getPolkadotSignerFromPjs` for WC
rossbulat Nov 22, 2024
74cb808
pApi fixes
rossbulat Nov 22, 2024
172a7a8
back to unsafe
rossbulat Nov 22, 2024
9bc5ba7
wallet connect fix
rossbulat Nov 22, 2024
aa41ec1
merge
rossbulat Nov 22, 2024
d52a11e
add comment
rossbulat Nov 22, 2024
d04fa05
Merge branch 'main' into rb-papi-init-again
rossbulat Nov 23, 2024
226bbaf
Merge branch 'main' into rb-papi-init-again
rossbulat Nov 23, 2024
537ef4e
Merge branch 'main' into rb-papi-init-again
rossbulat Nov 26, 2024
716a146
more linting
rossbulat Nov 26, 2024
262d475
Merge branch 'main' into rb-papi-init-again
rossbulat Nov 26, 2024
dd5aa19
yarn
rossbulat Nov 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"lodash.debounce": "^4.0.8",
"lodash.throttle": "^4.1.1",
"plugin-staking-api": "workspace:*",
"polkadot-api": "^1.7.3",
"qrcode-generator": "1.4.4",
"rc-slider": "^11.1.6",
"react": "^18.3.1",
Expand All @@ -62,6 +63,7 @@
"react-i18next": "^15.0.2",
"react-router-dom": "^6.23.1",
"react-scroll": "^1.9.0",
"rxjs": "^7.8.1",
"styled-components": "^6.1.13",
"styles": "workspace:*",
"ui-buttons": "workspace:*",
Expand Down
24 changes: 18 additions & 6 deletions packages/app/src/config/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export const NetworkList: Networks = {
polkadot: {
name: 'polkadot',
endpoints: {
lightClient: 'polkadot',
lightClientKey: 'polkadot',
lightClient: async () => await import('polkadot-api/chains/polkadot'),
defaultRpcEndpoint: 'IBP-GeoDNS1',
rpcEndpoints: {
'Automata 1RPC': 'wss://1rpc.io/dot',
Expand Down Expand Up @@ -72,7 +73,8 @@ export const NetworkList: Networks = {
kusama: {
name: 'kusama',
endpoints: {
lightClient: 'ksmcc3',
lightClientKey: 'ksmcc3',
lightClient: async () => await import('polkadot-api/chains/ksmcc3'),
defaultRpcEndpoint: 'IBP-GeoDNS1',
rpcEndpoints: {
'Automata 1RPC': 'wss://1rpc.io/ksm',
Expand Down Expand Up @@ -127,7 +129,8 @@ export const NetworkList: Networks = {
westend: {
name: 'westend',
endpoints: {
lightClient: 'westend2',
lightClientKey: 'westend2',
lightClient: async () => await import('polkadot-api/chains/westend2'),
defaultRpcEndpoint: 'IBP-GeoDNS1',
rpcEndpoints: {
Dwellir: 'wss://westend-rpc.dwellir.com',
Expand Down Expand Up @@ -187,34 +190,43 @@ export const SystemChainList: Record<string, SystemChain> = {
units: 10,
unit: 'DOT',
endpoints: {
lightClient: 'polkadot_people',
lightClientKey: 'polkadot_people',
lightClient: async () =>
await import('polkadot-api/chains/polkadot_people'),
rpcEndpoints: {
Parity: 'wss://polkadot-people-rpc.polkadot.io',
},
},
relayChain: 'polkadot',
},
'people-kusama': {
name: 'people-kusama',
ss58: 2,
units: 12,
unit: 'KSM',
endpoints: {
lightClient: 'kusama_people',
lightClientKey: 'ksmcc3_people',
lightClient: async () =>
await import('polkadot-api/chains/ksmcc3_people'),
rpcEndpoints: {
Parity: 'wss://kusama-people-rpc.polkadot.io',
},
},
relayChain: 'kusama',
},
'people-westend': {
name: 'people-westend',
ss58: 42,
units: 12,
unit: 'WND',
endpoints: {
lightClient: 'westend_people',
lightClientKey: 'westend2_people',
lightClient: async () =>
await import('polkadot-api/chains/westend2_people'),
rpcEndpoints: {
Parity: 'wss://westend-people-rpc.polkadot.io',
},
},
relayChain: 'westend',
},
};
45 changes: 45 additions & 0 deletions packages/app/src/config/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import type { ApiChainType } from 'model/Api/types';
import type { AnyApi, NetworkName, SystemChainId } from 'types';
import { NetworkList, SystemChainList } from './networks';

// Get the light client metadata for the given chain type and network.
export const getLightClientMetadata = (
chainType: ApiChainType,
network: NetworkName | SystemChainId
): {
chain: {
key: string;
fn: () => Promise<AnyApi>;
};
relay?: {
key: string;
fn: () => Promise<AnyApi>;
};
} => {
if (chainType === 'relay') {
return {
chain: {
key: NetworkList[network].endpoints.lightClientKey,
fn: NetworkList[network].endpoints.lightClient,
},
};
}

const { relayChain } = SystemChainList[network];
const relay = NetworkList[relayChain];
const system = SystemChainList[network];

return {
relay: {
key: relay.endpoints.lightClientKey,
fn: relay.endpoints.lightClient,
},
chain: {
key: system.endpoints.lightClientKey,
fn: system.endpoints.lightClient,
},
};
};
28 changes: 17 additions & 11 deletions packages/app/src/contexts/Api/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,14 @@ import { stringToU8a } from '@polkadot/util';
import BigNumber from 'bignumber.js';
import type {
APIActiveEra,
APIChainState,
APIConstants,
APIContextInterface,
APINetworkMetrics,
APIPoolsConfig,
APIStakingMetrics,
PapiChainSpecContext,
} from 'contexts/Api/types';

export const defaultChainState: APIChainState = {
chain: null,
version: {
specVersion: 0,
},
ss58Prefix: 0,
};

export const defaultConsts: APIConstants = {
bondDuration: new BigNumber(0),
maxNominations: new BigNumber(0),
Expand All @@ -43,6 +35,21 @@ export const defaultNetworkMetrics: APINetworkMetrics = {
minimumActiveStake: new BigNumber(0),
};

export const defaultChainSpecs: PapiChainSpecContext = {
genesisHash: '',
ss58Format: 0,
tokenDecimals: 0,
tokenSymbol: '',
received: false,
authoringVersion: 0,
implName: '',
implVersion: 0,
specName: '',
specVersion: 0,
stateVersion: 0,
transactionVersion: 0,
};

export const defaultActiveEra: APIActiveEra = {
index: new BigNumber(0),
start: new BigNumber(0),
Expand All @@ -62,7 +69,6 @@ export const defaultPoolsConfig: APIPoolsConfig = {
};

export const defaultStakingMetrics: APIStakingMetrics = {
totalNominators: new BigNumber(0),
totalValidators: new BigNumber(0),
lastReward: new BigNumber(0),
lastTotalStake: new BigNumber(0),
Expand All @@ -76,7 +82,7 @@ export const defaultStakingMetrics: APIStakingMetrics = {
export const defaultApiContext: APIContextInterface = {
api: null,
peopleApi: null,
chainState: defaultChainState,
chainSpecs: defaultChainSpecs,
isReady: false,
apiStatus: 'disconnected',
peopleApiStatus: 'disconnected',
Expand Down
Loading
Loading