Skip to content

Commit

Permalink
Merge branch 'main' into awaiting-modals
Browse files Browse the repository at this point in the history
  • Loading branch information
r-czajkowski authored Nov 7, 2024
2 parents 1440e07 + b3310fa commit d20300f
Show file tree
Hide file tree
Showing 107 changed files with 2,574 additions and 1,367 deletions.
2 changes: 1 addition & 1 deletion dapp/.env
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ VITE_FEATURE_FLAG_OKX_WALLET_ENABLED="false"
VITE_FEATURE_FLAG_XVERSE_WALLET_ENABLED="false"
VITE_FEATURE_FLAG_BEEHIVE_COMPONENT_ENABLED="false"
VITE_FEATURE_FLAG_ACRE_POINTS_ENABLED="true"
VITE_FEATURE_FLAG_TVL_ENABLED="false"
VITE_FEATURE_FLAG_TVL_ENABLED="true"
VITE_FEATURE_GATING_DAPP_ENABLED="true"

5 changes: 5 additions & 0 deletions dapp/config/development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "acre-dev",
"name": "Acre [dev]",
"url": "http://localhost:5173/"
}
5 changes: 5 additions & 0 deletions dapp/config/mainnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "acre",
"name": "Acre",
"url": "https://bitcoin.acre.fi/"
}
5 changes: 5 additions & 0 deletions dapp/config/testnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "acre-testnet",
"name": "Acre [testnet]",
"url": "https://bitcoin.test.acre.fi/"
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"id": "acre-dev",
"name": "Acre [dev]",
"url": "http://localhost:5173/",
"homepageUrl": "http://localhost:5173/",
"url": "http://localhost:5173/?embed=ledger-live",
"homepageUrl": "https:/acre.fi/",
"icon": "http://localhost:5173/acre.svg",
"platforms": "desktop",
"apiVersion": "^2.0.0",
Expand All @@ -21,10 +21,10 @@
"permissions": [
"account.request",
"account.list",
"message.sign",
"transaction.sign",
"transaction.signAndBroadcast",
"bitcoin.getXPub"
"bitcoin.getAddress",
"bitcoin.getPublicKey",
"custom.acre.messageSign",
"custom.acre.transactionSignAndBroadcast"
],
"domains": ["http://*"],
"type": "walletApp"
Expand Down
31 changes: 31 additions & 0 deletions dapp/manifests/ledger-live/ledger-live-manifest-mainnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"id": "acre",
"name": "Acre",
"url": "https://bitcoin.acre.fi/?embed=ledger-live",
"homepageUrl": "https:/acre.fi/",
"icon": "https://bitcoin.acre.fi/acre.svg",
"platforms": "desktop",
"apiVersion": "^2.0.0",
"manifestVersion": "2",
"branch": "stable",
"categories": ["staking"],
"currencies": ["bitcoin", "bitcoin_testnet"],
"content": {
"shortDescription": {
"en": "Bitcoin Liquid Staking"
},
"description": {
"en": "Bitcoin Liquid Staking"
}
},
"permissions": [
"account.request",
"account.list",
"bitcoin.getAddress",
"bitcoin.getPublicKey",
"custom.acre.messageSign",
"custom.acre.transactionSignAndBroadcast"
],
"domains": ["http://*"],
"type": "walletApp"
}
31 changes: 31 additions & 0 deletions dapp/manifests/ledger-live/ledger-live-manifest-testnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"id": "acre-testnet",
"name": "Acre [testnet]",
"url": "https://bitcoin.test.acre.fi/?embed=ledger-live",
"homepageUrl": "https:/acre.fi/",
"icon": "https://bitcoin.test.acre.fi/acre.svg",
"platforms": "desktop",
"apiVersion": "^2.0.0",
"manifestVersion": "2",
"branch": "stable",
"categories": ["staking"],
"currencies": ["bitcoin", "bitcoin_testnet"],
"content": {
"shortDescription": {
"en": "Bitcoin Liquid Staking"
},
"description": {
"en": "Bitcoin Liquid Staking"
}
},
"permissions": [
"account.request",
"account.list",
"bitcoin.getAddress",
"bitcoin.getPublicKey",
"custom.acre.messageSign",
"custom.acre.transactionSignAndBroadcast"
],
"domains": ["http://*"],
"type": "walletApp"
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"id": "acre-test",
"name": "Acre [test]",
"url": "https://dapp.test.acre.fi/",
"id": "{{id}}",
"name": "{{name}}",
"url": "{{{url}}}?embed=ledger-live",
"homepageUrl": "https:/acre.fi/",
"icon": "https://dapp.test.acre.fi/acre.svg",
"icon": "{{{url}}}acre.svg",
"platforms": "desktop",
"apiVersion": "^2.0.0",
"manifestVersion": "2",
Expand All @@ -21,10 +21,10 @@
"permissions": [
"account.request",
"account.list",
"message.sign",
"transaction.sign",
"transaction.signAndBroadcast",
"bitcoin.getXPub"
"bitcoin.getAddress",
"bitcoin.getPublicKey",
"custom.acre.messageSign",
"custom.acre.transactionSignAndBroadcast"
],
"domains": ["http://*"],
"type": "walletApp"
Expand Down
9 changes: 7 additions & 2 deletions dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
"lint:js:fix": "eslint . --fix",
"lint:config": "prettier -c '**/*.@(json|yaml|toml)'",
"lint:config:fix": "prettier -w '**/*.@(json|yaml|toml)'",
"test": "vitest"
"test": "vitest --reporter=verbose",
"generate:manifests": "for env in development testnet mainnet; do mustache config/$env.json ./manifests/ledger-live/ledger-manifest-template.json > ./manifests/ledger-live/ledger-live-manifest-$env.json; done"
},
"dependencies": {
"@acre-btc/sdk": "workspace:*",
"@chakra-ui/react": "^2.8.2",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@orangekit/react": "1.0.0-beta.32",
"@ledgerhq/wallet-api-acre-module": "0.1.0",
"@ledgerhq/wallet-api-client": "1.6.0",
"@orangekit/react": "1.0.0-beta.33",
"@orangekit/sign-in-with-wallet": "1.0.0-beta.6",
"@reduxjs/toolkit": "^2.2.0",
"@rehooks/local-storage": "^2.4.5",
Expand All @@ -31,9 +34,11 @@
"@tanstack/react-query": "^5.40.1",
"@tanstack/react-query-devtools": "^5.49.2",
"axios": "^1.6.7",
"bignumber.js": "^9.1.2",
"ethers": "^6.10.0",
"formik": "^2.4.5",
"framer-motion": "^10.16.5",
"mustache": "^4.2.0",
"react": "^18.2.0",
"react-confetti-explosion": "^2.1.2",
"react-dom": "^18.2.0",
Expand Down
64 changes: 43 additions & 21 deletions dapp/src/DApp.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from "react"
import { ChakraProvider } from "@chakra-ui/react"
import React, { useEffect, useState } from "react"
import { Center, Fade, Icon } from "@chakra-ui/react"
import { Provider as ReduxProvider } from "react-redux"
import { RouterProvider } from "react-router-dom"
import { WagmiProvider } from "wagmi"
import { Config, WagmiProvider } from "wagmi"
import { QueryClientProvider } from "@tanstack/react-query"
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"
import { AcreSdkProvider } from "./acre-react/contexts"
Expand All @@ -15,9 +15,10 @@ import {
import { useInitApp } from "./hooks"
import { router } from "./router"
import { store } from "./store"
import theme from "./theme"
import wagmiConfig from "./wagmiConfig"
import getWagmiConfig from "./wagmiConfig"
import queryClient from "./queryClient"
import { delay, logPromiseFailure } from "./utils"
import { AcreLogo } from "./assets/icons"

function DApp() {
useInitApp()
Expand All @@ -32,24 +33,45 @@ function DApp() {
}

function DAppProviders() {
const [config, setConfig] = useState<Config | undefined>()

useEffect(() => {
const setWagmiConfig = async () => {
await delay(500)
const wagmiConfig = await getWagmiConfig()
setConfig(wagmiConfig)
}

logPromiseFailure(setWagmiConfig())
}, [])

if (!config)
return (
<Fade in={!config}>
<Center h="100vh" w="100vw">
<Icon as={AcreLogo} alt="Acre logo" w={200} h={300} />
</Center>
</Fade>
)

return (
<WagmiProvider config={wagmiConfig}>
<QueryClientProvider client={queryClient}>
<AcreSdkProvider>
<DocsDrawerContextProvider>
<SidebarContextProvider>
<WalletConnectionErrorContextProvider>
<ReduxProvider store={store}>
<ChakraProvider theme={theme}>
<Fade in={config !== undefined}>
<WagmiProvider config={config}>
<QueryClientProvider client={queryClient}>
<AcreSdkProvider>
<DocsDrawerContextProvider>
<SidebarContextProvider>
<WalletConnectionErrorContextProvider>
<ReduxProvider store={store}>
<DApp />
</ChakraProvider>
</ReduxProvider>
</WalletConnectionErrorContextProvider>
</SidebarContextProvider>
</DocsDrawerContextProvider>
</AcreSdkProvider>
</QueryClientProvider>
</WagmiProvider>
</ReduxProvider>
</WalletConnectionErrorContextProvider>
</SidebarContextProvider>
</DocsDrawerContextProvider>
</AcreSdkProvider>
</QueryClientProvider>
</WagmiProvider>
</Fade>
)
}

Expand Down
8 changes: 4 additions & 4 deletions dapp/src/acre-react/contexts/AcreSdkContext.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useCallback, useMemo, useState } from "react"
import { Acre } from "@acre-btc/sdk"
import { BitcoinProvider } from "@acre-btc/sdk/dist/src/lib/bitcoin/providers"
import { Acre, AcreBitcoinProvider } from "@acre-btc/sdk"
import { BITCOIN_NETWORK, env } from "#/constants"

const { TBTC_API_ENDPOINT, SUBGRAPH_API_KEY } = env
Expand All @@ -9,7 +8,7 @@ const GELATO_API_KEY = env.GELATO_RELAY_API_KEY

type AcreSdkContextValue = {
acre?: Acre
init: (bitcoinProvider?: BitcoinProvider) => Promise<void>
init: (bitcoinProvider?: AcreBitcoinProvider) => Promise<void>
isInitialized: boolean
isConnected: boolean
}
Expand All @@ -27,7 +26,7 @@ export function AcreSdkProvider({ children }: { children: React.ReactNode }) {
const [isConnected, setIsConnected] = useState(false)

const init = useCallback<AcreSdkContextValue["init"]>(
async (bitcoinProvider?: BitcoinProvider) => {
async (bitcoinProvider?: AcreBitcoinProvider) => {
let sdk = await Acre.initialize(
BITCOIN_NETWORK,
TBTC_API_ENDPOINT,
Expand All @@ -37,6 +36,7 @@ export function AcreSdkProvider({ children }: { children: React.ReactNode }) {
)

if (bitcoinProvider) {
setIsConnected(false)
sdk = await sdk.connect(bitcoinProvider)
setIsConnected(true)
} else {
Expand Down
13 changes: 13 additions & 0 deletions dapp/src/assets/icons/BoltFilled.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react"
import { createIcon } from "@chakra-ui/react"

export default createIcon({
displayName: "BoltFilled",
viewBox: "0 0 24 24",
path: [
<path
fill="currentColor"
d="M13 2l.018 .001l.016 .001l.083 .005l.011 .002h.011l.038 .009l.052 .008l.016 .006l.011 .001l.029 .011l.052 .014l.019 .009l.015 .004l.028 .014l.04 .017l.021 .012l.022 .01l.023 .015l.031 .017l.034 .024l.018 .011l.013 .012l.024 .017l.038 .034l.022 .017l.008 .01l.014 .012l.036 .041l.026 .027l.006 .009c.12 .147 .196 .322 .218 .513l.001 .012l.002 .041l.004 .064v6h5a1 1 0 0 1 .868 1.497l-.06 .091l-8 11c-.568 .783 -1.808 .38 -1.808 -.588v-6h-5a1 1 0 0 1 -.868 -1.497l.06 -.091l8 -11l.01 -.013l.018 -.024l.033 -.038l.018 -.022l.009 -.008l.013 -.014l.04 -.036l.028 -.026l.008 -.006a1 1 0 0 1 .402 -.199l.011 -.001l.027 -.005l.074 -.013l.011 -.001l.041 -.002z"
/>,
],
})
1 change: 1 addition & 0 deletions dapp/src/assets/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export * from "./MezoSignIcon"
export * from "./AcreSignIcon"
export * from "./BitcoinsStackErrorIcon"
export { default as MatsIcon } from "./MatsIcon"
export { default as BoltFilled } from "./BoltFilled"
Loading

0 comments on commit d20300f

Please sign in to comment.