Skip to content

Commit 596b831

Browse files
api, api-{augment, base, contract, derive}, rpc-{augment, core, provider}, types, types-{augment, codec, create, known} 10.3.4
1 parent cad0312 commit 596b831

File tree

18 files changed

+43
-31
lines changed

18 files changed

+43
-31
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} 10.3.4
56
- api, api-{augment, base, contract, derive}, rpc-{augment, core, provider}, types, types-{augment, codec, create, known} 10.3.3
67

78
## 0.2.35 Apr 10, 2023

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: '10.3.3' };
3+
export const packageInfo = { name: '@polkadot/api-augment', path: new URL(import.meta.url).pathname, type: 'deno', version: '10.3.4' };

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: '10.3.3' };
3+
export const packageInfo = { name: '@polkadot/api-base', path: new URL(import.meta.url).pathname, type: 'deno', version: '10.3.4' };

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: '10.3.3' };
3+
export const packageInfo = { name: '@polkadot/api-contract', path: new URL(import.meta.url).pathname, type: 'deno', version: '10.3.4' };

api-derive/chain/getBlock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function getBlock (instanceId: string, api: DeriveApi): (hash: Uint8Array
3232
combineLatest([
3333
of(signedBlock),
3434
queryAt.system.events(),
35-
getAuthorDetails(signedBlock.block.header, queryAt)
35+
getAuthorDetails(api, signedBlock.block.header, blockHash)
3636
])
3737
),
3838
map(([signedBlock, events, [, validators, author]]) =>

api-derive/chain/getHeader.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Observable } from 'https://esm.sh/rxjs@7.8.0';
33
import type { HeaderExtended } from '../type/types.ts';
44
import type { DeriveApi } from '../types.ts';
55

6-
import { combineLatest, map, switchMap } from 'https://esm.sh/rxjs@7.8.0';
6+
import { map, switchMap } from 'https://esm.sh/rxjs@7.8.0';
77

88
import { createHeaderExtended } from '../type/index.ts';
99
import { memo } from '../util/index.ts';
@@ -25,12 +25,9 @@ import { getAuthorDetails } from './util.ts';
2525
*/
2626
export function getHeader (instanceId: string, api: DeriveApi): (blockHash: Uint8Array | string) => Observable<HeaderExtended> {
2727
return memo(instanceId, (blockHash: Uint8Array | string): Observable<HeaderExtended> =>
28-
combineLatest([
29-
api.rpc.chain.getHeader(blockHash),
30-
api.queryAt(blockHash)
31-
]).pipe(
32-
switchMap(([header, queryAt]) =>
33-
getAuthorDetails(header, queryAt)
28+
api.rpc.chain.getHeader(blockHash).pipe(
29+
switchMap((header) =>
30+
getAuthorDetails(api, header, blockHash)
3431
),
3532
map(([header, validators, author]) =>
3633
createHeaderExtended((validators || header).registry, header, validators, author)

api-derive/chain/subscribeNewHeads.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Observable } from 'https://esm.sh/rxjs@7.8.0';
33
import type { HeaderExtended } from '../type/types.ts';
44
import type { DeriveApi } from '../types.ts';
55

6-
import { combineLatest, map, of, switchMap } from 'https://esm.sh/rxjs@7.8.0';
6+
import { map, switchMap } from 'https://esm.sh/rxjs@7.8.0';
77

88
import { createHeaderExtended } from '../type/index.ts';
99
import { memo } from '../util/index.ts';
@@ -26,13 +26,7 @@ export function subscribeNewHeads (instanceId: string, api: DeriveApi): () => Ob
2626
return memo(instanceId, (): Observable<HeaderExtended> =>
2727
api.rpc.chain.subscribeNewHeads().pipe(
2828
switchMap((header) =>
29-
combineLatest([
30-
of(header),
31-
api.queryAt(header.hash)
32-
])
33-
),
34-
switchMap(([header, queryAt]) =>
35-
getAuthorDetails(header, queryAt)
29+
getAuthorDetails(api, header)
3630
),
3731
map(([header, validators, author]): HeaderExtended => {
3832
header.createdAtHash = header.hash;

api-derive/chain/util.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { SpCoreSr25519Public } from 'https://deno.land/x/polkadot/types/loo
77
import type { Codec, IOption } from 'https://deno.land/x/polkadot/types/types/index.ts';
88
import type { DeriveApi } from '../types.ts';
99

10-
import { combineLatest, map, mergeMap, of } from 'https://esm.sh/rxjs@7.8.0';
10+
import { combineLatest, map, mergeMap, of, switchMap } from 'https://esm.sh/rxjs@7.8.0';
1111

1212
import { memo, unwrapBlockNumber } from '../util/index.ts';
1313

@@ -22,7 +22,8 @@ export function createBlockNumberDerive <T extends { number: Compact<BlockNumber
2222
);
2323
}
2424

25-
export function getAuthorDetails (header: Header, queryAt: QueryableStorage<'rxjs'>): Observable<[Header, Vec<AccountId> | null, AccountId | null]> {
25+
/** @internal */
26+
function getAuthorDetailsWithAt (header: Header, queryAt: QueryableStorage<'rxjs'>): Observable<[Header, Vec<AccountId> | null, AccountId | null]> {
2627
const validators = queryAt.session
2728
? queryAt.session.validators()
2829
: of(null);
@@ -70,3 +71,22 @@ export function getAuthorDetails (header: Header, queryAt: QueryableStorage<'rxj
7071
of(null)
7172
]);
7273
}
74+
75+
export function getAuthorDetails (api: DeriveApi, header: Header, blockHash?: Uint8Array | string): Observable<[Header, Vec<AccountId> | null, AccountId | null]> {
76+
// For on-chain state, we need to retrieve it as per the start
77+
// of the block being constructed, i.e. session validators would
78+
// be at the point of the block construction, not when all operations
79+
// has been supplied.
80+
//
81+
// However for the first block (no parentHash available), we would
82+
// just use the as-is
83+
return api.queryAt(
84+
header.parentHash.isEmpty
85+
? blockHash || header.hash
86+
: header.parentHash
87+
).pipe(
88+
switchMap((queryAt) =>
89+
getAuthorDetailsWithAt(header, queryAt)
90+
)
91+
);
92+
}

api-derive/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-derive', path: new URL(import.meta.url).pathname, type: 'deno', version: '10.3.3' };
3+
export const packageInfo = { name: '@polkadot/api-derive', path: new URL(import.meta.url).pathname, type: 'deno', version: '10.3.4' };

api/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', path: new URL(import.meta.url).pathname, type: 'deno', version: '10.3.3' };
3+
export const packageInfo = { name: '@polkadot/api', path: new URL(import.meta.url).pathname, type: 'deno', version: '10.3.4' };

0 commit comments

Comments
 (0)