Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ecd00a4e6 | ||
|
|
6239818c26 | ||
|
|
6af22f41c7 | ||
|
|
77c3a701d0 | ||
|
|
46b17a466c | ||
|
|
e592c6c878 | ||
|
|
ef37586dfc | ||
|
|
5856ce24cc | ||
|
|
8b79056bf9 | ||
|
|
70e0f19ade | ||
|
|
cf1e242c17 | ||
|
|
68856e9692 | ||
|
|
e0626c3dad | ||
|
|
277ea92fda | ||
|
|
aec6694028 | ||
|
|
533abb76f7 | ||
|
|
7660bab86b | ||
|
|
f7c1b6e81b | ||
|
|
b6e9b29570 | ||
|
|
519d9c8fa9 | ||
|
|
ad905db53b | ||
|
|
0a0aa742b4 | ||
|
|
dfbb06a4d6 | ||
|
|
82e71fd51e | ||
|
|
a8b88af97a | ||
|
|
eee36537de | ||
|
|
20a75eafb6 | ||
|
|
00d3a1174b | ||
|
|
e293c7c1cf | ||
|
|
3c8cd499c4 | ||
|
|
cb3816df78 | ||
|
|
fcfcbb2d97 | ||
|
|
321b80ed63 | ||
|
|
73eaa9fe17 |
@@ -1,5 +1,27 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 1.30.1 Aug 24, 2020
|
||||
|
||||
Upgrade priority: Low, unless using the `proposeParachain` module.
|
||||
|
||||
- Adjust balance retrievals to check for `system.account` for new/old determination
|
||||
- Add types for the new `proposeParachain` module (as per Rococo)
|
||||
- Adjust `Address` <-> `LookupSource` definitions (no external impact, both in existence)
|
||||
- Add Ethereum-compatible `Ethereum{AccountId, LookupSource}` types, underlying `H160`
|
||||
- Allow for configurable hashers via `registry.setHasher(...)` (defaults to `blake2AsU8a`)
|
||||
- `@polkadot/util` 3.3
|
||||
|
||||
## 1.29.1 Aug 17, 2020
|
||||
|
||||
Upgrade priority: Low, unless on bleeding-edge chain with new compact `CompactAssignments`.
|
||||
|
||||
- **Important** The Substrate `CompactAssignments` type has changed for better space utilization. On older chains, supply `CompactAssignments: 'CompactAssignmentsTo257'`
|
||||
- Clean tx cookbook param expansion (Thanks to https://github.com/swswsw)
|
||||
- Add additional `Fixed{I,U}{64,128}` and `{I,U}32F32` types
|
||||
- Add `desiredRunnersUp` to council derives
|
||||
- Cleanup indices/AccountId combination derive lookups
|
||||
- `@polkadot/util` 3.2
|
||||
|
||||
## 1.28.1 Aug 10, 2020
|
||||
|
||||
Upgrade priority: Low, unless using Centrifuge or parachains
|
||||
|
||||
+3
-3
@@ -16,9 +16,9 @@ const info = await api.tx.balances
|
||||
|
||||
// log relevant info, partialFee is Balance, estimated for current
|
||||
console.log(`
|
||||
class=${class.toString()},
|
||||
weight=${weight.toString()},
|
||||
partialFee=${partialFee.toHuman()}
|
||||
class=${info.class.toString()},
|
||||
weight=${info.weight.toString()},
|
||||
partialFee=${info.partialFee.toHuman()}
|
||||
`);
|
||||
```
|
||||
|
||||
|
||||
+1
-1
@@ -9,5 +9,5 @@
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "1.28.1"
|
||||
"version": "1.30.1"
|
||||
}
|
||||
|
||||
+6
-6
@@ -24,15 +24,15 @@
|
||||
"test:watch": "polkadot-dev-run-test --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.11.1",
|
||||
"@babel/core": "^7.11.4",
|
||||
"@babel/register": "^7.10.5",
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/dev": "^0.55.36",
|
||||
"@polkadot/ts": "^0.3.36",
|
||||
"@polkadot/dev": "^0.55.39",
|
||||
"@polkadot/ts": "^0.3.39",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^26.0.9",
|
||||
"@vuepress/plugin-search": "^1.5.3",
|
||||
"@types/jest": "^26.0.10",
|
||||
"@vuepress/plugin-search": "^1.5.4",
|
||||
"copyfiles": "^2.3.0"
|
||||
},
|
||||
"version": "1.28.1"
|
||||
"version": "1.30.1"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "1.28.1",
|
||||
"version": "1.30.1",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,11 +27,11 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/api": "1.28.1",
|
||||
"@polkadot/rpc-core": "1.28.1",
|
||||
"@polkadot/types": "1.28.1",
|
||||
"@polkadot/util": "^3.1.1",
|
||||
"bn.js": "^5.1.2",
|
||||
"@polkadot/api": "1.30.1",
|
||||
"@polkadot/rpc-core": "1.30.1",
|
||||
"@polkadot/types": "1.30.1",
|
||||
"@polkadot/util": "^3.3.1",
|
||||
"bn.js": "^5.1.3",
|
||||
"rxjs": "^6.6.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "1.28.1",
|
||||
"version": "1.30.1",
|
||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -28,17 +28,17 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/api": "1.28.1",
|
||||
"@polkadot/rpc-core": "1.28.1",
|
||||
"@polkadot/rpc-provider": "1.28.1",
|
||||
"@polkadot/types": "1.28.1",
|
||||
"@polkadot/util": "^3.1.1",
|
||||
"@polkadot/util-crypto": "^3.1.1",
|
||||
"bn.js": "^5.1.2",
|
||||
"@polkadot/api": "1.30.1",
|
||||
"@polkadot/rpc-core": "1.30.1",
|
||||
"@polkadot/rpc-provider": "1.30.1",
|
||||
"@polkadot/types": "1.30.1",
|
||||
"@polkadot/util": "^3.3.1",
|
||||
"@polkadot/util-crypto": "^3.3.1",
|
||||
"bn.js": "^5.1.3",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.1.1"
|
||||
"@polkadot/keyring": "^3.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIn
|
||||
|
||||
const accountIndex = api.registry.createType('AccountIndex', decoded);
|
||||
|
||||
return api.derive.accounts.indexToId(accountIndex).pipe(
|
||||
return api.derive.accounts.indexToId(accountIndex.toString()).pipe(
|
||||
map((accountId): AccountIdAndIndex => [accountId, accountIndex])
|
||||
);
|
||||
} catch (error) {
|
||||
|
||||
@@ -131,7 +131,7 @@ export function all (api: ApiInterfaceRx): (address: AccountIndex | AccountId |
|
||||
? combineLatest([
|
||||
of(account),
|
||||
api.derive.chain.bestNumber(),
|
||||
isFunction(api.query.balances.account)
|
||||
isFunction(api.query.system.account) || isFunction(api.query.balances.account)
|
||||
? queryCurrent(api, account.accountId)
|
||||
: queryOld(api, account.accountId)
|
||||
])
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
|
||||
import { AccountId, Balance, BlockNumber } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveElectionsInfo } from './types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Vec, u32 } from '@polkadot/types';
|
||||
|
||||
import { DeriveElectionsInfo } from '../types';
|
||||
import { memo } from '../util';
|
||||
|
||||
function sortAccounts ([, balanceA]: ITuple<[AccountId, Balance]>, [, balanceB]: ITuple<[AccountId, Balance]>): number {
|
||||
@@ -30,6 +30,7 @@ function queryElections (api: ApiInterfaceRx): Observable<DeriveElectionsInfo> {
|
||||
candidacyBond: api.consts[section].candidacyBond as Balance,
|
||||
candidateCount: api.registry.createType('u32', candidates.length),
|
||||
candidates,
|
||||
desiredRunnersUp: api.consts[section].desiredRunnersUp as u32,
|
||||
desiredSeats: api.consts[section].desiredMembers as u32,
|
||||
members: members.length
|
||||
? members.sort(sortAccounts)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, Balance, BlockNumber, SetIndex, VoteIndex } from '@polkadot/types/interfaces';
|
||||
|
||||
import { u32 } from '@polkadot/types';
|
||||
|
||||
export interface DeriveElectionsInfo {
|
||||
candidates: AccountId[];
|
||||
candidateCount: u32;
|
||||
candidacyBond?: Balance;
|
||||
desiredRunnersUp: u32;
|
||||
desiredSeats: u32;
|
||||
members: [AccountId, Balance][];
|
||||
nextVoterSet?: SetIndex;
|
||||
runnersUp: [AccountId, Balance][];
|
||||
termDuration: BlockNumber;
|
||||
voteCount?: VoteIndex;
|
||||
voterCount?: SetIndex;
|
||||
votingBond?: Balance;
|
||||
}
|
||||
@@ -3,13 +3,14 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import { AccountId, Balance, BalanceLock, BalanceLockTo212, BalanceOf, Bid, BidKind, BlockNumber, Hash, Index, Proposal, ProposalIndex, SetIndex, SocietyVote, StrikeCount, TreasuryProposal, Votes, VoteIndex, VouchingStatus } from '@polkadot/types/interfaces';
|
||||
import { AccountId, Balance, BalanceLock, BalanceLockTo212, BalanceOf, Bid, BidKind, BlockNumber, Hash, Index, Proposal, ProposalIndex, SetIndex, SocietyVote, StrikeCount, TreasuryProposal, Votes, VouchingStatus } from '@polkadot/types/interfaces';
|
||||
|
||||
import { u32 } from '@polkadot/types';
|
||||
|
||||
export * from './accounts/types';
|
||||
export * from './council/types';
|
||||
export * from './democracy/types';
|
||||
export * from './elections/types';
|
||||
export * from './parachains/types';
|
||||
export * from './session/types';
|
||||
export * from './staking/types';
|
||||
@@ -59,20 +60,6 @@ export interface DeriveCollectiveProposal {
|
||||
|
||||
export type DeriveCollectiveProposals = DeriveCollectiveProposal[];
|
||||
|
||||
export interface DeriveElectionsInfo {
|
||||
candidates: AccountId[];
|
||||
candidateCount: u32;
|
||||
candidacyBond?: Balance;
|
||||
desiredSeats: u32;
|
||||
members: [AccountId, Balance][];
|
||||
nextVoterSet?: SetIndex;
|
||||
runnersUp: [AccountId, Balance][];
|
||||
termDuration: BlockNumber;
|
||||
voteCount?: VoteIndex;
|
||||
voterCount?: SetIndex;
|
||||
votingBond?: Balance;
|
||||
}
|
||||
|
||||
export interface DeriveFees {
|
||||
creationFee: Balance;
|
||||
existentialDeposit: Balance;
|
||||
|
||||
+13
-13
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api",
|
||||
"version": "1.28.1",
|
||||
"version": "1.30.1",
|
||||
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,20 +27,20 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/api-derive": "1.28.1",
|
||||
"@polkadot/keyring": "^3.1.1",
|
||||
"@polkadot/metadata": "1.28.1",
|
||||
"@polkadot/rpc-core": "1.28.1",
|
||||
"@polkadot/rpc-provider": "1.28.1",
|
||||
"@polkadot/types": "1.28.1",
|
||||
"@polkadot/types-known": "1.28.1",
|
||||
"@polkadot/util": "^3.1.1",
|
||||
"@polkadot/util-crypto": "^3.1.1",
|
||||
"bn.js": "^5.1.2",
|
||||
"eventemitter3": "^4.0.4",
|
||||
"@polkadot/api-derive": "1.30.1",
|
||||
"@polkadot/keyring": "^3.3.1",
|
||||
"@polkadot/metadata": "1.30.1",
|
||||
"@polkadot/rpc-core": "1.30.1",
|
||||
"@polkadot/rpc-provider": "1.30.1",
|
||||
"@polkadot/types": "1.30.1",
|
||||
"@polkadot/types-known": "1.30.1",
|
||||
"@polkadot/util": "^3.3.1",
|
||||
"@polkadot/util-crypto": "^3.3.1",
|
||||
"bn.js": "^5.1.3",
|
||||
"eventemitter3": "^4.0.5",
|
||||
"rxjs": "^6.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.1.1"
|
||||
"@polkadot/keyring": "^3.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* not assumed to be in the overlay.
|
||||
* # </weight>
|
||||
**/
|
||||
forceTransfer: AugmentedSubmittable<(source: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
forceTransfer: AugmentedSubmittable<(source: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, dest: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Set the balances of a given account.
|
||||
*
|
||||
@@ -85,7 +85,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - DB Weight: 1 Read, 1 Write to `who`
|
||||
* # </weight>
|
||||
**/
|
||||
setBalance: AugmentedSubmittable<(who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, newFree: Compact<Balance> | AnyNumber | Uint8Array, newReserved: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
setBalance: AugmentedSubmittable<(who: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, newFree: Compact<Balance> | AnyNumber | Uint8Array, newReserved: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Transfer some liquid free balance to another account.
|
||||
*
|
||||
@@ -115,7 +115,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Origin account is already in memory, so no DB operations for them.
|
||||
* # </weight>
|
||||
**/
|
||||
transfer: AugmentedSubmittable<(dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
transfer: AugmentedSubmittable<(dest: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Same as the [`transfer`] call, but with a check that the transfer will not kill the
|
||||
* origin account.
|
||||
@@ -129,7 +129,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - DB Weight: 1 Read and 1 Write to dest (sender is in overlay already)
|
||||
* #</weight>
|
||||
**/
|
||||
transferKeepAlive: AugmentedSubmittable<(dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
transferKeepAlive: AugmentedSubmittable<(dest: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
};
|
||||
contracts: {
|
||||
[index: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
@@ -142,7 +142,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* * If no account exists and the call value is not less than `existential_deposit`,
|
||||
* a regular account will be created and any value will be transferred.
|
||||
**/
|
||||
call: AugmentedSubmittable<(dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Gas> | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
call: AugmentedSubmittable<(dest: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Gas> | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Allows block producers to claim a small reward for evicting a contract. If a block producer
|
||||
* fails to do so, a regular users will be allowed to claim the reward.
|
||||
@@ -740,7 +740,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* Else, since this is a root call and will go into phragmen, we assume full block for now.
|
||||
* # </weight>
|
||||
**/
|
||||
removeMember: AugmentedSubmittable<(who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, hasReplacement: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
removeMember: AugmentedSubmittable<(who: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, hasReplacement: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Remove `origin` as a voter. This removes the lock and returns the bond.
|
||||
*
|
||||
@@ -948,7 +948,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* The dispatch origin for this call must be _Signed_ and the sender must have a registered
|
||||
* sub identity of `sub`.
|
||||
**/
|
||||
addSub: AugmentedSubmittable<(sub: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, data: Data | { None: any } | { Raw: any } | { BlakeTwo256: any } | { Sha256: any } | { Keccak256: any } | { ShaThree256: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
addSub: AugmentedSubmittable<(sub: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, data: Data | { None: any } | { Raw: any } | { BlakeTwo256: any } | { Sha256: any } | { Keccak256: any } | { ShaThree256: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Cancel a previous request.
|
||||
*
|
||||
@@ -1011,7 +1011,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - One event.
|
||||
* # </weight>
|
||||
**/
|
||||
killIdentity: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
killIdentity: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Provide a judgement for an account's identity.
|
||||
*
|
||||
@@ -1033,7 +1033,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - One event.
|
||||
* # </weight>
|
||||
**/
|
||||
provideJudgement: AugmentedSubmittable<(regIndex: Compact<RegistrarIndex> | AnyNumber | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, judgement: IdentityJudgement | { Unknown: any } | { FeePaid: any } | { Reasonable: any } | { KnownGood: any } | { OutOfDate: any } | { LowQuality: any } | { Erroneous: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
provideJudgement: AugmentedSubmittable<(regIndex: Compact<RegistrarIndex> | AnyNumber | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, judgement: IdentityJudgement | { Unknown: any } | { FeePaid: any } | { Reasonable: any } | { KnownGood: any } | { OutOfDate: any } | { LowQuality: any } | { Erroneous: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Remove the sender as a sub-account.
|
||||
*
|
||||
@@ -1056,14 +1056,14 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* The dispatch origin for this call must be _Signed_ and the sender must have a registered
|
||||
* sub identity of `sub`.
|
||||
**/
|
||||
removeSub: AugmentedSubmittable<(sub: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
removeSub: AugmentedSubmittable<(sub: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Alter the associated name of the given sub-account.
|
||||
*
|
||||
* The dispatch origin for this call must be _Signed_ and the sender must have a registered
|
||||
* sub identity of `sub`.
|
||||
**/
|
||||
renameSub: AugmentedSubmittable<(sub: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, data: Data | { None: any } | { Raw: any } | { BlakeTwo256: any } | { Sha256: any } | { Keccak256: any } | { ShaThree256: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
renameSub: AugmentedSubmittable<(sub: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, data: Data | { None: any } | { Raw: any } | { BlakeTwo256: any } | { Sha256: any } | { Keccak256: any } | { ShaThree256: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Request a judgement from a registrar.
|
||||
*
|
||||
@@ -2165,7 +2165,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* Total Complexity: O(M + logM + C)
|
||||
* # </weight>
|
||||
**/
|
||||
vote: AugmentedSubmittable<(candidate: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
vote: AugmentedSubmittable<(candidate: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* As a member, vouch for someone to join society by placing a bid on their behalf.
|
||||
*
|
||||
@@ -2240,7 +2240,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Write: Bonded, Payee, [Origin Account], Locks, Ledger
|
||||
* # </weight>
|
||||
**/
|
||||
bond: AugmentedSubmittable<(controller: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, payee: RewardDestination | 'Staked'|'Stash'|'Controller' | number | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
bond: AugmentedSubmittable<(controller: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, payee: RewardDestination | 'Staked'|'Stash'|'Controller' | number | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Add some extra amount that have appeared in the stash `free_balance` into the balance up
|
||||
* for staking.
|
||||
@@ -2385,7 +2385,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Writes: Validators, Nominators
|
||||
* # </weight>
|
||||
**/
|
||||
nominate: AugmentedSubmittable<(targets: Vec<LookupSource> | (LookupSource | Address | AccountId | AccountIndex | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>>;
|
||||
nominate: AugmentedSubmittable<(targets: Vec<LookupSource> | (LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Pay out all the stakers behind a single validator for a single era.
|
||||
*
|
||||
@@ -2480,7 +2480,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Write: Bonded, Ledger New Controller, Ledger Old Controller
|
||||
* # </weight>
|
||||
**/
|
||||
setController: AugmentedSubmittable<(controller: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
setController: AugmentedSubmittable<(controller: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Set `HistoryDepth` value. This function will delete any history information
|
||||
* when `HistoryDepth` is reduced.
|
||||
@@ -2711,7 +2711,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - One DB change.
|
||||
* # </weight>
|
||||
**/
|
||||
setKey: AugmentedSubmittable<(updated: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
setKey: AugmentedSubmittable<(updated: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Authenticates the sudo key and dispatches a function call with `Root` origin.
|
||||
*
|
||||
@@ -2738,7 +2738,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Weight of derivative `call` execution + 10,000.
|
||||
* # </weight>
|
||||
**/
|
||||
sudoAs: AugmentedSubmittable<(who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
sudoAs: AugmentedSubmittable<(who: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Authenticates the sudo key and dispatches a function call with `Root` origin.
|
||||
* This function does not check the weight of the call, and instead allows the
|
||||
@@ -3122,7 +3122,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - DbWrites: `ProposalCount`, `Proposals`, `origin account`
|
||||
* # </weight>
|
||||
**/
|
||||
proposeSpend: AugmentedSubmittable<(value: Compact<BalanceOf> | AnyNumber | Uint8Array, beneficiary: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
proposeSpend: AugmentedSubmittable<(value: Compact<BalanceOf> | AnyNumber | Uint8Array, beneficiary: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Reject a proposed spend. The original deposit will be slashed.
|
||||
*
|
||||
@@ -3303,7 +3303,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Using 100 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
|
||||
* # </weight>
|
||||
**/
|
||||
forceVestedTransfer: AugmentedSubmittable<(source: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
forceVestedTransfer: AugmentedSubmittable<(source: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Unlock any vested funds of the sender account.
|
||||
*
|
||||
@@ -3345,7 +3345,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Using 50 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
|
||||
* # </weight>
|
||||
**/
|
||||
vestOther: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
vestOther: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Create a vested transfer.
|
||||
*
|
||||
@@ -3366,7 +3366,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Using 100 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
|
||||
* # </weight>
|
||||
**/
|
||||
vestedTransfer: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
vestedTransfer: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/metadata",
|
||||
"version": "1.28.1",
|
||||
"version": "1.30.1",
|
||||
"description": "Helpers to extract information from runtime metadata",
|
||||
"main": "index.js",
|
||||
"publishConfig": {
|
||||
@@ -27,13 +27,13 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/types": "1.28.1",
|
||||
"@polkadot/types-known": "1.28.1",
|
||||
"@polkadot/util": "^3.1.1",
|
||||
"@polkadot/util-crypto": "^3.1.1",
|
||||
"bn.js": "^5.1.2"
|
||||
"@polkadot/types": "1.30.1",
|
||||
"@polkadot/types-known": "1.30.1",
|
||||
"@polkadot/util": "^3.3.1",
|
||||
"@polkadot/util-crypto": "^3.3.1",
|
||||
"bn.js": "^5.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.1.1"
|
||||
"@polkadot/keyring": "^3.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-core",
|
||||
"version": "1.28.1",
|
||||
"version": "1.30.1",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,14 +27,14 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/metadata": "1.28.1",
|
||||
"@polkadot/rpc-provider": "1.28.1",
|
||||
"@polkadot/types": "1.28.1",
|
||||
"@polkadot/util": "^3.1.1",
|
||||
"@polkadot/metadata": "1.30.1",
|
||||
"@polkadot/rpc-provider": "1.30.1",
|
||||
"@polkadot/types": "1.30.1",
|
||||
"@polkadot/util": "^3.3.1",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.1.1"
|
||||
"@polkadot/keyring": "^3.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-provider",
|
||||
"version": "1.28.1",
|
||||
"version": "1.30.1",
|
||||
"description": "Transport providers for the API",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,18 +27,18 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/metadata": "1.28.1",
|
||||
"@polkadot/types": "1.28.1",
|
||||
"@polkadot/util": "^3.1.1",
|
||||
"@polkadot/util-crypto": "^3.1.1",
|
||||
"bn.js": "^5.1.2",
|
||||
"eventemitter3": "^4.0.4",
|
||||
"@polkadot/metadata": "1.30.1",
|
||||
"@polkadot/types": "1.30.1",
|
||||
"@polkadot/util": "^3.3.1",
|
||||
"@polkadot/util-crypto": "^3.3.1",
|
||||
"bn.js": "^5.1.3",
|
||||
"eventemitter3": "^4.0.5",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
"websocket": "^1.0.31"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.1.1",
|
||||
"@polkadot/keyring": "^3.3.1",
|
||||
"mock-socket": "^9.0.3",
|
||||
"nock": "^13.0.3"
|
||||
"nock": "^13.0.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/typegen",
|
||||
"version": "1.28.1",
|
||||
"version": "1.30.1",
|
||||
"description": "Type generation scripts",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
@@ -33,14 +33,14 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.11.1",
|
||||
"@babel/core": "^7.11.4",
|
||||
"@babel/register": "^7.10.5",
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/api": "1.28.1",
|
||||
"@polkadot/metadata": "1.28.1",
|
||||
"@polkadot/rpc-provider": "1.28.1",
|
||||
"@polkadot/types": "1.28.1",
|
||||
"@polkadot/util": "^3.1.1",
|
||||
"@polkadot/api": "1.30.1",
|
||||
"@polkadot/metadata": "1.30.1",
|
||||
"@polkadot/rpc-provider": "1.30.1",
|
||||
"@polkadot/types": "1.30.1",
|
||||
"@polkadot/util": "^3.3.1",
|
||||
"handlebars": "^4.7.6",
|
||||
"websocket": "^1.0.31",
|
||||
"yargs": "^15.4.1"
|
||||
|
||||
@@ -16,7 +16,7 @@ import Vec from '@polkadot/types/codec/Vec';
|
||||
import Tuple from '@polkadot/types/codec/Tuple';
|
||||
import { AllConvictions } from '@polkadot/types/interfaces/democracy/definitions';
|
||||
import GenericAccountId from '@polkadot/types/generic/AccountId';
|
||||
import GenericAddress from '@polkadot/types/generic/Address';
|
||||
import GenericLookupSource from '@polkadot/types/generic/LookupSource';
|
||||
import Vote from '@polkadot/types/generic/Vote';
|
||||
import Null from '@polkadot/types/primitive/Null';
|
||||
import * as primitiveClasses from '@polkadot/types/primitive';
|
||||
@@ -122,8 +122,8 @@ export function getSimilarTypes (definitions: Record<string, ModuleTypes>, regis
|
||||
possibleTypes.push('Uint8Array');
|
||||
} else if (isChildClass(AbstractInt as unknown as Constructor<UInt>, Clazz) || isChildClass(Compact, Clazz)) {
|
||||
possibleTypes.push('AnyNumber', 'Uint8Array');
|
||||
} else if (isChildClass(GenericAddress, Clazz)) {
|
||||
possibleTypes.push('Address', 'AccountId', 'AccountIndex', 'string', 'Uint8Array');
|
||||
} else if (isChildClass(GenericLookupSource, Clazz)) {
|
||||
possibleTypes.push('Address', 'AccountId', 'AccountIndex', 'LookupSource', 'string', 'Uint8Array');
|
||||
} else if (isChildClass(GenericAccountId, Clazz)) {
|
||||
possibleTypes.push('string', 'Uint8Array');
|
||||
} else if (isChildClass(registry.createClass('bool'), Clazz)) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types-known",
|
||||
"version": "1.28.1",
|
||||
"version": "1.30.1",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,9 +27,9 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/types": "1.28.1",
|
||||
"@polkadot/util": "^3.1.1",
|
||||
"bn.js": "^5.1.2"
|
||||
"@polkadot/types": "1.30.1",
|
||||
"@polkadot/util": "^3.3.1",
|
||||
"bn.js": "^5.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bn.js": "^4.11.6"
|
||||
|
||||
@@ -29,6 +29,9 @@ const typesModules: Record<string, OverrideModuleType> = {
|
||||
parachains: {
|
||||
Id: 'ParaId'
|
||||
},
|
||||
proposeParachain: {
|
||||
Proposal: 'ParachainProposal'
|
||||
},
|
||||
proxy: {
|
||||
Announcement: 'ProxyAnnouncement'
|
||||
},
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
const sharedTypes = {
|
||||
Address: 'GenericAddress',
|
||||
Address: 'LookupSource',
|
||||
AnchorData: {
|
||||
anchoredBlock: 'u64',
|
||||
docRoot: 'H256',
|
||||
@@ -15,7 +15,6 @@ const sharedTypes = {
|
||||
key: 'Hash',
|
||||
price: 'Balance'
|
||||
},
|
||||
LookupSource: 'GenericAddress',
|
||||
MultiAccountData: {
|
||||
deposit: 'Balance',
|
||||
depositor: 'AccountId',
|
||||
|
||||
@@ -18,12 +18,12 @@ const versioned: OverrideVersionedType[] = [
|
||||
// 1020 is first CC3
|
||||
minmax: [1019, 1031],
|
||||
types: {
|
||||
Address: 'GenericAddress',
|
||||
Address: 'LookupSource',
|
||||
BalanceLock: 'BalanceLockTo212',
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchError: 'DispatchErrorTo198',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'Address',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
ReferendumInfo: 'ReferendumInfoTo239',
|
||||
@@ -36,11 +36,11 @@ const versioned: OverrideVersionedType[] = [
|
||||
{
|
||||
minmax: [1032, 1042],
|
||||
types: {
|
||||
Address: 'GenericAddress',
|
||||
Address: 'LookupSource',
|
||||
BalanceLock: 'BalanceLockTo212',
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'Address',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
ReferendumInfo: 'ReferendumInfoTo239',
|
||||
@@ -54,11 +54,11 @@ const versioned: OverrideVersionedType[] = [
|
||||
// actual at 1045 (1043-1044 is dev)
|
||||
minmax: [1043, 1045],
|
||||
types: {
|
||||
Address: 'GenericAddress',
|
||||
Address: 'LookupSource',
|
||||
BalanceLock: 'BalanceLockTo212',
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'Address',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
ReferendumInfo: 'ReferendumInfoTo239',
|
||||
@@ -72,6 +72,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
types: {
|
||||
// Indices optional, not in transaction
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
@@ -84,6 +85,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [1055, 1056],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
@@ -95,6 +97,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [1057, 1061],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
OpenTip: 'OpenTipTo225'
|
||||
}
|
||||
@@ -103,13 +106,15 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [1062, 2012],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
OpenTip: 'OpenTipTo225'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [2013, undefined],
|
||||
types: {
|
||||
...sharedTypes
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -19,13 +19,15 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [0, 12],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
OpenTip: 'OpenTipTo225'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [13, undefined],
|
||||
types: {
|
||||
...sharedTypes
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -14,7 +14,8 @@ const versioned: OverrideVersionedType[] = [
|
||||
{
|
||||
minmax: [0, undefined],
|
||||
types: {
|
||||
...sharedTypes
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -18,6 +18,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [1, 2],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
Weight: 'u32'
|
||||
@@ -27,13 +28,15 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [3, 22],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
OpenTip: 'OpenTipTo225'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [23, undefined],
|
||||
types: {
|
||||
...sharedTypes
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types",
|
||||
"version": "1.28.1",
|
||||
"version": "1.30.1",
|
||||
"description": "Implementation of the Parity codec",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,16 +27,16 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/metadata": "1.28.1",
|
||||
"@polkadot/util": "^3.1.1",
|
||||
"@polkadot/util-crypto": "^3.1.1",
|
||||
"@polkadot/metadata": "1.30.1",
|
||||
"@polkadot/util": "^3.3.1",
|
||||
"@polkadot/util-crypto": "^3.3.1",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^5.1.2",
|
||||
"bn.js": "^5.1.3",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.1.1",
|
||||
"@polkadot/keyring": "^3.3.1",
|
||||
"@types/memoizee": "^0.4.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, C
|
||||
import { AccountVote, AccountVoteSplit, AccountVoteStandard, Conviction, Delegations, PreimageStatus, PreimageStatusAvailable, PriorLock, PropIndex, Proposal, ProxyState, ReferendumIndex, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, ReferendumStatus, Tally, Voting, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces/democracy';
|
||||
import { ApprovalFlag, DefunctVoter, Renouncing, SetIndex, Vote, VoteIndex, VoteThreshold, VoterInfo } from '@polkadot/types/interfaces/elections';
|
||||
import { CreatedBlock, ImportedAux } from '@polkadot/types/interfaces/engine';
|
||||
import { EthereumAccountId, EthereumLookupSource } from '@polkadot/types/interfaces/ethereum';
|
||||
import { Account, Log, Vicinity } from '@polkadot/types/interfaces/evm';
|
||||
import { EcdsaSignature, Ed25519Signature, Extrinsic, ExtrinsicEra, ExtrinsicPayload, ExtrinsicPayloadUnknown, ExtrinsicPayloadV1, ExtrinsicPayloadV2, ExtrinsicPayloadV3, ExtrinsicPayloadV4, ExtrinsicSignatureV1, ExtrinsicSignatureV2, ExtrinsicSignatureV3, ExtrinsicSignatureV4, ExtrinsicUnknown, ExtrinsicV1, ExtrinsicV2, ExtrinsicV3, ExtrinsicV4, ImmortalEra, MortalEra, MultiSignature, Signature, SignerPayload, Sr25519Signature } from '@polkadot/types/interfaces/extrinsics';
|
||||
import { AssetOptions, Owner, PermissionLatest, PermissionVersions, PermissionsV1 } from '@polkadot/types/interfaces/genericAsset';
|
||||
@@ -27,18 +28,18 @@ import { AuthIndex, AuthoritySignature, Heartbeat, HeartbeatTo244, OpaqueMultiad
|
||||
import { CallMetadataV0, DoubleMapTypeLatest, DoubleMapTypeV10, DoubleMapTypeV11, DoubleMapTypeV3, DoubleMapTypeV4, DoubleMapTypeV5, DoubleMapTypeV6, DoubleMapTypeV7, DoubleMapTypeV8, DoubleMapTypeV9, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV8, ErrorMetadataV9, EventMetadataLatest, EventMetadataV0, EventMetadataV1, EventMetadataV10, EventMetadataV11, EventMetadataV2, EventMetadataV3, EventMetadataV4, EventMetadataV5, EventMetadataV6, EventMetadataV7, EventMetadataV8, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV0, FunctionArgumentMetadataV1, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV2, FunctionArgumentMetadataV3, FunctionArgumentMetadataV4, FunctionArgumentMetadataV5, FunctionArgumentMetadataV6, FunctionArgumentMetadataV7, FunctionArgumentMetadataV8, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV0, FunctionMetadataV1, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV2, FunctionMetadataV3, FunctionMetadataV4, FunctionMetadataV5, FunctionMetadataV6, FunctionMetadataV7, FunctionMetadataV8, FunctionMetadataV9, MapTypeLatest, MapTypeV0, MapTypeV10, MapTypeV11, MapTypeV2, MapTypeV3, MapTypeV4, MapTypeV5, MapTypeV6, MapTypeV7, MapTypeV8, MapTypeV9, MetadataAll, MetadataLatest, MetadataV0, MetadataV1, MetadataV10, MetadataV11, MetadataV2, MetadataV3, MetadataV4, MetadataV5, MetadataV6, MetadataV7, MetadataV8, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV6, ModuleConstantMetadataV7, ModuleConstantMetadataV8, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV0, ModuleMetadataV1, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV2, ModuleMetadataV3, ModuleMetadataV4, ModuleMetadataV5, ModuleMetadataV6, ModuleMetadataV7, ModuleMetadataV8, ModuleMetadataV9, OuterDispatchCallV0, OuterDispatchMetadataV0, OuterEventEventMetadataEventsV0, OuterEventEventMetadataV0, OuterEventMetadataV0, PlainTypeLatest, PlainTypeV0, PlainTypeV10, PlainTypeV11, PlainTypeV2, PlainTypeV3, PlainTypeV4, PlainTypeV5, PlainTypeV6, PlainTypeV7, PlainTypeV8, PlainTypeV9, RuntimeModuleMetadataV0, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV6, StorageEntryMetadataV7, StorageEntryMetadataV8, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV6, StorageEntryModifierV7, StorageEntryModifierV8, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV6, StorageEntryTypeV7, StorageEntryTypeV8, StorageEntryTypeV9, StorageFunctionMetadataV0, StorageFunctionMetadataV1, StorageFunctionMetadataV2, StorageFunctionMetadataV3, StorageFunctionMetadataV4, StorageFunctionMetadataV5, StorageFunctionModifierV0, StorageFunctionModifierV1, StorageFunctionModifierV2, StorageFunctionModifierV3, StorageFunctionModifierV4, StorageFunctionModifierV5, StorageFunctionTypeV0, StorageFunctionTypeV1, StorageFunctionTypeV2, StorageFunctionTypeV3, StorageFunctionTypeV4, StorageFunctionTypeV5, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV4, StorageHasherV5, StorageHasherV6, StorageHasherV7, StorageHasherV8, StorageHasherV9, StorageMetadataLatest, StorageMetadataV0, StorageMetadataV10, StorageMetadataV11, StorageMetadataV7, StorageMetadataV8, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
|
||||
import { StorageKind } from '@polkadot/types/interfaces/offchain';
|
||||
import { DeferredOffenceOf, Kind, OffenceDetails, Offender, OpaqueTimeSlot, ReportIdOf, Reporter } from '@polkadot/types/interfaces/offences';
|
||||
import { AbridgedCandidateReceipt, AttestedCandidate, AuctionIndex, Bidder, CandidateCommitments, CandidateReceipt, CollatorId, CollatorSignature, DoubleVoteReport, DownwardMessage, GlobalValidationSchedule, HeadData, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, LeasePeriod, LeasePeriodOf, LocalValidationData, NewBidder, ParaId, ParaInfo, ParaPastCodeMeta, ParaScheduling, ParachainDispatchOrigin, RelayChainBlockNumber, Remark, Retriable, Scheduling, SigningContext, SlotRange, Statement, SubId, UpwardMessage, ValidationCode, ValidationFunctionParams, ValidatorSignature, ValidityAttestation, WinningData, WinningDataEntry } from '@polkadot/types/interfaces/parachains';
|
||||
import { AbridgedCandidateReceipt, AttestedCandidate, AuctionIndex, Bidder, CandidateCommitments, CandidateReceipt, CollatorId, CollatorSignature, DoubleVoteReport, DownwardMessage, GlobalValidationSchedule, HeadData, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, LeasePeriod, LeasePeriodOf, LocalValidationData, NewBidder, ParaId, ParaInfo, ParaPastCodeMeta, ParaScheduling, ParachainDispatchOrigin, ParachainProposal, RegisteredParachainInfo, RelayChainBlockNumber, Remark, Retriable, Scheduling, SigningContext, SlotRange, Statement, SubId, UpwardMessage, ValidationCode, ValidationFunctionParams, ValidatorSignature, ValidityAttestation, WinningData, WinningDataEntry } from '@polkadot/types/interfaces/parachains';
|
||||
import { RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
|
||||
import { Approvals } from '@polkadot/types/interfaces/poll';
|
||||
import { ProxyAnnouncement, ProxyDefinition, ProxyType } from '@polkadot/types/interfaces/proxy';
|
||||
import { AccountStatus, AccountValidity } from '@polkadot/types/interfaces/purchase';
|
||||
import { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
|
||||
import { RpcMethods } from '@polkadot/types/interfaces/rpc';
|
||||
import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, CallHash, CallHashOf, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, ExtrinsicsWeight, Fixed128, Fixed64, H160, H256, H512, Hash, Header, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, OpaqueCall, Origin, Pays, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, StorageData, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
|
||||
import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, CallHash, CallHashOf, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, GenericAddress, H160, H256, H512, Hash, Header, I32F32, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, OpaqueCall, Origin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, StorageData, U32F32, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
|
||||
import { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
|
||||
import { FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, ValidatorCount } from '@polkadot/types/interfaces/session';
|
||||
import { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
|
||||
import { ActiveEraInfo, CompactAssignments, CompactScore, ElectionCompute, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, OffchainAccuracy, PerU16, PhragmenScore, Points, RewardDestination, RewardPoint, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking';
|
||||
import { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactScore, CompactScoreCompact, ElectionCompute, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, NominatorIndexCompact, OffchainAccuracy, OffchainAccuracyCompact, PhragmenScore, Points, RewardDestination, RewardPoint, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorIndexCompact, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking';
|
||||
import { ApiId, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from '@polkadot/types/interfaces/state';
|
||||
import { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
|
||||
import { AccountInfo, ApplyExtrinsicResult, ChainProperties, ChainType, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, EventRecordTo76, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, Phase, RefCount, TransactionValidityError, UnknownTransaction } from '@polkadot/types/interfaces/system';
|
||||
@@ -129,6 +130,50 @@ declare module '@polkadot/types/types/registry' {
|
||||
Raw: Raw;
|
||||
'Option<Raw>': Option<Raw>;
|
||||
'Vec<Raw>': Vec<Raw>;
|
||||
Fixed64: Fixed64;
|
||||
'Option<Fixed64>': Option<Fixed64>;
|
||||
'Vec<Fixed64>': Vec<Fixed64>;
|
||||
FixedI64: FixedI64;
|
||||
'Option<FixedI64>': Option<FixedI64>;
|
||||
'Vec<FixedI64>': Vec<FixedI64>;
|
||||
FixedU64: FixedU64;
|
||||
'Option<FixedU64>': Option<FixedU64>;
|
||||
'Vec<FixedU64>': Vec<FixedU64>;
|
||||
Fixed128: Fixed128;
|
||||
'Option<Fixed128>': Option<Fixed128>;
|
||||
'Vec<Fixed128>': Vec<Fixed128>;
|
||||
FixedI128: FixedI128;
|
||||
'Option<FixedI128>': Option<FixedI128>;
|
||||
'Vec<FixedI128>': Vec<FixedI128>;
|
||||
FixedU128: FixedU128;
|
||||
'Option<FixedU128>': Option<FixedU128>;
|
||||
'Vec<FixedU128>': Vec<FixedU128>;
|
||||
I32F32: I32F32;
|
||||
'Option<I32F32>': Option<I32F32>;
|
||||
'Vec<I32F32>': Vec<I32F32>;
|
||||
U32F32: U32F32;
|
||||
'Option<U32F32>': Option<U32F32>;
|
||||
'Vec<U32F32>': Vec<U32F32>;
|
||||
PerU16: PerU16;
|
||||
'Compact<PerU16>': Compact<PerU16>;
|
||||
'Option<PerU16>': Option<PerU16>;
|
||||
'Vec<PerU16>': Vec<PerU16>;
|
||||
Perbill: Perbill;
|
||||
'Compact<Perbill>': Compact<Perbill>;
|
||||
'Option<Perbill>': Option<Perbill>;
|
||||
'Vec<Perbill>': Vec<Perbill>;
|
||||
Percent: Percent;
|
||||
'Compact<Percent>': Compact<Percent>;
|
||||
'Option<Percent>': Option<Percent>;
|
||||
'Vec<Percent>': Vec<Percent>;
|
||||
Permill: Permill;
|
||||
'Compact<Permill>': Compact<Permill>;
|
||||
'Option<Permill>': Option<Permill>;
|
||||
'Vec<Permill>': Vec<Permill>;
|
||||
Perquintill: Perquintill;
|
||||
'Compact<Perquintill>': Compact<Perquintill>;
|
||||
'Option<Perquintill>': Option<Perquintill>;
|
||||
'Vec<Perquintill>': Vec<Perquintill>;
|
||||
AccountId: AccountId;
|
||||
'Option<AccountId>': Option<AccountId>;
|
||||
'Vec<AccountId>': Vec<AccountId>;
|
||||
@@ -183,12 +228,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
ExtrinsicsWeight: ExtrinsicsWeight;
|
||||
'Option<ExtrinsicsWeight>': Option<ExtrinsicsWeight>;
|
||||
'Vec<ExtrinsicsWeight>': Vec<ExtrinsicsWeight>;
|
||||
Fixed64: Fixed64;
|
||||
'Option<Fixed64>': Option<Fixed64>;
|
||||
'Vec<Fixed64>': Vec<Fixed64>;
|
||||
Fixed128: Fixed128;
|
||||
'Option<Fixed128>': Option<Fixed128>;
|
||||
'Vec<Fixed128>': Vec<Fixed128>;
|
||||
GenericAddress: GenericAddress;
|
||||
'Option<GenericAddress>': Option<GenericAddress>;
|
||||
'Vec<GenericAddress>': Vec<GenericAddress>;
|
||||
H160: H160;
|
||||
'Option<H160>': Option<H160>;
|
||||
'Vec<H160>': Vec<H160>;
|
||||
@@ -243,22 +285,6 @@ declare module '@polkadot/types/types/registry' {
|
||||
Pays: Pays;
|
||||
'Option<Pays>': Option<Pays>;
|
||||
'Vec<Pays>': Vec<Pays>;
|
||||
Perbill: Perbill;
|
||||
'Compact<Perbill>': Compact<Perbill>;
|
||||
'Option<Perbill>': Option<Perbill>;
|
||||
'Vec<Perbill>': Vec<Perbill>;
|
||||
Percent: Percent;
|
||||
'Compact<Percent>': Compact<Percent>;
|
||||
'Option<Percent>': Option<Percent>;
|
||||
'Vec<Percent>': Vec<Percent>;
|
||||
Permill: Permill;
|
||||
'Compact<Permill>': Compact<Permill>;
|
||||
'Option<Permill>': Option<Permill>;
|
||||
'Vec<Permill>': Vec<Permill>;
|
||||
Perquintill: Perquintill;
|
||||
'Compact<Perquintill>': Compact<Perquintill>;
|
||||
'Option<Perquintill>': Option<Perquintill>;
|
||||
'Vec<Perquintill>': Vec<Perquintill>;
|
||||
Phantom: Phantom;
|
||||
'Option<Phantom>': Option<Phantom>;
|
||||
'Vec<Phantom>': Vec<Phantom>;
|
||||
@@ -897,9 +923,15 @@ declare module '@polkadot/types/types/registry' {
|
||||
CompactAssignments: CompactAssignments;
|
||||
'Option<CompactAssignments>': Option<CompactAssignments>;
|
||||
'Vec<CompactAssignments>': Vec<CompactAssignments>;
|
||||
CompactAssignmentsTo257: CompactAssignmentsTo257;
|
||||
'Option<CompactAssignmentsTo257>': Option<CompactAssignmentsTo257>;
|
||||
'Vec<CompactAssignmentsTo257>': Vec<CompactAssignmentsTo257>;
|
||||
CompactScore: CompactScore;
|
||||
'Option<CompactScore>': Option<CompactScore>;
|
||||
'Vec<CompactScore>': Vec<CompactScore>;
|
||||
CompactScoreCompact: CompactScoreCompact;
|
||||
'Option<CompactScoreCompact>': Option<CompactScoreCompact>;
|
||||
'Vec<CompactScoreCompact>': Vec<CompactScoreCompact>;
|
||||
ElectionCompute: ElectionCompute;
|
||||
'Option<ElectionCompute>': Option<ElectionCompute>;
|
||||
'Vec<ElectionCompute>': Vec<ElectionCompute>;
|
||||
@@ -947,13 +979,15 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Compact<NominatorIndex>': Compact<NominatorIndex>;
|
||||
'Option<NominatorIndex>': Option<NominatorIndex>;
|
||||
'Vec<NominatorIndex>': Vec<NominatorIndex>;
|
||||
NominatorIndexCompact: NominatorIndexCompact;
|
||||
'Option<NominatorIndexCompact>': Option<NominatorIndexCompact>;
|
||||
'Vec<NominatorIndexCompact>': Vec<NominatorIndexCompact>;
|
||||
OffchainAccuracy: OffchainAccuracy;
|
||||
'Option<OffchainAccuracy>': Option<OffchainAccuracy>;
|
||||
'Vec<OffchainAccuracy>': Vec<OffchainAccuracy>;
|
||||
PerU16: PerU16;
|
||||
'Compact<PerU16>': Compact<PerU16>;
|
||||
'Option<PerU16>': Option<PerU16>;
|
||||
'Vec<PerU16>': Vec<PerU16>;
|
||||
OffchainAccuracyCompact: OffchainAccuracyCompact;
|
||||
'Option<OffchainAccuracyCompact>': Option<OffchainAccuracyCompact>;
|
||||
'Vec<OffchainAccuracyCompact>': Vec<OffchainAccuracyCompact>;
|
||||
PhragmenScore: PhragmenScore;
|
||||
'Option<PhragmenScore>': Option<PhragmenScore>;
|
||||
'Vec<PhragmenScore>': Vec<PhragmenScore>;
|
||||
@@ -1002,6 +1036,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Compact<ValidatorIndex>': Compact<ValidatorIndex>;
|
||||
'Option<ValidatorIndex>': Option<ValidatorIndex>;
|
||||
'Vec<ValidatorIndex>': Vec<ValidatorIndex>;
|
||||
ValidatorIndexCompact: ValidatorIndexCompact;
|
||||
'Option<ValidatorIndexCompact>': Option<ValidatorIndexCompact>;
|
||||
'Vec<ValidatorIndexCompact>': Vec<ValidatorIndexCompact>;
|
||||
ValidatorPrefs: ValidatorPrefs;
|
||||
'Option<ValidatorPrefs>': Option<ValidatorPrefs>;
|
||||
'Vec<ValidatorPrefs>': Vec<ValidatorPrefs>;
|
||||
@@ -1175,6 +1212,12 @@ declare module '@polkadot/types/types/registry' {
|
||||
StatementKind: StatementKind;
|
||||
'Option<StatementKind>': Option<StatementKind>;
|
||||
'Vec<StatementKind>': Vec<StatementKind>;
|
||||
ParachainProposal: ParachainProposal;
|
||||
'Option<ParachainProposal>': Option<ParachainProposal>;
|
||||
'Vec<ParachainProposal>': Vec<ParachainProposal>;
|
||||
RegisteredParachainInfo: RegisteredParachainInfo;
|
||||
'Option<RegisteredParachainInfo>': Option<RegisteredParachainInfo>;
|
||||
'Vec<RegisteredParachainInfo>': Vec<RegisteredParachainInfo>;
|
||||
AbridgedCandidateReceipt: AbridgedCandidateReceipt;
|
||||
'Option<AbridgedCandidateReceipt>': Option<AbridgedCandidateReceipt>;
|
||||
'Vec<AbridgedCandidateReceipt>': Vec<AbridgedCandidateReceipt>;
|
||||
@@ -1304,6 +1347,12 @@ declare module '@polkadot/types/types/registry' {
|
||||
AccountValidity: AccountValidity;
|
||||
'Option<AccountValidity>': Option<AccountValidity>;
|
||||
'Vec<AccountValidity>': Vec<AccountValidity>;
|
||||
EthereumAccountId: EthereumAccountId;
|
||||
'Option<EthereumAccountId>': Option<EthereumAccountId>;
|
||||
'Vec<EthereumAccountId>': Vec<EthereumAccountId>;
|
||||
EthereumLookupSource: EthereumLookupSource;
|
||||
'Option<EthereumLookupSource>': Option<EthereumLookupSource>;
|
||||
'Vec<EthereumLookupSource>': Vec<EthereumLookupSource>;
|
||||
CallMetadataV0: CallMetadataV0;
|
||||
'Option<CallMetadataV0>': Option<CallMetadataV0>;
|
||||
'Vec<CallMetadataV0>': Vec<CallMetadataV0>;
|
||||
|
||||
@@ -6,7 +6,6 @@ import { H256 } from '../interfaces/runtime';
|
||||
import { AnyJson, Codec, Registry } from '../types';
|
||||
|
||||
import { u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Compact from './Compact';
|
||||
import Raw from './Raw';
|
||||
@@ -41,7 +40,7 @@ export default abstract class AbstractArray<T extends Codec> extends Array<T> im
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,6 @@ import { AnyNumber, Codec, Registry } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { BN_ZERO, assert, bnToBn, bnToHex, bnToU8a, formatBalance, formatNumber, hexToBn, isHex, isString, isU8a, u8aToBn } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Raw from './Raw';
|
||||
|
||||
@@ -92,7 +91,7 @@ export default abstract class AbstractInt extends BN implements Codec {
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,6 @@ import { H256 } from '../interfaces/runtime';
|
||||
import { AnyJson, Constructor, Codec, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
import { isHex, hexToU8a, isU8a, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Compact from './Compact';
|
||||
import Raw from './Raw';
|
||||
@@ -117,7 +116,7 @@ export default class BTreeSet<V extends Codec = Codec> extends Set<V> implements
|
||||
* @description Returns a hash of the value
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
import { H256 } from '../interfaces/runtime';
|
||||
import { AnyJson, BareOpts, Codec, Registry } from '../types';
|
||||
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Raw from './Raw';
|
||||
|
||||
/**
|
||||
@@ -34,7 +32,7 @@ export default abstract class Base<T extends Codec> implements Codec {
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,6 @@ import { AnyJson, AnyNumber, Codec, Constructor, ICompact, InterfaceTypes, Regis
|
||||
import BN from 'bn.js';
|
||||
import { compactAddLength, compactFromU8a, compactStripLength, compactToU8a, isBigInt, isBn, isNumber, isString } from '@polkadot/util';
|
||||
import { DEFAULT_BITLENGTH } from '@polkadot/util/compact/defaults';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import typeToConstructor from './utils/typeToConstructor';
|
||||
import { UIntBitLength } from './AbstractInt';
|
||||
@@ -90,7 +89,7 @@ export default class Compact<T extends CompactEncodable> implements ICompact<T>
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,6 @@ import { AnyNumber, Codec, Registry } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { bnToBn, bnToHex, bnToU8a, isString, isU8a, u8aToBn } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import { UIntBitLength } from './AbstractInt';
|
||||
|
||||
@@ -58,7 +57,7 @@ export default class CodecDate extends Date implements Codec {
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return this.registry.createType('H256', blake2AsU8a(this.toU8a(), 256));
|
||||
return this.registry.createType('H256', this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,6 @@ import { H256 } from '@polkadot/types/interfaces';
|
||||
import { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
import { assert, hexToU8a, isHex, isNumber, isObject, isString, isU8a, isUndefined, stringCamelCase, stringUpperFirst, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Null from '../primitive/Null';
|
||||
import { mapToTypeMap } from './utils';
|
||||
@@ -188,7 +187,7 @@ export default class Enum implements Codec {
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,6 @@ import { H256 } from '../interfaces/runtime';
|
||||
import { AnyJson, Constructor, Codec, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
import { isHex, hexToU8a, isObject, isU8a, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Compact from './Compact';
|
||||
import Raw from './Raw';
|
||||
@@ -126,7 +125,7 @@ export default class CodecMap<K extends Codec = Codec, V extends Codec = Codec>
|
||||
* @description Returns a hash of the value
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,6 @@ import { H256 } from '@polkadot/types/interfaces';
|
||||
import { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
import { isNull, isU8a, isUndefined, u8aToHex } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Null from '../primitive/Null';
|
||||
import { typeToConstructor } from './utils';
|
||||
@@ -83,7 +82,7 @@ export default class Option<T extends Codec> implements Codec {
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,6 @@ import { H256 } from '../interfaces/runtime';
|
||||
import { AnyJson, AnyU8a, IU8a, Registry } from '../types';
|
||||
|
||||
import { assert, isAscii, isU8a, isUndefined, isUtf8, u8aToHex, u8aToString, u8aToU8a } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
/** @internal */
|
||||
function decodeU8a (value?: any): Uint8Array {
|
||||
@@ -46,7 +45,7 @@ export default class Raw extends Uint8Array implements IU8a {
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,6 @@ import { Codec, Constructor, Registry } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { assert, bnToBn, bnToU8a, isBn, isU8a, isNumber, isString, isUndefined, stringCamelCase, stringUpperFirst, u8aToHex, u8aToBn, u8aToU8a } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Raw from './Raw';
|
||||
import { compareArray } from './utils';
|
||||
@@ -127,7 +126,7 @@ export default class CodecSet extends Set<string> implements Codec {
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,6 @@ import { H256 } from '../interfaces/runtime';
|
||||
import { AnyJson, BareOpts, Codec, Constructor, ConstructorDef, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
import { hexToU8a, isBoolean, isFunction, isHex, isObject, isU8a, isUndefined, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Raw from './Raw';
|
||||
import { compareMap, decodeU8a, mapToTypeMap } from './utils';
|
||||
@@ -198,7 +197,7 @@ export default class Struct<
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,6 @@ import { H256 } from '../interfaces/runtime';
|
||||
import { AnyJson, Codec, Registry } from '../types';
|
||||
|
||||
import { isUndefined } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Raw from './Raw';
|
||||
|
||||
@@ -61,7 +60,7 @@ export default class StructAny extends Map<string, any> implements Codec {
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
import { Codec, Constructor } from '../types';
|
||||
|
||||
import { isChildClass } from '@polkadot/util';
|
||||
import { isChildClass, u8aToU8a } from '@polkadot/util';
|
||||
import { keccakAsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Struct from '../codec/Struct';
|
||||
import DoNotConstruct from '../primitive/DoNotConstruct';
|
||||
@@ -159,4 +160,30 @@ describe('TypeRegistry', (): void => {
|
||||
expect(struct.bar.toString()).toEqual('testing');
|
||||
});
|
||||
});
|
||||
|
||||
it('hashes via blake2 by default', (): void => {
|
||||
expect(
|
||||
registry.hash(u8aToU8a('abc'))
|
||||
).toEqual(
|
||||
new Uint8Array([189, 221, 129, 60, 99, 66, 57, 114, 49, 113, 239, 63, 238, 152, 87, 155, 148, 150, 78, 59, 177, 203, 62, 66, 114, 98, 200, 192, 104, 213, 35, 25])
|
||||
);
|
||||
});
|
||||
|
||||
it('hashes via override hasher', (): void => {
|
||||
registry.setHasher(keccakAsU8a);
|
||||
|
||||
expect(
|
||||
registry.hash(u8aToU8a('test value'))
|
||||
).toEqual(
|
||||
u8aToU8a('0x2d07364b5c231c56ce63d49430e085ea3033c750688ba532b24029124c26ca5e')
|
||||
);
|
||||
|
||||
registry.setHasher();
|
||||
|
||||
expect(
|
||||
registry.hash(u8aToU8a('abc'))
|
||||
).toEqual(
|
||||
new Uint8Array([189, 221, 129, 60, 99, 66, 57, 114, 49, 113, 239, 63, 238, 152, 87, 155, 148, 150, 78, 59, 177, 203, 62, 66, 114, 98, 200, 192, 104, 213, 35, 25])
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,6 +9,7 @@ import { CallFunction, Codec, Constructor, InterfaceTypes, RegistryError, Regist
|
||||
|
||||
import extrinsicsFromMeta from '@polkadot/metadata/Decorated/extrinsics/fromMetadata';
|
||||
import { assert, formatBalance, isFunction, isString, isU8a, isUndefined, stringCamelCase, u8aToHex } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Raw from '../codec/Raw';
|
||||
import { defaultExtensions, expandExtensionTypes, findUnknownExtensions } from '../extrinsic/signedExtensions';
|
||||
@@ -94,6 +95,8 @@ export class TypeRegistry implements Registry {
|
||||
|
||||
#chainProperties?: ChainProperties;
|
||||
|
||||
#hasher: (data: Uint8Array) => Uint8Array = blake2AsU8a;
|
||||
|
||||
#knownTypes: RegisteredTypes = {};
|
||||
|
||||
#signedExtensions: string[] = defaultExtensions;
|
||||
@@ -271,6 +274,10 @@ export class TypeRegistry implements Registry {
|
||||
return !this.#unknownTypes.get(name) && (this.hasClass(name) || this.hasDef(name));
|
||||
}
|
||||
|
||||
public hash (data: Uint8Array): Uint8Array {
|
||||
return this.#hasher(data);
|
||||
}
|
||||
|
||||
public register (type: Constructor | RegistryTypes): void;
|
||||
|
||||
// eslint-disable-next-line no-dupe-class-members
|
||||
@@ -317,6 +324,10 @@ export class TypeRegistry implements Registry {
|
||||
}
|
||||
}
|
||||
|
||||
setHasher (hasher: (data: Uint8Array) => Uint8Array = blake2AsU8a): void {
|
||||
this.#hasher = hasher;
|
||||
}
|
||||
|
||||
setKnownTypes (knownTypes: RegisteredTypes): void {
|
||||
this.#knownTypes = knownTypes;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
|
||||
import { TypeRegistry } from '../create';
|
||||
import Raw from '../codec/Raw';
|
||||
import AccountId from './AccountId';
|
||||
|
||||
describe('EthereumAccountId', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
describe('defaults', (): void => {
|
||||
const id = registry.createType('EthereumAccountId');
|
||||
|
||||
it('has a 20-byte length', (): void => {
|
||||
expect(id).toHaveLength(20);
|
||||
});
|
||||
|
||||
it('is empty by default', (): void => {
|
||||
expect(id.isEmpty).toBe(true);
|
||||
});
|
||||
|
||||
it('equals the empty address', (): void => {
|
||||
expect(id.eq('0x0000000000000000000000000000000000000000')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('decoding', (): void => {
|
||||
const testDecode = (type: string, input: Uint8Array | string | AccountId, expected: string): void =>
|
||||
it(`can decode from ${type}`, (): void => {
|
||||
const a = registry.createType('EthereumAccountId', input);
|
||||
|
||||
expect(a.toString()).toBe(expected);
|
||||
});
|
||||
|
||||
testDecode(
|
||||
'AccountId',
|
||||
registry.createType('EthereumAccountId', '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887'),
|
||||
'0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887'
|
||||
);
|
||||
testDecode('hex', '0x4119b2e6c3cb618f4f0B93ac77f9Beec7ff02887', '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887');
|
||||
testDecode(
|
||||
'Raw',
|
||||
new Raw(registry, [
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 1, 2,
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 1, 2
|
||||
]),
|
||||
'0x0102030405060708010201020304050607080102'
|
||||
);
|
||||
testDecode(
|
||||
'Uint8Array',
|
||||
Uint8Array.from([
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 1, 2,
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 1, 2
|
||||
]),
|
||||
'0x0102030405060708010201020304050607080102'
|
||||
);
|
||||
});
|
||||
|
||||
describe('encoding', (): void => {
|
||||
const testEncode = (to: 'toHex' | 'toJSON' | 'toString' | 'toU8a', expected: Uint8Array | string, input = '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887'): void =>
|
||||
it(`can encode ${to}`, (): void => {
|
||||
const a = registry.createType('EthereumAccountId', input);
|
||||
|
||||
expect(a[to]()).toEqual(expected);
|
||||
});
|
||||
|
||||
testEncode('toHex', '0x4119b2e6c3cb618f4f0b93ac77f9beec7ff02887');
|
||||
testEncode('toJSON', '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887');
|
||||
testEncode('toString', '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887');
|
||||
testEncode('toString', '0x0000000000000000000000000000000000000000', '0x00');
|
||||
testEncode('toU8a', Uint8Array.from([
|
||||
0x41, 0x19, 0xb2, 0xe6, 0xc3, 0xcb, 0x61, 0x8f, 0x4f, 0x0b,
|
||||
0x93, 0xac, 0x77, 0xf9, 0xbe, 0xec, 0x7f, 0xf0, 0x28, 0x87
|
||||
]));
|
||||
|
||||
it('decodes to a non-empty value', (): void => {
|
||||
expect(registry.createType('EthereumAccountId', '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887').isEmpty).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,75 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AnyString, AnyU8a, Registry } from '../types';
|
||||
|
||||
import { hexToU8a, isHex, isString, isU8a, u8aToU8a } from '@polkadot/util';
|
||||
import { ethereumEncode, isEthereumAddress } from '@polkadot/util-crypto';
|
||||
|
||||
import U8aFixed from '../codec/U8aFixed';
|
||||
|
||||
/** @internal */
|
||||
function decodeAccountId (value: AnyU8a | AnyString): AnyU8a {
|
||||
if (isU8a(value) || Array.isArray(value)) {
|
||||
return u8aToU8a(value);
|
||||
} else if (isHex(value) || isEthereumAddress(value)) {
|
||||
return hexToU8a(value.toString());
|
||||
} else if (isString(value)) {
|
||||
return u8aToU8a((value as string).toString());
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name EthereumAccountId
|
||||
* @description
|
||||
* A wrapper around an Ethereum-compatible AccountId. Since we are dealing with
|
||||
* underlying addresses (20 bytes in length), we extend from U8aFixed which is
|
||||
* just a Uint8Array wrapper with a fixed length.
|
||||
*/
|
||||
export default class AccountId extends U8aFixed {
|
||||
constructor (registry: Registry, value: AnyU8a = new Uint8Array()) {
|
||||
super(registry, decodeAccountId(value), 160);
|
||||
}
|
||||
|
||||
public static encode (value: Uint8Array): string {
|
||||
return ethereumEncode(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Compares the value of the input to see if there is a match
|
||||
*/
|
||||
public eq (other?: unknown): boolean {
|
||||
return super.eq(decodeAccountId(other as AnyU8a));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
||||
*/
|
||||
public toHuman (): string {
|
||||
return this.toJSON();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Converts the Object to JSON, typically used for RPC transfers
|
||||
*/
|
||||
public toJSON (): string {
|
||||
return this.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the string representation of the value
|
||||
*/
|
||||
public toString (): string {
|
||||
return AccountId.encode(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the base runtime type name for this instance
|
||||
*/
|
||||
public toRawType (): string {
|
||||
return 'AccountId';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { TypeRegistry } from '../create';
|
||||
import AccountIndex from '../generic/AccountIndex';
|
||||
import AccountId from './AccountId';
|
||||
import Address from './LookupSource';
|
||||
|
||||
describe('EthereumLookupSource', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
const testDecode = (type: string, input: Address | AccountId | AccountIndex | number[] | Uint8Array, expected: string): void =>
|
||||
it(`can decode from ${type}`, (): void => {
|
||||
const a = registry.createType('EthereumLookupSource', input);
|
||||
|
||||
expect(a.toString()).toBe(expected);
|
||||
});
|
||||
|
||||
describe('decoding', (): void => {
|
||||
testDecode(
|
||||
'Address',
|
||||
registry.createType('EthereumLookupSource', '0x00a329c0648769a73afac7f9381e08fb43dbea72'),
|
||||
'0x00a329c0648769A73afAc7F9381E08FB43dBEA72'
|
||||
);
|
||||
testDecode(
|
||||
'AccountId',
|
||||
registry.createType('EthereumAccountId', '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887'),
|
||||
'0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887'
|
||||
);
|
||||
testDecode(
|
||||
'AccountIndex (mixed prefixes)',
|
||||
registry.createType('EthereumLookupSource', '2jpAFn'),
|
||||
// NOTE Expected address here is encoded with prefix 42, input above with 68
|
||||
'25GUyv'
|
||||
);
|
||||
testDecode(
|
||||
'AccountIndex (hex)',
|
||||
registry.createType('AccountIndex', '0x0100'),
|
||||
'25GUyv'
|
||||
);
|
||||
testDecode(
|
||||
'Uint8Array (with prefix 255)',
|
||||
Uint8Array.from([
|
||||
255,
|
||||
0x41, 0x19, 0xb2, 0xe6, 0xc3, 0xcb, 0x61, 0x8f, 0x4f, 0x0b,
|
||||
0x93, 0xac, 0x77, 0xf9, 0xbe, 0xec, 0x7f, 0xf0, 0x28, 0x87
|
||||
]),
|
||||
'0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887'
|
||||
);
|
||||
testDecode(
|
||||
'Uint8Array (with prefix 1 byte)',
|
||||
Uint8Array.from([1]),
|
||||
'F7NZ'
|
||||
);
|
||||
testDecode(
|
||||
'Uint8Array (with prefix 2 bytes)',
|
||||
Uint8Array.from([0xfc, 0, 1]),
|
||||
'25GUyv'
|
||||
);
|
||||
testDecode(
|
||||
'Uint8Array (with prefix 4 bytes)',
|
||||
Uint8Array.from([0xfd, 17, 18, 19, 20]),
|
||||
'Mwz15xP2'
|
||||
);
|
||||
});
|
||||
|
||||
describe('encoding', (): void => {
|
||||
const testEncode = (to: 'toHex' | 'toString' | 'toU8a', expected: string | Uint8Array): void =>
|
||||
it(`can encode ${to}`, (): void => {
|
||||
const a = registry.createType('EthereumLookupSource', '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887');
|
||||
|
||||
expect(a[to]()).toEqual(expected);
|
||||
});
|
||||
|
||||
testEncode(
|
||||
'toHex',
|
||||
'0xff4119b2e6c3cb618f4f0b93ac77f9beec7ff02887'
|
||||
);
|
||||
testEncode(
|
||||
'toString',
|
||||
'0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887'
|
||||
);
|
||||
testEncode(
|
||||
'toU8a',
|
||||
Uint8Array.from([
|
||||
255,
|
||||
0x41, 0x19, 0xb2, 0xe6, 0xc3, 0xcb, 0x61, 0x8f, 0x4f, 0x0b,
|
||||
0x93, 0xac, 0x77, 0xf9, 0xbe, 0xec, 0x7f, 0xf0, 0x28, 0x87
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
describe('utility', (): void => {
|
||||
it('equals on AccountId', (): void => {
|
||||
const addr = '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887';
|
||||
|
||||
expect(registry.createType('EthereumLookupSource', addr).eq(addr)).toBe(true);
|
||||
});
|
||||
|
||||
it('equals on AccountIndex', (): void => {
|
||||
// see the test below - these are equivalent (with different prefix encoding)
|
||||
expect(registry.createType('EthereumLookupSource', '2jpAFn').eq('25GUyv')).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,124 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Registry } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { isBn, isHex, isNumber, isU8a, u8aConcat, u8aToHex, u8aToU8a, u8aToBn } from '@polkadot/util';
|
||||
import { decodeAddress } from '@polkadot/util-crypto';
|
||||
|
||||
import Base from '../codec/Base';
|
||||
import AccountIndex from '../generic/AccountIndex';
|
||||
import EthereumAccountId from './AccountId';
|
||||
|
||||
type AnyAddress = BN | LookupSource | EthereumAccountId | AccountIndex | number[] | Uint8Array | number | string;
|
||||
|
||||
export const ACCOUNT_ID_PREFIX = new Uint8Array([0xff]);
|
||||
|
||||
/** @internal */
|
||||
function decodeString (registry: Registry, value: string): EthereumAccountId | AccountIndex {
|
||||
const decoded = decodeAddress(value);
|
||||
|
||||
return decoded.length === 20
|
||||
? registry.createType('EthereumAccountId', decoded)
|
||||
: registry.createType('AccountIndex', u8aToBn(decoded, true));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function decodeU8a (registry: Registry, value: Uint8Array): EthereumAccountId | AccountIndex {
|
||||
// This allows us to instantiate an address with a raw publicKey. Do this first before
|
||||
// we checking the first byte, otherwise we may split an already-existent valid address
|
||||
if (value.length === 20) {
|
||||
return registry.createType('EthereumAccountId', value);
|
||||
} else if (value[0] === 0xff) {
|
||||
return registry.createType('EthereumAccountId', value.subarray(1));
|
||||
}
|
||||
|
||||
const [offset, length] = AccountIndex.readLength(value);
|
||||
|
||||
return registry.createType('AccountIndex', u8aToBn(value.subarray(offset, offset + length), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @name LookupSource
|
||||
* @description
|
||||
* A wrapper around an EthereumAccountId and/or AccountIndex that is encoded with a prefix.
|
||||
* Since we are dealing with underlying publicKeys (or shorter encoded addresses),
|
||||
* we extend from Base with an AccountId/AccountIndex wrapper. Basically the Address
|
||||
* is encoded as `[ <prefix-byte>, ...publicKey/...bytes ]` as per spec
|
||||
*/
|
||||
export default class LookupSource extends Base<EthereumAccountId | AccountIndex> {
|
||||
constructor (registry: Registry, value: AnyAddress = new Uint8Array()) {
|
||||
super(registry, LookupSource._decodeAddress(registry, value));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
private static _decodeAddress (registry: Registry, value: AnyAddress): EthereumAccountId | AccountIndex {
|
||||
if (value instanceof EthereumAccountId || value instanceof AccountIndex) {
|
||||
return value;
|
||||
} else if (value instanceof LookupSource) {
|
||||
return value._raw;
|
||||
} else if (isBn(value) || isNumber(value)) {
|
||||
return registry.createType('AccountIndex', value);
|
||||
} else if (Array.isArray(value) || isHex(value) || isU8a(value)) {
|
||||
return decodeU8a(registry, u8aToU8a(value));
|
||||
}
|
||||
|
||||
return decodeString(registry, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The length of the value when encoded as a Uint8Array
|
||||
*/
|
||||
public get encodedLength (): number {
|
||||
const rawLength = this._rawLength;
|
||||
|
||||
return rawLength + (
|
||||
// for 1 byte AccountIndexes, we are not adding a specific prefix
|
||||
rawLength > 1
|
||||
? 1
|
||||
: 0
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The length of the raw value, either AccountIndex or AccountId
|
||||
*/
|
||||
protected get _rawLength (): number {
|
||||
return this._raw instanceof AccountIndex
|
||||
? AccountIndex.calcLength(this._raw)
|
||||
: this._raw.encodedLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns a hex string representation of the value
|
||||
*/
|
||||
public toHex (): string {
|
||||
return u8aToHex(this.toU8a());
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the base runtime type name for this instance
|
||||
*/
|
||||
public toRawType (): string {
|
||||
return 'Address';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
||||
* @param isBare true when the value has none of the type-specific prefixes (internal)
|
||||
*/
|
||||
public toU8a (isBare?: boolean): Uint8Array {
|
||||
const encoded = this._raw.toU8a().subarray(0, this._rawLength);
|
||||
|
||||
return isBare
|
||||
? encoded
|
||||
: u8aConcat(
|
||||
this._raw instanceof AccountIndex
|
||||
? AccountIndex.writeLength(encoded)
|
||||
: ACCOUNT_ID_PREFIX,
|
||||
encoded
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export { default as GenericEthereumAccountId } from './AccountId';
|
||||
export { default as GenericEthereumLookupSource } from './LookupSource';
|
||||
@@ -3,14 +3,12 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { SignOptions } from '@polkadot/keyring/types';
|
||||
import { IKeyringPair } from '../types';
|
||||
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
import { IKeyringPair, Registry } from '../types';
|
||||
|
||||
// a helper function for both types of payloads, Raw and metadata-known
|
||||
export function sign (signerPair: IKeyringPair, u8a: Uint8Array, options?: SignOptions): Uint8Array {
|
||||
export function sign (registry: Registry, signerPair: IKeyringPair, u8a: Uint8Array, options?: SignOptions): Uint8Array {
|
||||
const encoded = u8a.length > 256
|
||||
? blake2AsU8a(u8a)
|
||||
? registry.hash(u8a)
|
||||
: u8a;
|
||||
|
||||
return signerPair.sign(encoded, options);
|
||||
|
||||
@@ -67,6 +67,6 @@ export default class ExtrinsicPayloadV1 extends Struct {
|
||||
* @description Sign the payload with the keypair
|
||||
*/
|
||||
public sign (signerPair: IKeyringPair): Uint8Array {
|
||||
return sign(signerPair, this.toU8a({ method: true }));
|
||||
return sign(this.registry, signerPair, this.toU8a({ method: true }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import { Address, Balance, Call, Index } from '../../interfaces/runtime';
|
||||
import { ExtrinsicPayloadValue, IExtrinsicSignature, IKeyringPair, Registry, SignatureOptions } from '../../types';
|
||||
import { ExtrinsicSignatureOptions } from '../types';
|
||||
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Compact from '../../codec/Compact';
|
||||
import Struct from '../../codec/Struct';
|
||||
import { EMPTY_U8A, IMMORTAL_ERA } from '../constants';
|
||||
@@ -142,10 +140,7 @@ export default class ExtrinsicSignatureV1 extends Struct implements IExtrinsicSi
|
||||
* @description Generate a payload and applies the signature from a keypair
|
||||
*/
|
||||
public sign (method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature {
|
||||
const address = account.publicKey.length > 32
|
||||
? blake2AsU8a(account.publicKey, 256)
|
||||
: account.publicKey;
|
||||
const signer = this.registry.createType('Address', address);
|
||||
const signer = this.registry.createType('Address', account.addressRaw);
|
||||
const payload = this.createPayload(method, options);
|
||||
const signature = this.registry.createType('Signature', payload.sign(account));
|
||||
|
||||
|
||||
@@ -69,6 +69,6 @@ export default class ExtrinsicPayloadV2 extends Struct {
|
||||
* @description Sign the payload with the keypair
|
||||
*/
|
||||
public sign (signerPair: IKeyringPair): Uint8Array {
|
||||
return sign(signerPair, this.toU8a({ method: true }));
|
||||
return sign(this.registry, signerPair, this.toU8a({ method: true }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import { Address, Balance, Call, Index } from '../../interfaces/runtime';
|
||||
import { ExtrinsicPayloadValue, IExtrinsicSignature, IKeyringPair, Registry, SignatureOptions } from '../../types';
|
||||
import { ExtrinsicSignatureOptions } from '../types';
|
||||
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Compact from '../../codec/Compact';
|
||||
import Struct from '../../codec/Struct';
|
||||
import { EMPTY_U8A, IMMORTAL_ERA } from '../constants';
|
||||
@@ -138,10 +136,7 @@ export default class ExtrinsicSignatureV2 extends Struct implements IExtrinsicSi
|
||||
* @description Generate a payload and applies the signature from a keypair
|
||||
*/
|
||||
public sign (method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature {
|
||||
const address = account.publicKey.length > 32
|
||||
? blake2AsU8a(account.publicKey, 256)
|
||||
: account.publicKey;
|
||||
const signer = this.registry.createType('Address', address);
|
||||
const signer = this.registry.createType('Address', account.addressRaw);
|
||||
const payload = this.createPayload(method, options);
|
||||
const signature = this.registry.createType('Signature', payload.sign(account));
|
||||
|
||||
|
||||
@@ -88,6 +88,6 @@ export default class ExtrinsicPayloadV3 extends Struct {
|
||||
* @description Sign the payload with the keypair
|
||||
*/
|
||||
public sign (signerPair: IKeyringPair): Uint8Array {
|
||||
return sign(signerPair, this.toU8a({ method: true }));
|
||||
return sign(this.registry, signerPair, this.toU8a({ method: true }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
import { Address, Call } from '../../interfaces/runtime';
|
||||
import { ExtrinsicPayloadValue, IExtrinsicSignature, IKeyringPair, SignatureOptions } from '../../types';
|
||||
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import { IMMORTAL_ERA } from '../constants';
|
||||
import ExtrinsicSignatureV2 from '../v2/ExtrinsicSignature';
|
||||
import ExtrinsicPayloadV3 from './ExtrinsicPayload';
|
||||
@@ -48,10 +46,7 @@ export default class ExtrinsicSignatureV3 extends ExtrinsicSignatureV2 {
|
||||
* @description Generate a payload and applies the signature from a keypair
|
||||
*/
|
||||
public sign (method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature {
|
||||
const address = account.publicKey.length > 32
|
||||
? blake2AsU8a(account.publicKey, 256)
|
||||
: account.publicKey;
|
||||
const signer = this.registry.createType('Address', address);
|
||||
const signer = this.registry.createType('Address', account.addressRaw);
|
||||
const payload = this.createPayload(method, options);
|
||||
const signature = this.registry.createType('Signature', payload.sign(account));
|
||||
|
||||
|
||||
@@ -91,6 +91,6 @@ export default class ExtrinsicPayloadV4 extends Struct {
|
||||
// to have the length prefix included. This means that the data-as-signed is un-decodable,
|
||||
// but is also doesn't need the extra information, only the pure data (and is not decoded)
|
||||
// ... The same applies to V1..V3, if we have a V5, carry move this comment to latest
|
||||
return sign(signerPair, this.toU8a({ method: true }), { withType: true });
|
||||
return sign(this.registry, signerPair, this.toU8a({ method: true }), { withType: true });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import { ExtrinsicPayloadValue, IExtrinsicSignature, IKeyringPair, Registry, Sig
|
||||
import { ExtrinsicSignatureOptions } from '../types';
|
||||
|
||||
import { u8aConcat } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Compact from '../../codec/Compact';
|
||||
import Struct from '../../codec/Struct';
|
||||
@@ -142,10 +141,7 @@ export default class ExtrinsicSignatureV4 extends Struct implements IExtrinsicSi
|
||||
* @description Generate a payload and applies the signature from a keypair
|
||||
*/
|
||||
public sign (method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature {
|
||||
const address = account.publicKey.length > 32
|
||||
? blake2AsU8a(account.publicKey, 256)
|
||||
: account.publicKey;
|
||||
const signer = this.registry.createType('Address', address);
|
||||
const signer = this.registry.createType('Address', account.addressRaw);
|
||||
const payload = this.createPayload(method, options);
|
||||
const signature = this.registry.createType('MultiSignature', payload.sign(account));
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
import { Digest, DigestItem, H256, Header } from '../interfaces/runtime';
|
||||
import { AnyNumber, AnyU8a, Registry } from '../types';
|
||||
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Extrinsic from '../extrinsic/Extrinsic';
|
||||
import Struct from '../codec/Struct';
|
||||
import Vec from '../codec/Vec';
|
||||
@@ -42,7 +40,7 @@ export default class Block extends Struct {
|
||||
* @description Encodes a content [[Hash]] for the block
|
||||
*/
|
||||
public get contentHash (): H256 {
|
||||
return this.registry.createType('H256', blake2AsU8a(this.toU8a(), 256));
|
||||
return this.registry.createType('H256', this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+7
-7
@@ -5,12 +5,12 @@
|
||||
import { TypeRegistry } from '../create';
|
||||
import AccountId from './AccountId';
|
||||
import AccountIndex from './AccountIndex';
|
||||
import Address from './Address';
|
||||
import LookupSource from './LookupSource';
|
||||
|
||||
describe('Address', (): void => {
|
||||
describe('LookupSource', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
const testDecode = (type: string, input: Address | AccountId | AccountIndex | number[] | Uint8Array, expected: string): void =>
|
||||
const testDecode = (type: string, input: LookupSource | AccountId | AccountIndex | number[] | Uint8Array, expected: string): void =>
|
||||
it(`can decode from ${type}`, (): void => {
|
||||
const a = registry.createType('Address', input);
|
||||
|
||||
@@ -21,19 +21,19 @@ describe('Address', (): void => {
|
||||
it('equals on AccountId', (): void => {
|
||||
const addr = '5DkQbYAExs3M2sZgT1Ec3mKfZnAQCL4Dt9beTCknkCUn5jzo';
|
||||
|
||||
expect(registry.createType('Address', addr).eq(addr)).toBe(true);
|
||||
expect(registry.createType('LookupSource', addr).eq(addr)).toBe(true);
|
||||
});
|
||||
|
||||
it('equals on AccountIndex', (): void => {
|
||||
// see the test below - these are equivalent (with different prefix encoding)
|
||||
expect(registry.createType('Address', '2jpAFn').eq('25GUyv')).toBe(true);
|
||||
expect(registry.createType('LookupSource', '2jpAFn').eq('25GUyv')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('decoding', (): void => {
|
||||
testDecode(
|
||||
'Address',
|
||||
registry.createType('Address', '5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF'),
|
||||
registry.createType('LookupSource', '5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF'),
|
||||
'5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF'
|
||||
);
|
||||
testDecode(
|
||||
@@ -43,7 +43,7 @@ describe('Address', (): void => {
|
||||
);
|
||||
testDecode(
|
||||
'AccountIndex (mixed prefixes)',
|
||||
registry.createType('Address', '2jpAFn'),
|
||||
registry.createType('LookupSource', '2jpAFn'),
|
||||
// NOTE Expected adress here is encoded with prefix 42, input above with 68
|
||||
'25GUyv'
|
||||
);
|
||||
@@ -12,7 +12,7 @@ import Base from '../codec/Base';
|
||||
import AccountId from './AccountId';
|
||||
import AccountIndex from './AccountIndex';
|
||||
|
||||
type AnyAddress = BN | Address | AccountId | AccountIndex | number[] | Uint8Array | number | string;
|
||||
type AnyAddress = BN | LookupSource | AccountId | AccountIndex | number[] | Uint8Array | number | string;
|
||||
|
||||
export const ACCOUNT_ID_PREFIX = new Uint8Array([0xff]);
|
||||
|
||||
@@ -41,23 +41,23 @@ function decodeU8a (registry: Registry, value: Uint8Array): AccountId | AccountI
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Address
|
||||
* @name LookupSource
|
||||
* @description
|
||||
* A wrapper around an AccountId and/or AccountIndex that is encoded with a prefix.
|
||||
* Since we are dealing with underlying publicKeys (or shorter encoded addresses),
|
||||
* we extend from Base with an AccountId/AccountIndex wrapper. Basically the Address
|
||||
* is encoded as `[ <prefix-byte>, ...publicKey/...bytes ]` as per spec
|
||||
*/
|
||||
export default class Address extends Base<AccountId | AccountIndex> {
|
||||
export default class LookupSource extends Base<AccountId | AccountIndex> {
|
||||
constructor (registry: Registry, value: AnyAddress = new Uint8Array()) {
|
||||
super(registry, Address._decodeAddress(registry, value));
|
||||
super(registry, LookupSource._decodeAddress(registry, value));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
private static _decodeAddress (registry: Registry, value: AnyAddress): AccountId | AccountIndex {
|
||||
if (value instanceof AccountId || value instanceof AccountIndex) {
|
||||
return value;
|
||||
} else if (value instanceof Address) {
|
||||
} else if (value instanceof LookupSource) {
|
||||
return value._raw;
|
||||
} else if (isBn(value) || isNumber(value)) {
|
||||
return registry.createType('AccountIndex', value);
|
||||
@@ -2,11 +2,13 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export * from '../ethereum';
|
||||
|
||||
export { default as GenericAccountId } from './AccountId';
|
||||
export { default as GenericAccountIndex } from './AccountIndex';
|
||||
export { default as GenericAddress } from './Address';
|
||||
export { default as GenericBlock } from './Block';
|
||||
export { default as GenericCall } from './Call';
|
||||
export { default as GenericConsensusEngineId } from './ConsensusEngineId';
|
||||
export { default as GenericEvent } from './Event';
|
||||
export { default as GenericLookupSource } from './LookupSource';
|
||||
export { default as GenericVote } from './Vote';
|
||||
|
||||
@@ -43,6 +43,9 @@ export { default as parachains } from './parachains/definitions';
|
||||
export { default as poll } from './poll/definitions';
|
||||
export { default as purchase } from './purchase/definitions';
|
||||
|
||||
// other useful types
|
||||
export { default as ethereum } from './ethereum/definitions';
|
||||
|
||||
// pull in metadata & rpc last, assuming that is uses info from above
|
||||
export { default as metadata } from './metadata/definitions';
|
||||
export { default as rpc } from './rpc/definitions';
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
EthereumAccountId: 'GenericEthereumAccountId',
|
||||
EthereumLookupSource: 'GenericEthereumLookupSource'
|
||||
}
|
||||
} as Definitions;
|
||||
@@ -0,0 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
@@ -0,0 +1,12 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
import { GenericEthereumAccountId, GenericEthereumLookupSource } from '@polkadot/types/generic';
|
||||
|
||||
/** @name EthereumAccountId */
|
||||
export interface EthereumAccountId extends GenericEthereumAccountId {}
|
||||
|
||||
/** @name EthereumLookupSource */
|
||||
export interface EthereumLookupSource extends GenericEthereumLookupSource {}
|
||||
|
||||
export type PHANTOM_ETHEREUM = 'ethereum';
|
||||
@@ -9,9 +9,25 @@ import { Definitions } from '../../types';
|
||||
|
||||
const SLOT_RANGE_COUNT = 10;
|
||||
|
||||
const proposeTypes = {
|
||||
ParachainProposal: {
|
||||
proposer: 'AccountId',
|
||||
validationFunction: 'ValidationCode',
|
||||
initialHeadState: 'HeadData',
|
||||
validators: 'Vec<ValidatorId>',
|
||||
name: 'Vec<u8>',
|
||||
balance: 'Balance'
|
||||
},
|
||||
RegisteredParachainInfo: {
|
||||
validators: 'Vec<ValidatorId>',
|
||||
proposer: 'AccountId'
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
...proposeTypes,
|
||||
AbridgedCandidateReceipt: {
|
||||
parachainIndex: 'ParaId',
|
||||
relayParent: 'Hash',
|
||||
|
||||
@@ -141,6 +141,16 @@ export interface ParachainDispatchOrigin extends Enum {
|
||||
readonly isRoot: boolean;
|
||||
}
|
||||
|
||||
/** @name ParachainProposal */
|
||||
export interface ParachainProposal extends Struct {
|
||||
readonly proposer: AccountId;
|
||||
readonly validationFunction: ValidationCode;
|
||||
readonly initialHeadState: HeadData;
|
||||
readonly validators: Vec<ValidatorId>;
|
||||
readonly name: Bytes;
|
||||
readonly balance: Balance;
|
||||
}
|
||||
|
||||
/** @name ParaId */
|
||||
export interface ParaId extends u32 {}
|
||||
|
||||
@@ -161,6 +171,12 @@ export interface ParaScheduling extends Enum {
|
||||
readonly isDynamic: boolean;
|
||||
}
|
||||
|
||||
/** @name RegisteredParachainInfo */
|
||||
export interface RegisteredParachainInfo extends Struct {
|
||||
readonly validators: Vec<ValidatorId>;
|
||||
readonly proposer: AccountId;
|
||||
}
|
||||
|
||||
/** @name RelayChainBlockNumber */
|
||||
export interface RelayChainBlockNumber extends BlockNumber {}
|
||||
|
||||
|
||||
@@ -7,9 +7,26 @@
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
const numberTypes = {
|
||||
Fixed64: 'Int<64, Fixed64>',
|
||||
FixedI64: 'Int<64, FixedI64>',
|
||||
FixedU64: 'UInt<64, FixedU64>',
|
||||
Fixed128: 'Int<128, Fixed128>',
|
||||
FixedI128: 'Int<128, FixedI128>',
|
||||
FixedU128: 'UInt<128, FixedU128>',
|
||||
I32F32: 'Int<64, I32F32>',
|
||||
U32F32: 'UInt<64, U32F32>',
|
||||
PerU16: 'u16',
|
||||
Perbill: 'u32',
|
||||
Percent: 'u8',
|
||||
Permill: 'u32',
|
||||
Perquintill: 'u64'
|
||||
};
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
...numberTypes,
|
||||
AccountId: 'GenericAccountId',
|
||||
AccountIdOf: 'AccountId',
|
||||
AccountIndex: 'GenericAccountIndex',
|
||||
@@ -45,8 +62,7 @@ export default {
|
||||
normal: 'Weight',
|
||||
operational: 'Weight'
|
||||
},
|
||||
Fixed64: 'Int<64, Fixed64>',
|
||||
Fixed128: 'Int<128, Fixed128>',
|
||||
GenericAddress: 'LookupSource',
|
||||
H160: '[u8; 20; H160]',
|
||||
H256: '[u8; 32; H256]',
|
||||
H512: '[u8; 64; H512]',
|
||||
@@ -63,7 +79,7 @@ export default {
|
||||
KeyValue: '(StorageKey, StorageData)',
|
||||
KeyTypeId: 'u32',
|
||||
LockIdentifier: '[u8; 8]',
|
||||
LookupSource: 'Address',
|
||||
LookupSource: 'GenericLookupSource',
|
||||
LookupTarget: 'AccountId',
|
||||
ModuleId: 'LockIdentifier',
|
||||
Moment: 'u64',
|
||||
@@ -72,10 +88,6 @@ export default {
|
||||
Pays: {
|
||||
_enum: ['Yes', 'No']
|
||||
},
|
||||
Perbill: 'u32',
|
||||
Percent: 'u8',
|
||||
Permill: 'u32',
|
||||
Perquintill: 'u64',
|
||||
Phantom: 'Null',
|
||||
PhantomData: 'Null',
|
||||
Releases: {
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/* eslint-disable */
|
||||
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { Compact, Enum, Int, Struct, U8aFixed, Vec } from '@polkadot/types/codec';
|
||||
import { GenericAccountId, GenericAccountIndex, GenericAddress, GenericBlock, GenericCall, GenericConsensusEngineId } from '@polkadot/types/generic';
|
||||
import { Bytes, DoNotConstruct, Null, StorageKey, u128, u32, u64, u8 } from '@polkadot/types/primitive';
|
||||
import { Compact, Enum, Int, Struct, U8aFixed, UInt, Vec } from '@polkadot/types/codec';
|
||||
import { GenericAccountId, GenericAccountIndex, GenericBlock, GenericCall, GenericConsensusEngineId, GenericLookupSource } from '@polkadot/types/generic';
|
||||
import { Bytes, DoNotConstruct, Null, StorageKey, u128, u16, u32, u64, u8 } from '@polkadot/types/primitive';
|
||||
import { AuthorityId } from '@polkadot/types/interfaces/consensus';
|
||||
import { Signature } from '@polkadot/types/interfaces/extrinsics';
|
||||
|
||||
@@ -91,6 +91,21 @@ export interface Fixed128 extends Int {}
|
||||
/** @name Fixed64 */
|
||||
export interface Fixed64 extends Int {}
|
||||
|
||||
/** @name FixedI128 */
|
||||
export interface FixedI128 extends Int {}
|
||||
|
||||
/** @name FixedI64 */
|
||||
export interface FixedI64 extends Int {}
|
||||
|
||||
/** @name FixedU128 */
|
||||
export interface FixedU128 extends UInt {}
|
||||
|
||||
/** @name FixedU64 */
|
||||
export interface FixedU64 extends UInt {}
|
||||
|
||||
/** @name GenericAddress */
|
||||
export interface GenericAddress extends LookupSource {}
|
||||
|
||||
/** @name H160 */
|
||||
export interface H160 extends U8aFixed {}
|
||||
|
||||
@@ -112,6 +127,9 @@ export interface Header extends Struct {
|
||||
readonly digest: Digest;
|
||||
}
|
||||
|
||||
/** @name I32F32 */
|
||||
export interface I32F32 extends Int {}
|
||||
|
||||
/** @name Index */
|
||||
export interface Index extends u32 {}
|
||||
|
||||
@@ -128,7 +146,7 @@ export interface KeyValue extends ITuple<[StorageKey, StorageData]> {}
|
||||
export interface LockIdentifier extends U8aFixed {}
|
||||
|
||||
/** @name LookupSource */
|
||||
export interface LookupSource extends Address {}
|
||||
export interface LookupSource extends GenericLookupSource {}
|
||||
|
||||
/** @name LookupTarget */
|
||||
export interface LookupTarget extends AccountId {}
|
||||
@@ -163,6 +181,9 @@ export interface Permill extends u32 {}
|
||||
/** @name Perquintill */
|
||||
export interface Perquintill extends u64 {}
|
||||
|
||||
/** @name PerU16 */
|
||||
export interface PerU16 extends u16 {}
|
||||
|
||||
/** @name Phantom */
|
||||
export interface Phantom extends Null {}
|
||||
|
||||
@@ -207,6 +228,9 @@ export interface SignedBlock extends Struct {
|
||||
/** @name StorageData */
|
||||
export interface StorageData extends Bytes {}
|
||||
|
||||
/** @name U32F32 */
|
||||
export interface U32F32 extends UInt {}
|
||||
|
||||
/** @name ValidatorId */
|
||||
export interface ValidatorId extends AccountId {}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -24,6 +24,24 @@ export default {
|
||||
start: 'Option<Moment>'
|
||||
},
|
||||
CompactAssignments: {
|
||||
votes1: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 0], ValidatorIndexCompact)>',
|
||||
votes2: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 1], ValidatorIndexCompact)>',
|
||||
votes3: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 2], ValidatorIndexCompact)>',
|
||||
votes4: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 3], ValidatorIndexCompact)>',
|
||||
votes5: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 4], ValidatorIndexCompact)>',
|
||||
votes6: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 5], ValidatorIndexCompact)>',
|
||||
votes7: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 6], ValidatorIndexCompact)>',
|
||||
votes8: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 7], ValidatorIndexCompact)>',
|
||||
votes9: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 8], ValidatorIndexCompact)>',
|
||||
votes10: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 9], ValidatorIndexCompact)>',
|
||||
votes11: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 10], ValidatorIndexCompact)>',
|
||||
votes12: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 11], ValidatorIndexCompact)>',
|
||||
votes13: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 12], ValidatorIndexCompact)>',
|
||||
votes14: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 13], ValidatorIndexCompact)>',
|
||||
votes15: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 14], ValidatorIndexCompact)>',
|
||||
votes16: 'Vec<(NominatorIndexCompact, [CompactScoreCompact; 15], ValidatorIndexCompact)>'
|
||||
},
|
||||
CompactAssignmentsTo257: {
|
||||
votes1: 'Vec<(NominatorIndex, [CompactScore; 0], ValidatorIndex)>',
|
||||
votes2: 'Vec<(NominatorIndex, [CompactScore; 1], ValidatorIndex)>',
|
||||
votes3: 'Vec<(NominatorIndex, [CompactScore; 2], ValidatorIndex)>',
|
||||
@@ -42,6 +60,7 @@ export default {
|
||||
votes16: 'Vec<(NominatorIndex, [CompactScore; 15], ValidatorIndex)>'
|
||||
},
|
||||
CompactScore: '(ValidatorIndex, OffchainAccuracy)',
|
||||
CompactScoreCompact: '(ValidatorIndexCompact, OffchainAccuracyCompact)',
|
||||
ElectionCompute: {
|
||||
_enum: ['OnChain', 'Signed', 'Authority']
|
||||
},
|
||||
@@ -96,8 +115,9 @@ export default {
|
||||
suppressed: 'bool'
|
||||
},
|
||||
NominatorIndex: 'u32',
|
||||
NominatorIndexCompact: 'Compact<NominatorIndex>',
|
||||
OffchainAccuracy: 'PerU16',
|
||||
PerU16: 'u16',
|
||||
OffchainAccuracyCompact: 'Compact<OffchainAccuracy>',
|
||||
PhragmenScore: '[u128; 3]',
|
||||
Points: 'u32',
|
||||
RewardDestination: {
|
||||
@@ -162,6 +182,7 @@ export default {
|
||||
era: 'Compact<BlockNumber>'
|
||||
},
|
||||
ValidatorIndex: 'u16',
|
||||
ValidatorIndexCompact: 'Compact<ValidatorIndex>',
|
||||
ValidatorPrefs: {
|
||||
commission: 'Compact<Perbill>'
|
||||
},
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { BTreeMap, Compact, Enum, Option, Struct, Vec } from '@polkadot/types/codec';
|
||||
import { bool, u128, u16, u32 } from '@polkadot/types/primitive';
|
||||
import { AccountId, Balance, BlockNumber, Moment, Perbill } from '@polkadot/types/interfaces/runtime';
|
||||
import { AccountId, Balance, BlockNumber, Moment, PerU16, Perbill } from '@polkadot/types/interfaces/runtime';
|
||||
|
||||
/** @name ActiveEraInfo */
|
||||
export interface ActiveEraInfo extends Struct {
|
||||
@@ -14,6 +14,26 @@ export interface ActiveEraInfo extends Struct {
|
||||
|
||||
/** @name CompactAssignments */
|
||||
export interface CompactAssignments extends Struct {
|
||||
readonly votes1: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
|
||||
readonly votes2: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
|
||||
readonly votes3: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
|
||||
readonly votes4: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
|
||||
readonly votes5: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
|
||||
readonly votes6: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
|
||||
readonly votes7: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
|
||||
readonly votes8: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
|
||||
readonly votes9: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
|
||||
readonly votes10: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
|
||||
readonly votes11: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
|
||||
readonly votes12: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
|
||||
readonly votes13: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
|
||||
readonly votes14: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
|
||||
readonly votes15: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
|
||||
readonly votes16: Vec<ITuple<[NominatorIndexCompact, Vec<CompactScoreCompact>, ValidatorIndexCompact]>>;
|
||||
}
|
||||
|
||||
/** @name CompactAssignmentsTo257 */
|
||||
export interface CompactAssignmentsTo257 extends Struct {
|
||||
readonly votes1: Vec<ITuple<[NominatorIndex, Vec<CompactScore>, ValidatorIndex]>>;
|
||||
readonly votes2: Vec<ITuple<[NominatorIndex, Vec<CompactScore>, ValidatorIndex]>>;
|
||||
readonly votes3: Vec<ITuple<[NominatorIndex, Vec<CompactScore>, ValidatorIndex]>>;
|
||||
@@ -35,6 +55,9 @@ export interface CompactAssignments extends Struct {
|
||||
/** @name CompactScore */
|
||||
export interface CompactScore extends ITuple<[ValidatorIndex, OffchainAccuracy]> {}
|
||||
|
||||
/** @name CompactScoreCompact */
|
||||
export interface CompactScoreCompact extends ITuple<[ValidatorIndexCompact, OffchainAccuracyCompact]> {}
|
||||
|
||||
/** @name ElectionCompute */
|
||||
export interface ElectionCompute extends Enum {
|
||||
readonly isOnChain: boolean;
|
||||
@@ -124,11 +147,14 @@ export interface Nominations extends Struct {
|
||||
/** @name NominatorIndex */
|
||||
export interface NominatorIndex extends u32 {}
|
||||
|
||||
/** @name NominatorIndexCompact */
|
||||
export interface NominatorIndexCompact extends Compact<NominatorIndex> {}
|
||||
|
||||
/** @name OffchainAccuracy */
|
||||
export interface OffchainAccuracy extends PerU16 {}
|
||||
|
||||
/** @name PerU16 */
|
||||
export interface PerU16 extends u16 {}
|
||||
/** @name OffchainAccuracyCompact */
|
||||
export interface OffchainAccuracyCompact extends Compact<OffchainAccuracy> {}
|
||||
|
||||
/** @name PhragmenScore */
|
||||
export interface PhragmenScore extends Vec<u128> {}
|
||||
@@ -224,6 +250,9 @@ export interface UnlockChunk extends Struct {
|
||||
/** @name ValidatorIndex */
|
||||
export interface ValidatorIndex extends u16 {}
|
||||
|
||||
/** @name ValidatorIndexCompact */
|
||||
export interface ValidatorIndexCompact extends Compact<ValidatorIndex> {}
|
||||
|
||||
/** @name ValidatorPrefs */
|
||||
export interface ValidatorPrefs extends Struct {
|
||||
readonly commission: Compact<Perbill>;
|
||||
|
||||
@@ -36,6 +36,7 @@ export * from './claims/types';
|
||||
export * from './parachains/types';
|
||||
export * from './poll/types';
|
||||
export * from './purchase/types';
|
||||
export * from './ethereum/types';
|
||||
export * from './metadata/types';
|
||||
export * from './rpc/types';
|
||||
export * from './author/types';
|
||||
|
||||
@@ -6,7 +6,6 @@ import { H256 } from '../interfaces/runtime';
|
||||
import { Codec, Registry } from '../types';
|
||||
|
||||
import { isU8a, u8aToHex } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
/** @internal */
|
||||
function decodeBool (value: any): boolean {
|
||||
@@ -46,7 +45,7 @@ export default class Bool extends Boolean implements Codec {
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return this.registry.createType('H256', blake2AsU8a(this.toU8a(), 256));
|
||||
return this.registry.createType('H256', this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,6 @@ import { H256 } from '../interfaces/runtime';
|
||||
import { AnyU8a, Codec, Registry } from '../types';
|
||||
|
||||
import { assert, hexToU8a, isHex, isString, stringToU8a, u8aToString, u8aToHex } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Compact from '../codec/Compact';
|
||||
import Raw from '../codec/Raw';
|
||||
@@ -69,7 +68,7 @@ export default class Text extends String implements Codec {
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return this.registry.createType('H256', blake2AsU8a(this.toU8a(), 256));
|
||||
return this.registry.createType('H256', this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@ export interface ICompact<T> extends Codec {
|
||||
|
||||
export interface IKeyringPair {
|
||||
address: string;
|
||||
addressRaw: Uint8Array;
|
||||
publicKey: Uint8Array;
|
||||
sign: (data: Uint8Array, options?: SignOptions) => Uint8Array;
|
||||
}
|
||||
|
||||
@@ -150,10 +150,12 @@ export interface Registry {
|
||||
hasClass (name: string): boolean;
|
||||
hasDef (name: string): boolean;
|
||||
hasType (name: string): boolean;
|
||||
hash (data: Uint8Array): Uint8Array;
|
||||
register (type: Constructor | RegistryTypes): void;
|
||||
register (name: string, type: Constructor): void;
|
||||
register (arg1: string | Constructor | RegistryTypes, arg2?: Constructor): void;
|
||||
setChainProperties (properties?: ChainProperties): void;
|
||||
setHasher (hasher?: (data: Uint8Array) => Uint8Array): void;
|
||||
setMetadata (metadata: RegistryMetadata, signedExtensions?: string[]): void;
|
||||
setSignedExtensions (signedExtensions?: string[]): void;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user