Compare commits

...
162 Commits
Author SHA1 Message Date
Github Actions c03068f0ec [CI Skip] release/stable 4.16.2
skip-checks: true
2021-06-27 04:03:48 +00:00
Jaco e8f352930d Correct CompactAssignments & RawSolution types for Polkadot (#3705)
* Correct `CompactAssignments` & `RawSolution` types for Polkadot

* Default to Solution 16
2021-06-27 05:55:11 +02:00
Github Actions bf2c560db5 [CI Skip] release/stable 4.16.1
skip-checks: true
2021-06-26 08:48:42 +00:00
Jaco 63189a6196 4.16 (#3701) 2021-06-26 10:37:06 +02:00
Jaco 9990690332 Bump common (#3700) 2021-06-26 10:10:46 +02:00
Github Actions ee163cc342 [CI Skip] release/beta 4.15.2-10
skip-checks: true
2021-06-26 05:54:47 +00:00
Jaco cf27f7e11b Add Kusama & Westend 9070 upgrade blocks (#3699) 2021-06-26 08:43:58 +03:00
Github Actions 12986865c8 [CI Skip] release/beta 4.15.2-9
skip-checks: true
2021-06-25 15:14:24 +00:00
Jaco aac0fc741a Add polkadot 9050 upgrade block (#3698)
* Add polkadot 9050 upgrade block

* CHANGELOG expansion

* CHAGELOG wording
2021-06-25 17:04:07 +02:00
Github Actions c33f95d64b [CI Skip] release/beta 4.15.2-8
skip-checks: true
2021-06-25 11:14:03 +00:00
Jaco eb7255b34f Bump util (#3695) 2021-06-25 13:04:35 +02:00
Github Actions 3982798d5e [CI Skip] release/beta 4.15.2-7
skip-checks: true
2021-06-25 09:39:35 +00:00
Yuri ded1ebd4e7 fixes #3693 Fix uniques return types (#3694) 2021-06-25 11:30:44 +02:00
Github Actions c261d4e333 [CI Skip] release/beta 4.15.2-6
skip-checks: true
2021-06-23 14:27:46 +00:00
Jaco 7b1400e238 Bump common (#3690) 2021-06-23 16:18:49 +02:00
Github Actions 7c2048bc6b [CI Skip] release/beta 4.15.2-5
skip-checks: true
2021-06-23 13:00:32 +00:00
Jaco 2b1d5664fe Adjust contract registry (#3689) 2021-06-23 14:49:51 +02:00
Github Actions 5403686e20 [CI Skip] release/beta 4.15.2-4
skip-checks: true
2021-06-23 12:39:41 +00:00
Jaco e90c72fc8b ABI indexes are 0-based from 0.7+ (#3688) 2021-06-23 14:31:18 +02:00
Github Actions 1910ef54a4 [CI Skip] release/beta 4.15.2-3
skip-checks: true
2021-06-23 09:18:59 +00:00
Jaco 45686f9482 Bump deps (#3686)
* Bump deps

* Add override (as applicable)
2021-06-23 11:10:12 +02:00
Github Actions a6b0d214af [CI Skip] release/beta 4.15.2-2
skip-checks: true
2021-06-22 08:36:05 +00:00
Jaco 2a1a2a936b Update .123trigger 2021-06-22 10:24:33 +02:00
Jaco 060275d1ae Event lazy create classes (#3685)
* Event lazy create classes

* head fallback
2021-06-22 09:49:45 +02:00
Github Actions abb54d2538 [CI Skip] release/beta 4.15.2-1
skip-checks: true
2021-06-21 12:16:05 +00:00
Jaco 98fc472a40 Add 9050 upgrade blocks (#3683)
* Add 9050 upgrade blocks

* CHANGELOG
2021-06-21 14:06:09 +02:00
Github Actions 4034429042 [CI Skip] release/beta 4.15.2-0
skip-checks: true
2021-06-21 09:16:45 +00:00
Jaco ca212b8736 Bump static metadata (#3682) 2021-06-21 11:06:38 +02:00
Github Actions 4c2593629d [CI Skip] release/stable 4.15.1
skip-checks: true
2021-06-19 09:34:55 +00:00
Jaco 612d85ca2a 4.15 (#3679)
* 4.15

* CHANGELOG
2021-06-19 11:24:31 +02:00
Jaco Greeff b25b92dddc Metadata generation has spaces between lines 2021-06-19 11:48:49 +03:00
Github Actions f01376ebe1 [CI Skip] release/beta 4.14.2-11
skip-checks: true
2021-06-19 08:38:55 +00:00
Jaco 03acde19b8 Expand nested getTypeDef tests (#3678)
* Expand nested getTypeDef tests

* Rename to fallback

* Remove --detectOpenHandles
2021-06-19 10:27:01 +02:00
Alexander Popiak 1de533ca9c add ChargeAssetTxPayment to SignedExtensions (#3668) 2021-06-19 09:50:30 +02:00
Jaco ce2037400c Bump common (#3677) 2021-06-19 09:18:04 +02:00
Github Actions 379fe12979 [CI Skip] release/beta 4.14.2-10
skip-checks: true
2021-06-19 06:21:43 +00:00
Jaco a285f53753 Add compatibility export for GenericAddress (#3676)
* Add compatibility export for GenericAddress

* GenericAddress -> GenericMultiAddress (new form)
2021-06-19 08:10:36 +02:00
Github Actions ed36eed112 [CI Skip] release/beta 4.14.2-9
skip-checks: true
2021-06-18 13:48:37 +00:00
Jaco ddf6f574f6 XcmOrigin definition (#3675)
* XcmOrigin definition

* CHANGELOG
2021-06-18 15:39:48 +02:00
Github Actions 4f7c4e8b4e [CI Skip] release/beta 4.14.2-8
skip-checks: true
2021-06-18 13:35:09 +00:00
Jaco f2a82ddd0f Allow for nested fixed vec defintions (#3673)
* Allow for nested fixed vec defintions

* struct with nested struct & tuple

* extract conversion to type string

* Include < & > in split iteration

* Allow for nested ( & )

* CHANGELOG
2021-06-18 15:23:54 +02:00
Github Actions 3cec316683 [CI Skip] release/beta 4.14.2-7
skip-checks: true
2021-06-18 13:08:49 +00:00
Jaco c23b5e674b Adjust module checks (& allow for nonce-only) (#3672) 2021-06-18 15:00:20 +02:00
Github Actions 8bf8222c31 [CI Skip] release/beta 4.14.2-6
skip-checks: true
2021-06-18 06:28:17 +00:00
Jaco 0c19e966cc Add BeefyId (#3671)
* Add BeefyId

* Alias
2021-06-18 08:19:00 +02:00
Github Actions 9fbda5a6e0 [CI Skip] release/beta 4.14.2-5
skip-checks: true
2021-06-17 07:38:18 +00:00
Jaco 3d7d39073f Remove isStakerPayout flag (#3665) 2021-06-17 09:26:50 +02:00
Github Actions ae26aebdf8 [CI Skip] release/beta 4.14.2-4
skip-checks: true
2021-06-16 11:52:28 +00:00
Alexander PopiakandJaco c43f442fb9 handle empty account data/missing balance gracefully (#3658)
* handle empty account data/missing balance gracefully

* check whether data is empty

Co-authored-by: Jaco <jacogr@gmail.com>

* pull out zero balance function

Co-authored-by: Jaco <jacogr@gmail.com>
2021-06-16 13:41:23 +02:00
Github Actions f97a6d0418 [CI Skip] release/beta 4.14.2-3
skip-checks: true
2021-06-15 09:19:27 +00:00
Jaco 7cd2fa5f6a Additional check for API connection & decoration in contracts (#3654)
* Additional check for API connection & decoration in contracts

* Remove snuck-in-file
2021-06-15 11:08:47 +02:00
Github Actions 6015552aab [CI Skip] release/beta 4.14.2-2
skip-checks: true
2021-06-15 07:05:21 +00:00
Jaco 8748c02b20 Adjust error message for contracts V3 (#3653)
* Adjust error message for contracts V3

* Adjust mock API
2021-06-15 08:54:43 +02:00
Github Actions 6e04d4aa93 [CI Skip] release/beta 4.14.2-1
skip-checks: true
2021-06-15 06:33:15 +00:00
Jaco 4a955f7b77 Add support for childstate_getKeysPaged RPC (#3652)
* Add support for childstate_getKeysPaged RPC

* Optional last
2021-06-15 08:22:51 +02:00
Github Actions 227143728d [CI Skip] release/beta 4.14.2-0
skip-checks: true
2021-06-15 06:19:06 +00:00
Jaco 7330555c37 Latest metadata (#3647) 2021-06-15 08:08:16 +02:00
Github Actions 09831fe325 [CI Skip] release/stable 4.14.1
skip-checks: true
2021-06-14 09:19:12 +00:00
Jaco c7dda6fe85 4.14 (#3646) 2021-06-14 11:08:27 +02:00
Github Actions 285bbab055 [CI Skip] release/beta 4.13.2-12
skip-checks: true
2021-06-14 08:35:39 +00:00
Xiliang Chen b73010a506 add Authority origin (#3645) 2021-06-14 10:25:33 +02:00
Github Actions 9c951fe1cb [CI Skip] release/beta 4.13.2-11
skip-checks: true
2021-06-14 06:18:55 +00:00
Jaco f7dfb633d6 Bump deps (#3644)
* Bump deps

* Adjust base test timeouts
2021-06-14 08:07:54 +02:00
Github Actions e32286b610 [CI Skip] release/beta 4.13.2-10
skip-checks: true
2021-06-14 05:08:25 +00:00
Jaco fe2687b514 Add GeneralCouncil as origin until solution is available (#3643) 2021-06-14 06:59:11 +02:00
Github Actions 1adde99e1b [CI Skip] release/beta 4.13.2-9
skip-checks: true
2021-06-12 15:01:26 +00:00
André Silva 33dcc9c8aa add support for ValidationCodeHash (#3640) 2021-06-12 17:52:20 +03:00
Github Actions db563bc131 [CI Skip] release/beta 4.13.2-8
skip-checks: true
2021-06-12 08:40:26 +00:00
hamidra 35d2fa31e0 Fix typo and add missing type (#3639)
fixing a typo and also seems the 'attribute': 'u32' is missing from ClassDetails struct.
https://github.com/paritytech/substrate/blob/41ab01a8cb2a43f7d743778c066ad91453e0c883/frame/uniques/src/types.rs#L54
2021-06-12 10:29:10 +02:00
Github Actions 399637280c [CI Skip] release/beta 4.13.2-7
skip-checks: true
2021-06-11 16:22:23 +00:00
Jaco f46916b215 djust keys/entries retrieval batch sizes (#3638) 2021-06-11 18:09:47 +02:00
Github Actions 94aa79d1e5 [CI Skip] release/beta 4.13.2-6
skip-checks: true
2021-06-11 11:04:45 +00:00
Jaco 10dacf1d16 Correct dangling (old-style) HttpProvider docs (#3635) 2021-06-11 12:54:10 +02:00
Jaco bdaacfdd56 BN import from util (#3637)
* BN import from util

* Update packages/api-derive/src/staking/stakerRewards.ts
2021-06-11 12:52:21 +02:00
Github Actions 4fa77b3654 [CI Skip] release/beta 4.13.2-5
skip-checks: true
2021-06-09 13:28:42 +00:00
Jaco 400e14d6c9 Explicit length checks for u8aFixed (#3630)
* Explicit length checks for u8aFixed

* Adjust tests
2021-06-09 15:19:48 +02:00
Github Actions 09f247432f [CI Skip] release/beta 4.13.2-4
skip-checks: true
2021-06-09 05:34:53 +00:00
Jaco fd195dd4f0 Add Kusama 9040 upgrade block (#3625) 2021-06-09 07:23:01 +02:00
Github Actions 0038227680 [CI Skip] release/beta 4.13.2-3
skip-checks: true
2021-06-08 15:16:16 +00:00
Jaco Greeff 89dec0bc0b .prettierignore 2021-06-08 18:05:18 +03:00
Github Actions a55a835504 [CI Skip] release/beta 4.13.2-2
skip-checks: true
2021-06-07 14:10:52 +00:00
Jaco Greeff c1266a6657 Merge branch 'master' of github.com:polkadot-js/api 2021-06-07 17:00:30 +03:00
Jaco Greeff b78f08e2e6 Adjust cron locks 2021-06-07 17:00:25 +03:00
Github Actions 298ef03787 [CI Skip] release/beta 4.13.2-1
skip-checks: true
2021-06-07 13:59:20 +00:00
Jaco Greeff dd80b1873c lock cron 2021-06-07 16:48:23 +03:00
Github Actions f7672e053b [CI Skip] release/beta 4.13.2-0
skip-checks: true
2021-06-07 05:48:23 +00:00
Jaco 281e9d2dee Adjust semgrep check (#3624) 2021-06-07 07:37:28 +02:00
Github Actions 3f0d11b026 [CI Skip] release/stable 4.13.1
skip-checks: true
2021-06-06 19:30:05 +00:00
Jaco 0c997d2850 4.13 (#3623) 2021-06-06 21:18:30 +02:00
Github Actions cb0beea7cd [CI Skip] release/beta 4.12.2-20
skip-checks: true
2021-06-05 11:19:19 +00:00
Jaco Greeff 4ed783878d No semgrep.yml on forks 2021-06-05 14:07:41 +03:00
Github Actions 3846b5cc18 [CI Skip] release/beta 4.12.2-19
skip-checks: true
2021-06-05 06:49:48 +00:00
Jaco Greeff 57b8915101 push-master.yml adjust skip 2021-06-05 09:38:02 +03:00
Github Actions 4f3f7e8dff [CI Skip] release/beta 4.12.2-18
skip-checks: true
2021-06-05 06:30:54 +00:00
Jaco Greeff a42c266a35 semgrep.yml on PR 2021-06-05 09:20:00 +03:00
Github Actions b03b2db3f8 [CI Skip] release/beta 4.12.2-17
skip-checks: true
2021-06-04 14:50:06 +00:00
Jaco 5347db445d Split page sizes for keys & values on maps (#3620)
* Ssplit page sizes for keys & values on maps

* Adjust semgrep
2021-06-04 16:39:23 +02:00
Github Actions 2a15b65385 [CI Skip] release/beta 4.12.2-16
skip-checks: true
2021-06-04 10:49:58 +00:00
Jaco 7f1952acfc Bump deps (#3618) 2021-06-04 13:40:32 +03:00
Github Actions d8920b4bac [CI Skip] release/beta 4.12.2-15
skip-checks: true
2021-06-04 09:25:48 +00:00
Jaco 3b46505027 Bump static Substrate metadata (#3616)
* Bump static Substrate metadata

* Add size alias
2021-06-04 11:15:11 +02:00
Github Actions ba3ac3f73d [CI Skip] release/beta 4.12.2-14
skip-checks: true
2021-06-04 08:49:45 +00:00
Jaco Greeff 81d460ccc8 Merge branch 'master' of github.com:polkadot-js/api 2021-06-04 11:38:49 +03:00
Jaco Greeff e6bb6c49b3 semgrep on master only 2021-06-04 11:38:45 +03:00
Jaco 82ffa8a6e2 Bump deps (#3617) 2021-06-04 10:37:55 +02:00
Github Actions adc1af1f21 [CI Skip] release/beta 4.12.2-13
skip-checks: true
2021-06-04 05:45:25 +00:00
Jaco Greeff a05d6ad7dc semgrep only for non-forked 2021-06-04 08:36:01 +03:00
Github Actions be592f53b8 [CI Skip] release/beta 4.12.2-12
skip-checks: true
2021-06-03 15:24:02 +00:00
Jaco Greeff 8e74eca435 lock.yml cron 2021-06-03 18:14:53 +03:00
Github Actions 8a28d2cf46 [CI Skip] release/beta 4.12.2-11
skip-checks: true
2021-06-02 16:15:00 +00:00
Jaco Greeff d36886fcbf fix stale.yml 2021-06-02 19:03:46 +03:00
Github Actions 3bbc9fbf6e [CI Skip] release/beta 4.12.2-10
skip-checks: true
2021-06-02 14:36:16 +00:00
Jaco Greeff 1d4539f3ef lock.yml interval 2021-06-02 17:24:17 +03:00
Github Actions 215b20f7db [CI Skip] release/beta 4.12.2-9
skip-checks: true
2021-06-02 07:48:17 +00:00
Jaco c034b54822 Add CandidateInfo type (#3609)
* Add CandidateInfo type

* Adjust lock time
2021-06-02 09:37:47 +02:00
Jaco Greeff 261ca2149d Merge branch 'master' of github.com:polkadot-js/api 2021-06-02 10:07:17 +03:00
Jaco Greeff eaa67c8ea6 cron workflows 2021-06-02 10:07:12 +03:00
Github Actions db287d6997 [CI Skip] release/beta 4.12.2-8
skip-checks: true
2021-06-02 07:07:06 +00:00
Jaco b85bf7e41c setKeys accepts string/Uint8Array (#3608)
* setKeys accepts string/Uint8Array

* CHANGELOG

* Update CHANGELOG

* Westend upgrade block

* --forceExit for jest
2021-06-02 08:56:22 +02:00
Github Actions 84b82dd9b5 [CI Skip] release/beta 4.12.2-7
skip-checks: true
2021-06-02 06:50:02 +00:00
Jaco 3df5b01375 Bump metadata (#3607)
* Bump metadata

* Generate

* s/removeBounded/removeExtensions/
2021-06-02 08:38:17 +02:00
Github Actions 2e6a59e2a0 [CI Skip] release/beta 4.12.2-6
skip-checks: true
2021-06-01 18:04:18 +00:00
Jaco 2f91561166 Westmint spec types (#3602) 2021-06-01 19:54:02 +02:00
Github Actions b307772be2 [CI Skip] release/beta 4.12.2-5
skip-checks: true
2021-06-01 10:09:09 +00:00
Jaco Greeff d14d2ccc86 semgrep.yml 2021-06-01 12:58:25 +03:00
Github Actions 0f26ec47e2 [CI Skip] release/beta 4.12.2-4
skip-checks: true
2021-06-01 06:15:01 +00:00
Jaco Greeff 40065e300b cron daily only 2021-06-01 09:03:59 +03:00
Github Actions bbdb8a317f [CI Skip] release/beta 4.12.2-3
skip-checks: true
2021-05-31 20:27:45 +00:00
Jaco Greeff 668085262c cron locks 2021-05-31 23:15:48 +03:00
Github Actions 508400684a [CI Skip] release/beta 4.12.2-2
skip-checks: true
2021-05-31 12:42:37 +00:00
Jaco 3273556f7b Convert stragging BN type imports (#3595) 2021-05-31 14:32:33 +02:00
Github Actions d36144bf36 [CI Skip] release/beta 4.12.2-1
skip-checks: true
2021-05-31 08:11:04 +00:00
Jaco 444479011e Update .123trigger 2021-05-31 10:00:35 +02:00
Github Actions 8ac713abcf [CI Skip] release/beta 4.12.2-0
skip-checks: true
2021-05-31 07:58:00 +00:00
Jaco Greeff 728bc5294f Bump dev 2021-05-31 10:47:09 +03:00
Jaco fd2f331bdf Bump dev (#3594) 2021-05-31 09:19:54 +02:00
Jaco Greeff 2aebbb89cb lock.yml 2021-05-30 22:23:25 +03:00
Github Actions 532c011495 [CI Skip] release/beta 4.12.2-0
skip-checks: true
2021-05-30 10:52:28 +00:00
Jaco e2802df9ce Bump berry (#3592) 2021-05-30 12:41:59 +02:00
Github Actions cc181e2cc3 [CI Skip] release/stable 4.12.1
skip-checks: true
2021-05-30 06:36:49 +00:00
Jaco 1b8ba41715 4.12 (#3590)
* 4.12

* Bump dev
2021-05-30 08:25:51 +02:00
Github Actions 648be9aecb [CI Skip] release/beta 4.11.3-9
skip-checks: true
2021-05-30 05:52:02 +00:00
Jaco 292af97dc9 Eth RPC def cleanups (#3589) 2021-05-30 07:40:26 +02:00
Github Actions bcdd537214 [CI Skip] release/beta 4.11.3-8
skip-checks: true
2021-05-29 08:29:57 +00:00
Jaco Greeff 514c5e4825 Update stale.yml 2021-05-29 11:19:23 +03:00
Github Actions 9b9581487d [CI Skip] release/beta 4.11.3-7
skip-checks: true
2021-05-28 14:39:22 +00:00
Jaco d443f31a9a Kusama 9030 upgrade block (#3584) 2021-05-28 16:30:14 +02:00
Github Actions 3951da5df3 [CI Skip] release/beta 4.11.3-6
skip-checks: true
2021-05-28 08:50:52 +00:00
Jaco Greeff 5f3a1e5b24 Update stale.yml 2021-05-28 11:39:43 +03:00
Github Actions b1a6ccd425 [CI Skip] release/beta 4.11.3-5
skip-checks: true
2021-05-28 08:26:21 +00:00
Jaco adc40e581f Add stale.yml (#3582) 2021-05-28 10:14:47 +02:00
Jaco c6b0b0c161 Remove confusing external-use rpc-core README (#3581)
Closes https://github.com/polkadot-js/api/issues/3580
2021-05-28 10:14:24 +02:00
Github Actions bf5b14580b [CI Skip] release/beta 4.11.3-4
skip-checks: true
2021-05-28 07:08:13 +00:00
Jaco 088c02862b Added 9030 upgrade block for Westend (#3579) 2021-05-28 08:59:04 +02:00
Github Actions a05980900e [CI Skip] release/beta 4.11.3-3
skip-checks: true
2021-05-28 06:47:44 +00:00
Jaco 77019def08 Allow storage queries with default keys values (#3578)
* Allow storage queries with default keys values

* Cleanups

* Adjust

* Tuple test
2021-05-28 08:37:08 +02:00
Github Actions ae6a3307b1 [CI Skip] release/beta 4.11.3-2
skip-checks: true
2021-05-27 15:25:37 +00:00
Jaco 8cb15c6a87 Update Substrate static metadata (#3576) 2021-05-27 17:13:57 +02:00
Github Actions 389dbb58a9 [CI Skip] release/beta 4.11.3-1
skip-checks: true
2021-05-27 08:30:51 +00:00
Jaco 2d02f61fa7 Align Data.Raw decoding with Substrate (32-bytes) (#3573)
* Align Data.Raw decoding with Substrate (32-bytes)

* CHANGELOG

* Encoding test updates

* provider.disconnect

* Adjust provider tests

* Unique connection URLs

* Dangling tests

* detectOpenHandles

* Additional

* Remove rx test (catered for by Promise wrap)

* Additional cleanups to tests
2021-05-27 10:18:56 +02:00
Github Actions 7497ac723f [CI Skip] release/beta 4.11.3-0
skip-checks: true
2021-05-26 06:47:13 +00:00
Arjan Zijderveld 711a145e1e Changed firstSlot and lastSlot to firstPeriod and lastPeriod. Reference: [Polkadot definition source](https://github.com/paritytech/polkadot/blob/master/runtime/common/src/crowdloan.rs#L141) (#3568) 2021-05-26 08:38:22 +02:00
196 changed files with 7665 additions and 4034 deletions
+4 -3
View File
@@ -1,4 +1,4 @@
29
31
1.4.2
1.6.2
1.11.2
@@ -19,8 +19,9 @@
3.10.2
4.0.2
4.0.3
4.6.2
4.7.2
4.9.2
4.11.2
4.11.2
4.16.2
+23
View File
@@ -0,0 +1,23 @@
name: 'Lock Threads'
on:
schedule:
- cron: '30 1/2 * * *'
jobs:
lock:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v2
with:
github-token: ${{ secrets.GH_PAT_BOT }}
issue-lock-inactive-days: '7'
issue-lock-comment: >
This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue
if you think you have a related problem or query.
pr-lock-inactive-days: '2'
pr-lock-comment: >
This pull request has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related bugs.
+1 -8
View File
@@ -6,11 +6,11 @@ on:
jobs:
master:
if: "! startsWith(github.event.head_commit.message, '[CI Skip]')"
strategy:
matrix:
step: ['build:release']
name: ${{ matrix.step }}
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && github.repository == 'polkadot-js/api'"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@@ -25,10 +25,3 @@ jobs:
run: |
yarn install --immutable | grep -v 'YN0013'
yarn ${{ matrix.step }}
dummy:
runs-on: ubuntu-latest
steps:
- name: dummy
run: |
echo "Dummy skip step"
+18
View File
@@ -0,0 +1,18 @@
name: Semgrep
on:
pull_request: {}
push:
branches:
- master
jobs:
check:
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && (!github.event.pull_request || github.event.pull_request.head.repo.full_name == github.repository)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: returntocorp/semgrep-action@v1
with:
auditOn: push
publishToken: ${{ secrets.SEMGREP_APP_TOKEN }}
publishDeployment: 1395
+17
View File
@@ -0,0 +1,17 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 2/2 * * *'
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GH_PAT_BOT }}
stale-issue-message: 'This issue has been open for 21 days with no activity and is not labelled as an enhancement. It will be closed in 7 days.'
stale-issue-label: 'stale'
exempt-issue-labels: '-size-l,-size-m,-size-s,-size-xl,-size-xs,[bug]'
days-before-stale: 21
days-before-close: 7
+3
View File
@@ -0,0 +1,3 @@
build
coverage
packages
+4
View File
@@ -0,0 +1,4 @@
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
module.exports = require('@polkadot/dev/config/prettier.cjs');
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-55
View File
File diff suppressed because one or more lines are too long
+591
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -10,4 +10,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"
yarnPath: .yarn/releases/yarn-2.4.1.cjs
yarnPath: .yarn/releases/yarn-3.0.0-rc.2.cjs
+101
View File
@@ -1,5 +1,106 @@
# CHANGELOG
## 4.16.2 Jun 27, 2021
Upgrade priority: Low. Recommended for Polkadot with runtime >= 9050.
Changes:
- Correct `CompactAssignments` & `RawSolution` types for Polkadot
## 4.16.1 Jun 26, 2021
Upgrade priority: Low. Recommended for full from-genesis queries on Kusama.
Contributed:
- Adjust types for uniques (Thanks to https://github.com/Yuripetusko)
Changes:
- Add Kusama, Polkadot & Westend 9050 upgrade blocks
- Add Kusama & Westend 9070 upgrade blocks
- Adjust API decoration to lazy-create event and storage types
- Use TS `override` as applicable (with `--noImplicitOverrides` option)
- Add missing historic `Heartbeat: HeartbeatTo244` mapping to Kusama
- Remove duplication from contracts registry
- Add explicit check for scale-info 0.7+ (contracts index lookups)
- Align static metadata with latest Substrate
## 4.15.1 Jun 19, 2021
Upgrade priority: Medium. Recommended for all chains where Xcm is used (addition of new `XcmOrigin`)
Contributed:
- Added `ChargeAssetTxPayment` extension (Thanks to https://github.com/apopiak)
Changes:
- Allow for type decoding of nested fixed vectors, tuples and structs
- Added `childstate_getKeysPaged` RPC
- Add `XcmOrigin` mapping for `OriginCaller` generation
- Align static metadata with latest Substrate
- Adjust error message for contracts V3 (extrinsic from runtime)
- Correct module optionality in `api.derive.balances.account`
- Add alias for `GenericAddress` -> `GenericMultiAddress`
- Adjust metadata doc generation (keep spaces between subsequent lines)
## 4.14.1 Jun 14, 2021
Upgrade priority: Low. Internal adjustment only, no major external usage changes.
Contributed:
- Adjust types for uniques (Thanks to https://github.com/hamidra)
- Add `ValidationCodeHash` type (Thanks to https://github.com/andresilva)
- Extend `OriginCaller` type creation (Thanks to https://github.com/xlc)
Changes:
- Do strict length checking on `[u8; <length>]` type inputs
- Adjust keys/entries retrieval batch sizes
- Add upgrade block for Kusama 9040
- Use `BN` imports from `@polkadot/util`
## 4.13.1 Jun 6, 2021
Upgrade priority: Medium. Required for users connecting to Statemine and future Kusama upgrades.
Changes:
- Overrides for `westmint` spec (same as `statemint`)
- Adjust `tx.session.setKeys` TS augmentation to allow `string` & `Uint8Array` keys
- Add & adjust types for latest Cumulus code
- Added 9031-9033 upgrade block for Westend
- Update static metadata to latest Substrate
- Optimize map retrieval with split page sizes for keys & values
- Sanitizing `BN` imports to `type`-only as required
## 4.12.1 May 30, 2021
Upgrade priority: Low. Internal adjustment only, no major external usage changes.
Changelog:
- Update `FundInfo` type with Polkadot (Thanks to https://github.com/arjanz)
Changes:
- Allow storage queries with default keys values
- Align identity `Data` to limit to 32 bytes in the `Raw` enum (as per Substrate)
- Align static (test & docs-only) metadata with latest Substrate master
- Added 9030 upgrade blocks for Kusama & Westend
- Cleanup of Eth pallet RPC definitions
- Cleanup README for `@polkadot/rpc-core` (recommended for internal-usage only)
- Cleanup internal tests (no dangling handles, cater for Jest 27)
## 4.11.2 May 24, 2021
Upgrade priority: Low. Recommended where users are having TS mismatches with type definitions created on older versions.
+1
View File
@@ -27,5 +27,6 @@ module.exports = {
'<rootDir>/packages/types/build',
'<rootDir>/packages/types-known/build'
],
testTimeout: 10000,
transformIgnorePatterns: ['/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/)']
};
+9 -9
View File
@@ -8,7 +8,7 @@
"packages/*"
],
"resolutions": {
"typescript": "^4.2.4"
"typescript": "^4.3.4"
},
"scripts": {
"build": "yarn build:interfaces && polkadot-dev-build-ts",
@@ -20,19 +20,19 @@
"lint": "polkadot-dev-run-lint",
"clean": "polkadot-dev-clean-build",
"postinstall": "polkadot-dev-yarn-only",
"test": "polkadot-dev-run-test --coverage --runInBand --testPathIgnorePatterns e2e",
"test:one": "polkadot-dev-run-test",
"test": "polkadot-dev-run-test --coverage --forceExit --runInBand --testPathIgnorePatterns e2e",
"test:one": "polkadot-dev-run-test --detectOpenHandles --forceExit",
"test:watch": "polkadot-dev-run-test --watch"
},
"devDependencies": {
"@babel/core": "^7.14.3",
"@babel/register": "^7.13.16",
"@babel/runtime": "^7.14.0",
"@polkadot/dev": "^0.62.16",
"@polkadot/ts": "^0.3.66",
"@babel/core": "^7.14.6",
"@babel/register": "^7.14.5",
"@babel/runtime": "^7.14.6",
"@polkadot/dev": "^0.62.43",
"@polkadot/ts": "^0.4.1",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^26.0.23",
"copyfiles": "^2.4.1"
},
"version": "4.11.2"
"version": "4.16.2"
}
+6 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "4.11.2",
"version": "4.16.2",
"type": "module",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
@@ -19,11 +19,10 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.14.0",
"@polkadot/api": "4.11.2",
"@polkadot/types": "4.11.2",
"@polkadot/util": "^6.5.1",
"@polkadot/x-rxjs": "^6.5.1",
"bn.js": "^4.11.9"
"@babel/runtime": "^7.14.6",
"@polkadot/api": "4.16.2",
"@polkadot/types": "4.16.2",
"@polkadot/util": "^6.10.1",
"@polkadot/x-rxjs": "^6.10.1"
}
}
+3 -3
View File
@@ -19,7 +19,7 @@ function findMessage <T extends AbiMessage> (list: T[], messageOrId: T | string
? list.find(({ identifier }) => [identifier, stringCamelCase(identifier)].includes(messageOrId.toString()))
: messageOrId;
return assertReturn(message, `Attempted to call an invalid contract interface, ${stringify(messageOrId)}`);
return assertReturn(message, () => `Attempted to call an invalid contract interface, ${stringify(messageOrId)}`);
}
export class Abi {
@@ -127,7 +127,7 @@ export class Abi {
const args = this.#createArgs(spec.args, spec);
const event = {
args,
docs: spec.docs.map((doc) => doc.toString()),
docs: spec.docs.map((d) => d.toString()),
fromU8a: (data: Uint8Array): DecodedEvent => ({
args: this.#decodeArgs(args, data),
event
@@ -145,7 +145,7 @@ export class Abi {
const message = {
...add,
args,
docs: spec.docs.map((doc) => doc.toString()),
docs: spec.docs.map((d) => d.toString()),
fromU8a: (data: Uint8Array): DecodedMessage => ({
args: this.#decodeArgs(args, data),
message
+32 -40
View File
@@ -35,8 +35,10 @@ export class MetaRegistry extends TypeRegistry {
constructor (metadataVersion: string, chainProperties?: ChainProperties) {
super();
// type indexes are 1-based pre-1.0 and 0-based post-1.0
this.typeOffset = metadataVersion.split('.')[0] === '0' ? 1 : 0;
const [major, minor] = metadataVersion.split('.').map((n) => parseInt(n, 10));
// type indexes are 1-based pre 0.7 and 0-based post
this.typeOffset = (major === 0 && minor < 7) ? 1 : 0;
if (chainProperties) {
this.setChainProperties(chainProperties);
@@ -124,7 +126,7 @@ export class MetaRegistry extends TypeRegistry {
: {}
),
...(path.length > 1
? { namespace: path.map((segment) => segment.toString()).join('::') }
? { namespace: path.map((s) => s.toString()).join('::') }
: {}
),
...(type.params.length > 0
@@ -154,15 +156,13 @@ export class MetaRegistry extends TypeRegistry {
assert(isTuple || isStruct, 'Invalid fields type detected, expected either Tuple or Struct');
const sub = fields.map(({ name, type }) => {
return {
...this.getMetaTypeDef({ type }),
...(name.isSome
? { name: name.unwrap().toString() }
: {}
)
};
});
const sub = fields.map(({ name, type }) => ({
...this.getMetaTypeDef({ type }),
...(name.isSome
? { name: name.unwrap().toString() }
: {}
)
}));
return isTuple && sub.length === 1
? sub[0]
@@ -213,32 +213,28 @@ export class MetaRegistry extends TypeRegistry {
const { params, path } = this.#getMetaType(id);
const specialVariant = path[0].toString();
if (specialVariant === 'Option') {
return {
return specialVariant === 'Option'
? {
info: TypeDefInfo.Option,
sub: this.getMetaTypeDef({ type: params[0] })
};
} else if (specialVariant === 'Result') {
return {
info: TypeDefInfo.Result,
sub: params.map((type, index) => ({
name: ['Ok', 'Error'][index],
...this.getMetaTypeDef({ type })
}))
};
}
return {
info: TypeDefInfo.Enum,
sub: this.#extractVariantSub(variants)
};
}
: specialVariant === 'Result'
? {
info: TypeDefInfo.Result,
sub: params.map((type, index) => ({
name: ['Ok', 'Error'][index],
...this.getMetaTypeDef({ type })
}))
}
: {
info: TypeDefInfo.Enum,
sub: this.#extractVariantSub(variants)
};
}
#extractVariantSub = (variants: SiVariant[]): TypeDef[] => {
const isAllUnitVariants = variants.every(({ fields }) => fields.length === 0);
if (isAllUnitVariants) {
return variants.map(({ discriminant, name }) => ({
return variants.every(({ fields }) => fields.length === 0)
? variants.map(({ discriminant, name }) => ({
...(
discriminant.isSome
? { ext: { discriminant: discriminant.unwrap().toNumber() } }
@@ -247,14 +243,10 @@ export class MetaRegistry extends TypeRegistry {
info: TypeDefInfo.Plain,
name: name.toString(),
type: 'Null'
}));
}
return variants.map(({ fields, name }) =>
withTypeString({
}))
: variants.map(({ fields, name }) => withTypeString({
...this.#extractFields(fields),
name: name.toString()
})
);
}));
}
}
+2 -1
View File
@@ -26,6 +26,7 @@ export abstract class Base<ApiType extends ApiTypes> {
this.registry = this.abi.registry;
this._decorateMethod = decorateMethod;
assert(isFunction(api.rx.tx.contracts?.instantiateWithCode), 'You need to connect to a node with a V3 contracts module. Your node does not expose api.tx.contracts.instantiateWithCode on this instance');
assert(!!(api && api.isConnected && api.tx && api.tx.contracts && Object.keys(api.tx.contracts).length), 'Your API has not been initialized correctly and it not decorated with the runtime interfaces for contracts as retrieved from the on-chain runtime');
assert(isFunction(api.tx.contracts.instantiateWithCode), 'You need to connect to a chain with a runtime with a V3 contracts module. The runtime does not expose api.tx.contracts.instantiateWithCode');
}
}
+1 -3
View File
@@ -9,12 +9,10 @@ import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/type
import type { AbiMessage, ContractCallOutcome, ContractOptions, DecodedEvent } from '../types';
import type { ContractCallResult, ContractCallSend, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
import BN from 'bn.js';
import { SubmittableResult } from '@polkadot/api';
import { ApiBase } from '@polkadot/api/base';
import { createTypeUnsafe } from '@polkadot/types';
import { assert, BN_HUNDRED, BN_ONE, BN_ZERO, bnToBn, isFunction, isUndefined, logger } from '@polkadot/util';
import { assert, BN, BN_HUNDRED, BN_ONE, BN_ZERO, bnToBn, isFunction, isUndefined, logger } from '@polkadot/util';
import { map } from '@polkadot/x-rxjs/operators';
import { Abi } from '../Abi';
+5 -6
View File
@@ -7,13 +7,12 @@ import { TypeRegistry } from '@polkadot/types';
const registry = new TypeRegistry();
export const mockApi = {
isConnected: true,
registry,
rx: {
tx: {
contracts: {
instantiateWithCode: (): never => {
throw new Error('mock');
}
tx: {
contracts: {
instantiateWithCode: (): never => {
throw new Error('mock');
}
}
}
+1 -1
View File
@@ -1,11 +1,11 @@
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type BN from 'bn.js';
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes, ObsInnerType } from '@polkadot/api/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { CodecArg } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { Observable } from '@polkadot/x-rxjs';
import type { AbiMessage, BlueprintOptions, ContractCallOutcome, ContractOptions } from '../types';
+1 -2
View File
@@ -5,11 +5,10 @@ import type { SubmittableResult } from '@polkadot/api';
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes } from '@polkadot/api/types';
import type { CodecArg } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { AbiConstructor, BlueprintOptions } from '../types';
import type { BlueprintDeploy, ContractGeneric } from './types';
import BN from 'bn.js';
import { Bytes } from '@polkadot/types';
import { compactAddLength, u8aToU8a } from '@polkadot/util';
import { randomAsU8a } from '@polkadot/util-crypto';
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-contract', version: '4.11.2' };
export const packageInfo = { name: '@polkadot/api-contract', version: '4.16.2' };
+1 -1
View File
@@ -1,12 +1,12 @@
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type BN from 'bn.js';
import type { ApiBase } from '@polkadot/api/base';
import type { ApiTypes } from '@polkadot/api/types';
import type { Text, u64 } from '@polkadot/types';
import type { ContractExecResultResult, ContractSelector } from '@polkadot/types/interfaces';
import type { Codec, CodecArg, TypeDef } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { Abi } from '.';
export interface ContractBase<ApiType extends ApiTypes> {
+1 -2
View File
@@ -4,10 +4,9 @@
import type { SubmittableResult } from '@polkadot/api';
import type { EventRecord } from '@polkadot/types/interfaces';
import type { CodecArg } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { BlueprintOptions, ContractOptions } from './types';
import BN from 'bn.js';
import { isBigInt, isBn, isNumber, isString } from '@polkadot/util';
type ContractEvents = 'CodeStored' | 'ContractEmitted' | 'ContractExecution' | 'Instantiated';
+10 -11
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "4.11.2",
"version": "4.16.2",
"type": "module",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
@@ -19,17 +19,16 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.14.0",
"@polkadot/api": "4.11.2",
"@polkadot/rpc-core": "4.11.2",
"@polkadot/types": "4.11.2",
"@polkadot/util": "^6.5.1",
"@polkadot/util-crypto": "^6.5.1",
"@polkadot/x-rxjs": "^6.5.1",
"bn.js": "^4.11.9"
"@babel/runtime": "^7.14.6",
"@polkadot/api": "4.16.2",
"@polkadot/rpc-core": "4.16.2",
"@polkadot/types": "4.16.2",
"@polkadot/util": "^6.10.1",
"@polkadot/util-crypto": "^6.10.1",
"@polkadot/x-rxjs": "^6.10.1"
},
"devDependencies": {
"@polkadot/keyring": "^6.5.1",
"@polkadot/rpc-provider": "4.11.2"
"@polkadot/keyring": "^6.10.1",
"@polkadot/rpc-provider": "4.16.2"
}
}
+45 -16
View File
@@ -23,13 +23,19 @@ type DeriveCustomAccount = ApiInterfaceRx['derive'] & {
}
}
function zeroBalance (api: ApiInterfaceRx) {
return api.registry.createType('Balance');
}
function getBalance (api: ApiInterfaceRx, [freeBalance, reservedBalance, frozenFee, frozenMisc]: BalanceResult): DeriveBalancesAccountData {
const votingBalance = api.registry.createType('Balance', freeBalance.toBn());
return {
freeBalance,
frozenFee,
frozenMisc,
reservedBalance,
votingBalance: api.registry.createType('Balance', freeBalance.toBn())
votingBalance
};
}
@@ -55,7 +61,16 @@ function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observab
]).pipe(
map(([freeBalance, reservedBalance, accountNonce]): Result => [
accountNonce,
[[freeBalance, reservedBalance, api.registry.createType('Balance'), api.registry.createType('Balance')]]
[[freeBalance, reservedBalance, zeroBalance(api), zeroBalance(api)]]
])
);
}
function querySystemNonce (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
return api.query.system.accountNonce<Index>(accountId).pipe(
map((accountNonce): Result => [
accountNonce,
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
])
);
}
@@ -71,6 +86,7 @@ function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, module
const extract = (data: AccountData[]) =>
data.map(({ feeFrozen, free, miscFrozen, reserved }): BalanceResult => [free, reserved, feeFrozen, miscFrozen]);
// NOTE this is for the first case where we do have instances specified
return isFunction(api.query.system.account)
? api.queryMulti<[AccountInfo, ...(AccountData[])]>([[api.query.system.account, accountId], ...balances]).pipe(
map(([{ nonce }, ...balances]): Result => [nonce, extract(balances)])
@@ -80,16 +96,27 @@ function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, module
);
}
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
function querySystemAccount (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
// AccountInfo is current, support old, eg. Edgeware
return api.query.system.account<AccountInfo | ITuple<[Index, AccountData]>>(accountId).pipe(
map((infoOrTuple): Result => {
const { feeFrozen, free, miscFrozen, reserved } = (infoOrTuple as AccountInfo).nonce
const data = (infoOrTuple as AccountInfo).nonce
? (infoOrTuple as AccountInfo).data
: (infoOrTuple as [Index, AccountData])[1];
const nonce = (infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0];
if (!data || data.isEmpty) {
return [
nonce,
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
];
}
const { feeFrozen, free, miscFrozen, reserved } = data;
return [
(infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0],
nonce,
[[free, reserved, feeFrozen, miscFrozen]]
];
})
@@ -113,6 +140,10 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
*/
export function account (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAccount> {
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
const empty: Result = [
api.registry.createType('Index'),
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
];
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAccount> =>
api.derive.accounts.accountId(address).pipe(
@@ -122,19 +153,17 @@ export function account (instanceId: string, api: ApiInterfaceRx): (address: Acc
of(accountId),
balanceInstances
? queryBalancesAccount(api, accountId, balanceInstances)
: isFunction(api.query.system.account)
? queryCurrent(api, accountId)
: isFunction(api.query.balances.account)
: isFunction(api.query.system?.account)
? querySystemAccount(api, accountId)
: isFunction(api.query.balances?.account)
? queryBalancesAccount(api, accountId)
: queryBalancesFree(api, accountId)
])
: of([
api.registry.createType('AccountId'),
[
api.registry.createType('Index'),
[[api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance')]]
]
: isFunction(api.query.balances?.freeBalance)
? queryBalancesFree(api, accountId)
: isFunction(api.query.system?.accountNonce)
? querySystemNonce(api, accountId)
: of(empty)
])
: of([api.registry.createType('AccountId'), empty])
)
),
map((result): DeriveBalancesAccount => calcBalances(api, result))
+1 -3
View File
@@ -7,9 +7,7 @@ import type { AccountId, AccountIndex, Address, Balance, BalanceLock, BalanceLoc
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveBalancesAccount, DeriveBalancesAccountData, DeriveBalancesAll, DeriveBalancesAllAccountData } from '../types';
import BN from 'bn.js';
import { bnMax, isFunction } from '@polkadot/util';
import { BN, bnMax, isFunction } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
+1 -2
View File
@@ -2,11 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { BN } from '@polkadot/util';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveContractFees } from '../types';
import BN from 'bn.js';
import { of } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
+1 -2
View File
@@ -4,11 +4,10 @@
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { AccountId, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, Vote, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces';
import type { BN } from '@polkadot/util';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveDemocracyLock } from '../types';
import BN from 'bn.js';
import { BN_ZERO, isUndefined } from '@polkadot/util';
import { of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
@@ -3,10 +3,9 @@
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { ReferendumIndex } from '@polkadot/types/interfaces';
import type { BN } from '@polkadot/util';
import type { Observable } from '@polkadot/x-rxjs';
import BN from 'bn.js';
import { of } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
@@ -4,11 +4,10 @@
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option, Vec } from '@polkadot/types';
import type { AccountId, ReferendumInfo, ReferendumInfoTo239, Vote, Voting, VotingDelegating, VotingDirectVote } from '@polkadot/types/interfaces';
import type { BN } from '@polkadot/util';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveBalancesAccount, DeriveReferendum, DeriveReferendumVote, DeriveReferendumVotes } from '../types';
import BN from 'bn.js';
import { isFunction } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
@@ -2,10 +2,9 @@
// SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { BN } from '@polkadot/util';
import type { Observable } from '@polkadot/x-rxjs';
import BN from 'bn.js';
import { bnSqrt } from '@polkadot/util';
import { map } from '@polkadot/x-rxjs/operators';
+1 -1
View File
@@ -1,9 +1,9 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type BN from 'bn.js';
import type { Vec } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, Hash, PropIndex, Proposal, ReferendumIndex, ReferendumInfoTo239, ReferendumStatus, Vote, VoteThreshold } from '@polkadot/types/interfaces';
import type { BN } from '@polkadot/util';
export interface DeriveDemocracyLock {
balance: Balance;
+1 -3
View File
@@ -7,9 +7,7 @@ import type { AccountId, Balance, BlockNumber, PreimageStatus, Proposal, Referen
import type { ITuple } from '@polkadot/types/types';
import type { DeriveProposalImage, DeriveReferendum, DeriveReferendumVote, DeriveReferendumVotes, DeriveReferendumVoteState } from '../types';
import BN from 'bn.js';
import { bnSqrt } from '@polkadot/util';
import { BN, bnSqrt } from '@polkadot/util';
type PreimageInfo = [Bytes, AccountId, Balance, BlockNumber];
type OldPreimage = ITuple<PreimageInfo>;
+9 -1
View File
@@ -39,6 +39,10 @@ describe('derive', (): void => {
api.isReady.subscribe(() => done());
});
afterAll(async () => {
await api.disconnect();
});
testFunction(api)('accounts', 'idAndIndex', []);
testFunction(api)('accounts', 'idToIndex', []);
testFunction(api)('accounts', 'indexes', []);
@@ -80,7 +84,11 @@ describe('derive', (): void => {
});
beforeAll((done): void => {
api.isReady.subscribe((): void => done());
api.isReady.subscribe(() => done());
});
afterAll(async () => {
await api.disconnect();
});
// override
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-derive', version: '4.11.2' };
export const packageInfo = { name: '@polkadot/api-derive', version: '4.16.2' };
+1 -3
View File
@@ -5,9 +5,7 @@ import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Balance, StakingLedger, UnlockChunk } from '@polkadot/types/interfaces';
import type { DeriveSessionInfo, DeriveStakingAccount, DeriveStakingKeys, DeriveStakingQuery, DeriveUnlocking } from '../types';
import BN from 'bn.js';
import { BN_ZERO } from '@polkadot/util';
import { BN, BN_ZERO } from '@polkadot/util';
import { combineLatest, Observable } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
@@ -4,10 +4,10 @@
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option, u32 } from '@polkadot/types';
import type { ActiveEraInfo, EraIndex } from '@polkadot/types/interfaces';
import type { BN } from '@polkadot/util';
import type { Observable } from '@polkadot/x-rxjs';
import BN from 'bn.js';
import { BN_ONE, BN_ZERO } from '@polkadot/util';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
@@ -24,12 +24,12 @@ export function erasHistoric (instanceId: string, api: ApiInterfaceRx): (withAct
const activeEra: BN = activeEraOpt.unwrapOrDefault().index;
let lastEra = activeEra;
while (lastEra.gten(0) && (result.length < max)) {
while (lastEra.gte(BN_ZERO) && (result.length < max)) {
if ((lastEra !== activeEra) || (withActive === true)) {
result.push(api.registry.createType('EraIndex', lastEra));
}
lastEra = lastEra.subn(1);
lastEra = lastEra.sub(BN_ONE);
}
// go from oldest to newest
@@ -3,12 +3,11 @@
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId, EraIndex, StakingLedger } from '@polkadot/types/interfaces';
import type { BN } from '@polkadot/util';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveEraPoints, DeriveEraPrefs, DeriveEraRewards, DeriveEraValPrefs, DeriveStakerExposure, DeriveStakerReward, DeriveStakerRewardValidator } from '../types';
import type { DeriveStakingQuery } from './types';
import BN from 'bn.js';
import { BN_BILLION, BN_ZERO } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
@@ -121,8 +120,6 @@ function filterRewards (eras: EraIndex[], valInfo: [string, DeriveStakingQuery][
return false;
}
reward.isStakerPayout = true;
removeClaimed(validators, queryValidators, reward);
return true;
@@ -165,17 +162,21 @@ export function _stakerRewards (instanceId: string, api: ApiInterfaceRx): (accou
const [allValidators, stashValidators] = allUniqValidators(allRewards);
return api.derive.staking.queryMulti(allValidators, { withLedger: true }).pipe(
map((queriedVals): DeriveStakerReward[][] => {
return queries.map(({ stakingLedger }, index): DeriveStakerReward[] => {
const rewards = allRewards[index];
const ownValidators = stashValidators[index].map((validatorId): [string, DeriveStakingQuery] => [
validatorId,
queriedVals.find((q) => q.accountId.eq(validatorId)) as DeriveStakingQuery
]);
return filterRewards(eras, ownValidators, { rewards, stakingLedger });
});
})
map((queriedVals): DeriveStakerReward[][] =>
queries.map(({ stakingLedger }, index): DeriveStakerReward[] =>
filterRewards(
eras,
stashValidators[index].map((validatorId): [string, DeriveStakingQuery] => [
validatorId,
queriedVals.find((q) => q.accountId.eq(validatorId)) as DeriveStakingQuery
]),
{
rewards: allRewards[index],
stakingLedger
}
)
)
)
);
})
)
+1 -2
View File
@@ -1,8 +1,8 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type BN from 'bn.js';
import type { AccountId, Balance, EraIndex, Exposure, RewardDestination, RewardPoint, StakingLedger, ValidatorPrefs } from '@polkadot/types/interfaces';
import type { BN } from '@polkadot/util';
import type { DeriveSessionIndexes } from '../session/types';
export type DeriveEraValPoints = Record<string, RewardPoint>;
@@ -81,7 +81,6 @@ export interface DeriveStakerRewardValidator {
export interface DeriveStakerReward {
era: EraIndex;
eraReward: Balance;
isStakerPayout?: boolean;
isEmpty: boolean;
isValidator: boolean;
nominating: DeriveEraExposureNominating[];
+1 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import BN from 'bn.js';
import { BN } from '@polkadot/util';
export const FALLBACK_MAX_HASH_COUNT = 250;
+1 -1
View File
@@ -1,9 +1,9 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type BN from 'bn.js';
import type { u32 } from '@polkadot/types';
import type { AccountId, Balance, BalanceLock, BalanceLockTo212, BalanceOf, Bid, BidKind, BlockNumber, Bounty, BountyIndex, Hash, Index, Proposal, ProposalIndex, SetIndex, SocietyVote, StrikeCount, TreasuryProposal, Votes, VouchingStatus } from '@polkadot/types/interfaces';
import type { BN } from '@polkadot/util';
export * from './accounts/types';
export * from './council/types';
+12 -13
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "4.11.2",
"version": "4.16.2",
"type": "module",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js",
@@ -19,18 +19,17 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": {
"@babel/runtime": "^7.14.0",
"@polkadot/api-derive": "4.11.2",
"@polkadot/keyring": "^6.5.1",
"@polkadot/metadata": "4.11.2",
"@polkadot/rpc-core": "4.11.2",
"@polkadot/rpc-provider": "4.11.2",
"@polkadot/types": "4.11.2",
"@polkadot/types-known": "4.11.2",
"@polkadot/util": "^6.5.1",
"@polkadot/util-crypto": "^6.5.1",
"@polkadot/x-rxjs": "^6.5.1",
"bn.js": "^4.11.9",
"@babel/runtime": "^7.14.6",
"@polkadot/api-derive": "4.16.2",
"@polkadot/keyring": "^6.10.1",
"@polkadot/metadata": "4.16.2",
"@polkadot/rpc-core": "4.16.2",
"@polkadot/rpc-provider": "4.16.2",
"@polkadot/types": "4.16.2",
"@polkadot/types-known": "4.16.2",
"@polkadot/util": "^6.10.1",
"@polkadot/util-crypto": "^6.10.1",
"@polkadot/x-rxjs": "^6.10.1",
"eventemitter3": "^4.0.7"
}
}
+16 -11
View File
@@ -1,7 +1,7 @@
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
/* eslint-disable */
import type { Vec, u16, u32, u64, u8 } from '@polkadot/types';
import type { Vec, u16, u32, u64 } from '@polkadot/types';
import type { Codec } from '@polkadot/types/types';
import type { Schedule } from '@polkadot/types/interfaces/contracts';
import type { Balance, BalanceOf, BlockNumber, LockIdentifier, Moment, PalletId, Perbill, Percent, Permill, RuntimeDbWeight, Weight } from '@polkadot/types/interfaces/runtime';
@@ -160,7 +160,7 @@ declare module '@polkadot/api/types/consts' {
**/
enactmentPeriod: BlockNumber & AugmentedConst<ApiType>;
/**
* Minimum voting period allowed for an emergency referendum.
* Minimum voting period allowed for a fast-track referendum.
**/
fastTrackVotingPeriod: BlockNumber & AugmentedConst<ApiType>;
/**
@@ -169,6 +169,9 @@ declare module '@polkadot/api/types/consts' {
launchPeriod: BlockNumber & AugmentedConst<ApiType>;
/**
* The maximum number of votes for an account.
*
* Also used to compute weight, an overly big value can
* lead to extrinsic with very big weight: see `delegate` for instance.
**/
maxVotes: u32 & AugmentedConst<ApiType>;
/**
@@ -364,14 +367,20 @@ declare module '@polkadot/api/types/consts' {
/**
* The base amount of currency needed to reserve for creating a multisig execution or to store
* a dispatch call for later.
*
* This is held for an additional storage item whose value size is
* `4 + sizeof((BlockNumber, Balance, AccountId))` bytes and whose key size is
* `32 + sizeof(AccountId)` bytes.
**/
depositBase: BalanceOf & AugmentedConst<ApiType>;
/**
* The amount of currency needed per unit threshold when creating a multisig execution.
*
* This is held for adding 32 bytes more into a pre-existing storage value.
**/
depositFactor: BalanceOf & AugmentedConst<ApiType>;
/**
* The maximum amount of signatories allowed for a given multisig.
* The maximum amount of signatories allowed in the multisig.
**/
maxSignatories: u16 & AugmentedConst<ApiType>;
/**
@@ -400,7 +409,7 @@ declare module '@polkadot/api/types/consts' {
/**
* The maximum amount of proxies allowed for a single account.
**/
maxProxies: u16 & AugmentedConst<ApiType>;
maxProxies: u32 & AugmentedConst<ApiType>;
/**
* The base amount of currency needed to reserve for creating a proxy.
*
@@ -499,9 +508,6 @@ declare module '@polkadot/api/types/consts' {
* Number of eras that staked funds must remain bonded for.
**/
bondingDuration: EraIndex & AugmentedConst<ApiType>;
/**
* Maximum number of nominations per nominator.
**/
maxNominations: u32 & AugmentedConst<ApiType>;
/**
* The maximum number of nominators rewarded for each validator.
@@ -517,9 +523,8 @@ declare module '@polkadot/api/types/consts' {
/**
* Number of eras that slashes are deferred by, after computation.
*
* This should be less than the bonding duration.
* Set to 0 if slashes should be applied immediately, without opportunity for
* intervention.
* This should be less than the bonding duration. Set to 0 if slashes
* should be applied immediately, without opportunity for intervention.
**/
slashDeferDuration: EraIndex & AugmentedConst<ApiType>;
/**
@@ -551,7 +556,7 @@ declare module '@polkadot/api/types/consts' {
* that the runtime should know about the prefix in order to make use of it as
* an identifier of the chain.
**/
ss58Prefix: u8 & AugmentedConst<ApiType>;
ss58Prefix: u16 & AugmentedConst<ApiType>;
/**
* Get the chain's current version.
**/
+156 -12
View File
@@ -136,6 +136,10 @@ declare module '@polkadot/api/types/errors' {
* Account liquidity restrictions prevent withdrawal
**/
LiquidityRestrictions: AugmentedError<ApiType>;
/**
* Number of named reserves exceed MaxReserves
**/
TooManyReserves: AugmentedError<ApiType>;
/**
* Vesting balance too high to send value
**/
@@ -205,6 +209,13 @@ declare module '@polkadot/api/types/errors' {
* current schedule.
**/
CodeTooLarge: AugmentedError<ApiType>;
/**
* A tombstone exist at the specified address.
*
* Tombstone cannot be called. Anyone can use `seal_restore_to` in order to revive
* the contract, though.
**/
ContractIsTombstone: AugmentedError<ApiType>;
/**
* A contract could not be evicted because it has enough balance to pay rent.
*
@@ -212,6 +223,10 @@ declare module '@polkadot/api/types/errors' {
* contract has enough balance to pay for its rent.
**/
ContractNotEvictable: AugmentedError<ApiType>;
/**
* No contract was found at the specified address.
**/
ContractNotFound: AugmentedError<ApiType>;
/**
* Contract trapped during execution.
**/
@@ -241,9 +256,9 @@ declare module '@polkadot/api/types/errors' {
**/
DuplicateTopics: AugmentedError<ApiType>;
/**
* `seal_input` was called twice from the same contract execution context.
* `seal_call` forwarded this contracts input. It therefore is no longer available.
**/
InputAlreadyRead: AugmentedError<ApiType>;
InputForwarded: AugmentedError<ApiType>;
/**
* An origin TrieId written in the current block.
**/
@@ -284,11 +299,6 @@ declare module '@polkadot/api/types/errors' {
* is rejected.
**/
NoChainExtension: AugmentedError<ApiType>;
/**
* The contract that was called is either no contract at all (a plain account)
* or is a tombstone.
**/
NotCallable: AugmentedError<ApiType>;
/**
* A buffer outside of sandbox memory was passed to a contract API function.
**/
@@ -306,11 +316,18 @@ declare module '@polkadot/api/types/errors' {
**/
RandomSubjectTooLong: AugmentedError<ApiType>;
/**
* The action performed is not allowed while the contract performing it is already
* on the call stack. Those actions are contract self destruction and restoration
* of a tombstone.
* A call tried to invoke a contract that is flagged as non-reentrant.
**/
ReentranceDenied: AugmentedError<ApiType>;
/**
* The called contract does not have enough balance to pay for its storage.
*
* The contract ran out of balance and is therefore eligible for eviction into a
* tombstone. Anyone can evict the contract by submitting a `claim_surcharge`
* extrinsic. Alternatively, a plain balance transfer can be used in order to
* increase the contracts funds so that it can be called again.
**/
RentNotPaid: AugmentedError<ApiType>;
/**
* A storage modification exhausted the 32bit type that holds the storage size.
*
@@ -324,6 +341,11 @@ declare module '@polkadot/api/types/errors' {
* This can be triggered by a call to `seal_terminate` or `seal_restore_to`.
**/
TerminatedInConstructor: AugmentedError<ApiType>;
/**
* Termination of a contract is not allowed while the contract is already
* on the call stack. Can be triggered by `seal_terminate` or `seal_restore_to.
**/
TerminatedWhileReentrant: AugmentedError<ApiType>;
/**
* The amount of topics passed to `seal_deposit_events` exceeds the limit.
**/
@@ -529,6 +551,10 @@ declare module '@polkadot/api/types/errors' {
[key: string]: AugmentedError<ApiType>;
};
electionProviderMultiPhase: {
/**
* The call is not allowed at this point.
**/
CallNotAllowed: AugmentedError<ApiType>;
/**
* OCW submitted solution for wrong round
**/
@@ -1160,6 +1186,10 @@ declare module '@polkadot/api/types/errors' {
* A nomination target was supplied that was blocked or otherwise not a validator.
**/
BadTarget: AugmentedError<ApiType>;
/**
* The user has enough bond and thus cannot be chilled forcefully by an external person.
**/
CannotChillOther: AugmentedError<ApiType>;
/**
* Duplicate index.
**/
@@ -1181,9 +1211,9 @@ declare module '@polkadot/api/types/errors' {
**/
IncorrectSlashingSpans: AugmentedError<ApiType>;
/**
* Can not bond with value less than minimum balance.
* Can not bond with value less than minimum required.
**/
InsufficientValue: AugmentedError<ApiType>;
InsufficientBond: AugmentedError<ApiType>;
/**
* Invalid era to reward.
**/
@@ -1216,10 +1246,20 @@ declare module '@polkadot/api/types/errors' {
* Can not rebond without unlocking chunks.
**/
NoUnlockChunk: AugmentedError<ApiType>;
/**
* There are too many nominators in the system. Governance needs to adjust the staking settings
* to keep things safe for the runtime.
**/
TooManyNominators: AugmentedError<ApiType>;
/**
* Too many nomination targets supplied.
**/
TooManyTargets: AugmentedError<ApiType>;
/**
* There are too many validators in the system. Governance needs to adjust the staking settings
* to keep things safe for the runtime.
**/
TooManyValidators: AugmentedError<ApiType>;
/**
* Generic error
**/
@@ -1355,6 +1395,64 @@ declare module '@polkadot/api/types/errors' {
**/
[key: string]: AugmentedError<ApiType>;
};
transactionStorage: {
/**
* Attempted to call `store` outside of block execution.
**/
BadContext: AugmentedError<ApiType>;
/**
* Double proof check in the block.
**/
DoubleCheck: AugmentedError<ApiType>;
/**
* Attempting to store empty transaction
**/
EmptyTransaction: AugmentedError<ApiType>;
/**
* Insufficient account balance.
**/
InsufficientFunds: AugmentedError<ApiType>;
/**
* Proof failed verification.
**/
InvalidProof: AugmentedError<ApiType>;
/**
* Missing storage proof.
**/
MissingProof: AugmentedError<ApiType>;
/**
* Unable to verify proof becasue state data is missing.
**/
MissingStateData: AugmentedError<ApiType>;
/**
* Invalid configuration.
**/
NotConfigured: AugmentedError<ApiType>;
/**
* Storage proof was not checked in the block.
**/
ProofNotChecked: AugmentedError<ApiType>;
/**
* Renewed extrinsic is not found.
**/
RenewedNotFound: AugmentedError<ApiType>;
/**
* Too many transactions in the block.
**/
TooManyTransactions: AugmentedError<ApiType>;
/**
* Transaction is too large.
**/
TransactionTooLarge: AugmentedError<ApiType>;
/**
* Proof was not expected in this block.
**/
UnexpectedProof: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
treasury: {
/**
* Proposer's balance is too low.
@@ -1373,6 +1471,52 @@ declare module '@polkadot/api/types/errors' {
**/
[key: string]: AugmentedError<ApiType>;
};
uniques: {
/**
* The asset instance ID has already been used for an asset.
**/
AlreadyExists: AugmentedError<ApiType>;
/**
* Invalid witness data given.
**/
BadWitness: AugmentedError<ApiType>;
/**
* The asset instance or class is frozen.
**/
Frozen: AugmentedError<ApiType>;
/**
* The asset ID is already taken.
**/
InUse: AugmentedError<ApiType>;
/**
* There is no delegate approved.
**/
NoDelegate: AugmentedError<ApiType>;
/**
* The signing account has no permission to do the operation.
**/
NoPermission: AugmentedError<ApiType>;
/**
* No approval exists that would allow the transfer.
**/
Unapproved: AugmentedError<ApiType>;
/**
* The given asset ID is unknown.
**/
Unknown: AugmentedError<ApiType>;
/**
* The delegate turned out to be different to what was expected.
**/
WrongDelegate: AugmentedError<ApiType>;
/**
* The owner turned out to be different to what was expected.
**/
WrongOwner: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
vesting: {
/**
* Amount being transferred is too low to create a vesting schedule.
+125
View File
@@ -21,6 +21,7 @@ import type { IdentificationTuple, SessionIndex } from '@polkadot/types/interfac
import type { ElectionCompute, EraIndex } from '@polkadot/types/interfaces/staking';
import type { DispatchError, DispatchInfo, DispatchResult } from '@polkadot/types/interfaces/system';
import type { BountyIndex } from '@polkadot/types/interfaces/treasury';
import type { ClassId, InstanceId } from '@polkadot/types/interfaces/uniques';
import type { Timepoint } from '@polkadot/types/interfaces/utility';
import type { ApiTypes } from '@polkadot/api/types';
@@ -834,6 +835,10 @@ declare module '@polkadot/api/types/events' {
* A new set of stakers was elected.
**/
StakingElection: AugmentedEvent<ApiType, []>;
/**
* The election failed. No new era is planned.
**/
StakingElectionFailed: AugmentedEvent<ApiType, []>;
/**
* An account has unbonded this amount. \[stash, amount\]
**/
@@ -995,6 +1000,24 @@ declare module '@polkadot/api/types/events' {
**/
[key: string]: AugmentedEvent<ApiType>;
};
transactionStorage: {
/**
* Storage proof was successfully checked.
**/
ProofChecked: AugmentedEvent<ApiType, []>;
/**
* Renewed data under specified index.
**/
Renewed: AugmentedEvent<ApiType, [u32]>;
/**
* Stored data under specified index.
**/
Stored: AugmentedEvent<ApiType, [u32]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
treasury: {
/**
* Some funds have been allocated. \[proposal_index, award, beneficiary\]
@@ -1030,6 +1053,108 @@ declare module '@polkadot/api/types/events' {
**/
[key: string]: AugmentedEvent<ApiType>;
};
uniques: {
/**
* An approval for a `delegate` account to transfer the `instance` of an asset `class` was
* cancelled by its `owner`.
* \[ class, instance, owner, delegate \]
**/
ApprovalCancelled: AugmentedEvent<ApiType, [ClassId, InstanceId, AccountId, AccountId]>;
/**
* An `instance` of an asset `class` has been approved by the `owner` for transfer by a
* `delegate`.
* \[ class, instance, owner, delegate \]
**/
ApprovedTransfer: AugmentedEvent<ApiType, [ClassId, InstanceId, AccountId, AccountId]>;
/**
* An asset `class` has had its attributes changed by the `Force` origin.
* \[ class \]
**/
AssetStatusChanged: AugmentedEvent<ApiType, [ClassId]>;
/**
* Attribute metadata has been cleared for an asset class or instance.
* \[ class, maybe_instance, key, maybe_value \]
**/
AttributeCleared: AugmentedEvent<ApiType, [ClassId, Option<InstanceId>, Bytes]>;
/**
* New attribute metadata has been set for an asset class or instance.
* \[ class, maybe_instance, key, value \]
**/
AttributeSet: AugmentedEvent<ApiType, [ClassId, Option<InstanceId>, Bytes, Bytes]>;
/**
* An asset `instance` was destroyed. \[ class, instance, owner \]
**/
Burned: AugmentedEvent<ApiType, [ClassId, InstanceId, AccountId]>;
/**
* Some asset `class` was frozen. \[ class \]
**/
ClassFrozen: AugmentedEvent<ApiType, [ClassId]>;
/**
* Metadata has been cleared for an asset class. \[ class \]
**/
ClassMetadataCleared: AugmentedEvent<ApiType, [ClassId]>;
/**
* New metadata has been set for an asset class. \[ class, data, is_frozen \]
**/
ClassMetadataSet: AugmentedEvent<ApiType, [ClassId, Bytes, bool]>;
/**
* Some asset `class` was thawed. \[ class \]
**/
ClassThawed: AugmentedEvent<ApiType, [ClassId]>;
/**
* An asset class was created. \[ class, creator, owner \]
**/
Created: AugmentedEvent<ApiType, [ClassId, AccountId, AccountId]>;
/**
* An asset `class` was destroyed. \[ class \]
**/
Destroyed: AugmentedEvent<ApiType, [ClassId]>;
/**
* An asset class was force-created. \[ class, owner \]
**/
ForceCreated: AugmentedEvent<ApiType, [ClassId, AccountId]>;
/**
* Some asset `instance` was frozen. \[ class, instance \]
**/
Frozen: AugmentedEvent<ApiType, [ClassId, InstanceId]>;
/**
* An asset `instace` was issued. \[ class, instance, owner \]
**/
Issued: AugmentedEvent<ApiType, [ClassId, InstanceId, AccountId]>;
/**
* Metadata has been cleared for an asset instance. \[ class, instance \]
**/
MetadataCleared: AugmentedEvent<ApiType, [ClassId, InstanceId]>;
/**
* New metadata has been set for an asset instance.
* \[ class, instance, data, is_frozen \]
**/
MetadataSet: AugmentedEvent<ApiType, [ClassId, InstanceId, Bytes, bool]>;
/**
* The owner changed \[ class, new_owner \]
**/
OwnerChanged: AugmentedEvent<ApiType, [ClassId, AccountId]>;
/**
* Metadata has been cleared for an asset instance. \[ class, successful_instances \]
**/
Redeposited: AugmentedEvent<ApiType, [ClassId, Vec<InstanceId>]>;
/**
* The management team changed \[ class, issuer, admin, freezer \]
**/
TeamChanged: AugmentedEvent<ApiType, [ClassId, AccountId, AccountId, AccountId]>;
/**
* Some asset `instance` was thawed. \[ class, instance \]
**/
Thawed: AugmentedEvent<ApiType, [ClassId, InstanceId]>;
/**
* An asset `instace` was transferred. \[ class, instance, from, to \]
**/
Transferred: AugmentedEvent<ApiType, [ClassId, InstanceId, AccountId, AccountId]>;
/**
* Generic event
**/
[key: string]: AugmentedEvent<ApiType>;
};
utility: {
/**
* Batch of dispatches completed fully with no error.
+118 -3
View File
@@ -6,7 +6,7 @@ import type { AnyNumber, ITuple, Observable } from '@polkadot/types/types';
import type { AssetApproval, AssetBalance, AssetDetails, AssetMetadata } from '@polkadot/types/interfaces/assets';
import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
import type { BabeAuthorityWeight, BabeEpochConfiguration, MaybeRandomness, NextConfigDescriptor, Randomness } from '@polkadot/types/interfaces/babe';
import type { AccountData, BalanceLock } from '@polkadot/types/interfaces/balances';
import type { AccountData, BalanceLock, ReserveData } from '@polkadot/types/interfaces/balances';
import type { ProposalIndex, Votes } from '@polkadot/types/interfaces/collective';
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
import type { CodeHash, ContractInfo, DeletedContract, PrefabWasmModule } from '@polkadot/types/interfaces/contracts';
@@ -20,14 +20,15 @@ import type { CallIndex, LotteryConfig } from '@polkadot/types/interfaces/lotter
import type { Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
import type { ProxyAnnouncement, ProxyDefinition } from '@polkadot/types/interfaces/proxy';
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, Releases, Slot, ValidatorId } from '@polkadot/types/interfaces/runtime';
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, Releases, Slot, TransactionInfo, ValidatorId } from '@polkadot/types/interfaces/runtime';
import type { Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
import type { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
import type { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
import type { ActiveEraInfo, ElectionPhase, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, ReadySolution, RewardDestination, RoundSnapshot, SeatHolder, SlashingSpans, SolutionOrSnapshotSize, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs, Voter } from '@polkadot/types/interfaces/staking';
import type { ActiveEraInfo, ElectionPhase, ElectionScore, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, ReadySolution, RewardDestination, RoundSnapshot, SeatHolder, SlashingSpans, SolutionOrSnapshotSize, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs, Voter } from '@polkadot/types/interfaces/staking';
import type { AccountInfo, ConsumedWeight, DigestOf, EventIndex, EventRecord, LastRuntimeUpgradeInfo, Phase } from '@polkadot/types/interfaces/system';
import type { Bounty, BountyIndex, OpenTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
import type { ClassDetails, ClassId, ClassMetadata, DepositBalanceOf, InstanceDetails, InstanceId, InstanceMetadata } from '@polkadot/types/interfaces/uniques';
import type { Multisig } from '@polkadot/types/interfaces/utility';
import type { VestingInfo } from '@polkadot/types/interfaces/vesting';
import type { ApiTypes } from '@polkadot/api/types';
@@ -188,6 +189,10 @@ declare module '@polkadot/api/types/storage' {
* NOTE: Should only be accessed when setting, changing and freeing a lock.
**/
locks: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Vec<BalanceLock>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Named reserves on some account balances.
**/
reserves: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Vec<ReserveData>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* Storage version of the pallet.
*
@@ -378,6 +383,13 @@ declare module '@polkadot/api/types/storage' {
* Only exists when [`Snapshot`] is present.
**/
desiredTargets: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The minimum score that each 'untrusted' solution must attain in order to be considered
* feasible.
*
* Can be set via `set_minimum_untrusted_score`.
**/
minimumUntrustedScore: AugmentedQuery<ApiType, () => Observable<Option<ElectionScore>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Current best solution, signed or unsigned, queued to be returned upon `elect`.
**/
@@ -871,6 +883,14 @@ declare module '@polkadot/api/types/storage' {
* canceled by extraordinary circumstances (e.g. governance).
**/
canceledSlashPayout: AugmentedQuery<ApiType, () => Observable<BalanceOf>, []> & QueryableStorageEntry<ApiType, []>;
/**
* A tracker to keep count of the number of items in the `Nominators` map.
**/
counterForNominators: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
* A tracker to keep count of the number of items in the `Validators` map.
**/
counterForValidators: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The current era index.
*
@@ -966,12 +986,34 @@ declare module '@polkadot/api/types/storage' {
* Map from all (unlocked) "controller" accounts to the info regarding the staking.
**/
ledger: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<StakingLedger>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* The maximum nominator count before we stop allowing new validators to join.
*
* When this value is not set, no limits are enforced.
**/
maxNominatorsCount: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The maximum validator count before we stop allowing new validators to join.
*
* When this value is not set, no limits are enforced.
**/
maxValidatorsCount: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Minimum number of staking participants before emergency conditions are imposed.
**/
minimumValidatorCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The minimum active bond to become and maintain the role of a nominator.
**/
minNominatorBond: AugmentedQuery<ApiType, () => Observable<BalanceOf>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The minimum active bond to become and maintain the role of a validator.
**/
minValidatorBond: AugmentedQuery<ApiType, () => Observable<BalanceOf>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The map from nominator stash key to the set of stash keys of all validators to nominate.
*
* When updating this storage item, you must also update the `CounterForNominators`.
**/
nominators: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<Nominations>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
@@ -1014,6 +1056,8 @@ declare module '@polkadot/api/types/storage' {
validatorCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The map from (wannabe) validator stash key to the preferences of that validator.
*
* When updating this storage item, you must also update the `CounterForValidators`.
**/
validators: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ValidatorPrefs>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
@@ -1199,6 +1243,46 @@ declare module '@polkadot/api/types/storage' {
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
transactionStorage: {
blockTransactions: AugmentedQuery<ApiType, () => Observable<Vec<TransactionInfo>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Storage fee per byte.
**/
byteFee: AugmentedQuery<ApiType, () => Observable<Option<BalanceOf>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Count indexed chunks for each block.
**/
chunkCount: AugmentedQuery<ApiType, (arg: BlockNumber | AnyNumber | Uint8Array) => Observable<u32>, [BlockNumber]> & QueryableStorageEntry<ApiType, [BlockNumber]>;
/**
* Storage fee per transaction.
**/
entryFee: AugmentedQuery<ApiType, () => Observable<Option<BalanceOf>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Maximum number of indexed transactions in the block.
**/
maxBlockTransactions: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Maximum data set in a single transaction in bytes.
**/
maxTransactionSize: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Was the proof checked in this block?
**/
proofChecked: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Storage period for data in blocks. Should match `sp_storage_proof::DEFAULT_STORAGE_PERIOD`
* for block authoring.
**/
storagePeriod: AugmentedQuery<ApiType, () => Observable<BlockNumber>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Collection of transaction metadata by block number.
**/
transactions: AugmentedQuery<ApiType, (arg: BlockNumber | AnyNumber | Uint8Array) => Observable<Option<Vec<TransactionInfo>>>, [BlockNumber]> & QueryableStorageEntry<ApiType, [BlockNumber]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
treasury: {
/**
* Proposal indices that have been approved but not yet awarded.
@@ -1217,6 +1301,37 @@ declare module '@polkadot/api/types/storage' {
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
uniques: {
/**
* The assets held by any given account; set out this way so that assets owned by a single
* account can be enumerated.
**/
account: AugmentedQuery<ApiType, (arg1: AccountId | string | Uint8Array, arg2: ClassId | AnyNumber | Uint8Array, arg3: InstanceId | AnyNumber | Uint8Array) => Observable<Option<ITuple<[]>>>, [AccountId, ClassId, InstanceId]> & QueryableStorageEntry<ApiType, [AccountId, ClassId, InstanceId]>;
/**
* The assets in existence and their ownership details.
**/
asset: AugmentedQuery<ApiType, (arg1: ClassId | AnyNumber | Uint8Array, arg2: InstanceId | AnyNumber | Uint8Array) => Observable<Option<InstanceDetails>>, [ClassId, InstanceId]> & QueryableStorageEntry<ApiType, [ClassId, InstanceId]>;
/**
* Metadata of an asset class.
**/
attribute: AugmentedQuery<ApiType, (arg1: ClassId | AnyNumber | Uint8Array, arg2: Option<InstanceId> | null | object | string | Uint8Array, arg3: Bytes | string | Uint8Array) => Observable<Option<ITuple<[Bytes, DepositBalanceOf]>>>, [ClassId, Option<InstanceId>, Bytes]> & QueryableStorageEntry<ApiType, [ClassId, Option<InstanceId>, Bytes]>;
/**
* Details of an asset class.
**/
class: AugmentedQuery<ApiType, (arg: ClassId | AnyNumber | Uint8Array) => Observable<Option<ClassDetails>>, [ClassId]> & QueryableStorageEntry<ApiType, [ClassId]>;
/**
* Metadata of an asset class.
**/
classMetadataOf: AugmentedQuery<ApiType, (arg: ClassId | AnyNumber | Uint8Array) => Observable<Option<ClassMetadata>>, [ClassId]> & QueryableStorageEntry<ApiType, [ClassId]>;
/**
* Metadata of an asset instance.
**/
instanceMetadataOf: AugmentedQuery<ApiType, (arg1: ClassId | AnyNumber | Uint8Array, arg2: InstanceId | AnyNumber | Uint8Array) => Observable<Option<InstanceMetadata>>, [ClassId, InstanceId]> & QueryableStorageEntry<ApiType, [ClassId, InstanceId]>;
/**
* Generic query
**/
[key: string]: QueryableStorageEntry<ApiType>;
};
vesting: {
/**
* Information regarding the vesting of a given account.
+5 -1
View File
@@ -106,6 +106,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Returns the keys with prefix from a child storage, leave empty to get all the keys
**/
getKeys: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, prefix: StorageKey | string | Uint8Array | any, at?: Hash | string | Uint8Array) => Observable<Vec<StorageKey>>>;
/**
* Returns the keys with prefix from a child storage with pagination support
**/
getKeysPaged: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, prefix: StorageKey | string | Uint8Array | any, count: u32 | AnyNumber | Uint8Array, startKey?: StorageKey | string | Uint8Array | any, at?: Hash | string | Uint8Array) => Observable<Vec<StorageKey>>>;
/**
* Returns a child storage entry at a specific block state
**/
@@ -153,7 +157,7 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
**/
accounts: AugmentedRpc<() => Observable<Vec<H160>>>;
/**
* Returns balance of the given account.
* Returns the blockNumber
**/
blockNumber: AugmentedRpc<() => Observable<U256>>;
/**
+517 -15
View File
@@ -15,13 +15,14 @@ import type { GrandpaEquivocationProof, KeyOwnerProof } from '@polkadot/types/in
import type { IdentityFields, IdentityInfo, IdentityJudgement, RegistrarIndex } from '@polkadot/types/interfaces/identity';
import type { Heartbeat } from '@polkadot/types/interfaces/imOnline';
import type { ProxyType } from '@polkadot/types/interfaces/proxy';
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, Call, CallHashOf, ChangesTrieConfiguration, Hash, Header, KeyValue, LookupSource, Moment, OpaqueCall, Perbill, Percent, Perquintill, Weight } from '@polkadot/types/interfaces/runtime';
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, Call, CallHashOf, ChangesTrieConfiguration, Hash, Header, KeyValue, LookupSource, Moment, OpaqueCall, Perbill, Percent, Perquintill, TransactionStorageProof, Weight } from '@polkadot/types/interfaces/runtime';
import type { Period, Priority } from '@polkadot/types/interfaces/scheduler';
import type { Keys } from '@polkadot/types/interfaces/session';
import type { SocietyJudgement } from '@polkadot/types/interfaces/society';
import type { EraIndex, RawSolution, RewardDestination, SolutionOrSnapshotSize, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
import type { ElectionScore, EraIndex, RawSolution, ReadySolution, RewardDestination, SolutionOrSnapshotSize, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
import type { Key } from '@polkadot/types/interfaces/system';
import type { BountyIndex } from '@polkadot/types/interfaces/treasury';
import type { ClassId, DestroyWitness, InstanceId } from '@polkadot/types/interfaces/uniques';
import type { Timepoint } from '@polkadot/types/interfaces/utility';
import type { VestingInfo } from '@polkadot/types/interfaces/vesting';
import type { ApiTypes, SubmittableExtrinsic } from '@polkadot/api/types';
@@ -133,6 +134,10 @@ declare module '@polkadot/api/types/submittable' {
*
* Emits `Destroyed` event when successful.
*
* NOTE: It can be helpful to first freeze an asset before destroying it so that you
* can provide accurate witness information and prevent users from manipulating state
* in a way that can make it harder to destroy.
*
* Weight: `O(c + p + a)` where:
* - `c = (witness.accounts - witness.sufficients)`
* - `s = witness.sufficients`
@@ -208,8 +213,6 @@ declare module '@polkadot/api/types/submittable' {
* - `owner`: The owner of this class of assets. The owner has full superuser permissions
* over this asset, but may later change and configure the permissions using `transfer_ownership`
* and `set_team`.
* - `max_zombies`: The total number of accounts which may hold assets in this class yet
* have no existential deposit.
* - `min_balance`: The minimum balance of this new asset that any single account must
* have. If an account's balance is reduced below this, then it collapses to zero.
*
@@ -253,8 +256,8 @@ declare module '@polkadot/api/types/submittable' {
* to zero.
*
* Weight: `O(1)`
* Modes: Pre-existence of `dest`; Post-existence of `source`; Prior & post zombie-status
* of `source`; Account pre-existence of `dest`.
* Modes: Pre-existence of `dest`; Post-existence of `source`; Account pre-existence of
* `dest`.
**/
forceTransfer: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, source: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, LookupSource, Compact<TAssetBalance>]>;
/**
@@ -291,7 +294,7 @@ declare module '@polkadot/api/types/submittable' {
* - `beneficiary`: The account to be credited with the minted assets.
* - `amount`: The amount of the asset to be minted.
*
* Emits `Destroyed` event when successful.
* Emits `Issued` event when successful.
*
* Weight: `O(1)`
* Modes: Pre-existing balance of `beneficiary`; Account pre-existence of `beneficiary`.
@@ -349,7 +352,7 @@ declare module '@polkadot/api/types/submittable' {
*
* Origin must be Signed and the sender should be the Admin of the asset `id`.
*
* - `id`: The identifier of the asset to be frozen.
* - `id`: The identifier of the asset to be thawed.
*
* Emits `Thawed`.
*
@@ -373,8 +376,8 @@ declare module '@polkadot/api/types/submittable' {
* to zero.
*
* Weight: `O(1)`
* Modes: Pre-existence of `target`; Post-existence of sender; Prior & post zombie-status
* of sender; Account pre-existence of `target`.
* Modes: Pre-existence of `target`; Post-existence of sender; Account pre-existence of
* `target`.
**/
transfer: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<TAssetBalance>]>;
/**
@@ -415,8 +418,8 @@ declare module '@polkadot/api/types/submittable' {
* to zero.
*
* Weight: `O(1)`
* Modes: Pre-existence of `target`; Post-existence of sender; Prior & post zombie-status
* of sender; Account pre-existence of `target`.
* Modes: Pre-existence of `target`; Post-existence of sender; Account pre-existence of
* `target`.
**/
transferKeepAlive: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<TAssetBalance>]>;
/**
@@ -539,6 +542,27 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
transfer: AugmentedSubmittable<(dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<Balance>]>;
/**
* Transfer the entire transferable balance from the caller account.
*
* NOTE: This function only attempts to transfer _transferable_ balances. This means that
* any locked, reserved, or existential deposits (when `keep_alive` is `true`), will not be
* transferred by this function. To ensure that this function results in a killed account,
* you might need to prepare the account by removing any reference counters, storage
* deposits, etc...
*
* The dispatch origin of this call must be Signed.
*
* - `dest`: The recipient of the transfer.
* - `keep_alive`: A boolean to determine if the `transfer_all` operation should send all
* of the funds the account has, causing the sender account to be killed (false), or
* transfer everything except at least the existential deposit, which will guarantee to
* keep the sender account alive (true).
* # <weight>
* - O(1). Just like transfer, but reading the user's transferable balance first.
* #</weight>
**/
transferAll: AugmentedSubmittable<(dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, keepAlive: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, bool]>;
/**
* Same as the [`transfer`] call, but with a check that the transfer will not kill the
* origin account.
@@ -699,7 +723,7 @@ declare module '@polkadot/api/types/submittable' {
* producer fails to do so, a regular users will be allowed to claim the reward.
*
* In case of a successful eviction no fees are charged from the sender. However, the
* reward is capped by the total amount of rent that was payed by the contract while
* reward is capped by the total amount of rent that was paid by the contract while
* it was alive.
*
* If contract is not evicted as a result of this call, [`Error::ContractNotEvictable`]
@@ -1222,6 +1246,25 @@ declare module '@polkadot/api/types/submittable' {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
electionProviderMultiPhase: {
/**
* Set a solution in the queue, to be handed out to the client of this pallet in the next
* call to `ElectionProvider::elect`.
*
* This can only be set by `T::ForceOrigin`, and only when the phase is `Emergency`.
*
* The solution is not checked for any feasibility and is assumed to be trustworthy, as any
* feasibility check itself can in principle cause the election process to fail (due to
* memory/weight constrains).
**/
setEmergencyElectionResult: AugmentedSubmittable<(solution: ReadySolution | { supports?: any; score?: any; compute?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [ReadySolution]>;
/**
* Set a new value for `MinimumUntrustedScore`.
*
* Dispatch origin must be aligned with `T::ForceOrigin`.
*
* This check can be turned off by setting the value to `None`.
**/
setMinimumUntrustedScore: AugmentedSubmittable<(maybeNextScore: Option<ElectionScore> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Option<ElectionScore>]>;
/**
* Submit a solution for the unsigned phase.
*
@@ -2518,7 +2561,7 @@ declare module '@polkadot/api/types/submittable' {
* Actual cost depends on the number of length of `T::Keys::key_ids()` which is fixed.
* - DbReads: `T::ValidatorIdOf`, `NextKeys`, `origin account`
* - DbWrites: `NextKeys`, `origin account`
* - DbWrites per key id: `KeyOwnder`
* - DbWrites per key id: `KeyOwner`
* # </weight>
**/
purgeKeys: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
@@ -2538,7 +2581,7 @@ declare module '@polkadot/api/types/submittable' {
* - DbWrites per key id: `KeyOwner`
* # </weight>
**/
setKeys: AugmentedSubmittable<(keys: Keys, proof: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Keys, Bytes]>;
setKeys: AugmentedSubmittable<(keys: Keys | string | Uint8Array, proof: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Keys, Bytes]>;
/**
* Generic tx
**/
@@ -2953,12 +2996,34 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
chill: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
/**
* Declare a `controller` as having no desire to either validator or nominate.
*
* Effects will be felt at the beginning of the next era.
*
* The dispatch origin for this call must be _Signed_, but can be called by anyone.
*
* If the caller is the same as the controller being targeted, then no further checks
* are enforced. However, this call can also be made by an third party user who witnesses
* that this controller does not satisfy the minimum bond requirements to be in their role.
*
* This can be helpful if bond requirements are updated, and we need to remove old users
* who do not satisfy these requirements.
*
**/
chillOther: AugmentedSubmittable<(controller: AccountId | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId]>;
/**
* Force there to be a new era at the end of the next session. After this, it will be
* reset to normal (non-forced) behaviour.
*
* The dispatch origin must be Root.
*
* # Warning
*
* The election process starts multiple blocks before the end of the era.
* If this is called just before a new era is triggered, the election process may not
* have enough blocks to get a result.
*
* # <weight>
* - No arguments.
* - Weight: O(1)
@@ -2971,6 +3036,12 @@ declare module '@polkadot/api/types/submittable' {
*
* The dispatch origin must be Root.
*
* # Warning
*
* The election process starts multiple blocks before the end of the era.
* If this is called just before a new era is triggered, the election process may not
* have enough blocks to get a result.
*
* # <weight>
* - Weight: O(1)
* - Write: ForceEra
@@ -2982,6 +3053,12 @@ declare module '@polkadot/api/types/submittable' {
*
* The dispatch origin must be Root.
*
* # Warning
*
* The election process starts multiple blocks before the end of the era.
* Thus the election process may be ongoing when this is called. In this case the
* election will continue until the next era is triggered.
*
* # <weight>
* - No arguments.
* - Weight: O(1)
@@ -3222,6 +3299,9 @@ declare module '@polkadot/api/types/submittable' {
* can co-exists at the same time. In that case, [`Call::withdraw_unbonded`] need
* to be called first to remove some of the chunks (if possible).
*
* If a user encounters the `InsufficientBond` error when calling this extrinsic,
* they should call `chill` first in order to free up their bonded funds.
*
* The dispatch origin for this call must be _Signed_ by the controller, not the stash.
* And, it can be only called when [`EraElectionStatus`] is `Closed`.
*
@@ -3245,6 +3325,22 @@ declare module '@polkadot/api/types/submittable' {
* </weight>
**/
unbond: AugmentedSubmittable<(value: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BalanceOf>]>;
/**
* Update the various staking limits this pallet.
*
* * `min_nominator_bond`: The minimum active bond needed to be a nominator.
* * `min_validator_bond`: The minimum active bond needed to be a validator.
* * `max_nominator_count`: The max number of users who can be a nominator at once.
* When set to `None`, no limit is enforced.
* * `max_validator_count`: The max number of users who can be a validator at once.
* When set to `None`, no limit is enforced.
*
* Origin must be Root to call this function.
*
* NOTE: Existing nominators and validators will not be affected by this update.
* to kick people under the new limits, `chill_other` should be called.
**/
updateStakingLimits: AugmentedSubmittable<(minNominatorBond: BalanceOf | AnyNumber | Uint8Array, minValidatorBond: BalanceOf | AnyNumber | Uint8Array, maxNominatorCount: Option<u32> | null | object | string | Uint8Array, maxValidatorCount: Option<u32> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [BalanceOf, BalanceOf, Option<u32>, Option<u32>]>;
/**
* Declare the desire to validate for the origin controller.
*
@@ -3830,6 +3926,41 @@ declare module '@polkadot/api/types/submittable' {
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
transactionStorage: {
/**
* Check storage proof for block number `block_number() - StoragePeriod`.
* If such block does not exist the proof is expected to be `None`.
* # <weight>
* - Linear w.r.t the number of indexed transactions in the proved block for random probing.
* There's a DB read for each transaction.
* Here we assume a maximum of 100 probed transactions.
* # </weight>
**/
checkProof: AugmentedSubmittable<(proof: TransactionStorageProof | { chunk?: any; proof?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [TransactionStorageProof]>;
/**
* Renew previously stored data. Parameters are the block number that contains
* previous `store` or `renew` call and transaction index within that block.
* Transaction index is emitted in the `Stored` or `Renewed` event.
* Applies same fees as `store`.
* # <weight>
* - Constant.
* # </weight>
**/
renew: AugmentedSubmittable<(block: BlockNumber | AnyNumber | Uint8Array, index: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [BlockNumber, u32]>;
/**
* Index and store data on chain. Minimum data size is 1 bytes, maximum is `MaxTransactionSize`.
* Data will be removed after `STORAGE_PERIOD` blocks, unless `renew` is called.
* # <weight>
* - n*log(n) of data size, as all data is pushed to an in-memory trie.
* Additionally contains a DB write.
* # </weight>
**/
store: AugmentedSubmittable<(data: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
treasury: {
/**
* Approve a proposal. At a later time, the proposal will be allocated to the beneficiary
@@ -3873,6 +4004,377 @@ declare module '@polkadot/api/types/submittable' {
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
uniques: {
/**
* Approve an instance to be transferred by a delegated third-party account.
*
* Origin must be Signed and must be the owner of the asset `instance`.
*
* - `class`: The class of the asset to be approved for delegated transfer.
* - `instance`: The instance of the asset to be approved for delegated transfer.
* - `delegate`: The account to delegate permission to transfer the asset.
*
* Emits `ApprovedTransfer` on success.
*
* Weight: `O(1)`
**/
approveTransfer: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instance: Compact<InstanceId> | AnyNumber | Uint8Array, delegate: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Compact<InstanceId>, LookupSource]>;
/**
* Destroy a single asset instance.
*
* Origin must be Signed and the sender should be the Admin of the asset `class`.
*
* - `class`: The class of the asset to be burned.
* - `instance`: The instance of the asset to be burned.
* - `check_owner`: If `Some` then the operation will fail with `WrongOwner` unless the
* asset is owned by this value.
*
* Emits `Burned` with the actual amount burned.
*
* Weight: `O(1)`
* Modes: `check_owner.is_some()`.
**/
burn: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instance: Compact<InstanceId> | AnyNumber | Uint8Array, checkOwner: Option<LookupSource> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Compact<InstanceId>, Option<LookupSource>]>;
/**
* Cancel the prior approval for the transfer of an asset by a delegate.
*
* Origin must be either:
* - the `Force` origin;
* - `Signed` with the signer being the Admin of the asset `class`;
* - `Signed` with the signer being the Owner of the asset `instance`;
*
* Arguments:
* - `class`: The class of the asset of whose approval will be cancelled.
* - `instance`: The instance of the asset of whose approval will be cancelled.
* - `maybe_check_delegate`: If `Some` will ensure that the given account is the one to
* which permission of transfer is delegated.
*
* Emits `ApprovalCancelled` on success.
*
* Weight: `O(1)`
**/
cancelApproval: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instance: Compact<InstanceId> | AnyNumber | Uint8Array, maybeCheckDelegate: Option<LookupSource> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Compact<InstanceId>, Option<LookupSource>]>;
/**
* Set an attribute for an asset class or instance.
*
* Origin must be either `ForceOrigin` or Signed and the sender should be the Owner of the
* asset `class`.
*
* If the origin is Signed, then funds of signer are reserved according to the formula:
* `MetadataDepositBase + DepositPerByte * (key.len + value.len)` taking into
* account any already reserved funds.
*
* - `class`: The identifier of the asset class whose instance's metadata to set.
* - `instance`: The identifier of the asset instance whose metadata to set.
* - `key`: The key of the attribute.
* - `value`: The value to which to set the attribute.
*
* Emits `AttributeSet`.
*
* Weight: `O(1)`
**/
clearAttribute: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, maybeInstance: Option<InstanceId> | null | object | string | Uint8Array, key: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Option<InstanceId>, Bytes]>;
/**
* Clear the metadata for an asset class.
*
* Origin must be either `ForceOrigin` or `Signed` and the sender should be the Owner of
* the asset `class`.
*
* Any deposit is freed for the asset class owner.
*
* - `class`: The identifier of the asset class whose metadata to clear.
*
* Emits `ClassMetadataCleared`.
*
* Weight: `O(1)`
**/
clearClassMetadata: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>]>;
/**
* Clear the metadata for an asset instance.
*
* Origin must be either `ForceOrigin` or Signed and the sender should be the Owner of the
* asset `instance`.
*
* Any deposit is freed for the asset class owner.
*
* - `class`: The identifier of the asset class whose instance's metadata to clear.
* - `instance`: The identifier of the asset instance whose metadata to clear.
*
* Emits `MetadataCleared`.
*
* Weight: `O(1)`
**/
clearMetadata: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instance: Compact<InstanceId> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Compact<InstanceId>]>;
/**
* Issue a new class of non-fungible assets from a public origin.
*
* This new asset class has no assets initially and its owner is the origin.
*
* The origin must be Signed and the sender must have sufficient funds free.
*
* `AssetDeposit` funds of sender are reserved.
*
* Parameters:
* - `class`: The identifier of the new asset class. This must not be currently in use.
* - `admin`: The admin of this class of assets. The admin is the initial address of each
* member of the asset class's admin team.
*
* Emits `Created` event when successful.
*
* Weight: `O(1)`
**/
create: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, admin: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, LookupSource]>;
/**
* Destroy a class of fungible assets.
*
* The origin must conform to `ForceOrigin` or must be `Signed` and the sender must be the
* owner of the asset `class`.
*
* - `class`: The identifier of the asset class to be destroyed.
* - `witness`: Information on the instances minted in the asset class. This must be
* correct.
*
* Emits `Destroyed` event when successful.
*
* Weight: `O(n + m)` where:
* - `n = witness.instances`
* - `m = witness.instance_metdadatas`
* - `a = witness.attributes`
**/
destroy: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, witness: DestroyWitness | { instances?: any; instanceMetadatas?: any; attributes?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, DestroyWitness]>;
/**
* Alter the attributes of a given asset.
*
* Origin must be `ForceOrigin`.
*
* - `class`: The identifier of the asset.
* - `owner`: The new Owner of this asset.
* - `issuer`: The new Issuer of this asset.
* - `admin`: The new Admin of this asset.
* - `freezer`: The new Freezer of this asset.
* - `free_holding`: Whether a deposit is taken for holding an instance of this asset
* class.
* - `is_frozen`: Whether this asset class is frozen except for permissioned/admin
* instructions.
*
* Emits `AssetStatusChanged` with the identity of the asset.
*
* Weight: `O(1)`
**/
forceAssetStatus: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, owner: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, issuer: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, admin: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, freezer: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, freeHolding: bool | boolean | Uint8Array, isFrozen: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, LookupSource, LookupSource, LookupSource, LookupSource, bool, bool]>;
/**
* Issue a new class of non-fungible assets from a privileged origin.
*
* This new asset class has no assets initially.
*
* The origin must conform to `ForceOrigin`.
*
* Unlike `create`, no funds are reserved.
*
* - `class`: The identifier of the new asset. This must not be currently in use.
* - `owner`: The owner of this class of assets. The owner has full superuser permissions
* over this asset, but may later change and configure the permissions using
* `transfer_ownership` and `set_team`.
*
* Emits `ForceCreated` event when successful.
*
* Weight: `O(1)`
**/
forceCreate: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, owner: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, freeHolding: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, LookupSource, bool]>;
/**
* Disallow further unprivileged transfer of an asset instance.
*
* Origin must be Signed and the sender should be the Freezer of the asset `class`.
*
* - `class`: The class of the asset to be frozen.
* - `instance`: The instance of the asset to be frozen.
*
* Emits `Frozen`.
*
* Weight: `O(1)`
**/
freeze: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instance: Compact<InstanceId> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Compact<InstanceId>]>;
/**
* Disallow further unprivileged transfers for a whole asset class.
*
* Origin must be Signed and the sender should be the Freezer of the asset `class`.
*
* - `class`: The asset class to be frozen.
*
* Emits `ClassFrozen`.
*
* Weight: `O(1)`
**/
freezeClass: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>]>;
/**
* Mint an asset instance of a particular class.
*
* The origin must be Signed and the sender must be the Issuer of the asset `class`.
*
* - `class`: The class of the asset to be minted.
* - `instance`: The instance value of the asset to be minted.
* - `beneficiary`: The initial owner of the minted asset.
*
* Emits `Issued` event when successful.
*
* Weight: `O(1)`
**/
mint: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instance: Compact<InstanceId> | AnyNumber | Uint8Array, owner: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Compact<InstanceId>, LookupSource]>;
/**
* Reevaluate the deposits on some assets.
*
* Origin must be Signed and the sender should be the Owner of the asset `class`.
*
* - `class`: The class of the asset to be frozen.
* - `instances`: The instances of the asset class whose deposits will be reevaluated.
*
* NOTE: This exists as a best-effort function. Any asset instances which are unknown or
* in the case that the owner account does not have reservable funds to pay for a
* deposit increase are ignored. Generally the owner isn't going to call this on instances
* whose existing deposit is less than the refreshed deposit as it would only cost them,
* so it's of little consequence.
*
* It will still return an error in the case that the class is unknown of the signer is
* not permitted to call it.
*
* Weight: `O(instances.len())`
**/
redeposit: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instances: Vec<InstanceId> | (InstanceId | AnyNumber | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Vec<InstanceId>]>;
/**
* Set an attribute for an asset class or instance.
*
* Origin must be either `ForceOrigin` or Signed and the sender should be the Owner of the
* asset `class`.
*
* If the origin is Signed, then funds of signer are reserved according to the formula:
* `MetadataDepositBase + DepositPerByte * (key.len + value.len)` taking into
* account any already reserved funds.
*
* - `class`: The identifier of the asset class whose instance's metadata to set.
* - `maybe_instance`: The identifier of the asset instance whose metadata to set.
* - `key`: The key of the attribute.
* - `value`: The value to which to set the attribute.
*
* Emits `AttributeSet`.
*
* Weight: `O(1)`
**/
setAttribute: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, maybeInstance: Option<InstanceId> | null | object | string | Uint8Array, key: Bytes | string | Uint8Array, value: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Option<InstanceId>, Bytes, Bytes]>;
/**
* Set the metadata for an asset class.
*
* Origin must be either `ForceOrigin` or `Signed` and the sender should be the Owner of
* the asset `class`.
*
* If the origin is `Signed`, then funds of signer are reserved according to the formula:
* `MetadataDepositBase + DepositPerByte * data.len` taking into
* account any already reserved funds.
*
* - `class`: The identifier of the asset whose metadata to update.
* - `data`: The general information of this asset. Limited in length by `StringLimit`.
* - `is_frozen`: Whether the metadata should be frozen against further changes.
*
* Emits `ClassMetadataSet`.
*
* Weight: `O(1)`
**/
setClassMetadata: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array, isFrozen: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Bytes, bool]>;
/**
* Set the metadata for an asset instance.
*
* Origin must be either `ForceOrigin` or Signed and the sender should be the Owner of the
* asset `class`.
*
* If the origin is Signed, then funds of signer are reserved according to the formula:
* `MetadataDepositBase + DepositPerByte * data.len` taking into
* account any already reserved funds.
*
* - `class`: The identifier of the asset class whose instance's metadata to set.
* - `instance`: The identifier of the asset instance whose metadata to set.
* - `data`: The general information of this asset. Limited in length by `StringLimit`.
* - `is_frozen`: Whether the metadata should be frozen against further changes.
*
* Emits `MetadataSet`.
*
* Weight: `O(1)`
**/
setMetadata: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instance: Compact<InstanceId> | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array, isFrozen: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Compact<InstanceId>, Bytes, bool]>;
/**
* Change the Issuer, Admin and Freezer of an asset class.
*
* Origin must be Signed and the sender should be the Owner of the asset `class`.
*
* - `class`: The asset class whose team should be changed.
* - `issuer`: The new Issuer of this asset class.
* - `admin`: The new Admin of this asset class.
* - `freezer`: The new Freezer of this asset class.
*
* Emits `TeamChanged`.
*
* Weight: `O(1)`
**/
setTeam: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, issuer: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, admin: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, freezer: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, LookupSource, LookupSource, LookupSource]>;
/**
* Re-allow unprivileged transfer of an asset instance.
*
* Origin must be Signed and the sender should be the Freezer of the asset `class`.
*
* - `class`: The class of the asset to be thawed.
* - `instance`: The instance of the asset to be thawed.
*
* Emits `Thawed`.
*
* Weight: `O(1)`
**/
thaw: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instance: Compact<InstanceId> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Compact<InstanceId>]>;
/**
* Re-allow unprivileged transfers for a whole asset class.
*
* Origin must be Signed and the sender should be the Admin of the asset `class`.
*
* - `class`: The class to be thawed.
*
* Emits `ClassThawed`.
*
* Weight: `O(1)`
**/
thawClass: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>]>;
/**
* Move an asset from the sender account to another.
*
* Origin must be Signed and the signing account must be either:
* - the Admin of the asset `class`;
* - the Owner of the asset `instance`;
* - the approved delegate for the asset `instance` (in this case, the approval is reset).
*
* Arguments:
* - `class`: The class of the asset to be transferred.
* - `instance`: The instance of the asset to be transferred.
* - `dest`: The account to receive ownership of the asset.
*
* Emits `Transferred`.
*
* Weight: `O(1)`
**/
transfer: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instance: Compact<InstanceId> | AnyNumber | Uint8Array, dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Compact<InstanceId>, LookupSource]>;
/**
* Change the Owner of an asset class.
*
* Origin must be Signed and the sender should be the Owner of the asset `class`.
*
* - `class`: The asset class whose owner should be changed.
* - `owner`: The new Owner of this asset class.
*
* Emits `OwnerChanged`.
*
* Weight: `O(1)`
**/
transferOwnership: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, owner: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, LookupSource]>;
/**
* Generic tx
**/
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
utility: {
/**
* Send a call through an indexed pseudonym of the sender.
+18 -23
View File
@@ -10,8 +10,6 @@ import type { AnyFunction, AnyTuple, CallFunction, Codec, CodecArg as Arg, Defin
import type { SubmittableExtrinsic } from '../submittable/types';
import type { ApiInterfaceRx, ApiOptions, ApiTypes, DecoratedErrors, DecoratedEvents, DecoratedRpc, DecoratedRpcSection, DecorateMethod, PaginationOptions, QueryableConsts, QueryableModuleStorage, QueryableStorage, QueryableStorageEntry, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics, SubmittableModuleExtrinsics } from '../types';
import BN from 'bn.js';
import { decorateDerive, ExactDerive } from '@polkadot/api-derive';
import { memo } from '@polkadot/api-derive/util';
import { expandMetadata, Metadata } from '@polkadot/metadata';
@@ -20,7 +18,7 @@ import { WsProvider } from '@polkadot/rpc-provider';
import { TypeRegistry } from '@polkadot/types/create';
import { DEFAULT_VERSION as EXTRINSIC_DEFAULT_VERSION } from '@polkadot/types/extrinsic/constants';
import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
import { arrayChunk, arrayFlatten, assert, compactStripLength, logger, u8aToHex } from '@polkadot/util';
import { arrayChunk, arrayFlatten, assert, BN, compactStripLength, logger, u8aToHex } from '@polkadot/util';
import { BehaviorSubject, combineLatest, Observable, of } from '@polkadot/x-rxjs';
import { map, switchMap, tap, toArray } from '@polkadot/x-rxjs/operators';
@@ -39,7 +37,8 @@ interface MetaDecoration {
}
// the max amount of keys/values that we will retrieve at once
const PAGE_SIZE = 256;
const PAGE_SIZE_K = 1000; // limit aligned with the 1k on the node (trie lookups are heavy)
const PAGE_SIZE_V = 250; // limited since the data may be very large (e.g. misfiring elections)
const l = logger('api/init');
@@ -471,15 +470,14 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
return of([]);
}
const queryCall = this.hasSubscriptions
? this._rpcCore.state.subscribeStorage
: this._rpcCore.state.queryStorageAt;
return combineLatest(
arrayChunk(keys, PAGE_SIZE).map((keys) =>
(this.hasSubscriptions
? this._rpcCore.state.subscribeStorage
: this._rpcCore.state.queryStorageAt
)(keys)
)
arrayChunk(keys, PAGE_SIZE_V).map((keys) => queryCall(keys))
).pipe(
map((valsArr): Codec[] => arrayFlatten(valsArr))
map(arrayFlatten)
);
}
@@ -488,25 +486,22 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
const headKey = iterKey(...args).toHex();
const startSubject = new BehaviorSubject<string>(headKey);
const query = at
? (startKey: string) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE, startKey, at)
: (startKey: string) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE, startKey);
const queryCall = at
? (startKey: string) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE_K, startKey, at)
: (startKey: string) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE_K, startKey);
return startSubject.pipe(
switchMap((startKey) =>
query(startKey).pipe(
map((keys) => keys.map((key) => key.setMeta(meta, section, method)))
)
),
switchMap(queryCall),
map((keys) => keys.map((key) => key.setMeta(meta, section, method))),
tap((keys): void => {
setTimeout((): void => {
keys.length === PAGE_SIZE
? startSubject.next(keys[PAGE_SIZE - 1].toHex())
keys.length === PAGE_SIZE_K
? startSubject.next(keys[PAGE_SIZE_K - 1].toHex())
: startSubject.complete();
}, 0);
}),
toArray(), // toArray since we want to startSubject to be completed
map((keysArr: StorageKey[][]) => arrayFlatten(keysArr))
map(arrayFlatten)
);
}
@@ -528,7 +523,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
return this._retrieveMapKeys(entry, at, args).pipe(
switchMap((keys) =>
keys.length
? combineLatest(arrayChunk(keys, PAGE_SIZE).map(query)).pipe(
? combineLatest(arrayChunk(keys, PAGE_SIZE_V).map(query)).pipe(
map((valsArr) =>
arrayFlatten(valsArr).map((value, index): [StorageKey, Codec] => [keys[index], value])
)
-7
View File
@@ -82,13 +82,6 @@ export abstract class Getters<ApiType extends ApiTypes> extends Init<ApiType> {
return assertResult(this._genesisHash);
}
/**
* @description `true` when subscriptions are supported
*/
public get hasSubscriptions (): boolean {
return this._rpcCore.provider.hasSubscriptions;
}
/**
* @description true is the underlying provider is connected
*/
+3 -5
View File
@@ -5,12 +5,11 @@ import type { RpcInterfaceMethod } from '@polkadot/rpc-core/types';
import type { Text } from '@polkadot/types';
import type { ChainProperties, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
import type { Registry } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { Observable, Subscription } from '@polkadot/x-rxjs';
import type { ApiBase, ApiOptions, ApiTypes, DecorateMethod } from '../types';
import type { VersionedRegistry } from './types';
import BN from 'bn.js';
import { Metadata } from '@polkadot/metadata';
import { TypeRegistry } from '@polkadot/types/create';
import { getSpecAlias, getSpecExtensions, getSpecHasher, getSpecRpc, getSpecTypes, getUpgradeVersion } from '@polkadot/types-known';
@@ -287,7 +286,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
}
// get unique types & validate
metadata.getUniqTypes(false);
metadata.getUniqTypes(this._options.throwOnUnknown || false);
return [genesisHash, metadata];
}
@@ -349,13 +348,12 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
}
this.#healthTimer = setInterval((): void => {
this._rpcCore.system.health().toPromise().catch((error) => l.warn(`Health keepalive check failed: ${(error as Error).message}`));
this._rpcCore.system.health().toPromise().catch(() => undefined);
}, KEEPALIVE_INTERVAL);
} catch (_error) {
const error = new Error(`FATAL: Unable to initialize the API: ${(_error as Error).message}`);
l.error(error);
l.error(_error);
this.emit('error', error);
}
+1 -1
View File
@@ -1,10 +1,10 @@
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type BN from 'bn.js';
import type { Metadata } from '@polkadot/metadata';
import type { Constants } from '@polkadot/metadata/decorate/types';
import type { Registry } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
export interface VersionedRegistry {
isDefault: boolean;
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api', version: '4.11.2' };
export const packageInfo = { name: '@polkadot/api', version: '4.16.2' };
+32 -11
View File
@@ -3,6 +3,8 @@
import type { SubmittableExtrinsic } from '../types';
import { jest } from '@jest/globals';
import { createPair } from '@polkadot/keyring/pair';
import { createTestKeyring } from '@polkadot/keyring/testing';
import { MockProvider } from '@polkadot/rpc-provider/mock';
@@ -48,6 +50,10 @@ describe('ApiPromise', (): void => {
provider = new MockProvider(registry);
});
afterEach(async () => {
await provider.disconnect();
});
describe('initialization', (): void => {
it('Create API instance with metadata map and makes the runtime, rpc, state & extrinsics available', async (): Promise<void> => {
const rpcData = await provider.send<string>('state_getMetadata', []);
@@ -62,6 +68,8 @@ describe('ApiPromise', (): void => {
expect(api.query).toBeDefined();
expect(api.tx).toBeDefined();
expect(api.derive).toBeDefined();
await api.disconnect();
});
it('Create API instance without metadata and makes the runtime, rpc, state & extrinsics available', async (): Promise<void> => {
@@ -75,6 +83,8 @@ describe('ApiPromise', (): void => {
expect(api.query).toBeDefined();
expect(api.tx).toBeDefined();
expect(api.derive).toBeDefined();
await api.disconnect();
});
it('Create API instance will error on failure to await ready', async (): Promise<void> => {
@@ -83,17 +93,22 @@ describe('ApiPromise', (): void => {
super({ provider });
}
protected _loadMeta (): Promise<boolean> {
protected override _loadMeta (): Promise<boolean> {
throw new Error('Simulate failure to load meta');
}
}
const api = new ErrorApiPromise();
try {
await new ErrorApiPromise().isReadyOrError;
await api.isReadyOrError;
fail('Expected an error but none occurred.');
} catch {
// Pass
}
await api.disconnect();
});
});
@@ -103,31 +118,35 @@ describe('ApiPromise', (): void => {
const SIG = '0x659effefbbe5ab4d7136ebb5084b959eb424e32b862307371be4721ac2c46334245af4f1476c36c5e5aff04396c2fdd2ce561ec90382821d4aa071b559b1db0f';
it('signs data using a specified keyring', async (): Promise<void> => {
const api = new ApiPromise({ provider, registry });
const api = await ApiPromise.create({ provider, registry });
const sig = await api.sign(aliceEd, TEST);
expect(
await api.sign(aliceEd, TEST)
).toEqual(SIG);
expect(sig).toEqual(SIG);
await api.disconnect();
});
it('signs data using an external signer', async (): Promise<void> => {
const api = new ApiPromise({
const api = await ApiPromise.create({
provider,
registry,
signer: new SingleAccountSigner(registry, aliceEd)
});
const sig = await api.sign(ADDR, TEST);
expect(
await api.sign(ADDR, TEST)
).toEqual(SIG);
expect(sig).toEqual(SIG);
await api.disconnect();
});
});
describe('decorator.signAsync', (): void => {
it('signs a transfer using an external signer', async (): Promise<void> => {
const { transfer } = await createTransfer();
const { api, transfer } = await createTransfer();
expect(transfer.signature.toHex()).toEqual(TRANSFER_SIG);
await api.disconnect();
});
});
@@ -137,6 +156,8 @@ describe('ApiPromise', (): void => {
expect(api.tx(transfer.toHex()).signature.toHex()).toEqual(TRANSFER_SIG);
expect(api.tx(transfer).signature.toHex()).toEqual(TRANSFER_SIG);
await api.disconnect();
});
});
});
-60
View File
@@ -1,60 +0,0 @@
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from '@polkadot/x-rxjs';
import type { SubmittableExtrinsic } from '../submittable/types';
import { createTestPairs } from '@polkadot/keyring/testingPairs';
import { MockProvider } from '@polkadot/rpc-provider/mock';
import { TypeRegistry } from '@polkadot/types/create';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { SingleAccountSigner } from '../../test/util';
import { ApiRx } from '.';
describe('ApiRx', (): void => {
const registry = new TypeRegistry();
const keyring = createTestPairs({ type: 'ed25519' });
let provider: MockProvider;
beforeEach((): void => {
jest.setTimeout(3000000);
provider = new MockProvider(registry);
});
describe('decorator.signAsync', (): void => {
it('signs a transfer using an external signer', (): void => {
const signer = new SingleAccountSigner(registry, keyring.alice_session);
ApiRx.create({ provider, registry, signer }).pipe(
switchMap((api: ApiRx): Observable<SubmittableExtrinsic<'rxjs'>> =>
api.tx.balances
.transfer(keyring.eve.address, 12345)
.signAsync(keyring.alice_session, {})
),
map((tx: SubmittableExtrinsic<'rxjs'>): void => {
expect(tx.signature.toHex()).toEqual(
'0x97f3cfe5088fcd575313e983f45d02b0f630e7b94ff9a3ac50e20cd096a8f554fda73d42ead891b5a1d3ce5607d83f20b0c6570b555e949cfb5763d0abcd590b'
);
})
);
});
it('allows the second argument to signAsync to be omitted', () => {
const signer = new SingleAccountSigner(registry, keyring.alice_session);
ApiRx.create({ provider, registry, signer }).pipe(
switchMap((api: ApiRx): Observable<SubmittableExtrinsic<'rxjs'>> =>
api.tx.balances
.transfer(keyring.eve.address, 12345)
.signAsync(keyring.alice_session)
),
map((tx: SubmittableExtrinsic<'rxjs'>): void => {
expect(tx.signature.toHex()).toEqual(
'0x97f3cfe5088fcd575313e983f45d02b0f630e7b94ff9a3ac50e20cd096a8f554fda73d42ead891b5a1d3ce5607d83f20b0c6570b555e949cfb5763d0abcd590b'
);
})
);
});
});
});
+1 -1
View File
@@ -110,7 +110,7 @@ export function createClass <ApiType extends ApiTypes> ({ api, apiType, decorate
* @description Sign a transaction, returning the this to allow chaining, i.e. .sign(...).send(). When options, e.g. nonce/blockHash are not specified, it will be inferred. To retrieve eg. nonce use `signAsync` (the preferred interface, this is provided for backwards compatibility)
* @deprecated
*/
public sign (account: IKeyringPair, optionsOrNonce?: Partial<SignerOptions>): this {
public override sign (account: IKeyringPair, optionsOrNonce?: Partial<SignerOptions>): this {
super.sign(account, this.#makeSignOptions(this.#optionsOrNonce(optionsOrNonce), {}));
return this;
+5 -1
View File
@@ -4,7 +4,6 @@
// Augment the modules
import '@polkadot/api/augment';
import type BN from 'bn.js';
import type { DeriveCustom, ExactDerive } from '@polkadot/api-derive';
import type { Metadata } from '@polkadot/metadata';
import type { RpcInterface } from '@polkadot/rpc-core/types';
@@ -12,6 +11,7 @@ import type { ProviderInterface, ProviderInterfaceEmitted } from '@polkadot/rpc-
import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
import type { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
import type { DefinitionRpc, DefinitionRpcSub, RegisteredTypes, Registry, SignatureOptions, Signer } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { ApiBase } from '../base';
import type { DeriveAllSections } from '../util/decorate';
import type { QueryableConsts } from './consts';
@@ -73,6 +73,10 @@ export interface ApiOptions extends RegisteredTypes {
* @description Throws an error when the initial connection fails (same as isReadyOrError)
*/
throwOnConnect?: boolean;
/**
* @description Throws an error when some types are unknown (useful with throwOnConnect)
*/
throwOnUnknown?: boolean;
}
// A smaller interface of ApiRx, used in derive and in SubmittableExtrinsic
+17 -31
View File
@@ -1,23 +1,28 @@
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { jest } from '@jest/globals';
import { ApiPromise, WsProvider } from '@polkadot/api';
function createApi (): Promise<ApiPromise> {
jest.setTimeout(30000);
process.env.NODE_ENV = 'test';
describe('misc online tests', (): void => {
let api: ApiPromise;
const provider = new WsProvider('wss://kusama-rpc.polkadot.io');
// const provider = new WsProvider('wss://westend-rpc.polkadot.io/');
// const provider = new WsProvider('ws://127.0.0.1:9944/');
beforeEach(async () => {
jest.setTimeout(30000);
process.env.NODE_ENV = 'test';
return new ApiPromise({ provider }).isReady;
}
// const provider = new WsProvider('wss://kusama-rpc.polkadot.io');
const provider = new WsProvider('wss://westend-rpc.polkadot.io/');
api = await ApiPromise.create({ provider });
});
afterEach(async () => {
await api.disconnect();
});
describe('misc quick tests', (): void => {
it.skip('retrieves balances correctly', async (): Promise<void> => {
const api = await createApi();
console.error(JSON.stringify(
await api.query.system.account('FPzukZw2mphWsXDqdkNzLaxnanjZEWH9i2vqwobTdtde5me')
));
@@ -27,8 +32,6 @@ describe('misc quick tests', (): void => {
});
it.skip('handles map keys', async (): Promise<void> => {
const api = await createApi();
console.time('map.keys');
const keys = await api.query.system.account.keys();
@@ -39,8 +42,6 @@ describe('misc quick tests', (): void => {
});
it.skip('handles map entries', async (): Promise<void> => {
const api = await createApi();
console.time('map.entries');
const entries = await api.query.system.account.entries(); // api.query.indices.accounts.entries();
@@ -51,7 +52,6 @@ describe('misc quick tests', (): void => {
});
it.skip('handles doublemap entries', async (): Promise<void> => {
const api = await createApi();
const activeEra = await api.query.staking.activeEra();
console.error(JSON.stringify(
@@ -60,26 +60,12 @@ describe('misc quick tests', (): void => {
});
it.skip('does something in society', async (): Promise<void> => {
const api = await createApi();
console.error(JSON.stringify(
await api.query.society.defenderVotes('Dab4bfYTZRUDMWjYAUQuFbDreQ9mt7nULWu3Dw7jodbzVe9')
));
});
it.skip('allows for range queries', async (): Promise<void> => {
const api = await createApi();
const header = await api.rpc.chain.getHeader();
console.error(JSON.stringify(
(await api.query.staking.activeEra.range([header.parentHash, header.hash], 'Dab4bfYTZRUDMWjYAUQuFbDreQ9mt7nULWu3Dw7jodbzVe9'))
.map(([block, value]) => [block, value.toRawType(), value.toHuman()])
));
});
it('expose rpc and rx definition', async (): Promise<void> => {
const api = await createApi();
it('expose rpc and rx definition', (): void => {
console.error(api.rpc.payment.queryFeeDetails.meta);
console.error(api.rx.rpc.chain.getBlock.meta);
@@ -7,6 +7,8 @@ import type { Option } from '@polkadot/types/codec';
import type { AccountId, AccountIndex, AccountInfo, Address, Balance, BlockNumber, Index } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import { jest } from '@jest/globals';
import { ApiPromise, WsProvider } from '@polkadot/api';
import { memo } from '@polkadot/api-derive/util/memo';
import { combineLatest, of } from '@polkadot/x-rxjs';
+7 -8
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/metadata",
"version": "4.11.2",
"version": "4.16.2",
"type": "module",
"description": "Helpers to extract information from runtime metadata",
"main": "index.js",
@@ -19,14 +19,13 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
"dependencies": {
"@babel/runtime": "^7.14.0",
"@polkadot/types": "4.11.2",
"@polkadot/types-known": "4.11.2",
"@polkadot/util": "^6.5.1",
"@polkadot/util-crypto": "^6.5.1",
"bn.js": "^4.11.9"
"@babel/runtime": "^7.14.6",
"@polkadot/types": "4.16.2",
"@polkadot/types-known": "4.16.2",
"@polkadot/util": "^6.10.1",
"@polkadot/util-crypto": "^6.10.1"
},
"devDependencies": {
"@polkadot/keyring": "^6.5.1"
"@polkadot/keyring": "^6.10.1"
}
}
+1 -1
View File
@@ -142,7 +142,7 @@ export class MetadataVersioned extends Struct {
/**
* @description Converts the Object to JSON, typically used for RPC transfers
*/
public toJSON (): Record<string, AnyJson> {
public override toJSON (): Record<string, AnyJson> {
// HACK(y): ensure that we apply the aliases if we have not done so already, this is
// needed to ensure we have the correct overrides (which is only applied in toLatest)
// eslint-disable-next-line no-unused-expressions
@@ -1,10 +1,9 @@
// Copyright 2017-2021 @polkadot/metadata authors & contributors
// SPDX-License-Identifier: Apache-2.0
import BN from 'bn.js';
import { createTestPairs } from '@polkadot/keyring/testingPairs';
import { TypeRegistry } from '@polkadot/types/create';
import { BN } from '@polkadot/util';
import { Metadata } from '../../Metadata';
import metadataStatic from '../../static';
@@ -1,15 +1,14 @@
// Copyright 2017-2021 @polkadot/metadata authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { StorageEntryMetadataLatest } from '@polkadot/types/interfaces/metadata';
import type { StorageEntryMetadataLatest, StorageHasher } from '@polkadot/types/interfaces/metadata';
import type { StorageEntry } from '@polkadot/types/primitive/types';
import type { Codec, Registry } from '@polkadot/types/types';
import BN from 'bn.js';
import type { BN } from '@polkadot/util';
import { Raw } from '@polkadot/types/codec';
import { StorageKey, Type } from '@polkadot/types/primitive';
import { assert, compactAddLength, compactStripLength, isNull, isUndefined, stringCamelCase, stringify, stringLowerFirst, u8aConcat, u8aToU8a } from '@polkadot/util';
import { assert, compactAddLength, compactStripLength, isUndefined, stringCamelCase, stringLowerFirst, u8aConcat, u8aToU8a } from '@polkadot/util';
import { xxhashAsU8a } from '@polkadot/util-crypto';
import { getHasher } from './getHasher';
@@ -31,33 +30,27 @@ interface IterFn {
meta: StorageEntryMetadataLatest;
}
type CreateArgType = boolean | string | number | null | BN | BigInt | Uint8Array | Codec;
type U8aHasher = (input: Uint8Array) => Uint8Array;
function createPrefixedKey ({ method, prefix }: CreateItemFn): Uint8Array {
return u8aConcat(xxhashAsU8a(prefix, 128), xxhashAsU8a(method, 128));
}
function createKeyRaw (registry: Registry, itemFn: CreateItemFn, keys: Type[], hashers: U8aHasher[], args: CreateArgType[]): Uint8Array {
const { method, section } = itemFn;
type Arg = boolean | string | number | null | BN | BigInt | Uint8Array | Codec;
/** @internal */
function createKeyRaw (registry: Registry, itemFn: CreateItemFn, keys: Type[], hashers: StorageHasher[], args: Arg[]): Uint8Array {
return u8aConcat(
createPrefixedKey(itemFn),
...keys.map((type, index): Uint8Array => {
const arg = args[index];
assert(!isUndefined(arg) && !isNull(arg), () => `Call to ${stringCamelCase(section || 'unknown')}.${stringCamelCase(method || 'unknown')} has a null or undefined argument at position ${index}`);
return hashers[index](registry.createType(type.toString() as 'Raw', arg).toU8a());
})
xxhashAsU8a(itemFn.prefix, 128),
xxhashAsU8a(itemFn.method, 128),
...keys.map((type, index) =>
getHasher(hashers[index])(
registry.createType(type.toString() as 'Raw', args[index]).toU8a()
)
)
);
}
function createKey (registry: Registry, itemFn: CreateItemFn, keys: Type[], hashers: U8aHasher[], args: CreateArgType[]): Uint8Array {
/** @internal */
function createKey (registry: Registry, itemFn: CreateItemFn, keys: Type[], hashers: StorageHasher[], args: Arg[]): Uint8Array {
const { method, section } = itemFn;
assert(Array.isArray(args) && args.length === keys.length, () => `Call to ${stringCamelCase(section || 'unknown')}.${stringCamelCase(method || 'unknown')} needs ${keys.length} arguments, found ${stringify(args)}`);
assert(Array.isArray(args), () => `Call to ${stringCamelCase(section || 'unknown')}.${stringCamelCase(method || 'unknown')} needs ${keys.length} arguments, provided in tuple format`);
assert(args.filter((a) => !isUndefined(a)).length === keys.length, () => `Call to ${stringCamelCase(section || 'unknown')}.${stringCamelCase(method || 'unknown')} needs ${keys.length} arguments, found [${args.join(', ')}]`);
// as per createKey, always add the length prefix (underlying it is Bytes)
return compactAddLength(
@@ -65,9 +58,8 @@ function createKey (registry: Registry, itemFn: CreateItemFn, keys: Type[], hash
);
}
// attach the metadata to expand to a StorageFunction
/** @internal */
function expandWithMeta ({ meta, method, prefix, section }: CreateItemFn, _storageFn: (arg?: CreateArgType | CreateArgType[]) => Uint8Array): StorageEntry {
function expandWithMeta ({ meta, method, prefix, section }: CreateItemFn, _storageFn: (arg?: Arg | Arg[]) => Uint8Array): StorageEntry {
const storageFn = _storageFn as StorageEntry;
storageFn.meta = meta;
@@ -97,7 +89,7 @@ function extendHeadMeta (registry: Registry, { meta: { documentation, name, type
// meta fallback only applies to actual entry values, create one for head
(iterFn as IterFn).meta = registry.createType('StorageEntryMetadataLatest', {
documentation,
fallback: registry.createType('Bytes', registry.createType(outputType.toString() as 'Raw').toHex()),
fallback: registry.createType('Bytes'),
modifier: registry.createType('StorageEntryModifierLatest', 1), // required
name,
type: registry.createType('StorageEntryTypeLatest', registry.createType('Type', outputType), 0)
@@ -107,7 +99,6 @@ function extendHeadMeta (registry: Registry, { meta: { documentation, name, type
registry.createType('StorageKey', iterFn(...args), { method, section });
}
// attach the full list hashing for prefixed maps
/** @internal */
function extendPrefixedMap (registry: Registry, itemFn: CreateItemFn, storageFn: StorageEntry): StorageEntry {
const { meta: { type }, method, section } = itemFn;
@@ -124,16 +115,16 @@ function extendPrefixedMap (registry: Registry, itemFn: CreateItemFn, storageFn:
if (args.length) {
if (type.isDoubleMap) {
return new Raw(registry, createKeyRaw(registry, itemFn, [type.asDoubleMap.key1], [getHasher(type.asDoubleMap.hasher)], args as CreateArgType[]));
return new Raw(registry, createKeyRaw(registry, itemFn, [type.asDoubleMap.key1], [type.asDoubleMap.hasher], args as Arg[]));
} else if (type.isNMap) {
const keys = [...type.asNMap.keyVec];
const hashers = type.asNMap.hashers.map((h) => getHasher(h));
const hashers = [...type.asNMap.hashers];
// remove the last entry
keys.pop();
hashers.pop();
return new Raw(registry, createKeyRaw(registry, itemFn, keys, hashers, args as CreateArgType[]));
return new Raw(registry, createKeyRaw(registry, itemFn, keys, hashers, args as Arg[]));
}
}
@@ -151,16 +142,16 @@ export function createFunction (registry: Registry, itemFn: CreateItemFn, option
// - storage.system.account(address)
// - storage.timestamp.blockPeriod()
// For higher-map queries the params are passed in as an tuple, [key1, key2]
const storageFn = expandWithMeta(itemFn, (arg?: CreateArgType | CreateArgType[]) =>
const storageFn = expandWithMeta(itemFn, (arg?: Arg | Arg[]) =>
type.isPlain
? options.skipHashing
? compactAddLength(u8aToU8a(options.key))
: createKey(registry, itemFn, [], [], [])
: type.isMap
? createKey(registry, itemFn, [type.asMap.key], [getHasher(type.asMap.hasher)], [arg as CreateArgType])
? createKey(registry, itemFn, [type.asMap.key], [type.asMap.hasher], [arg as Arg])
: type.isDoubleMap
? createKey(registry, itemFn, [type.asDoubleMap.key1, type.asDoubleMap.key2], [getHasher(type.asDoubleMap.hasher), getHasher(type.asDoubleMap.key2Hasher)], arg as CreateArgType[])
: createKey(registry, itemFn, type.asNMap.keyVec, type.asNMap.hashers.map((h) => getHasher(h)), arg as CreateArgType[])
? createKey(registry, itemFn, [type.asDoubleMap.key1, type.asDoubleMap.key2], [type.asDoubleMap.hasher, type.asDoubleMap.key2Hasher], arg as Arg[])
: createKey(registry, itemFn, type.asNMap.keyVec, type.asNMap.hashers, arg as Arg[])
);
if (type.isMap || type.isDoubleMap || type.isNMap) {
@@ -12,34 +12,36 @@ import { decorateStorage } from '..';
const keyring = createTestPairs({ type: 'ed25519' });
describe('decorateStorage', (): void => {
describe('latest', (): void => {
const registry = new TypeRegistry();
const metadata = new Metadata(registry, rpcMetadata);
const registry = new TypeRegistry();
const metadata = new Metadata(registry, rpcMetadata);
registry.setMetadata(metadata);
registry.setMetadata(metadata);
const query = decorateStorage(registry, metadata.asLatest, metadata.version);
const query = decorateStorage(registry, metadata.asLatest, metadata.version);
it('should throw if the storage function expects an argument', (): void => {
expect(() => query.balances.account()).toThrowError('Call to balances.account has a null or undefined argument at position 0');
});
it('should throw if the storage function expects an argument', (): void => {
expect(() => query.balances.account()).toThrowError('Call to balances.account needs 1 arguments, found []');
});
it('should throw if the storage function expects multiple arguments', (): void => {
expect(() => query.staking.erasStakers([1])).toThrowError('Call to staking.erasStakers needs 2 arguments, found [1]');
});
it('should throw if the storage function expects multiple arguments', (): void => {
expect(() => query.staking.erasStakers([1])).toThrowError('Call to staking.erasStakers needs 2 arguments, found [1]');
});
it('should return a value if the storage function does not expect an argument', (): void => {
expect(() => query.timestamp.now()).not.toThrow();
});
it('should throw if the storage function expects tuple arguments', (): void => {
expect(() => query.staking.erasStakers(1)).toThrowError('Call to staking.erasStakers needs 2 arguments, provided in tuple format');
});
it('should return the correct length-prefixed storage key', (): void => {
expect(
u8aToHex(
query.system.account(keyring.alice.address)
)
).toEqual(
'0x410126aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9de1e86a9a8c739864cf3cc5ec2bea59fd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d'
);
});
it('should return a value if the storage function does not expect an argument', (): void => {
expect(() => query.timestamp.now()).not.toThrow();
});
it('should return the correct length-prefixed storage key', (): void => {
expect(
u8aToHex(
query.system.account(keyring.alice.address)
)
).toEqual(
'0x410126aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9de1e86a9a8c739864cf3cc5ec2bea59fd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d'
);
});
});
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/metadata', version: '4.11.2' };
export const packageInfo = { name: '@polkadot/metadata', version: '4.16.2' };
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+11 -1
View File
@@ -8,12 +8,22 @@ import { Type } from '@polkadot/types/primitive';
import { getModuleTypes } from '@polkadot/types-known';
import { stringCamelCase } from '@polkadot/util';
// FIXME: Need some sort of solution for specifying these
// Since we don't have insight into the origin specification, we can only define what we know about
// in a pure Substrate/Polkadot implementation, any other custom origins won't be handled at all
const KNOWN_ORIGINS: Record<string, string> = {
/* eslint-disable sort-keys */
// Substrate
Council: 'CollectiveOrigin',
System: 'SystemOrigin',
TechnicalCommittee: 'CollectiveOrigin'
TechnicalCommittee: 'CollectiveOrigin',
// Polkadot
Xcm: 'XcmOrigin',
XcmPallet: 'XcmOrigin',
// Acala
Authority: 'AuthorityOrigin',
GeneralCouncil: 'CollectiveOrigin'
/* eslint-enable sort-keys */
};
const BOXES = [['<', '>'], ['<', ','], [',', '>'], ['(', ')'], ['(', ','], [',', ','], [',', ')']];
+1 -70
View File
@@ -1,72 +1,3 @@
# @polkadot/rpc-core
This library provides a clean wrapper around all the methods exposed by a Polkadot network client.
## Usage
Installation -
```
yarn add @polkadot/rpc-core
```
Initialization -
```js
import Rpc from '@polkadot/rpc-core';
import { WsProvider } from '@polkadot/rpc-provider/ws';
const provider = new WsProvider('http://127.0.0.1:9944');
const rpc = new Rpc(provider);
```
Retrieving the block header object for a given block header hash (a 0x-prefixed hex string with length of 64) -
```js
rpc.chain
.getHeader('0x1234567890')
.subscribe(
(header) => console.log(header),
(error) => console.error('error:', error)
);
```
Retrieving the best block number, parent hash, state root hash, extrinsics root hash, and digest (once-off) -
```js
rpc.chain
.getHead()
.pipe(
switchMap((headerHash) => {
return rpc.chain.getHeader(headerHash);
})
)
.subscribe(
(header) => {
console.log(`best #${header.number.toString()}`);
console.log(`parentHash: ${header.parentHash.toString()}`);
console.log(`stateRoot: ${header.stateRoot.toString()}`);
console.log(`extrinsicsRoot: ${header.extrinsicsRoot.toString()}`);
console.log(`digest: ${header.digest.toString()}`);
},
(error) => {
console.error('error:', error);
}
);
```
Retrieving best header via subscription -
```js
api.chain
rpc
.subscribeNewHeads()
.subscribe(
(header) => {
console.log(`best #${header.number}`);
},
(error) => {
console.error('error subscribing:', error);
}
);
```
This library provides a clean wrapper around all the methods exposed by a Polkadot network client. It is only used internally to the API.
+8 -8
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-core",
"version": "4.11.2",
"version": "4.16.2",
"type": "module",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
@@ -19,14 +19,14 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": {
"@babel/runtime": "^7.14.0",
"@polkadot/metadata": "4.11.2",
"@polkadot/rpc-provider": "4.11.2",
"@polkadot/types": "4.11.2",
"@polkadot/util": "^6.5.1",
"@polkadot/x-rxjs": "^6.5.1"
"@babel/runtime": "^7.14.6",
"@polkadot/metadata": "4.16.2",
"@polkadot/rpc-provider": "4.16.2",
"@polkadot/types": "4.16.2",
"@polkadot/util": "^6.10.1",
"@polkadot/x-rxjs": "^6.10.1"
},
"devDependencies": {
"@polkadot/keyring": "^6.5.1"
"@polkadot/keyring": "^6.10.1"
}
}
+7 -1
View File
@@ -12,10 +12,16 @@ import { RpcCore } from '.';
describe('Cached Observables', (): void => {
const registry = new TypeRegistry();
let rpc: RpcCore & RpcInterface;
let provider: MockProvider;
const keyring = createTestPairs();
beforeEach((): void => {
rpc = new RpcCore('123', registry, new MockProvider(registry)) as (RpcCore & RpcInterface);
provider = new MockProvider(registry);
rpc = new RpcCore('123', registry, provider) as (RpcCore & RpcInterface);
});
afterEach(async () => {
await provider.disconnect();
});
it('creates a single observable for subscriptions (multiple calls)', (): void => {
+5 -2
View File
@@ -16,8 +16,9 @@ describe('Api', (): void => {
).toThrow(/Expected Provider/);
});
it('allows for the definition of user RPCs', (): void => {
const rpc = new RpcCore('567', registry, new MockProvider(registry), {
it('allows for the definition of user RPCs', async () => {
const provider = new MockProvider(registry);
const rpc = new RpcCore('567', registry, provider, {
testing: {
foo: {
description: 'foo',
@@ -42,5 +43,7 @@ describe('Api', (): void => {
section: 'testing',
type: 'Balance'
});
await provider.disconnect();
});
});
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/rpc-core', version: '4.11.2' };
export const packageInfo = { name: '@polkadot/rpc-core', version: '4.16.2' };
+7 -1
View File
@@ -13,9 +13,15 @@ import { RpcCore } from '.';
describe('replay', (): void => {
const registry = new TypeRegistry();
let rpc: RpcCore & RpcInterface;
let provider: MockProvider;
beforeEach((): void => {
rpc = new RpcCore('653', registry, new MockProvider(registry)) as (RpcCore & RpcInterface);
provider = new MockProvider(registry);
rpc = new RpcCore('653', registry, provider) as (RpcCore & RpcInterface);
});
afterEach(async () => {
await provider.disconnect();
});
it('subscribes via the rpc section', (done): void => {
+19 -6
View File
@@ -1,33 +1,46 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { jest } from '@jest/globals';
import { of, timer } from '@polkadot/x-rxjs';
import { drr } from '.';
describe('drr', (): void => {
beforeEach((): void => {
jest.setTimeout(15000);
});
it('should not fire twice the same value', (done): void => {
let count = 0;
of(1, 1).pipe(drr()).subscribe((): void => { ++count; });
const sub = of(1, 1).pipe(drr({ delay: 500 })).subscribe((): void => { ++count; });
setTimeout((): void => {
expect(count).toBe(1);
done();
sub.unsubscribe();
setTimeout(done, 2000);
}, 50);
});
it('should be a ReplaySubject(1)', (done): void => {
const obs = timer(0, 100).pipe(drr()); // Starts at 0, increments every 100ms
const obs = timer(0, 100).pipe(drr({ delay: 500 })); // Starts at 0, increments every 100ms
obs.subscribe(); // Fire the observable
const sub = obs.subscribe(); // Fire the observable
// Subscribe another time after some time, i.e. after the observable has fired
setTimeout((): void => {
obs.subscribe((value): void => {
const sub = obs.subscribe((value): void => {
expect(value > 1).toBe(true);
done();
setTimeout(done, 2000);
});
sub.unsubscribe();
}, 500);
sub.unsubscribe();
});
});
+11 -12
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-provider",
"version": "4.11.2",
"version": "4.16.2",
"type": "module",
"description": "Transport providers for the API",
"main": "index.js",
@@ -19,20 +19,19 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.14.0",
"@polkadot/types": "4.11.2",
"@polkadot/util": "^6.5.1",
"@polkadot/util-crypto": "^6.5.1",
"@polkadot/x-fetch": "^6.5.1",
"@polkadot/x-global": "^6.5.1",
"@polkadot/x-ws": "^6.5.1",
"bn.js": "^4.11.9",
"@babel/runtime": "^7.14.6",
"@polkadot/types": "4.16.2",
"@polkadot/util": "^6.10.1",
"@polkadot/util-crypto": "^6.10.1",
"@polkadot/x-fetch": "^6.10.1",
"@polkadot/x-global": "^6.10.1",
"@polkadot/x-ws": "^6.10.1",
"eventemitter3": "^4.0.7"
},
"devDependencies": {
"@polkadot/keyring": "^6.5.1",
"@polkadot/metadata": "4.11.2",
"@polkadot/keyring": "^6.10.1",
"@polkadot/metadata": "4.16.2",
"mock-socket": "^9.0.3",
"nock": "^13.0.11"
"nock": "^13.1.0"
}
}
+3 -3
View File
@@ -14,18 +14,18 @@ const ERROR_SUBSCRIBE = 'HTTP Provider does not have subscriptions, use WebSocke
const l = logger('api-http');
/**
* # @polkadot/rpc-provider/https
* # @polkadot/rpc-provider
*
* @name HttpProvider
*
* @description The HTTP Provider allows sending requests using HTTP to a HTTP RPC server TCP port. It does not support subscriptions so you won't be able to listen to events such as new blocks or balance changes. It is usually preferrable using the [[WsProvider]].
* @description The HTTP Provider allows sending requests using HTTP to a HTTP RPC server TCP port. It does not support subscriptions so you won't be able to listen to events such as new blocks or balance changes. It is usually preferable using the [[WsProvider]].
*
* @example
* <BR>
*
* ```javascript
* import Api from '@polkadot/api/promise';
* import HttpProvider from '@polkadot/rpc-provider/http';
* import { HttpProvider } from '@polkadot/rpc-provider';
*
* const provider = new HttpProvider('http://127.0.0.1:9933');
* const api = new Api(provider);
+10 -5
View File
@@ -8,7 +8,6 @@ import type { Codec, Registry } from '@polkadot/types/types';
import type { ProviderInterface, ProviderInterfaceEmitCb, ProviderInterfaceEmitted } from '../types';
import type { MockStateDb, MockStateSubscriptionCallback, MockStateSubscriptions } from './types';
import BN from 'bn.js';
import EventEmitter from 'eventemitter3';
import { createTestKeyring } from '@polkadot/keyring/testing';
@@ -17,7 +16,7 @@ import rpcMetadata from '@polkadot/metadata/static';
import jsonrpc from '@polkadot/types/interfaces/jsonrpc';
import rpcHeader from '@polkadot/types/json/Header.004.json';
import rpcSignedBlock from '@polkadot/types/json/SignedBlock.004.immortal.json';
import { assert, bnToU8a, logger, u8aToHex } from '@polkadot/util';
import { assert, BN, bnToU8a, logger, u8aToHex } from '@polkadot/util';
import { randomAsU8a } from '@polkadot/util-crypto';
const INTERVAL = 1000;
@@ -45,6 +44,8 @@ export class MockProvider implements ProviderInterface {
private emitter = new EventEmitter();
private intervalId?: NodeJS.Timeout | null;
public isUpdating = true;
private registry: Registry;
@@ -55,7 +56,7 @@ export class MockProvider implements ProviderInterface {
// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-unsafe-member-access
chain_getBlock: () => this.registry.createType('SignedBlock', rpcSignedBlock.result).toJSON(),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
chain_getBlockHash: () => '0x1234',
chain_getBlockHash: () => '0x1234000000000000000000000000000000000000000000000000000000000000',
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
chain_getFinalizedHead: () => this.registry.createType('Header', rpcHeader.result).hash,
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
@@ -104,8 +105,12 @@ export class MockProvider implements ProviderInterface {
// noop
}
// eslint-disable-next-line @typescript-eslint/require-await
public async disconnect (): Promise<void> {
// noop
if (this.intervalId) {
clearInterval(this.intervalId);
this.intervalId = null;
}
}
public get isConnected (): boolean {
@@ -175,7 +180,7 @@ export class MockProvider implements ProviderInterface {
const query = decorateStorage(this.registry, metadata.asLatest, metadata.version);
// Do something every 1 seconds
setInterval((): void => {
this.intervalId = setInterval((): void => {
if (!this.isUpdating) {
return;
}
@@ -15,6 +15,10 @@ describe('on', (): void => {
mock = new MockProvider(registry);
});
afterEach(async () => {
await mock.disconnect();
});
it('it emits both connected and disconnected events', (done): void => {
const events: Record<string, boolean> = { connected: false, disconnected: false };
@@ -13,6 +13,10 @@ describe('send', (): void => {
mock = new MockProvider(registry);
});
afterEach(async () => {
await mock.disconnect();
});
it('fails on non-supported methods', (): Promise<any> => {
return mock
.send('something_invalid', [])
@@ -13,6 +13,10 @@ describe('subscribe', (): void => {
mock = new MockProvider(registry);
});
afterEach(async () => {
await mock.disconnect();
});
it('fails on unknown methods', (): Promise<number | void> => {
return mock
.subscribe('test', 'test_notFound')
@@ -29,28 +33,28 @@ describe('subscribe', (): void => {
});
});
it('calls back with the last known value', (done): Promise<number> => {
it('calls back with the last known value', (done): void => {
mock.isUpdating = false;
mock.subscriptions.chain_subscribeNewHead.lastValue = 'testValue';
return mock.subscribe('chain_newHead', 'chain_subscribeNewHead', (_: any, value: string): void => {
mock.subscribe('chain_newHead', 'chain_subscribeNewHead', (_: any, value: string): void => {
expect(value).toEqual('testValue');
done();
});
}).catch(console.error);
});
it('calls back with new headers', (done): Promise<number> => {
return mock.subscribe('chain_newHead', 'chain_subscribeNewHead', (_: any, header: { number: number }): void => {
it('calls back with new headers', (done): void => {
mock.subscribe('chain_newHead', 'chain_subscribeNewHead', (_: any, header: { number: number }): void => {
if (header.number === 4) {
done();
}
});
}).catch(console.error);
});
it('handles errors withing callbacks gracefully', (done): Promise<number> => {
it('handles errors withing callbacks gracefully', (done): void => {
let hasThrown = false;
return mock.subscribe('chain_newHead', 'chain_subscribeNewHead', (_: any, header: { number: number }): void => {
mock.subscribe('chain_newHead', 'chain_subscribeNewHead', (_: any, header: { number: number }): void => {
if (!hasThrown) {
hasThrown = true;
@@ -60,6 +64,6 @@ describe('subscribe', (): void => {
if (header.number === 3) {
done();
}
});
}).catch(console.error);
});
});
@@ -20,6 +20,10 @@ describe('unsubscribe', (): void => {
});
});
afterEach(async () => {
await mock.disconnect();
});
it('fails on unknown ids', (): Promise<boolean> => {
return mock
.unsubscribe('chain_newHead', 'chain_subscribeNewHead', 5)
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/rpc-provider', version: '4.11.2' };
export const packageInfo = { name: '@polkadot/rpc-provider', version: '4.16.2' };
+44 -19
View File
@@ -3,9 +3,13 @@
import type { Mock } from './../mock/types';
import { mockWs, TEST_WS_URL } from '../../test/mockWs';
import { jest } from '@jest/globals';
import { mockWs } from '../../test/mockWs';
import { WsProvider } from './';
const TEST_WS_URL = 'ws://localhost-connect.spec.ts:9988';
function sleepMs (ms = 0): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
@@ -15,7 +19,7 @@ describe('onConnect', (): void => {
beforeEach((): void => {
jest.setTimeout(30000);
mocks = [mockWs([])];
mocks = [mockWs([], TEST_WS_URL)];
});
afterEach((): void => {
@@ -27,9 +31,19 @@ describe('onConnect', (): void => {
});
});
it('Does not connect when autoConnect is false', (): void => {
it('Does not connect when autoConnect is false', async () => {
const provider: WsProvider = new WsProvider(TEST_WS_URL, 0);
await sleepMs(100); // Hack to give the provider time to connect
expect(provider.isConnected).toBe(false);
await provider.connect();
await sleepMs(100); // Hack to give the provider time to connect
expect(provider.isConnected).toBe(true);
await provider.disconnect();
await sleepMs(100); // Hack to give the provider time to connect
expect(provider.isConnected).toBe(false);
});
@@ -38,6 +52,8 @@ describe('onConnect', (): void => {
await sleepMs(100); // Hack to give the provider time to connect
expect(provider.isConnected).toBe(true);
await provider.disconnect();
});
it('Creates a new WebSocket instance by calling the connect() method', async () => {
@@ -50,7 +66,9 @@ describe('onConnect', (): void => {
await sleepMs(100); // Hack to give the provider time to connect
expect(provider.isConnected).toBe(true);
expect(mocks[0].server.clients().length).toBe(1);
expect(mocks[0].server.clients()).toHaveLength(1);
await provider.disconnect();
});
it('Connects to first endpoint when an array is given', async () => {
@@ -60,22 +78,26 @@ describe('onConnect', (): void => {
await sleepMs(100); // Hack to give the provider time to connect
expect(provider.isConnected).toBe(true);
await provider.disconnect();
});
it('Connects to the second endpoint when the first is unreachable', async () => {
/* eslint-disable @typescript-eslint/no-empty-function */
jest.spyOn(console, 'error').mockImplementation((): void => {});
const endpoints: string[] = ['ws://localhost:9956', TEST_WS_URL];
const endpoints: string[] = ['ws://localhost-connect.spec.ts:9956', TEST_WS_URL];
const provider: WsProvider = new WsProvider(endpoints, 1);
await sleepMs(100); // Hack to give the provider time to connect
expect(provider.isConnected).toBe(true);
await provider.disconnect();
});
it('Connects to the second endpoint when the first is dropped', async () => {
const endpoints: string[] = [TEST_WS_URL, 'ws://localhost:9957'];
const endpoints: string[] = [TEST_WS_URL, 'ws://localhost-connect.spec.ts:9957'];
mocks.push(mockWs([], endpoints[1]));
@@ -83,26 +105,27 @@ describe('onConnect', (): void => {
await sleepMs(100); // Hack to give the provider time to connect
// Check that first server is connected
expect(mocks[0].server.clients().length).toBe(1);
expect(mocks[1].server.clients().length).toBe(0);
expect(mocks[0].server.clients()).toHaveLength(1);
expect(mocks[1].server.clients()).toHaveLength(0);
// Close connection from first server
mocks[0].server.clients()[0].close();
await sleepMs(100);
// Check that second server is connected
expect(mocks[1].server.clients().length).toBe(1);
expect(mocks[1].server.clients()).toHaveLength(1);
expect(provider.isConnected).toBe(true);
await provider.disconnect();
});
it('Round-robin of endpoints on WsProvider', async () => {
const rounds = 5;
const endpoints: string[] = [
TEST_WS_URL,
'ws://localhost:9956',
'ws://localhost:9957',
'ws://invalid:9956',
'ws://localhost:9958'
'ws://localhost-connect.spec.ts:9956',
'ws://localhost-connect.spec.ts:9957',
'ws://invalid-connect.spec.ts:9956',
'ws://localhost-connect.spec.ts:9958'
];
mocks.push(mockWs([], endpoints[1]));
@@ -117,18 +140,20 @@ describe('onConnect', (): void => {
];
const provider: WsProvider = new WsProvider(endpoints, 1);
for (let round = 0; round < rounds; round++) {
for (let index = 0; index < mocks.length; index++) {
for (let round = 0; round < 5; round++) {
for (let mock = 0; mock < mocks.length; mock++) {
await sleepMs(100); // Hack to give the provider time to connect
// Check that first server is connected and the next one isn't
expect(mocks[index].server.clients().length).toBe(1);
expect(mockNext[index].server.clients().length).toBe(0);
expect(mocks[mock].server.clients()).toHaveLength(1);
expect(mockNext[mock].server.clients()).toHaveLength(0);
expect(provider.isConnected).toBe(true);
// Close connection from first server
mocks[index].server.clients()[0].close();
mocks[mock].server.clients()[0].close();
}
}
await provider.disconnect();
});
});
+25 -23
View File
@@ -1,25 +1,32 @@
// Copyright 2017-2021 @polkadot/rpc-provider authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { mockWs, TEST_WS_URL } from '../../test/mockWs';
import { mockWs } from '../../test/mockWs';
import { Mock } from './../mock/types';
import { WsProvider } from './';
let ws: WsProvider;
const TEST_WS_URL = 'ws://localhost-index.spec.ts:9977';
let provider: WsProvider | null;
let mock: Mock;
function createWs (requests: any[], autoConnect: number | undefined = 1000): WsProvider {
mock = mockWs(requests);
ws = new WsProvider(TEST_WS_URL, autoConnect);
function createWs (requests: any[], autoConnect = 1000, headers?: Record<string, string>): WsProvider {
mock = mockWs(requests, TEST_WS_URL);
provider = new WsProvider(TEST_WS_URL, autoConnect, headers);
return ws;
return provider;
}
describe('Ws', (): void => {
afterEach((): void => {
afterEach(async () => {
if (mock) {
mock.done();
}
if (provider) {
await provider.disconnect();
provider = null;
}
});
it('returns the connected state', (): void => {
@@ -28,10 +35,8 @@ describe('Ws', (): void => {
).toEqual(false);
});
it('allows you to initialize the provider with custom headers', (): void => {
expect(
(): WsProvider => new WsProvider(TEST_WS_URL, 1000, { foo: 'bar' })
).not.toThrow();
it('allows you to initialize the provider with custom headers', () => {
createWs([], 100, { foo: 'bar' });
});
});
@@ -42,10 +47,9 @@ describe('Endpoint Parsing', (): void => {
});
it('Throws when WsProvider endpoint is an invalid string', () => {
expect(() => {
/* eslint-disable no-new */
new WsProvider('http://127.0.0.1:9955', 0);
}).toThrowError(/^Endpoint should start with /);
expect(
() => new WsProvider('http://127.0.0.1:9955', 0)
).toThrowError(/^Endpoint should start with /);
});
it('Succeeds when WsProvider endpoint is a valid array', () => {
@@ -58,18 +62,16 @@ describe('Endpoint Parsing', (): void => {
it('Throws when WsProvider endpoint is an empty array', () => {
const endpoints: string[] = [];
expect(() => {
/* eslint-disable no-new */
new WsProvider(endpoints, 0);
}).toThrowError('WsProvider requires at least one Endpoint');
expect(
() => new WsProvider(endpoints, 0)
).toThrowError('WsProvider requires at least one Endpoint');
});
it('Throws when WsProvider endpoint is an invalid array', () => {
const endpoints: string[] = ['ws://127.0.0.1:9955', 'http://bad.co:9944', 'ws://mychain.com:9933'];
expect(() => {
/* eslint-disable no-new */
new WsProvider(endpoints, 0);
}).toThrowError(/^Endpoint should start with /);
expect(
() => new WsProvider(endpoints, 0)
).toThrowError(/^Endpoint should start with /);
});
});
+11 -4
View File
@@ -3,17 +3,19 @@
import type { Constructor } from '@polkadot/types/types';
import { mockWs, TEST_WS_URL } from '../../test/mockWs';
import { mockWs } from '../../test/mockWs';
import { Global, Mock } from './../mock/types';
import { WsProvider } from './';
declare const global: Global;
let provider: WsProvider;
const TEST_WS_URL = 'ws://localhost-send.spec.ts:9965';
let provider: WsProvider | null;
let mock: Mock;
function createMock (requests: any[]): void {
mock = mockWs(requests);
mock = mockWs(requests, TEST_WS_URL);
}
function createWs (autoConnect = 1000): Promise<WsProvider> {
@@ -29,12 +31,17 @@ describe('send', (): void => {
globalWs = global.WebSocket;
});
afterEach((): void => {
afterEach(async () => {
global.WebSocket = globalWs;
if (mock) {
mock.done();
}
if (provider) {
await provider.disconnect();
provider = null;
}
});
it('handles internal errors', (): Promise<any> => {
+2 -2
View File
@@ -6,13 +6,13 @@ import { WsProvider } from './';
describe('state', (): void => {
it('requires an ws:// prefixed endpoint', (): void => {
expect(
(): WsProvider => new WsProvider('http://', 0)
() => new WsProvider('http://', 0)
).toThrow(/with 'ws/);
});
it('allows wss:// endpoints', (): void => {
expect(
(): WsProvider => new WsProvider('wss://', 0)
() => new WsProvider('wss://', 0)
).not.toThrow();
});
});
+13 -6
View File
@@ -3,23 +3,25 @@
import type { Constructor } from '@polkadot/types/types';
import { mockWs, TEST_WS_URL } from '../../test/mockWs';
import { mockWs } from '../../test/mockWs';
import { Global, Mock } from './../mock/types';
import { WsProvider } from './';
declare const global: Global;
let ws: WsProvider;
const TEST_WS_URL = 'ws://localhost-subscribe.test.ts:9933';
let provider: WsProvider | null;
let mock: Mock;
function createMock (requests: any[]): void {
mock = mockWs(requests);
mock = mockWs(requests, TEST_WS_URL);
}
function createWs (autoConnect = 1000): Promise<WsProvider> {
ws = new WsProvider(TEST_WS_URL, autoConnect);
provider = new WsProvider(TEST_WS_URL, autoConnect);
return ws.isReady;
return provider.isReady;
}
describe('subscribe', (): void => {
@@ -29,12 +31,17 @@ describe('subscribe', (): void => {
globalWs = global.WebSocket;
});
afterEach((): void => {
afterEach(async () => {
global.WebSocket = globalWs;
if (mock) {
mock.done();
}
if (provider) {
await provider.disconnect();
provider = null;
}
});
it('adds subscriptions', (): Promise<void> => {
@@ -3,23 +3,25 @@
import type { Constructor } from '@polkadot/types/types';
import { mockWs, TEST_WS_URL } from '../../test/mockWs';
import { mockWs } from '../../test/mockWs';
import { Global, Mock } from './../mock/types';
import { WsProvider } from './';
declare const global: Global;
let ws: WsProvider;
const TEST_WS_URL = 'ws://localhost-unsubscribe.test.ts:9933';
let provider: WsProvider | null;
let mock: Mock;
function createMock (requests: any): void {
mock = mockWs(requests);
mock = mockWs(requests, TEST_WS_URL);
}
function createWs (autoConnect = 1000): Promise<WsProvider> {
ws = new WsProvider(TEST_WS_URL, autoConnect);
provider = new WsProvider(TEST_WS_URL, autoConnect);
return ws.isReady;
return provider.isReady;
}
describe('subscribe', (): void => {
@@ -29,12 +31,17 @@ describe('subscribe', (): void => {
globalWs = global.WebSocket;
});
afterEach((): void => {
afterEach(async () => {
global.WebSocket = globalWs;
if (mock) {
mock.done();
}
if (provider) {
await provider.disconnect();
provider = null;
}
});
it('removes subscriptions', (): Promise<boolean> => {
+9 -9
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/typegen",
"version": "4.11.2",
"version": "4.16.2",
"type": "module",
"description": "Type generation scripts",
"main": "index.js",
@@ -26,14 +26,14 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme",
"dependencies": {
"@babel/core": "^7.14.3",
"@babel/register": "^7.13.16",
"@babel/runtime": "^7.14.0",
"@polkadot/api": "4.11.2",
"@polkadot/metadata": "4.11.2",
"@polkadot/rpc-provider": "4.11.2",
"@polkadot/types": "4.11.2",
"@polkadot/util": "^6.5.1",
"@babel/core": "^7.14.6",
"@babel/register": "^7.14.5",
"@babel/runtime": "^7.14.6",
"@polkadot/api": "4.16.2",
"@polkadot/metadata": "4.16.2",
"@polkadot/rpc-provider": "4.16.2",
"@polkadot/types": "4.16.2",
"@polkadot/util": "^6.10.1",
"handlebars": "^4.7.7",
"websocket": "^1.0.34",
"yargs": "^17.0.1"
+1
View File
@@ -14,6 +14,7 @@ import { stringCamelCase } from '@polkadot/util';
import { compareName, createImports, formatType, getSimilarTypes, initMeta, readTemplate, setImports, writeFile } from '../util';
const MAPPED_NAMES: Record<string, string> = {
class: 'clazz',
new: 'updated'
};
+1 -1
View File
@@ -54,7 +54,7 @@ function documentationVecToMarkdown (docLines: Vec<Text>, indent = 0): string {
? `${md}\n\n` // empty line
: /^[*-]/.test(docLine.trimStart()) && !md.endsWith('\n\n')
? `${md}\n\n${docLine}` // line calling for a preceding linebreak
: `${md}${docLine.replace(/^#{1,3} /, '#### ')} `
: `${md} ${docLine.replace(/^#{1,3} /, '#### ')} `
, '')
.replace(/#### <weight>/g, '<weight>')
.replace(/<weight>(.|\n)*?<\/weight>/g, '')
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/typegen', version: '4.11.2' };
export const packageInfo = { name: '@polkadot/typegen', version: '4.16.2' };
+3
View File
@@ -74,6 +74,9 @@ export function getSimilarTypes (registry: Registry, definitions: Record<string,
setImports(definitions, imports, ['IExtrinsic']);
return ['IExtrinsic'];
} else if (type === 'Keys') {
// This one is weird... surely it should popup as a Tuple? (but either way better as defined hex)
return ['Keys', 'string', 'Uint8Array'];
} else if (type === 'StorageKey') {
// TODO We can do better
return ['StorageKey', 'string', 'Uint8Array', 'any'];
+5 -9
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types-known",
"version": "4.11.2",
"version": "4.16.2",
"type": "module",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
@@ -19,13 +19,9 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
"dependencies": {
"@babel/runtime": "^7.14.0",
"@polkadot/networks": "^6.5.1",
"@polkadot/types": "4.11.2",
"@polkadot/util": "^6.5.1",
"bn.js": "^4.11.9"
},
"devDependencies": {
"@types/bn.js": "^4.11.6"
"@babel/runtime": "^7.14.6",
"@polkadot/networks": "^6.10.1",
"@polkadot/types": "4.16.2",
"@polkadot/util": "^6.10.1"
}
}
+1 -1
View File
@@ -3,11 +3,11 @@
import './detectPackage';
import type BN from 'bn.js';
import type { Text } from '@polkadot/types';
import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
import type { Hash } from '@polkadot/types/interfaces';
import type { ChainUpgradeVersion, CodecHasher, DefinitionRpc, DefinitionRpcSub, OverrideModuleType, OverrideVersionedType, Registry, RegistryTypes } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import { bnToBn, isUndefined } from '@polkadot/util';
+3
View File
@@ -17,6 +17,9 @@ const typesModules: Record<string, OverrideModuleType> = {
balances: {
Status: 'BalanceStatus'
},
beefy: {
AuthorityId: 'BeefyId'
},
contracts: {
StorageKey: 'ContractStorageKey'
},

Some files were not shown because too many files have changed in this diff Show More