-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add chainSpec_v1 group of functions (#820)
* feat: add chainSpec_v1 group of functions * throw error if genesis is null
- Loading branch information
Showing
4 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { ChainProperties } from '../../index.js' | ||
import { Handler, ResponseError } from '../shared.js' | ||
import { HexString } from '@polkadot/util/types' | ||
|
||
export const chainSpec_v1_chainName: Handler<[], string> = async (context) => { | ||
return context.chain.api.getSystemChain() | ||
} | ||
|
||
export const chainSpec_v1_genesisHash: Handler<[], HexString> = async (context) => { | ||
const genesisHash = await context.chain.api.getBlockHash(0) | ||
if (genesisHash === null) { | ||
throw new ResponseError(1, 'Unexpected null genesis hash') | ||
} | ||
return genesisHash | ||
} | ||
|
||
export const chainSpec_v1_properties: Handler<[], ChainProperties> = async (context) => { | ||
return context.chain.api.getSystemProperties() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import * as ChainHeadV1RPC from './chainHead_v1.js' | ||
import * as ChainSpecV1RPC from './chainSpec_v1.js' | ||
import * as TransactionV1RPC from './transaction_v1.js' | ||
|
||
export { ChainHeadV1RPC, TransactionV1RPC } | ||
export { ChainHeadV1RPC, TransactionV1RPC, ChainSpecV1RPC } | ||
|
||
const handlers = { | ||
...ChainHeadV1RPC, | ||
...TransactionV1RPC, | ||
...ChainSpecV1RPC, | ||
} | ||
|
||
export default handlers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`chainSpec_v1 > retrieves the chainSpec data 1`] = ` | ||
{ | ||
"genesisHash": "0xfc41b9bd8ef8fe53d58c7ea67c794c7ec9a73daf05e6d54b14ff6342c99ba64c", | ||
"name": "Acala", | ||
"properties": { | ||
"ss58Format": 10, | ||
"tokenDecimals": [ | ||
12, | ||
12, | ||
10, | ||
10, | ||
], | ||
"tokenSymbol": [ | ||
"ACA", | ||
"AUSD", | ||
"DOT", | ||
"LDOT", | ||
], | ||
}, | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters