[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: esbuild configuration
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: esbuild configuration |
Date: |
Thu, 24 Mar 2022 20:02:52 +0100 |
This is an automated email from the git hooks/post-receive script.
sebasjm pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new f45ef767 esbuild configuration
f45ef767 is described below
commit f45ef767016a425d04cce7755b27aceff292603c
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Thu Mar 24 16:02:38 2022 -0300
esbuild configuration
---
packages/taler-util/package.json | 3 -
packages/taler-util/src/bitcoin.ts | 8 +--
packages/taler-util/src/payto.ts | 33 +++++++++-
.../babel.config-linaria.json | 11 ++--
.../build-fast-with-linaria.mjs | 77 ++++++++++++++++++++++
.../clean_and_build_fast.sh | 11 ----
packages/taler-wallet-webextension/encode.mjs | 3 -
packages/taler-wallet-webextension/esbuild.sh | 17 +++++
packages/taler-wallet-webextension/pack.sh | 8 +--
packages/taler-wallet-webextension/package.json | 3 +-
.../run-test-in-browser.html | 9 +--
.../src/NavigationBar.tsx | 15 ++++-
.../src/components/Banner.stories.tsx | 6 +-
.../src/components/ErrorMessage.tsx | 7 +-
.../src/components/ErrorTalerOperation.tsx | 6 +-
.../src/components/LogoHeader.tsx | 13 ++--
.../src/components/MultiActionButton.tsx | 7 +-
.../src/components/styled/index.tsx | 25 +++----
.../src/hooks/useTalerActionURL.test.ts | 18 ++---
.../src/mui/Button.stories.tsx | 4 +-
.../mui/index.stories.tsx} | 19 +++---
.../src/popup/BalancePage.tsx | 2 +-
.../taler-wallet-webextension/src/stories.test.ts | 3 +-
.../{static/img => src/svg}/chevron-down.svg | 0
.../{static/img => src/svg}/delete_24px.svg | 0
.../src/svg/logo-2021.svg | 9 +++
.../{static/img => src/svg}/ri-bank-line.svg | 0
.../img => src/svg}/ri-file-unknown-line.svg | 0
.../{static/img => src/svg}/ri-hand-heart-line.svg | 0
.../{static/img => src/svg}/ri-refresh-line.svg | 0
.../{static/img => src/svg}/ri-refund-2-line.svg | 0
.../img => src/svg}/ri-shopping-cart-line.svg | 0
.../{static/img => src/svg}/send_24px.svg | 0
.../img => src/svg}/settings_black_24dp.svg | 0
.../{static/img => src/svg}/spinner-bars.svg | 0
.../{static/img => src/svg}/wifi.svg | 0
.../taler-wallet-webextension/src/test-utils.ts | 17 +++--
.../src/wallet/ManualWithdrawPage.tsx | 14 +++-
.../src/wallet/ReserveCreated.tsx | 18 +++--
.../static/img/logo-2021.svg | 1 -
pnpm-lock.yaml | 9 +++
41 files changed, 261 insertions(+), 115 deletions(-)
diff --git a/packages/taler-util/package.json b/packages/taler-util/package.json
index 6a46de89..42ca8cb2 100644
--- a/packages/taler-util/package.json
+++ b/packages/taler-util/package.json
@@ -2,9 +2,6 @@
"name": "@gnu-taler/taler-util",
"version": "0.9.0-dev.1",
"description": "Generic helper functionality for GNU Taler",
- "exports": {
- ".": "./lib/index.node.js"
- },
"module": "./lib/index.node.js",
"main": "./lib/index.node.js",
"browser": {
diff --git a/packages/taler-util/src/bitcoin.ts
b/packages/taler-util/src/bitcoin.ts
index f4d3cfeb..85a176dc 100644
--- a/packages/taler-util/src/bitcoin.ts
+++ b/packages/taler-util/src/bitcoin.ts
@@ -24,8 +24,8 @@ import * as segwit from "./segwit_addr"
*/
export interface SegwitAddrs {
- segwitAddr1: string,
- segwitAddr2: string,
+ addr1: string,
+ addr2: string,
}
function buf2hex(buffer: Uint8Array) { // buffer is an ArrayBuffer
@@ -57,8 +57,8 @@ export function generateFakeSegwitAddress(reservePub: string,
addr: string): Seg
if (prefix === undefined) throw new Error('unknown bitcoin net')
return {
- segwitAddr1: segwit.default.encode(prefix, 0, first_part),
- segwitAddr2: segwit.default.encode(prefix, 0, second_part),
+ addr1: segwit.default.encode(prefix, 0, first_part),
+ addr2: segwit.default.encode(prefix, 0, second_part),
}
}
diff --git a/packages/taler-util/src/payto.ts b/packages/taler-util/src/payto.ts
index fc338055..a7736ea7 100644
--- a/packages/taler-util/src/payto.ts
+++ b/packages/taler-util/src/payto.ts
@@ -14,9 +14,10 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
+import { generateFakeSegwitAddress } from "./index.js";
import { URLSearchParams } from "./url.js";
-export type PaytoUri = PaytoUriUnknown | PaytoUriIBAN | PaytoUriTalerBank;
+export type PaytoUri = PaytoUriUnknown | PaytoUriIBAN | PaytoUriTalerBank |
PaytoUriBitcoin;
interface PaytoUriGeneric {
targetType: string;
@@ -41,6 +42,13 @@ interface PaytoUriTalerBank extends PaytoUriGeneric {
account: string;
}
+interface PaytoUriBitcoin extends PaytoUriGeneric {
+ isKnown: true;
+ targetType: 'bitcoin',
+ generateSegwitAddress: (r: string) => { addr1: string, addr2: string };
+ addr1?: string, addr2?: string,
+}
+
const paytoPfx = "payto://";
/**
@@ -104,6 +112,29 @@ export function parsePaytoUri(s: string): PaytoUri |
undefined {
iban: targetPath
};
+ }
+ if (targetType === 'bitcoin') {
+
+ const result: PaytoUriBitcoin = {
+ isKnown: true,
+ targetPath,
+ targetType,
+ params,
+ generateSegwitAddress: (): any => null
+ }
+
+ //generate segwit address just once, save addr in payto object
+ //and use it as cache
+ function generateSegwitAddress(reserve: string) {
+ if (result.addr1 && result.addr2) return { addr1: result.addr1, addr2:
result.addr2 };
+ const { addr1, addr2 } = generateFakeSegwitAddress(reserve, targetPath)
+ result.addr1 = addr1
+ result.addr2 = addr2
+ return { addr1, addr2 }
+ }
+ result.generateSegwitAddress = generateSegwitAddress
+ return result;
+
}
return {
targetPath,
diff --git a/packages/taler-wallet-webextension/babel.config-linaria.json
b/packages/taler-wallet-webextension/babel.config-linaria.json
index abf87db8..70d5a3c7 100644
--- a/packages/taler-wallet-webextension/babel.config-linaria.json
+++ b/packages/taler-wallet-webextension/babel.config-linaria.json
@@ -13,8 +13,7 @@
You should have received a copy of the GNU General Public License along with
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-
- /**
+/**
*
* @author Sebastian Javier Marchano (sebasjm)
*/
@@ -24,7 +23,7 @@
* This file should be used from @linaria/rollup plugin only
*/
{
- "presets": [
- "preact-cli/babel",
- ]
-}
+ "presets": [
+ "preact-cli/babel",
+ ]
+}
\ No newline at end of file
diff --git a/packages/taler-wallet-webextension/build-fast-with-linaria.mjs
b/packages/taler-wallet-webextension/build-fast-with-linaria.mjs
new file mode 100644
index 00000000..890217ae
--- /dev/null
+++ b/packages/taler-wallet-webextension/build-fast-with-linaria.mjs
@@ -0,0 +1,77 @@
+
+import linaria from '@linaria/esbuild'
+import esbuild from 'esbuild'
+import path from "path"
+import fs from "fs"
+
+function getFilesInDirectory(startPath, regex) {
+ if (!fs.existsSync(startPath)) {
+ return;
+ }
+ const files = fs.readdirSync(startPath);
+ const result = files.flatMap(file => {
+ const filename = path.join(startPath, file);
+
+ const stat = fs.lstatSync(filename);
+ if (stat.isDirectory()) {
+ return getFilesInDirectory(filename, regex);
+ }
+ else if (regex.test(filename)) {
+ return filename
+ }
+ }).filter(x => !!x)
+
+ return result
+}
+
+const allTestFiles = getFilesInDirectory(path.join(process.cwd(), 'src'),
/.test.ts$/)
+
+const preact = path.join(process.cwd(), "node_modules", "preact", "compat",
"dist", "compat.module.js");
+const preactCompatPlugin = {
+ name: "preact-compat",
+ setup(build) {
+ build.onResolve({ filter: /^(react-dom|react)$/ }, args => ({ path: preact
}));
+ }
+}
+
+const entryPoints = [
+ 'src/popupEntryPoint.tsx', 'src/walletEntryPoint.tsx', 'src/background.ts',
'src/browserWorkerEntry.ts'
+]
+
+await esbuild
+ .build({
+ entryPoints: [...entryPoints, ...allTestFiles],
+ bundle: true,
+ outdir: 'dist',
+ minify: false,
+ loader: {
+ '.svg': 'text',
+ '.png': 'file',
+ },
+ target: [
+ 'es6'
+ ],
+ format: 'iife',
+ platform: 'browser',
+ sourcemap: 'external',
+ jsxFactory: 'h',
+ jsxFragment: 'Fragment',
+ // define: {
+ // 'process.env.NODE_ENV': '"development"',
+ // },
+ plugins: [
+ preactCompatPlugin,
+ linaria.default({
+ babelOptions: {
+ babelrc: false,
+ configFile: './babel.config-linaria.json',
+ },
+ sourceMap: true,
+ }),
+ ],
+ })
+ .catch((e) => {
+ console.log(e)
+ process.exit(1)
+ });
+
diff --git a/packages/taler-wallet-webextension/clean_and_build_fast.sh
b/packages/taler-wallet-webextension/clean_and_build_fast.sh
deleted file mode 100755
index 61015d0c..00000000
--- a/packages/taler-wallet-webextension/clean_and_build_fast.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/env bash
-# This file is in the public domain.
-set -e
-
-mv node_modules{,_saved}
-rm -rf dist lib tsconfig.tsbuildinfo
-(cd ../.. && rm -rf build/web && ./contrib/build-fast-web.sh)
-rm -rf extension/
-./pack.sh
-
-mv node_modules{_saved,}
diff --git a/packages/taler-wallet-webextension/encode.mjs
b/packages/taler-wallet-webextension/encode.mjs
deleted file mode 100644
index 16de7f64..00000000
--- a/packages/taler-wallet-webextension/encode.mjs
+++ /dev/null
@@ -1,3 +0,0 @@
-import {encodeCrock, stringToBytes} from "../taler-util/lib/talerCrypto.js";
-const pepe =process.argv[2]
-console.log(pepe, encodeCrock(stringToBytes(pepe)));
diff --git a/packages/taler-wallet-webextension/esbuild.sh
b/packages/taler-wallet-webextension/esbuild.sh
new file mode 100755
index 00000000..202012e7
--- /dev/null
+++ b/packages/taler-wallet-webextension/esbuild.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+set -e
+
+#rm -rf dist lib tsconfig.tsbuildinfo .linaria-cache
+
+echo typecheck and bundle...
+node build-fast-with-linaria.mjs &
+pnpm tsc --noEmit &
+wait
+
+echo testing...
+pnpm test -- -R dot
+
+echo packing...
+rm -rf extension/
+./pack.sh
diff --git a/packages/taler-wallet-webextension/pack.sh
b/packages/taler-wallet-webextension/pack.sh
index a3876f4c..4fb41999 100755
--- a/packages/taler-wallet-webextension/pack.sh
+++ b/packages/taler-wallet-webextension/pack.sh
@@ -15,14 +15,14 @@ zipfile="taler-wallet-webextension-${vers_manifest}.zip"
TEMP_DIR=$(mktemp -d)
jq '. | .name = "GNU Taler Wallet" ' manifest-v2.json > $TEMP_DIR/manifest.json
cp -r dist static $TEMP_DIR
-(cd $TEMP_DIR && zip -r "$zipfile" dist static manifest.json)
+(cd $TEMP_DIR && zip -q -r "$zipfile" dist static manifest.json)
mkdir -p extension/v2
mv "$TEMP_DIR/$zipfile" ./extension/v2/
rm -rf $TEMP_DIR
# also provide unpacked version
rm -rf extension/v2/unpacked
mkdir -p extension/v2/unpacked
-(cd extension/v2/unpacked && unzip ../$zipfile)
+(cd extension/v2/unpacked && unzip -q ../$zipfile)
echo "Packed webextension: extension/v2/$zipfile"
cp -rf src extension/v2/unpacked
@@ -33,12 +33,12 @@ zipfile="taler-wallet-webextension-${vers_manifest}.zip"
TEMP_DIR=$(mktemp -d)
jq '. | .name = "GNU Taler Wallet" ' manifest-v3.json > $TEMP_DIR/manifest.json
cp -r dist static $TEMP_DIR
-(cd $TEMP_DIR && zip -r "$zipfile" dist static manifest.json)
+(cd $TEMP_DIR && zip -q -r "$zipfile" dist static manifest.json)
mkdir -p extension/v3
mv "$TEMP_DIR/$zipfile" ./extension/v3/
rm -rf $TEMP_DIR
# also provide unpacked version
rm -rf extension/v3/unpacked
mkdir -p extension/v3/unpacked
-(cd extension/v3/unpacked && unzip ../$zipfile)
+(cd extension/v3/unpacked && unzip -q ../$zipfile)
echo "Packed webextension: extension/v3/$zipfile"
diff --git a/packages/taler-wallet-webextension/package.json
b/packages/taler-wallet-webextension/package.json
index eaad4a4f..f61a0390 100644
--- a/packages/taler-wallet-webextension/package.json
+++ b/packages/taler-wallet-webextension/package.json
@@ -37,6 +37,7 @@
"@babel/core": "7.13.16",
"@babel/plugin-transform-react-jsx-source": "^7.12.13",
"@babel/preset-typescript": "^7.13.0",
+ "@babel/runtime": "^7.17.8",
"@gnu-taler/pogen": "workspace:*",
"@linaria/babel-preset": "3.0.0-beta.4",
"@linaria/core": "3.0.0-beta.4",
@@ -85,4 +86,4 @@
"pogen": {
"domain": "taler-wallet-webex"
}
-}
\ No newline at end of file
+}
diff --git a/packages/taler-wallet-webextension/run-test-in-browser.html
b/packages/taler-wallet-webextension/run-test-in-browser.html
index 0c7d9f6f..b027c071 100644
--- a/packages/taler-wallet-webextension/run-test-in-browser.html
+++ b/packages/taler-wallet-webextension/run-test-in-browser.html
@@ -2,16 +2,18 @@
<html>
<head>
<title>Mocha Tests</title>
- <link rel="stylesheet" href="node_modules/mocha/mocha.css">
+ <link rel="stylesheet" href="node_modules/mocha/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="node_modules/mocha/mocha.js"></script>
- <script>mocha.setup('bdd')</script>
+ <script>
+ mocha.setup("bdd");
+ </script>
<!-- load code you want to test here -->
- <!-- script src="dist/stories.test.js"></script -->
+ <script src="dist/stories.test.js"></script>
<script src="dist/hooks/useTalerActionURL.test.js"></script>
<!-- load your test files here -->
@@ -20,4 +22,3 @@
</script>
</body>
</html>
-
diff --git a/packages/taler-wallet-webextension/src/NavigationBar.tsx
b/packages/taler-wallet-webextension/src/NavigationBar.tsx
index 85e1f188..680c34a9 100644
--- a/packages/taler-wallet-webextension/src/NavigationBar.tsx
+++ b/packages/taler-wallet-webextension/src/NavigationBar.tsx
@@ -24,10 +24,15 @@
/**
* Imports.
*/
-import { VNode, h } from "preact";
+import { h, VNode } from "preact";
import { JustInDevMode } from "./components/JustInDevMode";
-import { NavigationHeader, NavigationHeaderHolder } from "./components/styled";
+import {
+ NavigationHeader,
+ NavigationHeaderHolder,
+ SvgIcon,
+} from "./components/styled";
import { useTranslationContext } from "./context/translation";
+import settingsIcon from "./svg/settings_black_24dp.svg";
/**
* List of pages used by the wallet
@@ -72,7 +77,11 @@ export function PopupNavBar({ path = "" }: { path?: string
}): VNode {
</a>
<a />
<a href="/settings">
- <div class="settings-icon" title={i18n.str`Settings`} />
+ <SvgIcon
+ title={i18n.str`Settings`}
+ dangerouslySetInnerHTML={{ __html: settingsIcon }}
+ color="white"
+ />
</a>
</NavigationHeader>
);
diff --git
a/packages/taler-wallet-webextension/src/components/Banner.stories.tsx
b/packages/taler-wallet-webextension/src/components/Banner.stories.tsx
index 4d5b2220..258bd067 100644
--- a/packages/taler-wallet-webextension/src/components/Banner.stories.tsx
+++ b/packages/taler-wallet-webextension/src/components/Banner.stories.tsx
@@ -22,7 +22,7 @@
import { Banner } from "./Banner";
import { Fragment, h, VNode } from "preact";
import { Avatar } from "../mui/Avatar";
-import { Icon } from "./styled";
+import { Icon, SvgIcon } from "./styled";
import { Typography } from "../mui/Typography";
export default {
@@ -48,7 +48,7 @@ function Wrapper({ children }: any) {
);
}
function SignalWifiOffIcon({ ...rest }: any): VNode {
- return <Icon {...rest} />;
+ return <SvgIcon {...rest} />;
}
export const BasicExample = () => (
@@ -67,7 +67,7 @@ export const BasicExample = () => (
<Banner
elements={[
{
- icon: <SignalWifiOffIcon />,
+ icon: <SignalWifiOffIcon color="gray" />,
description: (
<Typography>
You have lost connection to the internet. This app is offline.
diff --git a/packages/taler-wallet-webextension/src/components/ErrorMessage.tsx
b/packages/taler-wallet-webextension/src/components/ErrorMessage.tsx
index 085bf0b8..d6765c13 100644
--- a/packages/taler-wallet-webextension/src/components/ErrorMessage.tsx
+++ b/packages/taler-wallet-webextension/src/components/ErrorMessage.tsx
@@ -15,7 +15,7 @@
*/
import { VNode, h, ComponentChildren } from "preact";
import { useState } from "preact/hooks";
-import arrowDown from "../../static/img/chevron-down.svg";
+import arrowDown from "../svg/chevron-down.svg";
import { ErrorBox } from "./styled";
export function ErrorMessage({
@@ -36,7 +36,10 @@ export function ErrorMessage({
setShowErrorDetail((v) => !v);
}}
>
- <img style={{ height: "1.5em" }} src={arrowDown} />
+ <div
+ style={{ height: "1.5em" }}
+ dangerouslySetInnerHTML={{ __html: arrowDown }}
+ />
</button>
)}
</div>
diff --git
a/packages/taler-wallet-webextension/src/components/ErrorTalerOperation.tsx
b/packages/taler-wallet-webextension/src/components/ErrorTalerOperation.tsx
index 38d6ec56..9fd8f7a0 100644
--- a/packages/taler-wallet-webextension/src/components/ErrorTalerOperation.tsx
+++ b/packages/taler-wallet-webextension/src/components/ErrorTalerOperation.tsx
@@ -16,7 +16,7 @@
import { TalerErrorDetail } from "@gnu-taler/taler-util";
import { Fragment, h, VNode } from "preact";
import { useState } from "preact/hooks";
-import arrowDown from "../../static/img/chevron-down.svg";
+import arrowDown from "../svg/chevron-down.svg";
import { useDevContext } from "../context/devContext";
import { ErrorBox } from "./styled";
@@ -45,12 +45,12 @@ export function ErrorTalerOperation({
setShowErrorDetail((v) => !v);
}}
>
- <img
+ <div
style={{
transform: !showErrorDetail ? undefined : "scaleY(-1)",
height: 24,
}}
- src={arrowDown}
+ dangerouslySetInnerHTML={{ __html: arrowDown }}
/>
</button>
)}
diff --git a/packages/taler-wallet-webextension/src/components/LogoHeader.tsx
b/packages/taler-wallet-webextension/src/components/LogoHeader.tsx
index 6c47dc92..57322161 100644
--- a/packages/taler-wallet-webextension/src/components/LogoHeader.tsx
+++ b/packages/taler-wallet-webextension/src/components/LogoHeader.tsx
@@ -15,6 +15,7 @@
*/
import { h } from "preact";
+import logo from "../svg/logo-2021.svg";
export function LogoHeader() {
return (
@@ -25,14 +26,10 @@ export function LogoHeader() {
margin: "2em",
}}
>
- <img
- style={{
- width: 150,
- height: 70,
- }}
- src="/static/img/logo-2021.svg"
- width="150"
- />
+ <div
+ style={{ width: 150, height: 70 }}
+ dangerouslySetInnerHTML={{ __html: logo }}
+ ></div>
</div>
);
}
diff --git
a/packages/taler-wallet-webextension/src/components/MultiActionButton.tsx
b/packages/taler-wallet-webextension/src/components/MultiActionButton.tsx
index 1f46cf82..866bd037 100644
--- a/packages/taler-wallet-webextension/src/components/MultiActionButton.tsx
+++ b/packages/taler-wallet-webextension/src/components/MultiActionButton.tsx
@@ -1,5 +1,5 @@
import { h, VNode } from "preact";
-import arrowDown from "../../static/img/chevron-down.svg";
+import arrowDown from "../svg/chevron-down.svg";
import { ButtonBoxPrimary, ButtonPrimary, ParagraphClickable } from "./styled";
import { useState } from "preact/hooks";
@@ -91,7 +91,10 @@ export function MultiActionButton({
borderBottomLeftRadius: 0,
}}
>
- <img style={{ height: 14 }} src={arrowDown} />
+ <div
+ style={{ height: 14 }}
+ dangerouslySetInnerHTML={{ __html: arrowDown }}
+ />
</ButtonPrimary>
</div>
);
diff --git a/packages/taler-wallet-webextension/src/components/styled/index.tsx
b/packages/taler-wallet-webextension/src/components/styled/index.tsx
index 608e4af7..13e3189f 100644
--- a/packages/taler-wallet-webextension/src/components/styled/index.tsx
+++ b/packages/taler-wallet-webextension/src/components/styled/index.tsx
@@ -778,9 +778,6 @@ export const WarningBox = styled(ErrorBox)`
border-color: #ffecb5;
`;
-import settingsIcon from "../../../static/img/settings_black_24dp.svg";
-import wifiIcon from "../../../static/img/wifi.svg";
-
export const NavigationHeaderHolder = styled.div`
width: 100%;
display: flex;
@@ -809,27 +806,25 @@ export const NavigationHeader = styled.div`
line-height: 35px;
}
- & > a > div.settings-icon {
- mask: url(${settingsIcon}) no-repeat center;
- background-color: white;
- width: 24px;
- height: 24px;
- margin-left: auto;
- margin-right: 8px;
- padding: 4px;
- }
& > a.active {
background-color: #f8faf7;
color: #0042b2;
font-weight: bold;
}
- & > a.active > div.settings-icon {
- background-color: #0042b2;
+`;
+
+export const SvgIcon = styled.div<{ color: string }>`
+ & > svg {
+ fill: ${({ color }) => color};
}
+ width: 24px;
+ height: 24px;
+ margin-left: auto;
+ margin-right: 8px;
+ padding: 4px;
`;
export const Icon = styled.div`
- mask: url(${wifiIcon}) no-repeat center;
background-color: gray;
width: 24px;
height: 24px;
diff --git
a/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.test.ts
b/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.test.ts
index 95c77cd7..082b3a05 100644
--- a/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.test.ts
+++ b/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.test.ts
@@ -17,11 +17,10 @@ import { useTalerActionURL } from "./useTalerActionURL"
import { mountHook } from "../test-utils";
import { IoCProviderForTesting } from "../context/iocContext";
import { h, VNode } from "preact";
-import { act } from "preact/test-utils";
+import { expect } from "chai";
describe('useTalerActionURL hook', () => {
- // eslint-disable-next-line jest/expect-expect
it('should be set url to undefined when dismiss', async () => {
const ctx = ({ children }: { children: any }): VNode => {
@@ -36,24 +35,25 @@ describe('useTalerActionURL hook', () => {
{
const [url] = result.current!
- if (url !== undefined) throw Error('invalid')
+ expect(url).undefined;
}
- await waitNextUpdate()
+ await waitNextUpdate("waiting for useEffect")
{
const [url] = result.current!
- if (url !== "asd") throw Error(`invalid: ${url}`)
+ expect(url).equals("asd");
}
- await act(() => {
- const [, setDismissed] = result.current!
- setDismissed(true)
- })
+ const [, setDismissed] = result.current!
+ setDismissed(true)
+
+ await waitNextUpdate("after dismiss")
{
const [url] = result.current!
if (url !== undefined) throw Error('invalid')
+ expect(url).undefined;
}
})
diff --git a/packages/taler-wallet-webextension/src/mui/Button.stories.tsx
b/packages/taler-wallet-webextension/src/mui/Button.stories.tsx
index a6863add..9750c6a9 100644
--- a/packages/taler-wallet-webextension/src/mui/Button.stories.tsx
+++ b/packages/taler-wallet-webextension/src/mui/Button.stories.tsx
@@ -21,8 +21,8 @@
import { Button } from "./Button";
import { Fragment, h } from "preact";
-import DeleteIcon from "../../static/img/delete_24px.svg";
-import SendIcon from "../../static/img/send_24px.svg";
+import DeleteIcon from "../svg/delete_24px.svg";
+import SendIcon from "../svg/send_24px.svg";
import { styled } from "@linaria/react";
export default {
diff --git a/packages/taler-wallet-webextension/babel.config-linaria.json
b/packages/taler-wallet-webextension/src/mui/index.stories.tsx
similarity index 74%
copy from packages/taler-wallet-webextension/babel.config-linaria.json
copy to packages/taler-wallet-webextension/src/mui/index.stories.tsx
index abf87db8..7755c6f6 100644
--- a/packages/taler-wallet-webextension/babel.config-linaria.json
+++ b/packages/taler-wallet-webextension/src/mui/index.stories.tsx
@@ -14,17 +14,14 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
- /**
+/**
*
* @author Sebastian Javier Marchano (sebasjm)
*/
-/*
- * Linaria need pre-process typscript files into javascript before running.
- * We choose to use the default preact-cli config.
- * This file should be used from @linaria/rollup plugin only
- */
-{
- "presets": [
- "preact-cli/babel",
- ]
-}
+
+import * as a1 from "./Button.stories";
+import * as a3 from "./Grid.stories";
+import * as a4 from "./Paper.stories";
+import * as a5 from "./TextField.stories";
+
+export default [a1, a3, a4, a5];
diff --git a/packages/taler-wallet-webextension/src/popup/BalancePage.tsx
b/packages/taler-wallet-webextension/src/popup/BalancePage.tsx
index 9de12da4..2dc0f81e 100644
--- a/packages/taler-wallet-webextension/src/popup/BalancePage.tsx
+++ b/packages/taler-wallet-webextension/src/popup/BalancePage.tsx
@@ -119,7 +119,7 @@ export function BalanceView({
{currencyWithNonZeroAmount.length > 0 && (
<MultiActionButton
label={(s) => (
- <i18n.Translate debug>Deposit {<span>{s}</span>}</i18n.Translate>
+ <i18n.Translate>Deposit {<span>{s}</span>}</i18n.Translate>
)}
actions={currencyWithNonZeroAmount}
onClick={(c) => goToWalletDeposit(c)}
diff --git a/packages/taler-wallet-webextension/src/stories.test.ts
b/packages/taler-wallet-webextension/src/stories.test.ts
index db697460..dc33dbde 100644
--- a/packages/taler-wallet-webextension/src/stories.test.ts
+++ b/packages/taler-wallet-webextension/src/stories.test.ts
@@ -20,6 +20,7 @@
*/
import * as popup from "./popup/index.stories";
import * as wallet from "./wallet/index.stories";
+import * as mui from "./mui/index.stories";
import { setupI18n } from "@gnu-taler/taler-util";
import { renderNodeOrBrowser } from "./test-utils";
@@ -40,7 +41,7 @@ function testThisStory(st: any): any {
}
describe("render every storybook example", () => {
- [popup, wallet].forEach(function testAll(st: any) {
+ [popup, wallet, mui].forEach(function testAll(st: any) {
if (Array.isArray(st.default)) {
st.default.forEach(testAll)
} else {
diff --git a/packages/taler-wallet-webextension/static/img/chevron-down.svg
b/packages/taler-wallet-webextension/src/svg/chevron-down.svg
similarity index 100%
rename from packages/taler-wallet-webextension/static/img/chevron-down.svg
rename to packages/taler-wallet-webextension/src/svg/chevron-down.svg
diff --git a/packages/taler-wallet-webextension/static/img/delete_24px.svg
b/packages/taler-wallet-webextension/src/svg/delete_24px.svg
similarity index 100%
rename from packages/taler-wallet-webextension/static/img/delete_24px.svg
rename to packages/taler-wallet-webextension/src/svg/delete_24px.svg
diff --git a/packages/taler-wallet-webextension/src/svg/logo-2021.svg
b/packages/taler-wallet-webextension/src/svg/logo-2021.svg
new file mode 100644
index 00000000..8c5ff3e5
--- /dev/null
+++ b/packages/taler-wallet-webextension/src/svg/logo-2021.svg
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 201 90">
+ <g fill="#0042b3" fill-rule="evenodd" stroke-width=".3">
+ <path d="M86.7 1.1c15.6 0 29 9.4 36 23.2h-5.9A35.1 35.1 0 0086.7 6.5C67
6.5 51 23.6 51 44.7c0 10.4 3.8 19.7 10 26.6a31.4 31.4 0 01-4.2 3A45.2 45.2 0
0146 44.7c0-24 18.2-43.6 40.7-43.6zm35.8 64.3a40.4 40.4 0 01-39 22.8c3-1.5
6-3.5 8.6-5.7a35.6 35.6 0 0024.6-17.1z" />
+ <path d="M64.2 1.1l3.1.1c-3 1.6-5.9 3.5-8.5 5.8a37.5 37.5 0 00-30.2 37.7c0
14.3 7.3 26.7 18 33.3a29.6 29.6 0 01-8.5.2c-9-8-14.6-20-14.6-33.5 0-24
18.2-43.6 40.7-43.6zm5.4 81.4a35.6 35.6 0 0024.6-17.1h5.9a40.4 40.4 0 01-39
22.8c3-1.5 5.9-3.5 8.5-5.7zm24.8-58.2a37 37 0 00-12.6-12.8 29.6 29.6 0
018.5-.2c4 3.6 7.4 8 9.9 13z" />
+ <path d="M41.8 1.1c1 0 2 0 3.1.2-3 1.5-5.9 3.4-8.5 5.6A37.5 37.5 0 006.1
44.7c0 21.1 16 38.3 35.7 38.3 12.6 0 23.6-7 30-17.6h5.8a40.4 40.4 0 01-35.8
23C19.3 88.4 1 68.8 1 44.7c0-24 18.2-43.6 40.7-43.6zm30.1 23.2a38.1 38.1 0
00-4.5-6.1c1.3-1.2 2.7-2.2 4.3-3 2.3 2.7 4.4 5.8 6 9.1z" />
+ </g>
+ <path d="M76.1 34.4h9.2v-5H61.9v5H71v26h5.1zM92.6 52.9h13.7l3
7.4h5.3l-12.7-31.2h-4.7L84.5 60.3h5.2zm11.8-4.9h-9.9l5-12.4zM123.8
29.4h-4.6v31h20.6v-5h-16zM166.5
29.4H145v31h21.6v-5H150v-8.3h14.5v-4.9h-14.5v-8h16.4zM191.2 39.5c0 1.6-.5
2.8-1.6 3.8s-2.6 1.4-4.4 1.4h-7.4V34.3h7.4c1.9 0 3.4.4 4.4 1.3 1 .9 1.6 2.2 1.6
3.9zm6 20.8l-7.7-11.7c1-.3 1.9-.7 2.7-1.3a8.8 8.8 0 003.6-4.6c.4-1 .5-2.2.5-3.5
0-1.5-.2-2.9-.7-4.1a8.4 8.4 0
00-2.1-3.1c-1-.8-2-1.5-3.4-2-1.3-.4-2.8-.6-4.5-.6h-12.9v31h5V49.4 [...]
+</svg>
\ No newline at end of file
diff --git a/packages/taler-wallet-webextension/static/img/ri-bank-line.svg
b/packages/taler-wallet-webextension/src/svg/ri-bank-line.svg
similarity index 100%
rename from packages/taler-wallet-webextension/static/img/ri-bank-line.svg
rename to packages/taler-wallet-webextension/src/svg/ri-bank-line.svg
diff --git
a/packages/taler-wallet-webextension/static/img/ri-file-unknown-line.svg
b/packages/taler-wallet-webextension/src/svg/ri-file-unknown-line.svg
similarity index 100%
rename from
packages/taler-wallet-webextension/static/img/ri-file-unknown-line.svg
rename to packages/taler-wallet-webextension/src/svg/ri-file-unknown-line.svg
diff --git
a/packages/taler-wallet-webextension/static/img/ri-hand-heart-line.svg
b/packages/taler-wallet-webextension/src/svg/ri-hand-heart-line.svg
similarity index 100%
rename from packages/taler-wallet-webextension/static/img/ri-hand-heart-line.svg
rename to packages/taler-wallet-webextension/src/svg/ri-hand-heart-line.svg
diff --git a/packages/taler-wallet-webextension/static/img/ri-refresh-line.svg
b/packages/taler-wallet-webextension/src/svg/ri-refresh-line.svg
similarity index 100%
rename from packages/taler-wallet-webextension/static/img/ri-refresh-line.svg
rename to packages/taler-wallet-webextension/src/svg/ri-refresh-line.svg
diff --git a/packages/taler-wallet-webextension/static/img/ri-refund-2-line.svg
b/packages/taler-wallet-webextension/src/svg/ri-refund-2-line.svg
similarity index 100%
rename from packages/taler-wallet-webextension/static/img/ri-refund-2-line.svg
rename to packages/taler-wallet-webextension/src/svg/ri-refund-2-line.svg
diff --git
a/packages/taler-wallet-webextension/static/img/ri-shopping-cart-line.svg
b/packages/taler-wallet-webextension/src/svg/ri-shopping-cart-line.svg
similarity index 100%
rename from
packages/taler-wallet-webextension/static/img/ri-shopping-cart-line.svg
rename to packages/taler-wallet-webextension/src/svg/ri-shopping-cart-line.svg
diff --git a/packages/taler-wallet-webextension/static/img/send_24px.svg
b/packages/taler-wallet-webextension/src/svg/send_24px.svg
similarity index 100%
rename from packages/taler-wallet-webextension/static/img/send_24px.svg
rename to packages/taler-wallet-webextension/src/svg/send_24px.svg
diff --git
a/packages/taler-wallet-webextension/static/img/settings_black_24dp.svg
b/packages/taler-wallet-webextension/src/svg/settings_black_24dp.svg
similarity index 100%
rename from
packages/taler-wallet-webextension/static/img/settings_black_24dp.svg
rename to packages/taler-wallet-webextension/src/svg/settings_black_24dp.svg
diff --git a/packages/taler-wallet-webextension/static/img/spinner-bars.svg
b/packages/taler-wallet-webextension/src/svg/spinner-bars.svg
similarity index 100%
rename from packages/taler-wallet-webextension/static/img/spinner-bars.svg
rename to packages/taler-wallet-webextension/src/svg/spinner-bars.svg
diff --git a/packages/taler-wallet-webextension/static/img/wifi.svg
b/packages/taler-wallet-webextension/src/svg/wifi.svg
similarity index 100%
rename from packages/taler-wallet-webextension/static/img/wifi.svg
rename to packages/taler-wallet-webextension/src/svg/wifi.svg
diff --git a/packages/taler-wallet-webextension/src/test-utils.ts
b/packages/taler-wallet-webextension/src/test-utils.ts
index 30b37ab8..24dba8c7 100644
--- a/packages/taler-wallet-webextension/src/test-utils.ts
+++ b/packages/taler-wallet-webextension/src/test-utils.ts
@@ -14,10 +14,16 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { PendingTestFunction, TestFunction } from "mocha";
-import { ComponentChildren, Fragment, FunctionalComponent, h as create, render
as renderIntoDom, VNode } from "preact";
+import { ComponentChildren, Fragment, FunctionalComponent, h as create,
options, render as renderIntoDom, VNode } from "preact";
import { render as renderToString } from "preact-render-to-string";
+// When doing tests we want the requestAnimationFrame to be as fast as
possible.
+// without this option the RAF will timeout after 100ms making the tests slower
+options.requestAnimationFrame = (fn: () => void) => {
+ // console.log("RAF called")
+ return fn()
+}
+
export function createExample<Props>(
Component: FunctionalComponent<Props>,
props: Partial<Props>,
@@ -59,7 +65,7 @@ export function renderNodeOrBrowser(Component: any, args:
any): void {
interface Mounted<T> {
unmount: () => void;
result: { current: T | null };
- waitNextUpdate: () => Promise<void>;
+ waitNextUpdate: (s?: string) => Promise<void>;
}
const isNode = typeof window === "undefined"
@@ -84,10 +90,11 @@ export function mountHook<T>(callback: () => T, Context?:
({ children }: { child
const vdom = !Context ? create(Component, {}) : create(Context, { children:
[create(Component, {})] },);
// waiter callback
- async function waitNextUpdate(): Promise<void> {
+ async function waitNextUpdate(_label = ""): Promise<void> {
+ if (_label) _label = `. label: "${_label}"`
await new Promise((res, rej) => {
const tid = setTimeout(() => {
- rej(Error("waiting for an update but the hook didn't make one"))
+ rej(Error(`waiting for an update but the hook didn't make
one${_label}`))
}, 100)
listener.push(() => {
diff --git
a/packages/taler-wallet-webextension/src/wallet/ManualWithdrawPage.tsx
b/packages/taler-wallet-webextension/src/wallet/ManualWithdrawPage.tsx
index 05c51850..bea8f002 100644
--- a/packages/taler-wallet-webextension/src/wallet/ManualWithdrawPage.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/ManualWithdrawPage.tsx
@@ -19,6 +19,8 @@ import {
AmountJson,
Amounts,
NotificationType,
+ parsePaytoUri,
+ PaytoUri,
} from "@gnu-taler/taler-util";
import { h, VNode } from "preact";
import { useState } from "preact/hooks";
@@ -41,6 +43,8 @@ export function ManualWithdrawPage({ currency, onCancel }:
Props): VNode {
response: AcceptManualWithdrawalResult;
exchangeBaseUrl: string;
amount: AmountJson;
+ paytoURI: PaytoUri | undefined;
+ payto: string;
}
| undefined
>(undefined);
@@ -60,7 +64,12 @@ export function ManualWithdrawPage({ currency, onCancel }:
Props): VNode {
exchangeBaseUrl,
Amounts.stringify(amount),
);
- setSuccess({ exchangeBaseUrl, response, amount });
+ const payto = response.exchangePaytoUris[0];
+ const paytoURI = parsePaytoUri(payto);
+ if (paytoURI && paytoURI.isKnown && paytoURI.targetType === "bitcoin") {
+ paytoURI.generateSegwitAddress(response.reservePub);
+ }
+ setSuccess({ exchangeBaseUrl, response, amount, paytoURI, payto });
} catch (e) {
if (e instanceof Error) {
setError(e.message);
@@ -75,7 +84,8 @@ export function ManualWithdrawPage({ currency, onCancel }:
Props): VNode {
return (
<ReserveCreated
reservePub={success.response.reservePub}
- payto={success.response.exchangePaytoUris[0]}
+ paytoURI={success.paytoURI}
+ payto={success.payto}
exchangeBaseUrl={success.exchangeBaseUrl}
amount={success.amount}
onCancel={onCancel}
diff --git a/packages/taler-wallet-webextension/src/wallet/ReserveCreated.tsx
b/packages/taler-wallet-webextension/src/wallet/ReserveCreated.tsx
index 526daa7a..84a2a744 100644
--- a/packages/taler-wallet-webextension/src/wallet/ReserveCreated.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/ReserveCreated.tsx
@@ -4,6 +4,7 @@ import {
Amounts,
segwitMinAmount,
generateFakeSegwitAddress,
+ PaytoUri,
} from "@gnu-taler/taler-util";
import { Fragment, h, VNode } from "preact";
import { BankDetailsByPaytoType } from "../components/BankDetailsByPaytoType";
@@ -13,6 +14,7 @@ import { useTranslationContext } from
"../context/translation";
import { amountToString } from "../utils/index";
export interface Props {
reservePub: string;
+ paytoURI: PaytoUri | undefined;
payto: string;
exchangeBaseUrl: string;
amount: AmountJson;
@@ -21,13 +23,13 @@ export interface Props {
export function ReserveCreated({
reservePub,
+ paytoURI,
payto,
onCancel,
exchangeBaseUrl,
amount,
}: Props): VNode {
const { i18n } = useTranslationContext();
- const paytoURI = parsePaytoUri(payto);
if (!paytoURI) {
return (
<div>
@@ -39,11 +41,7 @@ export function ReserveCreated({
}
function TransferDetails(): VNode {
if (!paytoURI) return <Fragment />;
- if (paytoURI.targetType === "bitcoin") {
- const { segwitAddr1, segwitAddr2 } = generateFakeSegwitAddress(
- reservePub,
- paytoURI.targetPath,
- );
+ if (paytoURI.isKnown && paytoURI.targetType === "bitcoin") {
const min = segwitMinAmount();
return (
<section>
@@ -64,10 +62,10 @@ export function ReserveCreated({
{paytoURI.targetPath} {Amounts.stringifyValue(amount)} BTC
</li>
<li>
- {segwitAddr1} {Amounts.stringifyValue(min)} BTC
+ {paytoURI.addr1} {Amounts.stringifyValue(min)} BTC
</li>
<li>
- {segwitAddr2} {Amounts.stringifyValue(min)} BTC
+ {paytoURI.addr2} {Amounts.stringifyValue(min)} BTC
</li>
</ul>
<i18n.Translate>
@@ -79,10 +77,10 @@ export function ReserveCreated({
{paytoURI.targetPath},{Amounts.stringifyValue(amount)}
</li>
<li>
- {segwitAddr1},{Amounts.stringifyValue(min)}
+ {paytoURI.addr1},{Amounts.stringifyValue(min)}
</li>
<li>
- {segwitAddr2},{Amounts.stringifyValue(min)}
+ {paytoURI.addr2},{Amounts.stringifyValue(min)}
</li>
</ul>
<i18n.Translate>
diff --git a/packages/taler-wallet-webextension/static/img/logo-2021.svg
b/packages/taler-wallet-webextension/static/img/logo-2021.svg
deleted file mode 100644
index e72611eb..00000000
--- a/packages/taler-wallet-webextension/static/img/logo-2021.svg
+++ /dev/null
@@ -1 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg
xmlns="http://www.w3.org/2000/svg" width="670" height="300" viewBox="0 0 201
90"><g fill="#0042b3" fill-rule="evenodd" stroke-width=".3"><path d="M86.7
1.1c15.6 0 29 9.4 36 23.2h-5.9A35.1 35.1 0 0086.7 6.5C67 6.5 51 23.6 51 44.7c0
10.4 3.8 19.7 10 26.6a31.4 31.4 0 01-4.2 3A45.2 45.2 0 0146 44.7c0-24 18.2-43.6
40.7-43.6zm35.8 64.3a40.4 40.4 0 01-39 22.8c3-1.5 6-3.5 8.6-5.7a35.6 35.6 0
0024.6-17.1z"/><path d="M64.2 1.1l3.1.1c-3 1.6 [...]
\ No newline at end of file
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index d16a9b05..8197c836 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -325,6 +325,7 @@ importers:
'@babel/core': 7.13.16
'@babel/plugin-transform-react-jsx-source': ^7.12.13
'@babel/preset-typescript': ^7.13.0
+ '@babel/runtime': ^7.17.8
'@gnu-taler/pogen': workspace:*
'@gnu-taler/taler-util': workspace:*
'@gnu-taler/taler-wallet-core': workspace:*
@@ -384,6 +385,7 @@ importers:
'@babel/core': 7.13.16
'@babel/plugin-transform-react-jsx-source': 7.14.5_@babel+core@7.13.16
'@babel/preset-typescript': 7.15.0_@babel+core@7.13.16
+ '@babel/runtime': 7.17.8
'@gnu-taler/pogen': link:../pogen
'@linaria/babel-preset': 3.0.0-beta.4_@babel+core@7.13.16
'@linaria/core': 3.0.0-beta.4
@@ -3000,6 +3002,13 @@ packages:
regenerator-runtime: 0.13.9
dev: true
+ /@babel/runtime/7.17.8:
+ resolution: {integrity:
sha512-dQpEpK0O9o6lj6oPu0gRDbbnk+4LeHlNcBpspf6Olzt3GIX4P1lWF1gS+pHLDFlaJvbR6q7jCfQ08zA4QJBnmA==}
+ engines: {node: '>=6.9.0'}
+ dependencies:
+ regenerator-runtime: 0.13.9
+ dev: true
+
/@babel/template/7.14.5:
resolution: {integrity:
sha512-6Z3Po85sfxRGachLULUhOmvAaOo7xCvqGQtxINai2mEGPFm6pQ4z5QInFnUrRpfoSV60BnjyF5F3c+15fxFV1g==}
engines: {node: '>=6.9.0'}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: esbuild configuration,
gnunet <=