-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: hook and utility class to easily deal with planck denominated n…
…umber
- Loading branch information
Showing
14 changed files
with
842 additions
and
18 deletions.
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
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 |
---|---|---|
|
@@ -14,8 +14,9 @@ | |
"cache": true | ||
}, | ||
"test": { | ||
"dependsOn": ["^build"], | ||
"cache": true | ||
} | ||
}, | ||
"parallel": 5 | ||
"parallel": 6 | ||
} |
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
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
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 @@ | ||
import { ChainIdContext } from "../context.js"; | ||
import { chainSpecDataAtomFamily } from "../stores/client.js"; | ||
import type { ChainHookOptions } from "./types.js"; | ||
import { ReDotError } from "@reactive-dot/core"; | ||
import { useAtomValue } from "jotai"; | ||
import { useContext } from "react"; | ||
|
||
/** | ||
* Hook for fetching the [JSON-RPC spec](https://paritytech.github.io/json-rpc-interface-spec/api/chainSpec.html). | ||
* | ||
* @param options - Additional options | ||
* @returns The [JSON-RPC spec](https://paritytech.github.io/json-rpc-interface-spec/api/chainSpec.html) | ||
*/ | ||
export const useChainSpecData = (options?: ChainHookOptions) => { | ||
const contextChainId = useContext(ChainIdContext); | ||
const chainId = options?.chainId ?? contextChainId; | ||
|
||
if (chainId === undefined) { | ||
throw new ReDotError("No chain Id provided"); | ||
} | ||
|
||
return useAtomValue(chainSpecDataAtomFamily(chainId)); | ||
}; |
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
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 @@ | ||
build |
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,4 @@ | ||
import recommended from "@reactive-dot/eslint-config"; | ||
import tseslint from "typescript-eslint"; | ||
|
||
export default tseslint.config(...recommended); |
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,29 @@ | ||
{ | ||
"name": "@reactive-dot/utils", | ||
"version": "0.0.0", | ||
"type": "module", | ||
"files": [ | ||
"src", | ||
"build" | ||
], | ||
"exports": { | ||
".": { | ||
"default": "./build/index.js", | ||
"types": "./src/index.ts" | ||
} | ||
}, | ||
"scripts": { | ||
"dev": "tsc --build --watch", | ||
"build": "rm -rf build && tsc --build", | ||
"lint": "eslint src", | ||
"test": "vitest run" | ||
}, | ||
"devDependencies": { | ||
"@reactive-dot/eslint-config": "workspace:^", | ||
"@tsconfig/recommended": "^1.0.6", | ||
"@tsconfig/strictest": "^2.0.5", | ||
"eslint": "^9.4.0", | ||
"typescript": "^5.4.5", | ||
"vitest": "^1.6.0" | ||
} | ||
} |
Oops, something went wrong.