Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ca79f2f70 | ||
|
|
8fb64f77cd | ||
|
|
d1f86ce78e | ||
|
|
64ff226535 | ||
|
|
e762746ff0 | ||
|
|
ce5c8f7443 | ||
|
|
fc4cbb608c | ||
|
|
7ac3043f83 | ||
|
|
44b56fb0cb | ||
|
|
758ce567e5 | ||
|
|
cb5308b476 | ||
|
|
a9211690be | ||
|
|
a7db14a261 | ||
|
|
3a1f284fa8 | ||
|
|
a0b6c42629 | ||
|
|
f77ae4d99f | ||
|
|
5fa9af8fd3 | ||
|
|
1ff029dc11 | ||
|
|
4c8c9fbb07 | ||
|
|
7057cf365b | ||
|
|
d1bc48e936 | ||
|
|
2dee50f019 | ||
|
|
fa76378702 | ||
|
|
e855da1f13 | ||
|
|
adffde368c | ||
|
|
5278138cc3 | ||
|
|
98249a282e | ||
|
|
b7eeb992cd | ||
|
|
01daf32646 | ||
|
|
51a866fd35 | ||
|
|
53401e29ea | ||
|
|
774f41e6db | ||
|
|
1ca3b295a4 | ||
|
|
82828d8e09 | ||
|
|
131055c1d5 | ||
|
|
bd2e690261 | ||
|
|
1a2ca8ea38 | ||
|
|
0c98593aee | ||
|
|
416e2fbc96 | ||
|
|
c04fb9073e | ||
|
|
4f85ceb2c3 | ||
|
|
9196ce85a0 | ||
|
|
26734bf8bf | ||
|
|
53959d482d | ||
|
|
0a0f110c42 | ||
|
|
47f1350652 | ||
|
|
3c3b7290c2 | ||
|
|
006c686c18 | ||
|
|
44d4a07005 | ||
|
|
6e61be960c | ||
|
|
bd57359dc5 | ||
|
|
10bc6b4060 | ||
|
|
9e681c0666 | ||
|
|
e969382fd0 | ||
|
|
1949a13810 | ||
|
|
362262c4e1 | ||
|
|
ddd5eab7f5 | ||
|
|
1da6193f34 | ||
|
|
c4e553ad80 | ||
|
|
0b83a61600 | ||
|
|
382f7d75c8 | ||
|
|
88e4518f64 | ||
|
|
b1a657d68a | ||
|
|
067f17b28b |
+1
-1
@@ -1 +1 @@
|
||||
14
|
||||
16
|
||||
|
||||
+13
-2
@@ -1,3 +1,14 @@
|
||||
# 0.100.1
|
||||
|
||||
- **Important** This will the the last API version with Substrate 1.x support. Although you will still be able to use subsequent versions with older chans, dependent libraries such as sr25519 may not be compatible.
|
||||
- Add support for the Substrate identity module
|
||||
- Remove the `codec/Data` type, to remove a conflict with Substrate. This type is now named `Raw`
|
||||
- Fix for linked maps using `Option`
|
||||
- Add support for `BTreeSet` (Thanks to https://github.com/satellitex)
|
||||
- Add support for Metadata v10
|
||||
- Add support for latest Polkadot/Substrate types
|
||||
- Add `paymentInfo` to submittables to calculate fees
|
||||
|
||||
# 0.99.1
|
||||
|
||||
- **Breaking change** The `Data` and `U8a` type has been renamed and just replaced with the `Raw` type
|
||||
@@ -9,9 +20,9 @@
|
||||
|
||||
# 0.98.1
|
||||
|
||||
- Make the TypeScript generation script mor re-usable (Thanks to @xlc)
|
||||
- Make the TypeScript generation script mor re-usable (Thanks to https://github.com/xlc)
|
||||
- Add `.entries()` for all map-types, returning storage keys and values
|
||||
- Add `.signAsync` to submittable extrinsics (Thanks to @c410-f3r)
|
||||
- Add `.signAsync` to submittable extrinsics (Thanks to https://github.com/c410-f3r)
|
||||
- Cleanup circular references between internal dependencies
|
||||
- Support for new Substrate democracy with preimages in derive
|
||||
- Alignment of types with Substrate/Polkadot master branches
|
||||
|
||||
+1
-1
@@ -9,5 +9,5 @@
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "0.99.1"
|
||||
"version": "0.100.1"
|
||||
}
|
||||
|
||||
+7
-7
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "0.99.1",
|
||||
"version": "0.100.1",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"yarn": "^1.10.1"
|
||||
@@ -9,7 +9,7 @@
|
||||
],
|
||||
"resolutions": {
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"typescript": "^3.7.3"
|
||||
"typescript": "^3.7.4"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn build:interfaces && polkadot-dev-build-ts",
|
||||
@@ -29,10 +29,10 @@
|
||||
"test:watch": "jest --coverage --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.7.5",
|
||||
"@babel/register": "^7.7.4",
|
||||
"@babel/runtime": "^7.7.6",
|
||||
"@polkadot/dev": "^0.32.0-beta.18",
|
||||
"@polkadot/ts": "^0.1.88"
|
||||
"@babel/core": "^7.7.7",
|
||||
"@babel/register": "^7.7.7",
|
||||
"@babel/runtime": "^7.7.7",
|
||||
"@polkadot/dev": "^0.32.14",
|
||||
"@polkadot/ts": "^0.1.90"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "0.99.1",
|
||||
"version": "0.100.1",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,7 +26,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.7.6",
|
||||
"@polkadot/types": "^0.99.1"
|
||||
"@babel/runtime": "^7.7.7",
|
||||
"@polkadot/types": "^0.100.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -41,7 +41,7 @@ export default class Contract<ApiType extends ApiTypes> extends BaseWithTxAndRpc
|
||||
|
||||
return {
|
||||
send: this.decorateMethod(
|
||||
as === 'rpc'
|
||||
as === 'rpc' && this.hasRpcContractsCall
|
||||
? (account: IKeyringPair | string | AccountId | Address): ContractCallResult<'rpc'> => {
|
||||
return this.rpcContractsCall(
|
||||
createType(this.registry, 'ContractCallRequest', {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -7,7 +7,7 @@ import { ApiObject, ContractABIMessage, ContractABIPre, ContractBase, ContractMe
|
||||
import { RpcInterface } from '@polkadot/rpc-core/jsonrpc.types';
|
||||
import { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { assert, stringCamelCase } from '@polkadot/util';
|
||||
import { assert, isFunction, stringCamelCase } from '@polkadot/util';
|
||||
import Abi from '../Abi';
|
||||
|
||||
export abstract class Base<ApiType extends ApiTypes> implements ContractBase<ApiType> {
|
||||
@@ -66,13 +66,13 @@ export abstract class BaseWithTx<ApiType extends ApiTypes> extends Base<ApiType>
|
||||
}
|
||||
|
||||
export abstract class BaseWithTxAndRpcCall<ApiType extends ApiTypes> extends BaseWithTx<ApiType> {
|
||||
public get hasRpcContractsCall (): boolean {
|
||||
return isFunction(this.api.rx.rpc.contracts?.call);
|
||||
}
|
||||
|
||||
protected get rpcContractsCall (): DecoratedRpc<'rxjs', RpcInterface>['contracts']['call'] {
|
||||
assert(this.hasRpcContractsCall, 'You need to connect to a node with the contracts.call RPC method.');
|
||||
|
||||
return this.api.rx.rpc.contracts.call;
|
||||
}
|
||||
|
||||
constructor (api: ApiObject<ApiType>, abi: ContractABIPre | Abi, decorateMethod: DecorateMethod<ApiType>) {
|
||||
super(api, abi, decorateMethod);
|
||||
|
||||
assert(this.api.rx.rpc.contracts && this.api.rx.tx.contracts.call, 'You need to connect to a node with the contracts module, the metadata does not enable api.rpc.contracts.call on this instance');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-contract authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/rpc-core authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/rpc-core authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,49 +1,49 @@
|
||||
[
|
||||
{
|
||||
"info": 7,
|
||||
"info": 8,
|
||||
"type": "{\"value\": {\"cell\": {\"cell\": ([u8;32])}}}",
|
||||
"name": "Flipper",
|
||||
"namespace": "flipper::normal",
|
||||
"sub": [
|
||||
{
|
||||
"info": 7,
|
||||
"info": 8,
|
||||
"type": "{\"cell\": {\"cell\": ([u8;32])}}",
|
||||
"name": "value",
|
||||
"namespace": "ink_core::storage::value",
|
||||
"params": [
|
||||
{
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"sub": [
|
||||
{
|
||||
"info": 7,
|
||||
"info": 8,
|
||||
"type": "{\"cell\": ([u8;32])}",
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::cell::sync_cell",
|
||||
"params": [
|
||||
{
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"sub": [
|
||||
{
|
||||
"info": 8,
|
||||
"info": 9,
|
||||
"type": "([u8;32])",
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::key",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": 11,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": ""
|
||||
},
|
||||
"sub": {
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
@@ -57,44 +57,44 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": 7,
|
||||
"info": 8,
|
||||
"type": "{\"cell\": {\"cell\": ([u8;32])}}",
|
||||
"name": "Value",
|
||||
"namespace": "ink_core::storage::value",
|
||||
"params": [
|
||||
{
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"sub": [
|
||||
{
|
||||
"info": 7,
|
||||
"info": 8,
|
||||
"type": "{\"cell\": ([u8;32])}",
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::cell::sync_cell",
|
||||
"params": [
|
||||
{
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"sub": [
|
||||
{
|
||||
"info": 8,
|
||||
"info": 9,
|
||||
"type": "([u8;32])",
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::key",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": 11,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": ""
|
||||
},
|
||||
"sub": {
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
@@ -106,36 +106,36 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"info": 7,
|
||||
"info": 8,
|
||||
"type": "{\"cell\": ([u8;32])}",
|
||||
"name": "SyncCell",
|
||||
"namespace": "ink_core::storage::cell::sync_cell",
|
||||
"params": [
|
||||
{
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"sub": [
|
||||
{
|
||||
"info": 8,
|
||||
"info": 9,
|
||||
"type": "([u8;32])",
|
||||
"name": "cell",
|
||||
"namespace": "ink_core::storage::key",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": 11,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": ""
|
||||
},
|
||||
"sub": {
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
@@ -145,20 +145,20 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": 8,
|
||||
"info": 9,
|
||||
"type": "([u8;32])",
|
||||
"name": "Key",
|
||||
"namespace": "ink_core::storage::key",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": 11,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": ""
|
||||
},
|
||||
"sub": {
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
@@ -166,19 +166,19 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": 11,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": ""
|
||||
},
|
||||
"sub": {
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
}
|
||||
},
|
||||
{
|
||||
"info": 5,
|
||||
"info": 6,
|
||||
"type": "u8"
|
||||
}
|
||||
]
|
||||
@@ -1,29 +1,29 @@
|
||||
[
|
||||
{
|
||||
"info": 9,
|
||||
"info": 10,
|
||||
"type": "{ \"value\": \"{ \"cell\": \"{ \"cell\": \"([u8;32])\"} }<u32>\"} }<u32>\"} }",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"info": 10,
|
||||
"type": "{ \"cell\": \"{ \"cell\": \"([u8;32])\"} }<u32>\"} }",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"info": 10,
|
||||
"type": "{ \"cell\": \"([u8;32])\"} }",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": 11,
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
"info": 13,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": "u8"
|
||||
},
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
@@ -37,7 +37,7 @@
|
||||
"namespace": "ink_core::storage::cell::sync_cell",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u32"
|
||||
}
|
||||
]
|
||||
@@ -47,7 +47,7 @@
|
||||
"namespace": "ink_core::storage::value",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u32"
|
||||
}
|
||||
]
|
||||
@@ -57,26 +57,26 @@
|
||||
"namespace": "incrementer::normal"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"info": 10,
|
||||
"type": "{ \"cell\": \"{ \"cell\": \"([u8;32])\"} }<u32>\"} }",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"info": 10,
|
||||
"type": "{ \"cell\": \"([u8;32])\"} }",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": 11,
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
"info": 13,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": "u8"
|
||||
},
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
@@ -90,7 +90,7 @@
|
||||
"namespace": "ink_core::storage::cell::sync_cell",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u32"
|
||||
}
|
||||
]
|
||||
@@ -100,32 +100,32 @@
|
||||
"namespace": "ink_core::storage::value",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u32"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"info": 10,
|
||||
"type": "{ \"cell\": \"([u8;32])\"} }",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": 11,
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
"info": 13,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": "u8"
|
||||
},
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
@@ -139,24 +139,24 @@
|
||||
"namespace": "ink_core::storage::cell::sync_cell",
|
||||
"params": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u32"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": 11,
|
||||
"type": "([u8;32])",
|
||||
"sub": [
|
||||
{
|
||||
"info": 12,
|
||||
"info": 13,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": "u8"
|
||||
},
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u8"
|
||||
},
|
||||
"index": 0
|
||||
@@ -166,23 +166,23 @@
|
||||
"namespace": "ink_core::storage::key"
|
||||
},
|
||||
{
|
||||
"info": 12,
|
||||
"info": 13,
|
||||
"type": "[u8;32]",
|
||||
"ext": {
|
||||
"length": 32,
|
||||
"type": "u8"
|
||||
},
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u8"
|
||||
}
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "u8"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": 7,
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "0.99.1",
|
||||
"version": "0.100.1",
|
||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,11 +27,11 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.7.6",
|
||||
"@polkadot/api": "^0.99.1",
|
||||
"@polkadot/types": "^0.99.1"
|
||||
"@babel/runtime": "^7.7.7",
|
||||
"@polkadot/api": "^0.100.1",
|
||||
"@polkadot/types": "^0.100.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^1.7.1"
|
||||
"@polkadot/keyring": "^1.8.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,22 +1,30 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, AccountIndex, Address, Balance } from '@polkadot/types/interfaces';
|
||||
import { AccountId, AccountIndex, Address, Balance, Registration } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveAccountInfo } from '../types';
|
||||
import { DeriveAccountInfo, DeriveAccountRegistration } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { Bytes, Option, u32 } from '@polkadot/types';
|
||||
import { Bytes, Data, Option, u32 } from '@polkadot/types';
|
||||
import { u8aToString } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
function dataAsString (data: Data): string | undefined {
|
||||
return data.isRaw
|
||||
? u8aToString(data.asRaw.toU8a(true))
|
||||
: data.isSha256
|
||||
? data.asSha256.toHex()
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function retrieveNick (api: ApiInterfaceRx, accountId?: AccountId): Observable<string | undefined> {
|
||||
return ((
|
||||
accountId && api.query.nicks
|
||||
accountId && api.query.nicks?.nameOf
|
||||
? api.query.nicks.nameOf<Option<ITuple<[Bytes, Balance]>>>(accountId)
|
||||
: of(undefined)
|
||||
) as Observable<Option<ITuple<[Bytes, Balance]>> | undefined>).pipe(
|
||||
@@ -28,6 +36,69 @@ function retrieveNick (api: ApiInterfaceRx, accountId?: AccountId): Observable<s
|
||||
);
|
||||
}
|
||||
|
||||
function extractIdentity (identityOfOpt?: Option<Registration>, superOf?: [AccountId, Data]): DeriveAccountRegistration {
|
||||
if (!identityOfOpt?.isSome) {
|
||||
return { judgements: [] };
|
||||
}
|
||||
|
||||
const { info, judgements } = identityOfOpt.unwrap();
|
||||
const topDisplay = dataAsString(info.display);
|
||||
|
||||
return {
|
||||
display: superOf
|
||||
? dataAsString(superOf[1]) || topDisplay
|
||||
: topDisplay,
|
||||
displayParent: superOf
|
||||
? topDisplay
|
||||
: undefined,
|
||||
email: dataAsString(info.email),
|
||||
image: dataAsString(info.image),
|
||||
legal: dataAsString(info.legal),
|
||||
parent: superOf
|
||||
? superOf[0]
|
||||
: undefined,
|
||||
pgp: info.pgpFingerprint.isSome
|
||||
? info.pgpFingerprint.unwrap().toHex()
|
||||
: undefined,
|
||||
riot: dataAsString(info.riot),
|
||||
twitter: dataAsString(info.twitter),
|
||||
web: dataAsString(info.web),
|
||||
judgements
|
||||
};
|
||||
}
|
||||
|
||||
function retrieveIdentity (api: ApiInterfaceRx, accountId?: AccountId): Observable<DeriveAccountRegistration> {
|
||||
return ((
|
||||
accountId && api.query.identity?.identityOf
|
||||
? api.queryMulti([
|
||||
[api.query.identity.identityOf, accountId],
|
||||
[api.query.identity.superOf, accountId]
|
||||
])
|
||||
: of([undefined, undefined])
|
||||
) as Observable<[Option<Registration> | undefined, Option<ITuple<[AccountId, Data]>> | undefined]>).pipe(
|
||||
switchMap(([identityOfOpt, superOfOpt]): Observable<[Option<Registration> | undefined, [AccountId, Data] | undefined]> => {
|
||||
if (identityOfOpt?.isSome) {
|
||||
// this identity has something set
|
||||
return of([identityOfOpt, undefined]);
|
||||
} else if (superOfOpt?.isSome) {
|
||||
const superOf = superOfOpt.unwrap();
|
||||
|
||||
// we have a super
|
||||
return combineLatest([
|
||||
api.query.identity.identityOf<Option<Registration>>(superOf[0]),
|
||||
of(superOf)
|
||||
]);
|
||||
}
|
||||
|
||||
// nothing of value returned
|
||||
return of([undefined, undefined]);
|
||||
}),
|
||||
map(([identityOfOpt, superOf]): DeriveAccountRegistration =>
|
||||
extractIdentity(identityOfOpt, superOf)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name info
|
||||
* @description Returns aux. info with regards to an account, current that includes the accountId, accountIndex and nickname
|
||||
@@ -35,14 +106,15 @@ function retrieveNick (api: ApiInterfaceRx, accountId?: AccountId): Observable<s
|
||||
export function info (api: ApiInterfaceRx): (address?: AccountIndex | AccountId | Address | string | null) => Observable<DeriveAccountInfo> {
|
||||
return memo((address?: AccountIndex | AccountId | Address | string | null): Observable<DeriveAccountInfo> =>
|
||||
api.derive.accounts.idAndIndex(address).pipe(
|
||||
switchMap(([accountId, accountIndex]): Observable<[DeriveAccountInfo, string?]> =>
|
||||
switchMap(([accountId, accountIndex]): Observable<[Partial<DeriveAccountInfo>, DeriveAccountRegistration, string?]> =>
|
||||
combineLatest([
|
||||
of({ accountId, accountIndex }),
|
||||
retrieveIdentity(api, accountId),
|
||||
retrieveNick(api, accountId)
|
||||
])
|
||||
),
|
||||
map(([{ accountId, accountIndex }, nickname]): DeriveAccountInfo => ({
|
||||
accountId, accountIndex, nickname
|
||||
map(([{ accountId, accountIndex }, identity, nickname]): DeriveAccountInfo => ({
|
||||
accountId, accountIndex, identity, nickname
|
||||
}))
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export * from './proposals';
|
||||
@@ -0,0 +1,44 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Hash, Proposal, Votes } from '@polkadot/types/interfaces';
|
||||
import { DerivedCollectiveProposals } from '../types';
|
||||
|
||||
import { combineLatest, Observable, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { Option } from '@polkadot/types';
|
||||
|
||||
export function proposals (api: ApiInterfaceRx, section: 'council' | 'technicalCommittee'): () => Observable<DerivedCollectiveProposals> {
|
||||
return (): Observable<DerivedCollectiveProposals> =>
|
||||
api.query[section]
|
||||
? api.query[section].proposals()
|
||||
.pipe(
|
||||
switchMap((hashes: Hash[]): Observable<[Hash[], Option<Proposal>[], Option<Votes>[]]> => {
|
||||
return combineLatest([
|
||||
of(hashes),
|
||||
combineLatest(
|
||||
hashes.map((hash): Observable<Option<Proposal>> => api.query[section].proposalOf(hash))
|
||||
),
|
||||
api.query[section].voting.multi<Option<Votes>>(hashes)
|
||||
]);
|
||||
}),
|
||||
map(([hashes, proposals, votes]): DerivedCollectiveProposals => {
|
||||
const result: DerivedCollectiveProposals = [];
|
||||
|
||||
proposals.forEach((proposalOpt, index): void => {
|
||||
if (proposalOpt.isSome) {
|
||||
result.push({
|
||||
hash: hashes[index],
|
||||
proposal: proposalOpt.unwrap(),
|
||||
votes: votes[index].unwrapOr(null)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
})
|
||||
)
|
||||
: of([] as DerivedCollectiveProposals);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,48 +1,14 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Hash, Proposal, Votes } from '@polkadot/types/interfaces';
|
||||
import { DerivedCouncilProposals } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { Option } from '@polkadot/types';
|
||||
import { DerivedCollectiveProposals } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { proposals as collectiveProposals } from '../collective';
|
||||
import { memo } from '../util';
|
||||
|
||||
function retrieveProposals (api: ApiInterfaceRx, hashes: Hash[]): Observable<DerivedCouncilProposals> {
|
||||
return combineLatest([
|
||||
api.query.council.proposalOf.multi<Option<Proposal>>(hashes),
|
||||
api.query.council.voting.multi<Option<Votes>>(hashes)
|
||||
]).pipe(
|
||||
map(([proposals, votes]: [Option<Proposal>[], Option<Votes>[]]): DerivedCouncilProposals => {
|
||||
const result: DerivedCouncilProposals = [];
|
||||
|
||||
proposals.forEach((proposalOpt, index): void => {
|
||||
if (proposalOpt.isSome) {
|
||||
result.push({
|
||||
hash: hashes[index],
|
||||
proposal: proposalOpt.unwrap(),
|
||||
votes: votes[index].unwrapOr(null)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export function proposals (api: ApiInterfaceRx): () => Observable<DerivedCouncilProposals> {
|
||||
return memo((): Observable<DerivedCouncilProposals> =>
|
||||
api.query.council
|
||||
? api.query.council.proposals().pipe(
|
||||
switchMap((proposals: Hash[]): Observable<DerivedCouncilProposals> =>
|
||||
retrieveProposals(api, proposals)
|
||||
)
|
||||
)
|
||||
: of([] as DerivedCouncilProposals)
|
||||
);
|
||||
export function proposals (api: ApiInterfaceRx): () => Observable<DerivedCollectiveProposals> {
|
||||
return memo(collectiveProposals(api, 'council'));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, Balance, BlockNumber, Hash, PropIndex } from '@polkadot/types/interfaces';
|
||||
import { AccountId, Balance, BlockNumber, Hash, PropIndex, Proposal } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveProposal } from '../types';
|
||||
|
||||
@@ -27,11 +27,21 @@ interface Result {
|
||||
function parse (api: ApiInterfaceRx, { depositors, proposals, preimages }: Result): DeriveProposal[] {
|
||||
return proposals
|
||||
.filter(([, , proposer], index): boolean =>
|
||||
!!(preimages[index]?.isSome) && !!(depositors[index]?.isSome) && !proposer.isEmpty
|
||||
!!(depositors[index]?.isSome) && !proposer.isEmpty
|
||||
)
|
||||
.map(([propIndex, hash, proposer], index): DeriveProposal => {
|
||||
const preimage = preimages[index].unwrapOr(null);
|
||||
const depositor = depositors[index].unwrap();
|
||||
let proposal: undefined | Proposal;
|
||||
|
||||
// we could end up in a situation where the proposal is non-decodable, e.g. after an upgrade
|
||||
if (preimage) {
|
||||
try {
|
||||
proposal = createType(api.registry, 'Proposal', preimage[0].toU8a(true));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
balance: depositor[0],
|
||||
@@ -44,9 +54,7 @@ function parse (api: ApiInterfaceRx, { depositors, proposals, preimages }: Resul
|
||||
proposer: preimage[1]
|
||||
}
|
||||
: undefined,
|
||||
proposal: preimage
|
||||
? createType(api.registry, 'Proposal', preimage[0].toU8a(true))
|
||||
: undefined,
|
||||
proposal,
|
||||
proposer,
|
||||
seconds: depositor[1]
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -17,6 +17,7 @@ import * as elections from './elections';
|
||||
import * as imOnline from './imOnline';
|
||||
import * as session from './session';
|
||||
import * as staking from './staking';
|
||||
import * as technicalCommittee from './technicalCommittee';
|
||||
import * as treasury from './treasury';
|
||||
|
||||
export * from './type';
|
||||
@@ -58,7 +59,7 @@ function injectFunctions<AllSections> (api: ApiInterfaceRx, allSections: AllSect
|
||||
}, {} as DeriveAllSections<AllSections>);
|
||||
}
|
||||
|
||||
export const derive = { accounts, balances, chain, contracts, council, democracy, elections, imOnline, session, staking, treasury };
|
||||
export const derive = { accounts, balances, chain, contracts, council, democracy, elections, imOnline, session, staking, technicalCommittee, treasury };
|
||||
export type ExactDerive = DeriveAllSections<typeof derive>;
|
||||
|
||||
// FIXME The return type of this function should be {...ExactDerive, ...DeriveCustom}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export * from './proposals';
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { DerivedCollectiveProposals } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { proposals as collectiveProposals } from '../collective';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function proposals (api: ApiInterfaceRx): () => Observable<DerivedCollectiveProposals> {
|
||||
return memo(collectiveProposals(api, 'technicalCommittee'));
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { ProposalIndex, TreasuryProposal } from '@polkadot/types/interfaces';
|
||||
import { DerivedCouncilProposals, DerivedTreasuryProposal, DerivedTreasuryProposals } from '../types';
|
||||
import { DerivedCollectiveProposals, DerivedTreasuryProposal, DerivedTreasuryProposals } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
@@ -16,7 +16,7 @@ interface Result {
|
||||
allIds: ProposalIndex[];
|
||||
allProposals: Option<TreasuryProposal>[];
|
||||
approvalIds: ProposalIndex[];
|
||||
councilProposals: DerivedCouncilProposals;
|
||||
councilProposals: DerivedCollectiveProposals;
|
||||
proposalCount: ProposalIndex;
|
||||
}
|
||||
|
||||
@@ -62,10 +62,13 @@ function retrieveProposals (api: ApiInterfaceRx, proposalCount: ProposalIndex, a
|
||||
const allIds = [...proposalIds, ...approvalIds];
|
||||
|
||||
return combineLatest([
|
||||
api.query.treasury.proposals.multi<Option<TreasuryProposal>>(allIds),
|
||||
// We are doing single subscriptions on all these, multi may yield old results
|
||||
combineLatest(
|
||||
allIds.map((id): Observable<Option<TreasuryProposal>> => api.query.treasury.proposals(id))
|
||||
),
|
||||
api.derive.council.proposals()
|
||||
]).pipe(
|
||||
map(([allProposals, councilProposals]: [Option<TreasuryProposal>[], DerivedCouncilProposals]): DerivedTreasuryProposals =>
|
||||
map(([allProposals, councilProposals]: [Option<TreasuryProposal>[], DerivedCollectiveProposals]): DerivedTreasuryProposals =>
|
||||
parseResult(api, { allIds, allProposals, approvalIds, councilProposals, proposalCount })
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,17 +1,32 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, AccountIndex, Balance, BalanceLock, BlockNumber, EraIndex, EraPoints, Exposure, Hash, Index, Keys, Proposal, PropIndex, ProposalIndex, ReferendumInfo, RewardDestination, SessionIndex, SetIndex, StakingLedger, TreasuryProposal, ValidatorPrefs, Vote, Votes, VoteIndex } from '@polkadot/types/interfaces';
|
||||
import { AccountId, AccountIndex, Balance, BalanceLock, BlockNumber, EraIndex, EraPoints, Exposure, Hash, Index, Keys, Proposal, PropIndex, ProposalIndex, ReferendumInfo, RegistrationJudgement, RewardDestination, SessionIndex, SetIndex, StakingLedger, TreasuryProposal, ValidatorPrefs, Vote, Votes, VoteIndex } from '@polkadot/types/interfaces';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { u32, Vec } from '@polkadot/types';
|
||||
|
||||
export type AccountIndexes = Record<string, AccountIndex>;
|
||||
|
||||
export interface DeriveAccountRegistration {
|
||||
display?: string;
|
||||
displayParent?: string;
|
||||
email?: string;
|
||||
image?: string;
|
||||
legal?: string;
|
||||
parent?: AccountId;
|
||||
pgp?: string;
|
||||
riot?: string;
|
||||
twitter?: string;
|
||||
web?: string;
|
||||
judgements: RegistrationJudgement[];
|
||||
}
|
||||
|
||||
export interface DeriveAccountInfo {
|
||||
accountId?: AccountId;
|
||||
accountIndex?: AccountIndex;
|
||||
identity: DeriveAccountRegistration;
|
||||
nickname?: string;
|
||||
}
|
||||
|
||||
@@ -44,13 +59,13 @@ export interface DerivedContractFees {
|
||||
transferFee: BN;
|
||||
}
|
||||
|
||||
export interface DerivedCouncilProposal {
|
||||
export interface DerivedCollectiveProposal {
|
||||
hash: Hash;
|
||||
proposal: Proposal;
|
||||
votes: Votes | null;
|
||||
}
|
||||
|
||||
export type DerivedCouncilProposals = DerivedCouncilProposal[];
|
||||
export type DerivedCollectiveProposals = DerivedCollectiveProposal[];
|
||||
|
||||
export interface DerivedElectionsInfo {
|
||||
candidates: AccountId[];
|
||||
@@ -173,7 +188,7 @@ export interface DerivedStakingOverview extends DeriveSessionIndexes {
|
||||
}
|
||||
|
||||
export interface DerivedTreasuryProposal {
|
||||
council: DerivedCouncilProposal[];
|
||||
council: DerivedCollectiveProposal[];
|
||||
id: ProposalIndex;
|
||||
proposal: TreasuryProposal;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.v
|
||||
|
||||
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api",
|
||||
"version": "0.99.1",
|
||||
"version": "0.100.1",
|
||||
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,16 +26,16 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.7.6",
|
||||
"@polkadot/api-derive": "^0.99.1",
|
||||
"@polkadot/keyring": "^1.7.1",
|
||||
"@polkadot/metadata": "^0.99.1",
|
||||
"@polkadot/rpc-core": "^0.99.1",
|
||||
"@polkadot/rpc-provider": "^0.99.1",
|
||||
"@polkadot/types": "^0.99.1",
|
||||
"@polkadot/util-crypto": "^1.7.1"
|
||||
"@babel/runtime": "^7.7.7",
|
||||
"@polkadot/api-derive": "^0.100.1",
|
||||
"@polkadot/keyring": "^1.8.1",
|
||||
"@polkadot/metadata": "^0.100.1",
|
||||
"@polkadot/rpc-core": "^0.100.1",
|
||||
"@polkadot/rpc-provider": "^0.100.1",
|
||||
"@polkadot/types": "^0.100.1",
|
||||
"@polkadot/util-crypto": "^1.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^1.7.1"
|
||||
"@polkadot/keyring": "^1.8.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// Copyright 2017-2019 @polkadot/api authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Constants, Storage } from '@polkadot/metadata/Decorated/types';
|
||||
import { RpcInterface } from '@polkadot/rpc-core/jsonrpc.types';
|
||||
import { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import { AnyFunction, CallFunction, Codec, CodecArg as Arg, ModulesWithCalls, Registry } from '@polkadot/types/types';
|
||||
import { AnyFunction, CallFunction, Codec, CodecArg as Arg, ITuple, ModulesWithCalls, Registry } from '@polkadot/types/types';
|
||||
import { SubmittableExtrinsic } from '../submittable/types';
|
||||
import {
|
||||
ApiInterfaceRx, ApiOptions, ApiTypes,
|
||||
@@ -20,7 +20,7 @@ import { map, switchMap } from 'rxjs/operators';
|
||||
import decorateDerive, { ExactDerive } from '@polkadot/api-derive';
|
||||
import RpcCore from '@polkadot/rpc-core';
|
||||
import { WsProvider } from '@polkadot/rpc-provider';
|
||||
import { Metadata, Null, TypeRegistry, u64, Vec } from '@polkadot/types';
|
||||
import { Metadata, Null, Option, TypeRegistry, u64, Vec } from '@polkadot/types';
|
||||
import Linkage, { LinkageResult } from '@polkadot/types/codec/Linkage';
|
||||
import { DEFAULT_VERSION as EXTRINSIC_DEFAULT_VERSION } from '@polkadot/types/primitive/Extrinsic/constants';
|
||||
import StorageKey, { StorageEntry } from '@polkadot/types/primitive/StorageKey';
|
||||
@@ -38,6 +38,8 @@ interface MetaDecoration {
|
||||
toJSON: () => any;
|
||||
}
|
||||
|
||||
type LinkageData = ITuple<[Codec, Linkage<Codec>]>;
|
||||
|
||||
export default abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
public readonly registry: Registry;
|
||||
|
||||
@@ -298,7 +300,7 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
|
||||
}
|
||||
|
||||
private decorateStorageLinked<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>): ReturnType<DecorateMethod<ApiType>> {
|
||||
const result: Map<Codec, [Codec, Linkage<Codec>]> = new Map();
|
||||
const result: Map<Codec, ITuple<[Codec, Linkage<Codec>]> | null> = new Map();
|
||||
let subject: BehaviorSubject<LinkageResult>;
|
||||
let head: Codec | null = null;
|
||||
|
||||
@@ -306,13 +308,17 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
|
||||
// entries can be re-linked in the middle of a list, we subscribe here to make
|
||||
// sure we catch any updates, no matter the list position
|
||||
const getNext = (key: Codec): Observable<LinkageResult> =>
|
||||
this._rpcCore.state.subscribeStorage<[[Codec, Linkage<Codec>]]>([[creator, key]]).pipe(
|
||||
switchMap(([data]: [[Codec, Linkage<Codec>]]): Observable<LinkageResult> => {
|
||||
this._rpcCore.state.subscribeStorage<[LinkageData | Option<LinkageData>]>([[creator, key]]).pipe(
|
||||
switchMap(([_data]: [LinkageData | Option<LinkageData>]): Observable<LinkageResult> => {
|
||||
const data = creator.meta.modifier.isOptional
|
||||
? (_data as Option<LinkageData>).unwrapOr(null)
|
||||
: _data as LinkageData;
|
||||
|
||||
result.set(key, data);
|
||||
|
||||
// iterate from this key to the linkages, constructing entries for all
|
||||
// those found and available
|
||||
if (data[1].next.isSome) {
|
||||
if (data && data[1].next.isSome) {
|
||||
return getNext(data[1].next.unwrap());
|
||||
}
|
||||
|
||||
@@ -334,7 +340,7 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
|
||||
keys.push(nextKey);
|
||||
vals.push(item);
|
||||
|
||||
nextKey = linkage.next && linkage.next.unwrapOr(null);
|
||||
nextKey = linkage.next?.unwrapOr(null);
|
||||
}
|
||||
|
||||
const nextResult = vals.length
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api authors & contributors
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user