android support skeleton
This commit is contained in:
parent
204c10c007
commit
da6b6e1049
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "taler-wallet",
|
||||
"version": "0.6.1",
|
||||
"version": "0.6.2",
|
||||
"description": "",
|
||||
"main": "dist/node/index.js",
|
||||
"repository": {
|
||||
@ -9,6 +9,9 @@
|
||||
},
|
||||
"author": "Florian Dold",
|
||||
"license": "GPL-3.0",
|
||||
"bin": {
|
||||
"taler-wallet-cli": "./bin/taler-wallet-cli"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/moment": "^2.13.0",
|
||||
"@types/react": "^16.4.0",
|
||||
|
63
src/android/index.ts
Normal file
63
src/android/index.ts
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
This file is part of GNU Taler
|
||||
(C) 2019 GNUnet e.V.
|
||||
|
||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
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/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { Wallet } from "../wallet";
|
||||
import { getDefaultNodeWallet } from "../headless/helpers";
|
||||
|
||||
|
||||
class AndroidWalletHelper {
|
||||
wallet: Wallet | undefined;
|
||||
constructor (private sendMessage: (m: any) => void) {
|
||||
}
|
||||
|
||||
async init() {
|
||||
this.wallet = await getDefaultNodeWallet();
|
||||
}
|
||||
}
|
||||
|
||||
export function installAndroidWalletListener() {
|
||||
// @ts-ignore
|
||||
const sendMessage: (m: any) => void = global.__akono_sendMessage;
|
||||
if (typeof sendMessage !== "function") {
|
||||
const errMsg = "FATAL: cannot install android wallet listener: akono functions missing";
|
||||
console.error(errMsg);
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
const walletHelper = new AndroidWalletHelper(sendMessage);
|
||||
const onMessage = (msg: any) => {
|
||||
const operation = msg.operation;
|
||||
if (typeof operation !== "string") {
|
||||
console.error("message to android wallet helper must contain operation of type string");
|
||||
return;
|
||||
}
|
||||
switch (operation) {
|
||||
case "init":
|
||||
break;
|
||||
case "getBalances":
|
||||
break;
|
||||
case "withdraw-testkudos":
|
||||
break;
|
||||
default:
|
||||
console.error(`operation "${operation}" not understood`);
|
||||
return;
|
||||
}
|
||||
};
|
||||
// @ts-ignore
|
||||
globalThis.__akono_onMessage = onMessage;
|
||||
}
|
@ -20,3 +20,4 @@
|
||||
|
||||
export { Wallet } from "./wallet";
|
||||
export { runIntegrationTest } from "./headless/integrationtest";
|
||||
export { installAndroidWalletListener } from "./android";
|
||||
|
24
yarn.lock
24
yarn.lock
@ -332,11 +332,6 @@
|
||||
dependencies:
|
||||
"@types/filesystem" "*"
|
||||
|
||||
"@types/estree@0.0.39":
|
||||
version "0.0.39"
|
||||
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
|
||||
integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==
|
||||
|
||||
"@types/events@*":
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
|
||||
@ -409,11 +404,6 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-11.12.0.tgz#ec5594728811dc2797e42396cfcdf786f2052c12"
|
||||
integrity sha512-Lg00egj78gM+4aE0Erw05cuDbvX9sLJbaaPwwRtdCdAMnIudqrQZ0oZX98Ek0yiSK/A2nubHgJfvII/rTT2Dwg==
|
||||
|
||||
"@types/node@^12.6.9":
|
||||
version "12.7.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.7.1.tgz#3b5c3a26393c19b400844ac422bd0f631a94d69d"
|
||||
integrity sha512-aK9jxMypeSrhiYofWWBf/T7O+KwaiAHzM4sveCdWPn71lzUSMimRnKzhXDKfKwV1kWoBo2P1aGgaIYGLf9/ljw==
|
||||
|
||||
"@types/prop-types@*":
|
||||
version "15.7.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.0.tgz#4c48fed958d6dcf9487195a0ef6456d5f6e0163a"
|
||||
@ -631,11 +621,6 @@ acorn@^6.0.5, acorn@^6.0.7:
|
||||
resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.1.1.tgz#7d25ae05bb8ad1f9b699108e1094ecd7884adc1f"
|
||||
integrity sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==
|
||||
|
||||
acorn@^6.2.1:
|
||||
version "6.3.0"
|
||||
resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.3.0.tgz#0087509119ffa4fc0a0041d1e93a417e68cb856e"
|
||||
integrity sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA==
|
||||
|
||||
ajv-errors@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-1.0.1.tgz#f35986aceb91afadec4102fbd85014950cefa64d"
|
||||
@ -5560,15 +5545,6 @@ ripemd160@^2.0.0, ripemd160@^2.0.1:
|
||||
hash-base "^3.0.0"
|
||||
inherits "^2.0.1"
|
||||
|
||||
rollup@^1.19.4:
|
||||
version "1.19.4"
|
||||
resolved "https://registry.yarnpkg.com/rollup/-/rollup-1.19.4.tgz#0cb4e4d6fa127adab59b11d0be50e8dd1c78123a"
|
||||
integrity sha512-G24w409GNj7i/Yam2cQla6qV2k6Nug8bD2DZg9v63QX/cH/dEdbNJg8H4lUm5M1bRpPKRUC465Rm9H51JTKOfQ==
|
||||
dependencies:
|
||||
"@types/estree" "0.0.39"
|
||||
"@types/node" "^12.6.9"
|
||||
acorn "^6.2.1"
|
||||
|
||||
run-queue@^1.0.0, run-queue@^1.0.3:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/run-queue/-/run-queue-1.0.3.tgz#e848396f057d223f24386924618e25694161ec47"
|
||||
|
Loading…
Reference in New Issue
Block a user