Skip to content

Commit

Permalink
Merge pull request #803 from invariant-labs/dev
Browse files Browse the repository at this point in the history
Update staging env
  • Loading branch information
wojciech-cichocki authored Dec 3, 2024
2 parents e2577f3 + 2ad5107 commit 990ea4e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
34 changes: 25 additions & 9 deletions src/containers/HeaderWrapper/HeaderWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,44 +68,60 @@ export const HeaderWrapper: React.FC = () => {
})()
}, [])

const shouldResetRpc = useMemo(() => {
const defaultRpcNumber = localStorage.getItem(`INVARIANT_DEFAULT_RPC_NUMBER`)

const currentRpcNumber =
RECOMMENDED_RPC_ADDRESS[NetworkType.Mainnet].slice(-12, -1) +
RECOMMENDED_RPC_ADDRESS[NetworkType.Testnet].slice(-15, -5) +
RECOMMENDED_RPC_ADDRESS[NetworkType.Devnet].slice(-15, -5)

if (defaultRpcNumber === null || currentRpcNumber !== defaultRpcNumber) {
localStorage.setItem(`INVARIANT_DEFAULT_RPC_NUMBER`, currentRpcNumber)
return true
} else {
return false
}
}, [])

const defaultTestnetRPC = useMemo(() => {
const lastRPC = localStorage.getItem(`INVARIANT_RPC_SOLANA_${NetworkType.Testnet}`)

if (lastRPC === null) {
if (lastRPC === null || shouldResetRpc) {
localStorage.setItem(
`INVARIANT_RPC_SOLANA_${NetworkType.Testnet}`,
RECOMMENDED_RPC_ADDRESS[NetworkType.Devnet]
)
}

return lastRPC === null ? RPC.TEST : lastRPC
}, [])
return lastRPC === null || shouldResetRpc ? RPC.TEST : lastRPC
}, [shouldResetRpc])

const defaultDevnetRPC = useMemo(() => {
const lastRPC = localStorage.getItem(`INVARIANT_RPC_SOLANA_${NetworkType.Devnet}`)

if (lastRPC === null) {
if (lastRPC === null || shouldResetRpc) {
localStorage.setItem(
`INVARIANT_RPC_SOLANA_${NetworkType.Devnet}`,
RECOMMENDED_RPC_ADDRESS[NetworkType.Devnet]
)
}

return lastRPC === null ? RPC.DEV : lastRPC
}, [])
return lastRPC === null || shouldResetRpc ? RPC.DEV : lastRPC
}, [shouldResetRpc])

const defaultMainnetRPC = useMemo(() => {
const lastRPC = localStorage.getItem(`INVARIANT_RPC_SOLANA_${NetworkType.Mainnet}`)

if (lastRPC === null) {
if (lastRPC === null || shouldResetRpc) {
localStorage.setItem(
`INVARIANT_RPC_SOLANA_${NetworkType.Mainnet}`,
RECOMMENDED_RPC_ADDRESS[NetworkType.Mainnet]
)
}

return lastRPC === null ? RPC.MAIN_HELIUS : lastRPC
}, [])
return lastRPC === null || shouldResetRpc ? RPC.MAIN_HELIUS : lastRPC
}, [shouldResetRpc])

const activeChain = CHAINS.find(chain => chain.name === Chain.Solana) ?? CHAINS[0]

Expand Down
6 changes: 3 additions & 3 deletions src/containers/NewPositionWrapper/NewPositionWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export const NewPositionWrapper: React.FC<IProps> = ({
)
}
}
}, [isWaitingForNewPool, allPools])
}, [isWaitingForNewPool, allPools.length])

useEffect(() => {
if (poolIndex !== null) {
Expand Down Expand Up @@ -409,16 +409,16 @@ export const NewPositionWrapper: React.FC<IProps> = ({

const [tokenAPriceData, setTokenAPriceData] = useState<TokenPriceData | undefined>(undefined)
const [priceALoading, setPriceALoading] = useState(false)

useEffect(() => {
if (tokenA === null || (tokenA !== null && !tokens[tokenA.toString()])) {
return
}
console.log(tokens[tokenA.toString()])

if (tokenA) {
setPriceALoading(true)
getTokenPrice(tokenA.toString(), tokens[tokenA.toString()]?.coingeckoId)
.then(data => {
console.log('data', data)
return setTokenAPriceData(data)
})
.catch(() => setTokenAPriceData(undefined))
Expand Down
2 changes: 1 addition & 1 deletion src/utils/web3/adapters/backpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class BackpackWalletAdapter implements WalletAdapter {
}
let provider: BackpackProvider
if ((window as any)?.backpack) {
provider = (window as any).backpack
provider = (window as any).backpack.solana
} else {
return
}
Expand Down

0 comments on commit 990ea4e

Please sign in to comment.