aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile16
-rwxr-xr-xconfigure57
-rw-r--r--src/android/index.ts26
4 files changed, 91 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index 7f18bfd70..99ac470ff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,5 @@ node_modules
yarn-error.log
npm-packages-offline-cache/
+
+config.mk
diff --git a/Makefile b/Makefile
index 06241581e..efb3e7cb0 100644
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,7 @@ ava = node_modules/ava/cli.js
nyc = node_modules/nyc/bin/nyc.js
tslint = node_modules/tslint/bin/tslint
+-include config.mk
.PHONY: package-stable
package-stable: i18n
@@ -40,7 +41,6 @@ typedoc:
.PHONY: clean
clean:
- rm -rf build/
rm -rf dist/
.PHONY: check
@@ -70,3 +70,17 @@ i18n: yarn-install
done;
# generate .ts file containing all translations
$(gulp) po2js
+
+
+ifndef prefix
+.PHONY: install
+install:
+ @echo "no prefix configured, did you run ./configure?"
+else
+.PHONY: install
+install:
+ @echo "installing to" $(prefix)
+ npm install -g --prefix $(prefix) .
+endif
+
+
diff --git a/configure b/configure
index 3ec6d4d12..ede3a9164 100755
--- a/configure
+++ b/configure
@@ -2,6 +2,63 @@
set -eu
+prefix=/usr/local
+
+usage() {
+ echo "Usage: ./configure [OPTION]"
+ echo
+ echo "Configuration:"
+ echo " -h, --help display this help and exit"
+ echo
+ echo "Installation directories:"
+ echo " --prefix=PREFIX install architecture-independent files in PREFIX [$prefix]"
+}
+
+
+# -allow a command to fail with !’s side effect on errexit
+# -use return value from ${PIPESTATUS[0]}, because ! hosed $?
+! getopt --test > /dev/null
+if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
+ echo 'getopt not available'
+ exit 1
+fi
+
+LONGOPTS=prefix:,help
+OPTIONS=h
+
+! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@")
+if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
+ # e.g. return value is 1
+ # then getopt has complained about wrong arguments to stdout
+ exit 2
+fi
+
+# read getopt’s output this way to handle the quoting right:
+eval set -- "$PARSED"
+
+while true; do
+ case "$1" in
+ --prefix)
+ prefix="$2"
+ shift 2
+ ;;
+ -h|--help)
+ usage
+ exit 1
+ ;;
+ --)
+ shift
+ break
+ ;;
+ *)
+ echo "Programming error"
+ exit 3
+ ;;
+ esac
+done
+
+echo "prefix=$prefix" >config.mk
+
node_version=$(node --version)
if [ ! "$?" -eq 0 ]; then
echo 'Error: node executable not found.'
diff --git a/src/android/index.ts b/src/android/index.ts
index 3e7eeb645..abf065a8a 100644
--- a/src/android/index.ts
+++ b/src/android/index.ts
@@ -20,14 +20,12 @@
import { Wallet } from "../wallet";
import { getDefaultNodeWallet } from "../headless/helpers";
-
class AndroidWalletHelper {
- wallet: Wallet | undefined;
- constructor (private sendMessage: (m: any) => void) {
- }
+ walletPromise: Promise<Wallet> | undefined;
+ constructor() {}
async init() {
- this.wallet = await getDefaultNodeWallet();
+ this.walletPromise = getDefaultNodeWallet();
}
}
@@ -35,19 +33,25 @@ 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";
+ const errMsg =
+ "FATAL: cannot install android wallet listener: akono functions missing";
console.error(errMsg);
throw new Error(errMsg);
}
- const walletHelper = new AndroidWalletHelper(sendMessage);
+ const walletHelper = new AndroidWalletHelper();
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");
+ console.error(
+ "message to android wallet helper must contain operation of type string",
+ );
return;
}
+ const id = msg.id;
+ let result;
switch (operation) {
case "init":
+ result = walletHelper.init();
break;
case "getBalances":
break;
@@ -57,7 +61,11 @@ export function installAndroidWalletListener() {
console.error(`operation "${operation}" not understood`);
return;
}
+
+ const respMsg = { result, id };
+ console.log("sending message back", respMsg);
+ sendMessage(respMsg);
};
// @ts-ignore
globalThis.__akono_onMessage = onMessage;
-} \ No newline at end of file
+}