Skip to content

Commit

Permalink
feat: add /pallets/errors (#1176)
Browse files Browse the repository at this point in the history
* add controller and service for errors

* add pallet errors endpoint

* removed unused error query param

* fix newline in response json

* add abstract pallet service

* add AbstractPallerService

* remove dev log

* change access modifier in abstract pallets

* change fn name

* add errors pallet to kusama

* remove unused import
remove newline

* remove lower casing of pallet name in fetchErrors
update latest polkadot e2e tests with PhragmentElection Pallet

* update parsedPalletName
  • Loading branch information
marshacb committed Jan 23, 2023
1 parent 93e7d36 commit 65a0881
Show file tree
Hide file tree
Showing 33 changed files with 1,106 additions and 161 deletions.
2 changes: 1 addition & 1 deletion docs/dist/app.bundle.js

Large diffs are not rendered by default.

167 changes: 164 additions & 3 deletions docs/src/openapi-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ paths:
description: The storage deposit limit to be used as an option for the queried message.
required: false
schema:
deafult: null
default: null
type: number
- name: args
in: query
Expand Down Expand Up @@ -1016,6 +1016,113 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
/pallets/{palletId}/errors:
get:
tags:
- pallets
summary: Get a list of errors for a pallet.
description: Returns a list of error item metadata for error items of the
specified palletId.
parameters:
- name: palletId
in: path
description: 'Name or index of the pallet to read error metadata for. Note: the pallet name must match what is
specified in the runtime metadata.'
required: true
schema:
type: string
- name: onlyIds
in: query
description: Only return the names (IDs) of the error items instead of every error's metadata.
required: false
schema:
type: boolean
- name: at
in: query
description: Block at which to retrieve a list of
the pallet's error items.
required: false
schema:
type: string
description: Block identifier, as the block height or block hash.
format: unsignedInteger or $hex
responses:
"200":
description: successful operation
content:
application/json:
schema:
type: array
description: Pallet info and Array of errorItemIds.
items:
$ref: '#/components/schemas/PalletErrors'
"400":
description: invalid blockId supplied for at query param
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
"404":
description: could not find pallet with palletId
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/pallets/{palletId}/errors/{errorItemId}:
get:
tags:
- pallets
summary: Get the value of an error item.
description: Returns the value stored under the errorItemId.
parameters:
- name: palletId
in: path
description: 'Name or index of the pallet to read error metadata for. Note: the pallet name must match what is
specified in the runtime metadata.'
required: true
schema:
type: string
- name: errorItemId
in: path
description: Id of the error item to query for.
required: true
schema:
type: string
- name: at
in: query
description: Block at which to query the error item at.
required: false
schema:
type: string
description: Block identifier, as the block height or block hash.
format: unsignedInteger or $hex
- name: metadata
in: query
description: Include the error items metadata (including documentation)
if set to true.
required: false
schema:
default: false
type: boolean
responses:
"200":
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/PalletErrorsItem'
"400":
description: invalid blockId supplied for at query param
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
"404":
description: could not find resource with with id
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/runtime/metadata:
get:
tags:
Expand Down Expand Up @@ -2400,11 +2507,65 @@ components:
$ref: '#/components/schemas/AssetInfo'
assetMetadata:
$ref: '#/components/schemas/AssetMetadata'
PalletsNominationPool:
PalletErrors:
type: object
properties:
at:
$ref: '#/components/schemas/BlockIdentifiers'
pallet:
type: string
description: Name of the pallet.
example: "democracy"
palletIndex:
type: string
description: Index of the pallet for looking up errors.
example: "14"
items:
type: array
items:
$ref: '#/components/schemas/PalletErrorsItemMetadata'
description: Array containing metadata for each error entry of the pallet.
PalletErrorsItem:
type: object
properties:
pallet:
type: string
description: Name of the pallet.
example: "democracy"
palletIndex:
type: string
description: Index of the pallet for looking up errors.
example: "14"
errorItem:
type: string
description: Name of the error item.
example: "ValueLow"
metadata:
$ref: '#/components/schemas/PalletErrorsItemMetadata'
PalletErrorsItemMetadata:
type: object
properties:
name:
type: string
example: "InsufficientFunds"
description: The error item's name (which is the same as the error item's ID).
fields:
type: array
items:
type: string
index:
type: string
example: "0"
description: The index of the error item in the lists of pallet errors
docs:
type: string
example: " Information concerning any given error.\n\n TWOX-NOTE: SAFE as indexes are not under an attacker’s control."
args:
type: array
items:
type: string
description: Metadata of an error item from a FRAME pallet.
PalletsNominationPool:
bondedPool:
$ref: '#/components/schemas/BondedPool'
rewardPool:
Expand Down Expand Up @@ -3307,6 +3468,6 @@ components:
ContractMetadata:
content:
application/json:
scehma:
schema:
$ref: '#/components/schemas/ContractMetadata'

18 changes: 18 additions & 0 deletions e2e-tests/latest/endpoints/polkadot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,24 @@ export const polkadot: IConfig = {
'at={blockId}',
]
},
'/pallets/{palletId}/errors': {
path: '/pallets/balances/errors',
queryParams: [
'at={blockId}'
],
},
'/pallets/{palletId}/errors?onlyIds=true': {
path: '/pallets/17/errors',
queryParams: [
'at={blockId}'
],
},
'/pallets/{palletId}/errors/{errorItemId}': {
path: '/pallets/democracy/errors/ValueLow',
queryParams: [
'at={blockId}'
],
},
'/pallets/nominationPoools/info': {
path: '/pallets/nominationPools/info',
queryParams: [
Expand Down
12 changes: 12 additions & 0 deletions e2e-tests/latest/endpoints/statemint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,16 @@ export const statemint = {
'at={blockId}'
],
},
'/pallets/{palletId}/errors': {
path: '/pallets/assets/errors',
queryParams: [
'at={blockId}'
],
},
'/pallets/{palletId}/errors/{errorItemId}': {
path: '/pallets/assets/errors/Frozen',
queryParams: [
'at={blockId}'
],
},
};
1 change: 1 addition & 0 deletions src/chains-config/astarControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const astarControllers: ControllerConfig = {
'NodeTransactionPool',
'NodeVersion',
'PalletsAssets',
'PalletsErrors',
'PalletsStorage',
'Paras',
'RuntimeCode',
Expand Down
1 change: 1 addition & 0 deletions src/chains-config/defaultControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const defaultControllers: ControllerConfig = {
'NodeTransactionPool',
'NodeVersion',
'PalletsAssets',
'PalletsErrors',
'PalletsStakingProgress',
'PalletsStorage',
'Paras',
Expand Down
1 change: 1 addition & 0 deletions src/chains-config/kusamaControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const kusamaControllers: ControllerConfig = {
'NodeNetwork',
'NodeTransactionPool',
'NodeVersion',
'PalletsErrors',
'PalletsNominationPools',
'PalletsStakingProgress',
'PalletsStorage',
Expand Down
1 change: 1 addition & 0 deletions src/chains-config/polkadotControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const polkadotControllers: ControllerConfig = {
'NodeNetwork',
'NodeTransactionPool',
'NodeVersion',
'PalletsErrors',
'PalletsNominationPools',
'PalletsStakingProgress',
'PalletsStorage',
Expand Down
1 change: 1 addition & 0 deletions src/chains-config/statemineControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const statemineControllers: ControllerConfig = {
'NodeTransactionPool',
'NodeVersion',
'PalletsAssets',
'PalletsErrors',
'RuntimeCode',
'RuntimeMetadata',
'RuntimeSpec',
Expand Down
1 change: 1 addition & 0 deletions src/chains-config/statemintControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const statemintControllers: ControllerConfig = {
'NodeTransactionPool',
'NodeVersion',
'PalletsAssets',
'PalletsErrors',
'RuntimeCode',
'RuntimeMetadata',
'RuntimeSpec',
Expand Down
1 change: 1 addition & 0 deletions src/chains-config/westendControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const westendControllers: ControllerConfig = {
'NodeNetwork',
'NodeTransactionPool',
'NodeVersion',
'PalletsErrors',
'PalletsNominationPools',
'PalletsStakingProgress',
'PalletsStorage',
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { ContractsInk } from './contracts';
import { NodeNetwork, NodeTransactionPool, NodeVersion } from './node';
import {
PalletsAssets,
PalletsErrors,
PalletsNominationPools,
PalletsStakingProgress,
PalletsStorage,
Expand Down Expand Up @@ -57,6 +58,7 @@ export const controllers = {
AccountsStakingPayouts,
ContractsInk,
PalletsAssets,
PalletsErrors,
PalletsNominationPools,
PalletsStakingProgress,
PalletsStorage,
Expand Down
Loading

0 comments on commit 65a0881

Please sign in to comment.