Compare commits

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

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

* CHANGELOG expansion

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

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

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

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

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

* Rename to fallback

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

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

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

* struct with nested struct & tuple

* extract conversion to type string

* Include < & > in split iteration

* Allow for nested ( & )

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

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

* check whether data is empty

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

* pull out zero balance function

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

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

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

* Optional last
2021-06-15 08:22:51 +02:00
Github Actions 227143728d [CI Skip] release/beta 4.14.2-0
skip-checks: true
2021-06-15 06:19:06 +00:00
Jaco 7330555c37 Latest metadata (#3647) 2021-06-15 08:08:16 +02:00
113 changed files with 1713 additions and 979 deletions
+3 -1
View File
@@ -1,4 +1,4 @@
30
31
1.4.2
1.6.2
1.11.2
@@ -23,3 +23,5 @@
4.7.2
4.9.2
4.11.2
4.16.2
+49
View File
@@ -1,5 +1,54 @@
# CHANGELOG
## 4.16.2 Jun 27, 2021
Upgrade priority: Low. Recommended for Polkadot with runtime >= 9050.
Changes:
- Correct `CompactAssignments` & `RawSolution` types for Polkadot
## 4.16.1 Jun 26, 2021
Upgrade priority: Low. Recommended for full from-genesis queries on Kusama.
Contributed:
- Adjust types for uniques (Thanks to https://github.com/Yuripetusko)
Changes:
- Add Kusama, Polkadot & Westend 9050 upgrade blocks
- Add Kusama & Westend 9070 upgrade blocks
- Adjust API decoration to lazy-create event and storage types
- Use TS `override` as applicable (with `--noImplicitOverrides` option)
- Add missing historic `Heartbeat: HeartbeatTo244` mapping to Kusama
- Remove duplication from contracts registry
- Add explicit check for scale-info 0.7+ (contracts index lookups)
- Align static metadata with latest Substrate
## 4.15.1 Jun 19, 2021
Upgrade priority: Medium. Recommended for all chains where Xcm is used (addition of new `XcmOrigin`)
Contributed:
- Added `ChargeAssetTxPayment` extension (Thanks to https://github.com/apopiak)
Changes:
- Allow for type decoding of nested fixed vectors, tuples and structs
- Added `childstate_getKeysPaged` RPC
- Add `XcmOrigin` mapping for `OriginCaller` generation
- Align static metadata with latest Substrate
- Adjust error message for contracts V3 (extrinsic from runtime)
- Correct module optionality in `api.derive.balances.account`
- Add alias for `GenericAddress` -> `GenericMultiAddress`
- Adjust metadata doc generation (keep spaces between subsequent lines)
## 4.14.1 Jun 14, 2021
Upgrade priority: Low. Internal adjustment only, no major external usage changes.
+7 -7
View File
@@ -8,7 +8,7 @@
"packages/*"
],
"resolutions": {
"typescript": "^4.3.2"
"typescript": "^4.3.4"
},
"scripts": {
"build": "yarn build:interfaces && polkadot-dev-build-ts",
@@ -20,19 +20,19 @@
"lint": "polkadot-dev-run-lint",
"clean": "polkadot-dev-clean-build",
"postinstall": "polkadot-dev-yarn-only",
"test": "polkadot-dev-run-test --coverage --detectOpenHandles --forceExit --runInBand --testPathIgnorePatterns e2e",
"test": "polkadot-dev-run-test --coverage --forceExit --runInBand --testPathIgnorePatterns e2e",
"test:one": "polkadot-dev-run-test --detectOpenHandles --forceExit",
"test:watch": "polkadot-dev-run-test --watch"
},
"devDependencies": {
"@babel/core": "^7.14.5",
"@babel/core": "^7.14.6",
"@babel/register": "^7.14.5",
"@babel/runtime": "^7.14.5",
"@polkadot/dev": "^0.62.42",
"@polkadot/ts": "^0.3.90",
"@babel/runtime": "^7.14.6",
"@polkadot/dev": "^0.62.43",
"@polkadot/ts": "^0.4.1",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^26.0.23",
"copyfiles": "^2.4.1"
},
"version": "4.14.1"
"version": "4.16.2"
}
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "4.14.1",
"version": "4.16.2",
"type": "module",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
@@ -19,10 +19,10 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.14.5",
"@polkadot/api": "4.14.1",
"@polkadot/types": "4.14.1",
"@polkadot/util": "^6.8.1",
"@polkadot/x-rxjs": "^6.8.1"
"@babel/runtime": "^7.14.6",
"@polkadot/api": "4.16.2",
"@polkadot/types": "4.16.2",
"@polkadot/util": "^6.10.1",
"@polkadot/x-rxjs": "^6.10.1"
}
}
+3 -3
View File
@@ -19,7 +19,7 @@ function findMessage <T extends AbiMessage> (list: T[], messageOrId: T | string
? list.find(({ identifier }) => [identifier, stringCamelCase(identifier)].includes(messageOrId.toString()))
: messageOrId;
return assertReturn(message, `Attempted to call an invalid contract interface, ${stringify(messageOrId)}`);
return assertReturn(message, () => `Attempted to call an invalid contract interface, ${stringify(messageOrId)}`);
}
export class Abi {
@@ -127,7 +127,7 @@ export class Abi {
const args = this.#createArgs(spec.args, spec);
const event = {
args,
docs: spec.docs.map((doc) => doc.toString()),
docs: spec.docs.map((d) => d.toString()),
fromU8a: (data: Uint8Array): DecodedEvent => ({
args: this.#decodeArgs(args, data),
event
@@ -145,7 +145,7 @@ export class Abi {
const message = {
...add,
args,
docs: spec.docs.map((doc) => doc.toString()),
docs: spec.docs.map((d) => d.toString()),
fromU8a: (data: Uint8Array): DecodedMessage => ({
args: this.#decodeArgs(args, data),
message
+32 -40
View File
@@ -35,8 +35,10 @@ export class MetaRegistry extends TypeRegistry {
constructor (metadataVersion: string, chainProperties?: ChainProperties) {
super();
// type indexes are 1-based pre-1.0 and 0-based post-1.0
this.typeOffset = metadataVersion.split('.')[0] === '0' ? 1 : 0;
const [major, minor] = metadataVersion.split('.').map((n) => parseInt(n, 10));
// type indexes are 1-based pre 0.7 and 0-based post
this.typeOffset = (major === 0 && minor < 7) ? 1 : 0;
if (chainProperties) {
this.setChainProperties(chainProperties);
@@ -124,7 +126,7 @@ export class MetaRegistry extends TypeRegistry {
: {}
),
...(path.length > 1
? { namespace: path.map((segment) => segment.toString()).join('::') }
? { namespace: path.map((s) => s.toString()).join('::') }
: {}
),
...(type.params.length > 0
@@ -154,15 +156,13 @@ export class MetaRegistry extends TypeRegistry {
assert(isTuple || isStruct, 'Invalid fields type detected, expected either Tuple or Struct');
const sub = fields.map(({ name, type }) => {
return {
...this.getMetaTypeDef({ type }),
...(name.isSome
? { name: name.unwrap().toString() }
: {}
)
};
});
const sub = fields.map(({ name, type }) => ({
...this.getMetaTypeDef({ type }),
...(name.isSome
? { name: name.unwrap().toString() }
: {}
)
}));
return isTuple && sub.length === 1
? sub[0]
@@ -213,32 +213,28 @@ export class MetaRegistry extends TypeRegistry {
const { params, path } = this.#getMetaType(id);
const specialVariant = path[0].toString();
if (specialVariant === 'Option') {
return {
return specialVariant === 'Option'
? {
info: TypeDefInfo.Option,
sub: this.getMetaTypeDef({ type: params[0] })
};
} else if (specialVariant === 'Result') {
return {
info: TypeDefInfo.Result,
sub: params.map((type, index) => ({
name: ['Ok', 'Error'][index],
...this.getMetaTypeDef({ type })
}))
};
}
return {
info: TypeDefInfo.Enum,
sub: this.#extractVariantSub(variants)
};
}
: specialVariant === 'Result'
? {
info: TypeDefInfo.Result,
sub: params.map((type, index) => ({
name: ['Ok', 'Error'][index],
...this.getMetaTypeDef({ type })
}))
}
: {
info: TypeDefInfo.Enum,
sub: this.#extractVariantSub(variants)
};
}
#extractVariantSub = (variants: SiVariant[]): TypeDef[] => {
const isAllUnitVariants = variants.every(({ fields }) => fields.length === 0);
if (isAllUnitVariants) {
return variants.map(({ discriminant, name }) => ({
return variants.every(({ fields }) => fields.length === 0)
? variants.map(({ discriminant, name }) => ({
...(
discriminant.isSome
? { ext: { discriminant: discriminant.unwrap().toNumber() } }
@@ -247,14 +243,10 @@ export class MetaRegistry extends TypeRegistry {
info: TypeDefInfo.Plain,
name: name.toString(),
type: 'Null'
}));
}
return variants.map(({ fields, name }) =>
withTypeString({
}))
: variants.map(({ fields, name }) => withTypeString({
...this.#extractFields(fields),
name: name.toString()
})
);
}));
}
}
+2 -1
View File
@@ -26,6 +26,7 @@ export abstract class Base<ApiType extends ApiTypes> {
this.registry = this.abi.registry;
this._decorateMethod = decorateMethod;
assert(isFunction(api.rx.tx.contracts?.instantiateWithCode), 'You need to connect to a node with a V3 contracts module. Your node does not expose api.tx.contracts.instantiateWithCode on this instance');
assert(!!(api && api.isConnected && api.tx && api.tx.contracts && Object.keys(api.tx.contracts).length), 'Your API has not been initialized correctly and it not decorated with the runtime interfaces for contracts as retrieved from the on-chain runtime');
assert(isFunction(api.tx.contracts.instantiateWithCode), 'You need to connect to a chain with a runtime with a V3 contracts module. The runtime does not expose api.tx.contracts.instantiateWithCode');
}
}
+5 -6
View File
@@ -7,13 +7,12 @@ import { TypeRegistry } from '@polkadot/types';
const registry = new TypeRegistry();
export const mockApi = {
isConnected: true,
registry,
rx: {
tx: {
contracts: {
instantiateWithCode: (): never => {
throw new Error('mock');
}
tx: {
contracts: {
instantiateWithCode: (): never => {
throw new Error('mock');
}
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-contract', version: '4.14.1' };
export const packageInfo = { name: '@polkadot/api-contract', version: '4.16.2' };
+10 -10
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "4.14.1",
"version": "4.16.2",
"type": "module",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
@@ -19,16 +19,16 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.14.5",
"@polkadot/api": "4.14.1",
"@polkadot/rpc-core": "4.14.1",
"@polkadot/types": "4.14.1",
"@polkadot/util": "^6.8.1",
"@polkadot/util-crypto": "^6.8.1",
"@polkadot/x-rxjs": "^6.8.1"
"@babel/runtime": "^7.14.6",
"@polkadot/api": "4.16.2",
"@polkadot/rpc-core": "4.16.2",
"@polkadot/types": "4.16.2",
"@polkadot/util": "^6.10.1",
"@polkadot/util-crypto": "^6.10.1",
"@polkadot/x-rxjs": "^6.10.1"
},
"devDependencies": {
"@polkadot/keyring": "^6.8.1",
"@polkadot/rpc-provider": "4.14.1"
"@polkadot/keyring": "^6.10.1",
"@polkadot/rpc-provider": "4.16.2"
}
}
+45 -16
View File
@@ -23,13 +23,19 @@ type DeriveCustomAccount = ApiInterfaceRx['derive'] & {
}
}
function zeroBalance (api: ApiInterfaceRx) {
return api.registry.createType('Balance');
}
function getBalance (api: ApiInterfaceRx, [freeBalance, reservedBalance, frozenFee, frozenMisc]: BalanceResult): DeriveBalancesAccountData {
const votingBalance = api.registry.createType('Balance', freeBalance.toBn());
return {
freeBalance,
frozenFee,
frozenMisc,
reservedBalance,
votingBalance: api.registry.createType('Balance', freeBalance.toBn())
votingBalance
};
}
@@ -55,7 +61,16 @@ function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observab
]).pipe(
map(([freeBalance, reservedBalance, accountNonce]): Result => [
accountNonce,
[[freeBalance, reservedBalance, api.registry.createType('Balance'), api.registry.createType('Balance')]]
[[freeBalance, reservedBalance, zeroBalance(api), zeroBalance(api)]]
])
);
}
function querySystemNonce (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
return api.query.system.accountNonce<Index>(accountId).pipe(
map((accountNonce): Result => [
accountNonce,
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
])
);
}
@@ -71,6 +86,7 @@ function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, module
const extract = (data: AccountData[]) =>
data.map(({ feeFrozen, free, miscFrozen, reserved }): BalanceResult => [free, reserved, feeFrozen, miscFrozen]);
// NOTE this is for the first case where we do have instances specified
return isFunction(api.query.system.account)
? api.queryMulti<[AccountInfo, ...(AccountData[])]>([[api.query.system.account, accountId], ...balances]).pipe(
map(([{ nonce }, ...balances]): Result => [nonce, extract(balances)])
@@ -80,16 +96,27 @@ function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, module
);
}
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
function querySystemAccount (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
// AccountInfo is current, support old, eg. Edgeware
return api.query.system.account<AccountInfo | ITuple<[Index, AccountData]>>(accountId).pipe(
map((infoOrTuple): Result => {
const { feeFrozen, free, miscFrozen, reserved } = (infoOrTuple as AccountInfo).nonce
const data = (infoOrTuple as AccountInfo).nonce
? (infoOrTuple as AccountInfo).data
: (infoOrTuple as [Index, AccountData])[1];
const nonce = (infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0];
if (!data || data.isEmpty) {
return [
nonce,
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
];
}
const { feeFrozen, free, miscFrozen, reserved } = data;
return [
(infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0],
nonce,
[[free, reserved, feeFrozen, miscFrozen]]
];
})
@@ -113,6 +140,10 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
*/
export function account (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAccount> {
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
const empty: Result = [
api.registry.createType('Index'),
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
];
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAccount> =>
api.derive.accounts.accountId(address).pipe(
@@ -122,19 +153,17 @@ export function account (instanceId: string, api: ApiInterfaceRx): (address: Acc
of(accountId),
balanceInstances
? queryBalancesAccount(api, accountId, balanceInstances)
: isFunction(api.query.system.account)
? queryCurrent(api, accountId)
: isFunction(api.query.balances.account)
: isFunction(api.query.system?.account)
? querySystemAccount(api, accountId)
: isFunction(api.query.balances?.account)
? queryBalancesAccount(api, accountId)
: queryBalancesFree(api, accountId)
])
: of([
api.registry.createType('AccountId'),
[
api.registry.createType('Index'),
[[api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance')]]
]
: isFunction(api.query.balances?.freeBalance)
? queryBalancesFree(api, accountId)
: isFunction(api.query.system?.accountNonce)
? querySystemNonce(api, accountId)
: of(empty)
])
: of([api.registry.createType('AccountId'), empty])
)
),
map((result): DeriveBalancesAccount => calcBalances(api, result))
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-derive', version: '4.14.1' };
export const packageInfo = { name: '@polkadot/api-derive', version: '4.16.2' };
@@ -120,8 +120,6 @@ function filterRewards (eras: EraIndex[], valInfo: [string, DeriveStakingQuery][
return false;
}
reward.isStakerPayout = true;
removeClaimed(validators, queryValidators, reward);
return true;
-1
View File
@@ -81,7 +81,6 @@ export interface DeriveStakerRewardValidator {
export interface DeriveStakerReward {
era: EraIndex;
eraReward: Balance;
isStakerPayout?: boolean;
isEmpty: boolean;
isValidator: boolean;
nominating: DeriveEraExposureNominating[];
+12 -12
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "4.14.1",
"version": "4.16.2",
"type": "module",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js",
@@ -19,17 +19,17 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": {
"@babel/runtime": "^7.14.5",
"@polkadot/api-derive": "4.14.1",
"@polkadot/keyring": "^6.8.1",
"@polkadot/metadata": "4.14.1",
"@polkadot/rpc-core": "4.14.1",
"@polkadot/rpc-provider": "4.14.1",
"@polkadot/types": "4.14.1",
"@polkadot/types-known": "4.14.1",
"@polkadot/util": "^6.8.1",
"@polkadot/util-crypto": "^6.8.1",
"@polkadot/x-rxjs": "^6.8.1",
"@babel/runtime": "^7.14.6",
"@polkadot/api-derive": "4.16.2",
"@polkadot/keyring": "^6.10.1",
"@polkadot/metadata": "4.16.2",
"@polkadot/rpc-core": "4.16.2",
"@polkadot/rpc-provider": "4.16.2",
"@polkadot/types": "4.16.2",
"@polkadot/types-known": "4.16.2",
"@polkadot/util": "^6.10.1",
"@polkadot/util-crypto": "^6.10.1",
"@polkadot/x-rxjs": "^6.10.1",
"eventemitter3": "^4.0.7"
}
}
+4 -8
View File
@@ -1,7 +1,7 @@
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
/* eslint-disable */
import type { Vec, u16, u32, u64, u8 } from '@polkadot/types';
import type { Vec, u16, u32, u64 } from '@polkadot/types';
import type { Codec } from '@polkadot/types/types';
import type { Schedule } from '@polkadot/types/interfaces/contracts';
import type { Balance, BalanceOf, BlockNumber, LockIdentifier, Moment, PalletId, Perbill, Percent, Permill, RuntimeDbWeight, Weight } from '@polkadot/types/interfaces/runtime';
@@ -508,9 +508,6 @@ declare module '@polkadot/api/types/consts' {
* Number of eras that staked funds must remain bonded for.
**/
bondingDuration: EraIndex & AugmentedConst<ApiType>;
/**
* Maximum number of nominations per nominator.
**/
maxNominations: u32 & AugmentedConst<ApiType>;
/**
* The maximum number of nominators rewarded for each validator.
@@ -526,9 +523,8 @@ declare module '@polkadot/api/types/consts' {
/**
* Number of eras that slashes are deferred by, after computation.
*
* This should be less than the bonding duration.
* Set to 0 if slashes should be applied immediately, without opportunity for
* intervention.
* This should be less than the bonding duration. Set to 0 if slashes
* should be applied immediately, without opportunity for intervention.
**/
slashDeferDuration: EraIndex & AugmentedConst<ApiType>;
/**
@@ -560,7 +556,7 @@ declare module '@polkadot/api/types/consts' {
* that the runtime should know about the prefix in order to make use of it as
* an identifier of the chain.
**/
ss58Prefix: u8 & AugmentedConst<ApiType>;
ss58Prefix: u16 & AugmentedConst<ApiType>;
/**
* Get the chain's current version.
**/
+28 -7
View File
@@ -256,9 +256,9 @@ declare module '@polkadot/api/types/errors' {
**/
DuplicateTopics: AugmentedError<ApiType>;
/**
* `seal_input` was called twice from the same contract execution context.
* `seal_call` forwarded this contracts input. It therefore is no longer available.
**/
InputAlreadyRead: AugmentedError<ApiType>;
InputForwarded: AugmentedError<ApiType>;
/**
* An origin TrieId written in the current block.
**/
@@ -316,9 +316,7 @@ declare module '@polkadot/api/types/errors' {
**/
RandomSubjectTooLong: AugmentedError<ApiType>;
/**
* The action performed is not allowed while the contract performing it is already
* on the call stack. Those actions are contract self destruction and restoration
* of a tombstone.
* A call tried to invoke a contract that is flagged as non-reentrant.
**/
ReentranceDenied: AugmentedError<ApiType>;
/**
@@ -343,6 +341,11 @@ declare module '@polkadot/api/types/errors' {
* This can be triggered by a call to `seal_terminate` or `seal_restore_to`.
**/
TerminatedInConstructor: AugmentedError<ApiType>;
/**
* Termination of a contract is not allowed while the contract is already
* on the call stack. Can be triggered by `seal_terminate` or `seal_restore_to.
**/
TerminatedWhileReentrant: AugmentedError<ApiType>;
/**
* The amount of topics passed to `seal_deposit_events` exceeds the limit.
**/
@@ -548,6 +551,10 @@ declare module '@polkadot/api/types/errors' {
[key: string]: AugmentedError<ApiType>;
};
electionProviderMultiPhase: {
/**
* The call is not allowed at this point.
**/
CallNotAllowed: AugmentedError<ApiType>;
/**
* OCW submitted solution for wrong round
**/
@@ -1179,6 +1186,10 @@ declare module '@polkadot/api/types/errors' {
* A nomination target was supplied that was blocked or otherwise not a validator.
**/
BadTarget: AugmentedError<ApiType>;
/**
* The user has enough bond and thus cannot be chilled forcefully by an external person.
**/
CannotChillOther: AugmentedError<ApiType>;
/**
* Duplicate index.
**/
@@ -1200,9 +1211,9 @@ declare module '@polkadot/api/types/errors' {
**/
IncorrectSlashingSpans: AugmentedError<ApiType>;
/**
* Can not bond with value less than minimum balance.
* Can not bond with value less than minimum required.
**/
InsufficientValue: AugmentedError<ApiType>;
InsufficientBond: AugmentedError<ApiType>;
/**
* Invalid era to reward.
**/
@@ -1235,10 +1246,20 @@ declare module '@polkadot/api/types/errors' {
* Can not rebond without unlocking chunks.
**/
NoUnlockChunk: AugmentedError<ApiType>;
/**
* There are too many nominators in the system. Governance needs to adjust the staking settings
* to keep things safe for the runtime.
**/
TooManyNominators: AugmentedError<ApiType>;
/**
* Too many nomination targets supplied.
**/
TooManyTargets: AugmentedError<ApiType>;
/**
* There are too many validators in the system. Governance needs to adjust the staking settings
* to keep things safe for the runtime.
**/
TooManyValidators: AugmentedError<ApiType>;
/**
* Generic error
**/
+4
View File
@@ -835,6 +835,10 @@ declare module '@polkadot/api/types/events' {
* A new set of stakers was elected.
**/
StakingElection: AugmentedEvent<ApiType, []>;
/**
* The election failed. No new era is planned.
**/
StakingElectionFailed: AugmentedEvent<ApiType, []>;
/**
* An account has unbonded this amount. \[stash, amount\]
**/
+32
View File
@@ -883,6 +883,14 @@ declare module '@polkadot/api/types/storage' {
* canceled by extraordinary circumstances (e.g. governance).
**/
canceledSlashPayout: AugmentedQuery<ApiType, () => Observable<BalanceOf>, []> & QueryableStorageEntry<ApiType, []>;
/**
* A tracker to keep count of the number of items in the `Nominators` map.
**/
counterForNominators: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
* A tracker to keep count of the number of items in the `Validators` map.
**/
counterForValidators: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The current era index.
*
@@ -978,12 +986,34 @@ declare module '@polkadot/api/types/storage' {
* Map from all (unlocked) "controller" accounts to the info regarding the staking.
**/
ledger: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<StakingLedger>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
* The maximum nominator count before we stop allowing new validators to join.
*
* When this value is not set, no limits are enforced.
**/
maxNominatorsCount: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The maximum validator count before we stop allowing new validators to join.
*
* When this value is not set, no limits are enforced.
**/
maxValidatorsCount: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Minimum number of staking participants before emergency conditions are imposed.
**/
minimumValidatorCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The minimum active bond to become and maintain the role of a nominator.
**/
minNominatorBond: AugmentedQuery<ApiType, () => Observable<BalanceOf>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The minimum active bond to become and maintain the role of a validator.
**/
minValidatorBond: AugmentedQuery<ApiType, () => Observable<BalanceOf>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The map from nominator stash key to the set of stash keys of all validators to nominate.
*
* When updating this storage item, you must also update the `CounterForNominators`.
**/
nominators: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<Nominations>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
@@ -1026,6 +1056,8 @@ declare module '@polkadot/api/types/storage' {
validatorCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
/**
* The map from (wannabe) validator stash key to the preferences of that validator.
*
* When updating this storage item, you must also update the `CounterForValidators`.
**/
validators: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ValidatorPrefs>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
/**
+4
View File
@@ -106,6 +106,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Returns the keys with prefix from a child storage, leave empty to get all the keys
**/
getKeys: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, prefix: StorageKey | string | Uint8Array | any, at?: Hash | string | Uint8Array) => Observable<Vec<StorageKey>>>;
/**
* Returns the keys with prefix from a child storage with pagination support
**/
getKeysPaged: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, prefix: StorageKey | string | Uint8Array | any, count: u32 | AnyNumber | Uint8Array, startKey?: StorageKey | string | Uint8Array | any, at?: Hash | string | Uint8Array) => Observable<Vec<StorageKey>>>;
/**
* Returns a child storage entry at a specific block state
**/
+92 -3
View File
@@ -19,7 +19,7 @@ import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber,
import type { Period, Priority } from '@polkadot/types/interfaces/scheduler';
import type { Keys } from '@polkadot/types/interfaces/session';
import type { SocietyJudgement } from '@polkadot/types/interfaces/society';
import type { ElectionScore, EraIndex, RawSolution, RewardDestination, SolutionOrSnapshotSize, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
import type { ElectionScore, EraIndex, RawSolution, ReadySolution, RewardDestination, SolutionOrSnapshotSize, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
import type { Key } from '@polkadot/types/interfaces/system';
import type { BountyIndex } from '@polkadot/types/interfaces/treasury';
import type { ClassId, DestroyWitness, InstanceId } from '@polkadot/types/interfaces/uniques';
@@ -134,6 +134,10 @@ declare module '@polkadot/api/types/submittable' {
*
* Emits `Destroyed` event when successful.
*
* NOTE: It can be helpful to first freeze an asset before destroying it so that you
* can provide accurate witness information and prevent users from manipulating state
* in a way that can make it harder to destroy.
*
* Weight: `O(c + p + a)` where:
* - `c = (witness.accounts - witness.sufficients)`
* - `s = witness.sufficients`
@@ -538,6 +542,27 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
transfer: AugmentedSubmittable<(dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<Balance>]>;
/**
* Transfer the entire transferable balance from the caller account.
*
* NOTE: This function only attempts to transfer _transferable_ balances. This means that
* any locked, reserved, or existential deposits (when `keep_alive` is `true`), will not be
* transferred by this function. To ensure that this function results in a killed account,
* you might need to prepare the account by removing any reference counters, storage
* deposits, etc...
*
* The dispatch origin of this call must be Signed.
*
* - `dest`: The recipient of the transfer.
* - `keep_alive`: A boolean to determine if the `transfer_all` operation should send all
* of the funds the account has, causing the sender account to be killed (false), or
* transfer everything except at least the existential deposit, which will guarantee to
* keep the sender account alive (true).
* # <weight>
* - O(1). Just like transfer, but reading the user's transferable balance first.
* #</weight>
**/
transferAll: AugmentedSubmittable<(dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, keepAlive: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, bool]>;
/**
* Same as the [`transfer`] call, but with a check that the transfer will not kill the
* origin account.
@@ -1221,6 +1246,17 @@ declare module '@polkadot/api/types/submittable' {
[key: string]: SubmittableExtrinsicFunction<ApiType>;
};
electionProviderMultiPhase: {
/**
* Set a solution in the queue, to be handed out to the client of this pallet in the next
* call to `ElectionProvider::elect`.
*
* This can only be set by `T::ForceOrigin`, and only when the phase is `Emergency`.
*
* The solution is not checked for any feasibility and is assumed to be trustworthy, as any
* feasibility check itself can in principle cause the election process to fail (due to
* memory/weight constrains).
**/
setEmergencyElectionResult: AugmentedSubmittable<(solution: ReadySolution | { supports?: any; score?: any; compute?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [ReadySolution]>;
/**
* Set a new value for `MinimumUntrustedScore`.
*
@@ -2525,7 +2561,7 @@ declare module '@polkadot/api/types/submittable' {
* Actual cost depends on the number of length of `T::Keys::key_ids()` which is fixed.
* - DbReads: `T::ValidatorIdOf`, `NextKeys`, `origin account`
* - DbWrites: `NextKeys`, `origin account`
* - DbWrites per key id: `KeyOwnder`
* - DbWrites per key id: `KeyOwner`
* # </weight>
**/
purgeKeys: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
@@ -2960,12 +2996,34 @@ declare module '@polkadot/api/types/submittable' {
* # </weight>
**/
chill: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
/**
* Declare a `controller` as having no desire to either validator or nominate.
*
* Effects will be felt at the beginning of the next era.
*
* The dispatch origin for this call must be _Signed_, but can be called by anyone.
*
* If the caller is the same as the controller being targeted, then no further checks
* are enforced. However, this call can also be made by an third party user who witnesses
* that this controller does not satisfy the minimum bond requirements to be in their role.
*
* This can be helpful if bond requirements are updated, and we need to remove old users
* who do not satisfy these requirements.
*
**/
chillOther: AugmentedSubmittable<(controller: AccountId | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId]>;
/**
* Force there to be a new era at the end of the next session. After this, it will be
* reset to normal (non-forced) behaviour.
*
* The dispatch origin must be Root.
*
* # Warning
*
* The election process starts multiple blocks before the end of the era.
* If this is called just before a new era is triggered, the election process may not
* have enough blocks to get a result.
*
* # <weight>
* - No arguments.
* - Weight: O(1)
@@ -2978,6 +3036,12 @@ declare module '@polkadot/api/types/submittable' {
*
* The dispatch origin must be Root.
*
* # Warning
*
* The election process starts multiple blocks before the end of the era.
* If this is called just before a new era is triggered, the election process may not
* have enough blocks to get a result.
*
* # <weight>
* - Weight: O(1)
* - Write: ForceEra
@@ -2989,6 +3053,12 @@ declare module '@polkadot/api/types/submittable' {
*
* The dispatch origin must be Root.
*
* # Warning
*
* The election process starts multiple blocks before the end of the era.
* Thus the election process may be ongoing when this is called. In this case the
* election will continue until the next era is triggered.
*
* # <weight>
* - No arguments.
* - Weight: O(1)
@@ -3229,6 +3299,9 @@ declare module '@polkadot/api/types/submittable' {
* can co-exists at the same time. In that case, [`Call::withdraw_unbonded`] need
* to be called first to remove some of the chunks (if possible).
*
* If a user encounters the `InsufficientBond` error when calling this extrinsic,
* they should call `chill` first in order to free up their bonded funds.
*
* The dispatch origin for this call must be _Signed_ by the controller, not the stash.
* And, it can be only called when [`EraElectionStatus`] is `Closed`.
*
@@ -3252,6 +3325,22 @@ declare module '@polkadot/api/types/submittable' {
* </weight>
**/
unbond: AugmentedSubmittable<(value: Compact<BalanceOf> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<BalanceOf>]>;
/**
* Update the various staking limits this pallet.
*
* * `min_nominator_bond`: The minimum active bond needed to be a nominator.
* * `min_validator_bond`: The minimum active bond needed to be a validator.
* * `max_nominator_count`: The max number of users who can be a nominator at once.
* When set to `None`, no limit is enforced.
* * `max_validator_count`: The max number of users who can be a validator at once.
* When set to `None`, no limit is enforced.
*
* Origin must be Root to call this function.
*
* NOTE: Existing nominators and validators will not be affected by this update.
* to kick people under the new limits, `chill_other` should be called.
**/
updateStakingLimits: AugmentedSubmittable<(minNominatorBond: BalanceOf | AnyNumber | Uint8Array, minValidatorBond: BalanceOf | AnyNumber | Uint8Array, maxNominatorCount: Option<u32> | null | object | string | Uint8Array, maxValidatorCount: Option<u32> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [BalanceOf, BalanceOf, Option<u32>, Option<u32>]>;
/**
* Declare the desire to validate for the origin controller.
*
@@ -4052,7 +4141,7 @@ declare module '@polkadot/api/types/submittable' {
* - `m = witness.instance_metdadatas`
* - `a = witness.attributes`
**/
destroy: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, witness: DestroyWitness | { instances?: any; instanceMetadatas?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, DestroyWitness]>;
destroy: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, witness: DestroyWitness | { instances?: any; instanceMetadatas?: any; attributes?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, DestroyWitness]>;
/**
* Alter the attributes of a given asset.
*
-7
View File
@@ -82,13 +82,6 @@ export abstract class Getters<ApiType extends ApiTypes> extends Init<ApiType> {
return assertResult(this._genesisHash);
}
/**
* @description `true` when subscriptions are supported
*/
public get hasSubscriptions (): boolean {
return this._rpcCore.provider.hasSubscriptions;
}
/**
* @description true is the underlying provider is connected
*/
+1 -1
View File
@@ -286,7 +286,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
}
// get unique types & validate
metadata.getUniqTypes(false);
metadata.getUniqTypes(this._options.throwOnUnknown || false);
return [genesisHash, metadata];
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api', version: '4.14.1' };
export const packageInfo = { name: '@polkadot/api', version: '4.16.2' };
+3 -1
View File
@@ -3,6 +3,8 @@
import type { SubmittableExtrinsic } from '../types';
import { jest } from '@jest/globals';
import { createPair } from '@polkadot/keyring/pair';
import { createTestKeyring } from '@polkadot/keyring/testing';
import { MockProvider } from '@polkadot/rpc-provider/mock';
@@ -91,7 +93,7 @@ describe('ApiPromise', (): void => {
super({ provider });
}
protected _loadMeta (): Promise<boolean> {
protected override _loadMeta (): Promise<boolean> {
throw new Error('Simulate failure to load meta');
}
}
+1 -1
View File
@@ -110,7 +110,7 @@ export function createClass <ApiType extends ApiTypes> ({ api, apiType, decorate
* @description Sign a transaction, returning the this to allow chaining, i.e. .sign(...).send(). When options, e.g. nonce/blockHash are not specified, it will be inferred. To retrieve eg. nonce use `signAsync` (the preferred interface, this is provided for backwards compatibility)
* @deprecated
*/
public sign (account: IKeyringPair, optionsOrNonce?: Partial<SignerOptions>): this {
public override sign (account: IKeyringPair, optionsOrNonce?: Partial<SignerOptions>): this {
super.sign(account, this.#makeSignOptions(this.#optionsOrNonce(optionsOrNonce), {}));
return this;
+4
View File
@@ -73,6 +73,10 @@ export interface ApiOptions extends RegisteredTypes {
* @description Throws an error when the initial connection fails (same as isReadyOrError)
*/
throwOnConnect?: boolean;
/**
* @description Throws an error when some types are unknown (useful with throwOnConnect)
*/
throwOnUnknown?: boolean;
}
// A smaller interface of ApiRx, used in derive and in SubmittableExtrinsic
+2
View File
@@ -1,6 +1,8 @@
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { jest } from '@jest/globals';
import { ApiPromise, WsProvider } from '@polkadot/api';
describe('misc online tests', (): void => {
@@ -7,6 +7,8 @@ import type { Option } from '@polkadot/types/codec';
import type { AccountId, AccountIndex, AccountInfo, Address, Balance, BlockNumber, Index } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import { jest } from '@jest/globals';
import { ApiPromise, WsProvider } from '@polkadot/api';
import { memo } from '@polkadot/api-derive/util/memo';
import { combineLatest, of } from '@polkadot/x-rxjs';
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/metadata",
"version": "4.14.1",
"version": "4.16.2",
"type": "module",
"description": "Helpers to extract information from runtime metadata",
"main": "index.js",
@@ -19,13 +19,13 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
"dependencies": {
"@babel/runtime": "^7.14.5",
"@polkadot/types": "4.14.1",
"@polkadot/types-known": "4.14.1",
"@polkadot/util": "^6.8.1",
"@polkadot/util-crypto": "^6.8.1"
"@babel/runtime": "^7.14.6",
"@polkadot/types": "4.16.2",
"@polkadot/types-known": "4.16.2",
"@polkadot/util": "^6.10.1",
"@polkadot/util-crypto": "^6.10.1"
},
"devDependencies": {
"@polkadot/keyring": "^6.8.1"
"@polkadot/keyring": "^6.10.1"
}
}
+1 -1
View File
@@ -142,7 +142,7 @@ export class MetadataVersioned extends Struct {
/**
* @description Converts the Object to JSON, typically used for RPC transfers
*/
public toJSON (): Record<string, AnyJson> {
public override toJSON (): Record<string, AnyJson> {
// HACK(y): ensure that we apply the aliases if we have not done so already, this is
// needed to ensure we have the correct overrides (which is only applied in toLatest)
// eslint-disable-next-line no-unused-expressions
@@ -89,7 +89,7 @@ function extendHeadMeta (registry: Registry, { meta: { documentation, name, type
// meta fallback only applies to actual entry values, create one for head
(iterFn as IterFn).meta = registry.createType('StorageEntryMetadataLatest', {
documentation,
fallback: registry.createType('Bytes', registry.createType(outputType.toString() as 'Raw').toHex()),
fallback: registry.createType('Bytes'),
modifier: registry.createType('StorageEntryModifierLatest', 1), // required
name,
type: registry.createType('StorageEntryTypeLatest', registry.createType('Type', outputType), 0)
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/metadata', version: '4.14.1' };
export const packageInfo = { name: '@polkadot/metadata', version: '4.16.2' };
+269 -23
View File
@@ -506,8 +506,8 @@
},
{
"name": "SS58Prefix",
"type": "u8",
"value": "0x2a",
"type": "u16",
"value": "0x2a00",
"documentation": [
" The designated SS85 prefix of this chain.",
"",
@@ -1638,6 +1638,39 @@
" - DB Weight: 1 Read and 1 Write to dest (sender is in overlay already)",
" #</weight>"
]
},
{
"name": "transfer_all",
"args": [
{
"name": "dest",
"type": "LookupSource"
},
{
"name": "keep_alive",
"type": "bool"
}
],
"documentation": [
" Transfer the entire transferable balance from the caller account.",
"",
" NOTE: This function only attempts to transfer _transferable_ balances. This means that",
" any locked, reserved, or existential deposits (when `keep_alive` is `true`), will not be",
" transferred by this function. To ensure that this function results in a killed account,",
" you might need to prepare the account by removing any reference counters, storage",
" deposits, etc...",
"",
" The dispatch origin of this call must be Signed.",
"",
" - `dest`: The recipient of the transfer.",
" - `keep_alive`: A boolean to determine if the `transfer_all` operation should send all",
" of the funds the account has, causing the sender account to be killed (false), or",
" transfer everything except at least the existential deposit, which will guarantee to",
" keep the sender account alive (true).",
" # <weight>",
" - O(1). Just like transfer, but reading the user's transferable balance first.",
" #</weight>"
]
}
],
"events": [
@@ -1982,6 +2015,25 @@
"",
" This check can be turned off by setting the value to `None`."
]
},
{
"name": "set_emergency_election_result",
"args": [
{
"name": "solution",
"type": "ReadySolution"
}
],
"documentation": [
" Set a solution in the queue, to be handed out to the client of this pallet in the next",
" call to `ElectionProvider::elect`.",
"",
" This can only be set by `T::ForceOrigin`, and only when the phase is `Emergency`.",
"",
" The solution is not checked for any feasibility and is assumed to be trustworthy, as any",
" feasibility check itself can in principle cause the election process to fail (due to",
" memory/weight constrains)."
]
}
],
"events": [
@@ -2106,6 +2158,12 @@
"documentation": [
" OCW submitted solution for wrong round"
]
},
{
"name": "CallNotAllowed",
"documentation": [
" The call is not allowed at this point."
]
}
],
"index": 8
@@ -2183,6 +2241,28 @@
" Map from all locked \"stash\" accounts to the controller account."
]
},
{
"name": "MinNominatorBond",
"modifier": "Default",
"type": {
"plain": "BalanceOf"
},
"fallback": "0x00000000000000000000000000000000",
"documentation": [
" The minimum active bond to become and maintain the role of a nominator."
]
},
{
"name": "MinValidatorBond",
"modifier": "Default",
"type": {
"plain": "BalanceOf"
},
"fallback": "0x00000000000000000000000000000000",
"documentation": [
" The minimum active bond to become and maintain the role of a validator."
]
},
{
"name": "Ledger",
"modifier": "Optional",
@@ -2228,7 +2308,33 @@
},
"fallback": "0x0000",
"documentation": [
" The map from (wannabe) validator stash key to the preferences of that validator."
" The map from (wannabe) validator stash key to the preferences of that validator.",
"",
" When updating this storage item, you must also update the `CounterForValidators`."
]
},
{
"name": "CounterForValidators",
"modifier": "Default",
"type": {
"plain": "u32"
},
"fallback": "0x00000000",
"documentation": [
" A tracker to keep count of the number of items in the `Validators` map."
]
},
{
"name": "MaxValidatorsCount",
"modifier": "Optional",
"type": {
"plain": "u32"
},
"fallback": "0x00",
"documentation": [
" The maximum validator count before we stop allowing new validators to join.",
"",
" When this value is not set, no limits are enforced."
]
},
{
@@ -2244,7 +2350,33 @@
},
"fallback": "0x00",
"documentation": [
" The map from nominator stash key to the set of stash keys of all validators to nominate."
" The map from nominator stash key to the set of stash keys of all validators to nominate.",
"",
" When updating this storage item, you must also update the `CounterForNominators`."
]
},
{
"name": "CounterForNominators",
"modifier": "Default",
"type": {
"plain": "u32"
},
"fallback": "0x00000000",
"documentation": [
" A tracker to keep count of the number of items in the `Nominators` map."
]
},
{
"name": "MaxNominatorsCount",
"modifier": "Optional",
"type": {
"plain": "u32"
},
"fallback": "0x00",
"documentation": [
" The maximum nominator count before we stop allowing new validators to join.",
"",
" When this value is not set, no limits are enforced."
]
},
{
@@ -2580,7 +2712,7 @@
"type": {
"plain": "Releases"
},
"fallback": "0x05",
"fallback": "0x06",
"documentation": [
" True if network has been upgraded to this version.",
" Storage version of the pallet.",
@@ -2684,6 +2816,9 @@
" can co-exists at the same time. In that case, [`Call::withdraw_unbonded`] need",
" to be called first to remove some of the chunks (if possible).",
"",
" If a user encounters the `InsufficientBond` error when calling this extrinsic,",
" they should call `chill` first in order to free up their bonded funds.",
"",
" The dispatch origin for this call must be _Signed_ by the controller, not the stash.",
" And, it can be only called when [`EraElectionStatus`] is `Closed`.",
"",
@@ -2947,6 +3082,12 @@
"",
" The dispatch origin must be Root.",
"",
" # Warning",
"",
" The election process starts multiple blocks before the end of the era.",
" Thus the election process may be ongoing when this is called. In this case the",
" election will continue until the next era is triggered.",
"",
" # <weight>",
" - No arguments.",
" - Weight: O(1)",
@@ -2963,6 +3104,12 @@
"",
" The dispatch origin must be Root.",
"",
" # Warning",
"",
" The election process starts multiple blocks before the end of the era.",
" If this is called just before a new era is triggered, the election process may not",
" have enough blocks to get a result.",
"",
" # <weight>",
" - No arguments.",
" - Weight: O(1)",
@@ -3022,6 +3169,12 @@
"",
" The dispatch origin must be Root.",
"",
" # Warning",
"",
" The election process starts multiple blocks before the end of the era.",
" If this is called just before a new era is triggered, the election process may not",
" have enough blocks to get a result.",
"",
" # <weight>",
" - Weight: O(1)",
" - Write: ForceEra",
@@ -3213,6 +3366,66 @@
" Note: Making this call only makes sense if you first set the validator preferences to",
" block any further nominations."
]
},
{
"name": "update_staking_limits",
"args": [
{
"name": "min_nominator_bond",
"type": "BalanceOf"
},
{
"name": "min_validator_bond",
"type": "BalanceOf"
},
{
"name": "max_nominator_count",
"type": "Option<u32>"
},
{
"name": "max_validator_count",
"type": "Option<u32>"
}
],
"documentation": [
" Update the various staking limits this pallet.",
"",
" * `min_nominator_bond`: The minimum active bond needed to be a nominator.",
" * `min_validator_bond`: The minimum active bond needed to be a validator.",
" * `max_nominator_count`: The max number of users who can be a nominator at once.",
" When set to `None`, no limit is enforced.",
" * `max_validator_count`: The max number of users who can be a validator at once.",
" When set to `None`, no limit is enforced.",
"",
" Origin must be Root to call this function.",
"",
" NOTE: Existing nominators and validators will not be affected by this update.",
" to kick people under the new limits, `chill_other` should be called."
]
},
{
"name": "chill_other",
"args": [
{
"name": "controller",
"type": "AccountId"
}
],
"documentation": [
" Declare a `controller` as having no desire to either validator or nominate.",
"",
" Effects will be felt at the beginning of the next era.",
"",
" The dispatch origin for this call must be _Signed_, but can be called by anyone.",
"",
" If the caller is the same as the controller being targeted, then no further checks",
" are enforced. However, this call can also be made by an third party user who witnesses",
" that this controller does not satisfy the minimum bond requirements to be in their role.",
"",
" This can be helpful if bond requirements are updated, and we need to remove old users",
" who do not satisfy these requirements.",
""
]
}
],
"events": [
@@ -3310,6 +3523,13 @@
"documentation": [
" A nominator has been kicked from a validator. \\[nominator, stash\\]"
]
},
{
"name": "StakingElectionFailed",
"args": [],
"documentation": [
" The election failed. No new era is planned."
]
}
],
"constants": [
@@ -3336,9 +3556,8 @@
"documentation": [
" Number of eras that slashes are deferred by, after computation.",
"",
" This should be less than the bonding duration.",
" Set to 0 if slashes should be applied immediately, without opportunity for",
" intervention."
" This should be less than the bonding duration. Set to 0 if slashes",
" should be applied immediately, without opportunity for intervention."
]
},
{
@@ -3356,9 +3575,7 @@
"name": "MaxNominations",
"type": "u32",
"value": "0x10000000",
"documentation": [
" Maximum number of nominations per nominator."
]
"documentation": []
}
],
"errors": [
@@ -3405,9 +3622,9 @@
]
},
{
"name": "InsufficientValue",
"name": "InsufficientBond",
"documentation": [
" Can not bond with value less than minimum balance."
" Can not bond with value less than minimum required."
]
},
{
@@ -3481,6 +3698,26 @@
"documentation": [
" A nomination target was supplied that was blocked or otherwise not a validator."
]
},
{
"name": "CannotChillOther",
"documentation": [
" The user has enough bond and thus cannot be chilled forcefully by an external person."
]
},
{
"name": "TooManyNominators",
"documentation": [
" There are too many nominators in the system. Governance needs to adjust the staking settings",
" to keep things safe for the runtime."
]
},
{
"name": "TooManyValidators",
"documentation": [
" There are too many validators in the system. Governance needs to adjust the staking settings",
" to keep things safe for the runtime."
]
}
],
"index": 9
@@ -3627,7 +3864,7 @@
" Actual cost depends on the number of length of `T::Keys::key_ids()` which is fixed.",
" - DbReads: `T::ValidatorIdOf`, `NextKeys`, `origin account`",
" - DbWrites: `NextKeys`, `origin account`",
" - DbWrites per key id: `KeyOwnder`",
" - DbWrites per key id: `KeyOwner`",
" # </weight>"
]
}
@@ -7561,17 +7798,16 @@
]
},
{
"name": "ReentranceDenied",
"name": "TerminatedWhileReentrant",
"documentation": [
" The action performed is not allowed while the contract performing it is already",
" on the call stack. Those actions are contract self destruction and restoration",
" of a tombstone."
" Termination of a contract is not allowed while the contract is already",
" on the call stack. Can be triggered by `seal_terminate` or `seal_restore_to."
]
},
{
"name": "InputAlreadyRead",
"name": "InputForwarded",
"documentation": [
" `seal_input` was called twice from the same contract execution context."
" `seal_call` forwarded this contracts input. It therefore is no longer available."
]
},
{
@@ -7647,6 +7883,12 @@
"documentation": [
" The debug message specified to `seal_debug_message` does contain invalid UTF-8."
]
},
{
"name": "ReentranceDenied",
"documentation": [
" A call tried to invoke a contract that is flagged as non-reentrant."
]
}
],
"index": 18
@@ -7951,7 +8193,7 @@
{
"name": "AuthorityDiscovery",
"storage": null,
"calls": [],
"calls": null,
"events": null,
"constants": [],
"errors": [],
@@ -8018,7 +8260,7 @@
}
]
},
"calls": [],
"calls": null,
"events": [
{
"name": "Offence",
@@ -8066,7 +8308,7 @@
}
]
},
"calls": [],
"calls": null,
"events": null,
"constants": [],
"errors": [],
@@ -12825,6 +13067,10 @@
"",
" Emits `Destroyed` event when successful.",
"",
" NOTE: It can be helpful to first freeze an asset before destroying it so that you",
" can provide accurate witness information and prevent users from manipulating state",
" in a way that can make it harder to destroy.",
"",
" Weight: `O(c + p + a)` where:",
" - `c = (witness.accounts - witness.sufficients)`",
" - `s = witness.sufficients`",
File diff suppressed because one or more lines are too long
+4 -1
View File
@@ -13,10 +13,13 @@ import { stringCamelCase } from '@polkadot/util';
// in a pure Substrate/Polkadot implementation, any other custom origins won't be handled at all
const KNOWN_ORIGINS: Record<string, string> = {
/* eslint-disable sort-keys */
// Substrate/Polkadot
// Substrate
Council: 'CollectiveOrigin',
System: 'SystemOrigin',
TechnicalCommittee: 'CollectiveOrigin',
// Polkadot
Xcm: 'XcmOrigin',
XcmPallet: 'XcmOrigin',
// Acala
Authority: 'AuthorityOrigin',
GeneralCouncil: 'CollectiveOrigin'
+8 -8
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-core",
"version": "4.14.1",
"version": "4.16.2",
"type": "module",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
@@ -19,14 +19,14 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": {
"@babel/runtime": "^7.14.5",
"@polkadot/metadata": "4.14.1",
"@polkadot/rpc-provider": "4.14.1",
"@polkadot/types": "4.14.1",
"@polkadot/util": "^6.8.1",
"@polkadot/x-rxjs": "^6.8.1"
"@babel/runtime": "^7.14.6",
"@polkadot/metadata": "4.16.2",
"@polkadot/rpc-provider": "4.16.2",
"@polkadot/types": "4.16.2",
"@polkadot/util": "^6.10.1",
"@polkadot/x-rxjs": "^6.10.1"
},
"devDependencies": {
"@polkadot/keyring": "^6.8.1"
"@polkadot/keyring": "^6.10.1"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/rpc-core', version: '4.14.1' };
export const packageInfo = { name: '@polkadot/rpc-core', version: '4.16.2' };
+2
View File
@@ -1,6 +1,8 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { jest } from '@jest/globals';
import { of, timer } from '@polkadot/x-rxjs';
import { drr } from '.';
+10 -10
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-provider",
"version": "4.14.1",
"version": "4.16.2",
"type": "module",
"description": "Transport providers for the API",
"main": "index.js",
@@ -19,18 +19,18 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.14.5",
"@polkadot/types": "4.14.1",
"@polkadot/util": "^6.8.1",
"@polkadot/util-crypto": "^6.8.1",
"@polkadot/x-fetch": "^6.8.1",
"@polkadot/x-global": "^6.8.1",
"@polkadot/x-ws": "^6.8.1",
"@babel/runtime": "^7.14.6",
"@polkadot/types": "4.16.2",
"@polkadot/util": "^6.10.1",
"@polkadot/util-crypto": "^6.10.1",
"@polkadot/x-fetch": "^6.10.1",
"@polkadot/x-global": "^6.10.1",
"@polkadot/x-ws": "^6.10.1",
"eventemitter3": "^4.0.7"
},
"devDependencies": {
"@polkadot/keyring": "^6.8.1",
"@polkadot/metadata": "4.14.1",
"@polkadot/keyring": "^6.10.1",
"@polkadot/metadata": "4.16.2",
"mock-socket": "^9.0.3",
"nock": "^13.1.0"
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/rpc-provider', version: '4.14.1' };
export const packageInfo = { name: '@polkadot/rpc-provider', version: '4.16.2' };
@@ -3,6 +3,8 @@
import type { Mock } from './../mock/types';
import { jest } from '@jest/globals';
import { mockWs } from '../../test/mockWs';
import { WsProvider } from './';
+8 -8
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/typegen",
"version": "4.14.1",
"version": "4.16.2",
"type": "module",
"description": "Type generation scripts",
"main": "index.js",
@@ -26,14 +26,14 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme",
"dependencies": {
"@babel/core": "^7.14.5",
"@babel/core": "^7.14.6",
"@babel/register": "^7.14.5",
"@babel/runtime": "^7.14.5",
"@polkadot/api": "4.14.1",
"@polkadot/metadata": "4.14.1",
"@polkadot/rpc-provider": "4.14.1",
"@polkadot/types": "4.14.1",
"@polkadot/util": "^6.8.1",
"@babel/runtime": "^7.14.6",
"@polkadot/api": "4.16.2",
"@polkadot/metadata": "4.16.2",
"@polkadot/rpc-provider": "4.16.2",
"@polkadot/types": "4.16.2",
"@polkadot/util": "^6.10.1",
"handlebars": "^4.7.7",
"websocket": "^1.0.34",
"yargs": "^17.0.1"
+1 -1
View File
@@ -54,7 +54,7 @@ function documentationVecToMarkdown (docLines: Vec<Text>, indent = 0): string {
? `${md}\n\n` // empty line
: /^[*-]/.test(docLine.trimStart()) && !md.endsWith('\n\n')
? `${md}\n\n${docLine}` // line calling for a preceding linebreak
: `${md}${docLine.replace(/^#{1,3} /, '#### ')} `
: `${md} ${docLine.replace(/^#{1,3} /, '#### ')} `
, '')
.replace(/#### <weight>/g, '<weight>')
.replace(/<weight>(.|\n)*?<\/weight>/g, '')
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/typegen', version: '4.14.1' };
export const packageInfo = { name: '@polkadot/typegen', version: '4.16.2' };
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types-known",
"version": "4.14.1",
"version": "4.16.2",
"type": "module",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
@@ -19,9 +19,9 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
"dependencies": {
"@babel/runtime": "^7.14.5",
"@polkadot/networks": "^6.8.1",
"@polkadot/types": "4.14.1",
"@polkadot/util": "^6.8.1"
"@babel/runtime": "^7.14.6",
"@polkadot/networks": "^6.10.1",
"@polkadot/types": "4.16.2",
"@polkadot/util": "^6.10.1"
}
}
+3
View File
@@ -17,6 +17,9 @@ const typesModules: Record<string, OverrideModuleType> = {
balances: {
Status: 'BalanceStatus'
},
beefy: {
AuthorityId: 'BeefyId'
},
contracts: {
StorageKey: 'ContractStorageKey'
},
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/types-known', version: '4.14.1' };
export const packageInfo = { name: '@polkadot/types-known', version: '4.16.2' };
+10 -2
View File
@@ -6,6 +6,8 @@
import type { OverrideVersionedType } from '@polkadot/types/types';
const sharedTypes = {
CompactAssignments: 'CompactAssignmentsWith24',
RawSolution: 'RawSolutionWith24',
Keys: 'SessionKeys6',
ProxyType: {
_enum: ['Any', 'NonTransfer', 'Governance', 'Staking', 'IdentityJudgement', 'CancelProxy']
@@ -16,9 +18,9 @@ const addrIndicesTypes = {
AccountInfo: 'AccountInfoWithRefCount',
Address: 'LookupSource',
CompactAssignments: 'CompactAssignmentsWith16',
RawSolution: 'RawSolutionWith16',
Keys: 'SessionKeys5',
LookupSource: 'IndicesLookupSource',
RawSolution: 'RawSolutionWith16',
ValidatorPrefs: 'ValidatorPrefsWithCommission'
};
@@ -26,9 +28,9 @@ const addrAccountIdTypes = {
AccountInfo: 'AccountInfoWithRefCount',
Address: 'AccountId',
CompactAssignments: 'CompactAssignmentsWith16',
RawSolution: 'RawSolutionWith16',
Keys: 'SessionKeys5',
LookupSource: 'AccountId',
RawSolution: 'RawSolutionWith16',
ValidatorPrefs: 'ValidatorPrefsWithCommission'
};
@@ -42,6 +44,7 @@ const versioned: OverrideVersionedType[] = [
CompactAssignments: 'CompactAssignmentsTo257',
DispatchError: 'DispatchErrorTo198',
DispatchInfo: 'DispatchInfoTo244',
Heartbeat: 'HeartbeatTo244',
Keys: 'SessionKeys5',
Multiplier: 'Fixed64',
OpenTip: 'OpenTipTo225',
@@ -60,6 +63,7 @@ const versioned: OverrideVersionedType[] = [
BalanceLock: 'BalanceLockTo212',
CompactAssignments: 'CompactAssignmentsTo257',
DispatchInfo: 'DispatchInfoTo244',
Heartbeat: 'HeartbeatTo244',
Keys: 'SessionKeys5',
Multiplier: 'Fixed64',
OpenTip: 'OpenTipTo225',
@@ -79,6 +83,7 @@ const versioned: OverrideVersionedType[] = [
BalanceLock: 'BalanceLockTo212',
CompactAssignments: 'CompactAssignmentsTo257',
DispatchInfo: 'DispatchInfoTo244',
Heartbeat: 'HeartbeatTo244',
Keys: 'SessionKeys5',
Multiplier: 'Fixed64',
OpenTip: 'OpenTipTo225',
@@ -97,6 +102,7 @@ const versioned: OverrideVersionedType[] = [
...addrAccountIdTypes,
CompactAssignments: 'CompactAssignmentsTo257',
DispatchInfo: 'DispatchInfoTo244',
Heartbeat: 'HeartbeatTo244',
Multiplier: 'Fixed64',
OpenTip: 'OpenTipTo225',
RefCount: 'RefCountTo259',
@@ -112,6 +118,7 @@ const versioned: OverrideVersionedType[] = [
...addrAccountIdTypes,
CompactAssignments: 'CompactAssignmentsTo257',
DispatchInfo: 'DispatchInfoTo244',
Heartbeat: 'HeartbeatTo244',
Multiplier: 'Fixed64',
OpenTip: 'OpenTipTo225',
RefCount: 'RefCountTo259',
@@ -126,6 +133,7 @@ const versioned: OverrideVersionedType[] = [
...addrAccountIdTypes,
CompactAssignments: 'CompactAssignmentsTo257',
DispatchInfo: 'DispatchInfoTo244',
Heartbeat: 'HeartbeatTo244',
OpenTip: 'OpenTipTo225',
RefCount: 'RefCountTo259'
}
+3 -13
View File
@@ -6,6 +6,8 @@
import type { OverrideVersionedType } from '@polkadot/types/types';
const sharedTypes = {
CompactAssignments: 'CompactAssignmentsWith16',
RawSolution: 'RawSolutionWith16',
Keys: 'SessionKeys6',
ProxyType: {
_enum: {
@@ -23,10 +25,8 @@ const sharedTypes = {
const addrAccountIdTypes = {
AccountInfo: 'AccountInfoWithRefCount',
Address: 'AccountId',
CompactAssignments: 'CompactAssignmentsWith16',
Keys: 'SessionKeys5',
LookupSource: 'AccountId',
RawSolution: 'RawSolutionWith16',
ValidatorPrefs: 'ValidatorPrefsWithCommission'
};
@@ -70,21 +70,11 @@ const versioned: OverrideVersionedType[] = [
minmax: [28, 29],
types: {
...sharedTypes,
CompactAssignments: 'CompactAssignmentsWith16',
RawSolution: 'RawSolutionWith16',
AccountInfo: 'AccountInfoWithDualRefCount'
}
},
{
minmax: [30, 9000],
types: {
...sharedTypes,
CompactAssignments: 'CompactAssignmentsWith16',
RawSolution: 'RawSolutionWith16'
}
},
{
minmax: [9010, undefined],
minmax: [30, undefined],
types: {
...sharedTypes
}
+1 -1
View File
@@ -13,7 +13,7 @@ const upgrades: ChainUpgradesRaw = [
[2962294, 2012], [3240000, 2013], [3274408, 2015], [3323565, 2019], [3534175, 2022],
[3860281, 2023], [4143129, 2024], [4401242, 2025], [4841367, 2026], [5961600, 2027],
[6137912, 2028], [6561855, 2029], [7100891, 2030], [7468792, 9010], [7668600, 9030],
[7812476, 9040]
[7812476, 9040], [8010981, 9050], [8073833, 9070]
];
export default upgrades;
@@ -8,7 +8,7 @@ const upgrades: ChainUpgradesRaw = [
[244358, 8], [303079, 9], [314201, 10], [342400, 11], [443963, 12],
[528470, 13], [687751, 14], [746085, 15], [787923, 16], [799302, 17],
[1205128, 18], [1603423, 23], [1733218, 24], [2005673, 25], [2436698, 26],
[3613564, 27], [3899547, 28], [4345767, 29], [4876134, 30]
[3613564, 27], [3899547, 28], [4345767, 29], [4876134, 30], [5661442, 9050]
];
export default upgrades;
+1 -1
View File
@@ -10,7 +10,7 @@ const upgrades: ChainUpgradesRaw = [
[1431703, 36], [1433369, 37], [1490972, 41], [2087397, 43], [2316688, 44],
[2549864, 45], [3925782, 46], [3925843, 47], [4207800, 48], [4627944, 49],
[5124076, 50], [5478664, 900], [5482450, 9000], [5584305, 9010], [5784566, 9030],
[5879822, 9031], [5896856, 9032], [5897316, 9033]
[5879822, 9031], [5896856, 9032], [5897316, 9033], [6117927, 9050], [6210274, 9070]
];
export default upgrades;
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types",
"version": "4.14.1",
"version": "4.16.2",
"type": "module",
"description": "Implementation of the Parity codec",
"main": "index.js",
@@ -19,14 +19,14 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
"dependencies": {
"@babel/runtime": "^7.14.5",
"@polkadot/metadata": "4.14.1",
"@polkadot/util": "^6.8.1",
"@polkadot/util-crypto": "^6.8.1",
"@polkadot/x-rxjs": "^6.8.1"
"@babel/runtime": "^7.14.6",
"@polkadot/metadata": "4.16.2",
"@polkadot/util": "^6.10.1",
"@polkadot/util-crypto": "^6.10.1",
"@polkadot/x-rxjs": "^6.10.1"
},
"devDependencies": {
"@polkadot/keyring": "^6.8.1",
"@polkadot/keyring": "^6.10.1",
"@types/bn.js": "^4.11.6",
"bn.js": "^4.11.9"
}
+8 -2
View File
@@ -9,7 +9,7 @@ import type { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interface
import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
import type { AllowedSlots, BabeAuthorityWeight, BabeBlockWeight, BabeEpochConfiguration, BabeEquivocationProof, BabeWeight, EpochAuthorship, MaybeRandomness, MaybeVrf, NextConfigDescriptor, NextConfigDescriptorV1, Randomness, RawBabePreDigest, RawBabePreDigestCompat, RawBabePreDigestPrimary, RawBabePreDigestPrimaryTo159, RawBabePreDigestSecondaryPlain, RawBabePreDigestSecondaryTo159, RawBabePreDigestSecondaryVRF, RawBabePreDigestTo159, SlotNumber, VrfData, VrfOutput, VrfProof } from '@polkadot/types/interfaces/babe';
import type { AccountData, BalanceLock, BalanceLockTo212, BalanceStatus, Reasons, ReserveData, ReserveIdentifier, VestingSchedule, WithdrawReasons } from '@polkadot/types/interfaces/balances';
import type { BeefyCommitment, BeefyNextAuthoritySet, BeefyPayload, BeefySignedCommitment, MmrRootHash, ValidatorSetId } from '@polkadot/types/interfaces/beefy';
import type { BeefyCommitment, BeefyId, BeefyNextAuthoritySet, BeefyPayload, BeefySignedCommitment, MmrRootHash, ValidatorSetId } from '@polkadot/types/interfaces/beefy';
import type { BridgedBlockHash, BridgedBlockNumber, BridgedHeader, InitializationData } from '@polkadot/types/interfaces/bridges';
import type { BlockHash } from '@polkadot/types/interfaces/chain';
import type { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
@@ -57,7 +57,7 @@ import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
import type { ClassDetails, ClassId, ClassMetadata, DepositBalance, DepositBalanceOf, DestroyWitness, InstanceDetails, InstanceId, InstanceMetadata } from '@polkadot/types/interfaces/uniques';
import type { Multisig, Timepoint } from '@polkadot/types/interfaces/utility';
import type { VestingInfo } from '@polkadot/types/interfaces/vesting';
import type { AccountId32Junction, AccountIndex64Junction, AccountKey20Junction, AssetInstance, BodyId, BodyPart, BodyPartAtLeastProportion, BodyPartFraction, BodyPartMoreThanProportion, DoubleEncodedCall, InboundStatus, Junction, MultiAsset, MultiAssetAbstractFungible, MultiAssetAbstractNonFungible, MultiAssetConcreteFungible, MultiAssetConcreteNonFungible, MultiLocation, NetworkId, OutboundStatus, Outcome, PluralityJunction, QueueConfigData, VersionedMultiAsset, VersionedMultiLocation, VersionedXcm, Xcm, XcmAssetEffects, XcmError, XcmHrmpChannelAccepted, XcmHrmpChannelClosing, XcmHrmpNewChannelOpenRequest, XcmOrder, XcmOrderBuyExecution, XcmOrderDepositAsset, XcmOrderDepositReserveAsset, XcmOrderExchangeAsset, XcmOrderInitiateReserveWithdraw, XcmOrderInitiateTeleport, XcmOrderQueryHolding, XcmOriginKind, XcmQueryResponse, XcmRelayedFrom, XcmReserveAssetDeposit, XcmResponse, XcmTeleportAsset, XcmTransact, XcmTransferAsset, XcmTransferReserveAsset, XcmWithdrawAsset, XcmpMessageFormat } from '@polkadot/types/interfaces/xcm';
import type { AccountId32Junction, AccountIndex64Junction, AccountKey20Junction, AssetInstance, BodyId, BodyPart, BodyPartAtLeastProportion, BodyPartFraction, BodyPartMoreThanProportion, DoubleEncodedCall, InboundStatus, Junction, MultiAsset, MultiAssetAbstractFungible, MultiAssetAbstractNonFungible, MultiAssetConcreteFungible, MultiAssetConcreteNonFungible, MultiLocation, NetworkId, OutboundStatus, Outcome, PluralityJunction, QueueConfigData, VersionedMultiAsset, VersionedMultiLocation, VersionedXcm, Xcm, XcmAssetEffects, XcmError, XcmHrmpChannelAccepted, XcmHrmpChannelClosing, XcmHrmpNewChannelOpenRequest, XcmOrder, XcmOrderBuyExecution, XcmOrderDepositAsset, XcmOrderDepositReserveAsset, XcmOrderExchangeAsset, XcmOrderInitiateReserveWithdraw, XcmOrderInitiateTeleport, XcmOrderQueryHolding, XcmOrigin, XcmOriginKind, XcmQueryResponse, XcmRelayedFrom, XcmReserveAssetDeposit, XcmResponse, XcmTeleportAsset, XcmTransact, XcmTransferAsset, XcmTransferReserveAsset, XcmWithdrawAsset, XcmpMessageFormat } from '@polkadot/types/interfaces/xcm';
declare module '@polkadot/types/types/registry' {
export interface InterfaceTypes {
@@ -226,6 +226,7 @@ declare module '@polkadot/types/types/registry' {
'Option<BalanceOf>': Option<BalanceOf>;
'Option<BalanceStatus>': Option<BalanceStatus>;
'Option<BeefyCommitment>': Option<BeefyCommitment>;
'Option<BeefyId>': Option<BeefyId>;
'Option<BeefyKey>': Option<BeefyKey>;
'Option<BeefyNextAuthoritySet>': Option<BeefyNextAuthoritySet>;
'Option<BeefyPayload>': Option<BeefyPayload>;
@@ -1018,6 +1019,7 @@ declare module '@polkadot/types/types/registry' {
'Option<XcmOrderInitiateReserveWithdraw>': Option<XcmOrderInitiateReserveWithdraw>;
'Option<XcmOrderInitiateTeleport>': Option<XcmOrderInitiateTeleport>;
'Option<XcmOrderQueryHolding>': Option<XcmOrderQueryHolding>;
'Option<XcmOrigin>': Option<XcmOrigin>;
'Option<XcmOriginKind>': Option<XcmOriginKind>;
'Option<XcmpMessageFormat>': Option<XcmpMessageFormat>;
'Option<XcmQueryResponse>': Option<XcmQueryResponse>;
@@ -1100,6 +1102,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<BalanceOf>': Vec<BalanceOf>;
'Vec<BalanceStatus>': Vec<BalanceStatus>;
'Vec<BeefyCommitment>': Vec<BeefyCommitment>;
'Vec<BeefyId>': Vec<BeefyId>;
'Vec<BeefyKey>': Vec<BeefyKey>;
'Vec<BeefyNextAuthoritySet>': Vec<BeefyNextAuthoritySet>;
'Vec<BeefyPayload>': Vec<BeefyPayload>;
@@ -1892,6 +1895,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<XcmOrderInitiateReserveWithdraw>': Vec<XcmOrderInitiateReserveWithdraw>;
'Vec<XcmOrderInitiateTeleport>': Vec<XcmOrderInitiateTeleport>;
'Vec<XcmOrderQueryHolding>': Vec<XcmOrderQueryHolding>;
'Vec<XcmOrigin>': Vec<XcmOrigin>;
'Vec<XcmOriginKind>': Vec<XcmOriginKind>;
'Vec<XcmpMessageFormat>': Vec<XcmpMessageFormat>;
'Vec<XcmQueryResponse>': Vec<XcmQueryResponse>;
@@ -1974,6 +1978,7 @@ declare module '@polkadot/types/types/registry' {
BalanceOf: BalanceOf;
BalanceStatus: BalanceStatus;
BeefyCommitment: BeefyCommitment;
BeefyId: BeefyId;
BeefyKey: BeefyKey;
BeefyNextAuthoritySet: BeefyNextAuthoritySet;
BeefyPayload: BeefyPayload;
@@ -2766,6 +2771,7 @@ declare module '@polkadot/types/types/registry' {
XcmOrderInitiateReserveWithdraw: XcmOrderInitiateReserveWithdraw;
XcmOrderInitiateTeleport: XcmOrderInitiateTeleport;
XcmOrderQueryHolding: XcmOrderQueryHolding;
XcmOrigin: XcmOrigin;
XcmOriginKind: XcmOriginKind;
XcmpMessageFormat: XcmpMessageFormat;
XcmQueryResponse: XcmQueryResponse;
+7 -7
View File
@@ -50,7 +50,7 @@ export abstract class AbstractArray<T extends Codec> extends Array<T> implements
/**
* @description The length of the value
*/
public get length (): number {
public override get length (): number {
// only included here since we ignore inherited docs
return super.length;
}
@@ -102,7 +102,7 @@ export abstract class AbstractArray<T extends Codec> extends Array<T> implements
/**
* @description Returns the string representation of the value
*/
public toString (): string {
public override toString (): string {
// Overwrite the default toString representation of Array.
const data = this.map((entry): string =>
entry.toString()
@@ -135,35 +135,35 @@ export abstract class AbstractArray<T extends Codec> extends Array<T> implements
/**
* @description Concatenates two arrays
*/
public concat (other: T[]): T[] {
public override concat (other: T[]): T[] {
return this.toArray().concat(other instanceof AbstractArray ? other.toArray() : other);
}
/**
* @description Filters the array with the callback
*/
public filter (callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: unknown): T[] {
public override filter (callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: unknown): T[] {
return this.toArray().filter(callbackfn, thisArg);
}
/**
* @description Maps the array with the callback
*/
public map<U> (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: unknown): U[] {
public override map<U> (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: unknown): U[] {
return this.toArray().map(callbackfn, thisArg);
}
/**
* @description Checks if the array includes a specific value
*/
public includes (check: unknown): boolean {
public override includes (check: unknown): boolean {
return this.some((value: T) => value.eq(check));
}
/**
* @description Returns a slice of an array
*/
public slice (start?: number, end?: number): T[] {
public override slice (start?: number, end?: number): T[] {
return this.toArray().slice(start, end);
}
}
+4 -4
View File
@@ -114,7 +114,7 @@ export abstract class AbstractInt extends BN implements Codec {
/**
* @description Returns the number of bits in the value
*/
public bitLength (): number {
public override bitLength (): number {
return this.#bitLength;
}
@@ -122,7 +122,7 @@ export abstract class AbstractInt extends BN implements Codec {
* @description Compares the value of the input to see if there is a match
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public eq (other?: unknown): boolean {
public override eq (other?: unknown): boolean {
// Here we are actually overriding the built-in .eq to take care of both
// number and BN inputs (no `.eqn` needed) - numbers will be converted
return super.eq(
@@ -192,7 +192,7 @@ export abstract class AbstractInt extends BN implements Codec {
/**
* @description Converts the Object to JSON, typically used for RPC transfers
*/
public toJSON (onlyHex = false): any {
public override toJSON (onlyHex = false): any {
// FIXME this return type should by string | number, however BN returns string
// Options here are
// - super.bitLength() - the actual used bits
@@ -218,7 +218,7 @@ export abstract class AbstractInt extends BN implements Codec {
* @description Returns the string representation of the value
* @param base The base to use for the conversion
*/
public toString (base?: number): string {
public override toString (base?: number): string {
// only included here since we do not inherit docs
return super.toString(base);
}
+1 -1
View File
@@ -175,7 +175,7 @@ export class BTreeSet<V extends Codec = Codec> extends Set<V> implements Codec {
/**
* @description Returns the string representation of the value
*/
public toString (): string {
public override toString (): string {
return stringify(this.toJSON());
}
+2 -2
View File
@@ -114,7 +114,7 @@ export class CodecDate extends Date implements Codec {
/**
* @description Converts the Object to JSON, typically used for RPC transfers
*/
public toJSON (): any {
public override toJSON (): any {
// FIXME Return type should be number, but conflicts with Date.toJSON()
// which returns string
return this.toNumber();
@@ -137,7 +137,7 @@ export class CodecDate extends Date implements Codec {
/**
* @description Returns the string representation of the value
*/
public toString (): string {
public override toString (): string {
// only included here since we do not inherit docs
return super.toString();
}
+1 -1
View File
@@ -27,7 +27,7 @@ export class Int extends AbstractInt {
super(registry, value, bitLength);
}
public toRawType (): string {
public override toRawType (): string {
return typeName || super.toRawType();
}
};
+1 -1
View File
@@ -111,7 +111,7 @@ export class Json extends Map<string, any> implements Codec {
/**
* @description Returns the string representation of the value
*/
public toString (): string {
public override toString (): string {
return stringify(this.toJSON());
}
+2 -2
View File
@@ -44,14 +44,14 @@ export class Linkage<T extends Codec> extends Struct {
/**
* @description Returns the base runtime type name for this instance
*/
public toRawType (): string {
public override toRawType (): string {
return `Linkage<${this.next.toRawType(true)}>`;
}
/**
* @description Custom toU8a which with bare mode does not return the linkage if empty
*/
public toU8a (): Uint8Array {
public override toU8a (): Uint8Array {
// As part of a storage query (where these appear), in the case of empty, the values
// are NOT populated by the node - follow the same logic, leaving it empty
return this.isEmpty
+1 -1
View File
@@ -182,7 +182,7 @@ export class CodecMap<K extends Codec = Codec, V extends Codec = Codec> extends
/**
* @description Returns the string representation of the value
*/
public toString (): string {
public override toString (): string {
return stringify(this.toJSON());
}
+4 -4
View File
@@ -64,7 +64,7 @@ export class Raw extends Uint8Array implements IU8a {
/**
* @description The length of the value
*/
public get length (): number {
public override get length (): number {
// only included here since we ignore inherited docs
return super.length;
}
@@ -93,7 +93,7 @@ export class Raw extends Uint8Array implements IU8a {
* @param start The position to start at
* @param end The position to end at
*/
public slice (start?: number, end?: number): Uint8Array {
public override slice (start?: number, end?: number): Uint8Array {
// Like subarray below, we have to follow this approach since we are extending the TypeArray.
// This happens especially when it comes to further extensions, the length may be an override
return Uint8Array.from(this).slice(start, end);
@@ -104,7 +104,7 @@ export class Raw extends Uint8Array implements IU8a {
* @param begin The position to start at
* @param end The position to end at
*/
public subarray (begin?: number, end?: number): Uint8Array {
public override subarray (begin?: number, end?: number): Uint8Array {
return Uint8Array.from(this).subarray(begin, end);
}
@@ -141,7 +141,7 @@ export class Raw extends Uint8Array implements IU8a {
/**
* @description Returns the string representation of the value
*/
public toString (): string {
public override toString (): string {
return this.toHex();
}
+3 -3
View File
@@ -19,7 +19,7 @@ export class Result<O extends Codec, E extends Codec> extends Enum {
super(registry, { Ok, Err }, value);
}
public static with<O extends Codec, E extends Codec> (Types: { Ok: Constructor<O> | keyof InterfaceTypes; Err: Constructor<E> | keyof InterfaceTypes }): Constructor<Result<O, E>> {
public static override with<O extends Codec, E extends Codec> (Types: { Ok: Constructor<O> | keyof InterfaceTypes; Err: Constructor<E> | keyof InterfaceTypes }): Constructor<Result<O, E>> {
return class extends Result<O, E> {
constructor (registry: Registry, value?: unknown) {
super(registry, Types.Ok, Types.Err, value);
@@ -55,7 +55,7 @@ export class Result<O extends Codec, E extends Codec> extends Enum {
/**
* @description Checks if the Result has no value
*/
public get isEmpty (): boolean {
public override get isEmpty (): boolean {
return this.isOk && this.value.isEmpty;
}
@@ -83,7 +83,7 @@ export class Result<O extends Codec, E extends Codec> extends Enum {
/**
* @description Returns the base runtime type name for this instance
*/
public toRawType (): string {
public override toRawType (): string {
const Types = this._toRawStruct() as { Ok: unknown; Err: unknown };
return `Result<${Types.Ok as string},${Types.Err as string}>`;
+2 -2
View File
@@ -149,7 +149,7 @@ export class CodecSet extends Set<string> implements Codec {
/**
* @description adds a value to the Set (extended to allow for validity checking)
*/
public add = (key: string): this => {
public override add = (key: string): this => {
// ^^^ add = () property done to assign this instance's this, otherwise Set.add creates "some" chaos
// we have the isUndefined(this._setValues) in here as well, add is used internally
// in the Set constructor (so it is undefined at this point, and should allow)
@@ -214,7 +214,7 @@ export class CodecSet extends Set<string> implements Codec {
/**
* @description Returns the string representation of the value
*/
public toString (): string {
public override toString (): string {
return `[${this.strings.join(', ')}]`;
}
+3 -3
View File
@@ -99,7 +99,7 @@ function decodeStructFromObject <T> (registry: Registry, Types: ConstructorDef,
*/
function decodeStruct <T> (registry: Registry, Types: ConstructorDef, value: unknown, jsonMap: Map<any, string>): T {
if (isHex(value)) {
return decodeStruct(registry, Types, hexToU8a(value.toString()), jsonMap);
return decodeStruct(registry, Types, hexToU8a(value), jsonMap);
} else if (isU8a(value)) {
const keys = Object.keys(Types);
const values = decodeU8a(registry, value, Object.values(Types), keys);
@@ -245,7 +245,7 @@ export class Struct<
* @description Returns a specific names entry in the structure
* @param name The name of the entry to retrieve
*/
public get (name: keyof S): Codec | undefined {
public override get (name: keyof S): Codec | undefined {
return super.get(name);
}
@@ -309,7 +309,7 @@ export class Struct<
/**
* @description Returns the string representation of the value
*/
public toString (): string {
public override toString (): string {
return stringify(this.toJSON());
}
+3 -3
View File
@@ -73,7 +73,7 @@ export class Tuple extends AbstractArray<Codec> {
/**
* @description The length of the value when encoded as a Uint8Array
*/
public get encodedLength (): number {
public override get encodedLength (): number {
return this.reduce((total, entry) => total + entry.encodedLength, 0);
}
@@ -104,7 +104,7 @@ export class Tuple extends AbstractArray<Codec> {
/**
* @description Returns the string representation of the value
*/
public toString (): string {
public override toString (): string {
// Overwrite the default toString representation of Array.
return stringify(this.toJSON());
}
@@ -113,7 +113,7 @@ export class Tuple extends AbstractArray<Codec> {
* @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 {
public override toU8a (isBare?: boolean): Uint8Array {
return u8aConcat(
...this.map((entry): Uint8Array =>
entry.toU8a(isBare)
+2 -2
View File
@@ -43,7 +43,7 @@ export class U8aFixed extends Raw {
super(registry, value, bitLength);
}
public toRawType (): string {
public override toRawType (): string {
return typeName || super.toRawType();
}
};
@@ -52,7 +52,7 @@ export class U8aFixed extends Raw {
/**
* @description Returns the base runtime type name for this instance
*/
public toRawType (): string {
public override toRawType (): string {
return `[u8;${this.length}]`;
}
}
+1 -1
View File
@@ -23,7 +23,7 @@ export class UInt extends AbstractInt {
super(registry, value, bitLength);
}
public toRawType (): string {
public override toRawType (): string {
return typeName || super.toRawType();
}
};
+1 -1
View File
@@ -73,7 +73,7 @@ export class Vec<T extends Codec> extends AbstractArray<T> {
/**
* @description Finds the index of the value in the array
*/
public indexOf (_other?: unknown): number {
public override indexOf (_other?: unknown): number {
// convert type first, this removes overhead from the eq
const other = _other instanceof this._Type
? _other
+2 -2
View File
@@ -62,11 +62,11 @@ export class VecFixed<T extends Codec> extends AbstractArray<T> {
/**
* @description The length of the value when encoded as a Uint8Array
*/
public get encodedLength (): number {
public override get encodedLength (): number {
return this.reduce((total, entry) => total + entry.encodedLength, 0);
}
public toU8a (): Uint8Array {
public override toU8a (): Uint8Array {
// we override, we don't add the length prefix for ourselves, and at the same time we
// ignore isBare on entries, since they should be properly encoded at all times
const encoded = this.map((entry) => entry.toU8a());
+1 -1
View File
@@ -40,7 +40,7 @@ function initType<T extends Codec = Codec, K extends string = string> (registry:
if (isU8a(value)) {
checkInstance(value, created);
} else if (isHex(value)) {
checkInstance(u8aToU8a(value.toString()), created);
checkInstance(u8aToU8a(value), created);
}
}
+239 -13
View File
@@ -252,28 +252,254 @@ describe('getTypeDef', (): void => {
});
});
// FIXME - not handled atm
it.skip('creates a nested fixed vec', (): void => {
it('creates a nested fixed vec', (): void => {
expect(
getTypeDef('[[u8;32];3]')
getTypeDef('[[[bool; 3]; 6]; 9]')
).toEqual({
ext: {
length: 3,
type: '[u8;32]'
},
info: TypeDefInfo.VecFixed,
length: 9,
sub: {
ext: {
length: 32
},
info: TypeDefInfo.VecFixed,
length: 6,
sub: {
info: TypeDefInfo.VecFixed,
length: 3,
sub: {
info: TypeDefInfo.Plain,
type: 'bool'
},
type: '[bool;3]'
},
type: '[[bool;3];6]'
},
type: '[[[bool;3];6];9]'
});
});
it('creates a nested fixed vec (named)', (): void => {
expect(
getTypeDef('[[bool; 6]; 3; MyType]')
).toEqual({
displayName: 'MyType',
info: TypeDefInfo.VecFixed,
length: 3,
sub: {
info: TypeDefInfo.VecFixed,
length: 6,
sub: {
info: TypeDefInfo.Plain,
type: 'u8'
type: 'bool'
},
type: '[u8;32]'
type: '[bool;6]'
},
type: '[[u8;32];3]'
type: '[[bool;6];3;MyType]'
});
});
it('creates a nested tuple', (): void => {
expect(
getTypeDef('((u32, u64), u128)')
).toEqual({
info: TypeDefInfo.Tuple,
sub: [
{
info: TypeDefInfo.Tuple,
sub: [
{
info: TypeDefInfo.Plain,
type: 'u32'
},
{
info: TypeDefInfo.Plain,
type: 'u64'
}
],
type: '(u32,u64)'
},
{
info: TypeDefInfo.Plain,
type: 'u128'
}
],
type: '((u32,u64),u128)'
});
});
it('creates a nested enum with tuple/struct', (): void => {
expect(
getTypeDef(JSON.stringify({
_enum: {
A: 'u32',
B: '(u32, bool)',
C: {
d: 'AccountId',
e: 'Balance'
}
}
}))
).toEqual({
info: TypeDefInfo.Enum,
sub: [
{
index: 0,
info: TypeDefInfo.Plain,
name: 'A',
type: 'u32'
},
{
index: 1,
info: TypeDefInfo.Tuple,
name: 'B',
sub: [
{
info: TypeDefInfo.Plain,
type: 'u32'
},
{
info: TypeDefInfo.Plain,
type: 'bool'
}
],
type: '(u32,bool)'
},
{
index: 2,
info: TypeDefInfo.Struct,
name: 'C',
sub: [
{
info: TypeDefInfo.Plain,
name: 'd',
type: 'AccountId'
},
{
info: TypeDefInfo.Plain,
name: 'e',
type: 'Balance'
}
],
type: '{"d":"AccountId","e":"Balance"}'
}
],
type: '{"_enum":{"A":"u32","B":"(u32,bool)","C":{"d":"AccountId","e":"Balance"}}}'
});
});
it('creates a nested struct with struct/tuple', (): void => {
expect(
getTypeDef(JSON.stringify({
a: 'u32',
b: '(u32, bool)',
c: {
d: 'AccountId',
e: 'Balance'
}
}))
).toEqual({
info: TypeDefInfo.Struct,
sub: [
{
info: TypeDefInfo.Plain,
name: 'a',
type: 'u32'
},
{
info: TypeDefInfo.Tuple,
name: 'b',
sub: [
{
info: TypeDefInfo.Plain,
type: 'u32'
},
{
info: TypeDefInfo.Plain,
type: 'bool'
}
],
type: '(u32,bool)'
},
{
info: TypeDefInfo.Struct,
name: 'c',
sub: [
{
info: TypeDefInfo.Plain,
name: 'd',
type: 'AccountId'
},
{
info: TypeDefInfo.Plain,
name: 'e',
type: 'Balance'
}
],
type: '{"d":"AccountId","e":"Balance"}'
}
],
type: '{"a":"u32","b":"(u32,bool)","c":{"d":"AccountId","e":"Balance"}}'
});
});
it('creates a Vec with nested fixed', (): void => {
expect(
getTypeDef('Vec<[[[bool; 3]; 6]; 9]>')
).toEqual({
info: TypeDefInfo.Vec,
sub: {
info: TypeDefInfo.VecFixed,
length: 9,
sub: {
info: TypeDefInfo.VecFixed,
length: 6,
sub: {
info: TypeDefInfo.VecFixed,
length: 3,
sub: {
info: TypeDefInfo.Plain,
type: 'bool'
},
type: '[bool;3]'
},
type: '[[bool;3];6]'
},
type: '[[[bool;3];6];9]'
},
type: 'Vec<[[[bool;3];6];9]>'
});
});
it('creates a Vec with nested struct', (): void => {
expect(
getTypeDef('Vec<{ "a": "u32", "b": "(u32, bool)" }>')
).toEqual({
info: TypeDefInfo.Vec,
sub: {
info: TypeDefInfo.Struct,
sub: [
{
info: TypeDefInfo.Plain,
name: 'a',
type: 'u32'
},
{
info: TypeDefInfo.Tuple,
name: 'b',
sub: [
{
info: TypeDefInfo.Plain,
type: 'u32'
},
{
info: TypeDefInfo.Plain,
type: 'bool'
}
],
type: '(u32,bool)'
}
],
type: '{"a":"u32","b":"(u32,bool)"}'
},
type: 'Vec<{"a":"u32","b":"(u32,bool)"}>'
});
});
+28 -9
View File
@@ -3,7 +3,7 @@
import type { TypeDef } from './types';
import { assert, isNumber } from '@polkadot/util';
import { assert, isNumber, isString } from '@polkadot/util';
import { sanitize } from './sanitize';
import { TypeDefInfo } from './types';
@@ -16,6 +16,12 @@ interface TypeDefOptions {
const MAX_NESTED = 64;
function getTypeString (typeOrObj: any): string {
return isString(typeOrObj)
? typeOrObj.toString()
: JSON.stringify(typeOrObj);
}
function isRustEnum (details: Record<string, string> | Record<string, number>): details is Record<string, string> {
const values = Object.values(details);
@@ -44,9 +50,8 @@ function _decodeEnum (value: TypeDef, details: string[] | Record<string, string>
type: 'Null'
}));
} else if (isRustEnum(details)) {
value.sub = Object.entries(details).map(([name, type], index): TypeDef => ({
// eslint-disable-next-line @typescript-eslint/no-use-before-define
...getTypeDef(type || 'Null', { name }, count),
value.sub = Object.entries(details).map(([name, typeOrObj], index): TypeDef => ({
...getTypeDef(getTypeString(typeOrObj || 'Null'), { name }, count),
index
}));
} else {
@@ -96,8 +101,7 @@ function _decodeStruct (value: TypeDef, type: string, _: string, count: number):
? new Map(Object.entries(parsed._alias))
: undefined;
value.sub = keys.filter((name) => !['_alias'].includes(name)).map((name): TypeDef =>
// eslint-disable-next-line @typescript-eslint/no-use-before-define
getTypeDef(parsed[name], { name }, count)
getTypeDef(getTypeString(parsed[name]), { name }, count)
);
return value;
@@ -106,7 +110,24 @@ function _decodeStruct (value: TypeDef, type: string, _: string, count: number):
// decode a fixed vector, e.g. [u8;32]
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function _decodeFixedVec (value: TypeDef, type: string, _: string, count: number): TypeDef {
const [vecType, strLength, displayName] = type.substr(1, type.length - 2).split(';');
const max = type.length - 1;
let index = -1;
let inner = 0;
for (let i = 1; (i < max) && (index === -1); i++) {
if (type[i] === ';' && inner === 0) {
index = i;
} else if (['[', '(', '<'].includes(type[i])) {
inner++;
} else if ([']', ')', '>'].includes(type[i])) {
inner--;
}
}
assert(index !== -1, () => `${type}: Unable to extract location of ';'`);
const vecType = type.substr(1, index - 1);
const [strLength, displayName] = type.substr(index + 1, max - index - 1).split(';');
const length = parseInt(strLength.trim(), 10);
// as a first round, only u8 via u8aFixed, we can add more support
@@ -114,7 +135,6 @@ function _decodeFixedVec (value: TypeDef, type: string, _: string, count: number
value.displayName = displayName;
value.length = length;
// eslint-disable-next-line @typescript-eslint/no-use-before-define
value.sub = getTypeDef(vecType, {}, count);
return value;
@@ -124,7 +144,6 @@ function _decodeFixedVec (value: TypeDef, type: string, _: string, count: number
function _decodeTuple (value: TypeDef, _: string, subType: string, count: number): TypeDef {
value.sub = subType.length === 0
? []
// eslint-disable-next-line @typescript-eslint/no-use-before-define
: typeSplit(subType).map((inner) => getTypeDef(inner, {}, count));
return value;
+19 -18
View File
@@ -15,7 +15,7 @@ import { blake2AsU8a } from '@polkadot/util-crypto';
import { Json } from '../codec/Json';
import { Raw } from '../codec/Raw';
import { defaultExtensions, expandExtensionTypes, findUnknownExtensions } from '../extrinsic/signedExtensions';
import { expandExtensionTypes, fallbackExtensions, findUnknownExtensions } from '../extrinsic/signedExtensions';
import { GenericEventData } from '../generic/Event';
import * as baseTypes from '../index.types';
import * as definitions from '../interfaces/definitions';
@@ -51,31 +51,32 @@ function injectErrors (_: Registry, metadata: Metadata, metadataErrors: Record<s
// create event classes from metadata
function injectEvents (registry: Registry, metadata: Metadata, metadataEvents: Record<string, Constructor<GenericEventData>>): void {
const modules = metadata.asLatest.modules;
// decorate the events
modules
metadata.asLatest.modules
.filter(({ events }) => events.isSome)
.forEach((section, _sectionIndex): void => {
const sectionIndex = metadata.version >= 12 ? section.index.toNumber() : _sectionIndex;
const sectionIndex = metadata.version >= 12
? section.index.toNumber()
: _sectionIndex;
const sectionName = stringCamelCase(section.name);
section.events.unwrap().forEach((meta, methodIndex): void => {
const methodName = meta.name.toString();
const eventIndex = new Uint8Array([sectionIndex, methodIndex]);
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
const typeDef = meta.args.map((arg) => getTypeDef(arg));
let Types: Constructor<Codec>[] = [];
let Types: Constructor<Codec>[] | null = null;
try {
Types = typeDef.map((typeDef) => getTypeClass(registry, typeDef));
} catch (error) {
l.error(error);
}
// Lazy create the actual type classes right at the point of use
const getTypes = (): Constructor<Codec>[] => {
if (!Types) {
Types = typeDef.map((typeDef) => getTypeClass(registry, typeDef));
}
metadataEvents[u8aToHex(eventIndex)] = class extends GenericEventData {
return Types;
};
metadataEvents[u8aToHex(new Uint8Array([sectionIndex, methodIndex]))] = class extends GenericEventData {
constructor (registry: Registry, value: Uint8Array) {
super(registry, value, Types, typeDef, meta, sectionName, methodName);
super(registry, value, getTypes(), typeDef, meta, sectionName, methodName);
}
};
});
@@ -132,7 +133,7 @@ export class TypeRegistry implements Registry {
#knownTypes: RegisteredTypes = {};
#signedExtensions: string[] = defaultExtensions;
#signedExtensions: string[] = fallbackExtensions;
#userExtensions?: ExtDef;
@@ -397,7 +398,7 @@ export class TypeRegistry implements Registry {
signedExtensions || (
metadata.asLatest.extrinsic.version.gt(BN_ZERO)
? metadata.asLatest.extrinsic.signedExtensions.map((key) => key.toString())
: defaultExtensions
: fallbackExtensions
),
userExtensions
);
@@ -409,7 +410,7 @@ export class TypeRegistry implements Registry {
}
// sets the available signed extensions
setSignedExtensions (signedExtensions: string[] = defaultExtensions, userExtensions?: ExtDef): void {
setSignedExtensions (signedExtensions: string[] = fallbackExtensions, userExtensions?: ExtDef): void {
this.#signedExtensions = signedExtensions;
this.#userExtensions = userExtensions;
+7 -7
View File
@@ -13,9 +13,9 @@ 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());
return hexToU8a(value);
} else if (isString(value)) {
return u8aToU8a((value as string).toString());
return u8aToU8a(value);
}
return value;
@@ -40,35 +40,35 @@ export class GenericEthereumAccountId extends U8aFixed {
/**
* @description Compares the value of the input to see if there is a match
*/
public eq (other?: unknown): boolean {
public override 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 {
public override toHuman (): string {
return this.toJSON();
}
/**
* @description Converts the Object to JSON, typically used for RPC transfers
*/
public toJSON (): string {
public override toJSON (): string {
return this.toString();
}
/**
* @description Returns the string representation of the value
*/
public toString (): string {
public override toString (): string {
return GenericEthereumAccountId.encode(this);
}
/**
* @description Returns the base runtime type name for this instance
*/
public toRawType (): string {
public override toRawType (): string {
return 'AccountId';
}
}
+4 -4
View File
@@ -69,7 +69,7 @@ export class GenericEthereumLookupSource extends Base<GenericEthereumAccountId |
/**
* @description The length of the value when encoded as a Uint8Array
*/
public get encodedLength (): number {
public override get encodedLength (): number {
const rawLength = this._rawLength;
return rawLength + (
@@ -92,14 +92,14 @@ export class GenericEthereumLookupSource extends Base<GenericEthereumAccountId |
/**
* @description Returns a hex string representation of the value
*/
public toHex (): string {
public override toHex (): string {
return u8aToHex(this.toU8a());
}
/**
* @description Returns the base runtime type name for this instance
*/
public toRawType (): string {
public override toRawType (): string {
return 'Address';
}
@@ -107,7 +107,7 @@ export class GenericEthereumLookupSource extends Base<GenericEthereumAccountId |
* @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 {
public override toU8a (isBare?: boolean): Uint8Array {
const encoded = this._raw.toU8a().subarray(0, this._rawLength);
return isBare
+6 -6
View File
@@ -73,7 +73,7 @@ abstract class ExtrinsicBase<A extends AnyTuple> extends Base<ExtrinsicVx | Extr
/**
* @description The length of the value when encoded as a Uint8Array
*/
public get encodedLength (): number {
public override get encodedLength (): number {
return this.toU8a().length;
}
@@ -243,14 +243,14 @@ export class GenericExtrinsic<A extends AnyTuple = AnyTuple> extends ExtrinsicBa
/**
* @description Returns a hex string representation of the value
*/
public toHex (isBare?: boolean): string {
public override toHex (isBare?: boolean): string {
return u8aToHex(this.toU8a(isBare));
}
/**
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
*/
public toHuman (isExpanded?: boolean): AnyJson {
public override toHuman (isExpanded?: boolean): AnyJson {
return {
isSigned: this.isSigned,
method: this.method.toHuman(isExpanded),
@@ -270,14 +270,14 @@ export class GenericExtrinsic<A extends AnyTuple = AnyTuple> extends ExtrinsicBa
/**
* @description Converts the Object to JSON, typically used for RPC transfers
*/
public toJSON (): string {
public override toJSON (): string {
return this.toHex();
}
/**
* @description Returns the base runtime type name for this instance
*/
public toRawType (): string {
public override toRawType (): string {
return 'Extrinsic';
}
@@ -285,7 +285,7 @@ export class GenericExtrinsic<A extends AnyTuple = AnyTuple> extends ExtrinsicBa
* @description Encodes the value as a Uint8Array as per the SCALE specifications
* @param isBare true when the value is not length-prefixed
*/
public toU8a (isBare?: boolean): Uint8Array {
public override toU8a (isBare?: boolean): Uint8Array {
// we do not apply bare to the internal values, rather this only determines out length addition,
// where we strip all lengths this creates an extrinsic that cannot be decoded
const encoded = u8aConcat(new Uint8Array([this.version]), this._raw.toU8a());
+6 -6
View File
@@ -113,7 +113,7 @@ export class MortalEra extends Tuple {
/**
* @description Encoded length for mortals occupy 2 bytes, different from the actual Tuple since it is encoded. This is a shortcut fro `toU8a().length`
*/
public get encodedLength (): number {
public override get encodedLength (): number {
return 2;
}
@@ -134,7 +134,7 @@ export class MortalEra extends Tuple {
/**
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
*/
public toHuman (): any {
public override toHuman (): any {
return {
period: formatNumber(this.period),
phase: formatNumber(this.phase)
@@ -144,7 +144,7 @@ export class MortalEra extends Tuple {
/**
* @description Returns a JSON representation of the actual value
*/
public toJSON (): any {
public override toJSON (): any {
return this.toHex();
}
@@ -159,7 +159,7 @@ export class MortalEra extends Tuple {
* `period` is.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public toU8a (isBare?: boolean): Uint8Array {
public override toU8a (isBare?: boolean): Uint8Array {
const period = this.period.toNumber();
const phase = this.phase.toNumber();
const quantizeFactor = Math.max(period >> 12, 1);
@@ -235,7 +235,7 @@ export class GenericExtrinsicEra extends Enum implements IExtrinsicEra {
/**
* @description Override the encoded length method
*/
public get encodedLength (): number {
public override get encodedLength (): number {
return this.isImmortalEra
? this.asImmortalEra.encodedLength
: this.asMortalEra.encodedLength;
@@ -277,7 +277,7 @@ export class GenericExtrinsicEra extends Enum implements IExtrinsicEra {
* @description Encodes the value as a Uint8Array as per the parity-codec specifications
* @param isBare true when the value has none of the type-specific prefixes (internal)
*/
public toU8a (isBare?: boolean): Uint8Array {
public override toU8a (isBare?: boolean): Uint8Array {
return this.isMortalEra
? this.asMortalEra.toU8a(isBare)
: this.asImmortalEra.toU8a(isBare);
@@ -112,7 +112,7 @@ export class GenericExtrinsicPayload extends Base<ExtrinsicPayloadVx> {
/**
* @description Compares the value of the input to see if there is a match
*/
public eq (other?: unknown): boolean {
public override eq (other?: unknown): boolean {
return this._raw.eq(other);
}
@@ -134,28 +134,28 @@ export class GenericExtrinsicPayload extends Base<ExtrinsicPayloadVx> {
/**
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
*/
public toHuman (isExtended?: boolean): AnyJson {
public override toHuman (isExtended?: boolean): AnyJson {
return this._raw.toHuman(isExtended);
}
/**
* @description Converts the Object to JSON, typically used for RPC transfers
*/
public toJSON (): any {
public override toJSON (): any {
return this.toHex();
}
/**
* @description Returns the string representation of the value
*/
public toString (): string {
public override toString (): string {
return this.toHex();
}
/**
* @description Returns a serialized u8a form
*/
public toU8a (isBare?: BareOpts): Uint8Array {
public override toU8a (isBare?: BareOpts): Uint8Array {
// call our parent, with only the method stripped
return super.toU8a(isBare ? { method: true } : false);
}
@@ -5,20 +5,25 @@ import type { ExtDef, ExtInfo, ExtTypes } from './types';
import { polkadot } from './polkadot';
import { shell } from './shell';
import { statemint } from './statemint';
import { substrate } from './substrate';
// A mapping of the known signed extensions to the extra fields that they contain. Unlike in the actual extensions,
// we define the extra fields not as a Tuple, but rather as a struct so they can be named. These will be expanded
// into the various fields when added to the payload (we only support V4 onwards with these, V3 and earlier are
// deemed fixed and non-changeable)
const allExtensions: ExtDef = {
export const allExtensions: ExtDef = {
...substrate,
...polkadot,
...shell,
...polkadot
...statemint
};
// the v4 signed extensions (the order is important here, as applied by default)
const defaultExtensions: Array<keyof typeof allExtensions> = [
// the v4 signed extensions prior to the point of exposing these to the metadata.
// This may not match 100% with the current defaults and are used when not specified
// in the metadata (which is for very old chains). The order is important here, as
// applied by default
export const fallbackExtensions: Array<keyof typeof allExtensions> = [
'CheckVersion',
'CheckGenesis',
'CheckEra',
@@ -28,18 +33,16 @@ const defaultExtensions: Array<keyof typeof allExtensions> = [
'CheckBlockGasLimit'
];
function findUnknownExtensions (extensions: string[], userExtensions: ExtDef = {}): string[] {
export function findUnknownExtensions (extensions: string[], userExtensions: ExtDef = {}): string[] {
const names = [...Object.keys(allExtensions), ...Object.keys(userExtensions)];
return extensions.filter((key) => !names.includes(key));
}
function expandExtensionTypes (extensions: string[], type: keyof ExtInfo, userExtensions: ExtDef = {}): ExtTypes {
export function expandExtensionTypes (extensions: string[], type: keyof ExtInfo, userExtensions: ExtDef = {}): ExtTypes {
return extensions
// Always allow user extensions first - these should provide overrides
.map((key) => userExtensions[key] || allExtensions[key])
.filter((info): info is ExtInfo => !!info)
.reduce((result, info): ExtTypes => ({ ...result, ...info[type] }), {});
}
export { allExtensions, defaultExtensions, expandExtensionTypes, findUnknownExtensions };
@@ -0,0 +1,15 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ExtDef } from './types';
export const statemint: ExtDef = {
ChargeAssetTxPayment: {
extrinsic: {
tip: 'Compact<Balance>',
// eslint-disable-next-line sort-keys
assetId: 'Option<AssetId>'
},
payload: {}
}
};
+1 -1
View File
@@ -54,7 +54,7 @@ export class GenericExtrinsicV4 extends Struct implements IExtrinsicImpl {
/**
* @description The length of the value when encoded as a Uint8Array
*/
public get encodedLength (): number {
public override get encodedLength (): number {
return this.toU8a().length;
}
@@ -58,7 +58,7 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig
/**
* @description The length of the value when encoded as a Uint8Array
*/
public get encodedLength (): number {
public override get encodedLength (): number {
return this.isSigned
? super.encodedLength
: 0;
@@ -181,7 +181,7 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig
* @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 {
public override toU8a (isBare?: boolean): Uint8Array {
return this.isSigned
? super.toU8a(isBare)
: EMPTY_U8A;
+8 -8
View File
@@ -14,10 +14,10 @@ function decodeAccountId (value?: AnyU8a | AnyString): Uint8Array {
return new Uint8Array();
} else if (isU8a(value) || Array.isArray(value)) {
return u8aToU8a(value);
} else if (isHex(value)) {
return hexToU8a(value);
} else if (isString(value)) {
return isHex(value)
? hexToU8a(value.toString())
: decodeAddress((value as string).toString());
return decodeAddress(value);
}
throw new Error(`Unknown type passed to AccountId constructor, found typeof ${typeof value}`);
@@ -43,35 +43,35 @@ export class GenericAccountId extends U8aFixed {
/**
* @description Compares the value of the input to see if there is a match
*/
public eq (other?: unknown): boolean {
public override 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 {
public override toHuman (): string {
return this.toJSON();
}
/**
* @description Converts the Object to JSON, typically used for RPC transfers
*/
public toJSON (): string {
public override toJSON (): string {
return this.toString();
}
/**
* @description Returns the string representation of the value
*/
public toString (): string {
public override toString (): string {
return encodeAddress(this, this.registry.chainSS58);
}
/**
* @description Returns the base runtime type name for this instance
*/
public toRawType (): string {
public override toRawType (): string {
return 'AccountId';
}
}
+5 -5
View File
@@ -81,7 +81,7 @@ export class GenericAccountIndex extends u32 {
/**
* @description Compares the value of the input to see if there is a match
*/
public eq (other?: unknown): boolean {
public override eq (other?: unknown): boolean {
// shortcut for BN or Number, don't create an object
if (isBn(other as string) || isNumber(other)) {
return super.eq(other);
@@ -94,21 +94,21 @@ export class GenericAccountIndex extends u32 {
/**
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
*/
public toHuman (): string {
public override toHuman (): string {
return this.toJSON();
}
/**
* @description Converts the Object to JSON, typically used for RPC transfers
*/
public toJSON (): string {
public override toJSON (): string {
return this.toString();
}
/**
* @description Returns the string representation of the value
*/
public toString (): string {
public override toString (): string {
const length = GenericAccountIndex.calcLength(this);
return encodeAddress(this.toU8a().subarray(0, length), this.registry.chainSS58);
@@ -117,7 +117,7 @@ export class GenericAccountIndex extends u32 {
/**
* @description Returns the base runtime type name for this instance
*/
public toRawType (): string {
public override toRawType (): string {
return 'AccountIndex';
}
}
+1 -1
View File
@@ -52,7 +52,7 @@ export class GenericBlock extends Struct {
/**
* @description Block/header [[Hash]]
*/
public get hash (): CodecHash {
public override get hash (): CodecHash {
return this.header.hash;
}
+3 -3
View File
@@ -93,7 +93,7 @@ function decodeCallViaU8a (registry: Registry, value: Uint8Array, _meta?: Functi
*/
function decodeCall (registry: Registry, value: unknown | DecodedMethod | Uint8Array | string = new Uint8Array(), _meta?: FunctionMetadataLatest): DecodedMethod {
if (isHex(value) || isU8a(value)) {
return decodeCallViaU8a(registry, u8aToU8a(value as string), _meta);
return decodeCallViaU8a(registry, u8aToU8a(value), _meta);
} else if (isObject(value) && value.callIndex && value.args) {
return decodeCallViaObject(registry, value as DecodedMethod, _meta);
}
@@ -216,7 +216,7 @@ export class GenericCall<A extends AnyTuple = AnyTuple> extends Struct implement
/**
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
*/
public toHuman (isExpanded?: boolean): Record<string, AnyJson> {
public override toHuman (isExpanded?: boolean): Record<string, AnyJson> {
let call: CallFunction | undefined;
try {
@@ -244,7 +244,7 @@ export class GenericCall<A extends AnyTuple = AnyTuple> extends Struct implement
/**
* @description Returns the base runtime type name for this instance
*/
public toRawType (): string {
public override toRawType (): string {
return 'Call';
}
}
@@ -103,21 +103,21 @@ export class GenericConsensusEngineId extends U8aFixed {
/**
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
*/
public toHuman (): string {
public override toHuman (): string {
return this.toString();
}
/**
* @description Returns the base runtime type name for this instance
*/
public toRawType (): string {
public override toRawType (): string {
return 'ConsensusEngineId';
}
/**
* @description Override the default toString to return a 4-byte string
*/
public toString (): string {
public override toString (): string {
return this.isAscii
? u8aToString(this)
: u8aToHex(this);
+27 -19
View File
@@ -10,6 +10,31 @@ import { Struct } from '../codec/Struct';
import { Tuple } from '../codec/Tuple';
import { Null } from '../primitive/Null';
interface Decoded {
DataType: Constructor<Null> | Constructor<GenericEventData>;
value?: {
index: Uint8Array;
data: Uint8Array;
}
}
/** @internal */
function decodeEvent (registry: Registry, value?: Uint8Array): Decoded {
if (!value || !value.length) {
return { DataType: Null };
}
const index = value.subarray(0, 2);
return {
DataType: registry.findMetaEvent(index),
value: {
data: value.subarray(2),
index
}
};
}
/**
* @name GenericEventData
* @description
@@ -72,7 +97,7 @@ export class GenericEvent extends Struct implements IEvent<Codec[]> {
// Currently we _only_ decode from Uint8Array, since we expect it to
// be used via EventRecord
constructor (registry: Registry, _value?: Uint8Array) {
const { DataType, value } = GenericEvent.decodeEvent(registry, _value);
const { DataType, value } = decodeEvent(registry, _value);
super(registry, {
index: 'EventId',
@@ -81,23 +106,6 @@ export class GenericEvent extends Struct implements IEvent<Codec[]> {
}, value);
}
/** @internal */
public static decodeEvent (registry: Registry, value: Uint8Array = new Uint8Array()): { DataType: Constructor<Null> | Constructor<GenericEventData>; value?: { index: Uint8Array; data: Uint8Array } } {
if (!value.length) {
return { DataType: Null };
}
const index = value.subarray(0, 2);
return {
DataType: registry.findMetaEvent(index),
value: {
data: value.subarray(2),
index
}
};
}
/**
* @description The wrapped [[EventData]]
*/
@@ -143,7 +151,7 @@ export class GenericEvent extends Struct implements IEvent<Codec[]> {
/**
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
*/
public toHuman (isExpanded?: boolean): Record<string, AnyJson> {
public override toHuman (isExpanded?: boolean): Record<string, AnyJson> {
return {
method: this.method,
section: this.section,
+4 -4
View File
@@ -69,7 +69,7 @@ export class GenericLookupSource extends Base<GenericAccountId | GenericAccountI
/**
* @description The length of the value when encoded as a Uint8Array
*/
public get encodedLength (): number {
public override get encodedLength (): number {
const rawLength = this._rawLength;
return rawLength + (
@@ -92,14 +92,14 @@ export class GenericLookupSource extends Base<GenericAccountId | GenericAccountI
/**
* @description Returns a hex string representation of the value
*/
public toHex (): string {
public override toHex (): string {
return u8aToHex(this.toU8a());
}
/**
* @description Returns the base runtime type name for this instance
*/
public toRawType (): string {
public override toRawType (): string {
return 'Address';
}
@@ -107,7 +107,7 @@ export class GenericLookupSource extends Base<GenericAccountId | GenericAccountI
* @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 {
public override toU8a (isBare?: boolean): Uint8Array {
const encoded = this._raw.toU8a().subarray(0, this._rawLength);
return isBare
+1 -1
View File
@@ -54,7 +54,7 @@ export class GenericMultiAddress extends Enum {
/**
* @description Returns the string representation of the value
*/
public toString (): string {
public override toString (): string {
return this.value.toString();
}
}
+2 -2
View File
@@ -105,7 +105,7 @@ export class GenericVote extends U8aFixed {
/**
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
*/
public toHuman (isExpanded?: boolean): AnyJson {
public override toHuman (isExpanded?: boolean): AnyJson {
return {
conviction: this.conviction.toHuman(isExpanded),
vote: this.isAye ? 'Aye' : 'Nay'
@@ -115,7 +115,7 @@ export class GenericVote extends U8aFixed {
/**
* @description Returns the base runtime type name for this instance
*/
public toRawType (): string {
public override toRawType (): string {
return 'Vote';
}
}
+1 -1
View File
@@ -11,5 +11,5 @@ export { GenericChainProperties } from './ChainProperties';
export { GenericConsensusEngineId } from './ConsensusEngineId';
export { GenericEvent, GenericEventData } from './Event';
export { GenericLookupSource } from './LookupSource';
export { GenericMultiAddress } from './MultiAddress';
export { GenericMultiAddress, GenericMultiAddress as GenericAddress } from './MultiAddress';
export { GenericVote } from './Vote';
@@ -25,6 +25,7 @@ export default {
blockNumber: 'BlockNumber',
validatorSetId: 'ValidatorSetId'
},
BeefyId: '[u8; 33]',
BeefySignedCommitment: {
commitment: 'BeefyCommitment',
signatures: 'Vec<Option<Signature>>'
+4 -1
View File
@@ -1,7 +1,7 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
import type { Option, Struct, Vec, u32, u64 } from '@polkadot/types';
import type { Option, Struct, U8aFixed, Vec, u32, u64 } from '@polkadot/types';
import type { Signature } from '@polkadot/types/interfaces/extrinsics';
import type { BlockNumber, H256 } from '@polkadot/types/interfaces/runtime';
@@ -12,6 +12,9 @@ export interface BeefyCommitment extends Struct {
readonly validatorSetId: ValidatorSetId;
}
/** @name BeefyId */
export interface BeefyId extends U8aFixed {}
/** @name BeefyNextAuthoritySet */
export interface BeefyNextAuthoritySet extends Struct {
readonly id: u64;
@@ -28,6 +28,36 @@ export default {
],
type: 'Vec<StorageKey>'
},
getKeysPaged: {
alias: ['childstate_getKeysPagedAt'],
description: 'Returns the keys with prefix from a child storage with pagination support',
params: [
{
name: 'childKey',
type: 'PrefixedStorageKey'
},
{
name: 'prefix',
type: 'StorageKey'
},
{
name: 'count',
type: 'u32'
},
{
name: 'startKey',
type: 'StorageKey',
isOptional: true
},
{
name: 'at',
type: 'Hash',
isHistoric: true,
isOptional: true
}
],
type: 'Vec<StorageKey>'
},
getStorage: {
description: 'Returns a child storage entry at a specific block state',
params: [
@@ -15,7 +15,7 @@ const deprecated = {
};
const phragmen = {
CompactAssignments: 'CompactAssignmentsWith24',
CompactAssignments: 'CompactAssignmentsWith16',
CompactAssignmentsWith16: {
votes1: 'Vec<(NominatorIndexCompact, ValidatorIndexCompact)>',
votes2: 'Vec<(NominatorIndexCompact, CompactScoreCompact, ValidatorIndexCompact)>',
@@ -111,7 +111,7 @@ const phragmen = {
}
},
ExtendedBalance: 'u128',
RawSolution: 'RawSolutionWith24',
RawSolution: 'RawSolutionWith16',
RawSolutionWith16: {
compact: 'CompactAssignmentsWith16',
score: 'ElectionScore',
@@ -12,7 +12,7 @@ export interface ActiveEraInfo extends Struct {
}
/** @name CompactAssignments */
export interface CompactAssignments extends CompactAssignmentsWith24 {}
export interface CompactAssignments extends CompactAssignmentsWith16 {}
/** @name CompactAssignmentsTo257 */
export interface CompactAssignmentsTo257 extends Struct {
@@ -207,7 +207,7 @@ export interface PhragmenScore extends Vec<u128> {}
export interface Points extends u32 {}
/** @name RawSolution */
export interface RawSolution extends RawSolutionWith24 {}
export interface RawSolution extends RawSolutionWith16 {}
/** @name RawSolutionTo265 */
export interface RawSolutionTo265 extends RawSolutionWith16 {}

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