Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: release v1.1.0 #154

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .env.local.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
VITE_LOCAL_HOSTNAME=http://127.0.0.1
VITE_PROXY_URL_REGEN_MAINNET=http://api.registry.regen.network
VITE_PROXY_URL_REGEN_TESTNET=http://api-staging.registry.regen.network
VITE_INDEXER_GRAPHQL_API=http://localhost:5000/indexer/v1/graphql
VITE_PROXY_URL_REGEN_MAINNET=http://api.regen.network
VITE_PROXY_URL_REGEN_TESTNET=http://api-staging.regen.network
VITE_INDEXER_GRAPHQL_API_REGEN_LOCAL=http://127.0.0.1:5000/indexer/v1/graphql
VITE_INDEXER_GRAPHQL_API_REGEN_MAINNET=http://127.0.0.1:5000/indexer/v1/graphql
VITE_INDEXER_GRAPHQL_API_REGEN_TESTNET=http://127.0.0.1:5000/indexer/v1/graphql
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ local-ledger
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

### Storybook ###
storybook-static
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.0.0](https://github.com/regen-network/groups-ui/commits/v1.0.0) (2023-08-09)
2 changes: 1 addition & 1 deletion indexer-codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CodegenConfig } from '@graphql-codegen/cli'

const config: CodegenConfig = {
overwrite: true,
schema: 'http://localhost:5000/indexer/v1/graphql',
schema: 'http://127.0.0.1:5000/indexer/v1/graphql',
documents: ['src/graphql/indexer/**/*.graphql'],
generates: {
'./src/gql/': {
Expand Down
6 changes: 0 additions & 6 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
[context.production.environment]
VITE_INDEXER_GRAPHQL_API="https://api.regen.network/indexer/v1/graphql"

[context.deploy-preview.environment]
VITE_INDEXER_GRAPHQL_API="https://api-staging.regen.network/indexer/v1/graphql"

[[redirects]]
from = "/*"
to = "/index.html"
Expand Down
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "groups-ui",
"version": "0.0.0",
"version": "1.0.0",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
Expand All @@ -13,7 +13,7 @@
"type-check": "tsc",
"storybook": "storybook dev -p 6006",
"storybook-clean": "rm -rf ./node_modules/.cache/storybook",
"build-storybook": "storybook build"
"build-storybook": "NODE_OPTIONS=--max_old_space_size=8192 storybook build"
},
"dependencies": {
"@chakra-ui/icons": "^2.0.19",
Expand Down Expand Up @@ -60,12 +60,13 @@
"@graphql-codegen/cli": "^4.0.1",
"@graphql-codegen/client-preset": "^4.0.1",
"@keplr-wallet/types": "^0.11.59",
"@storybook/addon-actions": "^7.0.18",
"@storybook/addon-essentials": "^7.0.18",
"@storybook/addon-interactions": "^7.0.18",
"@storybook/addon-links": "^7.0.18",
"@storybook/react": "^7.0.18",
"@storybook/react-vite": "^7.0.18",
"@storybook/addons": "^7.3.0",
"@storybook/addon-actions": "^7.3.0",
"@storybook/addon-essentials": "^7.3.0",
"@storybook/addon-interactions": "^7.3.0",
"@storybook/addon-links": "^7.3.0",
"@storybook/react": "^7.3.0",
"@storybook/react-vite": "^7.3.0",
"@storybook/testing-library": "^0.1.0",
"@types/react": "^18.2.8",
"@types/react-dom": "^18.2.4",
Expand All @@ -89,8 +90,8 @@
"pre-commit": "^1.2.2",
"prettier": "^2.8.8",
"rollup-plugin-visualizer": "^5.9.0",
"storybook": "^7.0.18",
"storybook-addon-react-router-v6": "^1.0.2",
"storybook": "^7.3.0",
"storybook-addon-react-router-v6": "^2.0.4",
"ts-node": "^10.9.1",
"ts-proto": "^1.148.2",
"typescript": "^5.1.6",
Expand Down
13 changes: 10 additions & 3 deletions src/api/chains/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@ const {

import { regenLocal, regenMainnet, regenTestnet } from './regen'

export const mainnetChainsArray: ChainInfo[] = [
export interface ChainInfoExtended extends ChainInfo {
indexer: string
}

export const mainnetChainsArray: ChainInfoExtended[] = [
...(VITE_PROXY_URL_REGEN_MAINNET ? [regenMainnet] : []),
]

export const testnetChainsArray: ChainInfo[] = [
export const testnetChainsArray: ChainInfoExtended[] = [
...(VITE_PROXY_URL_REGEN_TESTNET ? [regenTestnet] : []),
...(VITE_LOCAL_HOSTNAME ? [regenLocal] : []),
]

export const allChainsArray: ChainInfo[] = [...mainnetChainsArray, ...testnetChainsArray]
export const allChainsArray: ChainInfoExtended[] = [
...mainnetChainsArray,
...testnetChainsArray,
]
41 changes: 31 additions & 10 deletions src/api/chains/regen.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import type { AppCurrency, ChainInfo } from '@keplr-wallet/types'
import type { AppCurrency } from '@keplr-wallet/types'

import { Bech32Address } from 'util/bech32'

import { ChainInfoExtended } from './index'

const {
VITE_LOCAL_HOSTNAME,
VITE_PROXY_URL_REGEN_MAINNET,
VITE_PROXY_URL_REGEN_TESTNET,
VITE_INDEXER_GRAPHQL_API_REGEN_LOCAL,
VITE_INDEXER_GRAPHQL_API_REGEN_MAINNET,
VITE_INDEXER_GRAPHQL_API_REGEN_TESTNET,
} = import.meta.env

const REGEN: AppCurrency = {
Expand All @@ -22,10 +27,12 @@ const REGEN: AppCurrency = {
*/
const currencies: AppCurrency[] = [REGEN]

export const regenLocal: ChainInfo = {
export const regenLocal: ChainInfoExtended = {
// hardcoded port values based on makefile
rpc: `${VITE_LOCAL_HOSTNAME}:26657`,
rest: `${VITE_LOCAL_HOSTNAME}:1317`,
rpc: VITE_LOCAL_HOSTNAME ? `${VITE_LOCAL_HOSTNAME}:26657` : 'http://127.0.0.1:26657',
rest: VITE_LOCAL_HOSTNAME ? `${VITE_LOCAL_HOSTNAME}:1317` : 'http://127.0.0.1:1317',
indexer:
VITE_INDEXER_GRAPHQL_API_REGEN_LOCAL || 'http://127.0.0.1:5000/indexer/v1/graphql',
chainId: 'regen-local',
chainName: 'Regen Local',
stakeCurrency: REGEN,
Expand All @@ -40,9 +47,16 @@ export const regenLocal: ChainInfo = {
/**
* @see https://github.com/cosmos/chain-registry/blob/master/regen/chain.json
*/
export const regenMainnet: ChainInfo = {
rpc: `${VITE_PROXY_URL_REGEN_MAINNET}/ledger`,
rest: `${VITE_PROXY_URL_REGEN_MAINNET}/ledger-rest`,
export const regenMainnet: ChainInfoExtended = {
rpc: VITE_PROXY_URL_REGEN_MAINNET
? `${VITE_PROXY_URL_REGEN_MAINNET}/ledger`
: 'https://api.regen.network/ledger',
rest: VITE_PROXY_URL_REGEN_MAINNET
? `${VITE_PROXY_URL_REGEN_MAINNET}/ledger-rest`
: 'https://api.regen.network/ledger-rest',
indexer:
VITE_INDEXER_GRAPHQL_API_REGEN_MAINNET ||
'https://api.regen.network/indexer/v1/graphql',
chainId: 'regen-1',
chainName: 'Regen',
stakeCurrency: REGEN,
Expand All @@ -54,9 +68,16 @@ export const regenMainnet: ChainInfo = {
feeCurrencies: currencies,
}

export const regenTestnet: ChainInfo = {
rpc: `${VITE_PROXY_URL_REGEN_TESTNET}/ledger`,
rest: `${VITE_PROXY_URL_REGEN_TESTNET}/ledger-rest`,
export const regenTestnet: ChainInfoExtended = {
rpc: VITE_PROXY_URL_REGEN_TESTNET
? `${VITE_PROXY_URL_REGEN_TESTNET}/ledger`
: 'https://api-staging.regen.network/ledger',
rest: VITE_PROXY_URL_REGEN_TESTNET
? `${VITE_PROXY_URL_REGEN_TESTNET}/ledger-rest`
: 'https://api.regen.network/ledger-rest',
indexer:
VITE_INDEXER_GRAPHQL_API_REGEN_TESTNET ||
'https://api-staging.regen.network/indexer/v1/graphql',
chainId: 'regen-redwood-1',
chainName: 'Regen Redwood',
stakeCurrency: REGEN,
Expand Down
3 changes: 1 addition & 2 deletions src/api/ipfs.actions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { create as createIpfsClient } from 'ipfs-http-client'

import { throwError } from 'util/errors'
import { isJson } from 'util/validation'

const client = createIpfsClient({
Expand All @@ -20,6 +19,6 @@ export async function fetchIpfsData(cid: string) {
const dataStr = data.toString()
return isJson(dataStr) ? JSON.parse(dataStr) : dataStr
} catch (error) {
throwError(error)
console.log({ error, cid, message: 'unable to fetch ipfs data' })
}
}
8 changes: 4 additions & 4 deletions src/graphql-request-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React, { useState } from 'react'
import { GraphQLClient } from 'graphql-request'
import { GraphqlRequestContext } from 'graphql-request-context'
import { useSnapshot } from 'valtio'

const { VITE_INDEXER_GRAPHQL_API } = import.meta.env
import { Chain } from './store/chain.store'

export const GraphqlProvider = ({ children }: { children?: React.ReactNode }) => {
const { active } = useSnapshot(Chain)
const [client, setClient] = useState<GraphQLClient | undefined>(undefined)
if (!client) {
setClient(
new GraphQLClient(
VITE_INDEXER_GRAPHQL_API || 'http://localhost:5000/indexer/graphql',
),
new GraphQLClient(active.indexer || 'http://127.0.0.1:5000/indexer/v1/graphql'),
)
}
return (
Expand Down
22 changes: 14 additions & 8 deletions src/hooks/use-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,21 @@ export function useGroupHistoricalProposals(groupId?: string) {
}
const result = []
for (const address of policyIds) {
const res = await client.request(ProposalsByGroupPolicyAddressDocument, {
groupPolicyAddress: address,
})
if (!!res.allProposals && !!res.allProposals.nodes) {
const { nodes } = res.allProposals
for (const node of nodes) {
const uiProposal = nodeToUIProposal(node)
result.push(uiProposal)
// NOTE: We use a try-catch statement to prevent the application from being dependent on
// indexed proposals being available (i.e. a successful request to the graphql endpoint).
try {
const res = await client.request(ProposalsByGroupPolicyAddressDocument, {
groupPolicyAddress: address,
})
if (!!res.allProposals && !!res.allProposals.nodes) {
const { nodes } = res.allProposals
for (const node of nodes) {
const uiProposal = nodeToUIProposal(node)
result.push(uiProposal)
}
}
} catch (e) {
console.error(e)
}
}
return result
Expand Down
7 changes: 3 additions & 4 deletions src/store/chain.store.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { StdFee } from '@cosmjs/stargate'
import type { ChainInfo } from '@keplr-wallet/types'
import { proxy } from 'valtio'

import type { ValidatorSDKType } from 'types'
import { isJson } from 'util/validation'

import { allChainsArray } from 'api/chains'
import { allChainsArray, ChainInfoExtended } from 'api/chains'

import { bootstrapKeplr } from './wallet.store'

Expand All @@ -15,8 +14,8 @@ const savedChain = localStorage.getItem(LOCALSTORAGE_CHAIN_KEY)
const defaultChain = allChainsArray[0]

type ChainStore = {
active: ChainInfo
all: ChainInfo[]
active: ChainInfoExtended
all: ChainInfoExtended[]
fee?: StdFee // | 'auto' | number
stakeDenom: string
validators: ValidatorSDKType[]
Expand Down
Loading