Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic configuration for ledger live app #19

Merged
merged 11 commits into from
Nov 16, 2023
6 changes: 5 additions & 1 deletion dapp/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"root": true,
"extends": ["@thesis-co"]
"extends": ["@thesis-co"],
"rules": {
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
"import/prefer-default-export": "off"
}
}
5 changes: 2 additions & 3 deletions dapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<!-- TODO: Set the correct logo and title -->
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="icon" type="image/svg+xml" href="/acre.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Acre</title>
<title>ACRE</title>
</head>
<body>
<div id="root"></div>
Expand Down
30 changes: 30 additions & 0 deletions dapp/manifest-ledger-live-app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"id": "acre",
"name": "ACRE",
"url": "http://localhost:5173/",
"homepageUrl": "http://localhost:5173/",
"icon": "http://localhost:5173/acre.svg",
"platform": "all",
"apiVersion": "2.0.0",
"manifestVersion": "1",
"branch": "stable",
"categories": [
"buy"
],
"currencies": [
"bitcoin",
"bitcoin_testnet"
],
"content": {
"shortDescription": {
"en": "Bitcoin Liquid Staking"
},
"description": {
"en": "Bitcoin Liquid Staking"
}
},
"permissions": [],
"domains": [
"http://*"
]
}
2 changes: 2 additions & 0 deletions dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"lint:config:fix": "prettier -w '**/*.@(json|yaml|toml)'"
},
"dependencies": {
"@ledgerhq/wallet-api-client": "^1.2.1",
"@ledgerhq/wallet-api-client-react": "^1.1.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
4 changes: 4 additions & 0 deletions dapp/public/acre.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion dapp/public/vite.svg

This file was deleted.

7 changes: 0 additions & 7 deletions dapp/src/App.tsx

This file was deleted.

16 changes: 16 additions & 0 deletions dapp/src/DApp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react"
import { LedgerWalletAPIProvider } from "./providers"

function DApp() {
return <h1>Ledger live - Acre dApp</h1>
}

function DAppWrapper() {
return (
<LedgerWalletAPIProvider>
<DApp />
</LedgerWalletAPIProvider>
)
}

export default DAppWrapper
4 changes: 2 additions & 2 deletions dapp/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react"
import ReactDOM from "react-dom/client"
import App from "./App"
import DAppWrapper from "./DApp"

ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<App />
<DAppWrapper />
</React.StrictMode>,
)
27 changes: 27 additions & 0 deletions dapp/src/providers/LedgerWalletAPIProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from "react"
import { Transport, WindowMessageTransport } from "@ledgerhq/wallet-api-client"
import { WalletAPIProvider } from "@ledgerhq/wallet-api-client-react"

function getWalletAPITransport(): Transport {
if (typeof window === "undefined") {
return {
onMessage: undefined,
send: () => {},
}
}

const transport = new WindowMessageTransport()
transport.connect()
return transport
}

type LedgerWalletAPIProviderProps = {
children: React.ReactElement
}

export default function LedgerWalletAPIProvider({
children,
}: LedgerWalletAPIProviderProps): JSX.Element {
const transport = getWalletAPITransport()
return <WalletAPIProvider transport={transport}>{children}</WalletAPIProvider>
}
1 change: 1 addition & 0 deletions dapp/src/providers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as LedgerWalletAPIProvider } from "./LedgerWalletAPIProvider"
2 changes: 0 additions & 2 deletions dapp/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Unfortunately, the Vite React package structure does not play nice with no-extraneous-dependencies.
/* eslint-disable import/no-extraneous-dependencies */
import { defineConfig } from "vite"
import react from "@vitejs/plugin-react"

Expand Down
87 changes: 85 additions & 2 deletions dapp/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,62 @@
"@jridgewell/resolve-uri" "^3.1.0"
"@jridgewell/sourcemap-codec" "^1.4.14"

"@ledgerhq/devices@^8.0.8":
version "8.0.8"
resolved "https://registry.yarnpkg.com/@ledgerhq/devices/-/devices-8.0.8.tgz#cd233eb54a044913160c9183be9fb22adae4e071"
integrity sha512-0j7E8DY2jeSSATc8IJk+tXDZ9u+Z7tXxB8I4TzXrfV/8A5exMh/K1IwX6Jt1zlw1wre4CT9MV4mzUs3M/TE7lg==
dependencies:
"@ledgerhq/errors" "^6.15.0"
"@ledgerhq/logs" "^6.11.0"
rxjs "^7.8.1"
semver "^7.3.5"

"@ledgerhq/errors@^6.14.0", "@ledgerhq/errors@^6.15.0":
version "6.15.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/errors/-/errors-6.15.0.tgz#45cda73915f695cc072cb8a99650830bc5dc6668"
integrity sha512-6xaw5/mgoht62TnL3rXsaQYEFwpnXyNDk1AOSJksIjFHx9bHUnkyVmrnGQDj0JLzi+E7bHEgTrpCs8wpeDh9jA==

"@ledgerhq/hw-transport@^6.28.8":
version "6.29.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-6.29.0.tgz#2b85f39d90b093930f0c7bfc513b29eb47ba97fa"
integrity sha512-WQfzxt3EnnbOmzZVYiCgSmNsqafBOFQn40awvUPY2IZviJRs23/1ANPHAo76bzPV88+Qk0+1wZlcnIanGN6fFA==
dependencies:
"@ledgerhq/devices" "^8.0.8"
"@ledgerhq/errors" "^6.15.0"
"@ledgerhq/logs" "^6.11.0"
events "^3.3.0"

"@ledgerhq/logs@^6.11.0":
version "6.11.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/logs/-/logs-6.11.0.tgz#0d28e7edcf71548506f4304686cba480ba91bbcf"
integrity sha512-HHK9y4GGe4X7CXbRUCh7z8Mp+WggpJn1dmUjmuk1rNugESF6o8nAOnXA+BxwtRRNV3CgNJR3Wxdos4J9qV0Zsg==

"@ledgerhq/wallet-api-client-react@^1.1.2":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@ledgerhq/wallet-api-client-react/-/wallet-api-client-react-1.1.2.tgz#da9ca900aefd671faecf121982de30b15c5c6271"
integrity sha512-ZBnp8HBHwtuDE/jqYuJmqx20Dx9dqqcZaOW4YuaY32GRwqEJJslTtcypCCgq2kArl0Y0q0irOYEd/0I7ULxdLQ==
dependencies:
"@ledgerhq/wallet-api-client" "1.2.1"

"@ledgerhq/[email protected]", "@ledgerhq/wallet-api-client@^1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@ledgerhq/wallet-api-client/-/wallet-api-client-1.2.1.tgz#b47fe5b4f431282f50ddb64c8abb911545593eba"
integrity sha512-uTBTZCpbLTM5y5Cd7ioQB0lcq0b3cbrU2bGzCiKuY1IEd0NUyFhr2dKliRrcLoMPDRtQRmRnSxeX0BFKinoo8Q==
dependencies:
"@ledgerhq/hw-transport" "^6.28.8"
"@ledgerhq/wallet-api-core" "1.3.1"
bignumber.js "^9.1.2"

"@ledgerhq/[email protected]":
version "1.3.1"
resolved "https://registry.yarnpkg.com/@ledgerhq/wallet-api-core/-/wallet-api-core-1.3.1.tgz#092d027a6d9ce7139a2d4c157480e2feb7c88489"
integrity sha512-yOeb1tfdwF6NdxVEIVr8SVz5iOyh6asWa0bbuCyMpiLrfuVS/Wkr6OeDMBYSxWxXxRFmQDJ9XQxdtSS+MGNk1Q==
dependencies:
"@ledgerhq/errors" "^6.14.0"
bignumber.js "^9.1.2"
uuid "^9.0.0"
zod "^3.22.2"

"@nodelib/[email protected]":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
Expand Down Expand Up @@ -813,6 +869,11 @@ big-integer@^1.6.44:
resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.51.tgz#0df92a5d9880560d3ff2d5fd20245c889d130686"
integrity sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==

bignumber.js@^9.1.2:
version "9.1.2"
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.2.tgz#b7c4242259c008903b13707983b5f4bbd31eda0c"
integrity sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==

bplist-parser@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/bplist-parser/-/bplist-parser-0.2.0.tgz#43a9d183e5bf9d545200ceac3e712f79ebbe8d0e"
Expand Down Expand Up @@ -1397,6 +1458,11 @@ esutils@^2.0.2:
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64"
integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==

events@^3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400"
integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==

execa@^5.0.0:
version "5.1.1"
resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd"
Expand Down Expand Up @@ -2469,6 +2535,13 @@ run-parallel@^1.1.9:
dependencies:
queue-microtask "^1.2.2"

rxjs@^7.8.1:
version "7.8.1"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.1.tgz#6f6f3d99ea8044291efd92e7c7fcf562c4057543"
integrity sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==
dependencies:
tslib "^2.1.0"

safe-array-concat@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/safe-array-concat/-/safe-array-concat-1.0.1.tgz#91686a63ce3adbea14d61b14c99572a8ff84754c"
Expand Down Expand Up @@ -2500,7 +2573,7 @@ semver@^6.3.0, semver@^6.3.1:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==

semver@^7.5.4:
semver@^7.3.5, semver@^7.5.4:
version "7.5.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
Expand Down Expand Up @@ -2695,7 +2768,7 @@ tsconfig-paths@^3.14.2:
minimist "^1.2.6"
strip-bom "^3.0.0"

tslib@^2.5.0, tslib@^2.6.0:
tslib@^2.1.0, tslib@^2.5.0, tslib@^2.6.0:
version "2.6.2"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae"
integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==
Expand Down Expand Up @@ -2786,6 +2859,11 @@ uri-js@^4.2.2:
dependencies:
punycode "^2.1.0"

uuid@^9.0.0:
version "9.0.1"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30"
integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==

vite@^4.4.5:
version "4.5.0"
resolved "https://registry.yarnpkg.com/vite/-/vite-4.5.0.tgz#ec406295b4167ac3bc23e26f9c8ff559287cff26"
Expand Down Expand Up @@ -2873,3 +2951,8 @@ yocto-queue@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==

zod@^3.22.2:
version "3.22.4"
resolved "https://registry.yarnpkg.com/zod/-/zod-3.22.4.tgz#f31c3a9386f61b1f228af56faa9255e845cf3fff"
integrity sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==
Loading