Add const example to app-js (#1424)
* Add const example to app-js * Trigger Travis
This commit is contained in:
parent
84153afd51
commit
7dffdb2e7e
20
packages/app-js/src/snippets/consts-examples.ts
Normal file
20
packages/app-js/src/snippets/consts-examples.ts
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2017-2019 @polkadot/app-js authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Snippet } from '@polkadot/app-js/types';
|
||||
|
||||
export const constsStakingParameters: Snippet = {
|
||||
value: 'constsStakingParameters',
|
||||
text: 'Get staking parameters',
|
||||
label: { color: 'green', children: 'Consts', size: 'tiny' },
|
||||
code: `// Get SRML staking parameters as consts
|
||||
// 'parameter_types' were added to substrate with spec_version: 101.
|
||||
// This example will throw an error if used with versions before that.
|
||||
|
||||
const bondingDuration = api.consts.staking.bondingDuration;
|
||||
const sessionsPerEra = api.consts.staking.sessionsPerEra;
|
||||
|
||||
console.log('Staking bonding duration: ' + bondingDuration);
|
||||
console.log('Staking sessions per era: ' + sessionsPerEra);`
|
||||
};
|
||||
@ -19,7 +19,13 @@ import {
|
||||
storageRetrieveInfoOnQueryKeys
|
||||
} from './storage-examples';
|
||||
|
||||
import { extrinsicMakeTransfer } from './extrinsics-examples';
|
||||
import {
|
||||
constsStakingParameters
|
||||
} from './consts-examples';
|
||||
|
||||
import {
|
||||
extrinsicMakeTransfer
|
||||
} from './extrinsics-examples';
|
||||
|
||||
const snippets: Snippet[] = [
|
||||
rpcNetworkAuthoring,
|
||||
@ -31,6 +37,7 @@ const snippets: Snippet[] = [
|
||||
storageListenToBalanceChange,
|
||||
storageListenToMultipleBalancesChange,
|
||||
storageRetrieveInfoOnQueryKeys,
|
||||
constsStakingParameters,
|
||||
extrinsicMakeTransfer
|
||||
];
|
||||
|
||||
|
||||
@ -9,17 +9,16 @@ export const storageGetInfo: Snippet = {
|
||||
text: 'Get chain state information',
|
||||
label: { color: 'blue', children: 'Storage', size: 'tiny' },
|
||||
code: `// Get chain state information
|
||||
// Make our basic chain state/storage queries, all in one go
|
||||
// Make our basic chain state / storage queries, all in one go
|
||||
|
||||
const [minimumValidatorCount, validators] = await Promise.all([
|
||||
const [now, minimumValidatorCount, validators] = await Promise.all([
|
||||
api.query.timestamp.now(),
|
||||
api.query.staking.minimumValidatorCount(),
|
||||
api.query.session.validators()
|
||||
]);
|
||||
|
||||
const transferFee = api.consts.balances.transferFee;
|
||||
|
||||
console.log('The current date is: ' + now);
|
||||
console.log('The minimum validator count: ' + minimumValidatorCount);
|
||||
console.log('transfer fee: ', transferFee);
|
||||
|
||||
if (validators && validators.length > 0) {
|
||||
// Retrieve the balances for all validators
|
||||
|
||||
Loading…
Reference in New Issue
Block a user