Compare commits

..
64 Commits
Author SHA1 Message Date
Github Actions 2ca79f2f70 [CI Skip] 0.100.1
skip-checks: true
2020-01-13 15:19:07 +00:00
Jaco Greeff 8fb64f77cd 0.100 (#1716) 2020-01-13 16:11:56 +01:00
Github Actions d1f86ce78e [CI Skip] 0.100.0-beta.30
skip-checks: true
2020-01-13 14:24:03 +00:00
Keith IngramandJaco Greeff 64ff226535 Fix api.derive.collective (#1711)
* fix api.derive.collective

* imports

* Update proposals.ts

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2020-01-13 15:17:04 +01:00
Github Actions e762746ff0 [CI Skip] 0.100.0-beta.29
skip-checks: true
2020-01-13 11:03:54 +00:00
Xiliang Chen ce5c8f7443 fix AssetOptions def (#1714) 2020-01-13 11:55:51 +01:00
Github Actions fc4cbb608c [CI Skip] 0.100.0-beta.28
skip-checks: true
2020-01-12 13:50:01 +00:00
Jaco Greeff 7ac3043f83 Extract sub identities (via accounts derive) (#1713)
* Extract sub identities

* Cleanups
2020-01-12 14:42:42 +01:00
Github Actions 44b56fb0cb [CI Skip] 0.100.0-beta.27
skip-checks: true
2020-01-10 15:06:03 +00:00
Jaco Greeff 758ce567e5 Failsafe on proposal decode (fallback ro preimage only) (#1710) 2020-01-10 15:58:56 +01:00
Github Actions cb5308b476 [CI Skip] 0.100.0-beta.26
skip-checks: true
2020-01-10 13:55:10 +00:00
Amaury Martiny a9211690be Remove v9->v10 hack (#1694)
* Remove v9->v10 hack

* Update static

* Update JSON
2020-01-10 14:47:06 +01:00
Github Actions a7db14a261 [CI Skip] 0.100.0-beta.25
skip-checks: true
2020-01-10 13:03:45 +00:00
Jaco Greeff 3a1f284fa8 Treasury OpenTip (#1708) 2020-01-10 13:56:05 +01:00
Github Actions a0b6c42629 [CI Skip] 0.100.0-beta.24
skip-checks: true
2020-01-10 11:10:20 +00:00
Jaco Greeff f77ae4d99f Add percent type (#1707) 2020-01-10 12:02:35 +01:00
Github Actions 5fa9af8fd3 [CI Skip] 0.100.0-beta.23
skip-checks: true
2020-01-10 10:32:55 +00:00
Jaco Greeff 1ff029dc11 Update IdentityInfo with twitter field (#1706)
* Update IdentityInfo with twitter field

* Rebuild

* Update test with twitter
2020-01-10 11:25:10 +01:00
Github Actions 4c8c9fbb07 [CI Skip] 0.100.0-beta.22
skip-checks: true
2020-01-09 13:47:13 +00:00
Jaco Greeff 7057cf365b Add paymentInfo to submittables (#1582)
* Add paymentInfo to submittables

* Cleanup paymentInfo call

* Use 0x42...42 dummy sigs

* Re-add paymentInfo to submittable

* Add correct signFake interfaces

* CHANGELOG
2020-01-09 14:40:25 +01:00
Github Actions d1bc48e936 [CI Skip] 0.100.0-beta.21
skip-checks: true
2020-01-09 11:07:18 +00:00
Jaco Greeff 2dee50f019 Bump deps (#1704) 2020-01-09 11:59:21 +01:00
Github Actions fa76378702 [CI Skip] 0.100.0-beta.20
skip-checks: true
2020-01-08 08:29:06 +00:00
Jaco Greeff e855da1f13 Make a start at the Polkadot launch types (#1700)
* Make a start at the Polkadot launch types

* Add missing old DispatchInfo
2020-01-08 09:21:23 +01:00
Github Actions adffde368c [CI Skip] 0.100.0-beta.19
skip-checks: true
2020-01-07 09:01:45 +00:00
Jaco Greeff 5278138cc3 Make submittable signAsync Observable-aware (#1698)
* Make submittable signAsync Observable-aware

* rxjs test for signAsync

* Cleanup tests, pass signer in .create

* Simplify Observable creation
2020-01-07 09:54:04 +01:00
Github Actions 98249a282e [CI Skip] 0.100.0-beta.18
skip-checks: true
2020-01-06 13:20:39 +00:00
Jaco Greeff b7eeb992cd Bump deps (#1699) 2020-01-06 14:12:49 +01:00
Github Actions 01daf32646 [CI Skip] 0.100.0-beta.17
skip-checks: true
2020-01-03 16:45:58 +00:00
Amaury Martiny 51a866fd35 Update kusama static from 1032 to 1033 (#1696)
* Update kusama static from 1032 to 1033

* Update comment

* Rename variables

* Test 1032 and 1033

* Got exact metadata from kusama
2020-01-03 17:38:32 +01:00
Github Actions 53401e29ea [CI Skip] 0.100.0-beta.16
skip-checks: true
2020-01-03 11:13:30 +00:00
Amaury Martiny 774f41e6db Only apply hack if exactly metadata from kusama 1032 (#1695) 2020-01-03 12:05:27 +01:00
Github Actions 1ca3b295a4 [CI Skip] 0.100.0-beta.15
skip-checks: true
2020-01-02 17:11:51 +00:00
Keith IngramandAmaury Martiny 82828d8e09 Add metadata v10/11, blake2_128concat hasher (#1691)
* v11, blake2_128concat

* MetadataAll

* Add storage hasher v4 and v10

* Make lint pass

* Add correct interfaces

* Fix lint

* Update metadata definitions

* Update v10 metadata

* Update packages/types/src/interfaces/utility/definitions.ts

* Update v11

* Add HACK

* Skip v9 tests (part of HACK)

* Correct function names

Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>
2020-01-02 18:04:42 +01:00
Github Actions 131055c1d5 [CI Skip] 0.100.0-beta.14
skip-checks: true
2019-12-20 10:04:22 +00:00
Jaco Greeff bd2e690261 Update DispatchError for Kusama (#1686) 2019-12-20 10:57:37 +01:00
Github Actions 1a2ca8ea38 [CI Skip] 0.100.0-beta.13
skip-checks: true
2019-12-19 14:44:19 +00:00
Jaco Greeff 0c98593aee Update DispatchError as enum (#1682)
* Update DispatchError as enum

* Add DispatchResult

* Update tests for DispatchResult

* Rebuild
2019-12-19 15:37:36 +01:00
Github Actions 416e2fbc96 [CI Skip] 0.100.0-beta.12
skip-checks: true
2019-12-19 13:14:08 +00:00
Jaco Greeff c04fb9073e Don't query proposal via multi (#1683) 2019-12-19 14:07:23 +01:00
Github Actions 4f85ceb2c3 [CI Skip] 0.100.0-beta.11
skip-checks: true
2019-12-19 10:09:06 +00:00
Jaco Greeff 9196ce85a0 Expand identity derive fields (incl. all) (#1680) 2019-12-19 11:00:47 +01:00
Github Actions 26734bf8bf [CI Skip] 0.100.0-beta.10
skip-checks: true
2019-12-18 15:30:04 +00:00
satellitex 53959d482d Add BTreeSet<V> Codec (#1639)
* add BTreeSet Codec

* Add following BTreeMap

* fix linting

* fix linting

* add validate Types and encode Types

* type def info is incremented.

* fix compareSet
2019-12-18 16:22:54 +01:00
Github Actions 0a0f110c42 [CI Skip] 0.100.0-beta.9
skip-checks: true
2019-12-17 16:28:01 +00:00
Keith Ingram 47f1350652 Additional rpcContractCall guard (#1677)
* additional rpc guard

* isFunction

* isFunction
2019-12-17 17:21:19 +01:00
Github Actions 3c3b7290c2 [CI Skip] 0.100.0-beta.8
skip-checks: true
2019-12-17 14:40:40 +00:00
Jaco Greeff 006c686c18 Fix linked maps with optional entries (#1676)
* Fix linked maps with optional entries

* Revert entries() change for linked maps
2019-12-17 15:33:45 +01:00
Github Actions 44d4a07005 [CI Skip] 0.100.0-beta.7
skip-checks: true
2019-12-16 11:41:13 +00:00
Github Actions 6e61be960c [CI Skip] 0.100.0-beta.6
skip-checks: true
2019-12-16 11:02:37 +00:00
Jaco Greeff bd57359dc5 Cleanuop preimage check (#1674) 2019-12-16 11:56:42 +01:00
Github Actions 10bc6b4060 [CI Skip] 0.100.0-beta.5
skip-checks: true
2019-12-16 09:49:08 +00:00
Jaco Greeff 9e681c0666 Update .123trigger 2019-12-16 10:42:04 +01:00
Github Actions e969382fd0 [CI Skip] 0.100.0-beta.4
skip-checks: true
2019-12-16 09:36:41 +00:00
Jaco Greeff 1949a13810 Update .123trigger 2019-12-16 10:30:18 +01:00
Github Actions 362262c4e1 [CI Skip] 0.100.0-beta.3
skip-checks: true
2019-12-15 20:44:20 +00:00
Keith Ingram ddd5eab7f5 collective proposals (#1671) 2019-12-15 15:37:27 -05:00
Github Actions 1da6193f34 [CI Skip] 0.100.0-beta.2
skip-checks: true
2019-12-15 11:22:45 +00:00
Jaco Greeff c4e553ad80 Add identity names to derive.accounts.info (#1673) 2019-12-15 12:16:17 +01:00
Github Actions 0b83a61600 [CI Skip] 0.100.0-beta.1
skip-checks: true
2019-12-15 09:04:04 +00:00
Jaco Greeff 382f7d75c8 Data has custom encodedLength 2019-12-15 09:56:30 +01:00
Github Actions 88e4518f64 [CI Skip] 0.100.0-beta.0
skip-checks: true
2019-12-15 07:50:37 +00:00
Jaco Greeff b1a657d68a Custom encoding for identity Data (#1672)
* Custom encoding for identity Data

* Custom encoding for IdentityFields

* Allow empty U8a input to Data

* IdentityField tests
2019-12-15 08:43:22 +01:00
Jaco Greeff 067f17b28b Enum with single-entry encoding (#1670)
* Enum with single-entry encoding

* Expand test with breakdown
2019-12-13 11:19:38 +01:00
520 changed files with 19069 additions and 4974 deletions
+1 -1
View File
@@ -1 +1 @@
14
16
+13 -2
View File
@@ -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
View File
@@ -9,5 +9,5 @@
"packages": [
"packages/*"
],
"version": "0.99.1"
"version": "0.100.1"
}
+7 -7
View File
@@ -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"
}
}
+3 -3
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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.
+2 -2
View File
@@ -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 -1
View File
@@ -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.
+8 -8
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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
+5 -5
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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.
+80 -8
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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.
+6 -40
View File
@@ -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 -1
View File
@@ -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.
+14 -6
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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.
+3 -2
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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.
+20 -5
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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
View File
@@ -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"
}
}
+14 -8
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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