Skip to content

Commit eafaf9f

Browse files
committed
Merge remote-tracking branch 'origin/main' into syncpack-pnpm
2 parents e11895d + ff60a53 commit eafaf9f

40 files changed

+452
-68
lines changed

.github/workflows/core.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,42 @@ jobs:
6262
core/typechain/
6363
if-no-files-found: error
6464

65+
core-slither:
66+
needs: [core-build]
67+
runs-on: ubuntu-latest
68+
steps:
69+
- uses: actions/checkout@v4
70+
71+
- name: Set up pnpm
72+
uses: pnpm/action-setup@v2
73+
74+
- name: Set up Node
75+
uses: actions/setup-node@v4
76+
with:
77+
node-version-file: "core/.nvmrc"
78+
cache: "pnpm"
79+
80+
- name: Install Dependencies
81+
run: pnpm install --prefer-offline --frozen-lockfile
82+
83+
- uses: actions/setup-python@v4
84+
with:
85+
python-version: 3.11
86+
87+
- name: Install Slither
88+
env:
89+
SLITHER_VERSION: 0.9.6
90+
run: pip3 install slither-analyzer==$SLITHER_VERSION
91+
92+
- name: Download Build Artifacts
93+
uses: actions/download-artifact@v3
94+
with:
95+
name: core-build
96+
path: core/
97+
98+
- name: Run Slither
99+
run: slither --hardhat-ignore-compile .
100+
65101
core-test:
66102
needs: [core-build]
67103
runs-on: ubuntu-latest

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1+
# Node
12
node_modules/
3+
pnpm-debug.log*
4+
5+
# Editor directories and files
6+
.vscode/*
7+
!.vscode/extensions.json
8+
.idea
9+
.DS_Store

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public-hoist-pattern[]=@chakra-ui/*

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lts/iron

README.md

+22-8
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,36 @@ pre-commit run --files ./core/contracts/Acre.sol
5656
[Syncpack](https://jamiemason.github.io/syncpack/) is a tool that helps manage
5757
multiple package.json files in a monorepo.
5858

59+
60+
#### Usage
61+
62+
To list dependencies from all packages run:
63+
```sh
64+
pnpm syncpack list
65+
```
66+
67+
To update a dependency (e.g. `eslint`) in all packages run:
68+
```sh
69+
pnpm syncpack update --filter eslint
70+
```
71+
72+
### Slither
73+
74+
[Slither](https://github.com/crytic/slither) is a static analysis framework used
75+
for Solidity contracts verification.
76+
5977
#### Install
6078

61-
In the repository's root directory execute:
79+
To install Slither execute:
6280

6381
```sh
64-
yarn install
82+
pip3 install slither-analyzer
6583
```
6684

6785
#### Usage
6886

69-
To list dependencies from all packages run:
70-
```sh
71-
syncpack list
72-
```
87+
To run Slither execute:
7388

74-
To update a dependency (e.g. `eslint`) in all packages run:
7589
```sh
76-
syncpack update --filter eslint
90+
slither .
7791
```

core/.gitignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1+
# Hardhat
12
build/
23
cache/
34
export.json
45
export/
5-
node_modules/
66
typechain/
7-
yarn-debug.log*
8-
yarn-error.log*

core/slither.config.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"detectors_to_exclude": "assembly,naming-convention,timestamp,pragma,solc-version",
23
"hardhat_artifacts_directory": "build",
34
"filter_paths": "node_modules/.*"
45
}

dapp/.env

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_USE_TESTNET=true

dapp/.gitignore

+2-24
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,2 @@
1-
# Logs
2-
logs
3-
*.log
4-
npm-debug.log*
5-
yarn-debug.log*
6-
yarn-error.log*
7-
pnpm-debug.log*
8-
lerna-debug.log*
9-
10-
node_modules
11-
dist
12-
dist-ssr
13-
*.local
14-
15-
# Editor directories and files
16-
.vscode/*
17-
!.vscode/extensions.json
18-
.idea
19-
.DS_Store
20-
*.suo
21-
*.ntvs*
22-
*.njsproj
23-
*.sln
24-
*.sw?
1+
# Output
2+
dist/

dapp/README.md

+24-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
# Acre dApp
22

3-
## Installation
4-
5-
1. Install dependencies and start the app.
6-
```bash
7-
yarn install
8-
yarn start
9-
```
10-
2. Open [http://localhost:5173](http://localhost:5173) to view it in the browser.
3+
The application is compatible with Ledger Live and allows people to earn yield on their Bitcoin via yield farming on Ethereum.
4+
5+
This project was bootstrapped with [Create Vite](https://github.com/vitejs/vite/tree/main/packages/create-vite).
6+
7+
## Quickstart
8+
9+
Install dependencies and start the app.
10+
11+
```bash
12+
pnpm install
13+
pnpm run start
14+
```
15+
16+
Once the build is running, you can import the manifest on desktop:
17+
18+
1. [Install Ledger Live Desktop](https://www.ledger.com/ledger-live)
19+
2. Enable the Developer mode
20+
21+
Go to the **Settings -> About** section, and click 10 times on the Ledger Live version. A new Developer section appears in the settings menu. Turn on **Enable platform dev** tools to use the developer tools window to inspect your app.
22+
3. Add your manifest
23+
24+
Click on Browse next to **Add a local app** and select the manifest file. The app is now visible in the menu.
25+
26+
If you have any problems, take a look [here](https://developers.ledger.com/docs/non-dapp/tutorial/3-import/#desktop).

dapp/manifest-ledger-live-app.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"manifestVersion": "1",
1010
"branch": "stable",
1111
"categories": ["buy"],
12-
"currencies": ["bitcoin", "bitcoin_testnet"],
12+
"currencies": ["bitcoin", "bitcoin_testnet", "ethereum", "ethereum_goerli"],
1313
"content": {
1414
"shortDescription": {
1515
"en": "Bitcoin Liquid Staking"
@@ -18,6 +18,6 @@
1818
"en": "Bitcoin Liquid Staking"
1919
}
2020
},
21-
"permissions": [],
21+
"permissions": ["account.request"],
2222
"domains": ["http://*"]
2323
}

dapp/package.json

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
},
1717
"dependencies": {
1818
"@chakra-ui/react": "^2.8.2",
19-
"@chakra-ui/styled-system": "^2.9.2",
20-
"@chakra-ui/theme-tools": "^2.1.2",
2119
"@emotion/react": "^11.11.1",
2220
"@emotion/styled": "^11.11.0",
2321
"@ledgerhq/wallet-api-client": "^1.2.1",

dapp/src/DApp.tsx

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
import React from "react"
2-
import { ChakraProvider, Button, Box } from "@chakra-ui/react"
3-
import { useDetectThemeMode } from "./hooks"
4-
import { LedgerWalletAPIProvider } from "./providers"
2+
import { ChakraProvider, Box, Text } from "@chakra-ui/react"
3+
import { useDetectThemeMode, useWalletContext } from "./hooks"
54
import theme from "./theme"
5+
import { LedgerWalletAPIProvider, WalletContextProvider } from "./contexts"
6+
import Navbar from "./components/Navbar"
67

78
function DApp() {
89
useDetectThemeMode()
10+
11+
const { btcAccount, ethAccount } = useWalletContext()
12+
913
return (
10-
<Box p={4}>
14+
<Box>
15+
<Navbar />
1116
<h1>Ledger live - Acre dApp</h1>
12-
<Button>Test button</Button>
17+
{btcAccount && <Text>Account: {btcAccount.address}</Text>}
18+
{ethAccount && <Text>Account: {ethAccount.address}</Text>}
1319
</Box>
1420
)
1521
}
1622

1723
function DAppProviders() {
1824
return (
1925
<LedgerWalletAPIProvider>
20-
<ChakraProvider theme={theme}>
21-
<DApp />
22-
</ChakraProvider>
26+
<WalletContextProvider>
27+
<ChakraProvider theme={theme}>
28+
<DApp />
29+
</ChakraProvider>
30+
</WalletContextProvider>
2331
</LedgerWalletAPIProvider>
2432
)
2533
}

dapp/src/assets/bitcoin.svg

+16
Loading

dapp/src/assets/ethereum.svg

+16
Loading

dapp/src/assets/info.svg

+11
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import React from "react"
2+
import { Box, Button, Image, Text } from "@chakra-ui/react"
3+
import { Account } from "@ledgerhq/wallet-api-client"
4+
import BitcoinIcon from "../../assets/bitcoin.svg"
5+
import EthereumIcon from "../../assets/ethereum.svg"
6+
import InfoIcon from "../../assets/info.svg"
7+
import { BITCOIN } from "../../constants"
8+
import {
9+
useRequestBitcoinAccount,
10+
useRequestEthereumAccount,
11+
useWalletContext,
12+
} from "../../hooks"
13+
import { formatSatoshiAmount, truncateAddress } from "../../utils"
14+
15+
export type ConnectButtonsProps = {
16+
leftIcon: string
17+
rightIcon: string
18+
account: Account | undefined
19+
requestAccount: () => Promise<void>
20+
}
21+
22+
function ConnectButton({
23+
leftIcon,
24+
rightIcon,
25+
account,
26+
requestAccount,
27+
}: ConnectButtonsProps) {
28+
const styles = !account ? { color: "error", borderColor: "error" } : undefined
29+
return (
30+
<Button
31+
variant="outline"
32+
sx={styles}
33+
leftIcon={<Image src={leftIcon} />}
34+
// TODO: Add a tooltip here
35+
rightIcon={!account ? <Image src={rightIcon} /> : undefined}
36+
onClick={requestAccount}
37+
>
38+
{account ? truncateAddress(account.address) : "Not connected"}
39+
</Button>
40+
)
41+
}
42+
43+
export default function ConnectWallet() {
44+
const { requestAccount: requestBitcoinAccount } = useRequestBitcoinAccount()
45+
const { requestAccount: requestEthereumAccount } = useRequestEthereumAccount()
46+
const { btcAccount, ethAccount } = useWalletContext()
47+
48+
return (
49+
<Box display="flex" alignItems="center" gap="4">
50+
<Box display="flex" gap="2">
51+
<Text>Balance</Text>
52+
<Text as="b">
53+
{!btcAccount || btcAccount?.balance.isZero()
54+
? "0.00"
55+
: formatSatoshiAmount(btcAccount.balance.toString())}
56+
</Text>
57+
<Text>{BITCOIN.symbol}</Text>
58+
</Box>
59+
<ConnectButton
60+
leftIcon={BitcoinIcon}
61+
rightIcon={InfoIcon}
62+
account={btcAccount}
63+
requestAccount={async () => {
64+
await requestBitcoinAccount()
65+
}}
66+
/>
67+
<ConnectButton
68+
leftIcon={EthereumIcon}
69+
rightIcon={InfoIcon}
70+
account={ethAccount}
71+
requestAccount={async () => {
72+
await requestEthereumAccount()
73+
}}
74+
/>
75+
</Box>
76+
)
77+
}

dapp/src/components/Navbar/index.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from "react"
2+
import { Box } from "@chakra-ui/react"
3+
import ConnectWallet from "./ConnectWallet"
4+
5+
export default function Navbar() {
6+
return (
7+
<Box p={4} display="flex" justifyContent="end">
8+
<ConnectWallet />
9+
</Box>
10+
)
11+
}

0 commit comments

Comments
 (0)