Skip to content

Commit

Permalink
Merge pull request #22 from Runebase/Abstraction
Browse files Browse the repository at this point in the history
Abstraction
  • Loading branch information
bobpepers authored Dec 19, 2023
2 parents f78f715 + 8187ad0 commit 883ca2a
Show file tree
Hide file tree
Showing 20 changed files with 252 additions and 200 deletions.
38 changes: 36 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,43 @@ for cmd in yarn jq zip cordova electron-builder webpack; do
fi
done

# Define version for chrome extension zip
# Determine the release type (patch, minor, major)
release_type=${1:-patch} # Default to 'patch' if no argument is provided

# Read the current version from main package.json
current_version=$(jq -r .version package.json)

# Increment version based on the release type
if [ "$release_type" = "patch" ]; then
new_version=$(echo "$current_version" | awk -F. '{print $1 "." $2 "." $3 + 1}')
elif [ "$release_type" = "minor" ]; then
new_version=$(echo "$current_version" | awk -F. '{print $1 "." $2 + 1 ".0"}')
elif [ "$release_type" = "major" ]; then
new_version=$(echo "$current_version" | awk -F. '{print $1 + 1 ".0.0"}')
else
echo "Error: Invalid release type. Please use 'patch', 'minor', or 'major'."
exit 1
fi

# Update version in main package.json
jq --arg new_version "$new_version" '.version = $new_version' package.json > tmp_package.json && mv tmp_package.json package.json

# Update version in cordova/package.json
jq --arg new_version "$new_version" '.version = $new_version' cordova/package.json > tmp_cordova_package.json && mv tmp_cordova_package.json cordova/package.json

# Update version in config.xml
sed -i "s/version=\"[0-9.]*\"/version=\"$new_version\"/" cordova/config.xml

# Update android-versionCode in config.xml
android_version_code=$(echo "$new_version" | tr -d .)
sed -i "s/android-versionCode=\"[0-9]*\"/android-versionCode=\"$android_version_code\"/" cordova/config.xml

# Get the updated version
version=$(jq -r .version package.json)

# Bump version in static/manifest (adjust the path as needed)
sed -i "s/\"version\": \".*\"/\"version\": \"$version\"/" static/manifest.json

# Clean and prepare directories
yarn clean
mkdir -p dist
Expand Down Expand Up @@ -62,4 +96,4 @@ cp -r dist-electron/*.AppImage "$compiled_dir"
cp -r dist-electron/*.exe "$compiled_dir"

# Display a message indicating where the compiled files are located
echo "Compiled files are in the '$compiled_dir' directory."
echo "Compiled files are in the '$compiled_dir' directory."
2 changes: 1 addition & 1 deletion cordova/config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.runebase.runebaselitewallet" version="1.6.5" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" android-versionCode="165">
<widget id="io.runebase.runebaselitewallet" version="1.6.7" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" android-versionCode="167">
<name>Runebase Lite Wallet</name>
<description>A lightweight wallet and transaction signing client for the Runebase network</description>
<author email="[email protected]" href="https://www.runebase.io">Bago</author>
Expand Down
4 changes: 2 additions & 2 deletions cordova/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "io.runebase.runebaselitewallet",
"displayName": "Runebase Lite Wallet",
"version": "1.6.6",
"version": "1.6.7",
"description": "A Runebase Lite Wallet",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -30,4 +30,4 @@
"cordova-plugin-file": "^8.0.1",
"cordova-plugin-qrscanner-androidx": "^3.0.6"
}
}
}
113 changes: 36 additions & 77 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
"name": "Runebase-Lite-Wallet",
"description": "LightWeight wallet for the Runebase blockchain",
"author": "Bago",
"version": "1.6.6",
"version": "1.6.7",
"private": true,
"scripts": {
"clean": "rm -rf dist",
"start": "yarn clean && mkdir dist && ./scripts/create-empty-thunk.sh && webpack --progress --config webpack.dev.config.js --watch --devtool source-map & yarn css-types -w",
"build": "./build.sh",
"release:patch": "./build.sh patch",
"release:minor": "./build.sh minor",
"release:major": "./build.sh major",
"build:cordova:release": "cd cordova && cordova build android --release",
"start:cordova": "cd cordova && cordova run android",
"start:electron": "electron ./electron/main.js",
Expand Down Expand Up @@ -107,7 +109,7 @@
"react-dom": "^18.2.0",
"runebasejs-lib": "github:runebase/runebasejs-lib#dc7680e7800a2b7329760e78d842671e61573247",
"runebasejs-wallet": "github:runebase/runebasejs-wallet#7a034eff515236abcca5bf2515a65a2e4a73364f",
"rweb3": "github:runebase/rweb3.js#3ab0414adaabcd52aad2f1c1fd0f2f9f81c67dde",
"rweb3": "github:Runebase/rweb3.js#1758e789623f9f707938c2bbc3a05c3ce92f2388",
"secp256k1": "^5.0.0",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
Expand Down
36 changes: 33 additions & 3 deletions src/background/controllers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import SessionController from './sessionController';
import OnInstallController from './onInstallController';
import { API_TYPE, MESSAGE_TYPE } from '../../constants';
import UtilsController from './utilsController';
import { sendMessage } from '../../popup/abstraction';
import { MessageCallback, sendMessage } from '../../popup/abstraction';

interface ConnectListenerOptions {
onMessage: MessageCallback;
onDisconnect?: () => void; // New optional callback for disconnect events
}

export default class RunebaseChromeController {
public crypto: CryptoController;
Expand Down Expand Up @@ -84,14 +89,39 @@ export default class RunebaseChromeController {
if (every(this.initialized)) {
sendMessage({
type: MESSAGE_TYPE.ROUTE_LOGIN
}, () => {});
});
}
};

public displayErrorOnPopup = (err: Error) => {
sendMessage({
type: MESSAGE_TYPE.UNEXPECTED_ERROR,
error: err.message
}, () => {});
});
};


public addConnectListener =(options: ConnectListenerOptions): void => {
if (
typeof chrome !== 'undefined'
&& chrome.runtime
&& chrome.runtime.onConnect
) {
// Chrome extension compatible implementation
chrome.runtime.onConnect.addListener((port) => {
port.onMessage.addListener((message) => {
options.onMessage(message);
});
if (options.onDisconnect) {
port.onDisconnect.addListener(options.onDisconnect);
}
sendMessage({ type: MESSAGE_TYPE.POPUP_OPENED });
});
} else if (typeof window !== 'undefined') {
// Web-compatible implementation
window.addEventListener('message', (event: MessageEvent) => {
options.onMessage(event.data);
});
}
};
}
4 changes: 1 addition & 3 deletions src/background/controllers/inpageAccountController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ import RunebaseChromeController from '.';
import IController from './iController';
import { MESSAGE_TYPE, PORT_NAME, RUNEBASECHROME_ACCOUNT_CHANGE } from '../../constants';
import { InpageAccount } from '../../models/InpageAccount';
import { addConnectListener } from '../../popup/abstraction';

export default class InpageAccountController extends IController {
// All connected ports from content script
private ports: chrome.runtime.Port[] = [];

constructor(main: RunebaseChromeController) {
super('inpageAccount', main);
addConnectListener({
this.main.addConnectListener({
onMessage: this.handleLongLivedConnection,
});
// chrome.runtime.onConnect.addListener(this.handleLongLivedConnection);

this.initFinished();
}
Expand Down
Loading

0 comments on commit 883ca2a

Please sign in to comment.