Skip to content

Commit

Permalink
fix: build
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut committed Jun 27, 2024
1 parent 319107a commit 9f02ff4
Show file tree
Hide file tree
Showing 25 changed files with 1,154 additions and 31,864 deletions.
5 changes: 0 additions & 5 deletions packages/ui/node-metadata.json

This file was deleted.

4 changes: 3 additions & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
"@mui/material": "^5.15.15",
"@mui/styled-engine": "^5.15.14",
"@polkadot/api": "^12.0.1",
"@polkadot/api-augment": "^12.0.1",
"@polkadot/extension-dapp": "^0.47.6",
"@polkadot/react-identicon": "^3.6.6",
"@polkadot/types": "^12.0.1",
"@polkadot/util-crypto": "^12.6.2",
"@tanstack/react-query": "^5.29.2",
"@types/react-router-dom": "^5.3.3",
Expand All @@ -36,7 +38,7 @@
"@graphql-codegen/typescript-react-query": "^6.1.0",
"@graphql-eslint/eslint-plugin": "^3.20.1",
"@polkadot/extension-inject": "^0.47.6",
"@polkadot/typegen": "^10.13.1",
"@polkadot/typegen": "^12.0.1",
"@types/node": "^20.12.7",
"@types/react-dom": "^18.2.25",
"@typescript-eslint/eslint-plugin": "^7.6.0",
Expand Down
7 changes: 6 additions & 1 deletion packages/ui/src/components/modals/ProposalSigning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ const ProposalSigning = ({
const shouldExecute = hasReachedThreshold ? true : amountOfSigner >= threshold - 1

setIsSubmitting(true)
let tx: SubmittableExtrinsic<'promise'>
let tx: SubmittableExtrinsic<'promise'> | undefined

// if it's a rejection we can send it right away, no need for weight or calldata
if (!isApproving) {
Expand Down Expand Up @@ -239,6 +239,11 @@ const ProposalSigning = ({
return
}

if (!tx) {
console.error('tx is undefined in ProposalSigning')
return
}

tx.signAndSend(selectedAccount.address, { signer: selectedSigner }, signCallback)
.then(() => {
// poll for 1min if the tx may make changes
Expand Down
17 changes: 5 additions & 12 deletions packages/ui/src/contexts/ApiContext.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import React, { useMemo } from 'react'
import { ApiPromise, WsProvider } from '@polkadot/api'
import { ApiOptions } from '@polkadot/api/types'
import { TypeRegistry } from '@polkadot/types'
import { useState, useEffect, createContext, useContext } from 'react'
import { useNetwork } from './NetworkContext'
import { ethereumChains } from '../utils/ethereumChains'
import '@polkadot/api-augment'

type ApiContextProps = {
children: React.ReactNode | React.ReactNode[]
types?: ApiOptions['types']
}

const registry = new TypeRegistry()

export interface IApiContext {
api?: false | ApiPromise
chainInfo?: ChainInfoHuman
Expand All @@ -33,7 +29,7 @@ interface RawChainInfoHuman {

const ApiContext = createContext<IApiContext | undefined>(undefined)

const ApiContextProvider = ({ children, types }: ApiContextProps) => {
const ApiContextProvider = ({ children }: ApiContextProps) => {
const { selectedNetworkInfo } = useNetwork()
const [chainInfo, setChainInfo] = useState<ChainInfoHuman | undefined>()
const [apiPromise, setApiPromise] = useState<ApiPromise | undefined>()
Expand All @@ -48,7 +44,7 @@ const ApiContextProvider = ({ children, types }: ApiContextProps) => {

// console.log('---> connecting to', provider.endpoint)
setIsApiReady(false)
const api = new ApiPromise({ provider, types })
const api = new ApiPromise({ provider })
api.isReady.then((newApi) => setApiPromise(newApi)).catch(console.error)

return () => {
Expand All @@ -60,17 +56,14 @@ const ApiContextProvider = ({ children, types }: ApiContextProps) => {

// prevent an infinite loop
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [provider, types])
}, [provider])

useEffect(() => {
if (!apiPromise) return

apiPromise.isReady
.then((api) => {
setIsApiReady(true)
if (types) {
registry.register(types)
}

const info = api.registry.getChainProperties()
const raw = info?.toHuman() as unknown as RawChainInfoHuman
Expand All @@ -84,7 +77,7 @@ const ApiContextProvider = ({ children, types }: ApiContextProps) => {
})
})
.catch(console.error)
}, [apiPromise, types])
}, [apiPromise])

return (
<ApiContext.Provider
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/hooks/useGetMultisigTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const useGetMultisigTx = ({

try {
// the proxy is selected
if (isProxy) {
if (isProxy && !!extrinsicToCall) {
tx = api.tx.proxy.proxy(fromAddress, null, extrinsicToCall)
// a multisig is selected
} else {
Expand Down
Loading

0 comments on commit 9f02ff4

Please sign in to comment.