Skip to content

Commit e480cbd

Browse files
api, api-{augment, base, contract, derive}, rpc-{augment, core, provider}, types, types-{augment, codec, create, known} 15.7.2
1 parent 0275b09 commit e480cbd

File tree

98 files changed

+1208
-91
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1208
-91
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## master
44

5+
- api, api-{augment, base, contract, derive}, rpc-{augment, core, provider}, types, types-{augment, codec, create, known} 15.7.2
56
- api, api-{augment, base, contract, derive}, rpc-{augment, core, provider}, types, types-{augment, codec, create, known} 15.7.1
67
- phishing 0.25.4
78
- api, api-{augment, base, contract, derive}, rpc-{augment, core, provider}, types, types-{augment, codec, create, known} 15.6.1

api-augment/packageInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
export const packageInfo = { name: '@polkadot/api-augment', path: new URL(import.meta.url).pathname, type: 'deno', version: '15.7.1' };
3+
export const packageInfo = { name: '@polkadot/api-augment', path: new URL(import.meta.url).pathname, type: 'deno', version: '15.7.2' };

api-base/packageInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
export const packageInfo = { name: '@polkadot/api-base', path: new URL(import.meta.url).pathname, type: 'deno', version: '15.7.1' };
3+
export const packageInfo = { name: '@polkadot/api-base', path: new URL(import.meta.url).pathname, type: 'deno', version: '15.7.2' };

api-contract/packageInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
export const packageInfo = { name: '@polkadot/api-contract', path: new URL(import.meta.url).pathname, type: 'deno', version: '15.7.1' };
3+
export const packageInfo = { name: '@polkadot/api-contract', path: new URL(import.meta.url).pathname, type: 'deno', version: '15.7.2' };

api-derive/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,28 @@
33
Collection of high-level utility functions built on top of the @polkadot/api library. Designed to simplify the process of querying complex on-chain data by combining multiple RPC calls, storage queries, and runtime logic into a single, callable function.
44

55
Instead of manually fetching and processing blockchain data, developers can use `api.derive` methods to retrieve information.
6+
7+
## Available Derive Namespaces
8+
9+
The derive functions are categorized into namespaces based on different common Substrate modules. Accesible by calling `api.derive.NAMESPACE` (e.g. `api.derive.balances`). The available modules are as follows:
10+
11+
- [accounts](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/accounts)
12+
- [alliance](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/alliance)
13+
- [bagsList](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/bagsList)
14+
- [balances](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/balances)
15+
- [bounties](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/bounties)
16+
- [chain](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/chain)
17+
- [contracts](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/contracts)
18+
- [council](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/council)
19+
- [crowdloan](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/crowdloan)
20+
- [democracy](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/democracy)
21+
- [elections](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/elections)
22+
- [imOnline](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/imOnline)
23+
- [membership](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/membership)
24+
- [parachains](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/parachains)
25+
- [session](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/session)
26+
- [society](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/society)
27+
- [staking](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/staking)
28+
- [technicalCommittee](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/technicalCommittee)
29+
- [treasury](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/treasury)
30+
- [tx](https://github.com/polkadot-js/api/tree/master/packages/api-derive/src/tx)

api-derive/accounts/accountId.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ import { memo } from '../util/index.ts';
1313
/**
1414
* @name accountId
1515
* @param {(Address | AccountId | AccountIndex | string | null)} address An accounts address in various formats.
16-
* @description An [[AccountId]]
16+
* @description Resolves an address (in different formats) to its corresponding `AccountId`.
17+
* @example
18+
* ```javascript
19+
* const ALICE = "F7Hs";
20+
*
21+
* api.derive.accounts.accountId(ALICE, (accountId) => {
22+
* console.log(`Resolved AccountId: ${accountId}`);
23+
* });
24+
* ```
1725
*/
1826
export function accountId (instanceId: string, api: DeriveApi): (address?: Address | AccountId | AccountIndex | string | null) => Observable<AccountId> {
1927
return memo(instanceId, (address?: Address | AccountId | AccountIndex | string | null): Observable<AccountId> => {

api-derive/accounts/flags.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,18 @@ export function _flags (instanceId: string, api: DeriveApi): () => Observable<Fl
6666
}
6767

6868
/**
69-
* @name info
70-
* @description Returns account membership flags
69+
* @name flags
70+
* @param {(AccountId | Address | string | null)} address The account identifier.
71+
* @description Retrieves the membership flags for a given account.
72+
* @example
73+
* const ALICE = "F7Hs";
74+
*
75+
* api.derive.accounts.flags(ALICE, (flags) => {
76+
* console.log(
77+
* `Account Flags:`,
78+
* Object.keys(flags).map((flag) => `${flag}: ${flags[flag]}`)
79+
* );
80+
* });
7181
*/
7282
export function flags (instanceId: string, api: DeriveApi): (address?: AccountId | Address | string | null) => Observable<DeriveAccountFlags> {
7383
return memo(instanceId, (address?: AccountId | Address | string | null): Observable<DeriveAccountFlags> =>

api-derive/accounts/idAndIndex.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ import { memo } from '../util/index.ts';
1212

1313
/**
1414
* @name idAndIndex
15-
* @param {(Address | AccountId | AccountIndex | Uint8Array | string | null)} address - An accounts address in various formats.
16-
* @description An array containing the [[AccountId]] and [[AccountIndex]] as optional values.
15+
* @param {(Address | AccountId | AccountIndex | Uint8Array | string | null)} address An accounts address in various formats.
16+
* @description An array containing the [[AccountId]] and [[AccountIndex]] as optional values.
1717
* @example
18-
* <BR>
19-
*
2018
* ```javascript
2119
* api.derive.accounts.idAndIndex('F7Hs', ([id, ix]) => {
2220
* console.log(`AccountId #${id} with corresponding AccountIndex ${ix}`);

api-derive/accounts/idToIndex.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ import { memo } from '../util/index.ts';
99

1010
/**
1111
* @name idToIndex
12-
* @param {( AccountId | string )} accountId - An accounts Id in different formats.
13-
* @returns Returns the corresponding AccountIndex.
12+
* @description Retrieves the corresponding AccountIndex.
13+
* @param {( AccountId | string )} accountId An accounts Id in different formats.
1414
* @example
15-
* <BR>
16-
*
1715
* ```javascript
1816
* const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
1917
* api.derive.accounts.idToIndex(ALICE, (accountIndex) => {

api-derive/accounts/identity.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,19 @@ export function _identity (instanceId: string, api: DeriveApi): (accountId?: Acc
122122

123123
/**
124124
* @name identity
125-
* @description Returns identity info for an account
125+
* @description Retrieves the on chain identity information for a given account.
126+
* @param {(AccountId | Uint8Array | string)} accoutId The account identifier to query the identity for.
127+
* @example
128+
* ```javascript
129+
* const ALICE = "13xAUH";
130+
*
131+
* api.derive.accounts.identity(ALICE, (identity) => {
132+
* console.log(
133+
* "Account Identity:",
134+
* Object.keys(identity).map((key) => `${key}: ${identity[key]}`)
135+
* );
136+
* });
137+
* ```
126138
*/
127139
export function identity (instanceId: string, api: DeriveApi): (accountId?: AccountId | Uint8Array | string) => Observable<DeriveAccountRegistration> {
128140
return memo(instanceId, (accountId?: AccountId | Uint8Array | string): Observable<DeriveAccountRegistration> =>
@@ -160,11 +172,32 @@ function getSubIdentities (identity: DeriveAccountRegistration, api: DeriveApi,
160172
);
161173
}
162174

175+
/**
176+
* @name hasIdentity
177+
* @description Checks if a specific account has an identity registered on chain.
178+
* @param {(AccountId | Uint8Array | string)} accoutId The account identifier to query.
179+
* @example
180+
* ```javascript
181+
* const ALICE = "13AU";
182+
* console.log(await api.derive.accounts.hasIdentity(ALICE));
183+
* ```
184+
*/
163185
export const hasIdentity = /*#__PURE__*/ firstMemo(
164186
(api: DeriveApi, accountId: AccountId | Uint8Array | string) =>
165187
api.derive.accounts.hasIdentityMulti([accountId])
166188
);
167189

190+
/**
191+
* @name hasIdentityMulti
192+
* @description Checks whether multiple accounts have on chain identities registered.
193+
* @param {(AccountId | Uint8Array | string)[]} accountIds Array of account identifiers to query.
194+
* @example
195+
* ```javascript
196+
* const ALICE = "13AU";
197+
* const BOB = "16WW";
198+
* console.log(await api.derive.accounts.hasIdentityMulti([ALICE, BOB]));
199+
* ```
200+
*/
168201
export function hasIdentityMulti (instanceId: string, api: DeriveApi): (accountIds: (AccountId | Uint8Array | string)[]) => Observable<DeriveHasIdentity[]> {
169202
return memo(instanceId, (accountIds: (AccountId | Uint8Array | string)[]): Observable<DeriveHasIdentity[]> =>
170203
api.query.identity?.identityOf

api-derive/accounts/indexToId.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ import { memo } from '../util/index.ts';
99

1010
/**
1111
* @name indexToId
12-
* @param {( AccountIndex | string )} accountIndex - An accounts index in different formats.
13-
* @returns Returns the corresponding AccountId.
12+
* @description Resolves an AccountIndex (short address) to the full AccountId.
13+
* @param {( AccountIndex | string )} accountIndex An accounts index in different formats.
1414
* @example
15-
* <BR>
16-
*
1715
* ```javascript
18-
* api.derive.accounts.indexToId('F7Hs', (accountId) => {
19-
* console.log(`The AccountId of F7Hs is ${accountId}`);
20-
* });
16+
* const ALICE = "13AU";
17+
* const id = await api.derive.accounts.indexToId(ALICE);
18+
* console.log(id);
2119
* ```
2220
*/
2321
export function indexToId (instanceId: string, api: DeriveApi): (accountIndex: AccountIndex | string) => Observable<AccountId | undefined> {

api-derive/accounts/indexes.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ function queryAccounts (api: DeriveApi): Observable<AccountIndexes> {
2727
* @returns Returns all the indexes on the system.
2828
* @description This is an unwieldly query since it loops through
2929
* all of the enumsets and returns all of the values found. This could be up to 32k depending
30-
* on the number of active accounts in the system
30+
* on the number of active accounts in the system.
3131
* @example
32-
* <BR>
33-
*
3432
* ```javascript
3533
* api.derive.accounts.indexes((indexes) => {
3634
* console.log('All existing AccountIndexes', indexes);

api-derive/accounts/info.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ function retrieveNick (api: DeriveApi, accountId?: AccountId): Observable<string
2828
/**
2929
* @name info
3030
* @description Returns aux. info with regards to an account, current that includes the accountId, accountIndex, identity and nickname
31+
* @param {(AccountIndex | AccountId | Address | Uint8Array | string | null)} address An accounts in different formats.
32+
* @example
33+
* ```javascript
34+
* const ALICE = "13AU";
35+
* const info = await api.derive.accounts.info(ALICE);
36+
* console.log(
37+
* "Account Info: ",
38+
* Object.keys(info).map((key) => `${key}: ${info[key]}`)
39+
* );
40+
* ```
3141
*/
3242
export function info (instanceId: string, api: DeriveApi): (address?: AccountIndex | AccountId | Address | Uint8Array | string | null) => Observable<DeriveAccountInfo> {
3343
return memo(instanceId, (address?: AccountIndex | AccountId | Address | Uint8Array | string | null): Observable<DeriveAccountInfo> =>

api-derive/alliance/index.ts

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,74 @@
11

22
import { hasProposals as collectiveHasProposals, members as collectiveMembers, prime as collectivePrime, proposal as collectiveProposal, proposalCount as collectiveProposalCount, proposalHashes as collectiveProposalHashes, proposals as collectiveProposals } from '../collective/index.ts';
33

4+
/**
5+
* @name members
6+
* @description Retrieves the list of members in the "allianceMotion" collective.
7+
* @example
8+
* ```javascript
9+
* const members = await api.derive.alliance.members();
10+
* console.log(`Members: ${JSON.stringify(members)});
11+
* ```
12+
*/
413
export const members = /*#__PURE__*/ collectiveMembers('allianceMotion');
514

15+
/**
16+
* @name hasProposals
17+
* @description Checks if there are any active proposals in the "allianceMotion" collective.
18+
* @example
19+
* ```javascript
20+
* const exists = await api.derive.alliance.hasProposals();
21+
* console.log(exists);
22+
* ```
23+
*/
624
export const hasProposals = /*#__PURE__*/ collectiveHasProposals('allianceMotion');
25+
/**
26+
* @name proposal
27+
* @description Retrieves details of a specific proposal in the "allianceMotion" collective by its hash.
28+
* @example
29+
* ```javascript
30+
* const proposalDetails = await api.derive.alliance.proposal(PROPOSAL_HASH);
31+
* console.log(proposalDetails);
32+
* ```
33+
*/
734
export const proposal = /*#__PURE__*/ collectiveProposal('allianceMotion');
35+
/**
36+
* @name proposalCount
37+
* @description Retrieves the total number of proposals in the "allianceMotion" collective.
38+
* @example
39+
* ```javascript
40+
* const count = await api.derive.alliance.proposalCount();
41+
* console.log(`Amount of proposals: ${count}`);
42+
* ```
43+
*/
844
export const proposalCount = /*#__PURE__*/ collectiveProposalCount('allianceMotion');
45+
/**
46+
* @name proposalHashes
47+
* @description Retrieves an array of hashes for all active proposals in the "allianceMotion" collective.
48+
* @example
49+
* ```javascript
50+
* const hashes = await api.derive.alliance.proposalHashes();
51+
* console.log(`Proposals ${JSON.stringify(hashes)}`);
52+
* ```
53+
*/
954
export const proposalHashes = /*#__PURE__*/ collectiveProposalHashes('allianceMotion');
55+
/**
56+
* @name proposals
57+
* @description Retrieves a list of all active proposals in the "allianceMotion" collective.
58+
* @example
59+
* ```javascript
60+
* const proposals = await api.derive.alliance.proposals();
61+
* console.log(proposals);
62+
* ```
63+
*/
1064
export const proposals = /*#__PURE__*/ collectiveProposals('allianceMotion');
11-
65+
/**
66+
* @name prime
67+
* @description Retrieves the prime member of the "allianceMotion" collective, if one exists.
68+
* @example
69+
* ```javascript
70+
* const primeMember = await api.derive.alliance.prime();
71+
* console.log(primeMember);
72+
* ```
73+
*/
1274
export const prime = /*#__PURE__*/ collectivePrime('allianceMotion');

api-derive/bagsList/get.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ export function all (instanceId: string, api: DeriveApi): () => Observable<Bag[]
6363
);
6464
}
6565

66+
/**
67+
* @name get
68+
* @param {(BN | number)} id The id of the bag to retrieve.
69+
* @description Retrieves a specific bag from the BagsList pallet by its id.
70+
*/
6671
export function get (instanceId: string, api: DeriveApi): (id: BN | number) => Observable<Bag> {
6772
return memo(instanceId, (id: BN | number): Observable<Bag> =>
6873
api.derive.bagsList._getIds([bnToBn(id)]).pipe(

api-derive/bagsList/getExpanded.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import { objectSpread } from 'https://deno.land/x/polkadot/util/mod.ts';
1010

1111
import { memo } from '../util/index.ts';
1212

13+
/**
14+
* @name expand
15+
* @description Expands a given bag by retrieving all its nodes (accounts contained within the bag).
16+
* @param {Bag} bag The bag to be expanded.
17+
*/
1318
export function expand (instanceId: string, api: DeriveApi): (bag: Bag) => Observable<BagExpanded> {
1419
return memo(instanceId, (bag: Bag): Observable<BagExpanded> =>
1520
api.derive.bagsList.listNodes(bag.bag).pipe(
@@ -18,6 +23,11 @@ export function expand (instanceId: string, api: DeriveApi): (bag: Bag) => Obser
1823
);
1924
}
2025

26+
/**
27+
* @name getExpanded
28+
* @description Retrieves and expands a specific bag from the BagsList pallet.
29+
* @param {BN | number} id The id of the bag to expand.
30+
*/
2131
export function getExpanded (instanceId: string, api: DeriveApi): (id: BN | number) => Observable<BagExpanded> {
2232
return memo(instanceId, (id: BN | number): Observable<BagExpanded> =>
2333
api.derive.bagsList.get(id).pipe(

api-derive/bagsList/listNodes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ function traverseLinks (api: DeriveApi, head: AccountId32 | string): Observable<
3434
);
3535
}
3636

37+
/**
38+
* @name listNodes
39+
* @param {(PalletBagsListListBag | null)} bag A reference to a specific bag in the BagsList pallet.
40+
* @description Retrieves the list of nodes (accounts) contained in a specific bag within the BagsList pallet.
41+
*/
3742
export function listNodes (instanceId: string, api: DeriveApi): (bag: PalletBagsListListBag | null) => Observable<PalletBagsListListNode[]> {
3843
return memo(instanceId, (bag: PalletBagsListListBag | null): Observable<PalletBagsListListNode[]> =>
3944
bag && bag.head.isSome

api-derive/balances/account.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,9 @@ function querySystemAccount (api: DeriveApi, accountId: AccountId): Observable<R
164164

165165
/**
166166
* @name account
167-
* @param {( AccountIndex | AccountId | Address | string )} address - An accounts Id in different formats.
168-
* @returns An object containing the results of various balance queries
167+
* @description Retrieves the essential balance details for an account, such as free balance and account nonce.
168+
* @param {( AccountIndex | AccountId | Address | string )} address An accountsId in different formats.
169169
* @example
170-
* <BR>
171-
*
172170
* ```javascript
173171
* const ALICE = 'F7Hs';
174172
*

api-derive/balances/all.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,17 @@ function queryCurrent (api: DeriveApi, accountId: AccountId | string, balanceIns
206206

207207
/**
208208
* @name all
209-
* @param {( AccountIndex | AccountId | Address | string )} address - An accounts Id in different formats.
210-
* @returns An object containing the results of various balance queries
209+
* @description Retrieves the complete balance information for an account, including free balance, locked balance, reserved balance, and more.
210+
* @param {( AccountId | string )} address An accountsId in different formats.
211211
* @example
212-
* <BR>
213-
*
214212
* ```javascript
215213
* const ALICE = 'F7Hs';
216214
*
217-
* api.derive.balances.all(ALICE, ({ accountId, lockedBalance }) => {
218-
* console.log(`The account ${accountId} has a locked balance ${lockedBalance} units.`);
215+
* api.derive.balances.account(ALICE, (accountInfo) => {
216+
* console.log(
217+
* `${accountInfo.accountId} info:`,
218+
* Object.keys(accountInfo).map((key) => `${key}: ${accountInfo[key]}`)
219+
* );
219220
* });
220221
* ```
221222
*/

0 commit comments

Comments
 (0)