Skip to content

Commit

Permalink
Merge pull request #839 from autonomys/bug/roleAssignationFail
Browse files Browse the repository at this point in the history
Role assignation fail
  • Loading branch information
marc-aurele-besner authored Sep 2, 2024
2 parents d54de68 + 117d138 commit 74ab199
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 28 deletions.
2 changes: 0 additions & 2 deletions explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"faunadb": "^4.8.0",
"formik": "^2.4.5",
"graphql": "^16.6.0",
"js-cookie": "^3.0.5",
"jsonwebtoken": "^9.0.2",
"lodash": "^4.17.21",
"lottie-react": "^2.4.0",
Expand Down Expand Up @@ -89,7 +88,6 @@
"@next/eslint-plugin-next": "^14.1.3",
"@svgr/webpack": "^8.1.0",
"@types/jest": "^29.5.12",
"@types/js-cookie": "^3.0.6",
"@types/jsonwebtoken": "^9.0.3",
"@types/node": "^20.11.24",
"@types/react": "^18.2.63",
Expand Down
6 changes: 1 addition & 5 deletions explorer/src/providers/ChainProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
import { RetryLink } from '@apollo/client/link/retry'
import { NetworkId } from '@autonomys/auto-utils'
import { Indexer, defaultIndexer } from 'constants/indexers'
import Cookies from 'js-cookie'
import { FC, ReactNode, createContext, useCallback, useMemo, useState } from 'react'

export type ChainContextValue = {
Expand Down Expand Up @@ -63,14 +62,11 @@ export const SelectedChainProvider: FC<SelectedChainProps> = ({ indexerSet, chil

export const ChainProvider: FC<Props> = ({ children }) => {
const [indexerSet, _setIndexerSet] = useState<Indexer>(defaultIndexer)
const [network, setNetwork] = useState<NetworkId>(defaultIndexer.network)
const [section, setSection] = useState<Routes>(Routes.consensus)

const setIndexerSet = useCallback(
(indexer: Indexer) => {
Cookies.set('selected-network', indexer.network, { expires: 1 })
_setIndexerSet(indexer)
setNetwork(indexer.network)
},
[_setIndexerSet],
)
Expand All @@ -79,7 +75,7 @@ export const ChainProvider: FC<Props> = ({ children }) => {
<ChainContext.Provider
value={{
indexerSet,
network,
network: indexerSet.network,
section,
setIndexerSet,
setSection,
Expand Down
10 changes: 2 additions & 8 deletions explorer/src/utils/queryGraphqlServer.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import { indexers } from 'constants/indexers'
import { cookies } from 'next/headers'
import { defaultIndexer, indexers } from 'constants/indexers'

export const queryGraphqlServer = async (query: string, variables: object) => {
try {
// Get the selected chain from the cookies
const { get } = cookies()
const selectedNetwork = get('selected-network')
if (!selectedNetwork) throw new Error('No selected network')

// Find the selected chain api
const api = indexers.find((indexer) => indexer.network === selectedNetwork.value)
const api = indexers.find((indexer) => indexer.network === defaultIndexer.network)
if (!api) throw new Error('No selected chain api')

// Fetch the data from the api
Expand Down
41 changes: 28 additions & 13 deletions explorer/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3554,11 +3554,6 @@
expect "^29.0.0"
pretty-format "^29.0.0"

"@types/js-cookie@^3.0.6":
version "3.0.6"
resolved "https://registry.yarnpkg.com/@types/js-cookie/-/js-cookie-3.0.6.tgz#a04ca19e877687bd449f5ad37d33b104b71fdf95"
integrity sha512-wkw9yd1kEXOPnvEeEV1Go1MmxtBJL0RR79aOTAApecWFVu7w0NNXNqhcWgvw2YgZDYadliXkl14pa3WXw5jlCQ==

"@types/js-yaml@^4.0.0":
version "4.0.9"
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-4.0.9.tgz#cd82382c4f902fed9691a2ed79ec68c5898af4c2"
Expand Down Expand Up @@ -6963,11 +6958,6 @@ jose@^5.0.0:
resolved "https://registry.yarnpkg.com/jose/-/jose-5.2.3.tgz#071c87f9fe720cff741a403c8080b69bfe13164a"
integrity sha512-KUXdbctm1uHVL8BYhnyHkgp3zDX5KW8ZhAKVFEfUbU2P8Alpzjb+48hHvjOdQIyPshoblhzsuqOwEEAbtHVirA==

js-cookie@^3.0.5:
version "3.0.5"
resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-3.0.5.tgz#0b7e2fd0c01552c58ba86e0841f94dc2557dcdbc"
integrity sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==

"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
Expand Down Expand Up @@ -8980,7 +8970,16 @@ string-env-interpolation@^1.0.1:
resolved "https://registry.yarnpkg.com/string-env-interpolation/-/string-env-interpolation-1.0.1.tgz#ad4397ae4ac53fe6c91d1402ad6f6a52862c7152"
integrity sha512-78lwMoCcn0nNu8LszbP1UA7g55OeE4v7rCeWnM5B453rnNr4aq+5it3FEYtZrSEiMvHZOZ9Jlqb0OD0M2VInqg==

"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -9068,7 +9067,14 @@ stringify-object@^3.3.0:
is-obj "^1.0.1"
is-regexp "^1.0.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -10022,7 +10028,7 @@ workbox-window@6.6.1, workbox-window@^6.5.4:
"@types/trusted-types" "^2.0.2"
workbox-core "6.6.1"

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -10040,6 +10046,15 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down

0 comments on commit 74ab199

Please sign in to comment.