diff --git a/dapp/.eslintrc b/dapp/.eslintrc index 15eda3013..198832b1e 100644 --- a/dapp/.eslintrc +++ b/dapp/.eslintrc @@ -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" + } } diff --git a/dapp/index.html b/dapp/index.html index 9bdab828c..606a95c29 100644 --- a/dapp/index.html +++ b/dapp/index.html @@ -2,10 +2,9 @@ - - + - Acre + ACRE
diff --git a/dapp/manifest-ledger-live-app.json b/dapp/manifest-ledger-live-app.json new file mode 100644 index 000000000..a6ed3d306 --- /dev/null +++ b/dapp/manifest-ledger-live-app.json @@ -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://*" + ] +} diff --git a/dapp/package.json b/dapp/package.json index c56624990..da7f674ec 100644 --- a/dapp/package.json +++ b/dapp/package.json @@ -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" }, diff --git a/dapp/public/acre.svg b/dapp/public/acre.svg new file mode 100644 index 000000000..59e8dbf1c --- /dev/null +++ b/dapp/public/acre.svg @@ -0,0 +1,4 @@ + + + + diff --git a/dapp/public/vite.svg b/dapp/public/vite.svg deleted file mode 100644 index e7b8dfb1b..000000000 --- a/dapp/public/vite.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/dapp/src/App.tsx b/dapp/src/App.tsx deleted file mode 100644 index 1d6ad014f..000000000 --- a/dapp/src/App.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import React from "react" - -function App() { - return

Acre dApp

-} - -export default App diff --git a/dapp/src/DApp.tsx b/dapp/src/DApp.tsx new file mode 100644 index 000000000..8de8b9693 --- /dev/null +++ b/dapp/src/DApp.tsx @@ -0,0 +1,16 @@ +import React from "react" +import { LedgerWalletAPIProvider } from "./providers" + +function DApp() { + return

Ledger live - Acre dApp

+} + +function DAppWrapper() { + return ( + + + + ) +} + +export default DAppWrapper diff --git a/dapp/src/main.tsx b/dapp/src/main.tsx index 50f340bcd..e16b6215c 100644 --- a/dapp/src/main.tsx +++ b/dapp/src/main.tsx @@ -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( - + , ) diff --git a/dapp/src/providers/LedgerWalletAPIProvider.tsx b/dapp/src/providers/LedgerWalletAPIProvider.tsx new file mode 100644 index 000000000..3581cad6f --- /dev/null +++ b/dapp/src/providers/LedgerWalletAPIProvider.tsx @@ -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 {children} +} diff --git a/dapp/src/providers/index.ts b/dapp/src/providers/index.ts new file mode 100644 index 000000000..c8f56e2c2 --- /dev/null +++ b/dapp/src/providers/index.ts @@ -0,0 +1 @@ +export { default as LedgerWalletAPIProvider } from "./LedgerWalletAPIProvider" diff --git a/dapp/vite.config.ts b/dapp/vite.config.ts index c45a49260..ea1889ae7 100644 --- a/dapp/vite.config.ts +++ b/dapp/vite.config.ts @@ -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" diff --git a/dapp/yarn.lock b/dapp/yarn.lock index a49ca4bd8..cd7e8541a 100644 --- a/dapp/yarn.lock +++ b/dapp/yarn.lock @@ -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/wallet-api-client@1.2.1", "@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/wallet-api-core@1.3.1": + 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/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -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" @@ -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" @@ -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" @@ -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== @@ -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== @@ -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" @@ -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==