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

0 commit comments

Comments
 (0)