Skip to content
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
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"start": "serve -s build",
"dev": "craco start",
"build": "craco build && echo '/* /index.html 200' | cat >build/_redirects ",
"build": "NODE_OPTIONS='--max-old-space-size=4096' craco build && echo '/* /index.html 200' | cat >build/_redirects ",
"analyze": "source-map-explorer 'build/static/js/*.js'",
"test": "playwright test --project=chromium",
"test:ui": "playwright test --ui",
Expand All @@ -32,12 +32,12 @@
"@mui/material": "^5.14.14",
"@mui/x-date-pickers": "^5.0.2",
"@tanstack/react-query": "^5.59.13",
"@taquito/beacon-wallet": "^20.0.0",
"@taquito/signer": "^20.0.0",
"@taquito/taquito": "^20.0.0",
"@taquito/tzip12": "^20.0.0",
"@taquito/tzip16": "^20.0.0",
"@taquito/utils": "^20.0.0",
"@taquito/beacon-wallet": "^22.0.0",
"@taquito/signer": "^22.0.0",
"@taquito/taquito": "^22.0.0",
"@taquito/tzip12": "^22.0.0",
"@taquito/tzip16": "^22.0.0",
"@taquito/utils": "^22.0.0",
"@types/mixpanel-browser": "^2.35.7",
"@types/prismjs": "^1.26.0",
"@types/react-paginate": "^7.1.2",
Expand Down Expand Up @@ -125,14 +125,14 @@
"resolutions": {
"@types/react": "~17.0.3",
"react-error-overlay": "6.0.9",
"@walletconnect/core": "2.14.0",
"@walletconnect/types": "2.14.0",
"@walletconnect/utils": "2.14.0"
"@walletconnect/core": "2.18.0",
"@walletconnect/types": "2.18.0",
"@walletconnect/utils": "2.18.0"
},
"overrides": {
"@walletconnect/core": "2.14.0",
"@walletconnect/types": "2.14.0",
"@walletconnect/utils": "2.14.0"
"@walletconnect/core": "2.18.0",
"@walletconnect/types": "2.18.0",
"@walletconnect/utils": "2.18.0"
},
"eslintConfig": {
"extends": [
Expand Down
13 changes: 12 additions & 1 deletion src/modules/lite/creator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,18 @@ export const CommunityCreator: React.FC = () => {

try {
const { signature, payloadBytes } = await getSignature(account, wallet, JSON.stringify(values))
const publicKey = (await wallet?.client.getActiveAccount())?.publicKey
let publicKey: string | undefined
try {
const activeAccount = await wallet?.client.getActiveAccount()
publicKey = activeAccount?.publicKey
} catch (error) {
console.warn("Could not get active account, proceeding without public key:", error)
return openNotification({
message: "Could not get active account, please try again later",
autoHideDuration: 3000,
variant: "error"
})
}
if (!signature) {
openNotification({
message: `Issue with Signature`,
Expand Down
9 changes: 4 additions & 5 deletions src/modules/lite/explorer/pages/CreateProposal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { saveLiteProposal } from "services/services/lite/lite-services"
import { isWebUri } from "valid-url"
import { useDAO } from "services/services/dao/hooks/useDAO"
import { useDAOID } from "modules/explorer/pages/DAO/router"
import { useUserTokenBalance } from "services/contracts/token/hooks/useUserTokenBalance"
import CodeIcon from "@mui/icons-material/Code"
import CodeOffIcon from "@mui/icons-material/CodeOff"
import { ProposalCodeEditorInput } from "modules/explorer/components/ProposalFormInput"
Expand Down Expand Up @@ -706,7 +705,7 @@ const calculateEndTime = (days: number, hours: number, minutes: number) => {

export const ProposalCreator: React.FC<{ id?: string; onClose?: any }> = props => {
const navigate = useHistory()
const { network, account, wallet, etherlink } = useTezos()
const { network, account, wallet, etherlink, getPublicKey } = useTezos()
const openNotification = useNotification()
const [isLoading, setIsLoading] = useState(false)
const daoId = useDAOID()
Expand Down Expand Up @@ -743,10 +742,10 @@ export const ProposalCreator: React.FC<{ id?: string; onClose?: any }> = props =
data.author = account

const { signature, payloadBytes } = await getSignature(account, wallet, JSON.stringify(data))
const publicKey = (await wallet?.client.getActiveAccount())?.publicKey
if (!signature) {
const publicKey = await getPublicKey()
if (!signature || !publicKey) {
openNotification({
message: `Issue with Signature`,
message: `Issue with Signature or Public Key`,
autoHideDuration: 3000,
variant: "error"
})
Expand Down
8 changes: 4 additions & 4 deletions src/modules/lite/explorer/pages/ProposalDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const ProposalDetails: React.FC<{ id: string }> = ({ id }) => {

const isMobileSmall = useMediaQuery(theme.breakpoints.down("sm"))
const navigate = useHistory()
const { network, account, wallet, etherlink } = useTezos()
const { network, account, wallet, etherlink, getPublicKey } = useTezos()
const openNotification = useNotification()
const [refresh, setRefresh] = useState<number>()
const community = useCommunity(id)
Expand Down Expand Up @@ -123,11 +123,11 @@ export const ProposalDetails: React.FC<{ id: string }> = ({ id }) => {
const saveVote = async () => {
if (wallet) {
try {
const publicKey = (await wallet?.client.getActiveAccount())?.publicKey
const publicKey = await getPublicKey()
const { signature, payloadBytes } = await getSignature(account, wallet, JSON.stringify(votesData))
if (!signature) {
if (!signature || !publicKey) {
openNotification({
message: `Issue with Signature`,
message: `Issue with Signature or Public Key`,
autoHideDuration: 3000,
variant: "error"
})
Expand Down
27 changes: 16 additions & 11 deletions src/services/beacon/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,25 @@ const getSavedState = async (): Promise<TezosState> => {
const network = getTezosNetwork()
const tezos = createTezos(network)
const wallet = createWallet(network)
const activeAccount = await wallet.client.getActiveAccount()

if (!activeAccount?.address) {
throw new Error("No wallet address found")
// Try to get existing active account first (for backward compatibility)
try {
const activeAccount = await wallet.client.getActiveAccount()
if (activeAccount?.address) {
tezos.setProvider({ wallet })
return {
network,
tezos,
wallet,
account: activeAccount.address
}
}
} catch (error) {
// If getActiveAccount fails, fall back to INITIAL_STATE
console.warn("getActiveAccount failed, falling back to initial state:", error)
}

tezos.setProvider({ wallet })

return {
network,
tezos,
wallet,
account: activeAccount.address
}
return INITIAL_STATE
} catch (error) {
return INITIAL_STATE
}
Expand Down
20 changes: 20 additions & 0 deletions src/services/beacon/hooks/useTezos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { BeaconWallet } from "@taquito/beacon-wallet"
import { EtherlinkContext } from "services/wagmi/context"
import { useNetwork } from "services/useNetwork"
import { useChainId } from "wagmi"
import { useNotification } from "modules/common/hooks/useNotification"

type WalletConnectReturn = {
tezos: TezosToolkit
Expand All @@ -17,6 +18,7 @@ type WalletConnectReturn = {
account: string
network: Network
wallet: BeaconWallet | undefined
getPublicKey: () => Promise<string | null>
etherlink: any
isEtherlink: boolean
}
Expand All @@ -27,6 +29,7 @@ export const useTezos = (): WalletConnectReturn => {
dispatch
} = useContext(TezosContext)
const { setNetwork } = useNetwork()
const openNotification = useNotification()

const {
switchToNetwork,
Expand Down Expand Up @@ -194,6 +197,23 @@ export const useTezos = (): WalletConnectReturn => {
changeNetwork: handleChangeNetwork,
account,
wallet,
getPublicKey: async () => {
let publicKey: string | undefined
try {
const activeAccount = await wallet?.client.getActiveAccount()
publicKey = activeAccount?.publicKey
} catch (error) {
console.warn("Could not get active account, proceeding without public key:", error)
publicKey = undefined
openNotification({
variant: "error",
message: "Could not get active account, proceeding without public key",
autoHideDuration: 3000
})
return null
}
return publicKey || null
},
network,
isEtherlink: network?.startsWith("etherlink"),
etherlink: {
Expand Down
10 changes: 6 additions & 4 deletions src/services/contracts/baseDAO/hooks/useOriginate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ export const useOriginate = (template: DAOTemplate) => {
const [states, setStates] = useState(INITIAL_STATES)

const [activeState, setActiveState] = useState<number>()
const { tezos, connect, network, account, wallet, etherlink } = useTezos()
const provider = etherlink.provider
const signer = etherlink.signer
const { tezos, connect, network, account, wallet, getPublicKey } = useTezos()

const result = useMutation<ContractAbstraction<ContractProvider | Wallet>, Error, OriginateParams>(
async ({ metadataParams, params, deploymentMethod }) => {
Expand Down Expand Up @@ -263,7 +261,11 @@ export const useOriginate = (template: DAOTemplate) => {
tokenID: params.orgSettings.governanceToken.tokenId
}
const { signature, payloadBytes } = await getSignature(account, wallet, JSON.stringify(values))
const publicKey = (await wallet?.client.getActiveAccount())?.publicKey
const publicKey = await getPublicKey()

if (!signature || !publicKey) {
throw new Error("Could not get signature or public key")
}

const resp = await saveLiteCommunity(signature, publicKey, payloadBytes, network)
const data = await resp.json()
Expand Down
Loading
Loading